星期日, 五月 02, 2010

rbreak break every functions in a file -- new gdb breakpoint command(GDB)

When I use the GDB, I always think about insert breakpoint to a file.
Then if inferior exec to any part of this file, the inferior will be
break. But GDB simple break command doesn't support it.

Now, gdb-cvs-head have a new command rbreak:
`rbreak REGEX'
Set breakpoints on all functions matching the regular expression
REGEX. This command sets an unconditional breakpoint on all
matches, printing a list of all breakpoints it set. Once these
breakpoints are set, they are treated just like the breakpoints
set with the `break' command. You can delete them, disable them,
or make them conditional the same way as any other breakpoint.

The syntax of the regular expression is the standard one used with
tools like `grep'. Note that this is different from the syntax
used by shells, so for instance `foo*' matches all functions that
include an `fo' followed by zero or more `o's. There is an
implicit `.*' leading and trailing the regular expression you
supply, so to match only functions that begin with `foo', use
`^foo'.

When debugging C++ programs, `rbreak' is useful for setting
breakpoints on overloaded functions that are not members of any
special classes.

The `rbreak' command can be used to set breakpoints in *all* the
functions in a program, like this:

(gdb) rbreak .

`rbreak FILE:REGEX'
If `rbreak' is called with a filename qualification, it limits the
search for functions matching the given regular expression to the
specified FILE. This can be used, for example, to set breakpoints
on every function in a given file:

(gdb) rbreak file.c:.

The colon separating the filename qualifier from the regex may
optionally be surrounded by spaces.

0 Comments:

发表评论

<< Home