python - 如何从Python访问gdb

标签 python linux gdb

我正在寻找一种从 python 访问 gdb 结果的方法。我需要使用 gdb 调试 c 程序并从 python 访问结果。这就像从python调用gdb来调试c程序一样。

最佳答案

使用subprocess在已编译的二进制文件上调用 gdb(例如 a.out):

import subprocess

# if you have arguments to gdb, you can supply then in the list itself.
proc = subprocess.Popen(['gdb', 'a.out'],
                        stdin=subprocess.PIPE,
                        )
proc.communicate('\tGDB Output:\n')

引用:

http://pymotw.com/2/subprocess/

关于python - 如何从Python访问gdb,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28468695/

相关文章:

python /Pillow : How to scale an image

c++ - 在没有/proc/self/exe 的情况下查找当前可执行文件的路径

c - 共享库中的 gdb 断点不起作用

linux - 为什么 "find -mmin -1 -exec du -cb {} + | grep total | head -1"和 "find -mmin -1 -exec du -ch {} + | grep total | head -1"不同

c - GDB 跳过共享库断点

macos - 如何在 OSX 10.9 上安装 gdb

python - 在Python标准库中添加模块

python - Numpy argsort 与 Scipy.stats 排名数据

python - 将字符串从 xmlcharrefreplace 转换回 utf-8

linux - 命令源码