A simple debugging tool exists to help visualize the views tree during debugging. It consists of 4 components:
View::PrintViewGraph()
(already in the file view.cc
if you‘ve sync’d recently),viewg.gdb
(see below),To use the tool,
TOUCH_DEBUG
and compile chrome with Views enabled,source viewg.gdb
(this can be done automatically in .gdbinit
),View
(or any derived class), andviewg
at the gdb prompt.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.
It is easy to modify the gdb script to generate PDF in case viewing with evince (or other PDF viewer) is preferred.
If you don't use gdb, you may be able to adapt the script to work with your favorite debugger. The gdb script invokes
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.
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