blob: 9fee466b62d307d4e45dff2e05ff5f65a449dec4 [file] [log] [blame] [view]
pwnalld8a250722016-11-09 18:24:031# Using breakpad with content shell
2
3When running layout tests, it is possible to use
Euisang Lime2f2e782018-05-09 05:04:064[breakpad](../../third_party/breakpad/) to capture stack traces on crashes while
pwnalld8a250722016-11-09 18:24:035running without a debugger attached and with the sandbox enabled.
6
7## Setup
8
9On all platforms, build the target `blink_tests`.
10
11*** note
Tom Bridgwatereef401542018-08-17 00:54:4312**Mac:** Add `enable_dsyms = 1` to your [gn build
13arguments](https://gn.googlesource.com/gn/+/master/docs/quick_start.md) before
14building. This slows down linking several minutes, so don't just always set it
15by default.
pwnalld8a250722016-11-09 18:24:0316***
17
18*** note
Tom Bridgwatereef401542018-08-17 00:54:4319**Linux:** Add `use_debug_fission = true` to your [gn build
20arguments](https://gn.googlesource.com/gn/+/master/docs/quick_start.md) before
21building.
pwnalld8a250722016-11-09 18:24:0322***
23
24Then, create a directory where the crash dumps will be stored:
25
26* Linux/Mac:
27 ```bash
28 mkdir /tmp/crashes
29 ```
30* Android:
31 ```bash
32 adb shell mkdir /data/local/tmp/crashes
33 ```
34* Windows:
35 ```bash
36 mkdir %TEMP%\crashes
pwnalld8a250722016-11-09 18:24:0337 ```
38
39## Running content shell with breakpad
40
41Breakpad can be enabled by passing `--enable-crash-reporter` and
42`--crash-dumps-dir` to content shell:
43
44* Linux:
45 ```bash
46 out/Debug/content_shell --enable-crash-reporter \
47 --crash-dumps-dir=/tmp/crashes chrome://crash
48 ```
49* Mac:
50 ```bash
51 out/Debug/Content\ Shell.app/Contents/MacOS/Content\ Shell \
52 --enable-crash-reporter --crash-dumps-dir=/tmp/crashes chrome://crash
53 ```
54* Windows:
55 ```bash
56 out\Default\content_shell.exe --enable-crash-reporter ^
57 --crash-dumps-dir=%TEMP%\crashes chrome://crash
58 ```
59* Android:
60 ```bash
61 build/android/adb_install_apk.py out/Default/apks/ContentShell.apk
62 build/android/adb_content_shell_command_line --enable-crash-reporter \
63 --crash-dumps-dir=/data/local/tmp/crashes chrome://crash
64 build/android/adb_run_content_shell
65 ```
66
67## Retrieving the crash dump
68
69On Linux and Android, we first have to retrieve the crash dump. On Mac and
70Windows, this step can be skipped.
71
72* Linux:
73 ```bash
74 components/crash/content/tools/dmp2minidump.py /tmp/crashes/*.dmp /tmp/minidump
75 ```
76* Android:
77 ```bash
78 adb pull $(adb shell ls /data/local/tmp/crashes/*) /tmp/chromium-renderer-minidump.dmp
79 components/breakpad/tools/dmp2minidump /tmp/chromium-renderer-minidump.dmp /tmp/minidump
80 ```
81
82## Symbolizing the crash dump
83
84On all platforms except for Windows, we need to convert the debug symbols to a
85format that breakpad can understand.
86
87* Linux:
88 ```bash
89 components/crash/content/tools/generate_breakpad_symbols.py \
90 --build-dir=out/Default --binary=out/Default/content_shell \
91 --symbols-dir=out/Default/content_shell.breakpad.syms --clear --jobs=16
92 ```
93* Mac:
94 ```bash
95 components/crash/content/tools/generate_breakpad_symbols.py \
96 --build-dir=out/Default \
97 --binary=out/Default/Content\ Shell.app/Contents/MacOS/Content\ Shell \
98 --symbols-dir=out/Default/content_shell.breakpad.syms --clear --jobs=16
99 ```
100* Android:
101 ```bash
102 components/crash/content/tools/generate_breakpad_symbols.py \
103 --build-dir=out/Default \
104 --binary=out/Default/lib/libcontent_shell_content_view.so \
105 --symbols-dir=out/Default/content_shell.breakpad.syms --clear
106 ```
107
108Now we can generate a stack trace from the crash dump. Assuming the crash dump
109is in minidump.dmp:
110
111* Linux/Android/Mac:
112 ```bash
113 out/Default/minidump_stackwalk minidump.dmp out/Debug/content_shell.breakpad.syms
114 ```
115* Windows:
116 ```bash
117 "c:\Program Files (x86)\Windows Kits\8.0\Debuggers\x64\cdb.exe" ^
118 -y out\Default -c ".ecxr;k30;q" -z minidump.dmp
119 ```