This is the mail archive of the gdb-patches@sources.redhat.com 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]

[patch/rfc, rfa:doco, 6.0] "set backtrace past-main|limit"


Hello,

This patch replaces the commands:

	set/show backtrace-below-main
	show backtrace-below-main

with the pair of commands:

	set/show backtrace past-main
	set/show backtrace limit

where the latter sets an absolute bound on the number of backtraces. 10000 (arbitrary) by default.

While the command could technically be named "above-main", "past-main" should avoid any "top", "bottom", "up" and "down".

I'm looking to commit at least the "past-main" command to 6.0 branch towards the end of the week (>2003-08-06)

eli, the doco ok?

Andrew
Index: doc/ChangeLog
2003-08-02  Andrew Cagney  <cagney@redhat.com>

	* gdb.texinfo (Backtrace): Replace "set/show backtrace-below-main"
	with "set/show backtrace past-main" and "set/show backtrace
	limit".

Index: ChangeLog
2003-08-02  Andrew Cagney  <cagney@redhat.com>

	Fix GDB PR cli/926.
	* cli/cli-decode.c (add_setshow_uinteger_cmd): New function.
	* command.h (add_setshow_uinteger_cmd): Declare.
	* frame.c (set_backtrace_cmd): New function.
	(show_backtrace_cmd): New function.
	* frame.c (_initialize_frame): Replace "set/show
	backtrace-below-main" with "set/show backtrace past-main".  Add
	command "set/show backtrace limit".
	(backtrace_past_main): Rename "backtrace_below_main".
	(backtrace_limit): New variable.
	(get_prev_frame): Update.  Check the backtrace_limit.

Index: command.h
===================================================================
RCS file: /cvs/src/src/gdb/command.h,v
retrieving revision 1.35
diff -u -r1.35 command.h
--- command.h	3 Jul 2002 17:35:20 -0000	1.35
+++ command.h	2 Aug 2003 23:04:40 -0000
@@ -262,6 +262,16 @@
 				     struct cmd_list_element **set_list,
 				     struct cmd_list_element **show_list);
 
+extern void add_setshow_uinteger_cmd (char *name,
+				      enum command_class class,
+				      unsigned int *var,
+				      char *set_doc,
+				      char *show_doc,
+				      cmd_sfunc_ftype *set_func,
+				      cmd_sfunc_ftype *show_func,
+				      struct cmd_list_element **set_list,
+				      struct cmd_list_element **show_list);
+
 extern struct cmd_list_element *add_show_from_set (struct cmd_list_element *,
 						   struct cmd_list_element
 						   **);
Index: frame.c
===================================================================
RCS file: /cvs/src/src/gdb/frame.c,v
retrieving revision 1.133
diff -u -r1.133 frame.c
--- frame.c	15 Jul 2003 17:35:00 -0000	1.133
+++ frame.c	2 Aug 2003 23:04:41 -0000
@@ -135,9 +135,11 @@
 
 static int frame_debug;
 
-/* Flag to indicate whether backtraces should stop at main.  */
+/* Flag to indicate whether backtraces should stop at main et.al.  */
+
+static int backtrace_past_main;
+static int backtrace_limit = 10000;
 
-static int backtrace_below_main;
 
 void
 fprint_frame_id (struct ui_file *file, struct frame_id id)
@@ -1799,7 +1801,7 @@
   gdb_assert (this_frame != NULL);
 
   if (this_frame->level >= 0
-      && !backtrace_below_main
+      && !backtrace_past_main
       && inside_main_func (get_frame_pc (this_frame)))
     /* Don't unwind past main(), bug always unwind the sentinel frame.
        Note, this is done _before_ the frame has been marked as
@@ -1811,6 +1813,11 @@
       return NULL;
     }
 
+  if (this_frame->level > backtrace_limit)
+    {
+      error ("Backtrace limit of %d exceeded", backtrace_limit);
+    }
+
   /* If we're already inside the entry function for the main objfile,
      then it isn't valid.  Don't apply this test to a dummy frame -
      dummy frame PC's typically land in the entry func.  Don't apply
@@ -2367,18 +2374,39 @@
 
 extern initialize_file_ftype _initialize_frame; /* -Wmissing-prototypes */
 
