OLD | NEW |
1 # Tips for debugging on Linux | 1 # Tips for debugging on Linux |
2 | 2 |
3 This page is for Chromium-specific debugging tips; learning how to run gdb is | 3 This page is for Chromium-specific debugging tips; learning how to run gdb is |
4 out of scope. | 4 out of scope. |
5 | 5 |
6 [TOC] | 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 | 10 The sandbox can interfere with the internal symbolizer. Use `--no-sandbox` (but |
11 keep this temporary) or an external symbolizer (see | 11 keep this temporary) or an external symbolizer (see |
12 `tools/valgrind/asan/asan_symbolize.py`). | 12 `tools/valgrind/asan/asan_symbolize.py`). |
13 | 13 |
14 Generally, do not use `--no-sandbox` on waterfall bots, sandbox testing is | 14 Generally, do not use `--no-sandbox` on waterfall bots, sandbox testing is |
15 needed. Talk to security@chromium.org. | 15 needed. Talk to security@chromium.org. |
16 | 16 |
17 ## GDB | 17 ## GDB |
18 | 18 |
19 **GDB-7.7 is required in order to debug Chrome on Linux.** | 19 *** promo |
| 20 GDB-7.7 is required in order to debug Chrome on Linux. |
| 21 *** |
20 | 22 |
21 Any prior version will fail to resolve symbols or segfault. | 23 Any prior version will fail to resolve symbols or segfault. |
22 | 24 |
23 ### Basic browser process debugging | 25 ### Basic browser process debugging |
24 | 26 |
25 gdb -tui -ex=r --args out/Debug/chrome --disable-seccomp-sandbox \ | 27 gdb -tui -ex=r --args out/Debug/chrome --disable-seccomp-sandbox \ |
26 http://google.com | 28 http://google.com |
27 | 29 |
28 ### Allowing attaching to foreign processes | 30 ### Allowing attaching to foreign processes |
29 | 31 |
(...skipping 22 matching lines...) Expand all Loading... |
52 ``` | 54 ``` |
53 | 55 |
54 The `--no-sandbox` flag is needed because otherwise the seccomp sandbox will | 56 The `--no-sandbox` flag is needed because otherwise the seccomp sandbox will |
55 kill the renderer process on startup, or the setuid sandbox will prevent xterm's | 57 kill the renderer process on startup, or the setuid sandbox will prevent xterm's |
56 execution. The "xterm" is necessary or gdb will run in the current terminal, | 58 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 | 59 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 | 60 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 | 61 instances will fight over the terminal). To auto-start the renderers in the |
60 debugger, send the "run" command to the debugger: | 62 debugger, send the "run" command to the debugger: |
61 | 63 |
62 chrome --no-sandbox --renderer-cmd-prefix='xterm -title renderer -e gdb -ex
\ | 64 chrome --no-sandbox --renderer-cmd-prefix='xterm -title renderer -e gdb \ |
63 run --args | 65 -ex run --args |
64 | 66 |
65 If you're using Emacs and `M-x gdb`, you can do | 67 If you're using Emacs and `M-x gdb`, you can do |
66 | 68 |
67 chrome "--renderer-cmd-prefix=gdb --args" | 69 chrome "--renderer-cmd-prefix=gdb --args" |
68 | 70 |
| 71 *** note |
69 Note: using the `--renderer-cmd-prefix` option bypasses the zygote launcher, so | 72 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 | 73 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, | 74 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). | 75 you will need to attach your debugger to a running renderer process (see below). |
| 76 *** |
73 | 77 |
74 You may also want to pass `--disable-hang-monitor` to suppress the hang monitor, | 78 You may also want to pass `--disable-hang-monitor` to suppress the hang monitor, |
75 which is rather annoying. | 79 which is rather annoying. |
76 | 80 |
77 You can also use `--renderer-startup-dialog` and attach to the process in order | 81 You can also use `--renderer-startup-dialog` and attach to the process in order |
78 to debug the renderer code. Go to | 82 to debug the renderer code. Go to |
79 http://www.chromium.org/blink/getting-started-with-blink-debugging for more | 83 http://www.chromium.org/blink/getting-started-with-blink-debugging for more |
80 information on how this can be done. | 84 information on how this can be done. |
81 | 85 |
82 #### Choosing which renderers to debug | 86 #### Choosing which renderers to debug |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 BROWSER_WRAPPER='xterm -title renderer -e gdb --eval-command=run \ | 174 BROWSER_WRAPPER='xterm -title renderer -e gdb --eval-command=run \ |
171 --eval-command=quit --args' out/Debug/browser_tests --gtest_filter=Print | 175 --eval-command=quit --args' out/Debug/browser_tests --gtest_filter=Print |
172 ``` | 176 ``` |
173 | 177 |
174 #### Plugin Processes | 178 #### Plugin Processes |
175 | 179 |
176 Same strategies as renderers above, but the flag is called `--plugin-launcher`: | 180 Same strategies as renderers above, but the flag is called `--plugin-launcher`: |
177 | 181 |
178 chrome --plugin-launcher='xterm -e gdb --args' | 182 chrome --plugin-launcher='xterm -e gdb --args' |
179 | 183 |
180 _Note: For now, this does not currently apply to PPAPI plugins because they | 184 *** note |
181 currently run in the renderer process._ | 185 Note: For now, this does not currently apply to PPAPI plugins because they |
| 186 currently run in the renderer process. |
| 187 *** |
182 | 188 |
183 #### Single-Process mode | 189 #### Single-Process mode |
184 | 190 |
185 Depending on whether it's relevant to the problem, it's often easier to just run | 191 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 | 192 in "single process" mode where the renderer threads are in-process. Then you can |
187 just run gdb on the main process. | 193 just run gdb on the main process. |
188 | 194 |
189 gdb --args chrome --single-process | 195 gdb --args chrome --single-process |
190 | 196 |
191 Currently, the `--disable-gpu` flag is also required, as there are known crashes | 197 Currently, the `--disable-gpu` flag is also required, as there are known crashes |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 The following link describes a tool that can be used on Linux, Windows and Mac u
nder GDB. | 256 The following link describes a tool that can be used on Linux, Windows and Mac u
nder GDB. |
251 | 257 |
252 [graphical_debugging_aid_chromium_views](graphical_debugging_aid_chromium_views.
md) | 258 [graphical_debugging_aid_chromium_views](graphical_debugging_aid_chromium_views.
md) |
253 | 259 |
254 ### Faster startup | 260 ### Faster startup |
255 | 261 |
256 Use the `gdb-add-index` script (e.g. | 262 Use the `gdb-add-index` script (e.g. |
257 `build/gdb-add-index out/Debug/browser_tests`) | 263 `build/gdb-add-index out/Debug/browser_tests`) |
258 | 264 |
259 Only makes sense if you run the binary multiple times or maybe if you use the | 265 Only makes sense if you run the binary multiple times or maybe if you use the |
260 component build since most .so files won't require reindexing on a rebuild. | 266 component build since most `.so` files won't require reindexing on a rebuild. |
261 | 267 |
262 See | 268 See |
263 https://groups.google.com/a/chromium.org/forum/#!searchin/chromium-dev/gdb-add-i
ndex/chromium-dev/ELRuj1BDCL4/5Ki4LGx41CcJ | 269 https://groups.google.com/a/chromium.org/forum/#!searchin/chromium-dev/gdb-add-i
ndex/chromium-dev/ELRuj1BDCL4/5Ki4LGx41CcJ |
264 for more info. | 270 for more info. |
265 | 271 |
266 Alternatively, specify: | 272 Alternatively, specify: |
267 | 273 |
268 linux_use_debug_fission=0 | 274 linux_use_debug_fission=0 |
269 | 275 |
270 in `GYP_DEFINES`. This improves load time of gdb significantly at the cost of | 276 in `GYP_DEFINES`. This improves load time of gdb significantly at the cost of |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 | 363 |
358 You can look at a snapshot of the output by: | 364 You can look at a snapshot of the output by: |
359 | 365 |
360 xwd -display :6.0 -root | xwud | 366 xwd -display :6.0 -root | xwud |
361 | 367 |
362 Alternatively, you can use testing/xvfb.py to set up your environment for you: | 368 Alternatively, you can use testing/xvfb.py to set up your environment for you: |
363 | 369 |
364 testing/xvfb.py out/Debug out/Debug/browser_tests \ | 370 testing/xvfb.py out/Debug out/Debug/browser_tests \ |
365 --gtest_filter="MyBrowserTest.MyActivateWindowTest" | 371 --gtest_filter="MyBrowserTest.MyActivateWindowTest" |
366 | 372 |
367 ### `BROWSER_WRAPPER` | 373 ### BROWSER_WRAPPER |
368 | 374 |
369 You can also get the browser under a debugger by setting the `BROWSER_WRAPPER` | 375 You can also get the browser under a debugger by setting the `BROWSER_WRAPPER` |
370 environment variable. (You can use this for `browser_tests` too, but see above | 376 environment variable. (You can use this for `browser_tests` too, but see above |
371 for discussion of a simpler way.) | 377 for discussion of a simpler way.) |
372 | 378 |
373 BROWSER_WRAPPER='xterm -e gdb --args' out/Debug/browser_tests | 379 BROWSER_WRAPPER='xterm -e gdb --args' out/Debug/browser_tests |
374 | 380 |
375 ### Replicating Trybot Slowness | 381 ### Replicating Trybot Slowness |
376 | 382 |
377 Trybots are pretty stressed, and can sometimes expose timing issues you can't | 383 Trybots are pretty stressed, and can sometimes expose timing issues you can't |
378 normally reproduce locally. | 384 normally reproduce locally. |
379 | 385 |
380 You can simulate this by shutting down all but one of the CPUs | 386 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 | 387 (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 | 388 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 | 389 test. It will run slowly, but any flakiness found by the trybot should replicate |
384 locally now - and often nearly 100% of the time. | 390 locally now - and often nearly 100% of the time. |
385 | 391 |
386 ## Logging | 392 ## Logging |
387 | 393 |
388 ### Seeing all LOG(foo) messages | 394 ### Seeing all LOG(foo) messages |
389 | 395 |
390 Default log level hides `LOG(INFO)`. Run with `--log-level=0` and | 396 Default log level hides `LOG(INFO)`. Run with `--log-level=0` and |
391 `--enable-logging=stderr` flags. | 397 `--enable-logging=stderr` flags. |
392 | 398 |
393 Newer versions of chromium with VLOG may need --v=1 too. For more VLOG tips, see | 399 Newer versions of chromium with VLOG may need --v=1 too. For more VLOG tips, see |
394 the chromium-dev thread: | 400 [the chromium-dev thread](http://groups.google.com/a/chromium.org/group/chromium
-dev/browse_thread/thread/dcd0cd7752b35de6?pli=1). |
395 http://groups.google.com/a/chromium.org/group/chromium-dev/browse_thread/thread/
dcd0cd7752b35de6?pli=1 | |
396 | 401 |
397 ### Seeing IPC debug messages | 402 ### Seeing IPC debug messages |
398 | 403 |
399 Run with `CHROME_IPC_LOGGING=1` eg. | 404 Run with `CHROME_IPC_LOGGING=1` eg. |
400 | 405 |
401 CHROME_IPC_LOGGING=1 out/Debug/chrome | 406 CHROME_IPC_LOGGING=1 out/Debug/chrome |
402 | 407 |
403 or within gdb: | 408 or within gdb: |
404 | 409 |
405 set environment CHROME_IPC_LOGGING 1 | 410 set environment CHROME_IPC_LOGGING 1 |
406 | 411 |
407 If some messages show as unknown, check if the list of IPC message headers in | 412 If some messages show as unknown, check if the list of IPC message headers in |
408 `chrome/common/logging_chrome.cc` is up-to-date. In case this file reference | 413 [chrome/common/logging_chrome.cc](/chrome/common/logging_chrome.cc) is |
409 goes out of date, try looking for usage of macros like `IPC_MESSAGE_LOG_ENABLED` | 414 up-to-date. In case this file reference goes out of date, try looking for usage |
410 or `IPC_MESSAGE_MACROS_LOG_ENABLED`. | 415 of macros like `IPC_MESSAGE_LOG_ENABLED` or `IPC_MESSAGE_MACROS_LOG_ENABLED`. |
411 | 416 |
412 ## Using valgrind | 417 ## Using valgrind |
413 | 418 |
414 To run valgrind on the browser and renderer processes, with our suppression file | 419 To run valgrind on the browser and renderer processes, with our suppression file |
415 and flags: | 420 and flags: |
416 | 421 |
417 $ cd $CHROMIUM_ROOT/src | 422 $ cd $CHROMIUM_ROOT/src |
418 $ tools/valgrind/valgrind.sh out/Debug/chrome | 423 $ tools/valgrind/valgrind.sh out/Debug/chrome |
419 | 424 |
420 You can use valgrind on chrome and/or on the renderers e.g | 425 You can use valgrind on chrome and/or on the renderers e.g |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 sudo apt-get install language-pack-ar language-pack-he \ | 467 sudo apt-get install language-pack-ar language-pack-he \ |
463 language-pack-gnome-ar language-pack-gnome-he | 468 language-pack-gnome-ar language-pack-gnome-he |
464 | 469 |
465 Note that the `--lang` flag does **not** work properly for this. | 470 Note that the `--lang` flag does **not** work properly for this. |
466 | 471 |
467 On non-Debian systems, you need the `gtk20.mo` files. (Please update these docs | 472 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.) | 473 with the appropriate instructions if you know what they are.) |
469 | 474 |
470 ## Breakpad | 475 ## Breakpad |
471 | 476 |
472 See the last section of [linux_crash_dumping.md](linux_crash_dumping.md); you | 477 See the last section of [Linux Crash Dumping](linux_crash_dumping.md); you |
473 need to set a gyp variable and an environment variable for the crash dump tests | 478 need to set a gyp variable and an environment variable for the crash dump tests |
474 to work. | 479 to work. |
475 | 480 |
476 ## Drag and Drop | 481 ## Drag and Drop |
477 | 482 |
478 If you break in a debugger during a drag, Chrome will have grabbed your mouse | 483 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 | 484 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 | 485 this, run via `Xephyr`. Instructions for how to use `Xephyr` are on the |
481 [layout_tests_linux.md](layout_tests_linux.md) page. | 486 [Running layout tests on Linux](layout_tests_linux.md) page. |
482 | 487 |
483 ## Tracking Down Bugs | 488 ## Tracking Down Bugs |
484 | 489 |
485 ### Isolating Regressions | 490 ### Isolating Regressions |
486 | 491 |
487 Old builds are archived here: | 492 Old builds are archived here: |
488 http://build.chromium.org/buildbot/snapshots/chromium-rel-linux/ | 493 http://build.chromium.org/buildbot/snapshots/chromium-rel-linux/ |
| 494 (TODO: does not exist). |
489 | 495 |
490 `tools/bisect-builds.py` in the tree automates bisecting through the archived | 496 `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 | 497 builds. Despite a computer science education, I am still amazed how quickly |
492 binary search will find its target. | 498 binary search will find its target. |
493 | 499 |
494 ### Screen recording for bug reports | 500 ### Screen recording for bug reports |
495 | 501 |
496 sudo apt-get install gtk-recordmydesktop | 502 sudo apt-get install gtk-recordmydesktop |
497 | 503 |
498 ## Version-specific issues | 504 ## Version-specific issues |
(...skipping 27 matching lines...) Expand all Loading... |
526 Some strategies are: | 532 Some strategies are: |
527 | 533 |
528 * pass `--sync` on the command line to make all X calls synchronous | 534 * pass `--sync` on the command line to make all X calls synchronous |
529 * run chrome via [xtrace](http://xtrace.alioth.debian.org/) | 535 * run chrome via [xtrace](http://xtrace.alioth.debian.org/) |
530 * turn on IPC debugging (see above section) | 536 * turn on IPC debugging (see above section) |
531 | 537 |
532 ### Window Managers | 538 ### Window Managers |
533 | 539 |
534 To test on various window managers, you can use a nested X server like `Xephyr`. | 540 To test on various window managers, you can use a nested X server like `Xephyr`. |
535 Instructions for how to use `Xephyr` are on the | 541 Instructions for how to use `Xephyr` are on the |
536 [layout_tests_linux.md](layout_tests_linux.md) page. | 542 [Running layout tests on Linux](layout_tests_linux.md) page. |
537 | 543 |
538 If you need to test something with hardware accelerated compositing | 544 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.: | 545 (e.g., compiz), you can use `Xgl` (`sudo apt-get install xserver-xgl`). E.g.: |
540 | 546 |
541 Xgl :1 -ac -accel glx:pbuffer -accel xv:pbuffer -screen 1024x768 | 547 Xgl :1 -ac -accel glx:pbuffer -accel xv:pbuffer -screen 1024x768 |
542 | 548 |
543 ## Mozilla Tips | 549 ## Mozilla Tips |
544 | 550 |
545 https://developer.mozilla.org/en/Debugging_Mozilla_on_Linux_FAQ | 551 https://developer.mozilla.org/en/Debugging_Mozilla_on_Linux_FAQ |
OLD | NEW |