This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fix unavailable.exp failures


I'm seeing

 FAIL: gdb.trace/unavailable.exp: unavailable arguments: print &argc
 FAIL: gdb.trace/unavailable.exp: unavailable arguments: print &argi
 FAIL: gdb.trace/unavailable.exp: unavailable arguments: print &argf
 FAIL: gdb.trace/unavailable.exp: unavailable arguments: print &argd
 FAIL: gdb.trace/unavailable.exp: unavailable arguments: print &argarray

against a native x86_64 gdbserver, on Fedora 16.

gdb.log shows:

 print argc
 $1 = <unavailable>
 (gdb) PASS: gdb.trace/unavailable.exp: unavailable arguments: print argc
 print &argc
 $2 = 0xffffffffffffffdc <Address 0xffffffffffffffdc out of bounds>
 (gdb) FAIL: gdb.trace/unavailable.exp: unavailable arguments: print &argc

That variable's address is bogus.  The problem is that while evaluating
a location descriptor, involving DW_OP_call_frame_cfa, we end up computing
the CFA from the unwinder's frame base, when that is not a usable value
in the case of an UNWIND_UNAVAILABLE frame.

The patch below fixes it.

(Note that for the test in question, the exception is caught, and a different
error message is shown to the user.)

Tested on x86_64 / fedora 16, local gdbserver, and applied.

-- 
Pedro Alves

2012-01-17  Pedro Alves  <palves@redhat.com>

	* dwarf2-frame.c (dwarf2_frame_cfa): Throw NOT_AVAILABLE_ERROR, if
	the frame's stop reason is UNWIND_UNAVAILABLE.
---
 gdb/dwarf2-frame.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/gdb/dwarf2-frame.c b/gdb/dwarf2-frame.c
index 88aa338..5870079 100644
--- a/gdb/dwarf2-frame.c
+++ b/gdb/dwarf2-frame.c
@@ -1490,6 +1490,10 @@ dwarf2_frame_cfa (struct frame_info *this_frame)
   if (!frame_unwinder_is (this_frame, &dwarf2_frame_unwind)
       && !frame_unwinder_is (this_frame, &dwarf2_tailcall_frame_unwind))
     error (_("can't compute CFA for this frame"));
+  if (get_frame_unwind_stop_reason (this_frame) == UNWIND_UNAVAILABLE)
+    throw_error (NOT_AVAILABLE_ERROR,
+		 _("can't compute CFA for this frame: "
+		   "required registers or memory are unavailable"));
   return get_frame_base (this_frame);
 }
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]