简体   繁体   English

gdb Python API:异常消失了吗?

[英]gdb Python API: exceptions disappearing?

Does anyone know why, in certain places, Python code inside of gdb doesn't properly handle exceptions? 有谁知道为什么在某些地方gdb内的Python代码不能正确处理异常? Or, to clarify, perhaps the exception message is going somewhere other than the *gud buffer. 或者,为澄清起见,异常消息可能会流向* gud缓冲区之外的其他地方。 gdb is not returning control to the prompt, as expected. gdb没有按预期将控制权返回给提示符。

(I'm using GNU gdb (GDB) 7.11.50.20160212-git in Emacs (24.5.1) gud mode) (我在Emacs(24.5.1)gud模式下使用GNU gdb(GDB)7.11.50.20160212-git)

For example: 例如:

class SomeEvent():
   def __init__(self, ...):
      ... do something ...
   def __call__(self):
      ... do something BAD here ...


gdb.post_event(SomeEvent())

When 'SomeEvent' is handled, it will just execute '__call__' up to the bad code, return, and then continue normal operation (as I can observe). 处理'SomeEvent'时,它将只执行'__call__'直到坏代码,返回,然后继续正常操作(如我所见)。

I've noticed this behavior in other 'callback' type methods, such as Stop() of a subclassed gdb.Breakpoint. 我在其他“回调”类型的方法中注意到了这一现象,例如子类gdb.Breakpoint的Stop()。

gdb.post_event ignores exceptions when the event object is invoked. 调用事件对象时, gdb.post_event忽略异常。 You can see this clearly in the source code, in gdbpy_run_events : 您可以在源代码gdbpy_run_events清楚地看到这gdbpy_run_events

  /* Ignore errors.  */
  call_result = PyObject_CallObject (item->event, NULL);
  if (call_result == NULL)
    PyErr_Clear ();

This seems like a bug to me -- it would be more useful to print a stack trace or something instead. 在我看来,这似乎是一个错误-打印堆栈跟踪或其他内容会更有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM