Re: trouble locating source files through relative paths

Bob Rossi
2005-08-19T12:43:36Z

> I've been having trouble getting GDB (v6.3 build myself from source on
> RHEL4) to locate the source files associated with the binary I'm
> debugging. The binary refers to some source files using relative paths
> say for example:
>
> ../../include/General/GeString.H
>
> This file exists but the path from which the relative path should start
> differs now because the binary has been moved.
>
> I've added the correct starting path to my source search path using the
> 'dir' command and expect GDB to find the file now as described in the
> GDB manual here:
> http://sources.redhat.com/gdb/download/onlinedocs/gdb_8.html#SEC53

What was the 'dir' command that you issued? What compiler are you using?
Do you know what debug format you are using? (stabs or dwarf)?

Have you tried using the cdir command? That might work.

> However an strace of GDB shows that it only looks for GeString.H in the
> newly specified search path directory and doesn't ever try using the
> search path as a base for the relative directories.
>
> If I ignore the relative path and set the search path to the full path
> to this file it works, however the application has hundreds of files,
> some of which have conflicting names if the directory path isn't
> included.
>
> How can I get GDB to use the search path as a base for relative paths
> specified in the debug info rather than only looking directly in the
> search path dirs?

I've done this before, so I know that it worked at some point. It should
still work.

Bob Rossi