How to set break point on one file of a project which has many files with same name?
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