Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change the debug path included in the DWARF info of a binary by the compiler

GCC includes the path to the source file that was used to generate an object file in its DWARF debug information (when compiled with -g).

However, GDB's search rules mean that I have to use the lesser-known set subsitute-path if I moved the source-code to a different subdirectory. Alternatively, maybe I want to hide some path information of my source files, of maybe just shorten it.

Does GCC provide an option to change the source path it includes in debug information of a binary?

like image 991
John de Largentaye Avatar asked Oct 22 '15 23:10

John de Largentaye


1 Answers

Use the -fdebug-prefix-map=old_path=new_path option to GCC.

As far as I can find, LLVM/Clang does not provide an equivalent option.

like image 181
John de Largentaye Avatar answered Oct 02 '22 20:10

John de Largentaye