OLD | NEW |
1 # Introduction | 1 # Linux Minidump to Core |
2 | 2 |
3 On Linux, Chromium can use Breakpad to generate minidump files for crashes. It i
s possible to convert the minidump files to core files, and examine the core fil
e in gdb, cgdb, or Qtcreator. In the examples below cgdb is assumed but any gdb
based debugger can be used. | 3 On Linux, Chromium can use Breakpad to generate minidump files for crashes. It |
| 4 is possible to convert the minidump files to core files, and examine the core |
| 5 file in gdb, cgdb, or Qtcreator. In the examples below cgdb is assumed but any |
| 6 gdb based debugger can be used. |
4 | 7 |
5 # Details | 8 [TOC] |
6 | 9 |
7 ## Creating the core file | 10 ## Creating the core file |
8 | 11 |
9 Use `minidump-2-core` to convert the minidump file to a core file. On Linux, one
can build the minidump-2-core target in a Chromium checkout, or alternatively,
build it in a Google Breakpad checkout. | 12 Use `minidump-2-core` to convert the minidump file to a core file. On Linux, one |
| 13 can build the minidump-2-core target in a Chromium checkout, or alternatively, |
| 14 build it in a Google Breakpad checkout. |
10 | 15 |
11 ``` | 16 $ minidump-2-core foo.dmp > foo.core |
12 | |
13 $ minidump-2-core foo.dmp > foo.core | |
14 | |
15 ``` | |
16 | 17 |
17 ## Retrieving Chrome binaries | 18 ## Retrieving Chrome binaries |
18 | 19 |
19 If the minidump is from | 20 If the minidump is from a public build then Googlers can find Google Chrome |
20 a public build then Googlers can find Google Chrome Linux binaries and debugging
symbols via https://goto.google.com/chromesymbols. Otherwise, use the locally b
uilt chrome files. | 21 Linux binaries and debugging symbols via https://goto.google.com/chromesymbols. |
21 Google Chrome uses the _debug link_ method to specify the debugging file. | 22 Otherwise, use the locally built chrome files. Google Chrome uses the |
22 Either way be sure to put chrome and chrome.debug | 23 _debug link_ method to specify the debugging file. Either way be sure to put |
23 (the stripped debug information) in the same directory as the core file so that
the debuggers can find them. | 24 `chrome` and `chrome.debug` (the stripped debug information) in the same |
| 25 directory as the core file so that the debuggers can find them. |
24 | 26 |
25 ## Loading the core file into gdb/cgdb | 27 ## Loading the core file into gdb/cgdb |
26 | 28 |
27 The recommended syntax for loading a core file into gdb/cgdb is as follows, spec
ifying both the executable and the core file: | 29 The recommended syntax for loading a core file into gdb/cgdb is as follows, |
| 30 specifying both the executable and the core file: |
28 | 31 |
29 ``` | 32 $ cgdb chrome foo.core |
30 | 33 |
31 $ cgdb chrome foo.core | 34 If the executable is not available then the core file can be loaded on its own |
| 35 but debugging options will be limited: |
32 | 36 |
33 ``` | 37 $ cgdb -c foo.core |
34 | |
35 If the executable is not available then the core file can be loaded on its own b
ut debugging options will be limited: | |
36 | |
37 ``` | |
38 | |
39 $ cgdb -c foo.core | |
40 | |
41 ``` | |
42 | 38 |
43 ## Loading the core file into Qtcreator | 39 ## Loading the core file into Qtcreator |
44 | 40 |
45 Qtcreator is a full GUI wrapper for gdb and it can also load Chrome's core files
. From Qtcreator select the Debug menu, Start Debugging, Load Core File... and t
hen enter the paths to the core file and executable. Qtcreator has windows to di
splay the call stack, locals, registers, etc. For more information on debugging
with Qtcreator see [Getting Started Debugging on Linux.](https://www.youtube.com
/watch?v=xTmAknUbpB0) | 41 Qtcreator is a full GUI wrapper for gdb and it can also load Chrome's core |
| 42 files. From Qtcreator select the Debug menu, Start Debugging, Load Core File... |
| 43 and then enter the paths to the core file and executable. Qtcreator has windows |
| 44 to display the call stack, locals, registers, etc. For more information on |
| 45 debugging with Qtcreator see |
| 46 [Getting Started Debugging on Linux.](https://www.youtube.com/watch?v=xTmAknUbpB
0) |
46 | 47 |
47 ## Source debugging | 48 ## Source debugging |
48 | 49 |
49 If you have a Chromium repo that is synchronized to exactly (or even approximate
ly) when the Chrome build was created then you can tell gdb/cgdb/Qtcreator to lo
ad source code. Since all source paths in Chrome are relative to the out/Release
directory you just need to add that directory to your debugger search path, by
adding a line similar to this to ~/.gdbinit: | 50 If you have a Chromium repo that is synchronized to exactly (or even |
| 51 approximately) when the Chrome build was created then you can tell |
| 52 `gdb/cgdb/Qtcreator` to load source code. Since all source paths in Chrome are |
| 53 relative to the out/Release directory you just need to add that directory to |
| 54 your debugger search path, by adding a line similar to this to `~/.gdbinit`: |
50 | 55 |
51 ``` | 56 (gdb) directory /usr/local/chromium/src/out/Release/ |
52 | |
53 (gdb) directory /usr/local/chromium/src/out/Release/ | |
54 | |
55 ``` | |
56 | 57 |
57 ## Notes | 58 ## Notes |
58 | 59 |
59 * Since the core file is created from a minidump, it is incomplete and the deb
ugger may not know values for variables in memory. Minidump files contain thread
stacks so local variables and function parameters should be available, subject
to the limitations of optimized builds. | 60 * Since the core file is created from a minidump, it is incomplete and the |
60 * For gdb's `add-symbol-file` command to work, the file must have debugging sy
mbols. | 61 debugger may not know values for variables in memory. Minidump files contain |
61 * In case of separate debug files, [the gdb manual](https://sourceware.org/g
db/onlinedocs/gdb/Separate-Debug-Files.html) explains how gdb looks for them. | 62 thread stacks so local variables and function parameters should be |
62 * If the stack trace involve system libraries, the Advanced module loading ste
ps shown below need to be repeated for each library. | 63 available, subject to the limitations of optimized builds. |
| 64 * For gdb's `add-symbol-file` command to work, the file must have debugging |
| 65 symbols. |
| 66 * In case of separate debug files, |
| 67 [the gdb manual](https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Fi
les.html) |
| 68 explains how gdb looks for them. |
| 69 * If the stack trace involve system libraries, the Advanced module loading |
| 70 steps shown below need to be repeated for each library. |
63 | 71 |
64 ## Advanced module loading | 72 ## Advanced module loading |
65 | 73 |
66 If gdb doesn't find shared objects that are needed you can force it to load them
. In gdb, the `add-symbol-file` command takes a filename and an address. To figu
re out the address, look near the end of `foo.dmp`, which contains a copy of `/p
roc/pid/maps` from the process that crashed. | 74 If gdb doesn't find shared objects that are needed you can force it to load |
| 75 them. In gdb, the `add-symbol-file` command takes a filename and an address. To |
| 76 figure out the address, look near the end of `foo.dmp`, which contains a copy of |
| 77 `/proc/pid/maps` from the process that crashed. |
67 | 78 |
68 One quick way to do this is with `grep`. For instance, if the executable is `/pa
th/to/chrome`, one can simply run: | 79 One quick way to do this is with `grep`. For instance, if the executable is |
| 80 `/path/to/chrome`, one can simply run: |
69 | 81 |
70 ``` | 82 $ grep -a /path/to/chrome$ foo.dmp |
71 | 83 |
72 $ grep -a /path/to/chrome$ foo.dmp | 84 7fe749a90000-7fe74d28f000 r-xp 00000000 08:07 289158 /path/to/chrome |
| 85 7fe74d290000-7fe74d4b7000 r--p 037ff000 08:07 289158 /path/to/chrome |
| 86 7fe74d4b7000-7fe74d4e0000 rw-p 03a26000 08:07 289158 /path/to/chrome |
73 | 87 |
74 7fe749a90000-7fe74d28f000 r-xp 00000000 08:07 289158 /path/t
o/chrome | 88 In this case, `7fe749a90000` is the base address for `/path/to/chrome`, but gdb |
75 7fe74d290000-7fe74d4b7000 r--p 037ff000 08:07 289158 /path/t
o/chrome | 89 takes the start address of the file's text section. To calculate this, one will |
76 7fe74d4b7000-7fe74d4e0000 rw-p 03a26000 08:07 289158 /path/t
o/chrome | 90 need a copy of `/path/to/chrome`, and run: |
77 | 91 |
| 92 $ objdump -x /path/to/chrome | grep '\.text' | head -n 1 | tr -s ' ' | \ |
| 93 cut -d' ' -f 7 |
78 | 94 |
79 ``` | 95 005282c0 |
80 | |
81 In this case, `7fe749a90000` is the base address for `/path/to/chrome`, but gdb
takes the start address of the file's text section. To calculate this, one will
need a copy of `/path/to/chrome`, and run: | |
82 | |
83 ``` | |
84 | |
85 $ objdump -x /path/to/chrome | grep '\.text' | head -n 1 | tr -s ' ' | cut -d' '
-f 7 | |
86 | |
87 005282c0 | |
88 | |
89 ``` | |
90 | 96 |
91 Now add the two addresses: `7fe749a90000 + 005282c0 = 7fe749fb82c0` and in gdb,
run: | 97 Now add the two addresses: `7fe749a90000 + 005282c0 = 7fe749fb82c0` and in gdb,
run: |
92 | 98 |
93 ``` | 99 (gdb) add-symbol-file /path/to/chrome 0x7fe749fb82c0 |
94 | |
95 (gdb) add-symbol-file /path/to/chrome 0x7fe749fb82c0 | |
96 | |
97 ``` | |
98 | 100 |
99 Then use gdb as normal. | 101 Then use gdb as normal. |
100 | 102 |
101 ## Other resources | 103 ## Other resources |
102 | 104 |
103 For more discussion on this process see [Debugging a Minidump](http://www.chromi
um.org/chromium-os/how-tos-and-troubleshooting/crash-reporting/debugging-a-minid
ump). This page discusses the same process in the context of ChromeOS and many o
f the concepts and techniques overlap. | 105 For more discussion on this process see |
| 106 [Debugging a Minidump](http://www.chromium.org/chromium-os/how-tos-and-troublesh
ooting/crash-reporting/debugging-a-minidump). |
| 107 This page discusses the same process in the context of ChromeOS and many of the |
| 108 concepts and techniques overlap. |
OLD | NEW |