blob: 7579deb9858e78038a6d09688730eba064afd8ea [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
qyearsley23599b72017-02-16 19:10:424[breakpad](../../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
12**Mac:** Add `enable_dsyms = 1` to your
13[gn build arguments](../../tools/gn/docs/quick_start.md) before building. This
14slows down linking several minutes, so don't just always set it by default.
15***
16
17*** note
18**Linux:** Add `use_debug_fission = true` to your
19[gn build arguments](../../tools/gn/docs/quick_start.md) before building.
20***
21
22Then, create a directory where the crash dumps will be stored:
23
24* Linux/Mac:
25 ```bash
26 mkdir /tmp/crashes
27 ```
28* Android:
29 ```bash
30 adb shell mkdir /data/local/tmp/crashes
31 ```
32* Windows:
33 ```bash
34 mkdir %TEMP%\crashes
35 out\Default\content_shell_crash_service.exe --dumps-dir=%TEMP%\crashes
36 ```
37
38## Running content shell with breakpad
39
40Breakpad can be enabled by passing `--enable-crash-reporter` and
41`--crash-dumps-dir` to content shell:
42
43* Linux:
44 ```bash
45 out/Debug/content_shell --enable-crash-reporter \
46 --crash-dumps-dir=/tmp/crashes chrome://crash
47 ```
48* Mac:
49 ```bash
50 out/Debug/Content\ Shell.app/Contents/MacOS/Content\ Shell \
51 --enable-crash-reporter --crash-dumps-dir=/tmp/crashes chrome://crash
52 ```
53* Windows:
54 ```bash
55 out\Default\content_shell.exe --enable-crash-reporter ^
56 --crash-dumps-dir=%TEMP%\crashes chrome://crash
57 ```
58* Android:
59 ```bash
60 build/android/adb_install_apk.py out/Default/apks/ContentShell.apk
61 build/android/adb_content_shell_command_line --enable-crash-reporter \
62 --crash-dumps-dir=/data/local/tmp/crashes chrome://crash
63 build/android/adb_run_content_shell
64 ```
65
66## Retrieving the crash dump
67
68On Linux and Android, we first have to retrieve the crash dump. On Mac and
69Windows, this step can be skipped.
70
71* Linux:
72 ```bash
73 components/crash/content/tools/dmp2minidump.py /tmp/crashes/*.dmp /tmp/minidump
74 ```
75* Android:
76 ```bash
77 adb pull $(adb shell ls /data/local/tmp/crashes/*) /tmp/chromium-renderer-minidump.dmp
78 components/breakpad/tools/dmp2minidump /tmp/chromium-renderer-minidump.dmp /tmp/minidump
79 ```
80
81## Symbolizing the crash dump
82
83On all platforms except for Windows, we need to convert the debug symbols to a
84format that breakpad can understand.
85
86* Linux:
87 ```bash
88 components/crash/content/tools/generate_breakpad_symbols.py \
89 --build-dir=out/Default --binary=out/Default/content_shell \
90 --symbols-dir=out/Default/content_shell.breakpad.syms --clear --jobs=16
91 ```
92* Mac:
93 ```bash
94 components/crash/content/tools/generate_breakpad_symbols.py \
95 --build-dir=out/Default \
96 --binary=out/Default/Content\ Shell.app/Contents/MacOS/Content\ Shell \
97 --symbols-dir=out/Default/content_shell.breakpad.syms --clear --jobs=16
98 ```
99* Android:
100 ```bash
101 components/crash/content/tools/generate_breakpad_symbols.py \
102 --build-dir=out/Default \
103 --binary=out/Default/lib/libcontent_shell_content_view.so \
104 --symbols-dir=out/Default/content_shell.breakpad.syms --clear
105 ```
106
107Now we can generate a stack trace from the crash dump. Assuming the crash dump
108is in minidump.dmp:
109
110* Linux/Android/Mac:
111 ```bash
112 out/Default/minidump_stackwalk minidump.dmp out/Debug/content_shell.breakpad.syms
113 ```
114* Windows:
115 ```bash
116 "c:\Program Files (x86)\Windows Kits\8.0\Debuggers\x64\cdb.exe" ^
117 -y out\Default -c ".ecxr;k30;q" -z minidump.dmp
118 ```