graphical_debugging_aid_chromium_views.md 1.98 KB
Newer Older
1
# Graphical Debugging Aid for Chromium Views
2

3
## Introduction
4

5 6
A simple debugging tool exists to help visualize the views tree during
debugging. It consists of 4 components:
7

8 9 10 11 12 13 14 15
1.  The function `View::PrintViewGraph()` (already in the file `view.cc` if
    you've sync'd recently),
1.  a gdb script file `viewg.gdb` (see below),
1.  the graphViz package (http://www.graphviz.org/ - downloadable for Linux,
    Windows and Mac), and
1.  an SVG viewer (_e.g._ Chrome).

## Details
16 17 18

To use the tool,

19 20 21 22 23 24
1.  Make sure you have 'dot' installed (part of graphViz),
1.  define `TOUCH_DEBUG` and compile chrome with Views enabled,
1.  run gdb on your build and
1.  `source viewg.gdb` (this can be done automatically in `.gdbinit`),
1.  stop at any breakpoint inside class `View` (or any derived class), and
1.  type `viewg` at the gdb prompt.
25

26 27 28 29 30
This will cause the current view, and any descendants, to be described in a
graph which is stored as `~/state.svg` (Windows users may need to modify the
script slightly to run under CygWin). If `state.svg` is kept open in a browser
window and refreshed each time `viewg` is run, then it provides a graphical
representation of the state of the views hierarchy that is always up to date.
31

32 33
It is easy to modify the gdb script to generate PDF in case viewing with evince
(or other PDF viewer) is preferred.
34

35 36
If you don't use gdb, you may be able to adapt the script to work with your
favorite debugger. The gdb script invokes
37

38 39 40 41 42 43
    this->PrintViewGraph(true)

on the current object, returning `std::string`, whose contents must then be
saved to a file in order to be processed by dot.

## viewg.gdb
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62

```
define viewg
  if $argc != 0
    echo Usage: viewg
  else
    set pagination off
    set print elements 0
    set logging off
    set logging file ~/state.dot
    set logging overwrite on
    set logging redirect on
    set logging on
    printf "%s\n", this->PrintViewGraph(true).c_str()
    set logging off
    shell dot -Tsvg -o ~/state.svg ~/state.dot
    set pagination on
  end
end
63
```