pwncollege / dojo

Infrastructure powering the pwn.college dojo
https://pwn.college
BSD 2-Clause "Simplified" License
303 stars 100 forks source link

Fix GDB Symbols #467

Open ConnorNelson opened 4 months ago

ConnorNelson commented 4 months ago

Nix is tricky! It seems like the challenge image might need to be a bit more explicit about things.

This shows that image gdb knows where to find libc debug info:

strace /usr/bin/gdb --batch -ex 'starti' -ex 'c' -ex 'p __libc_start_main' /bin/false 2>&1 | grep open | grep debug | grep 02430

Unfortunately nix gdb does not:

strace gdb --batch -ex 'starti' -ex 'c' -ex 'p __libc_start_main' /bin/false 2>&1 | grep open | grep debug | grep 02430

With -ex 'set debug-file-directory /lib/debug' nix gdb can find the debug info:

strace gdb --batch -ex 'set debug-file-directory /lib/debug' -ex 'starti' -ex 'c' -ex 'p __libc_start_main' /bin/false 2>&1 | grep open | grep debug | grep 02430

Rather than have users manually perform this, I think we can get a system gdbinit that always runs, or maybe theres an ENV variable for us to set, or otherwise we can patch nix gdb (but this sounds unideal because this is a challenge image attribute).

spencerpogo commented 4 months ago

Have you tried exporting NIX_DEBUG_INFO_DIRS? Reference: https://nixos.wiki/wiki/Debug_Symbols