调用GDB.execute时GDB Python API抛出GDB.error
我希望以任意慢的速度执行C/C++代码。事实证明这很难,我决定使用GDB,并以设定的速度逐步完成程序。我尝试使用GDB Python API,如下所示:调用GDB.execute时GDB Python API抛出GDB.error,python,gdb,gdb-python,Python,Gdb,Gdb Python,我希望以任意慢的速度执行C/C++代码。事实证明这很难,我决定使用GDB,并以设定的速度逐步完成程序。我尝试使用GDB Python API,如下所示: res = gdb.execute('break main\n', to_string=True) #print(res) res = gdb.execute('run\n', to_string=True) print(res) res = gdb.execute('next\n', from_tty=True, to_string=True
res = gdb.execute('break main\n', to_string=True)
#print(res)
res = gdb.execute('run\n', to_string=True)
print(res)
res = gdb.execute('next\n', from_tty=True, to_string=True)
print(res)
但我得到了这个错误:
Traceback (most recent call last):
File "gdb_script.py", line 15, in <module>
run()
File "gdb_script.py", line 11, in run
res = gdb.execute('next\n', from_tty=True, to_string=True)
gdb.error: A syntax error in expression, near `'.
看起来这是在8.1.1和8.2之间修复的。在早期版本中,解决方法是在gdb.execute的参数中省略尾随的
\n
。我想修复这个问题的补丁是
g++ -g -DASIO_STANDALONE -std=c++11 -Wall -Iasio/include main.cpp -o main.exe -lws2_32