This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[patch; rfa:doco] Add `set/show debug frame' command
- From: Andrew Cagney <ac131313 at redhat dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Tue, 25 Feb 2003 18:14:09 -0500
- Subject: [patch; rfa:doco] Add `set/show debug frame' command
Hello,
This adds a set/show debug frame command. It helps when trying to
figure out which of the N possible reasons caused the backtrace to fail.
I've committed the frame side.
Eli, the doco ok (I just discovered an entire section on `set/show debug
...')?
Andrew
2003-02-25 Andrew Cagney <cagney at redhat dot com>
* frame.c (frame_debug): New variable.
(_initialize_frame): Add "set/show debug frame" command.
(get_prev_frame): When frame_debug, print reason why unwind
failed.
Index: doc/ChangeLog
2003-02-25 Andrew Cagney <cagney at redhat dot com>
* gdb.texinfo (Debugging Output): Mention the "set/show debug
frame" command.
Index: frame.c
===================================================================
RCS file: /cvs/src/src/gdb/frame.c,v
retrieving revision 1.67
diff -u -r1.67 frame.c
--- frame.c 20 Feb 2003 16:35:51 -0000 1.67
+++ frame.c 25 Feb 2003 23:08:41 -0000
@@ -39,6 +39,10 @@
#include "command.h"
#include "gdbcmd.h"
+/* Flag to control debugging. */
+
+static int frame_debug;
+
/* Flag to indicate whether backtraces should stop at main. */
static int backtrace_below_main;
@@ -1223,7 +1227,12 @@
Note, this is done _before_ the frame has been marked as
previously unwound. That way if the user later decides to
allow unwinds past main(), that just happens. */
- return NULL;
+ {
+ if (frame_debug)
+ fprintf_unfiltered (gdb_stdlog,
+ "Outermost frame - inside main func.\n");
+ return NULL;
+ }
/* Only try to do the unwind once. */
if (next_frame->prev_p)
@@ -1239,7 +1248,12 @@
then it should probably be moved to before the ->prev_p test,
above. */
if (inside_entry_file (get_frame_pc (next_frame)))
+ {
+ if (frame_debug)
+ fprintf_unfiltered (gdb_stdlog,
+ "Outermost frame - inside entry file\n");
return NULL;
+ }
/* If any of the old frame initialization methods are around, use
the legacy get_prev_frame method. Just don't try to unwind a
@@ -1250,7 +1264,13 @@
|| INIT_EXTRA_FRAME_INFO_P ()
|| FRAME_CHAIN_P ())
&& next_frame->level >= 0)
- return legacy_get_prev_frame (next_frame);
+ {
+ prev_frame = legacy_get_prev_frame (next_frame);
+ if (frame_debug && prev_frame == NULL)
+ fprintf_unfiltered (gdb_stdlog,
+ "Outermost frame - legacy_get_prev_frame NULL.\n");
+ return prev_frame;
+ }
/* Allocate the new frame but do not wire it in to the frame chain.
Some (bad) code in INIT_FRAME_EXTRA_INFO tries to look along
@@ -1283,9 +1303,14 @@
prev_frame->pc = frame_pc_unwind (next_frame);
if (prev_frame->pc == 0)
- /* The allocated PREV_FRAME will be reclaimed when the frame
- obstack is next purged. */
- return NULL;
+ {
+ /* The allocated PREV_FRAME will be reclaimed when the frame
+ obstack is next purged. */
+ if (frame_debug)
+ fprintf_unfiltered (gdb_stdlog,
+ "Outermost frame - unwound PC zero\n");
+ return NULL;
+ }
prev_frame->type = frame_type_from_pc (prev_frame->pc);
/* Set the unwind functions based on that identified PC. */
@@ -1300,7 +1325,12 @@
save the frame ID directly. */
struct frame_id id = frame_id_unwind (next_frame);
if (!frame_id_p (id))
- return NULL;
+ {
+ if (frame_debug)
+ fprintf_unfiltered (gdb_stdlog,
+ "Outermost frame - unwound frame ID invalid\n");
+ return NULL;
+ }
prev_frame->frame = id.base;
}
@@ -1536,4 +1566,11 @@
the backtrace at \"main\". Set this variable if you need to see the rest\n\
of the stack trace.",
NULL, NULL, &setlist, &showlist);
+
+
+ /* Debug this files internals. */
+ add_show_from_set (add_set_cmd ("frame", class_maintenance, var_zinteger,
+ &frame_debug, "Set frame debugging.\n\
+When non-zero, frame specific internal debugging is enabled.", &setdebuglist),
+ &showdebuglist);
}
Index: doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.149
diff -u -r1.149 gdb.texinfo
--- doc/gdb.texinfo 23 Feb 2003 22:19:48 -0000 1.149
+++ doc/gdb.texinfo 25 Feb 2003 23:08:42 -0000
@@ -12947,6 +12947,14 @@
@item show debug expression
Displays the current state of displaying @value{GDBN} expression
debugging info.
+ at kindex set debug frame
+ at item set debug frame
+Turns on or off display of @value{GDBN} frame debugging info. The
+default is off.
+ at kindex show debug frame
+ at item show debug frame
+Displays the current state of displaying @value{GDBN} frame debugging
+info.
@kindex set debug overload
@item set debug overload
Turns on or off display of @value{GDBN} C at t{++} overload debugging