Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: docs/linux_debugging.md

Issue 1324603002: [Docs] Another round of stylistic fixes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « docs/linux_crash_dumping.md ('k') | docs/linux_debugging_gtk.md » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #summary tips for debugging on Linux 1 # Tips for debugging on Linux
2 #labels Linux
3 2
4 This page is for Chromium-specific debugging tips; learning how to run gdb is ou t of scope. 3 This page is for Chromium-specific debugging tips; learning how to run gdb is
4 out of scope.
5 5
6 6 [TOC]
7 7
8 ## Symbolized stack trace 8 ## Symbolized stack trace
9 9
10 The sandbox can interfere with the internal symbolizer. Use --no-sandbox (but ke ep this temporary) or an external symbolizer (see tools/valgrind/asan/asan\_symb olize.py). 10 The sandbox can interfere with the internal symbolizer. Use `--no-sandbox` (but
11 keep this temporary) or an external symbolizer (see
12 `tools/valgrind/asan/asan_symbolize.py`).
11 13
12 Generally, do not use --no-sandbox on waterfall bots, sandbox testing is needed. Talk to security@chromium.org. 14 Generally, do not use `--no-sandbox` on waterfall bots, sandbox testing is
15 needed. Talk to security@chromium.org.
13 16
14 ## GDB 17 ## GDB
18
15 **GDB-7.7 is required in order to debug Chrome on Linux.** 19 **GDB-7.7 is required in order to debug Chrome on Linux.**
16 20
17 Any prior version will fail to resolve symbols or segfault. 21 Any prior version will fail to resolve symbols or segfault.
18 22
19 ### Basic browser process debugging 23 ### Basic browser process debugging
20 24
21 ``` 25 gdb -tui -ex=r --args out/Debug/chrome --disable-seccomp-sandbox \
22 gdb -tui -ex=r --args out/Debug/chrome --disable-seccomp-sandbox http://google.c om 26 http://google.com
23 ```
24 27
25 ### Allowing attaching to foreign processes 28 ### Allowing attaching to foreign processes
26 On distributions that use the [Yama LSM](https://www.kernel.org/doc/Documentatio n/security/Yama.txt) (that includes Ubuntu and Chrome OS), process A can attach to process B only if A is an ancestor of B. 29
30 On distributions that use the
31 [Yama LSM](https://www.kernel.org/doc/Documentation/security/Yama.txt) (that
32 includes Ubuntu and Chrome OS), process A can attach to process B only if A is
33 an ancestor of B.
27 34
28 You will probably want to disable this feature by using 35 You will probably want to disable this feature by using
29 ``` 36
30 echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope 37 echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
31 ```
32 38
33 If you don't you'll get an error message such as "Could not attach to process". 39 If you don't you'll get an error message such as "Could not attach to process".
34 40
35 Note that you'll also probably want to use --no-sandbox, as explained below. 41 Note that you'll also probably want to use `--no-sandbox`, as explained below.
36 42
37 ### Multiprocess Tricks 43 ### Multiprocess Tricks
44
38 #### Getting renderer subprocesses into gdb 45 #### Getting renderer subprocesses into gdb
39 Since Chromium itself spawns the renderers, it can be tricky to grab a particula r with gdb. This command does the trick: 46
47 Since Chromium itself spawns the renderers, it can be tricky to grab a
48 particular with gdb. This command does the trick:
49
40 ``` 50 ```
41 chrome --no-sandbox --renderer-cmd-prefix='xterm -title renderer -e gdb --args' 51 chrome --no-sandbox --renderer-cmd-prefix='xterm -title renderer -e gdb --args'
42 ``` 52 ```
43 The "--no-sandbox" flag is needed because otherwise the seccomp sandbox will kil l the renderer process on startup, or the setuid sandbox will prevent xterm's ex ecution. The "xterm" is necessary or gdb will run in the current terminal, whic h can get particularly confusing since it's running in the background, and if yo u're also running the main process in gdb, won't work at all (the two instances will fight over the terminal). To auto-start the renderers in the debugger, send the "run" command to the debugger: 53
44 ``` 54 The `--no-sandbox` flag is needed because otherwise the seccomp sandbox will
45 chrome --no-sandbox --renderer-cmd-prefix='xterm -title renderer -e gdb -ex run --args' 55 kill the renderer process on startup, or the setuid sandbox will prevent xterm's
46 ``` 56 execution. The "xterm" is necessary or gdb will run in the current terminal,
57 which can get particularly confusing since it's running in the background, and
58 if you're also running the main process in gdb, won't work at all (the two
59 instances will fight over the terminal). To auto-start the renderers in the
60 debugger, send the "run" command to the debugger:
61
62 chrome --no-sandbox --renderer-cmd-prefix='xterm -title renderer -e gdb -ex \
63 run --args
64
47 If you're using Emacs and `M-x gdb`, you can do 65 If you're using Emacs and `M-x gdb`, you can do
48 ```
49 chrome "--renderer-cmd-prefix=gdb --args"
50 ```
51 66
52 Note: using the `--renderer-cmd-prefix` option bypasses the zygote launcher, so the renderers won't be sandboxed. It is generally not an issue, except when you are trying to debug interactions with the sandbox. If that's what you are doing, you will need to attach your debugger to a running renderer process (see below) . 67 chrome "--renderer-cmd-prefix=gdb --args"
53 68
54 You may also want to pass `--disable-hang-monitor` to suppress the hang monitor, which is rather annoying. 69 Note: using the `--renderer-cmd-prefix` option bypasses the zygote launcher, so
70 the renderers won't be sandboxed. It is generally not an issue, except when you
71 are trying to debug interactions with the sandbox. If that's what you are doing,
72 you will need to attach your debugger to a running renderer process (see below).
55 73
56 You can also use "--renderer-startup-dialog" and attach to the process in order to debug the renderer code. Go to http://www.chromium.org/blink/getting-started- with-blink-debugging for more information on how this can be done. 74 You may also want to pass `--disable-hang-monitor` to suppress the hang monitor,
75 which is rather annoying.
76
77 You can also use `--renderer-startup-dialog` and attach to the process in order
78 to debug the renderer code. Go to
79 http://www.chromium.org/blink/getting-started-with-blink-debugging for more
80 information on how this can be done.
57 81
58 #### Choosing which renderers to debug 82 #### Choosing which renderers to debug
59 If you are starting multiple renderers then the above means that multiple gdb's start and fight over the console. Instead, you can set the prefix to point to th is shell script:
60 83
61 ``` 84 If you are starting multiple renderers then the above means that multiple gdb's
85 start and fight over the console. Instead, you can set the prefix to point to
86 this shell script:
87
88 ```sh
62 #!/bin/sh 89 #!/bin/sh
63 90
64 echo "**** Child $$ starting: y to debug" 91 echo "**** Child $$ starting: y to debug"
65 read input 92 read input
66 if [ "$input" = "y" ] ; then 93 if [ "$input" = "y" ] ; then
67 gdb --args $* 94 gdb --args $*
68 else 95 else
69 $* 96 $*
70 fi 97 fi
71 ``` 98 ```
72 99
73 #### Selective breakpoints 100 #### Selective breakpoints
74 When debugging both the browser and renderer process, you might want to have sep arate set of breakpoints to hit. You can use gdb's command files to accomplish t his by putting breakpoints in separate files and instructing gdb to load them. 101
102 When debugging both the browser and renderer process, you might want to have
103 separate set of breakpoints to hit. You can use gdb's command files to
104 accomplish this by putting breakpoints in separate files and instructing gdb to
105 load them.
75 106
76 ``` 107 ```
77 gdb -x ~/debug/browser --args chrome --no-sandbox --disable-hang-monitor --rende rer-cmd-prefix='xterm -title renderer -e gdb -x ~/debug/renderer --args ' 108 gdb -x ~/debug/browser --args chrome --no-sandbox --disable-hang-monitor \
109 --renderer-cmd-prefix='xterm -title renderer -e gdb -x ~/debug/renderer \
110 --args '
78 ``` 111 ```
79 112
80 Also, instead of running gdb, you can use the script above, which let's you sele ct which renderer process to debug. Note: you might need to use the full path to the script and avoid $HOME or ~/. 113 Also, instead of running gdb, you can use the script above, which let's you
114 select which renderer process to debug. Note: you might need to use the full
115 path to the script and avoid `$HOME` or `~/.`
81 116
82 #### Connecting to a running renderer 117 #### Connecting to a running renderer
83 118
84 Usually `ps aux | grep chrome` will not give very helpful output. Try `pstree -p | grep chrome` to get something like 119 Usually `ps aux | grep chrome` will not give very helpful output. Try
120 `pstree -p | grep chrome` to get something like
85 121
86 ``` 122 ```
87 | |-bash(21969)---chrome(672)-+-chrome(694) 123 | |-bash(21969)---chrome(672)-+-chrome(694)
88 | | |-chrome(695)---chrom e(696)-+-{chrome}(697) 124 | | |-chrome(695)---chrom e(696)-+-{chrome}(697)
89 | | | \-{chrome}(709) 125 | | | \-{chrome}(709)
90 | | |-{chrome}(675) 126 | | |-{chrome}(675)
91 | | |-{chrome}(678) 127 | | |-{chrome}(678)
92 | | |-{chrome}(679) 128 | | |-{chrome}(679)
93 | | |-{chrome}(680) 129 | | |-{chrome}(680)
94 | | |-{chrome}(681) 130 | | |-{chrome}(681)
95 | | |-{chrome}(682) 131 | | |-{chrome}(682)
96 | | |-{chrome}(684) 132 | | |-{chrome}(684)
97 | | |-{chrome}(685) 133 | | |-{chrome}(685)
98 | | |-{chrome}(705) 134 | | |-{chrome}(705)
99 | | \-{chrome}(717) 135 | | \-{chrome}(717)
100 ``` 136 ```
101 137
102 Most of those are threads. In this case the browser process would be 672 and the (sole) renderer process is 696. You can use `gdb -p 696` to attach. Alternativ ely, you might find out the process ID from Chrome's built-in Task Manager (unde r the Tools menu). Right-click on the Task Manager, and enable "Process ID" in the list of columns. 138 Most of those are threads. In this case the browser process would be 672 and the
139 (sole) renderer process is 696. You can use `gdb -p 696` to attach.
140 Alternatively, you might find out the process ID from Chrome's built-in Task
141 Manager (under the Tools menu). Right-click on the Task Manager, and enable
142 "Process ID" in the list of columns.
103 143
104 Note: by default, sandboxed processes can't be attached by a debugger. To be abl e to do so, you will need to pass the `--allow-sandbox-debugging` option. 144 Note: by default, sandboxed processes can't be attached by a debugger. To be
145 able to do so, you will need to pass the `--allow-sandbox-debugging` option.
105 146
106 If the problem only occurs with the seccomp sandbox enabled (and the previous tr icks don't help), you could try enabling core-dumps (see the **Core files** sect ion). That would allow you to get a backtrace and see some local variables, tho ugh you won't be able to step through the running program. 147 If the problem only occurs with the seccomp sandbox enabled (and the previous
148 tricks don't help), you could try enabling core-dumps (see the **Core files**
149 section). That would allow you to get a backtrace and see some local variables,
150 though you won't be able to step through the running program.
107 151
108 Note: If you're interested in debugging LinuxSandboxIPC process, you can attach to 694 in the above diagram. The LinuxSandboxIPC process has the same command li ne flag as the browser process so that it's easy to identify it if you run `pstr ee -pa`. 152 Note: If you're interested in debugging LinuxSandboxIPC process, you can attach
153 to 694 in the above diagram. The LinuxSandboxIPC process has the same command
154 line flag as the browser process so that it's easy to identify it if you run
155 `pstree -pa`.
109 156
110 #### Getting GPU subprocesses into gdb 157 #### Getting GPU subprocesses into gdb
111 Use `--gpu-launcher` flag instead of `--renderer-cmd-prefix` in the instructions for renderer above.
112 158
113 #### Getting browser\_tests launched browsers into gdb 159 Use `--gpu-launcher` flag instead of `--renderer-cmd-prefix` in the instructions
114 Use environment variable `BROWSER_WRAPPER` instead of `--renderer-cmd-prefix` sw itch in the instructions above. 160 for renderer above.
161
162 #### Getting `browser_tests` launched browsers into gdb
163
164 Use environment variable `BROWSER_WRAPPER` instead of `--renderer-cmd-prefix`
165 switch in the instructions above.
115 166
116 Example: 167 Example:
117 $ BROWSER\_WRAPPER='xterm -title renderer -e gdb --eval-command=run --eval-comma nd=quit --args' out/Debug/browser\_tests --gtest\_filter=Print 168
169 ```shell
170 BROWSER_WRAPPER='xterm -title renderer -e gdb --eval-command=run \
171 --eval-command=quit --args' out/Debug/browser_tests --gtest_filter=Print
172 ```
118 173
119 #### Plugin Processes 174 #### Plugin Processes
175
120 Same strategies as renderers above, but the flag is called `--plugin-launcher`: 176 Same strategies as renderers above, but the flag is called `--plugin-launcher`:
121 ```
122 chrome --plugin-launcher='xterm -e gdb --args'
123 ```
124 177
125 _Note: For now, this does not currently apply to PPAPI plugins because they curr ently run in the renderer process._ 178 chrome --plugin-launcher='xterm -e gdb --args'
179
180 _Note: For now, this does not currently apply to PPAPI plugins because they
181 currently run in the renderer process._
126 182
127 #### Single-Process mode 183 #### Single-Process mode
128 Depending on whether it's relevant to the problem, it's often easier to just run in "single process" mode where the renderer threads are in-process. Then you c an just run gdb on the main process.
129 ```
130 gdb --args chrome --single-process
131 ```
132 184
133 Currently, the --disable-gpu flag is also required, as there are known crashes t hat occur under TextureImageTransportSurface without it. The crash described in http://crbug.com/361689 can also sometimes occur, but that crash can be continu ed from without harm. 185 Depending on whether it's relevant to the problem, it's often easier to just run
186 in "single process" mode where the renderer threads are in-process. Then you can
187 just run gdb on the main process.
134 188
135 Note that for technical reasons plugins cannot be in-process, so `--single-proce ss` only puts the renderers in the browser process. The flag is still useful fo r debugging plugins (since it's only two processes instead of three) but you'll still need to use `--plugin-launcher` or another approach. 189 gdb --args chrome --single-process
190
191 Currently, the `--disable-gpu` flag is also required, as there are known crashes
192 that occur under TextureImageTransportSurface without it. The crash described in
193 http://crbug.com/361689 can also sometimes occur, but that crash can be
194 continued from without harm.
195
196 Note that for technical reasons plugins cannot be in-process, so
197 `--single-process` only puts the renderers in the browser process. The flag is
198 still useful for debugging plugins (since it's only two processes instead of
199 three) but you'll still need to use `--plugin-launcher` or another approach.
136 200
137 ### Printing Chromium types 201 ### Printing Chromium types
138 gdb 7 lets us use Python to write pretty-printers for Chromium types. The direc tory `tools/gdb/` contains a Python gdb scripts useful for Chromium code. There are similar scripts [in WebKit](http://trac.webkit.org/wiki/GDB) (in fact, the Chromium script relies on using it with the WebKit one).
139 202
140 To include these pretty-printers with your gdb, put the following into `~/.gdbin it`: 203 gdb 7 lets us use Python to write pretty-printers for Chromium types. The
141 ``` 204 directory `tools/gdb/` contains a Python gdb scripts useful for Chromium code.
205 There are similar scripts [in WebKit](http://trac.webkit.org/wiki/GDB) (in fact,
206 the Chromium script relies on using it with the WebKit one).
207
208 To include these pretty-printers with your gdb, put the following into
209 `~/.gdbinit`:
210
211 ```python
142 python 212 python
143 import sys 213 import sys
144 sys.path.insert(0, "<path/to/chromium/src>/third_party/WebKit/Tools/gdb/") 214 sys.path.insert(0, "<path/to/chromium/src>/third_party/WebKit/Tools/gdb/")
145 import webkit 215 import webkit
146 sys.path.insert(0, "<path/to/chromium/src>/tools/gdb/") 216 sys.path.insert(0, "<path/to/chromium/src>/tools/gdb/")
147 import gdb_chrome 217 import gdb_chrome
148 ``` 218 ```
149 219
150 Pretty printers for std types shouldn't be necessary in gdb 7, but they're provi ded here in case you're using an older gdb. Put the following into `~/.gdbinit` : 220 Pretty printers for std types shouldn't be necessary in gdb 7, but they're
221 provided here in case you're using an older gdb. Put the following into
222 `~/.gdbinit`:
223
151 ``` 224 ```
152 # Print a C++ string. 225 # Print a C++ string.
153 define ps 226 define ps
154 print $arg0.c_str() 227 print $arg0.c_str()
155 end 228 end
156 229
157 # Print a C++ wstring or wchar_t*. 230 # Print a C++ wstring or wchar_t*.
158 define pws 231 define pws
159 printf "\"" 232 printf "\""
160 set $c = (wchar_t*)$arg0 233 set $c = (wchar_t*)$arg0
161 while ( *$c ) 234 while ( *$c )
162 if ( *$c > 0x7f ) 235 if ( *$c > 0x7f )
163 printf "[%x]", *$c 236 printf "[%x]", *$c
164 else 237 else
165 printf "%c", *$c 238 printf "%c", *$c
166 end 239 end
167 set $c++ 240 set $c++
168 end 241 end
169 printf "\"\n" 242 printf "\"\n"
170 end 243 end
171 ``` 244 ```
172 245
173 [More STL GDB macros](http://www.yolinux.com/TUTORIALS/src/dbinit_stl_views-1.01 .txt) 246 [More STL GDB macros](http://www.yolinux.com/TUTORIALS/src/dbinit_stl_views-1.01 .txt)
174 247
175 ### Graphical Debugging Aid for Chromium Views 248 ### Graphical Debugging Aid for Chromium Views
176 249
177 The following link describes a tool that can be used on Linux, Windows and Mac u nder GDB. 250 The following link describes a tool that can be used on Linux, Windows and Mac u nder GDB.
178 251
179 http://code.google.com/p/chromium/wiki/GraphicalDebuggingAidChromiumViews 252 [graphical_debugging_aid_chromium_views](graphical_debugging_aid_chromium_views. md)
180 253
181 ### Faster startup 254 ### Faster startup
182 255
183 Use the gdb-add-index script (e.g. build/gdb-add-index out/Debug/browser\_tests) 256 Use the `gdb-add-index` script (e.g.
184 257 `build/gdb-add-index out/Debug/browser_tests`)
185 Only makes sense if you run the binary multiple times or maybe if you use the co mponent build since most .so files won't require reindexing on a rebuild. 258
186 259 Only makes sense if you run the binary multiple times or maybe if you use the
187 See https://groups.google.com/a/chromium.org/forum/#!searchin/chromium-dev/gdb-a dd-index/chromium-dev/ELRuj1BDCL4/5Ki4LGx41CcJ for more info. 260 component build since most .so files won't require reindexing on a rebuild.
261
262 See
263 https://groups.google.com/a/chromium.org/forum/#!searchin/chromium-dev/gdb-add-i ndex/chromium-dev/ELRuj1BDCL4/5Ki4LGx41CcJ
264 for more info.
188 265
189 Alternatively, specify: 266 Alternatively, specify:
190 ``` 267
191 linux_use_debug_fission=0 268 linux_use_debug_fission=0
192 ``` 269
193 270 in `GYP_DEFINES`. This improves load time of gdb significantly at the cost of
194 in GYP\_DEFINES. This improves load time of gdb significantly at the cost of lin k time. 271 link time.
195 272
196 ## Core files 273 ## Core files
197 `ulimit -c unlimited` should cause all Chrome processes (run from that shell) to dump cores, with the possible exception of some sandboxed processes. 274
198 275 `ulimit -c unlimited` should cause all Chrome processes (run from that shell) to
199 Some sandboxed subprocesses might not dump cores unless you pass the `--allow-sa ndbox-debugging` flag. 276 dump cores, with the possible exception of some sandboxed processes.
200 277
201 If the problem is a freeze rather than a crash, you may be able to trigger a cor e-dump by sending SIGABRT to the relevant process: 278 Some sandboxed subprocesses might not dump cores unless you pass the
202 ``` 279 `--allow-sandbox-debugging` flag.
203 kill -6 [process id] 280
204 ``` 281 If the problem is a freeze rather than a crash, you may be able to trigger a
282 core-dump by sending SIGABRT to the relevant process:
283
284 kill -6 [process id]
205 285
206 ## Breakpad minidump files 286 ## Breakpad minidump files
207 287
208 See LinuxMinidumpToCore 288 See [linux_minidump_to_core.md](linux_minidump_to_core.md)
209 289
210 ## Running Tests 290 ## Running Tests
211 Many of our tests bring up windows on screen. This can be annoying (they steal your focus) and hard to debug (they receive extra events as you mouse over them) . Instead, use `Xvfb` or `Xephyr` to run a nested X session to debug them, as o utlined on LayoutTestsLinux. 291
292 Many of our tests bring up windows on screen. This can be annoying (they steal
293 your focus) and hard to debug (they receive extra events as you mouse over them) .
294 Instead, use `Xvfb` or `Xephyr` to run a nested X session to debug them, as
295 outlined on [layout_tests_linux.md](layout_tests_linux.md).
212 296
213 ### Browser tests 297 ### Browser tests
214 By default the browser\_tests forks a new browser for each test. To debug the b rowser side of a single test, use a command like 298
299 By default the `browser_tests` forks a new browser for each test. To debug the
300 browser side of a single test, use a command like
301
215 ``` 302 ```
216 gdb --args out/Debug/browser_tests --single_process --gtest_filter=MyTestName 303 gdb --args out/Debug/browser_tests --single_process --gtest_filter=MyTestName
217 ``` 304 ```
218 **note the underscore in single\_process** -- this makes the test harness and br owser process share the outermost process. 305
306 **note the underscore in `single_process`** -- this makes the test harness and
307 browser process share the outermost process.
219 308
220 309
221 To debug a renderer process in this case, use the tips above about renderers. 310 To debug a renderer process in this case, use the tips above about renderers.
222 311
223 ### Layout tests 312 ### Layout tests
224 See LayoutTestsLinux for some tips. In particular, note that it's possible to d ebug a layout test via `ssh`ing to a Linux box; you don't need anything on scree n if you use `Xvfb`. 313
314 See [layout_tests_linux.md](layout_tests_linux.md) for some tips. In particular,
315 note that it's possible to debug a layout test via `ssh`ing to a Linux box; you
316 don't need anything on screen if you use `Xvfb`.
225 317
226 ### UI tests 318 ### UI tests
227 UI tests are run in forked browsers. Unlike browser tests, you cannot do any sin gle process tricks here to debug the browser. See below about `BROWSER_WRAPPER` . 319
228 320 UI tests are run in forked browsers. Unlike browser tests, you cannot do any
229 To pass flags to the browser, use a command line like `--extra-chrome-flags="--f oo --bar"`. 321 single process tricks here to debug the browser. See below about
322 `BROWSER_WRAPPER`.
323
324 To pass flags to the browser, use a command line like
325 `--extra-chrome-flags="--foo --bar"`.
230 326
231 ### Timeouts 327 ### Timeouts
232 UI tests have a confusing array of timeouts in place. (Pawel is working on redu cing the number of timeouts.) To disable them while you debug, set the timeout flags to a large value: 328
233 * `--test-timeout=100000000` 329 UI tests have a confusing array of timeouts in place. (Pawel is working on
234 * `--ui-test-action-timeout=100000000` 330 reducing the number of timeouts.) To disable them while you debug, set the
235 * `--ui-test-terminate-timeout=100000000` 331 timeout flags to a large value:
332
333 * `--test-timeout=100000000`
334 * `--ui-test-action-timeout=100000000`
335 * `--ui-test-terminate-timeout=100000000`
236 336
237 ### To replicate Window Manager setup on the bots 337 ### To replicate Window Manager setup on the bots
238 Chromium try bots and main waterfall's bots run tests under Xvfb&openbox combina tion. Xvfb is an X11 server that redirects the graphical output to the memeory, and openbox is a simple window manager that is running on top of Xvfb. The behav ior of openbox is markedly different when it comes to focus management and other window tasks, so test that runs fine locally may fail or be flaky on try bots. To run the tests on a local machine as on a bot, follow these steps: 338
339 Chromium try bots and main waterfall's bots run tests under Xvfb&openbox
340 combination. Xvfb is an X11 server that redirects the graphical output to the
341 memory, and openbox is a simple window manager that is running on top of Xvfb.
342 The behavior of openbox is markedly different when it comes to focus management
343 and other window tasks, so test that runs fine locally may fail or be flaky on
344 try bots. To run the tests on a local machine as on a bot, follow these steps:
239 345
240 Make sure you have openbox: 346 Make sure you have openbox:
241 ``` 347
242 apt-get install openbox 348 apt-get install openbox
243 ``` 349
244 Start Xvfb and openbox on a particular display: 350 Start Xvfb and openbox on a particular display:
245 ``` 351
246 Xvfb :6.0 -screen 0 1280x1024x24 & DISPLAY=:6.0 openbox & 352 Xvfb :6.0 -screen 0 1280x1024x24 & DISPLAY=:6.0 openbox &
247 ``` 353
248 Run your tests with graphics output redirected to that display: 354 Run your tests with graphics output redirected to that display:
249 ``` 355
250 DISPLAY=:6.0 out/Debug/browser_tests --gtest_filter="MyBrowserTest.MyActivateWin dowTest" 356 DISPLAY=:6.0 out/Debug/browser_tests --gtest_filter="MyBrowserTest.MyActivat eWindowTest"
251 ``` 357
252 You can look at a snapshot of the output by: 358 You can look at a snapshot of the output by:
253 ``` 359
254 xwd -display :6.0 -root | xwud 360 xwd -display :6.0 -root | xwud
255 ```
256 361
257 Alternatively, you can use testing/xvfb.py to set up your environment for you: 362 Alternatively, you can use testing/xvfb.py to set up your environment for you:
258 ``` 363
259 testing/xvfb.py out/Debug out/Debug/browser_tests --gtest_filter="MyBrowserTest. MyActivateWindowTest" 364 testing/xvfb.py out/Debug out/Debug/browser_tests \
260 ``` 365 --gtest_filter="MyBrowserTest.MyActivateWindowTest"
261 366
262 ### BROWSER\_WRAPPER 367 ### `BROWSER_WRAPPER`
263 You can also get the browser under a debugger by setting the `BROWSER_WRAPPER` e nvironment variable. (You can use this for `browser_tests` too, but see above f or discussion of a simpler way.) 368
264 369 You can also get the browser under a debugger by setting the `BROWSER_WRAPPER`
265 ``` 370 environment variable. (You can use this for `browser_tests` too, but see above
266 BROWSER_WRAPPER='xterm -e gdb --args' out/Debug/browser_tests 371 for discussion of a simpler way.)
267 ``` 372
373 BROWSER_WRAPPER='xterm -e gdb --args' out/Debug/browser_tests
268 374
269 ### Replicating Trybot Slowness 375 ### Replicating Trybot Slowness
270 376
271 Trybots are pretty stressed, and can sometimes expose timing issues you can't no rmally reproduce locally. 377 Trybots are pretty stressed, and can sometimes expose timing issues you can't
272 378 normally reproduce locally.
273 You can simulate this by shutting down all but one of the CPUs (http://www.cyber citi.biz/faq/debian-rhel-centos-redhat-suse-hotplug-cpu/) and running a CPU load ing tool (e.g., http://www.devin.com/lookbusy/). Now run your test. It will run slowly, but any flakiness found by the trybot should replicate locally now - and often nearly 100% of the time. 379
380 You can simulate this by shutting down all but one of the CPUs
381 (http://www.cyberciti.biz/faq/debian-rhel-centos-redhat-suse-hotplug-cpu/) and
382 running a CPU loading tool (e.g., http://www.devin.com/lookbusy/). Now run your
383 test. It will run slowly, but any flakiness found by the trybot should replicate
384 locally now - and often nearly 100% of the time.
274 385
275 ## Logging 386 ## Logging
387
276 ### Seeing all LOG(foo) messages 388 ### Seeing all LOG(foo) messages
277 Default log level hides `LOG(INFO)`. Run with `--log-level=0` and `--enable-log ging=stderr` flags. 389
278 390 Default log level hides `LOG(INFO)`. Run with `--log-level=0` and
279 Newer versions of chromium with VLOG may need --v=1 too. For more VLOG tips, see the chromium-dev thread: http://groups.google.com/a/chromium.org/group/chromium -dev/browse_thread/thread/dcd0cd7752b35de6?pli=1 391 `--enable-logging=stderr` flags.
392
393 Newer versions of chromium with VLOG may need --v=1 too. For more VLOG tips, see
394 the chromium-dev thread:
395 http://groups.google.com/a/chromium.org/group/chromium-dev/browse_thread/thread/ dcd0cd7752b35de6?pli=1
280 396
281 ### Seeing IPC debug messages 397 ### Seeing IPC debug messages
282 Run with CHROME\_IPC\_LOGGING=1 eg. 398
283 ``` 399 Run with `CHROME_IPC_LOGGING=1` eg.
284 CHROME_IPC_LOGGING=1 out/Debug/chrome 400
285 ``` 401 CHROME_IPC_LOGGING=1 out/Debug/chrome
402
286 or within gdb: 403 or within gdb:
287 ``` 404
288 set environment CHROME_IPC_LOGGING 1 405 set environment CHROME_IPC_LOGGING 1
289 ``` 406
290 407 If some messages show as unknown, check if the list of IPC message headers in
291 If some messages show as unknown, check if the list of IPC message headers in ch rome/common/logging\_chrome.cc is up-to-date. In case this file reference goes o ut of date, try looking for usage of macros like IPC\_MESSAGE\_LOG\_ENABLED or I PC\_MESSAGE\_MACROS\_LOG\_ENABLED. 408 `chrome/common/logging_chrome.cc` is up-to-date. In case this file reference
409 goes out of date, try looking for usage of macros like `IPC_MESSAGE_LOG_ENABLED`
410 or `IPC_MESSAGE_MACROS_LOG_ENABLED`.
292 411
293 ## Using valgrind 412 ## Using valgrind
294 413
295 To run valgrind on the browser and renderer processes, with our suppression file and flags: 414 To run valgrind on the browser and renderer processes, with our suppression file
296 ``` 415 and flags:
297 $ cd $CHROMIUM_ROOT/src 416
298 $ tools/valgrind/valgrind.sh out/Debug/chrome 417 $ cd $CHROMIUM_ROOT/src
299 ``` 418 $ tools/valgrind/valgrind.sh out/Debug/chrome
300 419
301 You can use valgrind on chrome and/or on the renderers e.g 420 You can use valgrind on chrome and/or on the renderers e.g
302 `valgrind --smc-check=all ../sconsbuild/Debug/chrome` 421 `valgrind --smc-check=all ../sconsbuild/Debug/chrome`
303 or by passing valgrind as the argument to `--render-cmd-prefix`. 422 or by passing valgrind as the argument to `--render-cmd-prefix`.
304 423
305 Beware that there are several valgrind "false positives" e.g. pickle, sqlite and some instances in webkit that are ignorable. On systems with prelink and addres s space randomization (e.g. Fedora), you may also see valgrind errors in libstdc ++ on startup and in gnome-breakpad. 424 Beware that there are several valgrind "false positives" e.g. pickle, sqlite and
425 some instances in webkit that are ignorable. On systems with prelink and address
426 space randomization (e.g. Fedora), you may also see valgrind errors in libstdc++
427 on startup and in gnome-breakpad.
306 428
307 Valgrind doesn't seem to play nice with tcmalloc. To disable tcmalloc run GYP 429 Valgrind doesn't seem to play nice with tcmalloc. To disable tcmalloc run GYP
308 ``` 430
309 $ cd $CHROMIUM_ROOT/src 431 $ cd $CHROMIUM_ROOT/src
310 $ build/gyp_chromium -Duse_allocator=none 432 $ build/gyp_chromium -Duse_allocator=none
311 ``` 433
312 and rebuild. 434 and rebuild.
313 435
314 ## Profiling 436 ## Profiling
315 See https://sites.google.com/a/chromium.org/dev/developers/profiling-chromium-an d-webkit and http://code.google.com/p/chromium/wiki/LinuxProfiling 437
438 See
439 https://sites.google.com/a/chromium.org/dev/developers/profiling-chromium-and-we bkit
440 and
441 http://code.google.com/p/chromium/wiki/LinuxProfiling
316 442
317 ## i18n 443 ## i18n
318 We obey your system locale. Try something like: 444
319 ``` 445 We obey your system locale. Try something like:
320 LANG=ja_JP.UTF-8 out/Debug/chrome 446
321 ``` 447 LANG=ja_JP.UTF-8 out/Debug/chrome
322 If this doesn't work, make sure that the LANGUAGE, LC\_ALL and LC\_MESSAGE envir onment variables aren't set -- they have higher priority than LANG in the order listed. Alternatively, just do this: 448
323 449 If this doesn't work, make sure that the `LANGUAGE`, `LC_ALL` and `LC_MESSAGE`
324 ``` 450 environment variables aren't set -- they have higher priority than LANG in the
325 LANGUAGE=fr out/Debug/chrome 451 order listed. Alternatively, just do this:
326 ``` 452
327 453 LANGUAGE=fr out/Debug/chrome
328 Note that because we use GTK, some locale data comes from the system -- for exam ple, file save boxes and whether the current language is considered RTL. Withou t all the language data available, Chrome will use a mixture of your system lang uage and the language you run Chrome in. 454
455 Note that because we use GTK, some locale data comes from the system -- for
456 example, file save boxes and whether the current language is considered RTL.
457 Without all the language data available, Chrome will use a mixture of your
458 system language and the language you run Chrome in.
329 459
330 Here's how to install the Arabic (ar) and Hebrew (he) language packs: 460 Here's how to install the Arabic (ar) and Hebrew (he) language packs:
331 ``` 461
332 sudo apt-get install language-pack-ar language-pack-he language-pack-gnome-ar la nguage-pack-gnome-he 462 sudo apt-get install language-pack-ar language-pack-he \
333 ``` 463 language-pack-gnome-ar language-pack-gnome-he
464
334 Note that the `--lang` flag does **not** work properly for this. 465 Note that the `--lang` flag does **not** work properly for this.
335 466
336 On non-Debian systems, you need the `gtk20.mo` files. (Please update these docs with the appropriate instructions if you know what they are.) 467 On non-Debian systems, you need the `gtk20.mo` files. (Please update these docs
468 with the appropriate instructions if you know what they are.)
337 469
338 ## Breakpad 470 ## Breakpad
339 See the last section of LinuxCrashDumping; you need to set a gyp variable and an environment variable for the crash dump tests to work. 471
472 See the last section of [linux_crash_dumping.md](linux_crash_dumping.md); you
473 need to set a gyp variable and an environment variable for the crash dump tests
474 to work.
340 475
341 ## Drag and Drop 476 ## Drag and Drop
342 If you break in a debugger during a drag, Chrome will have grabbed your mouse an d keyboard so you won't be able to interact with the debugger! To work around t his, run via `Xephyr`. Instructions for how to use `Xephyr` are on the LayoutTes tsLinux page. 477
478 If you break in a debugger during a drag, Chrome will have grabbed your mouse
479 and keyboard so you won't be able to interact with the debugger! To work around
480 this, run via `Xephyr`. Instructions for how to use `Xephyr` are on the
481 [layout_tests_linux.md](layout_tests_linux.md) page.
343 482
344 ## Tracking Down Bugs 483 ## Tracking Down Bugs
345 484
346 ### Isolating Regressions 485 ### Isolating Regressions
347 Old builds are archived here: http://build.chromium.org/buildbot/snapshots/chrom ium-rel-linux/ 486
348 487 Old builds are archived here:
349 `tools/bisect-builds.py` in the tree automates bisecting through the archived bu ilds. Despite a computer science education, I am still amazed how quickly binar y search will find its target. 488 http://build.chromium.org/buildbot/snapshots/chromium-rel-linux/
489
490 `tools/bisect-builds.py` in the tree automates bisecting through the archived
491 builds. Despite a computer science education, I am still amazed how quickly
492 binary search will find its target.
350 493
351 ### Screen recording for bug reports 494 ### Screen recording for bug reports
352 `sudo apt-get install gtk-recordmydesktop` 495
496 sudo apt-get install gtk-recordmydesktop
353 497
354 ## Version-specific issues 498 ## Version-specific issues
355 499
356 ### Google Chrome 500 ### Google Chrome
357 Google Chrome binaries don't include symbols. Googlers can read where to get sy mbols from [the Google-internal wiki](http://wiki/Main/ChromeOfficialBuildLinux# The_Build_Archive). 501
502 Google Chrome binaries don't include symbols. Googlers can read where to get
503 symbols from
504 [the Google-internal wiki](http://wiki/Main/ChromeOfficialBuildLinux#The_Build_A rchive).
358 505
359 ### Ubuntu Chromium 506 ### Ubuntu Chromium
360 Since we don't build the Ubuntu packages (Ubuntu does) we can't get useful backt races from them. Direct users to https://wiki.ubuntu.com/Chromium/Debugging . 507
508 Since we don't build the Ubuntu packages (Ubuntu does) we can't get useful
509 backtraces from them. Direct users to https://wiki.ubuntu.com/Chromium/Debugging
361 510
362 ### Fedora's Chromium 511 ### Fedora's Chromium
363 Like Ubuntu, but direct users to https://fedoraproject.org/wiki/TomCallaway/Chro mium_Debug . 512
513 Like Ubuntu, but direct users to
514 https://fedoraproject.org/wiki/TomCallaway/Chromium_Debug
364 515
365 ### Xlib 516 ### Xlib
517
366 If you're trying to track down X errors like: 518 If you're trying to track down X errors like:
519
367 ``` 520 ```
368 The program 'chrome' received an X Window System error. 521 The program 'chrome' received an X Window System error.
369 This probably reflects a bug in the program. 522 This probably reflects a bug in the program.
370 The error was 'BadDrawable (invalid Pixmap or Window parameter)'. 523 The error was 'BadDrawable (invalid Pixmap or Window parameter)'.
371 ``` 524 ```
525
372 Some strategies are: 526 Some strategies are:
373 * pass `--sync` on the command line to make all X calls synchronous 527
374 * run chrome via [xtrace](http://xtrace.alioth.debian.org/) 528 * pass `--sync` on the command line to make all X calls synchronous
375 * turn on IPC debugging (see above section) 529 * run chrome via [xtrace](http://xtrace.alioth.debian.org/)
530 * turn on IPC debugging (see above section)
376 531
377 ### Window Managers 532 ### Window Managers
378 To test on various window managers, you can use a nested X server like `Xephyr`. Instructions for how to use `Xephyr` are on the LayoutTestsLinux page. 533
379 534 To test on various window managers, you can use a nested X server like `Xephyr`.
380 If you need to test something with hardware accelerated compositing (e.g., compi z), you can use `Xgl` (`sudo apt-get install xserver-xgl`). E.g.: 535 Instructions for how to use `Xephyr` are on the
381 ``` 536 [layout_tests_linux.md](layout_tests_linux.md) page.
382 Xgl :1 -ac -accel glx:pbuffer -accel xv:pbuffer -screen 1024x768 537
383 ``` 538 If you need to test something with hardware accelerated compositing
539 (e.g., compiz), you can use `Xgl` (`sudo apt-get install xserver-xgl`). E.g.:
540
541 Xgl :1 -ac -accel glx:pbuffer -accel xv:pbuffer -screen 1024x768
542
384 ## Mozilla Tips 543 ## Mozilla Tips
385 https://developer.mozilla.org/en/Debugging_Mozilla_on_Linux_FAQ 544
545 https://developer.mozilla.org/en/Debugging_Mozilla_on_Linux_FAQ
OLDNEW
« no previous file with comments | « docs/linux_crash_dumping.md ('k') | docs/linux_debugging_gtk.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698