From f6cca76ee3c93091daf72f8351913f6b58f1a34c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Bastian?= Date: Sun, 9 Jun 2019 19:02:24 +0200 Subject: [PATCH] Enhance debug messages --- src/eh_elf/eh_elf.c | 12 ++++++++++-- src/x86_64/Gstep.c | 13 ++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/eh_elf/eh_elf.c b/src/eh_elf/eh_elf.c index 0bdc543b..b48af9a2 100644 --- a/src/eh_elf/eh_elf.c +++ b/src/eh_elf/eh_elf.c @@ -97,6 +97,12 @@ int set_dwarf_loc_ifdef( int eh_elf_step_cursor(struct cursor *cursor) { uintptr_t ip = cursor->dwarf.ip; + { + uintptr_t dbp; + dwarf_get(&cursor->dwarf, cursor->dwarf.loc[UNW_TDEP_BP], &dbp); + Debug (4, "AT ENTER bp=%016lx%s sp=%016lx ip=%016lx\n", dbp, + DWARF_IS_NULL_LOC(cursor->dwarf.loc[UNW_TDEP_BP])?" [NULL]":"", + cursor->dwarf.cfa, cursor->dwarf.ip); } // Retrieve memory map entry @@ -134,10 +140,12 @@ int eh_elf_step_cursor(struct cursor *cursor) { _fetch_state.last_rc = 0; _fetch_state.cur_rsp = cursor->dwarf.cfa; - Debug(4, "Unwinding in mmap entry %s at position 0x%lx (sp=%016lx)\n", + Debug(4, "Unwinding in mmap entry %s at position 0x%lx (sp=%016lx, bp=%016lx)\n", mmap_entry->object_name, ip - mmap_entry->offset, - eh_elf_context.rsp); + eh_elf_context.rsp, + eh_elf_context.rbp + ); eh_elf_context.flags = 0; // Call fde_func diff --git a/src/x86_64/Gstep.c b/src/x86_64/Gstep.c index 39cc473b..d4e48090 100644 --- a/src/x86_64/Gstep.c +++ b/src/x86_64/Gstep.c @@ -80,6 +80,13 @@ unw_step (unw_cursor_t *cursor) _step_id_data.orig_cfa = c->dwarf.cfa; UnwDebug(3, "unw_step called\n"); + { + uintptr_t dbp; + dwarf_get(&c->dwarf, c->dwarf.loc[RBP], &dbp); + UnwDebug (4, "unw_step context: bp=%016lx%s sp=%016lx ip=%016lx\n", dbp, + DWARF_IS_NULL_LOC(c->dwarf.loc[RBP])? " [NULL]": "", + c->dwarf.cfa, c->dwarf.ip); + } struct timespec _timer_start = chrono_start(); int ret, i; @@ -114,11 +121,10 @@ unw_step (unw_cursor_t *cursor) if (ret < 0 && ret != -UNW_ENOINFO) { - UnwDebug (3, "dwarf_step also failed?\n", ret); + UnwDebug (3, "dwarf_step also failed [%d]?\n", ret); UnwDebug (2, "returning %d\n", ret); return ret; } - UnwDebug(4, "UNW_ENOINFO=%d\n", UNW_ENOINFO); UnwDebug(3, "fallback continuing\n"); if (likely (ret >= 0)) @@ -135,6 +141,7 @@ unw_step (unw_cursor_t *cursor) uintptr_t dbp; dwarf_get(&c->dwarf, c->dwarf.loc[RBP], &dbp); UnwDebug (3, " DWARF: bp=%016lx sp=%016lx ip=%016lx\n", dbp, c->dwarf.cfa, c->dwarf.ip); + UnwDebug(3, "fallback with actual dwarf\n"); } else { @@ -157,7 +164,7 @@ unw_step (unw_cursor_t *cursor) Validate all addresses before dereferencing. */ c->validate = 1; - UnwDebug (13, "dwarf_step() failed (ret=%d), trying frame-chain\n", ret); + UnwDebug (4, "dwarf_step() failed (ret=%d), trying frame-chain\n", ret); if (unw_is_signal_frame (cursor)) {