In my code base, there are some callbacks functions which are defined in anonymous namespace. I am debugging in gdb and I want to set breakpoint in the function using function name. I also tried putting breakpoint by using filename : linenum , but that will generally work if the file is already loaded or else it will say "No source file found" Make breakpoint pending on future shared library load? (y or [n]) n
So, the workaround is that once the debugger is inside the same file, I can set breakpoint using filename : line number
But is there any other way to set breakpoints inside anonymous namespace ?
Related stackoverflow questions : How to set breakpoint by function name inside anonymous namespace in Visual Studio?
But this does not solve the problem over here.
As per some post in stackoverflow,
namespace { int function_name(int a, int b) { return a+b; } }
"No source file found" /root/workspace/ProtocolInterface.cpp. Make breakpoint pending on future shared library load? (y or [n]) y
Even if the breakpoint pending, it does not break at the mentioned function.
I think anonymous namespace must be in parentheses.
(gdb) b (anonymous namespace)::function_name
It worked for me, please give it a try.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With