Yes, you can do this kind of thing:
(gdb) print PyRun_SimpleString("import traceback; traceback.print_stack()")
File "<string>", line 1, in <module>
File "/var/tmp/foo.py", line 2, in <module>
i**2
File "<string>", line 1, in <module>
$1 = 0
It should also be possible to use the pystack
command defined in the python gdbinit file, but it's not working for me. It's discussed here if you want to look into it.
Also, if you suspect memory issues, it's worth noting that you can use valgrind
with python, if you're prepared to recompile it. The procedure is described here.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…