Skip to content

Commit

Permalink
TRACE1 and TRACE instrument a word for one-shot and multi-shot tracin…
Browse files Browse the repository at this point in the history
…g respectively
  • Loading branch information
davazp committed Apr 4, 2012
1 parent 4dc0ba2 commit 5b13926
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions debugger.fs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ struct
cell field breakpoint-byte
cell field breakpoint-previous
cell field breakpoint-next
cell field breakpoint-oneshot?
end-struct breakpoint%

: breakpoint-enable? ( breakpoint -- )
Expand All @@ -52,16 +53,15 @@ end-struct breakpoint%
repeat
nip ;

: install-breakpoint ( nt addr -- )
dup find-breakpoint if 2drop
else
: install-breakpoint ( nt addr -- breakpoint%|0 )
dup find-breakpoint if 2drop 0 else
breakpoint% allocate throw
tuck breakpoint-addr !
tuck breakpoint-nt !
last-breakpoint @ over breakpoint-next !
0 over breakpoint-previous !
dup last-breakpoint !
enable-breakpoint
dup enable-breakpoint
endif ;

: delete-breakpoint ( breakpoint% -- )
Expand All @@ -74,12 +74,6 @@ end-struct breakpoint%
dup disable-breakpoint
free throw ;

: uninstall-breakpoint ( addr )
find-breakpoint ?dup if
dup disable-breakpoint
delete-breakpoint
endif ;

: breakpoints
last-breakpoint @
begin dup while
Expand All @@ -92,7 +86,13 @@ variable reseting-breakpoing

: debug-exception ( isrinfo -- )
[ $100 invert ]L over isrinfo-eflags and!
reseting-breakpoing @ ?dup if enable-breakpoint endif
reseting-breakpoing @ ?dup if
dup breakpoint-oneshot? @ if
reseting-breakpoing 0!
else
enable-breakpoint
endif
endif
; 1 ISR

: traced-function-hook ( nt -- )
Expand All @@ -111,7 +111,17 @@ variable reseting-breakpoing
breakpoint-addr @ swap isrinfo-eip !
; 3 ISR

: trace nt' dup nt>xt install-breakpoint ;
: untrace ' uninstall-breakpoint ;

: parse-and-trace
nt' dup nt>xt install-breakpoint
dup 0= if ." This word is being traced." CR endif ;

: trace parse-and-trace drop ;
: trace1 parse-and-trace breakpoint-oneshot? on ;

: untrace '
find-breakpoint ?dup if
delete-breakpoint
else ." This word is not traced." CR endif ;

\ debugger.fs ends here

0 comments on commit 5b13926

Please sign in to comment.