gdb, set breakpoint on all functions in a file

FunctionGdbBreakpoints

Function Problem Overview


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.

Function Solutions


Solution 1 - Function

Solution 2 - Function

(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.*

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSmashView Question on Stackoverflow
Solution 1 - FunctionShaun LebronView Answer on Stackoverflow
Solution 2 - FunctiongnodView Answer on Stackoverflow