[ << Programming work ] | [Top][Contents][Index][ ? ] | [ Release work >> ] | ||
[ < Debugging Scheme code ] | [ Up : Programming work ] | [ Adding or modifying features > ] |
10.8 Tracing object relationships
Understanding the LilyPond source often boils down to figuring out what is happening to the Grobs. Where (and why) are they being created, modified and destroyed? Tracing Lily through a debugger in order to identify these relationships can be time-consuming and tedious.
In order to simplify this process, a facility has been added to display the grobs that are created and the properties that are set and modified. Although it can be complex to get set up, once set up it easily provides detailed information about the life of grobs in the form of a network graph.
Each of the steps necessary to use the graphviz utility is described below.
- Installing graphviz
In order to create the graph of the object relationships, it is first necessary to install Graphviz. Graphviz is available for a number of different platforms:
http://www.graphviz.org/Download..php
- Modifying config.make
In order for the Graphviz tool to work, config.make must be modified. It is probably a good idea to first save a copy of config.make under a different name.
In order to have the required functionality available, LilyPond needs to be compiled with the option ‘-DDEBUG’. You can achieve this by configuring with
./configure --enable-checking
- Rebuilding LilyPond
The executable code of LilyPond must be rebuilt from scratch:
make clean && make
- Create a graphviz-compatible ‘.ly’ file
In order to use the graphviz utility, the ‘.ly’ file must include ‘ly/graphviz-init.ly’, and should then specify the grobs and symbols that should be tracked. An example of this is found in ‘input/regression/graphviz.ly’.
- Run LilyPond with output sent to a log file
The Graphviz data is sent to stderr by LilyPond, so it is necessary to redirect stderr to a logfile:
lilypond graphviz.ly 2> graphviz.log
- Edit the logfile
The logfile has standard LilyPond output, as well as the Graphviz output data. Delete everything from the beginning of the file up to but not including the first occurrence of
digraph
.Also, delete the final LilyPond message about success from the end of the file.
- Process the logfile with
dot
The directed graph is created from the log file with the program
dot
:dot -Tpdf graphviz.log > graphviz.pdf
The pdf file can then be viewed with any pdf viewer.
When compiled with ‘-DDEBUG’, LilyPond may run slower
than normal. The original configuration can be restored by rerunning
./configure
with ‘--disable-checking’. Then
rebuild LilyPond with
make clean && make
[ << Programming work ] | [Top][Contents][Index][ ? ] | [ Release work >> ] | ||
[ < Debugging Scheme code ] | [ Up : Programming work ] | [ Adding or modifying features > ] |