https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70428
Bug ID: 70428 Summary: -fdebug-prefix-map did not support to remap sources with relative path Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: other Assignee: unassigned at gcc dot gnu.org Reporter: hongxu.jia at windriver dot com Target Milestone: --- 1. Prepare sources and build dir $ pwd /folk/hjia $ mkdir dir1/dir2 test1/test2/ -p $ cat > test1/test2/test.c << ENDOF #include "test.h" int main(int argc, char *argv[]) { func(); return 0; } ENDOF $ cat > test1/test2/test.h << ENDOF void func() { return; } ENDOF $ cd dir1/dir2 2. Enter build dir to compile with relative path sources $ gcc ../../test1/test2/test.c -g -o test.o $ objdump -g test.o | less ---------------- <0><b>: Abbrev Number: 1 (DW_TAG_compile_unit) <c> DW_AT_producer : (indirect string, offset: 0x47): GNU C 4.8.4 -mtune=generic -march=x86-64 -g -fstack-protector <10> DW_AT_language : 1 (ANSI C) <11> DW_AT_name : (indirect string, offset: 0x5): ../../test1/test2/test.c <15> DW_AT_comp_dir : (indirect string, offset: 0x1e): /folk/hjia/dir1/dir2 Contents of the .debug_str section: ---------------- 3. Compile with option -fdebug-prefix-map, it could not remap sources with relative path $ gcc ../../test1/test2/test.c -fdebug-prefix-map=/folk/hjia/test1/test2=/usr/src -g -o test.o $ objdump -g test.o | less ---------------- <0><b>: Abbrev Number: 1 (DW_TAG_compile_unit) <c> DW_AT_producer : (indirect string, offset: 0x47): GNU C 4.8.4 -mtune=generic -march=x86-64 -g -fdebug-prefix-map=/folk/hjia/test1/test2=/usr/src -fstack-protector <10> DW_AT_language : 1 (ANSI C) <11> DW_AT_name : (indirect string, offset: 0x5): ../../test1/test2/test.c <15> DW_AT_comp_dir : (indirect string, offset: 0x1e): /folk/hjia/dir1/dir2 ---------------- What we expected is: ---------------- <11> DW_AT_name : (indirect string, offset: 0x5): /usr/src/test.c <15> DW_AT_comp_dir : (indirect string, offset: 0x15): /folk/hjia/dir1/dir2 ----------------