Hello,
I’m currently trying to debug python using gdb. In order to ease reproducibility, I’ve created a minimal shell.nix and test.py.
with import <nixpkgs> {};
let
pythonDbg = enableDebugging python37;
in
mkShell {
buildInputs = [
gdb
pythonDbg
];
}
# Just some nested function calls so we get a nice stacktrace
import time
def test1():
print("test1")
test2()
def test2():
print("test2")
test3()
def test3():
print("test3")
time.sleep(30)
By running :b (enableDebugging pkgs.python37)
in the repl, I get the following output:
this derivation produced the following outputs:
debug -> /nix/store/<debughash>-python3-3.7.9-debug
out -> /nix/store/<binhash>-python3-3.7.9
The .debug file at the <debughash>/lib/debug/python3.7 link has a name which corresponds to the build id of <binhash>/bin/python3.7, so this part looks fine. However, the size of the debug file is only 4kb and strings
shows almost no content.
After entering the nix-shell and starting the python script, I attach to it with gdb. In the startup message I can see that gdb was unable to find any debug symbols for <binhash>/bin/python3.7. I source the libpython.py script and run set debug-file-directory <debughash>/lib/debug
. At this point gdb should be able to read the python frame information but it isn’t. py-bt
returns “unable to read python frame information”.
What am I doing wrong?