Skip to content
jgevargi edited this page Aug 5, 2015 · 5 revisions

Usage Examples

Example 1

1. Attach measurer to process with PID 1590.

(set_target 1590)

2. Send the attester (me) the callstack right now.

(measure (callstack))

Response : M{type:0,data=CG{(main (foo (bar (print)) print) (bar (print))))}}

3. Store a measurement of variable A in function main.

To do this, we must create a hook which requires an event (aka trigger) and an action (a lazy expression). The event will be a reach on "main", (reach "main" 0), and the action will be lazy expression, '(store 1 (measure (var "A"))). note: Lazy expressions are denoted as follows: '<expr>

(hook (reach "main" 0 0) '(store 1 (measure (var "A"))))

4. Send the attester (me) the stored measurement in store 1.

(load 1)

Response : M{type:1,data="37"}

5. Close the measurer.

(quit)

Function Tables

Admin / Setup

Function Arguments Return Description
detach - VOID Detaches measurer from target.
quit - VOID Terminates measurer.
set_target STRING pid VOID Attaches measurer to a process by pid.

Measurement

Function Arguments Return Description
callstack - FEATURE Returns a the callstack feature.
load INT store_id MEASUREMENT Loads measurements in a store.
measure FEATURE f MEASUREMENT Measures a specific feature of target.
measure_callstack - MEASUREMENT Measures callstack of target.
mem STRING address, STRING format FEATURE Creates a feature for a specific memory address to be interpreted with a specific format.
store INT store_id, MEASUREMENT m VOID Stores a measurement away in a store.
var STRING var_name FEATURE Creates a feature for a specific target variable, by source code variable name.

Events and Hooks

Function Arguments Return Description
delay INT delay, INT repeat EVENT Creates a timed event to delay for a specified time.
disable INT hook_id VOID Disables a hook.
enable INT hook_id VOID Enables a hook.
hook EVENT e, Expression a INT Creates a hook that associates an expression to evaluate when an event happens.
kill INT hook_id VOID Kill a hook.
reach STRING source_file, INT source_line, INT repeat EVENT Creates an event upon target reaching a specified code location, by source file and line number.
reach_func STRING func_name, INT repeat EVENT Creates an event upon target reaching a specified function, by source funciton name.

Generic

Function Arguments Return Description
eq INT, INT INT Evaluates the equivalence of the arguments.
if INT, Anything, Anything Anything
seq Expression, ... VOID Evaluates arguments in sequence.

Debug

Function Arguments Return Description
gdb STRING command VOID Executes a GDB command.
print Anything VOID Prints Anything to the screen.
print_context - VOID Prints a bunch of info about the measurer's state.

Function Details

hook

(hook <Event *e*> <Expression *a*>) -> <INT *hook_id*> Creates a hook that associates an expression to evaluate when an event happens.

Examples: (hook (reach "foo" 0) '(print "I'm at foo!"))