wishlist for gdb ....

Jim Ingham jingham@apple.com
Tue Sep 26 18:32:00 GMT 2000


>        Here are some magic possible, by ksh integration , 
>        i would like to know how to achieve similar things in 
>        gdb. 
>     1. (dbx) $(funcs .*foo.*bar.* | sed 's/^/stop in/') 
>        this will set break points in all  
>        functions matching .*foo.*bar !!! 
>        (okay not exactly this, but something similar (-; ) 

The gdb command shell is not a real command interpreter, so you can't do neato programming stuff like this.  However, you can achieve this particular task using the "rbreak" command, which takes as its argument a regular expression, and sets a breakpoint on all the functions that match that regular expression.  In this particular case, rbreak is neater that what is given above, but clearly the programmability is more powerful in the long run.

Another option is to run Insight, which contains a full Tcl interpreter, including a bunch of commands wired into the guts of gdb for accessing variables, registers, etc, and an out to the gdb command set which returns the output in the result of the Tcl command so that you can capture and act on it further.  This is actually a pretty powerful environment (though somewhat poorly documented - sigh...).

In the long run, it would be nice to split the Tcl-only part of insight out from the Tk parts, so you could run Tcl as the command interpreter for gdb.  Someday, I will find the time to do this, but I haven't yet...

>    2.  how to grep help's output ?? 
>        help show | grep arg ????? 
>        or even setenv PAGER=xless displays help in seperate 
>        xless window. 

In this case do something like:

(gdb) tk exec grep arg [gdb_cmd {help show}]  

plus or minus a little tweaking will do what you want...  You could also write the search as a Tcl proc, and run that.  The only bogosity about the console window is that its line wrapping follows the gdb command language rules, not the Tcl ones, so any complicated command has to be put into a file, and sourced, as in:

(gdb) tk source defines_search_proc.tcl
(gdb) tk search_proc arg [gdb_cmd "help show"]

or whatever...

Hope this helps,


More information about the Gdb mailing list