Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding where std::out_of_range is thrown by std::vector.at()

Normally I would leave it unhandled and the debugger (gdb, Eclipse CDT) would show me the call stack. Unfortunately the code is being called by a third party library which absorbs all exceptions. I can catch the exception before the third party library however I cannot see the call stack (stack-unwinding?).

How can I figure out where the exception was thrown?

like image 872
Ali Avatar asked Jul 06 '11 22:07

Ali


2 Answers

Would catchpoints help? You can break whenever an exception is thrown by entering the catch throw command in gdb. In Eclipse, you can do this through the gdb console. See this question.

like image 82
Fred Larson Avatar answered Sep 18 '22 22:09

Fred Larson


You can put a breakpoint in the constructor for the exception object. Since this occurs before the exception is thrown, you get great visibility into the calling code.

like image 32
Mark Ransom Avatar answered Sep 17 '22 22:09

Mark Ransom