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.

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I was hoping you'd comment, Tom! Thanks for giving me a clue on the source. Yes, it would be better to show something

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.