+static struct cmd_list_element *set_backtrace_cmdlist;
+static struct cmd_list_element *show_backtrace_cmdlist;
+
+static void
+set_backtrace_cmd (char *args, int from_tty)
+{
+  help_list (set_backtrace_cmdlist, "set backtrace ", -1, gdb_stdout);
+}
+
+static void
+show_backtrace_cmd (char *args, int from_tty)
+{
+  cmd_show_list (show_backtrace_cmdlist, from_tty, "");
+}
+
 void
 _initialize_frame (void)
 {
   obstack_init (&frame_cache_obstack);
 
-  /* FIXME: cagney/2003-01-19: This command needs a rename.  Suggest
-     `set backtrace {past,beyond,...}-main'.  Also suggest adding `set
-     backtrace ...-start' to control backtraces past start.  The
-     problem with `below' is that it stops the `up' command.  */
+  add_prefix_cmd ("backtrace", class_maintenance, set_backtrace_cmd, "\
+Set backtrace specific variables.\n\
+Configure backtrace variables such as the backtrace limit",
+		  &set_backtrace_cmdlist, "set backtrace ",
+		  0/*allow-unknown*/, &setlist);
+  add_prefix_cmd ("backtrace", class_maintenance, show_backtrace_cmd, "\
+Show backtrace specific variables\n\
+Show backtrace variables such as the backtrace limit",
+		  &show_backtrace_cmdlist, "show backtrace ",
+		  0/*allow-unknown*/, &showlist);
 
-  add_setshow_boolean_cmd ("backtrace-below-main", class_obscure,
-			   &backtrace_below_main, "\
+  add_setshow_boolean_cmd ("past-main", class_obscure,
+			   &backtrace_past_main, "\
 Set whether backtraces should continue past \"main\".\n\
 Normally the caller of \"main\" is not of interest, so GDB will terminate\n\
 the backtrace at \"main\".  Set this variable if you need to see the rest\n\
@@ -2387,8 +2415,17 @@
 Normally the caller of \"main\" is not of interest, so GDB will terminate\n\
 the backtrace at \"main\".  Set this variable if you need to see the rest\n\
 of the stack trace.",
-			   NULL, NULL, &setlist, &showlist);
+			   NULL, NULL, &set_backtrace_cmdlist,
+			   &show_backtrace_cmdlist);
 
+  add_setshow_uinteger_cmd ("limit", class_obscure,
+			    &backtrace_limit, "\
+Set an upper bound on the number of backtrace levels.\n\
+No more than the specified number of frames can be displayed or examined.\n
+Zero is unlimited.", "\
+Show the upper bound on the number of backtrace levels.",
+			    NULL, NULL, &set_backtrace_cmdlist,
+			    &show_backtrace_cmdlist);
 
   /* Debug this files internals. */
   add_show_from_set (add_set_cmd ("frame", class_maintenance, var_zinteger,
Index: cli/cli-decode.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-decode.c,v
retrieving revision 1.31
diff -u -r1.31 cli-decode.c
--- cli/cli-decode.c	8 Jun 2003 18:27:14 -0000	1.31
+++ cli/cli-decode.c	2 Aug 2003 23:04:56 -0000
@@ -448,6 +448,26 @@
   c->enums = boolean_enums;
 }
 
+/* Add element named NAME to both the set and show command LISTs (the
+   list for set/show or some sublist thereof).  CLASS is as in
+   add_cmd.  VAR is address of the variable which will contain the
+   value.  SET_DOC and SHOW_DOR are the documentation strings.  */
+void
+add_setshow_uinteger_cmd (char *name,
+			  enum command_class class,
+			  unsigned int *var, char *set_doc, char *show_doc,
+			  cmd_sfunc_ftype *set_func,
+			  cmd_sfunc_ftype *show_func,
+			  struct cmd_list_element **set_list,
+			  struct cmd_list_element **show_list)
+{
+  add_setshow_cmd_full (name, class, var_uinteger, var,
+			set_doc, show_doc,
+			set_func, show_func,
+			set_list, show_list,
+			NULL, NULL);
+}
+
 /* Where SETCMD has already been added, add the corresponding show
    command to LIST and return a pointer to the added command (not
    necessarily the head of LIST).  */
Index: doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.171
diff -u -r1.171 gdb.texinfo
--- doc/gdb.texinfo	26 Jul 2003 07:38:54 -0000	1.171
+++ doc/gdb.texinfo	2 Aug 2003 23:07:05 -0000
@@ -3919,27 +3919,39 @@
 value, indicating that your program has stopped at the beginning of the
 code for line @code{993} of @code{builtin.c}.
 
-@kindex set backtrace-below-main
-@kindex show backtrace-below-main
+@kindex set backtrace past-main
+@kindex show backtrace past-main
+@kindex set backtrace limit
+@kindex show backtrace limit
 
-Most programs have a standard entry point---a place where system libraries
-and startup code transition into user code.  For C this is @code{main}.
-When @value{GDBN} finds the entry function in a backtrace it will terminate
-the backtrace, to avoid tracing into highly system-specific (and generally
-uninteresting) code.  If you need to examine the startup code, then you can
-change this behavior.
+Most programs have a standard user entry point---a place where system
+libraries and startup code transition into user code.  For C this is
+@code{main}.  When @value{GDBN} finds the entry function in a backtrace
+it will terminate the backtrace, to avoid tracing into highly
+system-specific (and generally uninteresting) code.
+
+If you need to examine the startup code, or limit the number of levels
+in a backtrace, you can change this behavior:
 
 @table @code
-@item set backtrace-below-main off
+@item set backtrace past-main off
 Backtraces will stop when they encounter the user entry point.  This is the
 default.
 
-@item set backtrace-below-main
-@itemx set backtrace-below-main on
-Backtraces will continue past the user entry point to the top of the stack.
+@item set backtrace past-main
+@itemx set backtrace past-main on
+Backtraces will continue past the user entry point.
+
+@item show backtrace past-main
+Display the current user entry point backtrace policy.
+
+@item set backtrace limit @var{number}
+@itemx set backtrace limit 0
+Limit the the backtrace to @var{number} levels.  A value of zero means
+unlimited.
 
-@item show backtrace-below-main
-Display the current backtrace policy.
+@item show backtrace limit
+Display the current limit on backtrace levels.
 @end table
 
 @node Selection

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