Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gdb, set breakpoint on all functions in a file

Is there a single command in gdb which can set breakpoints on all the functions in a given file ? I know about rbreak regex which sets breakpoints in matching regular expression functions, but my file doesnt have fixed patterned functions.

In another way, is there a command by which I can set a breakpoint on a filename. Which will mean, whenever control gets inside this file, it should break ?

I personally think this should not be much difficult to implement in gdb, but just wondering if somebody has already done this.

like image 904
Smash Avatar asked Sep 25 '09 08:09

Smash


People also ask

How do I add a breakpoint to a GDB file?

To set breakpoints, type "break [filename]:[linenumber]". For example, if you wanted to set a breakpoint at line 55 of main. cpp, you would type "break main. cpp:55".

What command is used in GDB to set a breakpoint?

The rbreak command can be used to set breakpoints in all the functions in a program, like this: (gdb) rbreak . Print a table of all breakpoints, watchpoints, and catchpoints set and not deleted, with the following columns for each breakpoint: Breakpoint Numbers.

How do you set a breakpoint in a program?

Set breakpoints in source code To set a breakpoint in source code: Click in the far left margin next to a line of code. You can also select the line and press F9, select Debug > Toggle Breakpoint, or right-click and select Breakpoint > Insert breakpoint.


2 Answers

(gdb) rbreak file:. 

from http://sourceware.org/gdb/download/onlinedocs/gdb/Set-Breaks.html#Set-Breaks

like image 141
Shaun Lebron Avatar answered Oct 13 '22 20:10

Shaun Lebron


(gdb) set height 0 (gdb) rbreak file.cpp:.* 

worked fine for me.

In my case it was useful to shrink the result set a little bit by specifying a template argument for the functions contained in the file:

(gdb) rbreak file.cpp:.*TemplateClass.* 
like image 27
gnod Avatar answered Oct 13 '22 21:10

gnod