GDB Python解析重载方法

GDB Python解析重载方法,python,c++,gdb,gdb-python,Python,C++,Gdb,Gdb Python,如何使用python接口在GDB中查找重载方法 我有一个类,它有几个叫做“el”的方法,其中一个取两个ints。GDB在断点处停止,在次进程的作用域中有一个名为\u Dr的成员变量。我这样做是为了得到一个Pythongdb.Value对象,表示\u Dr: (gdb) python _Dr = gdb.parse_and_eval('_Dr') 现在我想得到el(int,int)方法: (gdb) python el = _Dr['el'] Traceback (most recent cal

如何使用python接口在GDB中查找重载方法

我有一个类,它有几个叫做“el”的方法,其中一个取两个
int
s。GDB在断点处停止,在次进程的作用域中有一个名为
\u Dr
的成员变量。我这样做是为了得到一个Python
gdb.Value
对象,表示
\u Dr

(gdb) python _Dr = gdb.parse_and_eval('_Dr')
现在我想得到
el(int,int)
方法:

(gdb) python el = _Dr['el']
Traceback (most recent call last):
  File "<string>", line 1, in <module>
gdb.error: cannot resolve overloaded method `el': no arguments supplied
Error while executing Python code.
(gdb)python el=\u Dr['el']
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
gdb.error:无法解析重载方法“el”:未提供参数
执行Python代码时出错。
如何告诉它解决重载的参数类型

我试过这个:

(gdb) python el = _Dr['el(int,int)']
Traceback (most recent call last):
  File "<string>", line 1, in <module>
gdb.error: There is no member or method named el(int,int).
Error while executing Python code.
(gdb)python el=\u Dr['el(int,int)]
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
错误:没有名为el(int,int)的成员或方法。
执行Python代码时出错。
这是:

(gdb) python el = _Dr['el', 'int', 'int']
Traceback (most recent call last):
  File "<string>", line 1, in <module>
TypeError: Could not convert Python object: ('el', 'int', 'int').
Error while executing Python code.
(gdb) python el = _Dr['el(1,1)']
Traceback (most recent call last):
  File "<string>", line 1, in <module>
gdb.error: There is no member or method named el(1,1).
Error while executing Python code.
(gdb)python el=\u Dr['el','int','int']
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
TypeError:无法转换Python对象:('el','int','int')。
执行Python代码时出错。
这是:

(gdb) python el = _Dr['el', 'int', 'int']
Traceback (most recent call last):
  File "<string>", line 1, in <module>
TypeError: Could not convert Python object: ('el', 'int', 'int').
Error while executing Python code.
(gdb) python el = _Dr['el(1,1)']
Traceback (most recent call last):
  File "<string>", line 1, in <module>
gdb.error: There is no member or method named el(1,1).
Error while executing Python code.
(gdb)python el=_Dr['el(1,1)]
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
gdb.error:没有名为el(1,1)的成员或方法。
执行Python代码时出错。

正确的方法是什么?

最好的方法是迭代类型的字段,寻找所需的字段

比如:

for field in _Dr.type.fields():
  if field.name == 'el':
    ... check field.type here ...

有关更多详细信息,请参阅gdb手册中的节点“Types in Python”。

是的,尽管该方法位于基类上,但我想我还必须向下搜索继承树。