This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Relative Path for Source File


Hi, 

Is there a way in gcc to specify a relative path for source file so that gdb can use the relative path to look for the source? 

Let me explain it by an example. Suppose we have the following sources:
   src: a.c, makefile
   src/sub1: b.c, makefile
   src/sub2: d.c, makefile
The
master makefile in src will compile a.c and there go to all sub
directories (sub1 and sub2) and run its makefiles. Suppose a.c links
with the libararies produced by sub directories, and produce an
executable a.out. Now when we start gdb to debug a.out, it could not
find source file b.c and d.c since sub1 and sub2 are not in the source
file search path. In this case, we can add these two paths in to gdb
source path. However, in reality, there are lots of subdirectories,
some of them are more than 1 level deep. It becomes tedious soon to add
all these path to search path. 

Now
if we have an option in gcc to specify a relative path (e.g., in sub1,
we tell gcc to remember the relative path sub1 in the debug info), we
don't add sub1, sub2 to source path. Most importantly, if the a.out is
in different directory (even different machine), we only need to add
root directoy (src in this case) to gdb's source path.

I did some research, and could not find an answer. Is this possible in gcc? Any help will be greatly appreciated.

Best regards,

Jiafu


      


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]