进程终止C++

Bor*_*kov 1 c++ windows termination process

我有以下问题:我有一个用C++编写的应用程序(永远不会结束的服务器)作为服务运行,包含主线程内部还有3个线程(主要是做IO).

在主循环中,我捕获所有可能的异常.

该过程终止,主循环或线程本身没有打印任何内容.我在事件日志中看到进程已停止,代码为1000.

  1. Windows是否像unix一样创建Core文件?
  2. 如果从事件日志中得到一个内存地址,有没有办法知道应用程序中的哪个部分发生了?
  3. 也许这是一个线索:在它发生的同时我开始了另一个应用程序(不是同一类型).

whu*_*nmr 5

尝试将windbg设置为事后调试器.

  1. 安装windbg
  2. 从命令行执行" windbg -I"
  3. 启动您的应用程序,然后当您的应用程序获得未处理的异常时,您将启动windbg.
  4. 从windbg用"kb" or "!uniqstack"来看堆栈跟踪.

    在这里查看更多命令.
    在这里看如何分析.

并尝试使用SEH:

#include "windows.h"
#include "stdio.h"

DWORD FilterFunction() 
{ 
 printf("you will see this message first.\n");
 return EXCEPTION_EXECUTE_HANDLER; 
} 


int main(char** argv, int c)
{
 __try
 {
  int this_will_be_zero = (c == 9999);
  int blowup = 1 / this_will_be_zero;
 }
 __except ( FilterFunction()) 
 {
  printf("you will see this message\n");
 }

 return 0;
}
Run Code Online (Sandbox Code Playgroud)