0
Files
src/docs/graphical_debugging_aid_chromium_views.md
Tom Anderson f06ac3891c Make //tools/gdb easier to use
//tools/gdb was broken up into several different files that developers had to
source manually.  This change makes it so that all files get pulled in by
//tools/gdb/gdbinit, and also updates the documentation to point to a common
location for using gdbinit.

BUG=929992
R=thakis

Change-Id: Iea6c015a919b5615c0860e78ada246d7dbb5a278
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1538564
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Auto-Submit: Thomas Anderson <thomasanderson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#649401}
2019-04-10 03:49:38 +00:00

1.9 KiB

Graphical Debugging Aid for Chromium Views

Introduction

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

  1. The function views::PrintViewGraph() (in the file ui/views/debug_utils.h),
  2. a custom debugger command
  • For GDB, see gdbinit,
  • For LLDB, use tools/lldb/lldb_viewg.py
  • For other debuggers, it should be relatively easy to adapt the above scripts.
  1. the graphViz package (http://www.graphviz.org/ - downloadable for Linux, Windows and Mac), and
  2. an SVG viewer (e.g. Chrome).

Details

To use the tool,

  1. Make sure you have 'dot' installed (part of graphViz),
  2. run gdb/lldb on your build and
    1. For GDB see gdbinit,
    2. For LLDB command script import tools/lldb/lldb_viewg.py (this can be done automatically in .lldbinit),
  3. stop at any breakpoint inside class View (or any derived class), and
  4. type viewg 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 or lldb, you may be able to adapt the script to work with your favorite debugger. The gdb script invokes

views::PrintViewGraph(this)

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