Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I break on all functions that matches a pattern?

Tags:

gdb

I'm trying to break on all pthread functions, but it looks like gdb doesn't support wildcard here:

(gdb) b pthread_*
Function "pthread_*" not defined.

Any ideas?

like image 254
daisy Avatar asked Jul 07 '14 15:07

daisy


People also ask

How do you set a breakpoint in a function?

You can also set breakpoints on function names. To do this, just type "break [functionname]". gdb will stop your program just before that function is called.

What is the GDB command to set a breakpoint?

Breakpoints are set with the break command (abbreviated b ). The debugger convenience variable `$bpnum' records the number of the breakpoint you've set most recently; see section Convenience variables, for a discussion of what you can do with convenience variables.

Does GDB use hardware breakpoints?

This applies to breakpoints set with the break command as well as to internal breakpoints set by commands like next and finish . For breakpoints set with hbreak , GDB will always use hardware breakpoints. You can control this automatic behaviour with the following commands: set breakpoint auto-hw on.


1 Answers

Use rbreak ^pthread_

From GDB: Setting Breakpoints:

rbreak regex

Set breakpoints on all functions matching the regular expression regex.

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 os. There is an implicit .* leading and trailing the regular expression you supply, so to match only functions that begin with foo, use ^foo.

like image 117
Mark Plotnick Avatar answered Oct 21 '22 04:10

Mark Plotnick