Get breakpoint filename and line number from DWARF

This commit is contained in:
2025-03-12 11:37:23 +01:00
parent dc66bc84ae
commit d4fdd69c48
3 changed files with 34 additions and 16 deletions

View File

@@ -152,6 +152,7 @@ typedef struct {
HashTable brks;
uintptr_t program_load_offset;
HashTable js_descs;
PLibelfinBinding plibelfin;
} Dbg;
siginfo_t dbg_get_siginfo(Dbg *dbg)
@@ -178,10 +179,9 @@ void dbg_handle_sigtrap(Dbg *dbg, siginfo_t info)
case SI_KERNEL:
case TRAP_BRKPT:
dbg_set_rip(dbg, dbg_get_rip(dbg) - 1);
ai = libelfin_wrap_info_from_rip(dbg_get_rip(dbg));
ai = libelfin_wrap_info_from_rip(dbg->plibelfin, dbg_get_rip(dbg) - (uint64_t)dbg->program_load_offset);
if (ai != NULL) {
LOG_INF("Hit breakpoint at 0x%"PRIxPTR", %s:%zu\n", dbg_get_rip(dbg),
ai->file, (size_t)ai->line);
LOG_INF("Hit breakpoint at 0x%"PRIxPTR", %s:%zu\n", dbg_get_rip(dbg), ai->file, (size_t)ai->line);
libelfin_wrap_free_info(ai);
} else {
LOG_INF("Hit breakpoint at 0x%"PRIxPTR"\n", dbg_get_rip(dbg));
@@ -538,7 +538,7 @@ void dbg_libelfin_wrap_init(Dbg *dbg)
return;
}
libelfin_wrap_init(fileno(bin));
dbg->plibelfin = libelfin_wrap_get_binding(fileno(bin));
fclose(bin);
}
@@ -561,6 +561,7 @@ void dbg_deinit(Dbg *dbg)
js_freestate(dbg->js);
hashtable_deinit(&dbg->brks);
hashtable_deinit(&dbg->js_descs);
libelfin_wrap_free_binding(dbg->plibelfin);
}
void dbg_loop(Dbg *dbg)