Hi Alena,
There is at least one other big difference between (platform's) DirectorySourceContainer and (CDT's) CompilationDirectorySourceContainer. The latter implements (CDT's) IMappingSourceContainer. This means that when breakpoints are inserted (and similar operations that need to translate from local machine path to compilation path, such as run to line) when using CompilationDirectorySourceContainer you will get the full compilation path added to breakpoint insertions.
This is the set-up for the below example:
$ pwd
/scratch/eclipse/src/cdt/runtime-CDT/HelloWorld/compilationdirectory
$ gcc -g -o program.exe src/main.c
Then I reorganized things a bit:
$ cd ..
$ mv compilationdirectory relocatedcompilationdirectory
then you have two choices:
1) Remove "Program Relative File Path" from your lookup
2) move the program itself somewhere else so that "Program Relative File Path" does not work.
Once you do that, debug the program and CDT will not be able to locate the source because GDB has only provided the relative directory (src/main.c) in the MI output:
761,836 *stopped,reason="end-stepping-range",frame={addr="0x00000000004004f6",func="main",args=[],fi\
le="src/main.c",line="3"},thread-id="1",stopped-threads="all",core="2"
Using either DirectorySourceContainer or CompilationDirectorySourceContainer with a folder set as
/scratch/eclipse/src/cdt/runtime-CDT/HelloWorld/relocatedcompilationdirectory will locate the file correctly.
However, only CompilationDirectorySourceContainer will allow you to insert breakpoints because only it does the reverse translation.
This is the MI when inserting a breakpoint using a DirectorySourceContainer:
435,345 38-break-insert -f /scratch/eclipse/src/cdt/runtime-CDT/HelloWorld/relocatedcompilationdirec\
tory/src/main.c:3
435,346 &"No source file named /scratch/eclipse/src/cdt/runtime-CDT/HelloWorld/relocatedcompilationd\
irectory/src/main.c.\n"
435,348 38^done,bkpt={number="4",type="breakpoint",disp="keep",enabled="y",addr="<PENDING>",pending=\
"/scratch/eclipse/src/cdt/runtime-CDT/HelloWorld/relocatedcompilationdirectory/src/main.c:3",times="\
0",original-location="/scratch/eclipse/src/cdt/runtime-CDT/HelloWorld/relocatedcompilationdirectory/\
src/main.c:3"}
And this for the CompilationDirectorySourceContainer:
435,349 34-break-insert -f src/main.c:3
435,350 34^done,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="0x00000000004004f6"\
,func="main",file="src/main.c",line="3",times="0",original-location="src/main.c:3"}
Unfortunately the story does not end there. Because the above all applies to GDB <= 7.5. In GDB >= 7.6 neither DirectorySourceContainer nor CompilationDirectorySourceContainer work at all. Starting with GDB 7.6 if GDB can't locate a file it returns a full path to where it thinks the file should be in the fullname field, i.e. the absolute compilation directory. Here is what the MI looks like (compare to the above *stopped):
666,021 *stopped,reason="breakpoint-hit",disp="del",bkptno="2",frame={addr="0x00000000004004f1",func\
="main",args=[],file="src/main.c",fullname="/scratch/eclipse/src/cdt/runtime-CDT/HelloWorld/compilat\
iondirectory/src/main.c",line="2"},thread-id="1",stopped-threads="all",core="1"
Please let me know if I can be of more assistance. I would also appreciate any reviews you can make to my changes for
http://eclip.se/472765.
Thanks,
Jonah