Roll src/third_party/WebKit 75a2fa9:2546356 (svn 202272:202273)
[chromium-blink-merge.git] / docs / graphical_debugging_aid_chromium_views.md
blobd1057079efc94ae54172aa7b6a5a11cf300f3ba0
1 # Graphical Debugging Aid for Chromium Views
3 ## Introduction
5 A simple debugging tool exists to help visualize the views tree during
6 debugging. It consists of 4 components:
8 1.  The function `View::PrintViewGraph()` (already in the file `view.cc` if
9     you've sync'd recently),
10 1.  a gdb script file `viewg.gdb` (see below),
11 1.  the graphViz package (http://www.graphviz.org/ - downloadable for Linux,
12     Windows and Mac), and
13 1.  an SVG viewer (_e.g._ Chrome).
15 ## Details
17 To use the tool,
19 1.  Make sure you have 'dot' installed (part of graphViz),
20 1.  define `TOUCH_DEBUG` and compile chrome with Views enabled,
21 1.  run gdb on your build and
22 1.  `source viewg.gdb` (this can be done automatically in `.gdbinit`),
23 1.  stop at any breakpoint inside class `View` (or any derived class), and
24 1.  type `viewg` at the gdb prompt.
26 This will cause the current view, and any descendants, to be described in a
27 graph which is stored as `~/state.svg` (Windows users may need to modify the
28 script slightly to run under CygWin). If `state.svg` is kept open in a browser
29 window and refreshed each time `viewg` is run, then it provides a graphical
30 representation of the state of the views hierarchy that is always up to date.
32 It is easy to modify the gdb script to generate PDF in case viewing with evince
33 (or other PDF viewer) is preferred.
35 If you don't use gdb, you may be able to adapt the script to work with your
36 favorite debugger. The gdb script invokes
38     this->PrintViewGraph(true)
40 on the current object, returning `std::string`, whose contents must then be
41 saved to a file in order to be processed by dot.
43 ## viewg.gdb
45 ```
46 define viewg
47   if $argc != 0
48     echo Usage: viewg
49   else
50     set pagination off
51     set print elements 0
52     set logging off
53     set logging file ~/state.dot
54     set logging overwrite on
55     set logging redirect on
56     set logging on
57     printf "%s\n", this->PrintViewGraph(true).c_str()
58     set logging off
59     shell dot -Tsvg -o ~/state.svg ~/state.dot
60     set pagination on
61   end
62 end
63 ```