Clone wiki

dinv / Dump Annotations


Dump annotations are used to trigger both the static analysis of source code, and the injection of logging statements. Logging statements encode a set of variables, their names, values, and the time they were collected. The line number logged by the dump code, is the line number the dump statement resided on in the original source, no the instrumented code. The variables logged by a dump statement are comprised of only variables in the scope of the dump statement, This includes global variables, function parameters, and variables declared before the statements at the same block level.


This example demonstrates the functions injected by the instrumenter at dump statements, along with the variables collected.

    0   func doit( foo int) {
    1       bar := 2 * foo
    2       //@dump
    3       return bar - foo
    4   }

Post Instrumentation

    0   func doit( foo int) {
    1       bar := 2 * foo
    2       inject.InstrumenterInit()
    3       2_vars :=interface{}{foo,bar}
    4       2_varname := []string{"foo","bar"}
    5       p_2 := inject.CreatePoint(2_vars,2_varname,"2",instrumenter.GetLogger(),instrumenter.GetStamp())
    6       inject.Encode.Encdoe(p_2)
    7       inject.ReadableLog.WriteString(p_2.String())
    8       return bar - foo
    9   }