blob: 587080a9d54ed8b39767d87ec7afb835de7d6678 [file] [log] [blame] [view]
andybonse6a8f2bd2015-08-31 22:46:011# Tips for debugging on Linux
andybons3322f762015-08-24 21:37:092
andybonsad92aa32015-08-31 02:27:443This page is for Chromium-specific debugging tips; learning how to run gdb is
4out of scope.
andybons3322f762015-08-24 21:37:095
andybonsad92aa32015-08-31 02:27:446[TOC]
andybons3322f762015-08-24 21:37:097
8## Symbolized stack trace
9
andybonsad92aa32015-08-31 02:27:4410The sandbox can interfere with the internal symbolizer. Use `--no-sandbox` (but
11keep this temporary) or an external symbolizer (see
12`tools/valgrind/asan/asan_symbolize.py`).
andybons3322f762015-08-24 21:37:0913
andybonsad92aa32015-08-31 02:27:4414Generally, do not use `--no-sandbox` on waterfall bots, sandbox testing is
15needed. Talk to security@chromium.org.
andybons3322f762015-08-24 21:37:0916
17## GDB
andybonsad92aa32015-08-31 02:27:4418
nodira6074d4c2015-09-01 04:26:4519*** promo
20GDB-7.7 is required in order to debug Chrome on Linux.
21***
andybons3322f762015-08-24 21:37:0922
23Any prior version will fail to resolve symbols or segfault.
24
25### Basic browser process debugging
26
andybonsad92aa32015-08-31 02:27:4427 gdb -tui -ex=r --args out/Debug/chrome --disable-seccomp-sandbox \
28 http://google.com
andybons3322f762015-08-24 21:37:0929
30### Allowing attaching to foreign processes
andybonsad92aa32015-08-31 02:27:4431
32On distributions that use the
33[Yama LSM](https://www.kernel.org/doc/Documentation/security/Yama.txt) (that
34includes Ubuntu and Chrome OS), process A can attach to process B only if A is
35an ancestor of B.
andybons3322f762015-08-24 21:37:0936
37You will probably want to disable this feature by using
andybonsad92aa32015-08-31 02:27:4438
39 echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
andybons3322f762015-08-24 21:37:0940
41If you don't you'll get an error message such as "Could not attach to process".
42
andybonsad92aa32015-08-31 02:27:4443Note that you'll also probably want to use `--no-sandbox`, as explained below.
andybons3322f762015-08-24 21:37:0944
45### Multiprocess Tricks
andybonsad92aa32015-08-31 02:27:4446
andybons3322f762015-08-24 21:37:0947#### Getting renderer subprocesses into gdb
andybonsad92aa32015-08-31 02:27:4448
49Since Chromium itself spawns the renderers, it can be tricky to grab a
50particular with gdb. This command does the trick:
51
andybons3322f762015-08-24 21:37:0952```
53chrome --no-sandbox --renderer-cmd-prefix='xterm -title renderer -e gdb --args'
54```
andybonsad92aa32015-08-31 02:27:4455
56The `--no-sandbox` flag is needed because otherwise the seccomp sandbox will
57kill the renderer process on startup, or the setuid sandbox will prevent xterm's
58execution. The "xterm" is necessary or gdb will run in the current terminal,
59which can get particularly confusing since it's running in the background, and
60if you're also running the main process in gdb, won't work at all (the two
61instances will fight over the terminal). To auto-start the renderers in the
62debugger, send the "run" command to the debugger:
63
nodira6074d4c2015-09-01 04:26:4564 chrome --no-sandbox --renderer-cmd-prefix='xterm -title renderer -e gdb \
Zhang Haoa95224882021-05-12 11:26:3665 -ex run --args'
andybonsad92aa32015-08-31 02:27:4466
andybons3322f762015-08-24 21:37:0967If you're using Emacs and `M-x gdb`, you can do
andybons3322f762015-08-24 21:37:0968
andybonsad92aa32015-08-31 02:27:4469 chrome "--renderer-cmd-prefix=gdb --args"
andybons3322f762015-08-24 21:37:0970
nodira6074d4c2015-09-01 04:26:4571*** note
andybonsad92aa32015-08-31 02:27:4472Note: using the `--renderer-cmd-prefix` option bypasses the zygote launcher, so
73the renderers won't be sandboxed. It is generally not an issue, except when you
74are trying to debug interactions with the sandbox. If that's what you are doing,
75you will need to attach your debugger to a running renderer process (see below).
nodira6074d4c2015-09-01 04:26:4576***
andybons3322f762015-08-24 21:37:0977
andybonsad92aa32015-08-31 02:27:4478You may also want to pass `--disable-hang-monitor` to suppress the hang monitor,
79which is rather annoying.
80
81You can also use `--renderer-startup-dialog` and attach to the process in order
82to debug the renderer code. Go to
xiaoyin.l1003c0b2016-12-06 02:51:1783https://www.chromium.org/blink/getting-started-with-blink-debugging for more
andybonsad92aa32015-08-31 02:27:4484information on how this can be done.
andybons3322f762015-08-24 21:37:0985
Alex Gough20926742021-05-13 20:11:3086For utilities you can use `--utility-startup-dialog` to have all utilities
87prompt, or `--utility-startup-dialog=data_decoder.mojom.DataDecoderService`
88to debug only a particular service type.
89
andybons3322f762015-08-24 21:37:0990#### Choosing which renderers to debug
andybons3322f762015-08-24 21:37:0991
andybonsad92aa32015-08-31 02:27:4492If you are starting multiple renderers then the above means that multiple gdb's
93start and fight over the console. Instead, you can set the prefix to point to
94this shell script:
95
96```sh
andybons3322f762015-08-24 21:37:0997#!/bin/sh
98
99echo "**** Child $$ starting: y to debug"
100read input
101if [ "$input" = "y" ] ; then
102 gdb --args $*
103else
104 $*
105fi
106```
107
Robert Flackcdbf8c4a2022-11-18 18:12:34108#### Choosing renderer to debug by URL
109
110In most cases you'll want to debug the renderer which is loading a particular
111site. If you want a script which will automatically debug the renderer which has
112visited a given target URL and continue all other renderers, you can use the
113following:
114
115```sh
116./third_party/blink/tools/debug_renderer out/Default/content_shell https://example.domain/path
117```
118
119The script also supports specifying a different URL than the navigation URL.
120This is useful when the renderer you want to debug is not the top frame but one
121of the subframes on the page. For example, you could debug a particular subframe
122on a page with:
123
124```sh
125./third_party/blink/tools/debug_renderer -d https://subframe.url/path out/Default/content_shell https://example.domain/path
126```
127
128However, if you need more fine-grained control over which renderers to debug
129you can run chrome or content_shell directly with the
130`--wait-for-debugger-on-navigation` flag which will pause each renderer at the
131point of navigation (when the URL is known).
132
133This will result in a series of lines such as the following in the output:
134```
135...:content_switches_internal.cc(119)] Renderer url="https://example.domain/path" (PID) paused waiting for debugger to attach. Send SIGUSR1 to unpause.
136```
137
138You can signal the renderers you aren't interested in to continue running with:
139```sh
140kill -s SIGUSR1
141```
142
143And debug the renderer you are interested in debugging with:
144```sh
145gdb -p
146```
147
andybons3322f762015-08-24 21:37:09148#### Selective breakpoints
andybonsad92aa32015-08-31 02:27:44149
150When debugging both the browser and renderer process, you might want to have
151separate set of breakpoints to hit. You can use gdb's command files to
152accomplish this by putting breakpoints in separate files and instructing gdb to
153load them.
andybons3322f762015-08-24 21:37:09154
155```
andybonsad92aa32015-08-31 02:27:44156gdb -x ~/debug/browser --args chrome --no-sandbox --disable-hang-monitor \
157 --renderer-cmd-prefix='xterm -title renderer -e gdb -x ~/debug/renderer \
158 --args '
andybons3322f762015-08-24 21:37:09159```
160
andybonsad92aa32015-08-31 02:27:44161Also, instead of running gdb, you can use the script above, which let's you
162select which renderer process to debug. Note: you might need to use the full
163path to the script and avoid `$HOME` or `~/.`
andybons3322f762015-08-24 21:37:09164
165#### Connecting to a running renderer
166
andybonsad92aa32015-08-31 02:27:44167Usually `ps aux | grep chrome` will not give very helpful output. Try
168`pstree -p | grep chrome` to get something like
andybons3322f762015-08-24 21:37:09169
170```
171 | |-bash(21969)---chrome(672)-+-chrome(694)
172 | | |-chrome(695)---chrome(696)-+-{chrome}(697)
173 | | | \-{chrome}(709)
174 | | |-{chrome}(675)
175 | | |-{chrome}(678)
176 | | |-{chrome}(679)
177 | | |-{chrome}(680)
178 | | |-{chrome}(681)
179 | | |-{chrome}(682)
180 | | |-{chrome}(684)
181 | | |-{chrome}(685)
182 | | |-{chrome}(705)
183 | | \-{chrome}(717)
184```
185
andybonsad92aa32015-08-31 02:27:44186Most of those are threads. In this case the browser process would be 672 and the
187(sole) renderer process is 696. You can use `gdb -p 696` to attach.
188Alternatively, you might find out the process ID from Chrome's built-in Task
189Manager (under the Tools menu). Right-click on the Task Manager, and enable
190"Process ID" in the list of columns.
andybons3322f762015-08-24 21:37:09191
andybonsad92aa32015-08-31 02:27:44192Note: by default, sandboxed processes can't be attached by a debugger. To be
193able to do so, you will need to pass the `--allow-sandbox-debugging` option.
andybons3322f762015-08-24 21:37:09194
andybonsad92aa32015-08-31 02:27:44195If the problem only occurs with the seccomp sandbox enabled (and the previous
196tricks don't help), you could try enabling core-dumps (see the **Core files**
197section). That would allow you to get a backtrace and see some local variables,
198though you won't be able to step through the running program.
andybons3322f762015-08-24 21:37:09199
andybonsad92aa32015-08-31 02:27:44200Note: If you're interested in debugging LinuxSandboxIPC process, you can attach
201to 694 in the above diagram. The LinuxSandboxIPC process has the same command
202line flag as the browser process so that it's easy to identify it if you run
203`pstree -pa`.
andybons3322f762015-08-24 21:37:09204
205#### Getting GPU subprocesses into gdb
andybons3322f762015-08-24 21:37:09206
andybonsad92aa32015-08-31 02:27:44207Use `--gpu-launcher` flag instead of `--renderer-cmd-prefix` in the instructions
208for renderer above.
209
210#### Getting `browser_tests` launched browsers into gdb
211
212Use environment variable `BROWSER_WRAPPER` instead of `--renderer-cmd-prefix`
213switch in the instructions above.
andybons3322f762015-08-24 21:37:09214
215Example:
andybonsad92aa32015-08-31 02:27:44216
217```shell
218BROWSER_WRAPPER='xterm -title renderer -e gdb --eval-command=run \
219 --eval-command=quit --args' out/Debug/browser_tests --gtest_filter=Print
220```
andybons3322f762015-08-24 21:37:09221
222#### Plugin Processes
andybons3322f762015-08-24 21:37:09223
andybonsad92aa32015-08-31 02:27:44224Same strategies as renderers above, but the flag is called `--plugin-launcher`:
225
226 chrome --plugin-launcher='xterm -e gdb --args'
227
nodira6074d4c2015-09-01 04:26:45228*** note
229Note: For now, this does not currently apply to PPAPI plugins because they
230currently run in the renderer process.
231***
andybons3322f762015-08-24 21:37:09232
233#### Single-Process mode
andybons3322f762015-08-24 21:37:09234
andybonsad92aa32015-08-31 02:27:44235Depending on whether it's relevant to the problem, it's often easier to just run
236in "single process" mode where the renderer threads are in-process. Then you can
237just run gdb on the main process.
andybons3322f762015-08-24 21:37:09238
andybonsad92aa32015-08-31 02:27:44239 gdb --args chrome --single-process
240
241Currently, the `--disable-gpu` flag is also required, as there are known crashes
242that occur under TextureImageTransportSurface without it. The crash described in
xiaoyin.l1003c0b2016-12-06 02:51:17243https://crbug.com/361689 can also sometimes occur, but that crash can be
andybonsad92aa32015-08-31 02:27:44244continued from without harm.
245
246Note that for technical reasons plugins cannot be in-process, so
247`--single-process` only puts the renderers in the browser process. The flag is
248still useful for debugging plugins (since it's only two processes instead of
249three) but you'll still need to use `--plugin-launcher` or another approach.
andybons3322f762015-08-24 21:37:09250
251### Printing Chromium types
andybons3322f762015-08-24 21:37:09252
Tom Andersonf06ac382019-04-10 03:49:38253gdb 7 lets us use Python to write pretty-printers for Chromium types. See
John Palmer046f9872021-05-24 01:24:56254[gdbinit](https://chromium.googlesource.com/chromium/src/+/main/docs/gdbinit.md)
Tom Andersonf06ac382019-04-10 03:49:38255to enable pretty-printing of Chromium types. This will import Blink
256pretty-printers as well.
Kenichi Ishibashie17b8d9f2018-04-26 03:32:46257
andybonsad92aa32015-08-31 02:27:44258Pretty printers for std types shouldn't be necessary in gdb 7, but they're
259provided here in case you're using an older gdb. Put the following into
260`~/.gdbinit`:
261
andybons3322f762015-08-24 21:37:09262```
263# Print a C++ string.
264define ps
265 print $arg0.c_str()
266end
267
268# Print a C++ wstring or wchar_t*.
269define pws
270 printf "\""
271 set $c = (wchar_t*)$arg0
272 while ( *$c )
273 if ( *$c > 0x7f )
274 printf "[%x]", *$c
275 else
276 printf "%c", *$c
277 end
278 set $c++
279 end
280 printf "\"\n"
281end
282```
283
284[More STL GDB macros](http://www.yolinux.com/TUTORIALS/src/dbinit_stl_views-1.01.txt)
285
Christian Biesinger3332bb3a2019-08-13 05:45:23286### JsDbg -- visualize data structures in the browser
287
288JsDbg is a debugger plugin to display various Chrome data structures in a
289browser window, such as the accessibility tree, layout object tree, DOM tree,
290and others.
291[Installation instructions are here](https://github.com/MicrosoftEdge/JsDbg),
292and see [here](https://github.com/MicrosoftEdge/JsDbg/blob/master/docs/FEATURES.md)
293for screenshots and an introduction.
294
295For Googlers, please see [go/jsdbg](https://goto.google.com/jsdbg) for
296installation instructions.
297
298### Time travel debugging with rr
299
300You can use [rr](https://rr-project.org) for time travel debugging, so you
301can also step or execute backwards. This works by first recording a trace
L. David Barone99d91eb2021-03-30 20:18:00302and then debugging based on that.
Christian Biesinger3332bb3a2019-08-13 05:45:23303
Steve Kobes8ce3e44d2022-01-28 22:36:59304You need an up-to-date version of rr, since rr is frequently updated to support
305new parts of the Linux system call API surface that Chromium uses. If you have
306any issues with the latest release version, try compiling rr
L. David Barone99d91eb2021-03-30 20:18:00307[from source](https://github.com/rr-debugger/rr/wiki/Building-And-Installing).
Robert Flackc9e69952020-05-13 19:52:31308
Christian Biesinger3332bb3a2019-08-13 05:45:23309Once installed, you can use it like this:
310```
Steve Kobes8ce3e44d2022-01-28 22:36:59311rr record out/Debug/content_shell --single-process
Christian Biesinger3332bb3a2019-08-13 05:45:23312rr replay
Steve Kobes8ce3e44d2022-01-28 22:36:59313(rr) c
314(rr) break blink::NGBlockNode::Layout
315(rr) rc # reverse-continue to the last Layout call
316(rr) jsdbg # run JsDbg as described above to find the interesting object
317(rr) watch -l box_->frame_rect_.size_.width_.value_
318(rr) rc # reverse-continue to the last time the width was changed
319(rr) rn # reverse-next to the previous line
320(rr) reverse-fin # run to where this function was called from
Christian Biesinger3332bb3a2019-08-13 05:45:23321```
322
L. David Barone99d91eb2021-03-30 20:18:00323You can debug multi-process chrome using `rr -f [PID]`
Steve Kobes8ce3e44d2022-01-28 22:36:59324for processes `fork()`ed from a [zygote process](zygote.md) without exec,
325which includes renderer processes,
326or `rr -p [PID]` for other processes.
327To find the process id you can either run `rr ps` after recording, or for
328renderer processes use `--vmodule=render_frame_impl=1` which will log a
329message on navigations. Example:
Robert Flacke13e0b12020-04-16 17:03:58330
331```
Steve Kobes8ce3e44d2022-01-28 22:36:59332$ rr record out/Debug/content_shell --disable-hang-monitor --vmodule=render_frame_impl=1 https://www.google.com/
Robert Flacke13e0b12020-04-16 17:03:58333rr: Saving execution to trace directory `...'.
334...
335[128515:128515:0320/164124.768687:VERBOSE1:render_frame_impl.cc(4244)] Committed provisional load: https://www.google.com/
336```
337
338From the log message we can see that the site was loaded into process 128515
339and can set a breakpoint for when that process is forked.
340
341```
342rr replay -f 128515
343```
344
L. David Barone99d91eb2021-03-30 20:18:00345If you want to call debugging functions from gdb that use `LOG()`,
Steve Kobes8ce3e44d2022-01-28 22:36:59346then those functions need to disable the printing of timestamps using
347[`SetLogItems`](https://source.chromium.org/search?q=SetLogItems&sq=&ss=chromium%2Fchromium%2Fsrc).
348See `LayoutObject::ShowLayoutObject()` for an example of this, and
349[issue 2829](https://github.com/rr-debugger/rr/issues/2829) for why it is needed.
L. David Barone99d91eb2021-03-30 20:18:00350
Steve Kobes8ce3e44d2022-01-28 22:36:59351If rr doesn't work correctly, the rr developers are generally quite responsive
352to [bug reports](https://github.com/rr-debugger/rr/issues),
L. David Barone99d91eb2021-03-30 20:18:00353especially ones that have enough information so that
354they don't have to build Chromium.
355
356See Also:
Steve Kobes8ce3e44d2022-01-28 22:36:59357
L. David Barone99d91eb2021-03-30 20:18:00358* [The Chromium Chronicle #13: Time-Travel Debugging with RR](https://developer.chrome.com/blog/chromium-chronicle-13/)
Steve Kobes8ce3e44d2022-01-28 22:36:59359* [@davidbaron demo using rr](https://twitter.com/davidbaron/status/1473761042278887433)
360* [@davidbaron demo using pernosco](https://twitter.com/davidbaron/status/1475836824409022469)
361(Googlers: see [go/pernosco](https://goto.google.com/pernosco))
L. David Barone99d91eb2021-03-30 20:18:00362
andybons3322f762015-08-24 21:37:09363### Graphical Debugging Aid for Chromium Views
364
365The following link describes a tool that can be used on Linux, Windows and Mac under GDB.
366
sisidovskif270241c2021-08-04 07:07:44367[graphical_debugging_aid_chromium_views](../graphical_debugging_aid_chromium_views.md)
andybons3322f762015-08-24 21:37:09368
369### Faster startup
370
andybonsad92aa32015-08-31 02:27:44371Use the `gdb-add-index` script (e.g.
372`build/gdb-add-index out/Debug/browser_tests`)
andybons3322f762015-08-24 21:37:09373
andybonsad92aa32015-08-31 02:27:44374Only makes sense if you run the binary multiple times or maybe if you use the
nodira6074d4c2015-09-01 04:26:45375component build since most `.so` files won't require reindexing on a rebuild.
andybons3322f762015-08-24 21:37:09376
andybonsad92aa32015-08-31 02:27:44377See
378https://groups.google.com/a/chromium.org/forum/#!searchin/chromium-dev/gdb-add-index/chromium-dev/ELRuj1BDCL4/5Ki4LGx41CcJ
379for more info.
andybons3322f762015-08-24 21:37:09380
Takuto Ikutaa093dc22020-11-11 03:17:50381You can improve GDB load time significantly at the cost of link time by not
brettw20d800c2016-04-12 00:10:49382splitting symbols from the object files. In GN, set `use_debug_fission=false` in
383your "gn args".
andybons3322f762015-08-24 21:37:09384
Tom Anderson71df8872018-06-21 19:02:25385### Source level debug with -fdebug-compilation-dir
Takuto Ikuta3ae0e03b2018-05-18 06:10:40386
Nico Weber8940a782018-10-22 23:28:28387When `strip_absolute_paths_from_debug_symbols` is enabled (which is the
Tom Andersonf06ac382019-04-10 03:49:38388default), gdb may not be able to find debug files, making source-level debugging
389impossible. See
John Palmer046f9872021-05-24 01:24:56390[gdbinit](https://chromium.googlesource.com/chromium/src/+/main/docs/gdbinit.md)
Tom Andersonf06ac382019-04-10 03:49:38391to configure gdb to be able to find debug files.
Takuto Ikuta3ae0e03b2018-05-18 06:10:40392
andybons3322f762015-08-24 21:37:09393## Core files
andybons3322f762015-08-24 21:37:09394
andybonsad92aa32015-08-31 02:27:44395`ulimit -c unlimited` should cause all Chrome processes (run from that shell) to
396dump cores, with the possible exception of some sandboxed processes.
andybons3322f762015-08-24 21:37:09397
andybonsad92aa32015-08-31 02:27:44398Some sandboxed subprocesses might not dump cores unless you pass the
399`--allow-sandbox-debugging` flag.
400
401If the problem is a freeze rather than a crash, you may be able to trigger a
402core-dump by sending SIGABRT to the relevant process:
403
404 kill -6 [process id]
andybons3322f762015-08-24 21:37:09405
406## Breakpad minidump files
407
Tom Andersonabdbd6a2020-01-09 16:59:27408See [minidump_to_core.md](minidump_to_core.md)
andybons3322f762015-08-24 21:37:09409
410## Running Tests
andybonsad92aa32015-08-31 02:27:44411
412Many of our tests bring up windows on screen. This can be annoying (they steal
413your focus) and hard to debug (they receive extra events as you mouse over them).
414Instead, use `Xvfb` or `Xephyr` to run a nested X session to debug them, as
sisidovskif270241c2021-08-04 07:07:44415outlined on [testing/web_tests_linux.md](../testing/web_tests_linux.md).
andybons3322f762015-08-24 21:37:09416### Browser tests
andybonsad92aa32015-08-31 02:27:44417
418By default the `browser_tests` forks a new browser for each test. To debug the
419browser side of a single test, use a command like
420
andybons3322f762015-08-24 21:37:09421```
Thomas Lukaszewicz2c5fb6142019-10-14 19:20:05422gdb --args out/Debug/browser_tests --single-process-tests --gtest_filter=MyTestName
andybons3322f762015-08-24 21:37:09423```
andybonsad92aa32015-08-31 02:27:44424
Thomas Lukaszewicz2c5fb6142019-10-14 19:20:05425**note the use of `single-process-tests`** -- this makes the test harness and
andybonsad92aa32015-08-31 02:27:44426browser process share the outermost process.
andybons3322f762015-08-24 21:37:09427
428
429To debug a renderer process in this case, use the tips above about renderers.
430
Kent Tamura59ffb022018-11-27 05:30:56431### Web tests
andybonsad92aa32015-08-31 02:27:44432
sisidovskif270241c2021-08-04 07:07:44433See [testing/web_tests_linux.md](../testing/web_tests_linux.md) for some tips. In particular,
Kent Tamura59ffb022018-11-27 05:30:56434note that it's possible to debug a web test via `ssh`ing to a Linux box; you
andybonsad92aa32015-08-31 02:27:44435don't need anything on screen if you use `Xvfb`.
andybons3322f762015-08-24 21:37:09436
437### UI tests
andybons3322f762015-08-24 21:37:09438
andybonsad92aa32015-08-31 02:27:44439UI tests are run in forked browsers. Unlike browser tests, you cannot do any
440single process tricks here to debug the browser. See below about
441`BROWSER_WRAPPER`.
442
443To pass flags to the browser, use a command line like
444`--extra-chrome-flags="--foo --bar"`.
andybons3322f762015-08-24 21:37:09445
446### Timeouts
andybonsad92aa32015-08-31 02:27:44447
448UI tests have a confusing array of timeouts in place. (Pawel is working on
449reducing the number of timeouts.) To disable them while you debug, set the
450timeout flags to a large value:
451
452* `--test-timeout=100000000`
453* `--ui-test-action-timeout=100000000`
454* `--ui-test-terminate-timeout=100000000`
andybons3322f762015-08-24 21:37:09455
456### To replicate Window Manager setup on the bots
andybonsad92aa32015-08-31 02:27:44457
458Chromium try bots and main waterfall's bots run tests under Xvfb&openbox
459combination. Xvfb is an X11 server that redirects the graphical output to the
460memory, and openbox is a simple window manager that is running on top of Xvfb.
461The behavior of openbox is markedly different when it comes to focus management
462and other window tasks, so test that runs fine locally may fail or be flaky on
463try bots. To run the tests on a local machine as on a bot, follow these steps:
andybons3322f762015-08-24 21:37:09464
465Make sure you have openbox:
andybonsad92aa32015-08-31 02:27:44466
467 apt-get install openbox
468
andybons3322f762015-08-24 21:37:09469Start Xvfb and openbox on a particular display:
andybonsad92aa32015-08-31 02:27:44470
471 Xvfb :6.0 -screen 0 1280x1024x24 & DISPLAY=:6.0 openbox &
472
andybons3322f762015-08-24 21:37:09473Run your tests with graphics output redirected to that display:
andybonsad92aa32015-08-31 02:27:44474
475 DISPLAY=:6.0 out/Debug/browser_tests --gtest_filter="MyBrowserTest.MyActivateWindowTest"
476
andybons3322f762015-08-24 21:37:09477You can look at a snapshot of the output by:
andybonsad92aa32015-08-31 02:27:44478
479 xwd -display :6.0 -root | xwud
andybons3322f762015-08-24 21:37:09480
481Alternatively, you can use testing/xvfb.py to set up your environment for you:
andybons3322f762015-08-24 21:37:09482
thomasanderson3d074282016-12-06 18:21:12483 testing/xvfb.py out/Debug/browser_tests \
andybonsad92aa32015-08-31 02:27:44484 --gtest_filter="MyBrowserTest.MyActivateWindowTest"
andybons3322f762015-08-24 21:37:09485
nodira6074d4c2015-09-01 04:26:45486### BROWSER_WRAPPER
andybonsad92aa32015-08-31 02:27:44487
488You can also get the browser under a debugger by setting the `BROWSER_WRAPPER`
489environment variable. (You can use this for `browser_tests` too, but see above
490for discussion of a simpler way.)
491
492 BROWSER_WRAPPER='xterm -e gdb --args' out/Debug/browser_tests
andybons3322f762015-08-24 21:37:09493
qyearsleyc0dc6f42016-12-02 22:13:39494### Replicating try bot Slowness
andybons3322f762015-08-24 21:37:09495
qyearsleyc0dc6f42016-12-02 22:13:39496Try bots are pretty stressed, and can sometimes expose timing issues you can't
andybonsad92aa32015-08-31 02:27:44497normally reproduce locally.
andybons3322f762015-08-24 21:37:09498
andybonsad92aa32015-08-31 02:27:44499You can simulate this by shutting down all but one of the CPUs
500(http://www.cyberciti.biz/faq/debian-rhel-centos-redhat-suse-hotplug-cpu/) and
501running a CPU loading tool (e.g., http://www.devin.com/lookbusy/). Now run your
qyearsleyc0dc6f42016-12-02 22:13:39502test. It will run slowly, but any flakiness found by the try bot should replicate
andybonsad92aa32015-08-31 02:27:44503locally now - and often nearly 100% of the time.
andybons3322f762015-08-24 21:37:09504
505## Logging
andybons3322f762015-08-24 21:37:09506
andybonsad92aa32015-08-31 02:27:44507### Seeing all LOG(foo) messages
508
509Default log level hides `LOG(INFO)`. Run with `--log-level=0` and
510`--enable-logging=stderr` flags.
511
qyearsleyc0dc6f42016-12-02 22:13:39512Newer versions of Chromium with VLOG may need --v=1 too. For more VLOG tips, see
xiaoyin.l1003c0b2016-12-06 02:51:17513[the chromium-dev thread](https://groups.google.com/a/chromium.org/group/chromium-dev/browse_thread/thread/dcd0cd7752b35de6?pli=1).
andybons3322f762015-08-24 21:37:09514
515### Seeing IPC debug messages
andybons3322f762015-08-24 21:37:09516
andybonsad92aa32015-08-31 02:27:44517Run with `CHROME_IPC_LOGGING=1` eg.
518
519 CHROME_IPC_LOGGING=1 out/Debug/chrome
520
521or within gdb:
522
523 set environment CHROME_IPC_LOGGING 1
524
525If some messages show as unknown, check if the list of IPC message headers in
nodira6074d4c2015-09-01 04:26:45526[chrome/common/logging_chrome.cc](/chrome/common/logging_chrome.cc) is
thakis3e861de2016-06-14 14:24:01527up to date. In case this file reference goes out of date, try looking for usage
nodira6074d4c2015-09-01 04:26:45528of macros like `IPC_MESSAGE_LOG_ENABLED` or `IPC_MESSAGE_MACROS_LOG_ENABLED`.
andybons3322f762015-08-24 21:37:09529
andybons3322f762015-08-24 21:37:09530## Profiling
andybonsad92aa32015-08-31 02:27:44531
532See
533https://sites.google.com/a/chromium.org/dev/developers/profiling-chromium-and-webkit
Tom Anderson93e49e492019-12-23 19:55:37534and [Linux Profiling](profiling.md).
andybons3322f762015-08-24 21:37:09535
536## i18n
andybons3322f762015-08-24 21:37:09537
andybonsad92aa32015-08-31 02:27:44538We obey your system locale. Try something like:
andybons3322f762015-08-24 21:37:09539
andybonsad92aa32015-08-31 02:27:44540 LANG=ja_JP.UTF-8 out/Debug/chrome
541
542If this doesn't work, make sure that the `LANGUAGE`, `LC_ALL` and `LC_MESSAGE`
543environment variables aren't set -- they have higher priority than LANG in the
544order listed. Alternatively, just do this:
545
546 LANGUAGE=fr out/Debug/chrome
547
548Note that because we use GTK, some locale data comes from the system -- for
549example, file save boxes and whether the current language is considered RTL.
550Without all the language data available, Chrome will use a mixture of your
551system language and the language you run Chrome in.
andybons3322f762015-08-24 21:37:09552
553Here's how to install the Arabic (ar) and Hebrew (he) language packs:
andybonsad92aa32015-08-31 02:27:44554
555 sudo apt-get install language-pack-ar language-pack-he \
556 language-pack-gnome-ar language-pack-gnome-he
557
andybons3322f762015-08-24 21:37:09558Note that the `--lang` flag does **not** work properly for this.
559
Tom Anderson287339e2018-08-22 21:52:02560On non-Debian systems, you need the `gtk30.mo` files. (Please update these docs
andybonsad92aa32015-08-31 02:27:44561with the appropriate instructions if you know what they are.)
andybons3322f762015-08-24 21:37:09562
563## Breakpad
andybonsad92aa32015-08-31 02:27:44564
Tom Anderson93e49e492019-12-23 19:55:37565See the last section of [Linux Crash Dumping](crash_dumping.md).
andybons3322f762015-08-24 21:37:09566
567## Drag and Drop
andybonsad92aa32015-08-31 02:27:44568
569If you break in a debugger during a drag, Chrome will have grabbed your mouse
570and keyboard so you won't be able to interact with the debugger! To work around
571this, run via `Xephyr`. Instructions for how to use `Xephyr` are on the
sisidovskif270241c2021-08-04 07:07:44572[Running web tests on Linux](../testing/web_tests_linux.md) page.
andybons3322f762015-08-24 21:37:09573
574## Tracking Down Bugs
575
576### Isolating Regressions
andybons3322f762015-08-24 21:37:09577
andybonsad92aa32015-08-31 02:27:44578Old builds are archived here:
xiaoyin.l1003c0b2016-12-06 02:51:17579https://build.chromium.org/buildbot/snapshots/chromium-rel-linux/
nodira6074d4c2015-09-01 04:26:45580(TODO: does not exist).
andybonsad92aa32015-08-31 02:27:44581
582`tools/bisect-builds.py` in the tree automates bisecting through the archived
583builds. Despite a computer science education, I am still amazed how quickly
584binary search will find its target.
andybons3322f762015-08-24 21:37:09585
586### Screen recording for bug reports
andybonsad92aa32015-08-31 02:27:44587
588 sudo apt-get install gtk-recordmydesktop
andybons3322f762015-08-24 21:37:09589
590## Version-specific issues
591
592### Google Chrome
andybonsad92aa32015-08-31 02:27:44593
594Google Chrome binaries don't include symbols. Googlers can read where to get
595symbols from
596[the Google-internal wiki](http://wiki/Main/ChromeOfficialBuildLinux#The_Build_Archive).
andybons3322f762015-08-24 21:37:09597
598### Ubuntu Chromium
andybonsad92aa32015-08-31 02:27:44599
600Since we don't build the Ubuntu packages (Ubuntu does) we can't get useful
601backtraces from them. Direct users to https://wiki.ubuntu.com/Chromium/Debugging
andybons3322f762015-08-24 21:37:09602
603### Fedora's Chromium
andybonsad92aa32015-08-31 02:27:44604
605Like Ubuntu, but direct users to
606https://fedoraproject.org/wiki/TomCallaway/Chromium_Debug
andybons3322f762015-08-24 21:37:09607
608### Xlib
andybonsad92aa32015-08-31 02:27:44609
andybons3322f762015-08-24 21:37:09610If you're trying to track down X errors like:
andybonsad92aa32015-08-31 02:27:44611
andybons3322f762015-08-24 21:37:09612```
613The program 'chrome' received an X Window System error.
614This probably reflects a bug in the program.
615The error was 'BadDrawable (invalid Pixmap or Window parameter)'.
616```
andybonsad92aa32015-08-31 02:27:44617
andybons3322f762015-08-24 21:37:09618Some strategies are:
andybonsad92aa32015-08-31 02:27:44619
620* pass `--sync` on the command line to make all X calls synchronous
621* run chrome via [xtrace](http://xtrace.alioth.debian.org/)
622* turn on IPC debugging (see above section)
andybons3322f762015-08-24 21:37:09623
624### Window Managers
andybons3322f762015-08-24 21:37:09625
andybonsad92aa32015-08-31 02:27:44626To test on various window managers, you can use a nested X server like `Xephyr`.
627Instructions for how to use `Xephyr` are on the
sisidovskif270241c2021-08-04 07:07:44628[Running web tests on Linux](../testing/web_tests_linux.md) page.
andybonsad92aa32015-08-31 02:27:44629
630If you need to test something with hardware accelerated compositing
631(e.g., compiz), you can use `Xgl` (`sudo apt-get install xserver-xgl`). E.g.:
632
633 Xgl :1 -ac -accel glx:pbuffer -accel xv:pbuffer -screen 1024x768
634
andybons3322f762015-08-24 21:37:09635## Mozilla Tips
andybonsad92aa32015-08-31 02:27:44636
637https://developer.mozilla.org/en/Debugging_Mozilla_on_Linux_FAQ
Joshua Pawlickic2464187d2022-02-23 14:27:51638
639## Google Chrome Symbol Files
640
641Symbols for Google Chrome's official builds are available from
642`https://edgedl.me.gvt1.com/chrome/linux/symbols/google-chrome-debug-info-linux64-${VERSION}.zip`
643where ${VERSION} is any version of Google Chrome that has recently been served
Robert Flackcdbf8c4a2022-11-18 18:12:34644to Stable, Beta, or Unstable (Dev) channels on Linux.