gdb python脚本:哪里有`parse_and_eval`走了? [英] gdb python scripting: where has `parse_and_eval` gone?
问题描述
我在Python中使用了一些脚本来帮助我使用GDB进行调试,该功能使用 gdb.parse_and_eval
(仍有记录)从传递给脚本命令的参数中获取较低的值,现在模块不会似乎没有任何此功能的痕迹。做 python import gdb;从GDB打印dir(gdb)
清楚地表明缺少这个函数。
我之前为GDB 6.8编写了脚本 archer 分支,现在我找不到任何有关它是否已被弃用或GDB 7发生了什么的信息。
有关它的任何信息? / p>
谢谢!
我不知道它到了哪里为什么,但Qt在他们的代码中实施了这种解决方法,它可能对你有用:
def parseAndEvaluate(exp):
if gdb.VERSION.startswith(6.8 .50.2009):
返回gdb.parse_and_eval(exp)
#解决不存在的gdb.parse_and_eval和释放版本7.0
gdb.execute(set logging redirect on)
gdb.execute(set logging on)
gd b.execute(print%s%exp)
gdb.execute(set logging off)
return gdb.history(0)
I had some scripts in Python to help me debugging with GDB that used the function gdb.parse_and_eval
(still documented) to get the inferior values from the arguments passed to a scripted command, and now the module doesn't seem to have any trace of that function. Doing python import gdb; print dir(gdb)
from GDB clearly shows that this function is missing.
I wrote the scripts some time ago for the GDB 6.8 in the archer branch, and now I cannot find any information about if it's been deprecated or what happened in GDB 7.
Any information about it?
Thanks!
I don't know where it went or why, but Qt implemented this workaround in their code, which may be practically useful to you:
def parseAndEvaluate(exp):
if gdb.VERSION.startswith("6.8.50.2009"):
return gdb.parse_and_eval(exp)
# Work around non-existing gdb.parse_and_eval as in released 7.0
gdb.execute("set logging redirect on")
gdb.execute("set logging on")
gdb.execute("print %s" % exp)
gdb.execute("set logging off")
return gdb.history(0)
这篇关于gdb python脚本:哪里有`parse_and_eval`走了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!