blob: 4c08a9ec17d5ceceb6ea3b48035550d2cfe93d53 [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
25Then, create a directory where the crash dumps will be stored:
26
27* Linux/Mac:
28 ```bash
29 mkdir /tmp/crashes
30 ```
31* Android:
32 ```bash
Jochen Eisingerb003ef452019-05-07 06:10:0333 adb root
34 adb shell mkdir /data/data/org.chromium.content_shell_apk/cache
pwnalld8a250722016-11-09 18:24:0335 ```
36* Windows:
37 ```bash
38 mkdir %TEMP%\crashes
pwnalld8a250722016-11-09 18:24:0339 ```
40
Joshua Peraza6f96b9d2019-02-12 16:55:1441## Running content shell with crashpad
pwnalld8a250722016-11-09 18:24:0342
Joshua Peraza6f96b9d2019-02-12 16:55:1443Crashpad can be enabled by passing `--enable-crash-reporter` and
pwnalld8a250722016-11-09 18:24:0344`--crash-dumps-dir` to content shell:
45
46* Linux:
47 ```bash
48 out/Debug/content_shell --enable-crash-reporter \
49 --crash-dumps-dir=/tmp/crashes chrome://crash
50 ```
51* Mac:
52 ```bash
53 out/Debug/Content\ Shell.app/Contents/MacOS/Content\ Shell \
54 --enable-crash-reporter --crash-dumps-dir=/tmp/crashes chrome://crash
55 ```
56* Windows:
57 ```bash
58 out\Default\content_shell.exe --enable-crash-reporter ^
59 --crash-dumps-dir=%TEMP%\crashes chrome://crash
60 ```
61* Android:
62 ```bash
Joshua Peraza6f96b9d2019-02-12 16:55:1463 out/Default/bin/content_shell_apk install
64 out/Default/bin/content_shell_apk launch chrome://crash
Jochen Eisingerb003ef452019-05-07 06:10:0365 --args="--enable-crash-reporter --crash-dumps-dir=/data/data/org.chromium.content_shell_apk/cache"
pwnalld8a250722016-11-09 18:24:0366 ```
67
68## Retrieving the crash dump
69
70On Linux and Android, we first have to retrieve the crash dump. On Mac and
71Windows, this step can be skipped.
72
73* Linux:
74 ```bash
75 components/crash/content/tools/dmp2minidump.py /tmp/crashes/*.dmp /tmp/minidump
76 ```
77* Android:
78 ```bash
Jochen Eisingerb003ef452019-05-07 06:10:0379 adb pull $(adb shell ls /data/data/org.chromium.content_shell_apk/cache/pending/*.dmp) /tmp/chromium-renderer-minidump.dmp
pwnalld8a250722016-11-09 18:24:0380 ```
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 \
Jochen Eisingerb003ef452019-05-07 06:10:03105 --symbols-dir=out/Default/content_shell.breakpad.syms --clear \
106 --platform=android
pwnalld8a250722016-11-09 18:24:03107 ```
108
109Now we can generate a stack trace from the crash dump. Assuming the crash dump
110is in minidump.dmp:
111
112* Linux/Android/Mac:
113 ```bash
114 out/Default/minidump_stackwalk minidump.dmp out/Debug/content_shell.breakpad.syms
115 ```
116* Windows:
117 ```bash
118 "c:\Program Files (x86)\Windows Kits\8.0\Debuggers\x64\cdb.exe" ^
119 -y out\Default -c ".ecxr;k30;q" -z minidump.dmp
120 ```