如何解决如何从emacs中的gdb获取输入使用python脚本
|| 我想使用python为gdb创建一些交互式脚本。它在gdb中效果很好,但是如果我从emacs中调用gdb则无法正常工作。 例如,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中一样工作?
解决方法
用ѭ3调用gdb对我来说解决了这个问题。有关更多详细信息,请参阅Emacs手册的第27章。
希望两年后仍然有帮助...
,在emacs缓冲区中使用交互式外部进程时,当外部进程提示用户输入时,该模式必须能够从缓冲区中识别出来,以便知道需要允许用户输入某些内容。否则,emacs将永远等待该进程输出它可以识别的内容,并且该进程将永远等待输入。由于您的python脚本使用不同的提示符,因此emacs gdb模式永远不会识别正在请求输入。
尝试修改
gdb-prompt-name-regexp
的值。这是ѭ5中的默认值:
(defvar gdb-prompt-name-regexp \"value=\\\"\\\\(.*?\\\\)\\\"\")