Search code examples
c++visual-studio-2013exceptiongoogletest

Don't know where exception was thrown using google-test


We are using Google Test as our C++ unit testing framework. But I ran into a painful situation and don't know how to deal with.

Basically, when there is an uncaught exception in the code, I got the following error message printed in the console and get a FAILED. Obviously, the exception is captures by google test. However, I have no information at all where is the exception was throw.

unknown file: error: SEH exception with code 0xc000005 thrown in the test body.

What I can do is debug and step through the code and I will eventually figure out where the problem is. But this is not very efficient as the project is big.

I want the debugger to stop at the line of uncaught exception and give me a nice call stack. Is there any settings in google test that I don't know of? Any other work around or suggestions will be very much appreciated.

Edit: I am looking for something like the following under Windows enter image description here

Finally according to the answers, I found this settings for visual studio and everything works as the way I want now :) enter image description here


Solution

  • An SEH Exception is NOT a C++ exception.

    It is a windows exception that is throw outside of the standard C++ framework for exception handing (there is a different syntax for catching them).

    The best way to find the location is to run this inside DevStudio. Its been a while but I am sure DevStudio has an option to break when SEH exception is thrown. Just turn this on and your debugger will stop at the throw point and allow you to debug.

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

    As noted by @MatthiasVegh you should pass the name of the test as well so you don't have to run through all the tests.