准备
1、Python
2、Visual Studio
3、svn checkout http://google-breakpad.googlecode.com/svn/trunk/ source code
编译
1、转到google-breakpad根目录下,打开命令行,运行 src\tools\gyp\gyp.bat src\client\windows\breakpad_client.gyp --no-circular-check
如果不加 --no-circular-check 参数,将会看到以下信息:
Traceback (most recent call last): File "D:\google_breakpad\src\tools\gyp\/gyp", line 18, insys.exit(gyp.main(sys.argv[1:])) File "D:\google_breakpad\src\tools\gyp\pylib\gyp\__init__.py", line 511, in main return gyp_main(args) File "D:\google_breakpad\src\tools\gyp\pylib\gyp\__init__.py", line 494, in gyp_main options.circular_check) File "D:\google_breakpad\src\tools\gyp\pylib\gyp\__init__.py", line 133, in Load depth, generator_input_info, check, circular_check) File "D:\google_breakpad\src\tools\gyp\pylib\gyp\input.py", line 2412, in Load VerifyNoGYPFileCircularDependencies(targets) File "D:\google_breakpad\src\tools\gyp\pylib\gyp\input.py", line 1536, in Veri fyNoGYPFileCircularDependencies ' '.join(bad_files)gyp.input.CircularException: Some files not reachable, cycle in .gyp file dependency graph detected involving some or all of: src\client\windows\handler\exception_handler.gyp src\client\windows\tests\crash_generation_app\crash_generation_app.gyp src\client\windows\breakpad_client.gyp src\client\windows\sender\crash_report_sender.gyp src\client\windows\unittests\client_tests.gyp src\client\windows\crash_generation\crash_generation.gyp
2、运行之后在 src\client\windows目录下会生成一个solution,开打solution,F7生成。
注意:Debug版生成的时候一切正常,但切换到Release版本之后,生成的时候会遇到一个错误:
6>------ 已启动生成: 项目: crash_generation_server, 配置: Release Win32 ------6>生成启动时间为 2013/8/18 11:00:13。5>生成启动时间为 2013/8/18 11:00:13。6>InitializeBuildStatus:6> 正在创建“D:\google_breakpad\src\client\windows\Release\obj\crash_generation_server\crash_generation_server.unsuccessfulbuild”,因为已指定“AlwaysCreate”。5>InitializeBuildStatus:5> 正在创建“D:\google_breakpad\src\client\windows\Release\obj\common\common.unsuccessfulbuild”,因为已指定“AlwaysCreate”。6>ClCompile:6> client_info.cc6> minidump_generator.cc6> crash_generation_server.cc6>crash_generation_server.cc(391): error C2220: 警告被视为错误 - 没有生成“object”文件6>crash_generation_server.cc(391): warning C4189: “error_code”: 局部变量已初始化但不引用6>crash_generation_server.cc(471): warning C4189: “error_code”: 局部变量已初始化但不引用6>crash_generation_server.cc(520): warning C4189: “error_code”: 局部变量已初始化但不引用5>ClCompile:5> http_upload.cc5> guid_string.cc5> string_utils.cc2>Lib:2> gtest.vcxproj -> D:\google_breakpad\src\client\windows\Release\lib\gtest.lib2>FinalizeBuildStatus:2> 正在删除文件“D:\google_breakpad\src\client\windows\Release\obj\gtest\gtest.unsuccessfulbuild”。2> 正在对“D:\google_breakpad\src\client\windows\Release\obj\gtest\gtest.lastbuildstate”执行 Touch 任务。2>2>生成成功。2>2>已用时间 00:00:18.076>6>生成失败。
原因是错误被视为警告的选项,在Release模式下编译的时候增加了NDEBUG选项,导致了assert被关掉了,所以error_code没有被其他地方引用到,所以编译器发出警告。
然后又被视为错误,所以导致crash_generation_server工程编译失败。
void CrashGenerationServer::HandleReadingState() { assert(server_state_ == IPC_SERVER_STATE_READING); DWORD bytes_count = 0; bool success = GetOverlappedResult(pipe_, &overlapped_, &bytes_count, FALSE) != FALSE; DWORD error_code = success ? ERROR_SUCCESS : GetLastError(); if (success && bytes_count == sizeof(ProtocolMessage)) { EnterStateImmediately(IPC_SERVER_STATE_READ_DONE); } else { // We should never get an I/O incomplete since we should not execute this // unless the Read has finished and the overlapped event is signaled. If // we do get INCOMPLETE, we have a bug in our code. assert(error_code != ERROR_IO_INCOMPLETE); EnterStateImmediately(IPC_SERVER_STATE_DISCONNECTING); }}
最简单的解决方法是在下图的这个地方添加4189的警告。
然后重新生成,问题解决。
这次就先介绍到这里,下次介绍一下breakpad的使用。