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 ?