Windows client code
The Windows client code is located src/client/windows
in the directory tree. Because the header files are fairly well commented, some details are intentionally omitted from this document.
Integration generated by minidump
Once you compile src/client/windows
the visual studio solution within , exception_handler.lib
an output file named will be generated. You can check it into your project directory or build it directly from source, just like the project itself.
Enabling Breakpad in your application requires you #include "exception_handler.h"
to instantiate the Breakpad ExceptionHandler
object, like this:
handler = new ExceptionHandler(const wstring& dump_path,
FilterCallback filter,
MinidumpCallback callback,
void* callback_context,
int handler_types,
MINIDUMP_TYPE dump_type,
const wchar_t* pipe_name,
const CustomClientInfo* custom_info);
The parameters are as follows:
- Pathname to write minidumps file - this parameter will be ignored if OOP dump generation is used
- A callback that will be called when the exception is first handled - here you can return true/false to continue/stop exception handling
- callback called after minidumps are written
- callback context
- Which exceptions are handled - enumerations
exception_handler.h
in ReferenceHandlerType
- The type of minidump to generate, using the definition
DbgHelp.h
inMINIDUMP_TYPE
- Pipe name that can be used to communicate with the crash generation server
- Pointer to
CustomClientInfo
a class that can be used to send custom data with minidump when generated using OOP
You can also refer to src/client/windows/tests/crash_generation_app/*
the sample app below, which is generated using OOP.
OOP minidump generation
For out-of-process minidump generation, more work is required. If you drill down src/client/windows/crash_generation
, you'll be able to see a crash_generation_server.h
file called . This file is the interface of the crash generation server. The pipe name passed when instantiating it must be the same as the one passed to the client above. However, it is up to you to prepare a separate process to instantiate the crash generation server.
Build process details (symbol generation, uploading)
The symbol creation steps are discussed in the general overview document as it does not vary by platform. You need to ensure that these symbols are available wherever minidumps are uploaded to be processed. Here’s a brief look at the process. Take the breakpad integrated in WebRTC/ OpenRTCClient as an example. Symbols are generated through dump_syms
the tool. The compilation and generation method of this tool is as follows:
PS D:\Projects\OpenRTCClient> webrtc_build build:dump_syms win x64 debug
D:/Projects/OpenRTCClient/build_system/gn/bin/win/ninja.exe -C D:\Projects\OpenRTCClient\build\win\x64\debug dump_syms
ninja: Entering directory `D:\Projects\OpenRTCClient\build\win\x64\debug'
ninja: no work to do.
build success
Compile the executable file smoke_test
:
PS D:\Projects\OpenRTCClient> webrtc_build build:smoke_test win x64 debug
D:/Projects/OpenRTCClient/build_system/gn/bin/win/ninja.exe -C D:\Projects\OpenRTCClient\build\win\x64\debug smoke_test
ninja: Entering directory `D:\Projects\OpenRTCClient\build\win\x64\debug'
ninja: no work to do.
build success
smoke_test
Generate symbols for the resulting executable :
PS D:\Projects\OpenRTCClient> .\build\win\x64\debug\dump_syms.exe .\build\win\x64\debug\smoke_test.exe > .\build\win\x64\debug\smoke_test.sym
Other content - Upload minidump
src/client/windows/sender
There is a class implementation inside called CrashReportSender
. This class can be compiled into a dedicated standalone CLI, or compiled into a crash generation server, and used to upload reports; it knows when to do this via one of the callbacks provided by the CrashGenerationServer
or ExceptionHandler
object for in-process generation.
Convert crash stack to symbols
WebRTC/ OpenRTCClientminidump_stackwalk
does not create compiled call stacks for the integrated breakpad . However, the minidump file generated during the crash can be parsed directly by Visual Studio.
Take the test case in OpenRTCClient as an example:smoke_test
PS D:\Projects\OpenRTCClient> .\build\win\x64\debug\smoke_test.exe --gtest_filter=CrashCatchTest.* --gtest_also_run_disabled_tests
Note: Google Test filter = CrashCatchTest.*
[==========] Running 2 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 2 tests from CrashCatchTest
[ RUN ] CrashCatchTest.DISABLED_crash_catch_common
Build root /D:/Projects/OpenRTCClient/build/win/x64/debug
Dump path: D:/Projects/OpenRTCClient/build/win/x64/debug, minidump_id 043e1e02-5e21-4116-ad6d-d3a44ea9ea0f
These test cases intentionally generate a crash. At the same time, before compiling smoke_test
, comment out webrtc/third_party/googletest/src/googletest/src/gtest.cc
the code in that catches exceptions when running test cases, then when running these test cases, the minidump file will be generated as shown above.
Place the minidump file, the corresponding exe executable file and the corresponding pdb file in the same directory, open Visual Studio, and drag the minidump file into Visual Studio, as shown below:
Click 使用 仅限本机 进行调试
, and Visual Studio will parse out the crash call stack, open the source file corresponding to the crash location, and point to the crash line:
Compile minidump_stackwalk for Windows platform
Get and install gyp:
PS D:\Projects> git clone https://chromium.googlesource.com/external/gyp
PS D:\Projects> cd gyp
PS D:\Projects\gyp> python setup.py install
Get breakpad:
PS D:\Projects> git clone https://chromium.googlesource.com/breakpad/breakpad
Get googletest and put it in the breakpad/src directory, and rename the directory name to \src
:
PS D:\Projects> cd .\breakpad\
PS D:\Projects\breakpad> cd .\src\
PS D:\Projects\breakpad\src> git clone https://github.com/google/googletest.git
PS D:\Projects\breakpad\src> mv .\googletest\ testing
Otherwise, an error will be reported when executing later gyp
:
PS D:\Projects\breakpad\gyp> .\gyp.bat ../src/processor/processor.gyp
Warning: Missing input files:
..\src\common\android\ucontext_constants.h
..\src\build\..\testing\googlemock\src\gmock_main.cc
..\src\build\..\testing\googlemock\src\gmock-all.cc
..\src\build\..\testing\googletest\src\gtest_main.cc
..\src\build\..\testing\googletest\src\gtest-all.cc
Copy breakpad\src\common\linux\ucontext_constants.h
the file breakpad\src\common\android
to the directory:
PS D:\Projects\breakpad> cp .\src\common\linux\ucontext_constants.h .\src\common\android\
Otherwise, an error will be reported when executing later gyp
:
PS D:\Projects\breakpad\gyp> .\gyp.bat ../src/processor/processor.gyp
Warning: Missing input files:
..\src\common\android\ucontext_constants.h
Change everything breakpad\src/build/common.gypi
in the file to :'WarnAsError': 'true'
'WarnAsError': 'false'
PS D:\Projects\breakpad> git diff src/build/common.gypi
diff --git a/src/build/common.gypi b/src/build/common.gypi
index 29990c65..447639f2 100644
--- a/src/build/common.gypi
+++ b/src/build/common.gypi
@@ -328,7 +328,7 @@
'msvs_disabled_warnings': [4800],
'msvs_settings': {
'VCCLCompilerTool': {
- 'WarnAsError': 'true',
+ 'WarnAsError': 'false',
'Detect64BitPortabilityProblems': 'false',
},
},
@@ -904,7 +904,7 @@
'EnableFunctionLevelLinking': 'true',
'RuntimeTypeInfo': 'false',
'WarningLevel': '4',
- 'WarnAsError': 'true',
+ 'WarnAsError': 'false',
'DebugInformationFormat': '3',
'conditions': [
[ 'msvs_multi_core_compile', {
Otherwise, processor and libdisasm will not be successfully compiled later in Visual Studio.
Copy the gyp folder to the breakpad folder and generate the sln file of minidump_stackwalk. Enter the gyp directory you just copied and execute:
PS D:\Projects\breakpad\gyp> .\gyp.bat ../src/processor/processor.gyp
gyp will generate the visual studio project configuration sln file. Open the sln file through Visual Studio and compile it.
Reference documentation
Windows system, compilation of minidump_stackwalk in google breakpad