* [patch/rfc, rfa:doco, 6.0] "set backtrace past-main|limit"
@ 2003-08-02 23:16 Andrew Cagney
2003-08-03 6:02 ` Eli Zaretskii
0 siblings, 1 reply; 8+ messages in thread
From: Andrew Cagney @ 2003-08-02 23:16 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 551 bytes --]
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
[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 9130 bytes --]
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
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [patch/rfc, rfa:doco, 6.0] "set backtrace past-main|limit"
2003-08-02 23:16 [patch/rfc, rfa:doco, 6.0] "set backtrace past-main|limit" Andrew Cagney
@ 2003-08-03 6:02 ` Eli Zaretskii
2003-08-04 13:17 ` Andrew Cagney
0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2003-08-03 6:02 UTC (permalink / raw)
To: Andrew Cagney; +Cc: gdb-patches
> Date: Sat, 02 Aug 2003 19:16:18 -0400
> From: Andrew Cagney <ac131313@redhat.com>
>
> 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
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?
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?
Yes, but...
> +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.
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [patch/rfc, rfa:doco, 6.0] "set backtrace past-main|limit"
2003-08-03 6:02 ` Eli Zaretskii
@ 2003-08-04 13:17 ` Andrew Cagney
2003-08-04 15:23 ` Eli Zaretskii
0 siblings, 1 reply; 8+ messages in thread
From: Andrew Cagney @ 2003-08-04 13:17 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches
>> Date: Sat, 02 Aug 2003 19:16:18 -0400
>> From: Andrew Cagney <ac131313@redhat.com>
>>
>> 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
>
>
> 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?
The choices I could think of were:
- warn and return NULL
but that would become tedious as it would keep occuring - get_prev_frame
is called many times.
- error out
perhaps add additional information on how to change the limit
- warn and continue the backtrace
I don't think this helps
The difference between a warning and error are largely internal - the
latter aborts the command and I think that's better here.
>> 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?
(Zero gets turned into MAX_INT)
True, the problem I encountered was in the testsuite. That could always
be modified to, by default, set an upper bound.
> If we do set the limit by default to some number, that number should
> at least be documented in the manual.
There are a number of constants like that. There should be a more
robust way of keeping them consistent between the doco and the code.
However defaulting it to infinite would avoid the problem.
>> eli, the doco ok?
>
>
> Yes, but...
>
>
>> +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.
I'll switch the order (which came from the old doco :-).
>> +@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?
Yep. I was wondering what @var{} to use there.
> Finally, note the two consecutive "the" before "backtrace"; a typo.
>
> Otherwise, this docs change is okay; thanks.
Thanks. Lets see if there are any other comments on limit's default.
Andrew
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [patch/rfc, rfa:doco, 6.0] "set backtrace past-main|limit"
2003-08-04 13:17 ` Andrew Cagney
@ 2003-08-04 15:23 ` Eli Zaretskii
2003-08-04 15:59 ` Andrew Cagney
2003-08-07 22:05 ` Andrew Cagney
0 siblings, 2 replies; 8+ messages in thread
From: Eli Zaretskii @ 2003-08-04 15:23 UTC (permalink / raw)
To: ac131313; +Cc: gdb-patches
> Date: Mon, 04 Aug 2003 09:17:11 -0400
> From: Andrew Cagney <ac131313@redhat.com>
> >
> > Why should this be anything as scary as `error'? Isn't a simple
> > notice (not even a `warning') enough?
>
> The choices I could think of were:
>
> - warn and return NULL
> but that would become tedious as it would keep occuring - get_prev_frame
> is called many times.
>
> - error out
> perhaps add additional information on how to change the limit
>
> - warn and continue the backtrace
> I don't think this helps
>
> The difference between a warning and error are largely internal - the
> latter aborts the command and I think that's better here.
Doesn't `error' say something like "Error: ..."? If so, I think it's
wrong to scare the user like that. Perhaps we should have a way to
silently abort the command, if we don't have that already. Then we
could print a message and quitely stop the command.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch/rfc, rfa:doco, 6.0] "set backtrace past-main|limit"
2003-08-04 15:23 ` Eli Zaretskii
@ 2003-08-04 15:59 ` Andrew Cagney
2003-08-07 22:05 ` Andrew Cagney
1 sibling, 0 replies; 8+ messages in thread
From: Andrew Cagney @ 2003-08-04 15:59 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches
> Doesn't `error' say something like "Error: ..."? If so, I think it's
> wrong to scare the user like that. Perhaps we should have a way to
> silently abort the command, if we don't have that already. Then we
> could print a message and quitely stop the command.
There isn't an "Error: ..." prefix (well not that I've noticed). The
text that you see is all that the user would see. It's possible to
abort the command silently (by throwing a quit) but I think that would
confuse the user more.
Andrew
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch/rfc, rfa:doco, 6.0] "set backtrace past-main|limit"
2003-08-04 15:23 ` Eli Zaretskii
2003-08-04 15:59 ` Andrew Cagney
@ 2003-08-07 22:05 ` Andrew Cagney
2003-08-08 7:34 ` Eli Zaretskii
1 sibling, 1 reply; 8+ messages in thread
From: Andrew Cagney @ 2003-08-07 22:05 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 2145 bytes --]
> 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.
>
>
[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 9134 bytes --]
2003-08-07 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: doc/ChangeLog
2003-08-07 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: 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
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2003-08-09 15:07 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-02 23:16 [patch/rfc, rfa:doco, 6.0] "set backtrace past-main|limit" Andrew Cagney
2003-08-03 6:02 ` Eli Zaretskii
2003-08-04 13:17 ` Andrew Cagney
2003-08-04 15:23 ` Eli Zaretskii
2003-08-04 15:59 ` Andrew Cagney
2003-08-07 22:05 ` Andrew Cagney
2003-08-08 7:34 ` Eli Zaretskii
2003-08-09 15:07 ` Andrew Cagney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox