[Google Breakpad] crash_generation_app例子研究 -- 进程外和进程内dump的区别

来源:互联网 发布:unity3d做ar 编辑:程序博客网 时间:2024/05/18 03:39

src/client/windows/tests/crash_generation_app下的例子编译失败,看了看,有些地方需要更改一下(以release为例)

1.C++ -> Code Generation -> Runtime Library -> Multi-threaded (/MT)

2. Linker -> Additional Library Directories -> ../../$(ConfigurationName)/lib

3. Linker -> Input -> Additional Dependencies -> common.lib exception_handler.lib crash_report_sender.lib crash_generation_client.lib crash_generation_server.lib

4.crash_generation_app.cc 中将dump路径"C://Dump"之类的改成"."

 

 

从网上找了个两个图简单解释一下breakpad的流程

 

进程外Dump :由独立的Crash Handle Process处理Dump的生成过程,主进程产生异常时,通过IPC方式通知Crash Handle Process。由Crash Handle Process中的crash_generation_server负责写Dump文件。大致流程如下:

进程外捕获方式
上图中,crash_generation_client和crash_generation_server之间是进程间通讯(IPC)。crash_report_sender负责将dump信息发送到google的crash report server(https://clients2.google.com/cr/report)。

进程内Dump :与进程外方式类似,只不过在Browser进程中增加了一个crash_handle_thread线程,由此线程负责写dump.基本流程如下:
进程内捕获方式 

在crash_generation_app中,默认的代码是使用了IPC的进程外dump方式
CrashServerStart();
  // This is needed for CRT to not show dialog for invalid param
  // failures and instead let the code handle it.
  _CrtSetReportMode(_CRT_ASSERT, 0);
 handler = new ExceptionHandler(L".",
                                 NULL,
         google_breakpad::ShowDumpResults,
                                 NULL,
                                 ExceptionHandler::HANDLER_ALL,
         MiniDumpNormal,
         kPipeName,
         &custom_info );
这种方式生成的exe在只运行一个程序crash时,生成的dmp文件,用vs打开无法定位崩溃点
而运行两个程序,第二个程序crash后生成的dump文件,用vs打开可以正确定位崩溃点
说明进程外dump外方式需要一个独立的进程生成dump文件
而要想使用进程内dump方式,需要改成如下代码
//CrashServerStart();
  // This is needed for CRT to not show dialog for invalid param
  // failures and instead let the code handle it.
  _CrtSetReportMode(_CRT_ASSERT, 0);
 handler = new ExceptionHandler(L".",
                                 NULL,
         google_breakpad::ShowDumpResults,
                                 NULL,
                                 ExceptionHandler::HANDLER_ALL);
原创粉丝点击