2

I'm aware of _catch throw_ or even _catch throw MyExceptionType_.

What I need is everything else than a certain exception type.

jww
  • 97,681
  • 90
  • 411
  • 885

2 Answers2

3

Since gdb uses a regular expression for the exception string, you could use catch throw (?!MyExceptionType) (this will match any exception except for exactly "MyExceptionType")

See also Match everything except for specified strings

Gabriel Ravier
  • 358
  • 1
  • 6
  • 17
  • I have checked your answer and it does not work. Seems like `gdb` does not support the negative lookahead with (?!...). So `catch throw` with the negative lookahead does not work (see also a comment to https://stackoverflow.com/q/34790499/184968) –  Jan 11 '19 at 08:45
  • I tested it myself and it worked (it said "C++ catchpoint not caught" or something like that iirc). – Gabriel Ravier Jan 11 '19 at 09:51
  • @GabrielRavier I wrote a test where I throw exceptions of 2 different types MyExceptionType and TheirExceptionType. When I set `catch throw (?!MyExceptionType)` program does not catch both of them. –  Jan 11 '19 at 10:01
  • struct MyExceptionType {}; struct TheirExceptionType {}; int main() { try { throw MyExceptionType{}; } catch (MyExceptionType&) { } try { throw TheirExceptionType{}; } catch (TheirExceptionType&) { } } –  Jan 11 '19 at 10:01
  • Should I edit it to clarify its wrongness or just remove it ? – Gabriel Ravier Jan 11 '19 at 11:52
  • (gdb) catch throw (?!symphony::smc::eqNW::calculateInputException) Junk at end of arguments. –  Jan 15 '19 at 19:50
1

Specify a condition for the breakpoint on catch throw, look at break condition

bruno
  • 32,421
  • 7
  • 25
  • 37