我想使用python为gdb创建一些交互式脚本。它在gdb中运行良好,但如果我通过emacs调用gdb,则不起作用。如何从gdb中获取输入(使用python脚本)
例如,python脚本(test.py)如下所示。它只是打印它得到的。
def testInput():
n = raw_input('(gdb) ')
print n
它的工作原理在gdb:
% gdb
GNU gdb (GDB) 7.2.50.20110217
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) source test.py
(gdb) python testInput()
(gdb) 1
1
(gdb) q
但在Emacs,它会挂在 “的raw_input” 和永远无法得到的输入:
(gdb) source test.py
(gdb) python testInput()
(gdb) 1
2
...
反正有做它和gdb一样工作?
的问题是从你的脚本的提示,你需要的正则表达式匹配你需要的emacs认识到作为提示所有的东西。 – 2011-09-02 05:53:32
我改变了脚本,所以它使用与原始gdb相同的提示符,但它仍然不起作用。 – vicshen 2011-09-02 05:58:40
啊,对不起,误解了你以前的评论。没有线索。 – 2011-09-02 06:10:14