I want to set a break point in gdb on file service.cpp on line 45 and I do:
gdb> break service.cpp:45
The problem is that there are many service.cpp files in my application and it is not picking the one I am interested in. How can I specify the right service.cpp file?
Setting breakpoints A breakpoint is like a stop sign in your code -- whenever gdb gets to a breakpoint it halts execution of your program and allows you to examine it. To set breakpoints, type "break [filename]:[linenumber]". For example, if you wanted to set a breakpoint at line 55 of main.
Right-click the breakpoint symbol and select Conditions (or press Alt + F9, C). Or hover over the breakpoint symbol, select the Settings icon, and then select Conditions in the Breakpoint Settings window.
Press F3 and then press F9 to add a breakpoint.
In software development, a breakpoint is an intentional stopping or pausing place in a program, put in place for debugging purposes. It is also sometimes simply referred to as a pause.
Specify the full path:
gdb> break /Full/path/to/service.cpp:45
In addition to @Carl 's answer,
In case anyone gets No source file named /Full/path/to/service.c
like @Tobias, make sure to add the debugging -g
flag to main and the source file you want to access, like main.c
and foo.c
.
Then make sure main
uses the -g
compiled operable
file, wich might mean you'd have to update and relink a library, for instance.
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