diff options
author | Pedro Alves <palves@redhat.com> | 2011-03-18 18:45:30 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2011-03-18 18:45:30 +0000 |
commit | 008f8f2ee9bf610485993a17c1c460afb3cadc6c (patch) | |
tree | 6c6358cfe7ed6c0f1e24ce34825dbdb50a6483fe /gdb | |
parent | e3eebbd742b7c1820bead11710b71bfee694d7fa (diff) | |
download | gdb-008f8f2ee9bf610485993a17c1c460afb3cadc6c.zip gdb-008f8f2ee9bf610485993a17c1c460afb3cadc6c.tar.gz gdb-008f8f2ee9bf610485993a17c1c460afb3cadc6c.tar.bz2 |
gdb/
* frame.h (frame_unwind_caller_pc_if_available): Declare.
* frame.c (frame_unwind_caller_pc_if_available): New.
* stack.c (frame_info): Handle unavailable PC.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/frame.c | 7 | ||||
-rw-r--r-- | gdb/frame.h | 8 | ||||
-rw-r--r-- | gdb/stack.c | 22 | ||||
-rw-r--r-- | gdb/testsuite/ChangeLog | 6 |
4 files changed, 36 insertions, 7 deletions
diff --git a/gdb/frame.c b/gdb/frame.c index 20d8404..a817e4d 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -711,6 +711,13 @@ frame_unwind_caller_pc (struct frame_info *this_frame) } int +frame_unwind_caller_pc_if_available (struct frame_info *this_frame, + CORE_ADDR *pc) +{ + return frame_unwind_pc_if_available (skip_inlined_frames (this_frame), pc); +} + +int get_frame_func_if_available (struct frame_info *this_frame, CORE_ADDR *pc) { struct frame_info *next_frame = this_frame->next; diff --git a/gdb/frame.h b/gdb/frame.h index 25f20a9..7bc1148 100644 --- a/gdb/frame.h +++ b/gdb/frame.h @@ -562,6 +562,14 @@ extern void put_frame_register_bytes (struct frame_info *frame, int regnum, extern CORE_ADDR frame_unwind_caller_pc (struct frame_info *frame); +/* Same as frame_unwind_caller_pc, but returns a boolean indication of + whether the caller PC is determinable (when the PC is unavailable, + it will not be), instead of possibly throwing an error trying to + read unavailable memory or registers. */ + +extern int frame_unwind_caller_pc_if_available (struct frame_info *this_frame, + CORE_ADDR *pc); + /* Discard the specified frame. Restoring the registers to the state of the caller. */ extern void frame_pop (struct frame_info *frame); diff --git a/gdb/stack.c b/gdb/stack.c index de20418..dba77d4 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -1031,6 +1031,9 @@ frame_info (char *addr_exp, int from_tty) int selected_frame_p; struct gdbarch *gdbarch; struct cleanup *back_to = make_cleanup (null_cleanup, NULL); + CORE_ADDR frame_pc; + int frame_pc_p; + CORE_ADDR caller_pc; fi = parse_frame_specification_1 (addr_exp, "No stack.", &selected_frame_p); gdbarch = get_frame_arch (fi); @@ -1049,11 +1052,10 @@ frame_info (char *addr_exp, int from_tty) get_frame_pc(). */ pc_regname = "pc"; + frame_pc_p = get_frame_pc_if_available (fi, &frame_pc); find_frame_sal (fi, &sal); func = get_frame_function (fi); - /* FIXME: cagney/2002-11-28: Why bother? Won't sal.symtab contain - the same value? */ - s = find_pc_symtab (get_frame_pc (fi)); + s = sal.symtab; if (func) { funname = SYMBOL_PRINT_NAME (func); @@ -1074,11 +1076,11 @@ frame_info (char *addr_exp, int from_tty) } } } - else + else if (frame_pc_p) { struct minimal_symbol *msymbol; - msymbol = lookup_minimal_symbol_by_pc (get_frame_pc (fi)); + msymbol = lookup_minimal_symbol_by_pc (frame_pc); if (msymbol != NULL) { funname = SYMBOL_PRINT_NAME (msymbol); @@ -1099,7 +1101,10 @@ frame_info (char *addr_exp, int from_tty) fputs_filtered (paddress (gdbarch, get_frame_base (fi)), gdb_stdout); printf_filtered (":\n"); printf_filtered (" %s = ", pc_regname); - fputs_filtered (paddress (gdbarch, get_frame_pc (fi)), gdb_stdout); + if (frame_pc_p) + fputs_filtered (paddress (gdbarch, get_frame_pc (fi)), gdb_stdout); + else + fputs_filtered ("<unavailable>", gdb_stdout); wrap_here (" "); if (funname) @@ -1114,7 +1119,10 @@ frame_info (char *addr_exp, int from_tty) puts_filtered ("; "); wrap_here (" "); printf_filtered ("saved %s ", pc_regname); - fputs_filtered (paddress (gdbarch, frame_unwind_caller_pc (fi)), gdb_stdout); + if (frame_unwind_caller_pc_if_available (fi, &caller_pc)) + fputs_filtered (paddress (gdbarch, caller_pc), gdb_stdout); + else + fputs_filtered ("<unavailable>", gdb_stdout); printf_filtered ("\n"); if (calling_frame_info == NULL) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index e3b1a8a..96e2a9a 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,11 @@ 2011-03-18 Pedro Alves <pedro@codesourcery.com> + * frame.h (frame_unwind_caller_pc_if_available): Declare. + * frame.c (frame_unwind_caller_pc_if_available): New. + * stack.c (frame_info): Handle unavailable PC. + +2011-03-18 Pedro Alves <pedro@codesourcery.com> + * frame.c (frame_unwind_pc): Rename to ... (frame_unwind_pc_if_available): ... this. New `pc' output parameter. Change return type to int. Gracefully handle |