Skip to content
Martin Schulze edited this page Feb 28, 2014 · 3 revisions

This is a short how to for using Templar as template debugger. Most of the information has been extracted from this talk: ​https://www.youtube.com/watch?v=i0bzwHBiNc4

After loading a trace (File -> Open Trace) the source code of the compiled file will be visible.

The buttons "Rewind" (Image of the rewind button in Templar) and "Fast Forward" (Image of the fast forward button in Templar) allow to jump to the start and end of all instantiations. With the help of "Previous step" (Image of the step back button in Templar) and "Next step" (Image of the step forward button in Templar) one can step backwards and forwards through instantiations. If the follow node button (Follow node button in Templar) is activated (pressed in), the graph will automatically center on the node of the current event while stepping. Else, it will stay at the current position.

In the graph view the whole instantiation graph can be seen:

An example graph midway through instaniation

In this graph the nodes signify template instantiations (angle boxes) or memoizations (ellipses). Edges show the dependency of one template on another. The color of a node indicates the current status of the template instantiation/memoization: Grey means the node has not yet been reached. Orange means the node is being instaniated (right now). Green means the node has been instantiated. The blue border on a node means that it was selected (by clicking on it).

While stepping through the instantiation the code browser will show the relevant section of the source code. Below the source code browser the type of the current event (Begin/End? of instantiation), the kind (Instantiation, Memoization), the name and the file position of the relevant code are displayed. Besides this a list of all instantiations that have begun but not yet ended is shown (you can select them to jump to them in the graph/source code browser)

You can add a breakpoint by clicking on the button "Breakpoint". A dialog will pop up that allows you to manage existing breakpoints and add new ones. A breakpoint is a regex that is tested on each event of an instantiation/memoization and if it matches the name of the template of this exent, program breaks. Instead of stepping through the program you now can add the breakpoint and fast forward/rewind to the breakpoints.

When dealing with realworld programs (that use the stdlib) we get much more instantiations than only those we are interested in. Filtering allows us to skip templates that match the [expression](http://qt-project.org/doc/qt-4.8/qregexp.html#details regular) we entered in the filter.

If you select a node prior to clicking on the "Filter" button the nodes text will be inserted as (escaped) regex.

FAQ

Q: Can I set breakpoints on lines?
A: No, the regex is only matched against the template name. However, you can try to build a regex representing the line.

Clone this wiki locally