blob: d1057079efc94ae54172aa7b6a5a11cf300f3ba0 [file] [log] [blame] [view]
andybons22afb312015-08-31 02:24:511# Graphical Debugging Aid for Chromium Views
andybons3322f762015-08-24 21:37:092
andybons22afb312015-08-31 02:24:513## Introduction
andybons3322f762015-08-24 21:37:094
andybons22afb312015-08-31 02:24:515A simple debugging tool exists to help visualize the views tree during
6debugging. It consists of 4 components:
andybons3322f762015-08-24 21:37:097
andybons22afb312015-08-31 02:24:5181. The function `View::PrintViewGraph()` (already in the file `view.cc` if
9 you've sync'd recently),
101. a gdb script file `viewg.gdb` (see below),
111. the graphViz package (http://www.graphviz.org/ - downloadable for Linux,
12 Windows and Mac), and
131. an SVG viewer (_e.g._ Chrome).
14
15## Details
andybons3322f762015-08-24 21:37:0916
17To use the tool,
18
andybons22afb312015-08-31 02:24:51191. Make sure you have 'dot' installed (part of graphViz),
201. define `TOUCH_DEBUG` and compile chrome with Views enabled,
211. run gdb on your build and
221. `source viewg.gdb` (this can be done automatically in `.gdbinit`),
231. stop at any breakpoint inside class `View` (or any derived class), and
241. type `viewg` at the gdb prompt.
andybons3322f762015-08-24 21:37:0925
andybons22afb312015-08-31 02:24:5126This will cause the current view, and any descendants, to be described in a
27graph which is stored as `~/state.svg` (Windows users may need to modify the
28script slightly to run under CygWin). If `state.svg` is kept open in a browser
29window and refreshed each time `viewg` is run, then it provides a graphical
30representation of the state of the views hierarchy that is always up to date.
andybons3322f762015-08-24 21:37:0931
andybons22afb312015-08-31 02:24:5132It is easy to modify the gdb script to generate PDF in case viewing with evince
33(or other PDF viewer) is preferred.
andybons3322f762015-08-24 21:37:0934
andybons22afb312015-08-31 02:24:5135If you don't use gdb, you may be able to adapt the script to work with your
36favorite debugger. The gdb script invokes
andybons3322f762015-08-24 21:37:0937
andybons22afb312015-08-31 02:24:5138 this->PrintViewGraph(true)
39
40on the current object, returning `std::string`, whose contents must then be
41saved to a file in order to be processed by dot.
42
43## viewg.gdb
andybons3322f762015-08-24 21:37:0944
45```
46define 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
62end
andybons22afb312015-08-31 02:24:5163```