0

I am a C developer looking into C++:

Do I understand it correctly that if I throw an exception then the stack will unwind until the first exception-handler is found? Is it possible to instead open a debugger upon any throw without unwinding (ie without leaving the scope in which it was declared or any higher scope)?

The reason I am asking is, that - even though there are exception handlers in a higher scope - I am interested in the locals of that scope (and also dont want to lose the RAII'ed objs) and want to look at them during debugging.

EDIT: mostly for g++ on win+linux, but also interested in other platforms.

ben
  • 452
  • 3
  • 10

1 Answers1

1

You didn't specify your toolset/platform.

But in MSVC you can configure the debugger to break on various types of exceptions, in your case it would be C++ exceptions.

See here for details:

http://msdn.microsoft.com/en-us/library/d14azbfh.aspx

Edit: For gcc/gdb see this question Run an Application in GDB Until an Exception Occurs

Community
  • 1
  • 1
paulm
  • 5,629
  • 7
  • 47
  • 70
  • For future reference: MSDN says: `the debugger can break execution of your application immediately when an exception occurs, giving you a chance to debug the exception before a handler is invoked....` – ben Feb 15 '14 at 16:54