blob: 728dde8b119cd2e5e7308224732b65cab9deeb34 [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
Tom Andersonf06ac382019-04-10 03:49:3811 - For GDB, see
John Palmer046f9872021-05-24 01:24:5612 [gdbinit](https://chromium.googlesource.com/chromium/src/+/main/docs/gdbinit.md),
Leonard Grey99ade232018-07-31 14:58:2513 - For LLDB, use `tools/lldb/lldb_viewg.py`
14 - For other debuggers, it should be relatively easy to adapt the
15 above scripts.
andybons22afb312015-08-31 02:24:51161. the graphViz package (http://www.graphviz.org/ - downloadable for Linux,
17 Windows and Mac), and
181. an SVG viewer (_e.g._ Chrome).
19
20## Details
andybons3322f762015-08-24 21:37:0921
22To use the tool,
23
andybons22afb312015-08-31 02:24:51241. Make sure you have 'dot' installed (part of graphViz),
Leonard Grey99ade232018-07-31 14:58:25251. run gdb/lldb on your build and
Tom Andersonf06ac382019-04-10 03:49:3826 1. For GDB see
John Palmer046f9872021-05-24 01:24:5627 [gdbinit](https://chromium.googlesource.com/chromium/src/+/main/docs/gdbinit.md),
Leonard Grey99ade232018-07-31 14:58:2528 1. For LLDB `command script import tools/lldb/lldb_viewg.py` (this can
29 be done automatically in `.lldbinit`),
andybons22afb312015-08-31 02:24:51301. stop at any breakpoint inside class `View` (or any derived class), and
311. type `viewg` at the gdb prompt.
andybons3322f762015-08-24 21:37:0932
andybons22afb312015-08-31 02:24:5133This will cause the current view, and any descendants, to be described in a
34graph which is stored as `~/state.svg` (Windows users may need to modify the
35script slightly to run under CygWin). If `state.svg` is kept open in a browser
36window and refreshed each time `viewg` is run, then it provides a graphical
37representation of the state of the views hierarchy that is always up to date.
andybons3322f762015-08-24 21:37:0938
andybons22afb312015-08-31 02:24:5139It is easy to modify the gdb script to generate PDF in case viewing with evince
40(or other PDF viewer) is preferred.
andybons3322f762015-08-24 21:37:0941
Leonard Grey99ade232018-07-31 14:58:2542If you don't use gdb or lldb, you may be able to adapt the script to work with
43your favorite debugger. The gdb script invokes
andybons3322f762015-08-24 21:37:0944
Scott Violet83d75362018-05-22 20:25:5245 views::PrintViewGraph(this)
andybons22afb312015-08-31 02:24:5146
47on the current object, returning `std::string`, whose contents must then be
48saved to a file in order to be processed by dot.