我想使用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