18

I am debugging code with exception throwing and exception handling. I would like gdb to break immediately when an exception is thrown, so i can inspect the state of the program and the call stack. How can I make gdb break when any exception is thrown?

zr.
  • 7,240
  • 10
  • 48
  • 81

1 Answers1

24

You can do this with the catch throw command. See here:

catch event

Stop when event occurs. The event can be any of the following:

throw [regexp]

rethrow [regexp]

catch [regexp]

The throwing, re-throwing, or catching of a C++ exception.

If regexp is given, then only exceptions whose type matches the regular expression will be caught.

Daniel Hershcovich
  • 3,581
  • 2
  • 28
  • 35