Working on trace tool
parent
72487f7f33
commit
7a251950d8
|
@ -69,6 +69,18 @@ M: object add-breakpoint ;
|
|||
: (step-into-call-next-method) ( method -- )
|
||||
next-method-quot (step-into-quot) ;
|
||||
|
||||
<< {
|
||||
(step-into-quot)
|
||||
(step-into-dip)
|
||||
(step-into-2dip)
|
||||
(step-into-3dip)
|
||||
(step-into-if)
|
||||
(step-into-dispatch)
|
||||
(step-into-execute)
|
||||
(step-into-continuation)
|
||||
(step-into-call-next-method)
|
||||
} [ t "no-compile" set-word-prop ] each >>
|
||||
|
||||
: change-frame ( continuation quot -- continuation' )
|
||||
#! Applies quot to innermost call frame of the
|
||||
#! continuation.
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
IN: tools.trace.tests
|
||||
USING: tools.trace tools.test sequences ;
|
||||
|
||||
[ { 3 2 1 } ] [ { 1 2 3 } [ reverse ] trace ] unit-test
|
|
@ -1,21 +1,21 @@
|
|||
! Copyright (C) 2009 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: concurrency.promises models tools.continuations kernel
|
||||
sequences concurrency.messaging locals continuations
|
||||
threads namespaces namespaces.private make assocs accessors
|
||||
io strings prettyprint math words effects summary io.styles
|
||||
classes ;
|
||||
sequences concurrency.messaging locals continuations threads
|
||||
namespaces namespaces.private make assocs accessors io strings
|
||||
prettyprint math math.parser words effects summary io.styles classes
|
||||
generic.math combinators.short-circuit ;
|
||||
IN: tools.trace
|
||||
|
||||
: callstack-depth ( callstack -- n )
|
||||
callstack>array length ;
|
||||
callstack>array length 2/ ;
|
||||
|
||||
SYMBOL: end
|
||||
|
||||
SYMBOL: exclude-vocabs
|
||||
SYMBOL: include-vocabs
|
||||
|
||||
exclude-vocabs { "kernel" "math" "accessors" } swap set-global
|
||||
exclude-vocabs { "math" "accessors" } swap set-global
|
||||
|
||||
: include? ( vocab -- ? )
|
||||
include-vocabs get dup [ member? ] [ 2drop t ] if ;
|
||||
|
@ -24,11 +24,22 @@ exclude-vocabs { "kernel" "math" "accessors" } swap set-global
|
|||
exclude-vocabs get dup [ member? ] [ 2drop f ] if ;
|
||||
|
||||
: into? ( obj -- ? )
|
||||
dup word? [
|
||||
dup predicate? [ drop f ] [
|
||||
vocabulary>> [ include? ] [ exclude? not ] bi and
|
||||
] if
|
||||
] [ drop t ] if ;
|
||||
{
|
||||
[ word? ]
|
||||
[ predicate? not ]
|
||||
[ math-generic? not ]
|
||||
[
|
||||
{
|
||||
[ inline? ]
|
||||
[
|
||||
{
|
||||
[ vocabulary>> include? ]
|
||||
[ vocabulary>> exclude? not ]
|
||||
} 1&&
|
||||
]
|
||||
} 1||
|
||||
]
|
||||
} 1&& ;
|
||||
|
||||
TUPLE: trace-step word inputs ;
|
||||
|
||||
|
@ -49,15 +60,19 @@ M: trace-step summary
|
|||
nip short.
|
||||
] if ;
|
||||
|
||||
: print-depth ( continuation -- )
|
||||
call>> callstack-depth
|
||||
[ CHAR: \s <string> write ]
|
||||
[ number>string write ": " write ] bi ;
|
||||
|
||||
: trace-step ( continuation -- continuation' )
|
||||
dup continuation-current end eq? [
|
||||
[ call>> callstack-depth 2/ CHAR: \s <string> write ]
|
||||
[ print-depth ]
|
||||
[ print-step ]
|
||||
[
|
||||
dup continuation-current into?
|
||||
[ continuation-step-into ] [ continuation-step ] if
|
||||
]
|
||||
tri
|
||||
] tri
|
||||
] unless ;
|
||||
|
||||
: trace ( quot -- data )
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
! Copyright (C) 2004, 2008 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: concurrency.promises models tools.walker kernel
|
||||
sequences concurrency.messaging locals continuations
|
||||
threads namespaces namespaces.private assocs accessors ;
|
||||
USING: concurrency.promises models tools.walker tools.continuations
|
||||
kernel sequences concurrency.messaging locals continuations threads
|
||||
namespaces namespaces.private assocs accessors ;
|
||||
IN: tools.walker.debug
|
||||
|
||||
:: test-walker ( quot -- data )
|
||||
|
|
|
@ -43,18 +43,6 @@ break-hook [
|
|||
]
|
||||
] initialize
|
||||
|
||||
<< {
|
||||
(step-into-quot)
|
||||
(step-into-dip)
|
||||
(step-into-2dip)
|
||||
(step-into-3dip)
|
||||
(step-into-if)
|
||||
(step-into-dispatch)
|
||||
(step-into-execute)
|
||||
(step-into-continuation)
|
||||
(step-into-call-next-method)
|
||||
} [ t "no-compile" set-word-prop ] each >>
|
||||
|
||||
! Messages sent to walker thread
|
||||
SYMBOL: step
|
||||
SYMBOL: step-out
|
||||
|
|
Loading…
Reference in New Issue