3

The gdb docs say the compilation directory may be recorded in the executable file https://sourceware.org/gdb/current/onlinedocs/gdb/Source-Path.html

Executable programs sometimes do not record the directories of the source files from which they were compiled, just the names. Even when they do, the directories could be moved between the compilation and your debugging session.

Assuming the executable file records the compilation directory. How to print the compilation directory ?

1 Answer 1

4

Like so:

cd /tmp
gcc -g t.c
readelf -Wwi a.out | grep DW_AT_comp_dir

    <15>   DW_AT_comp_dir    : (indirect string, offset: 0x2ab): /tmp
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.