0

Does anyone know why, in certain places, Python code inside of gdb doesn't properly handle exceptions? Or, to clarify, perhaps the exception message is going somewhere other than the *gud buffer. gdb is not returning control to the prompt, as expected.

(I'm using GNU gdb (GDB) 7.11.50.20160212-git in Emacs (24.5.1) gud mode)

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).

I've noticed this behavior in other 'callback' type methods, such as Stop() of a subclassed gdb.Breakpoint.

Geof Sawaya
  • 55
  • 2
  • 7

1 Answers1

1

gdb.post_event ignores exceptions when the event object is invoked. You can see this clearly in the source code, in 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.

Tom Tromey
  • 21,507
  • 2
  • 45
  • 63
  • I was hoping you'd comment, Tom! Thanks for giving me a clue on the source. Yes, it would be better to show _something_ – Geof Sawaya Apr 01 '16 at 03:19