开发者

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?


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.


Just give same trailing components that differs the file from others :

filename:linenum Specifies the line linenum in the source file filename. If filename is a relative file name, then it will match any source file name with the same trailing components. For example, if filename is `gcc/expr.c', then it will match source file name of /build/trunk/gcc/expr.c, but not /build/trunk/libcpp/expr.c or /build/trunk/gcc/x-expr.c.

https://www.zeuthen.desy.de/dv/documentation/unixguide/infohtml/gdb/Specify-Location.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