blob: a582dc76507525f13bdd6921e5cb245b010ff9d0 [file] [log] [blame] [view]
Joshua Peraza6f96b9d2019-02-12 16:55:141# Using crashpad with content shell
pwnalld8a250722016-11-09 18:24:032
Kent Tamura59ffb022018-11-27 05:30:563When running web tests, it is possible to use
Joshua Peraza6f96b9d2019-02-12 16:55:144[crashpad](../third_party/crashpad/)/[breakpad](../../third_party/breakpad/) to
5capture stack traces on crashes while running without a debugger attached and
6with the sandbox enabled.
pwnalld8a250722016-11-09 18:24:037
8## Setup
9
10On all platforms, build the target `blink_tests`.
11
12*** note
Tom Bridgwatereef401542018-08-17 00:54:4313**Mac:** Add `enable_dsyms = 1` to your [gn build
14arguments](https://gn.googlesource.com/gn/+/master/docs/quick_start.md) before
15building. This slows down linking several minutes, so don't just always set it
16by default.
pwnalld8a250722016-11-09 18:24:0317***
18
19*** note
Tom Bridgwatereef401542018-08-17 00:54:4320**Linux:** Add `use_debug_fission = true` to your [gn build
21arguments](https://gn.googlesource.com/gn/+/master/docs/quick_start.md) before
22building.
pwnalld8a250722016-11-09 18:24:0323***
24
Joshua Peraza6f96b9d2019-02-12 16:55:1425*** note
26**Android:** Add `force_local_build_id = true` to your [gn build
27arguments](https://gn.googlesource.com/gn/+/master/docs/quick_start.md) before
28building.
29***
30
pwnalld8a250722016-11-09 18:24:0331Then, create a directory where the crash dumps will be stored:
32
33* Linux/Mac:
34 ```bash
35 mkdir /tmp/crashes
36 ```
37* Android:
38 ```bash
39 adb shell mkdir /data/local/tmp/crashes
40 ```
41* Windows:
42 ```bash
43 mkdir %TEMP%\crashes
pwnalld8a250722016-11-09 18:24:0344 ```
45
Joshua Peraza6f96b9d2019-02-12 16:55:1446## Running content shell with crashpad
pwnalld8a250722016-11-09 18:24:0347
Joshua Peraza6f96b9d2019-02-12 16:55:1448Crashpad can be enabled by passing `--enable-crash-reporter` and
pwnalld8a250722016-11-09 18:24:0349`--crash-dumps-dir` to content shell:
50
51* Linux:
52 ```bash
53 out/Debug/content_shell --enable-crash-reporter \
54 --crash-dumps-dir=/tmp/crashes chrome://crash
55 ```
56* Mac:
57 ```bash
58 out/Debug/Content\ Shell.app/Contents/MacOS/Content\ Shell \
59 --enable-crash-reporter --crash-dumps-dir=/tmp/crashes chrome://crash
60 ```
61* Windows:
62 ```bash
63 out\Default\content_shell.exe --enable-crash-reporter ^
64 --crash-dumps-dir=%TEMP%\crashes chrome://crash
65 ```
66* Android:
67 ```bash
Joshua Peraza6f96b9d2019-02-12 16:55:1468 out/Default/bin/content_shell_apk install
69 out/Default/bin/content_shell_apk launch chrome://crash
70 --args="--enable-crash-reporter --crash-dumps-dir=/data/local/tmp/crashes"
pwnalld8a250722016-11-09 18:24:0371 ```
72
73## Retrieving the crash dump
74
75On Linux and Android, we first have to retrieve the crash dump. On Mac and
76Windows, this step can be skipped.
77
78* Linux:
79 ```bash
80 components/crash/content/tools/dmp2minidump.py /tmp/crashes/*.dmp /tmp/minidump
81 ```
82* Android:
83 ```bash
Joshua Peraza6f96b9d2019-02-12 16:55:1484 adb pull $(adb shell ls /data/local/tmp/crashes/pending/*.dmp) /tmp/chromium-renderer-minidump.dmp
pwnalld8a250722016-11-09 18:24:0385 ```
86
87## Symbolizing the crash dump
88
89On all platforms except for Windows, we need to convert the debug symbols to a
90format that breakpad can understand.
91
92* Linux:
93 ```bash
94 components/crash/content/tools/generate_breakpad_symbols.py \
95 --build-dir=out/Default --binary=out/Default/content_shell \
96 --symbols-dir=out/Default/content_shell.breakpad.syms --clear --jobs=16
97 ```
98* Mac:
99 ```bash
100 components/crash/content/tools/generate_breakpad_symbols.py \
101 --build-dir=out/Default \
102 --binary=out/Default/Content\ Shell.app/Contents/MacOS/Content\ Shell \
103 --symbols-dir=out/Default/content_shell.breakpad.syms --clear --jobs=16
104 ```
105* Android:
106 ```bash
107 components/crash/content/tools/generate_breakpad_symbols.py \
108 --build-dir=out/Default \
109 --binary=out/Default/lib/libcontent_shell_content_view.so \
110 --symbols-dir=out/Default/content_shell.breakpad.syms --clear
111 ```
112
113Now we can generate a stack trace from the crash dump. Assuming the crash dump
114is in minidump.dmp:
115
116* Linux/Android/Mac:
117 ```bash
118 out/Default/minidump_stackwalk minidump.dmp out/Debug/content_shell.breakpad.syms
119 ```
120* Windows:
121 ```bash
122 "c:\Program Files (x86)\Windows Kits\8.0\Debuggers\x64\cdb.exe" ^
123 -y out\Default -c ".ecxr;k30;q" -z minidump.dmp
124 ```