Re: [RFC] add 'save-breakpoints' command

Klee Dienes
2001-12-11T16:35:44Z

> A related question is: maybe we should make all breakpoint commands
> behave like this by default?

My opinion is that we should not. I consider future-breakpoints as
something to be used only when GDB is for whatever reason unable to
properly load the symbols for something in advance. In general, I
much-prefer the error-checking behavior of traditional 'break'.

> Can we perhaps come up with a better name instead of `future-break'? It
> doesn't really describe well enough what does this command do, IMHO. For
> example, if it is possible to put a breakpoint at the time the user
> issues the command, GDB will do that without delays, so the word
> ``future'' is inaccurate.

I'd certainly be open to new names, but after years of using
'future-break' and 'fb', it's hard for me to come up with one. Other
options would be to use a variable such as 'set
defer-breakpoints-on-error 1' to enable the behavior (I tend to think
this is a bit cumbersome), or to add a '--retry' option to the
breakpoint commands. Does anyone have any suggestions?

>> * main.c (captured_main): Initialize $input_radix and $output_radix.
>> These are referenced by a save-breakpoints file to preserve radix
>> across the breakpoint restoration.

> This aspect of save-breakpoints isn't mentioned in the gdb.texinfo
> patch. Please add it; I think it's important to say that in the manual,
> since the radix has effect on features other than breakpoints.

In case I gave the wrong idea, the reason for the introduction of
these variables was to prevent the save-breakpoint implementation from
changing the default radix. The idea is that the saved command file
contains commands of the form:

set $current_radix = $input_radix
set input-radix 012
break internal_error
set input-radix $current_radix

The only reason we need to add $input_radix as a variable is that
there is no good way to use the output of a command as input to
another command; otherwise we'd probably have done something like

set $current_radix = `show input-radix`

. I'm certainly willing to document the additional convenience
variables, but I'm not sure where a good section for them would be.
Perhaps in the documentation for 'set input-radix'?

Index: gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.59
diff -u -r1.59 gdb.texinfo
--- gdb.texinfo 2001/11/30 23:03:09 1.59
+++ gdb.texinfo 2001/12/11 16:22:23
@@ -2335,6 +2335,7 @@
* Set Catchpoints:: Setting catchpoints
* Delete Breaks:: Deleting breakpoints
* Disabling:: Disabling breakpoints
+* Saving:: Saving breakpoints
* Conditions:: Break conditions
* Break Commands:: Breakpoint command lists
* Breakpoint Menus:: Breakpoint menus
@@ -2420,6 +2421,18 @@
above (or no argument) specifying where to break. @xref{Conditions,
,Break conditions}, for more information on breakpoint conditions.

+@kindex future-break
+@item future-break @var{args}
+Set a ``future'' breakpoint. @var{args} are the same as for the
+@code{break} command and the breakpoint is set in the same way.
+However, if @value{GDBN} is unable to set the breakpoint when the
+command is executed, it will store the expression, and try again to set
+it after any new symbol files or shared libraries are loaded. This
+command is typically used when setting breakpoints in shared libraries
+or plug-ins that are not able to be detected by GDB at start-up (either
+because they are dynamically loaded at run-time, or because GDB is for
+some other reason unable to detect them at start-up).
+
@kindex tbreak
@item tbreak @var{args}
Set a breakpoint enabled only for one stop. @var{args} are the
@@ -2942,6 +2955,22 @@
breakpoints; see @ref{Continuing and Stepping, ,Continuing and
stepping}.)

+@node Saving
+@subsection Saving breakpoints
+@cindex save breakpoints for future sessions
+
+Sometimes, it can be convenient to save the current set of breakpoints
+for use in a future debugging session:
+
+@table @code
+@kindex save-breakpoints
+@item save-breakpoints @var{filename}
+Save all current breakpoint definitions, together with their
+ignore-counts and command scripts, into the file @file{@var{filename}}.
+To read the saved breakpoint definitions, use the @code{source} command
+(@pxref{Command Files}).
+@end table
+
@node Conditions
@subsection Break conditions
@cindex conditional breakpoints
@@ -13080,13 +13109,13 @@
example, any of

@smallexample
-set radix 012
-set radix 10.
-set radix 0xa
+set input-radix 012
+set input-radix 10.
+set input-radix 0xa
@end smallexample

@noindent
-sets the base to decimal. On the other hand, @samp{set radix 10}
+sets the base to decimal. On the other hand, @samp{set input-radix 10}
leaves the radix unchanged no matter what it was.

@kindex set output-radix
@@ -13103,6 +13132,10 @@
@item show output-radix
Display the current default base for numeric display.
@end table
+
+The current input and output radixes can also be stored and set using
+the @value{GDBN} convenience variables @code{$input_radix} and
+@code{$output_radix}.

@node Messages/Warnings
@section Optional warnings and messages