From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31265 invoked by alias); 7 Aug 2003 22:05:25 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 31251 invoked from network); 7 Aug 2003 22:05:23 -0000 Received: from unknown (HELO localhost.redhat.com) (24.157.166.107) by sources.redhat.com with SMTP; 7 Aug 2003 22:05:23 -0000 Received: from redhat.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id A68DC2B7F; Thu, 7 Aug 2003 18:05:21 -0400 (EDT) Message-ID: <3F32CD21.4010805@redhat.com> Date: Thu, 07 Aug 2003 22:05:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0.2) Gecko/20030223 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Eli Zaretskii Cc: gdb-patches@sources.redhat.com Subject: Re: [patch/rfc, rfa:doco, 6.0] "set backtrace past-main|limit" References: <3F2C4642.4010409@redhat.com> <3F2E5CD7.6010403@redhat.com> <7458-Mon04Aug2003181932+0300-eliz@elta.co.il> Content-Type: multipart/mixed; boundary="------------020906090807080500070403" X-SW-Source: 2003-08/txt/msg00110.txt.bz2 This is a multi-part message in MIME format. --------------020906090807080500070403 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 2145 > I'm not sure I like what happens when the backtrace is deeper than > the limit: > > >> + if (this_frame->level > backtrace_limit) >> + { >> + error ("Backtrace limit of %d exceeded", backtrace_limit); >> + } >> + > > > Why should this be anything as scary as `error'? Isn't a simple > notice (not even a `warning') enough? > > >> where the latter sets an absolute bound on the number of backtraces. >> 10000 (arbitrary) by default. > > > The 10000 default limit is not backward-compatible. Why not just > leave it at zero, as that's how GDB behaves today? I've set it to UINT_MAX. > If we do set the limit by default to some number, that number should > at least be documented in the manual. > > >> eli, the doco ok? I think I've fixed all these. Andrew >> +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. > > > I think it's better to put "@itemx set backtrace past-main on" first, > and "@item set backtrace past-main off" second, because otherwise the > above fragment of text doesn't make sense: you tell the reader that > the default behavior can be changed, but then show them the command > that sets the default behavior. > > >> +@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. > > > I suggest a "@cindex backtrace limit" here. That way, someone who > types "backtrace" in an Info reader and then hits TAB, will see this > item in the list of possible completions. > > Also, isn't it better to use "n" instead of "number" here? It seems > to me that > > Limit the backtrace to N levels > > sounds better in English than > > Limit the backtrace to NUMBER levels > > Do you agree? > > Finally, note the two consecutive "the" before "backtrace"; a typo. > > Otherwise, this docs change is okay; thanks. > > --------------020906090807080500070403 Content-Type: text/plain; name="diffs" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diffs" Content-length: 9134 2003-08-07 Andrew Cagney 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: doc/ChangeLog 2003-08-07 Andrew Cagney * gdb.texinfo (Backtrace): Replace "set/show backtrace-below-main" with "set/show backtrace past-main" and "set/show 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 7 Aug 2003 22:00:11 -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.134 diff -u -r1.134 frame.c --- frame.c 4 Aug 2003 15:42:43 -0000 1.134 +++ frame.c 7 Aug 2003 22:00:13 -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 unsigned int backtrace_limit = UINT_MAX; -static int backtrace_below_main; void fprint_frame_id (struct ui_file *file, struct frame_id id) @@ -1802,7 +1804,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 @@ -1814,6 +1816,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 @@ -2370,18 +2377,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\ @@ -2390,8 +2418,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 7 Aug 2003 22:00:21 -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.173 diff -u -r1.173 gdb.texinfo --- doc/gdb.texinfo 7 Aug 2003 17:47:42 -0000 1.173 +++ doc/gdb.texinfo 7 Aug 2003 22:01:42 -0000 @@ -3922,27 +3922,40 @@ 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 +@itemx set backtrace past-main on +Backtraces will continue past the user entry point. + +@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 show backtrace past-main +Display the current user entry point backtrace policy. + +@item set backtrace limit @var{n} +@itemx set backtrace limit 0 +@cindex backtrace limit +Limit the backtrace to @var{n} 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 --------------020906090807080500070403--