5

I want to put breakpoint on all functions of a file. I came across this link : http://sourceware.org/gdb/download/onlinedocs/gdb/Set-Breaks.html#Set-Breaks

It suggest the use of rbreak command for this purpose. When i use "rbreak ." , it works fine as expected and puts breakpoint in all functions of a prog. But when is use

rbreak filename.c:.

This doesn't work at all and no breakpoint is put anywhere. I even tried a variation of this putting spaces around :, but even that doesn't work.

Any idea on how this can be done ? Is it possible at all ? Any help will be greatly appreciated.

thanks, vikas

mezda
  • 3,537
  • 6
  • 30
  • 37
  • 1
    possible duplicate of [Using gdb stop the program when it is using any function from file X](http://stackoverflow.com/questions/475283/using-gdb-stop-the-program-when-it-is-using-any-function-from-file-x) – Employed Russian Feb 01 '12 at 16:02
  • 1
    make sure your `gdb` version is up-to-date. The `rbreak filename.c:.` command works for me in *gdb 7.6* – Sebastian May 27 '13 at 08:13

2 Answers2

2

rbreak filename.cpp:.* works fine for me.

Note that in order to put breakpoint in a file you need to compile the program with debug info, e.g

g++ -g filename.cpp
Eytan Naim
  • 159
  • 14
-1

rbreak filename.c:.

That isn't supposed to work. From the document you linked to:

rbreak regex
Set breakpoints on all *functions* matching the regular expression regex.

This is different from locations, where filename.c:... is intended to be used.

I want to put breakpoint on all functions of a file.

This is an unusual request. In my many years of debugging, I've never needed to do that.

You'll have to prepare a list, and set the breakpoints individually. A recipe for doing this can be found here.

Community
  • 1
  • 1
Employed Russian
  • 199,314
  • 34
  • 295
  • 362
  • 1
    `rbreak filename.c:.` works for me on a recent *gdb 7.6*. It doesn't work in *gdb 7.2*. Your linked recipe works as well. thanks. – Sebastian May 27 '13 at 08:12
  • 3
    Thanks for the answer - just to note the "unusual request"; maybe want OP wants is the call graph during execution, which (I guess) would better be served with tracepoints (which, however, require `gdbserver`); however I myself often forget the 'tracepoints' name, and then I start looking for "set breakpoint at every function", and end up at pages like this `:)` Cheers! – sdaau Nov 12 '13 at 13:13