py-bt和相关命令通常在GDB脚本文件python * -gdb.py中定义,该文件往往存在于/usr/share / gdb / auto-load /usr/bin /中.如果在调试Python对象文件时GDB中没有这些命令,则表示包含它们的脚本未自动加载.
要找出原因,请启用自动加载调试:
(gdb) set debug auto-load
并尝试加载Python可执行文件:
(gdb) file python3
您应该看到与此类似的输出:
Reading symbols from python3...Reading symbols from /usr/lib/debug/.build-id/58/bce0c98a07039868053ed4b27e79959caadb9d.debug...done.
auto-load: Attempted file "/usr/lib/debug/.build-id/58/bce0c98a07039868053ed4b27e79959caadb9d.debug-gdb.gdb" does not exist.
auto-load: Expanded $-variables to "/usr/lib/debug:/usr/share/gdb/auto-load".
auto-load: Searching 'set auto-load scripts-directory' path "$debugdir:$datadir/auto-load".
auto-load: Attempted file "/usr/lib/debug/usr/lib/debug/.build-id/58/bce0c98a07039868053ed4b27e79959caadb9d.debug-gdb.gdb" does not exist.
auto-load: