blob: b36b5636b4660bf4646ec6859127677c5202b36d [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
Scott Violet83d75362018-05-22 20:25:5281. The function `views::PrintViewGraph()` (in the file
9 `ui/views/debug_utils.h`),
Leonard Grey99ade232018-07-31 14:58:25101. a custom debugger command
11 - For GDB, use `tools/gdb/viewg.gdb`
12 - For LLDB, use `tools/lldb/lldb_viewg.py`
13 - For other debuggers, it should be relatively easy to adapt the
14 above scripts.
andybons22afb312015-08-31 02:24:51151. the graphViz package (http://www.graphviz.org/ - downloadable for Linux,
16 Windows and Mac), and
171. an SVG viewer (_e.g._ Chrome).
18
19## Details
andybons3322f762015-08-24 21:37:0920
21To use the tool,
22
andybons22afb312015-08-31 02:24:51231. Make sure you have 'dot' installed (part of graphViz),
Leonard Grey99ade232018-07-31 14:58:25241. run gdb/lldb on your build and
25 1. For GDB `source tools/gdb/viewg.gdb` (this can be done automatically
26 in `.gdbinit`),
27 1. For LLDB `command script import tools/lldb/lldb_viewg.py` (this can
28 be done automatically in `.lldbinit`),
andybons22afb312015-08-31 02:24:51291. stop at any breakpoint inside class `View` (or any derived class), and
301. type `viewg` at the gdb prompt.
andybons3322f762015-08-24 21:37:0931
andybons22afb312015-08-31 02:24:5132This will cause the current view, and any descendants, to be described in a
33graph which is stored as `~/state.svg` (Windows users may need to modify the
34script slightly to run under CygWin). If `state.svg` is kept open in a browser
35window and refreshed each time `viewg` is run, then it provides a graphical
36representation of the state of the views hierarchy that is always up to date.
andybons3322f762015-08-24 21:37:0937
andybons22afb312015-08-31 02:24:5138It is easy to modify the gdb script to generate PDF in case viewing with evince
39(or other PDF viewer) is preferred.
andybons3322f762015-08-24 21:37:0940
Leonard Grey99ade232018-07-31 14:58:2541If you don't use gdb or lldb, you may be able to adapt the script to work with
42your favorite debugger. The gdb script invokes
andybons3322f762015-08-24 21:37:0943
Scott Violet83d75362018-05-22 20:25:5244 views::PrintViewGraph(this)
andybons22afb312015-08-31 02:24:5145
46on the current object, returning `std::string`, whose contents must then be
47saved to a file in order to be processed by dot.