From bb03dca33e1cda3cb14509d1df5899c38788ff4c Mon Sep 17 00:00:00 2001 From: "homeip.net!davidm" Date: Tue, 3 May 2005 09:13:17 +0000 Subject: [PATCH] Add Debug statement for return-value. 2004/10/19 23:15:02-07:00 mostang.com!davidm (update_frame_state): Take additional argument "prev_cfa". When we detect a NULL-frame, debug-print the IP and the CFA so we know where things went wrong. (dwarf_step): Get "prev_cfa" before we call dwarf_find_save_locs(), since update_frame_state() doesn't actually update the CFA. (Logical change 1.290) --- src/dwarf/Gstep.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/dwarf/Gstep.c b/src/dwarf/Gstep.c index d75351fd..62aead0b 100644 --- a/src/dwarf/Gstep.c +++ b/src/dwarf/Gstep.c @@ -1,5 +1,5 @@ /* libunwind - a platform-independent unwind library - Copyright (c) 2003 Hewlett-Packard Development Company, L.P. + Copyright (c) 2003-2004 Hewlett-Packard Development Company, L.P. Contributed by David Mosberger-Tang This file is part of libunwind. @@ -27,13 +27,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "tdep.h" static int -update_frame_state (struct dwarf_cursor *c) +update_frame_state (struct dwarf_cursor *c, unw_word_t prev_cfa) { - unw_word_t prev_ip, prev_cfa, ip; + unw_word_t prev_ip, ip; int ret; prev_ip = c->ip; - prev_cfa = c->cfa; /* Update the IP cache (do this first: if we reach the end of the frame-chain, the rest of the info may not be valid/useful @@ -110,8 +109,8 @@ update_frame_state (struct dwarf_cursor *c) if (c->ip == prev_ip && c->cfa == prev_cfa) { - dprintf ("%s: ip and cfa unchanged; stopping here (ip=0x%lx)\n", - __FUNCTION__, (long) ip); + dprintf ("%s: ip and cfa unchanged; stopping (ip=0x%lx cfa=0x%lx)\n", + __FUNCTION__, (long) prev_ip, (long) prev_cfa); return -UNW_EBADFRAME; } @@ -122,14 +121,13 @@ update_frame_state (struct dwarf_cursor *c) HIDDEN int dwarf_step (struct dwarf_cursor *c) { + unw_word_t prev_cfa = c->cfa; int ret; - if ((ret = dwarf_find_save_locs (c)) < 0) - return ret; + if ((ret = dwarf_find_save_locs (c)) >= 0 + && (ret = update_frame_state (c, prev_cfa)) >= 0) + ret = (c->ip == 0) ? 0 : 1; - if ((ret = update_frame_state (c)) < 0) - return ret; - - Debug (15, "done\n"); - return (c->ip == 0) ? 0 : 1; + Debug (15, "returning %d\n", ret); + return ret; }