Library globals

Class globals . debug . Breakpoint

View source

Breakpoint (BP) - do conditional backtrace (BT) controlled via property tree
* count how often the BP was hit
* do only a limited number of BT, avoid flooding the log / console

Data can be viewed / modified in the prop tree /_debug/nas/bp/<myLabel>/*
* tokens: number of backtraces to do; each hit will decrement this by 1
* hits:   total number of hits

== Example == 
var myBP = debug.Breakpoint.new("myLabel", 0);
myBP.enable(4);       # allow 4 hits, then be quiet 

#at the place of interest (e.g. in some loop or class method) insert:
myBP.hit();           # do backtrace here if tokens > 0, reduce tokens by 1
myBP.hit(myFunction); # same but call myFunction instead of backtrace

print(myBP.getHits()); # print total number of hits

Functions

enable

enable BP and set hit limit; tokens: int > 0; default: 1 (single shot); 0 allowed (=disable);

hit

hit the breakpoint, e.g. do backtrace if we have tokens available

new

label: Used in property path and as text for backtrace. dump_locals: bool passed to backtrace. Dump variables in BT. skip_level: int passed to backtrace.