This is the mail archive of the gdb@sourceware.cygnus.com mailing list for the GDB project. See the GDB home page for more information.


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

Re: problem with chained if statements?


> But I think the real power would be to add hooks into gdb at various places
> to which guile scripts can be attached.  Breakpoints, for example: if I
> could tell gdb to run a guile script each time a breakpoint is encountered,
> then I could do "conditional debugging" by letting the script examine the
> inferior program state so that execution pauses only when certain criteria
> are met.  Of course, it's possible to accomplish the same thing by building
> special debug code into the executable, but that's invasive and
> time-consuming -- best case, I have to recompile my program.  The ability to
> set up and change these hooks on the fly would be very nice.

Um, gdb already lets you do this, subject to the limitations of the gdb
command language and variable facilities.

(gdb) help command
Set commands to be executed when a breakpoint is hit.
Give breakpoint number as argument after "commands".
With no argument, the targeted breakpoint is the last one set.
The commands themselves follow starting on the next line.
Type a line containing "end" to indicate the end of them.
Give "silent" as the first line to make the breakpoint silent;
then no output is printed when it is hit, except what the commands print.

-- 
Todd Whitesel
toddpw @ wrs.com