mirror of
https://github.com/kichikuou/xsystem35-sdl2.git
synced 2026-10-01 11:18:22 +03:00
Debugger: Support more ways to specify breakpoint locations
- `break function` sets a breakpoint to the entry of `function`, which is either a global function or a local function in current page. - `break number` sets a breakpoint to the specified line in current file.
This commit is contained in:
@@ -353,3 +353,19 @@ const char *dsym_addr2func(struct debug_symbols *dsym, int page, int addr) {
|
||||
assert(f->addr <= addr);
|
||||
return f->name;
|
||||
}
|
||||
|
||||
boolean dsym_func2addr(struct debug_symbols *dsym, const char *name, int *inout_page, int *out_addr) {
|
||||
if (!dsym)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < dsym->nr_funcs; i++) {
|
||||
if (dsym->functions[i].is_local && dsym->functions[i].page != *inout_page)
|
||||
continue;
|
||||
if (!strcmp(dsym->functions[i].name, name)) {
|
||||
*inout_page = dsym->functions[i].page;
|
||||
*out_addr = dsym->functions[i].addr;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -32,5 +32,6 @@ int dsym_addr2line(struct debug_symbols *dsym, int page, int addr);
|
||||
const char *dsym_source_line(struct debug_symbols *dsym, int page, int line);
|
||||
int dsym_lookup_variable(struct debug_symbols *dsym, const char *name);
|
||||
const char *dsym_addr2func(struct debug_symbols *dsym, int page, int addr);
|
||||
boolean dsym_func2addr(struct debug_symbols *dsym, const char *name, int *inout_page, int *out_addr);
|
||||
|
||||
#endif // __DEBUG_SYMBOL_H__
|
||||
|
||||
+20
-3
@@ -94,7 +94,24 @@ static boolean parse_address(const char *str, int *page, int *addr) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO: accept function names.
|
||||
*page = sl_getPage();
|
||||
|
||||
// <linenum>
|
||||
char *endptr;
|
||||
line_no = strtol(str, &endptr, 0);
|
||||
if (!*endptr) {
|
||||
*addr = dsym_line2addr(symbols, sl_getPage(), line_no);
|
||||
if (*addr < 0) {
|
||||
printf("No line %d in current file.\n", line_no);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// <funcname>
|
||||
if (dsym_func2addr(symbols, str, page, addr))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -210,7 +227,7 @@ int dbg_handle_breakpoint(int page, int addr) {
|
||||
|
||||
if (bp->no != INTERNAL_BREAKPOINT_NO) {
|
||||
bp->ignore_next = true;
|
||||
printf("Breakpoint %d, %d:0x%x\n", bp->no, page, addr);
|
||||
printf("Breakpoint %d, %s\n", bp->no, format_address(page, addr, false));
|
||||
}
|
||||
dbg_trapped = true;
|
||||
return -1;
|
||||
@@ -251,7 +268,7 @@ static void cmd_break(void) {
|
||||
}
|
||||
Breakpoint *bp = set_breakpoint(page, addr, false);
|
||||
if (bp)
|
||||
printf("Breakpoint %d at %s\n", bp->no, arg);
|
||||
printf("Breakpoint %d at %s\n", bp->no, format_address(bp->page, bp->addr, false));
|
||||
}
|
||||
|
||||
static void cmd_delete(void) {
|
||||
|
||||
Reference in New Issue
Block a user