SKPS
SKPS

Reputation: 5855

Not able to set gdb breakpoint

I work on program with multiple C++ files. I have run the executable through gdb for debugging segmentation fault. Later, gdb backtrace provided the list of functions before segmentation fault. Later, I tried to set a break point in a file on a particular line-number. (The path specified is absolute path)

(gdb) break /aia/r015/home/sathish/zfs_amr/src/zfslbminterfaced2q9.cpp:100

However, gdb gives the following message:

No source file named /aia/r015/home/sathish/zfs_amr/src/zfslbminterfaced2q9.cpp.

However, this particular does exist in the location. What really the message means?

Upvotes: 2

Views: 4582

Answers (1)

Employed Russian
Employed Russian

Reputation: 213877

What really the message means?

The message means that GDB does not know about any source file named /aia/r015/home/sathish/zfs_amr/src/zfslbminterfaced2q9.cpp.

There are multiple reasons this could be the case:

  • The debug info for this file is missing, either because that file is compiled without -g, or because the debug info was (possibly inadvertantly) stripped later on,
  • There are some symbolic links in the above path, and GDB knows that file by fully-resolved pathname instead,
  • The file is actually not linked into the executable at all,
  • The file part of a shared library, and symbols for that shared library haven't been loaded yet,
  • Etc.

As Pat suggested, setting breakpoint on zfslbminterfaced2q9.cpp:100 is more likely to work.

If that doesn't work, info sources will tell you which files GDB does know about.

Update:

info sources gives blank

This means that the application doesn't have any debug info at all.

Usually this happens for one of two reasons:

  • You neglected to specify -g on the link line (some platforms require -g both at compile and link time),
  • You have a "stray" -s somewhere on your link line (which strips the final executable).

Upvotes: 3

Related Questions