Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set break point on one file of a project which has many files with same name?

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?

like image 435
WilliamKF Avatar asked Mar 11 '11 18:03

WilliamKF


People also ask

How do I set a breakpoint in a specific file in GDB?

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.

How do I apply a conditional breakpoint in Visual Studio?

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.

How do I add a breakpoint to all methods in visual studio?

Press F3 and then press F9 to add a breakpoint.

What is a breakpoint in debugging?

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.


2 Answers

Specify the full path:

gdb> break /Full/path/to/service.cpp:45 
like image 97
Carl Norum Avatar answered Sep 29 '22 13:09

Carl Norum


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.

like image 41
banmosh Avatar answered Sep 29 '22 14:09

banmosh