xref: /aosp_15_r20/external/google-breakpad/docs/getting_started_with_breakpad.md (revision 9712c20fc9bbfbac4935993a2ca0b3958c5adad2)
1*9712c20fSFrederick Mayle# Introduction
2*9712c20fSFrederick Mayle
3*9712c20fSFrederick MayleBreakpad is a library and tool suite that allows you to distribute an
4*9712c20fSFrederick Mayleapplication to users with compiler-provided debugging information removed,
5*9712c20fSFrederick Maylerecord crashes in compact "minidump" files, send them back to your server, and
6*9712c20fSFrederick Mayleproduce C and C++ stack traces from these minidumps. Breakpad can also write
7*9712c20fSFrederick Mayleminidumps on request for programs that have not crashed.
8*9712c20fSFrederick Mayle
9*9712c20fSFrederick MayleBreakpad is currently used by Google Chrome, Firefox, Google Picasa, Camino,
10*9712c20fSFrederick MayleGoogle Earth, and other projects.
11*9712c20fSFrederick Mayle
12*9712c20fSFrederick Mayle![Workflow](breakpad.png)
13*9712c20fSFrederick Mayle
14*9712c20fSFrederick MayleBreakpad has three main components:
15*9712c20fSFrederick Mayle
16*9712c20fSFrederick Mayle*   The **client** is a library that you include in your application. It can
17*9712c20fSFrederick Mayle    write minidump files capturing the current threads' state and the identities
18*9712c20fSFrederick Mayle    of the currently loaded executable and shared libraries. You can configure
19*9712c20fSFrederick Mayle    the client to write a minidump when a crash occurs, or when explicitly
20*9712c20fSFrederick Mayle    requested.
21*9712c20fSFrederick Mayle
22*9712c20fSFrederick Mayle*   The **symbol dumper** is a program that reads the debugging information
23*9712c20fSFrederick Mayle    produced by the compiler and produces a **symbol file**, in [Breakpad's own
24*9712c20fSFrederick Mayle    format](symbol_files.md).
25*9712c20fSFrederick Mayle
26*9712c20fSFrederick Mayle*   The **processor** is a program that reads a minidump file, finds the
27*9712c20fSFrederick Mayle    appropriate symbol files for the versions of the executables and shared
28*9712c20fSFrederick Mayle    libraries the minidump mentions, and produces a human-readable C/C++ stack
29*9712c20fSFrederick Mayle    trace.
30*9712c20fSFrederick Mayle
31*9712c20fSFrederick Mayle# The minidump file format
32*9712c20fSFrederick Mayle
33*9712c20fSFrederick MayleThe minidump file format is similar to core files but was developed by Microsoft
34*9712c20fSFrederick Maylefor its crash-uploading facility. A minidump file contains:
35*9712c20fSFrederick Mayle
36*9712c20fSFrederick Mayle*   A list of the executable and shared libraries that were loaded in the
37*9712c20fSFrederick Mayle    process at the time the dump was created. This list includes both file names
38*9712c20fSFrederick Mayle    and identifiers for the particular versions of those files that were loaded.
39*9712c20fSFrederick Mayle
40*9712c20fSFrederick Mayle*   A list of threads present in the process. For each thread, the minidump
41*9712c20fSFrederick Mayle    includes the state of the processor registers, and the contents of the
42*9712c20fSFrederick Mayle    threads' stack memory. These data are uninterpreted byte streams, as the
43*9712c20fSFrederick Mayle    Breakpad client generally has no debugging information available to produce
44*9712c20fSFrederick Mayle    function names or line numbers, or even identify stack frame boundaries.
45*9712c20fSFrederick Mayle
46*9712c20fSFrederick Mayle*   Other information about the system on which the dump was collected:
47*9712c20fSFrederick Mayle    processor and operating system versions, the reason for the dump, and so on.
48*9712c20fSFrederick Mayle
49*9712c20fSFrederick MayleBreakpad uses Windows minidump files on all platforms, instead of the
50*9712c20fSFrederick Mayletraditional core files, for several reasons:
51*9712c20fSFrederick Mayle
52*9712c20fSFrederick Mayle*   Core files can be very large, making them impractical to send across a
53*9712c20fSFrederick Mayle    network to the collector for processing. Minidumps are smaller, as they were
54*9712c20fSFrederick Mayle    designed to be used this way.
55*9712c20fSFrederick Mayle
56*9712c20fSFrederick Mayle*   The core file format is poorly documented. For example, the Linux Standards
57*9712c20fSFrederick Mayle    Base does not describe how registers are stored in `PT_NOTE` segments.
58*9712c20fSFrederick Mayle
59*9712c20fSFrederick Mayle*   It is harder to persuade a Windows machine to produce a core dump file than
60*9712c20fSFrederick Mayle    it is to persuade other machines to write a minidump file.
61*9712c20fSFrederick Mayle
62*9712c20fSFrederick Mayle*   It simplifies the Breakpad processor to support only one file format.
63*9712c20fSFrederick Mayle
64*9712c20fSFrederick Mayle# Overview/Life of a minidump
65*9712c20fSFrederick Mayle
66*9712c20fSFrederick MayleA minidump is generated via calls into the Breakpad library. By default,
67*9712c20fSFrederick Mayleinitializing Breakpad installs an exception/signal handler that writes a
68*9712c20fSFrederick Mayleminidump to disk at exception time. On Windows, this is done via
69*9712c20fSFrederick Mayle`SetUnhandledExceptionFilter()`; on OS X, this is done by creating a thread that
70*9712c20fSFrederick Maylewaits on the Mach exception port; and on Linux, this is done by installing a
71*9712c20fSFrederick Maylesignal handler for various exceptions like `SIGILL, SIGSEGV` etc.
72*9712c20fSFrederick Mayle
73*9712c20fSFrederick MayleOnce the minidump is generated, each platform has a slightly different way of
74*9712c20fSFrederick Mayleuploading the crash dump. On Windows & Linux, a separate library of functions is
75*9712c20fSFrederick Mayleprovided that can be called into to do the upload. On OS X, a separate process
76*9712c20fSFrederick Mayleis spawned that prompts the user for permission, if configured to do so, and
77*9712c20fSFrederick Maylesends the file.
78*9712c20fSFrederick Mayle
79*9712c20fSFrederick Mayle# Terminology
80*9712c20fSFrederick Mayle
81*9712c20fSFrederick Mayle**In-process vs. out-of-process exception handling** - it's generally considered
82*9712c20fSFrederick Maylethat writing the minidump from within the crashed process is unsafe - key
83*9712c20fSFrederick Mayleprocess data structures could be corrupted, or the stack on which the exception
84*9712c20fSFrederick Maylehandler runs could have been overwritten, etc. All 3 platforms support what's
85*9712c20fSFrederick Mayleknown as "out-of-process" exception handling.
86*9712c20fSFrederick Mayle
87*9712c20fSFrederick Mayle# Integration overview
88*9712c20fSFrederick Mayle
89*9712c20fSFrederick Mayle## Breakpad Code Overview
90*9712c20fSFrederick Mayle
91*9712c20fSFrederick MayleAll the client-side code is found by visiting the Google Project at
92*9712c20fSFrederick Maylehttps://chromium.googlesource.com/breakpad/breakpad. The following directory structure is
93*9712c20fSFrederick Maylepresent in the `src` directory:
94*9712c20fSFrederick Mayle
95*9712c20fSFrederick Mayle*   `processor` Contains minidump-processing code that is used on the server
96*9712c20fSFrederick Mayle    side and isn't of use on the client side
97*9712c20fSFrederick Mayle*   `client` Contains client minidump-generation libraries for all platforms
98*9712c20fSFrederick Mayle*   `tools` Contains source code & projects for building various tools on each
99*9712c20fSFrederick Mayle    platform.
100*9712c20fSFrederick Mayle
101*9712c20fSFrederick Mayle(Among other directories)
102*9712c20fSFrederick Mayle
103*9712c20fSFrederick Mayle*   [Windows Integration Guide](windows_client_integration.md)
104*9712c20fSFrederick Mayle*   [Mac Integration Guide](mac_breakpad_starter_guide.md)
105*9712c20fSFrederick Mayle*   [Linux Integration Guide](linux_starter_guide.md)
106*9712c20fSFrederick Mayle
107*9712c20fSFrederick Mayle## Build process specifics(symbol generation)
108*9712c20fSFrederick Mayle
109*9712c20fSFrederick MayleThis applies to all platforms. Inside `src/tools/{platform}/dump_syms` is a tool
110*9712c20fSFrederick Maylethat can read debugging information for each platform (e.g. for OS X/Linux,
111*9712c20fSFrederick MayleDWARF and STABS, and for Windows, PDB files) and generate a Breakpad symbol
112*9712c20fSFrederick Maylefile. This tool should be run on your binary before it's stripped(in the case of
113*9712c20fSFrederick MayleOS X/Linux) and the symbol files need to be stored somewhere that the minidump
114*9712c20fSFrederick Mayleprocessor can find. There is another tool, `symupload`, that can be used to
115*9712c20fSFrederick Mayleupload symbol files if you have written a server that can accept them.
116