I am trying set breakpoints in template functions in C++ via GDB I tried three possible approaches.
- break fileName:functionName => works for non-templated functions (specific to one function)
- rbreak fileName:. => breakpoints at all functions in a given file, but it does not seem to work for template functions
- break fileName:lineNumber => works for both non-templated and templated functions but problem here for me is I have to modify this linenumber everytime.
A overall objective is am using a script like below to trace the full codeflow via GDB, but my code has lot of template functions too. Sample GDB script below
set logging on
b func2
commands
silent
bt 1
continue
end
b func1
commands
silent
bt 1
set logging off
continue
end
- One option was to use rbreak filename:.
- run the code once, and
- run the code again without exiting GDB. This time it recognizes the functions and breakpoints works.
Could you please help suggest a proper solution or let me know if I am missing something ? Any help/suggestion is highly appreciated and simplify my debug a lot.
Thanks a lot in advance !!