First, you can compile your project using debugging information (gcc -g) and use objdump to get the source files.
objdump -W <some_compiled_binary>
The dwarf format should contain the information you are looking for.
<0><b>: Abbrev Number: 1 (DW_TAG_compile_unit) < c> DW_AT_producer : (indirect string, offset: 0x5f): GNU C 4.4.3 <10> DW_AT_language : 1 (ANSI C) <11> DW_AT_name : (indirect string, offset: 0x28): test_3.c <15> DW_AT_comp_dir : (indirect string, offset: 0x36): /home/auselen/trials <19> DW_AT_low_pc : 0x82f0 <1d> DW_AT_high_pc : 0x8408 <21> DW_AT_stmt_list : 0x0
In this example, I compiled the object file from test_3, and it was located in the ... / tests directory. Then, of course, you need to write a script around this to collect the associated source file names.
source share