How can I debug a win32 process that unexpectedly terminates silently?

前端 未结 11 2068
你的背包
你的背包 2021-02-03 13:29

I have a Windows application written in C++ that occasionally evaporates. I use the word evaporate because there is nothing left behind: no \"we\'re sorry\" message from Window

11条回答
  •  礼貌的吻别
    2021-02-03 13:52

    All the other ideas posted are good.

    But it also sounds like the application is calling abort() or terminate().

    If you run it in the debugger set a breakpoint on both these methods and exit() just for good measure.

    Here is a list of situations that will cause terminate to be called because of exceptions going wrong.

    See also: Why destructor is not called on exception?

    This shows that an application will terminate() if an exceptions is not caught. So stick a catch block in main() that reports the error (to a log file) then re-throw.

    int main()
    {
        try
        {
            // Do your code here.
        }
        catch(...)
        {
            // Log Error;
            throw;  // re-throw the error for the de-bugger.
        }
    }
    

提交回复
热议问题