Movatterモバイル変換


[0]ホーム

URL:


Google Git
Sign in
chromium /chromium /src /refs/heads/main /. /docs /linux /debugging.md
blob: 72530aa39a0b91c7e1c1e352bab604d8306b7fc6 [file] [log] [blame] [view]
andybonse6a8f2bd2015-08-31 22:46:01[diff] [blame]1# Tips for debugging on Linux
andybons3322f762015-08-24 21:37:09[diff] [blame]2
andybonsad92aa32015-08-31 02:27:44[diff] [blame]3This pageisforChromium-specific debugging tips; learning how to run gdbis
4out of scope.
andybons3322f762015-08-24 21:37:09[diff] [blame]5
andybonsad92aa32015-08-31 02:27:44[diff] [blame]6[TOC]
andybons3322f762015-08-24 21:37:09[diff] [blame]7
8## Symbolized stack trace
9
andybonsad92aa32015-08-31 02:27:44[diff] [blame]10The sandbox can interferewith theinternal symbolizer.Use`--no-sandbox`(but
11keepthis temporary)or an external symbolizer(see
12`tools/valgrind/asan/asan_symbolize.py`).
andybons3322f762015-08-24 21:37:09[diff] [blame]13
andybonsad92aa32015-08-31 02:27:44[diff] [blame]14Generally,donotuse`--no-sandbox` on waterfall bots, sandbox testingis
15needed.Talk to security@chromium.org.
andybons3322f762015-08-24 21:37:09[diff] [blame]16
17## GDB
andybonsad92aa32015-08-31 02:27:44[diff] [blame]18
nodira6074d4c2015-09-01 04:26:45[diff] [blame]19*** promo
20GDB-7.7is requiredin order to debugChrome onLinux.
21***
andybons3322f762015-08-24 21:37:09[diff] [blame]22
23Any prior version will fail to resolve symbolsor segfault.
24
Brett Wilson41a7de02023-04-27 18:56:54[diff] [blame]25### Setup
26
27#### Build setup
28
29In your buildset the GN build variable`symbol_level = 2`for interactive
30debugging.(`symbol_level = 1` only provides backtrace information).Andwhile
31release-mode debuggingis possible, things will be much easierin a debug build.
32Set your build argswith`gn args out/<your_dir>`(substituting your build
33directory),andset:
34
35```
36is_debug = true
37symbol_level = 2
38```
39
40#### GDB setup
41
42TheChrome build requires some GDB configurationfor it to be able to find
Taiyo Mizuhashid0f90c9d2023-05-31 00:55:23[diff] [blame]43source files.See[gdbinit](../gdbinit.md) to configure GDB.Thereis a similar
44processfor[LLDB](../lldbinit.md).
Brett Wilson41a7de02023-04-27 18:56:54[diff] [blame]45
andybons3322f762015-08-24 21:37:09[diff] [blame]46### Basic browser process debugging
47
andybonsad92aa32015-08-31 02:27:44[diff] [blame]48 gdb-tui-ex=r--argsout/Debug/chrome--disable-seccomp-sandbox \
49 http://google.com
andybons3322f762015-08-24 21:37:09[diff] [blame]50
51### Allowing attaching to foreign processes
andybonsad92aa32015-08-31 02:27:44[diff] [blame]52
53On distributions thatuse the
54[Yama LSM](https://www.kernel.org/doc/Documentation/security/Yama.txt) (that
55includesUbuntuandChrome OS), process A can attach to process B onlyif Ais
56an ancestor of B.
andybons3322f762015-08-24 21:37:09[diff] [blame]57
58You will probably want to disablethis featurebyusing
andybonsad92aa32015-08-31 02:27:44[diff] [blame]59
60 echo0| sudo tee/proc/sys/kernel/yama/ptrace_scope
andybons3322f762015-08-24 21:37:09[diff] [blame]61
62If you don't you'llget an error message suchas"Could not attach to process".
63
andybonsad92aa32015-08-31 02:27:44[diff] [blame]64Note that you'll also probably want to use `--no-sandbox`, as explained below.
andybons3322f762015-08-24 21:37:09[diff] [blame]65
66### Multiprocess Tricks
andybonsad92aa32015-08-31 02:27:44[diff] [blame]67
andybons3322f762015-08-24 21:37:09[diff] [blame]68#### Getting renderer subprocesses into gdb
andybonsad92aa32015-08-31 02:27:44[diff] [blame]69
70Since Chromium itself spawns the renderers, it can be tricky to grab a
71particular with gdb. This command does the trick:
72
andybons3322f762015-08-24 21:37:09[diff] [blame]73```
74chrome --no-sandbox --renderer-cmd-prefix='xterm-title renderer-e gdb--args'
75```
andybonsad92aa32015-08-31 02:27:44[diff] [blame]76
77The `--no-sandbox` flag is needed because otherwise the seccomp sandbox will
78kill the renderer process on startup, or the setuid sandbox will prevent xterm's
79execution.The"xterm"is necessaryor gdb will runin the current terminal,
80which canget particularly confusing since it's running in the background, and
81if you're also running the main processin gdb, won't work at all (the two
82instances will fight over the terminal). To auto-start the renderers in the
83debugger, send the "run" command to the debugger:
84
nodira6074d4c2015-09-01 04:26:45[diff] [blame]85 chrome --no-sandbox --renderer-cmd-prefix='xterm-title renderer-e gdb \
Zhang Haoa95224882021-05-12 11:26:36[diff] [blame]86-ex run--args'
andybonsad92aa32015-08-31 02:27:44[diff] [blame]87
andybons3322f762015-08-24 21:37:09[diff] [blame]88If you'reusingEmacsand`M-x gdb`, you cando
andybons3322f762015-08-24 21:37:09[diff] [blame]89
andybonsad92aa32015-08-31 02:27:44[diff] [blame]90 chrome"--renderer-cmd-prefix=gdb --args"
andybons3322f762015-08-24 21:37:09[diff] [blame]91
nodira6074d4c2015-09-01 04:26:45[diff] [blame]92*** note
andybonsad92aa32015-08-31 02:27:44[diff] [blame]93Note:using the`--renderer-cmd-prefix` option bypasses the zygote launcher, so
94the renderers won't be sandboxed. It is generally not an issue, except when you
95are trying to debug interactions with the sandbox. If that's what you are doing,
96you will need to attach yourdebugger to a running renderer process(see below).
nodira6074d4c2015-09-01 04:26:45[diff] [blame]97***
andybons3322f762015-08-24 21:37:09[diff] [blame]98
andybonsad92aa32015-08-31 02:27:44[diff] [blame]99You may also want topass`--disable-hang-monitor` to suppress the hang monitor,
100whichis rather annoying.
101
102You can alsouse`--renderer-startup-dialog`and attach to the processin order
103to debug the renderer code.Go to
xiaoyin.l1003c0b2016-12-06 02:51:17[diff] [blame]104https://www.chromium.org/blink/getting-started-with-blink-debugging for more
andybonsad92aa32015-08-31 02:27:44[diff] [blame]105information on howthis can bedone.
andybons3322f762015-08-24 21:37:09[diff] [blame]106
Alex Gough20926742021-05-13 20:11:30[diff] [blame]107For utilities you canuse`--utility-startup-dialog` to have all utilities
108prompt,or`--utility-startup-dialog=data_decoder.mojom.DataDecoderService`
109to debug only a particular service type.
110
andybons3322f762015-08-24 21:37:09[diff] [blame]111#### Choosing which renderers to debug
andybons3322f762015-08-24 21:37:09[diff] [blame]112
andybonsad92aa32015-08-31 02:27:44[diff] [blame]113If you are starting multiple renderersthen the above means that multiple gdb's
114start and fight over the console. Instead, you can set the prefix to point to
115this shell script:
116
117```sh
andybons3322f762015-08-24 21:37:09[diff] [blame]118#!/bin/sh
119
120echo "**** Child $$ starting: y to debug"
121read input
122if [ "$input" = "y" ] ; then
123 gdb --args $*
124else
125 $*
126fi
127```
128
Robert Flackcdbf8c4a2022-11-18 18:12:34[diff] [blame]129#### Choosing renderer to debug by URL
130
131In most cases you'll want to debug the renderer whichis loading a particular
132site.If you want a script which will automatically debug the renderer which has
133visited a given target URLandcontinue all other renderers, you canuse the
134following:
135
136```sh
137./third_party/blink/tools/debug_renderer out/Default/content_shell https://example.domain/path
138```
139
140The script also supports specifying a different URL than the navigation URL.
141Thisis usefulwhen the renderer you want to debugisnot the top frame but one
142of the subframes on the page.For example, you could debug a particular subframe
143on a pagewith:
144
145```sh
146./third_party/blink/tools/debug_renderer -d https://subframe.url/path out/Default/content_shell https://example.domain/path
147```
148
149However,if you need more fine-grained control over which renderers to debug
150you can run chromeor content_shell directlywith the
151`--wait-for-debugger-on-navigation` flag which will pause each renderer at the
152point of navigation(when the URLis known).
153
154This will resultin a series of lines suchas the followingin the output:
155```
156...:content_switches_internal.cc(119)] Renderer url="https://example.domain/path" (PID) paused waiting for debugger to attach. Send SIGUSR1 to unpause.
157```
158
159You can signal the renderers you aren't interested in to continue running with:
160```sh
161kill -s SIGUSR1 <pid>
162```
163
164And debug the renderer you are interested in debugging with:
165```sh
166gdb -p <pid>
167```
168
Robert Flack6bbefe72023-02-24 18:49:51[diff] [blame]169#### Debugging run_web_tests.py renderers
170
171The `debug_renderer` script can also be used to debug the renderer running
Jonathan Leee95877f2023-09-26 21:16:30[diff] [blame]172a web test. To do so, simply call `run_{web,wpt}_tests.py` from `debug_renderer`
173with all of the standard arguments for `run_{web,wpt}_tests.py`. For example:
Robert Flack6bbefe72023-02-24 18:49:51[diff] [blame]174
175```sh
176./third_party/blink/tools/debug_renderer ./third_party/blink/tools/run_web_tests.py [run_web_test args]
177```
178
andybons3322f762015-08-24 21:37:09[diff] [blame]179#### Selective breakpoints
andybonsad92aa32015-08-31 02:27:44[diff] [blame]180
181When debugging both the browser and renderer process, you might want to have
182separate set of breakpoints to hit. You can use gdb's command files to
183accomplishthisby putting breakpointsin separate filesand instructing gdb to
184load them.
andybons3322f762015-08-24 21:37:09[diff] [blame]185
186```
andybonsad92aa32015-08-31 02:27:44[diff] [blame]187gdb -x ~/debug/browser --args chrome --no-sandbox --disable-hang-monitor \
188 --renderer-cmd-prefix='xterm -title renderer -e gdb -x ~/debug/renderer \
189 --args '
andybons3322f762015-08-24 21:37:09[diff] [blame]190```
191
andybonsad92aa32015-08-31 02:27:44[diff] [blame]192Also, instead of running gdb, you canuse the script above, whichlet's you
193select which renderer process to debug. Note: you might need to use the full
194path to the script and avoid `$HOME` or `~/.`
andybons3322f762015-08-24 21:37:09[diff] [blame]195
196#### Connecting to a running renderer
197
andybonsad92aa32015-08-31 02:27:44[diff] [blame]198Usually `ps aux | grep chrome` will not give very helpful output. Try
199`pstree -p | grep chrome` to get something like
andybons3322f762015-08-24 21:37:09[diff] [blame]200
201```
202 | |-bash(21969)---chrome(672)-+-chrome(694)
203 | | |-chrome(695)---chrome(696)-+-{chrome}(697)
204 | | | \-{chrome}(709)
205 | | |-{chrome}(675)
206 | | |-{chrome}(678)
207 | | |-{chrome}(679)
208 | | |-{chrome}(680)
209 | | |-{chrome}(681)
210 | | |-{chrome}(682)
211 | | |-{chrome}(684)
212 | | |-{chrome}(685)
213 | | |-{chrome}(705)
214 | | \-{chrome}(717)
215```
216
andybonsad92aa32015-08-31 02:27:44[diff] [blame]217Most of those are threads. In this case the browser process would be 672 and the
218(sole) renderer process is 696. You can use `gdb -p 696` to attach.
219Alternatively, you might find out the process ID from Chrome's built-inTask
220Manager(under theTools menu).Right-click on theTaskManager,and enable
221"Process ID"in the list of columns.
andybons3322f762015-08-24 21:37:09[diff] [blame]222
andybonsad92aa32015-08-31 02:27:44[diff] [blame]223Note:bydefault, sandboxed processes can't be attached by a debugger. To be
224able to do so, you will need to pass the `--allow-sandbox-debugging` option.
andybons3322f762015-08-24 21:37:09[diff] [blame]225
andybonsad92aa32015-08-31 02:27:44[diff] [blame]226If the problem only occurs with the seccomp sandbox enabled (and the previous
227tricks don't help), you couldtry enabling core-dumps(see the**Core files**
228section).That would allow you toget a backtraceand see somelocal variables,
229though you won't be able to step through the running program.
andybons3322f762015-08-24 21:37:09[diff] [blame]230
andybonsad92aa32015-08-31 02:27:44[diff] [blame]231Note: If you're interestedin debuggingLinuxSandboxIPC process, you can attach
232to694in the above diagram.TheLinuxSandboxIPC process has the same command
233line flagas the browser process so that it's easy to identify it if you run
234`pstree -pa`.
andybons3322f762015-08-24 21:37:09[diff] [blame]235
236#### Getting GPU subprocesses into gdb
andybons3322f762015-08-24 21:37:09[diff] [blame]237
andybonsad92aa32015-08-31 02:27:44[diff] [blame]238Use `--gpu-launcher` flag instead of `--renderer-cmd-prefix` in the instructions
239for renderer above.
240
241#### Getting `browser_tests` launched browsers into gdb
242
243Use environment variable `BROWSER_WRAPPER` instead of `--renderer-cmd-prefix`
244switch in the instructions above.
andybons3322f762015-08-24 21:37:09[diff] [blame]245
246Example:
andybonsad92aa32015-08-31 02:27:44[diff] [blame]247
248```shell
249BROWSER_WRAPPER='xterm-title renderer-e gdb--eval-command=run \
250--eval-command=quit--args' out/Debug/browser_tests --gtest_filter=Print
251```
andybons3322f762015-08-24 21:37:09[diff] [blame]252
253#### Plugin Processes
andybons3322f762015-08-24 21:37:09[diff] [blame]254
andybonsad92aa32015-08-31 02:27:44[diff] [blame]255Same strategies as renderers above, but the flag is called `--plugin-launcher`:
256
257 chrome --plugin-launcher='xterm-e gdb--args'
258
nodira6074d4c2015-09-01 04:26:45[diff] [blame]259*** note
260Note: For now, this does not currently apply to PPAPI plugins because they
261currently run in the renderer process.
262***
andybons3322f762015-08-24 21:37:09[diff] [blame]263
264#### Single-Process mode
andybons3322f762015-08-24 21:37:09[diff] [blame]265
andybonsad92aa32015-08-31 02:27:44[diff] [blame]266Depending on whether it's relevant to the problem, it's often easier to just run
267in "single process" mode where the renderer threads are in-process. Then you can
268just run gdb on the main process.
andybons3322f762015-08-24 21:37:09[diff] [blame]269
andybonsad92aa32015-08-31 02:27:44[diff] [blame]270 gdb --args chrome --single-process
271
272Currently, the `--disable-gpu` flag is also required, as there are known crashes
273that occur under TextureImageTransportSurface without it. The crash described in
xiaoyin.l1003c0b2016-12-06 02:51:17[diff] [blame]274https://crbug.com/361689 can also sometimes occur, but that crash can be
andybonsad92aa32015-08-31 02:27:44[diff] [blame]275continued from without harm.
276
277Note that for technical reasons plugins cannot be in-process, so
278`--single-process` only puts the renderers in the browser process. The flag is
279still useful for debugging plugins (since it's only two processes instead of
280three) but you'll still need to use `--plugin-launcher` or another approach.
andybons3322f762015-08-24 21:37:09[diff] [blame]281
282### Printing Chromium types
andybons3322f762015-08-24 21:37:09[diff] [blame]283
Tom Andersonf06ac382019-04-10 03:49:38[diff] [blame]284gdb 7 lets us use Python to write pretty-printers for Chromium types. See
Taiyo Mizuhashid0f90c9d2023-05-31 00:55:23[diff] [blame]285[gdbinit](../gdbinit.md)
Tom Andersonf06ac382019-04-10 03:49:38[diff] [blame]286to enable pretty-printing of Chromium types. This will import Blink
287pretty-printers as well.
Kenichi Ishibashie17b8d9f2018-04-26 03:32:46[diff] [blame]288
andybonsad92aa32015-08-31 02:27:44[diff] [blame]289Pretty printers for std types shouldn't be necessaryin gdb7, but they're
290provided here in case you'reusing an older gdb.Put the followinginto
291`~/.gdbinit`:
292
andybons3322f762015-08-24 21:37:09[diff] [blame]293```
294# Print a C++ string.
295define ps
296 print $arg0.c_str()
297end
298
299# Print a C++ wstring or wchar_t*.
300define pws
301 printf "\""
302 set $c = (wchar_t*)$arg0
303 while ( *$c )
304 if ( *$c > 0x7f )
305 printf "[%x]", *$c
306 else
307 printf "%c", *$c
308 end
309 set $c++
310 end
311 printf "\"\n"
312end
313```
314
315[More STL GDB macros](http://www.yolinux.com/TUTORIALS/src/dbinit_stl_views-1.01.txt)
316
Christian Biesinger3332bb3a2019-08-13 05:45:23[diff] [blame]317### JsDbg -- visualize data structures in the browser
318
319JsDbgis adebugger plugin to display variousChrome data structuresin a
320browser window, suchas the accessibility tree, layoutobject tree, DOM tree,
321and others.
322[Installation instructions are here](https://github.com/MicrosoftEdge/JsDbg),
323and see[here](https://github.com/MicrosoftEdge/JsDbg/blob/master/docs/FEATURES.md)
324for screenshotsand an introduction.
325
326ForGooglers, please see[go/jsdbg](https://goto.google.com/jsdbg) for
327installation instructions.
328
329### Time travel debugging with rr
330
331You canuse[rr](https://rr-project.org) for time travel debugging, so you
332can also stepor execute backwards.This worksby first recording a trace
L. David Barone99d91eb2021-03-30 20:18:00[diff] [blame]333andthen debugging based on that.
Christian Biesinger3332bb3a2019-08-13 05:45:23[diff] [blame]334
Jie Sheng01180e62025-03-29 03:48:01[diff] [blame]335ForGooglers,if you have a remote cloud machine, please followthis
336[instruction](https://engdoc.corp.google.com/eng/doc/devguide/debugging/rr.md#setting-up-rr)
337toset up the machinein order touse the rr tool.
338
Steve Kobes8ce3e44d2022-01-28 22:36:59[diff] [blame]339You need an up-to-date version of rr, since rris frequently updated to support
340new parts of theLinux system call API surface thatChromium uses.If you have
341any issueswith the latest release version,try compiling rr
L. David Barone99d91eb2021-03-30 20:18:00[diff] [blame]342[from source](https://github.com/rr-debugger/rr/wiki/Building-And-Installing).
Robert Flackc9e69952020-05-13 19:52:31[diff] [blame]343
Christian Biesinger3332bb3a2019-08-13 05:45:23[diff] [blame]344Once installed, you canuse it likethis:
345```
Steve Kobes8ce3e44d2022-01-28 22:36:59[diff] [blame]346rr record out/Debug/content_shell --single-process
Christian Biesinger3332bb3a2019-08-13 05:45:23[diff] [blame]347rr replay
Steve Kobes8ce3e44d2022-01-28 22:36:59[diff] [blame]348(rr) c
349(rr) break blink::NGBlockNode::Layout
350(rr) rc # reverse-continue to the last Layout call
351(rr) jsdbg # run JsDbg as described above to find the interesting object
352(rr) watch -l box_->frame_rect_.size_.width_.value_
353(rr) rc # reverse-continue to the last time the width was changed
354(rr) rn # reverse-next to the previous line
355(rr) reverse-fin # run to where this function was called from
Christian Biesinger3332bb3a2019-08-13 05:45:23[diff] [blame]356```
357
L. David Barone99d91eb2021-03-30 20:18:00[diff] [blame]358You can debug multi-process chromeusing`rr -f [PID]`
Steve Kobes8ce3e44d2022-01-28 22:36:59[diff] [blame]359for processes`fork()`edfrom a[zygote process](zygote.md) withoutexec,
360which includes renderer processes,
361or`rr -p [PID]`for other processes.
362To find the process id you can either run`rr ps` after recording,orfor
363renderer processesuse`--vmodule=render_frame_impl=1` which will log a
364message on navigations.Example:
Robert Flacke13e0b12020-04-16 17:03:58[diff] [blame]365
366```
Steve Kobes8ce3e44d2022-01-28 22:36:59[diff] [blame]367$ rr record out/Debug/content_shell --disable-hang-monitor --vmodule=render_frame_impl=1 https://www.google.com/
Robert Flacke13e0b12020-04-16 17:03:58[diff] [blame]368rr: Saving execution to trace directory `...'.
369...
370[128515:128515:0320/164124.768687:VERBOSE1:render_frame_impl.cc(4244)] Committed provisional load: https://www.google.com/
371```
372
373From the log message we can see that the site was loaded into process 128515
374and can set a breakpoint for when that process is forked.
375
376```
377rr replay -f 128515
378```
379
L. David Barone99d91eb2021-03-30 20:18:00[diff] [blame]380If you want to call debugging functions from gdb that use `LOG()`,
Steve Kobes8ce3e44d2022-01-28 22:36:59[diff] [blame]381then those functions need to disable the printing of timestamps using
382[`SetLogItems`](https://source.chromium.org/search?q=SetLogItems&sq=&ss=chromium%2Fchromium%2Fsrc).
383See `LayoutObject::ShowLayoutObject()` for an example of this, and
384[issue 2829](https://github.com/rr-debugger/rr/issues/2829) for why it is needed.
L. David Barone99d91eb2021-03-30 20:18:00[diff] [blame]385
Steve Kobes8ce3e44d2022-01-28 22:36:59[diff] [blame]386If rr doesn't work correctly, the rr developers are generally quite responsive
387to[bug reports](https://github.com/rr-debugger/rr/issues),
L. David Barone99d91eb2021-03-30 20:18:00[diff] [blame]388especially ones that have enough information so that
389they don't have to build Chromium.
390
391See Also:
Steve Kobes8ce3e44d2022-01-28 22:36:59[diff] [blame]392
L. David Barone99d91eb2021-03-30 20:18:00[diff] [blame]393* [The Chromium Chronicle #13: Time-Travel Debugging with RR](https://developer.chrome.com/blog/chromium-chronicle-13/)
Steve Kobes8ce3e44d2022-01-28 22:36:59[diff] [blame]394* [@davidbaron demo using rr](https://twitter.com/davidbaron/status/1473761042278887433)
395* [@davidbaron demo using pernosco](https://twitter.com/davidbaron/status/1475836824409022469)
396(Googlers: see [go/pernosco](https://goto.google.com/pernosco))
L. David Barone99d91eb2021-03-30 20:18:00[diff] [blame]397
andybons3322f762015-08-24 21:37:09[diff] [blame]398### Graphical Debugging Aid for Chromium Views
399
400The following link describes a tool that can be used on Linux, Windows and Mac under GDB.
401
sisidovskif270241c2021-08-04 07:07:44[diff] [blame]402[graphical_debugging_aid_chromium_views](../graphical_debugging_aid_chromium_views.md)
andybons3322f762015-08-24 21:37:09[diff] [blame]403
404### Faster startup
405
andybonsad92aa32015-08-31 02:27:44[diff] [blame]406Use the `gdb-add-index` script (e.g.
407`build/gdb-add-index out/Debug/browser_tests`)
andybons3322f762015-08-24 21:37:09[diff] [blame]408
andybonsad92aa32015-08-31 02:27:44[diff] [blame]409Only makes sense if you run the binary multiple times or maybe if you use the
nodira6074d4c2015-09-01 04:26:45[diff] [blame]410component build since most `.so` files won'trequire reindexing on a rebuild.
andybons3322f762015-08-24 21:37:09[diff] [blame]411
andybonsad92aa32015-08-31 02:27:44[diff] [blame]412See
413https://groups.google.com/a/chromium.org/forum/#!searchin/chromium-dev/gdb-add-index/chromium-dev/ELRuj1BDCL4/5Ki4LGx41CcJ
414for more info.
andybons3322f762015-08-24 21:37:09[diff] [blame]415
Takuto Ikutaa093dc22020-11-11 03:17:50[diff] [blame]416You can improve GDB load time significantly at the cost of link timebynot
brettw20d800c2016-04-12 00:10:49[diff] [blame]417splitting symbolsfrom theobject files.In GN,set`use_debug_fission=false`in
418your"gn args".
andybons3322f762015-08-24 21:37:09[diff] [blame]419
420## Core files
andybons3322f762015-08-24 21:37:09[diff] [blame]421
andybonsad92aa32015-08-31 02:27:44[diff] [blame]422`ulimit -c unlimited` should cause allChrome processes(runfrom that shell) to
423dump cores,with the possible exception of some sandboxed processes.
andybons3322f762015-08-24 21:37:09[diff] [blame]424
andybonsad92aa32015-08-31 02:27:44[diff] [blame]425Some sandboxed subprocesses mightnotdump coresunless youpass the
426`--allow-sandbox-debugging` flag.
427
428If the problemis a freeze rather than a crash, you may be able to trigger a
429core-dumpby sending SIGABRT to the relevant process:
430
431 kill-6[process id]
andybons3322f762015-08-24 21:37:09[diff] [blame]432
433## Breakpad minidump files
434
Tom Andersonabdbd6a2020-01-09 16:59:27[diff] [blame]435See[minidump_to_core.md](minidump_to_core.md)
andybons3322f762015-08-24 21:37:09[diff] [blame]436
437## Running Tests
andybonsad92aa32015-08-31 02:27:44[diff] [blame]438
439Many ofour tests bring up windows on screen.This can be annoying(they steal
440your focus)and hard to debug(they receive extra eventsas you mouse over them).
441Instead,use`Xvfb`or`Xephyr` to run a nested X session to debug them,as
sisidovskif270241c2021-08-04 07:07:44[diff] [blame]442outlined on[testing/web_tests_linux.md](../testing/web_tests_linux.md).
Brett Wilson41a7de02023-04-27 18:56:54[diff] [blame]443
andybons3322f762015-08-24 21:37:09[diff] [blame]444### Browser tests
andybonsad92aa32015-08-31 02:27:44[diff] [blame]445
446Bydefault the`browser_tests` forks anew browserfor each test.To debug the
447browser side of a single test,use a command like
448
andybons3322f762015-08-24 21:37:09[diff] [blame]449```
Thomas Lukaszewicz2c5fb6142019-10-14 19:20:05[diff] [blame]450gdb --args out/Debug/browser_tests --single-process-tests --gtest_filter=MyTestName
andybons3322f762015-08-24 21:37:09[diff] [blame]451```
andybonsad92aa32015-08-31 02:27:44[diff] [blame]452
Thomas Lukaszewicz2c5fb6142019-10-14 19:20:05[diff] [blame]453**note theuse of`single-process-tests`**--this makes the test harnessand
andybonsad92aa32015-08-31 02:27:44[diff] [blame]454browser process share the outermost process.
andybons3322f762015-08-24 21:37:09[diff] [blame]455
Brett Wilson41a7de02023-04-27 18:56:54[diff] [blame]456Theswitch`--gtest_break_on_failure` can also be useful to automatically stop
457debugger upon`ASSERT`or`EXPECT` failures.
andybons3322f762015-08-24 21:37:09[diff] [blame]458
459To debug a renderer processinthiscase,use the tips above about renderers.
460
Kent Tamura59ffb022018-11-27 05:30:56[diff] [blame]461### Web tests
andybonsad92aa32015-08-31 02:27:44[diff] [blame]462
sisidovskif270241c2021-08-04 07:07:44[diff] [blame]463See[testing/web_tests_linux.md](../testing/web_tests_linux.md)for some tips.In particular,
Kent Tamura59ffb022018-11-27 05:30:56[diff] [blame]464note that it's possible to debug a web test via `ssh`ing to a Linux box; you
andybonsad92aa32015-08-31 02:27:44[diff] [blame]465don't need anything on screenif youuse`Xvfb`.
andybons3322f762015-08-24 21:37:09[diff] [blame]466
467### UI tests
andybons3322f762015-08-24 21:37:09[diff] [blame]468
andybonsad92aa32015-08-31 02:27:44[diff] [blame]469UI tests are runin forked browsers.Unlike browser tests, you cannotdo any
470single process tricks here to debug the browser.See below about
471`BROWSER_WRAPPER`.
472
473Topass flags to the browser,use a command line like
474`--extra-chrome-flags="--foo --bar"`.
andybons3322f762015-08-24 21:37:09[diff] [blame]475
476### Timeouts
andybonsad92aa32015-08-31 02:27:44[diff] [blame]477
478UI tests have a confusing array of timeoutsin place.(Pawelis working on
479reducing the number of timeouts.)To disable themwhile you debug,set the
480timeout flags to a large value:
481
482*`--test-timeout=100000000`
483*`--ui-test-action-timeout=100000000`
484*`--ui-test-terminate-timeout=100000000`
andybons3322f762015-08-24 21:37:09[diff] [blame]485
486### To replicate Window Manager setup on the bots
andybonsad92aa32015-08-31 02:27:44[diff] [blame]487
488Chromiumtry botsand main waterfall's bots run tests under Xvfb&openbox
489combination. Xvfb is an X11 server that redirects the graphical output to the
490memory, and openbox is a simple window manager that is running on top of Xvfb.
491The behavior of openbox is markedly different when it comes to focus management
492and other window tasks, so test that runs fine locally may fail or be flaky on
493try bots. To run the tests on a local machine as on a bot, follow these steps:
andybons3322f762015-08-24 21:37:09[diff] [blame]494
495Make sure you have openbox:
andybonsad92aa32015-08-31 02:27:44[diff] [blame]496
497 apt-get install openbox
498
andybons3322f762015-08-24 21:37:09[diff] [blame]499Start Xvfb and openbox on a particular display:
andybonsad92aa32015-08-31 02:27:44[diff] [blame]500
501 Xvfb :6.0 -screen 0 1280x1024x24 & DISPLAY=:6.0 openbox &
502
andybons3322f762015-08-24 21:37:09[diff] [blame]503Run your tests with graphics output redirected to that display:
andybonsad92aa32015-08-31 02:27:44[diff] [blame]504
505 DISPLAY=:6.0 out/Debug/browser_tests --gtest_filter="MyBrowserTest.MyActivateWindowTest"
506
andybons3322f762015-08-24 21:37:09[diff] [blame]507You can look at a snapshot of the output by:
andybonsad92aa32015-08-31 02:27:44[diff] [blame]508
509 xwd -display :6.0 -root | xwud
andybons3322f762015-08-24 21:37:09[diff] [blame]510
511Alternatively, you can use testing/xvfb.py to set up your environment for you:
andybons3322f762015-08-24 21:37:09[diff] [blame]512
thomasanderson3d074282016-12-06 18:21:12[diff] [blame]513 testing/xvfb.py out/Debug/browser_tests \
andybonsad92aa32015-08-31 02:27:44[diff] [blame]514 --gtest_filter="MyBrowserTest.MyActivateWindowTest"
andybons3322f762015-08-24 21:37:09[diff] [blame]515
nodira6074d4c2015-09-01 04:26:45[diff] [blame]516### BROWSER_WRAPPER
andybonsad92aa32015-08-31 02:27:44[diff] [blame]517
518You can also get the browser under a debugger by setting the `BROWSER_WRAPPER`
519environment variable. (You can use this for `browser_tests` too, but see above
520for discussion of a simpler way.)
521
522 BROWSER_WRAPPER='xterm-e gdb--args' out/Debug/browser_tests
andybons3322f762015-08-24 21:37:09[diff] [blame]523
qyearsleyc0dc6f42016-12-02 22:13:39[diff] [blame]524### Replicating try bot Slowness
andybons3322f762015-08-24 21:37:09[diff] [blame]525
qyearsleyc0dc6f42016-12-02 22:13:39[diff] [blame]526Try bots are pretty stressed, and can sometimes expose timing issues you can't
andybonsad92aa32015-08-31 02:27:44[diff] [blame]527normally reproduce locally.
andybons3322f762015-08-24 21:37:09[diff] [blame]528
andybonsad92aa32015-08-31 02:27:44[diff] [blame]529You can simulatethisby shutting down all but one of theCPUs
530(http://www.cyberciti.biz/faq/debian-rhel-centos-redhat-suse-hotplug-cpu/) and
531running a CPU loading tool(e.g., http://www.devin.com/lookbusy/). Now run your
qyearsleyc0dc6f42016-12-02 22:13:39[diff] [blame]532test.It will run slowly, but any flakiness foundby thetry bot should replicate
andybonsad92aa32015-08-31 02:27:44[diff] [blame]533locally now-and often nearly100% of the time.
andybons3322f762015-08-24 21:37:09[diff] [blame]534
535## Logging
andybons3322f762015-08-24 21:37:09[diff] [blame]536
andybonsad92aa32015-08-31 02:27:44[diff] [blame]537### Seeing all LOG(foo) messages
538
539Default log level hides`LOG(INFO)`.Runwith`--log-level=0`and
540`--enable-logging=stderr` flags.
541
qyearsleyc0dc6f42016-12-02 22:13:39[diff] [blame]542Newer versions ofChromiumwith VLOG may need--v=1 too.For more VLOG tips, see
xiaoyin.l1003c0b2016-12-06 02:51:17[diff] [blame]543[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:09[diff] [blame]544
andybons3322f762015-08-24 21:37:09[diff] [blame]545## Profiling
andybonsad92aa32015-08-31 02:27:44[diff] [blame]546
547See
548https://sites.google.com/a/chromium.org/dev/developers/profiling-chromium-and-webkit
Tom Anderson93e49e492019-12-23 19:55:37[diff] [blame]549and[LinuxProfiling](profiling.md).
andybons3322f762015-08-24 21:37:09[diff] [blame]550
551## i18n
andybons3322f762015-08-24 21:37:09[diff] [blame]552
andybonsad92aa32015-08-31 02:27:44[diff] [blame]553We obey your system locale.Try something like:
andybons3322f762015-08-24 21:37:09[diff] [blame]554
andybonsad92aa32015-08-31 02:27:44[diff] [blame]555 LANG=ja_JP.UTF-8out/Debug/chrome
556
557Ifthis doesn't work, make sure that the `LANGUAGE`, `LC_ALL` and `LC_MESSAGE`
558environment variables aren'tset-- they have higher priority than LANGin the
559order listed.Alternatively, justdothis:
560
561 LANGUAGE=frout/Debug/chrome
562
563Note that because weuse GTK, some locale data comesfrom the system--for
564example, file save boxesand whether the current languageis considered RTL.
565Without all the language data available,Chrome willuse a mixture of your
566system languageand the language you runChromein.
andybons3322f762015-08-24 21:37:09[diff] [blame]567
568Here's how to install the Arabic (ar) and Hebrew (he) language packs:
andybonsad92aa32015-08-31 02:27:44[diff] [blame]569
570 sudo apt-get install language-pack-ar language-pack-he \
571 language-pack-gnome-ar language-pack-gnome-he
572
andybons3322f762015-08-24 21:37:09[diff] [blame]573Note that the `--lang` flag does **not** work properly for this.
574
Tom Anderson287339e2018-08-22 21:52:02[diff] [blame]575On non-Debian systems, you need the `gtk30.mo` files. (Please update these docs
andybonsad92aa32015-08-31 02:27:44[diff] [blame]576with the appropriate instructions if you know what they are.)
andybons3322f762015-08-24 21:37:09[diff] [blame]577
578## Breakpad
andybonsad92aa32015-08-31 02:27:44[diff] [blame]579
Tom Anderson93e49e492019-12-23 19:55:37[diff] [blame]580See the last section of [Linux Crash Dumping](crash_dumping.md).
andybons3322f762015-08-24 21:37:09[diff] [blame]581
582## Drag and Drop
andybonsad92aa32015-08-31 02:27:44[diff] [blame]583
584If you break in a debugger during a drag, Chrome will have grabbed your mouse
585and keyboard so you won't be able to interactwith thedebugger!To work around
586this, run via`Xephyr`.Instructionsfor how touse`Xephyr` are on the
sisidovskif270241c2021-08-04 07:07:44[diff] [blame]587[Running web tests onLinux](../testing/web_tests_linux.md) page.
andybons3322f762015-08-24 21:37:09[diff] [blame]588
589## Tracking Down Bugs
590
591### Isolating Regressions
andybons3322f762015-08-24 21:37:09[diff] [blame]592
andybonsad92aa32015-08-31 02:27:44[diff] [blame]593Old builds are archived here:
xiaoyin.l1003c0b2016-12-06 02:51:17[diff] [blame]594https://build.chromium.org/buildbot/snapshots/chromium-rel-linux/
nodira6074d4c2015-09-01 04:26:45[diff] [blame]595(TODO: doesnot exist).
andybonsad92aa32015-08-31 02:27:44[diff] [blame]596
597`tools/bisect-builds.py`in the tree automates bisecting through the archived
598builds.Despite a computer science education, I am still amazed how quickly
599binary search will find its target.
andybons3322f762015-08-24 21:37:09[diff] [blame]600
601### Screen recording for bug reports
andybonsad92aa32015-08-31 02:27:44[diff] [blame]602
603 sudo apt-get install gtk-recordmydesktop
andybons3322f762015-08-24 21:37:09[diff] [blame]604
605## Version-specific issues
606
607### Google Chrome
andybonsad92aa32015-08-31 02:27:44[diff] [blame]608
609GoogleChrome binaries don't include symbols. Googlers can read where to get
610symbols from
611[the Google-internal wiki](http://wiki/Main/ChromeOfficialBuildLinux#The_Build_Archive).
andybons3322f762015-08-24 21:37:09[diff] [blame]612
613### Ubuntu Chromium
andybonsad92aa32015-08-31 02:27:44[diff] [blame]614
615Since we don't build theUbuntu packages(Ubuntu does) we can't get useful
616backtraces from them. Direct users to https://wiki.ubuntu.com/Chromium/Debugging
andybons3322f762015-08-24 21:37:09[diff] [blame]617
618### Fedora'sChromium
andybonsad92aa32015-08-31 02:27:44[diff] [blame]619
620LikeUbuntu, but direct users to
621https://fedoraproject.org/wiki/TomCallaway/Chromium_Debug
andybons3322f762015-08-24 21:37:09[diff] [blame]622
623### Xlib
andybonsad92aa32015-08-31 02:27:44[diff] [blame]624
andybons3322f762015-08-24 21:37:09[diff] [blame]625If you're trying to track down X errors like:
andybonsad92aa32015-08-31 02:27:44[diff] [blame]626
andybons3322f762015-08-24 21:37:09[diff] [blame]627```
628The program 'chrome' received an X Window System error.
629This probably reflects a bug in the program.
630The error was 'BadDrawable(invalidPixmaporWindow parameter)'.
631```
andybonsad92aa32015-08-31 02:27:44[diff] [blame]632
andybons3322f762015-08-24 21:37:09[diff] [blame]633Some strategies are:
andybonsad92aa32015-08-31 02:27:44[diff] [blame]634
635* pass `--sync` on the command line to make all X calls synchronous
636* run chrome via [xtrace](http://xtrace.alioth.debian.org/)
637* turn on IPC debugging (see above section)
andybons3322f762015-08-24 21:37:09[diff] [blame]638
639### Window Managers
andybons3322f762015-08-24 21:37:09[diff] [blame]640
andybonsad92aa32015-08-31 02:27:44[diff] [blame]641To test on various window managers, you can use a nested X server like `Xephyr`.
642Instructions for how to use `Xephyr` are on the
sisidovskif270241c2021-08-04 07:07:44[diff] [blame]643[Running web tests on Linux](../testing/web_tests_linux.md) page.
andybonsad92aa32015-08-31 02:27:44[diff] [blame]644
645If you need to test something with hardware accelerated compositing
646(e.g., compiz), you can use `Xgl` (`sudo apt-get install xserver-xgl`). E.g.:
647
648 Xgl :1 -ac -accel glx:pbuffer -accel xv:pbuffer -screen 1024x768
649
andybons3322f762015-08-24 21:37:09[diff] [blame]650## Mozilla Tips
andybonsad92aa32015-08-31 02:27:44[diff] [blame]651
652https://developer.mozilla.org/en/Debugging_Mozilla_on_Linux_FAQ
Joshua Pawlickic2464187d2022-02-23 14:27:51[diff] [blame]653
654## Google Chrome Symbol Files
655
656Symbols for Google Chrome's official builds are availablefrom
657`https://edgedl.me.gvt1.com/chrome/linux/symbols/google-chrome-debug-info-linux64-${VERSION}.zip`
658where ${VERSION}is any version ofGoogleChrome that has recently been served
Robert Flackcdbf8c4a2022-11-18 18:12:34[diff] [blame]659toStable,Beta,orUnstable(Dev) channels onLinux.

[8]ページ先頭

©2009-2025 Movatter.jp