debug.nas add callback to breakpoint
This commit is contained in:
parent
224ceaa546
commit
9c9fb23f55
1 changed files with 12 additions and 5 deletions
|
@ -452,6 +452,7 @@ var isnan = func {
|
|||
#
|
||||
# #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
|
||||
#
|
||||
|
@ -500,13 +501,19 @@ var Breakpoint = {
|
|||
},
|
||||
|
||||
# hit the breakpoint, e.g. do backtrace if we have tokens available
|
||||
hit: func() {
|
||||
hit: func(callback = nil) {
|
||||
me.hits += 1;
|
||||
me._hitsN.setIntValue(me.hits);
|
||||
me.tokens = me._tokensN.getValue();
|
||||
if (me.tokens > 0) {
|
||||
me.tokens -= 1;
|
||||
if (typeof(callback) == "func") {
|
||||
callback(me.hits, me.tokens);
|
||||
}
|
||||
else {
|
||||
debug.backtrace(me.label, me.dump_locals, 1);
|
||||
me._tokensN.setValue(me.tokens - 1);
|
||||
}
|
||||
me._tokensN.setValue(me.tokens);
|
||||
}
|
||||
return me;
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue