blob: 004fdac1f687af1c147d79ac80fdea8b231e44de [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
Andrew Williamsbbc1a1e2021-07-21 01:51:2214arguments](https://gn.googlesource.com/gn/+/main/docs/quick_start.md) before
Tom Bridgwatereef401542018-08-17 00:54:4315building. This slows down linking several minutes, so don't just always set it
16by default.
pwnalld8a250722016-11-09 18:24:0317***
18
pwnalld8a250722016-11-09 18:24:0319Then, create a directory where the crash dumps will be stored:
20
21* Linux/Mac:
22 ```bash
23 mkdir /tmp/crashes
24 ```
25* Android:
26 ```bash
Jochen Eisingerb003ef452019-05-07 06:10:0327 adb root
28 adb shell mkdir /data/data/org.chromium.content_shell_apk/cache
pwnalld8a250722016-11-09 18:24:0329 ```
30* Windows:
31 ```bash
32 mkdir %TEMP%\crashes
pwnalld8a250722016-11-09 18:24:0333 ```
34
Joshua Peraza6f96b9d2019-02-12 16:55:1435## Running content shell with crashpad
pwnalld8a250722016-11-09 18:24:0336
Joshua Peraza6f96b9d2019-02-12 16:55:1437Crashpad can be enabled by passing `--enable-crash-reporter` and
pwnalld8a250722016-11-09 18:24:0338`--crash-dumps-dir` to content shell:
39
40* Linux:
41 ```bash
42 out/Debug/content_shell --enable-crash-reporter \
43 --crash-dumps-dir=/tmp/crashes chrome://crash
44 ```
45* Mac:
46 ```bash
47 out/Debug/Content\ Shell.app/Contents/MacOS/Content\ Shell \
48 --enable-crash-reporter --crash-dumps-dir=/tmp/crashes chrome://crash
49 ```
50* Windows:
51 ```bash
52 out\Default\content_shell.exe --enable-crash-reporter ^
53 --crash-dumps-dir=%TEMP%\crashes chrome://crash
54 ```
55* Android:
56 ```bash
Joshua Peraza6f96b9d2019-02-12 16:55:1457 out/Default/bin/content_shell_apk install
58 out/Default/bin/content_shell_apk launch chrome://crash
Jochen Eisingerb003ef452019-05-07 06:10:0359 --args="--enable-crash-reporter --crash-dumps-dir=/data/data/org.chromium.content_shell_apk/cache"
pwnalld8a250722016-11-09 18:24:0360 ```
61
62## Retrieving the crash dump
63
Joshua Peraza00e6c562020-01-09 18:19:3764On Android, we first have to retrieve the crash dump. On other platforms, this
65step can be skipped.
pwnalld8a250722016-11-09 18:24:0366
pwnalld8a250722016-11-09 18:24:0367* Android:
68 ```bash
Jochen Eisingerb003ef452019-05-07 06:10:0369 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:0370 ```
71
72## Symbolizing the crash dump
73
74On all platforms except for Windows, we need to convert the debug symbols to a
75format that breakpad can understand.
76
77* Linux:
78 ```bash
79 components/crash/content/tools/generate_breakpad_symbols.py \
80 --build-dir=out/Default --binary=out/Default/content_shell \
81 --symbols-dir=out/Default/content_shell.breakpad.syms --clear --jobs=16
82 ```
83* Mac:
84 ```bash
85 components/crash/content/tools/generate_breakpad_symbols.py \
86 --build-dir=out/Default \
87 --binary=out/Default/Content\ Shell.app/Contents/MacOS/Content\ Shell \
88 --symbols-dir=out/Default/content_shell.breakpad.syms --clear --jobs=16
89 ```
90* Android:
91 ```bash
92 components/crash/content/tools/generate_breakpad_symbols.py \
93 --build-dir=out/Default \
94 --binary=out/Default/lib/libcontent_shell_content_view.so \
Jochen Eisingerb003ef452019-05-07 06:10:0395 --symbols-dir=out/Default/content_shell.breakpad.syms --clear \
96 --platform=android
pwnalld8a250722016-11-09 18:24:0397 ```
98
99Now we can generate a stack trace from the crash dump. Assuming the crash dump
100is in minidump.dmp:
101
102* Linux/Android/Mac:
103 ```bash
104 out/Default/minidump_stackwalk minidump.dmp out/Debug/content_shell.breakpad.syms
105 ```
106* Windows:
107 ```bash
108 "c:\Program Files (x86)\Windows Kits\8.0\Debuggers\x64\cdb.exe" ^
109 -y out\Default -c ".ecxr;k30;q" -z minidump.dmp
110 ```