Skip to main content

Variable Viewer

To produce distributional output for selected variables on a run on a C0 Reference core, you tell the platform which variables of your source code to trace. The Variable Viewer lists every variable defined in your source. Open it with Toggle variable viewer () on the editor toolbar, then click Discover to populate the list.

On a core without the Reference microarchitecture, the Variable Viewer offers to switch you to a compatible core in one click.

Each row in the list shows the variable name and, as a subtitle, the line number and source file of its declaration. Tick a row to trace that variable on the next Reference-core run. See How to Run a Reference Execution for how tracing works end to end.

For element-level traces, click Add Custom Trace to open the Add Custom Variable Trace dialog, where you enter an expression like array[1] or foo.bar along with the file and line of the base variable's declaration. To edit a custom trace, click the button at the end of its row, which reopens the dialog with the expression filled in. Untick the row to stop tracing it.

Figure 1. Opening the Variable Viewer panel and discovering variables in the source code.

Traceable variable types

The platform traces variables of float or double base type, including typedef aliases that resolve to those types. Tracing also covers individual array elements of any number of dimensions and the float or double fields of user-defined structs.

Custom trace expressions

The Add Custom Variable Trace dialog takes an expression along with the source file and the line number of the declaration of its base variable. For array[1] the base variable is array. For foo.bar it is foo. Pointer dereferences work too: foo->bar is valid as long as bar is a float or double field.

Use a colon to trace a range of array elements. array[0:3] traces array[0], array[1], array[2], and array[3]. The same notation works for dynamically allocated arrays of float or double, and across multiple dimensions: array[0:4][0:2].

A range bound cannot reference a variable. array[0:N], where N is an integer variable, is not supported. An upper bound larger than the actual array is fine. For a double *array of 64 elements, array[0:128] is a valid trace.

The platform builds a distribution from the expressions your program prints. Print the variable you want to trace, not an expression computed from it. If double seconds is printed with printf("Milliseconds = %lf\n", seconds * 1000), the platform does not produce a distribution for seconds * 1000, even when seconds is traced. Assign double milliseconds = seconds * 1000, print milliseconds, and trace that instead.