Skip to main content
Version: 1.1.0

Read your first trace

Follow two calls to a pure function, using a local program.

1. Write the program​

Create lecture.tb:

module lecture

function Label
takes value as Int
gives Text
do
give "Item " ++ text(value)

strategy Run
gives Text
do
Label
with value as 1
into first
Label
with value as 2
into second
show
with message as first ++ ", " ++ second
give "done"

2. Run and inspect​

touba compile lecture.tb --out lecture.air.json
touba run lecture.air.json --entry strategy:lecture/Run --trace-out lecture.trace.json
touba inspect lecture.trace.json

The program displays Item 1, Item 2 and returns done. The inspector summarizes the execution and its notable events.

To follow both calls in detail, open lecture.trace.json in your editor, or use Touba: Render Trace in VS Code. Find the call_started and call_completed events for Label: their sequence and context distinguish the two calls.

3. Review the execution​

touba audit --trace lecture.trace.json --air lecture.air.json --output text

The audit reads the trace together with its compiled program. Keep these files with the matching source. In VS Code, Touba: Render Trace opens a text view; Touba: Open Trace Event Source navigates to the matching source.

Continue with Read execution traces.