This is the mail archive of the gdb@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]

Terminate backtrace at target arch's request


Hi,

Quite some time ago we discussed the possibility of a mechanism for the
target architecture to signal that the outermost call frame has been
reached and so terminate back tracing (
http://sourceware.org/ml/gdb/2007-06/msg00087.html ). The patch below
implements such a mechanism using a new flag in the frame_id struct. If
the target architecture sets the flag in the unwinder's frame_this_id
function then frame.c:get_prev_frame_1 will not attempt to unwind past
this frame. This should be backwards compatible with existing unwinders
assuming the flag gets initialised to zero if unset. In our port we
check for a valid return address to find the outermost frame.

ChangeLog:

  * frame.h (struct frame_id): Add a flag for unwinder to indicate the
outermost frame.
  * frame.c (get_prev_frame_1): Check this flag and don't attempt to
unwind further.

Robert

Index: frame.c
===================================================================
RCS file: /cvs/dev/tools/src/binutils/gdb/frame.c,v
retrieving revision 1.4
diff -u -r1.4 frame.c
--- frame.c	7 Jul 2008 13:20:30 -0000	1.4
+++ frame.c	10 Jul 2008 14:04:28 -0000
@@ -1166,6 +1166,21 @@
      unwind to the prev frame.  Be careful to not apply this test to
      the sentinel frame.  */
   this_id = get_frame_id (this_frame);
+  
+  /* Check to see if this is flagged by target arch as the outermost
frame. */
+  if (this_id.outermost_frame_p)
+  {
+    if (frame_debug)
+    {
+      fprintf_unfiltered (gdb_stdlog, "-> ");
+      fprint_frame (gdb_stdlog, NULL);
+      fprintf_unfiltered (gdb_stdlog, " // outermost frame}\n");
+    }
+    /* TODO we could invent a new stop_reason for this */
+    this_frame->stop_reason = UNWIND_NULL_ID;
+    return NULL;
+  }
+  
   if (this_frame->level >= 0 && !frame_id_p (this_id))
     {
       if (frame_debug)
Index: frame.h
===================================================================
RCS file: /cvs/dev/tools/src/binutils/gdb/frame.h,v
retrieving revision 1.4
diff -u -r1.4 frame.h
--- frame.h	7 Jul 2008 13:20:25 -0000	1.4
+++ frame.h	10 Jul 2008 14:04:28 -0000
@@ -122,6 +122,9 @@
   unsigned int stack_addr_p : 1;
   unsigned int code_addr_p : 1;
   unsigned int special_addr_p : 1;
+  /* Flag to indicate that this is the outermost frame in this thread. 
+     GDB will not attempt to  unwind past this frame if this flag is
set. */
+  unsigned int outermost_frame_p : 1;
 };
 
 /* Methods for constructing and comparing Frame IDs.


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