This library provides debugging support reader macro.
This reader macro reads the next expression as followings;
(debug-print _expr_)
debug-print
is an internal macro of this library which prints the
read expression and its result.
Following example shows how to enable this;
#!read-macro=sagittarius/debug
#!debug
(let ((a (+ 1 2)))
#?=(expt a 2))
#|
#?=(expt a 2)
#?- 9
|#
#!debug
enables the debug print.
Expands given expr. The returning value may or may not be used as proper Scheme expression.
Expands given expr n times. The first form's n is 1.
This procedure expands only globally defined macro and the result of expansion
is other macro such as next rule of syntax-rules
. It doesn't consider
locally bound macros.
The returning value may or may not be used as proper Scheme expression.
Above 2 procedures are no more than debug aid. Depending on the result of expansion is not guaranteed to work.
CAVEAT This functionality and interface is subjected to be changed in the future.
When you want to debug a running script, you can use a remote debugger provided this library. Below example shows how to use it.
(import (rnrs)
(sagittarius debug))
;; Using random port
(define remote-debugger (make-remote-debugger "0"))
(print "Debugger port: " (remote-debugger-port remote-debugger))
;; Do heavy process or multi threading program which hangs :)
To connect the remote debugger, you can use simpley use
(sagittarius remote-repl)
towards the debugger node and port.
(import (rnrs)
(sagittarius remote-repl))
(connect-remote-repl "localhost" "${port number shown on the console}")
Returns #t
if the given obj is a remote debugger object.
Creates a remote debugger. The port must be an available port number,
or "0"
for random port.
Terminates the given remote-debugger.
Returns the port number of the given remote-debugger.
The bindings listed below are only available on the remote debugger's REPL.
Get a list of threads created on Scheme world.
Get a list of sleeping threads created on Scheme world.
Ssleeping thread is a thread which can't suspend within the given timeout.
[SRFI-18] Returns if the given obj is a thread.
thread?
)
[SRFI-18] Returns the name of the given thread.
thread?
)
[SRFI-18] Returns the specific value of the given thread.
Returns a human readable string representation of the given thread's backtrace.
Returns the current procedure of the thread.
thread?
)
Returns the backtrace of the given thread.
Currently, a backtrace is a list, however it may change in the future, to access the value of backtrace, use the procedures listed below.
NOTE: A backtrace starts with 1
, not zero base.
Returns the type of nth backtrace. The value is
*cproc
For C procedure.
*proc
For Scheme procedure.
Returns the procedure of the nth backtrace.
Returns the source, list of file and line number` of the nth backtrace, if available.
Returns alist of the arguments of the nth backtrace's procedure.
For local variable, the key is local
. For free variable, the key is free
.
NOTE: local
variable may contain more than the argument of the current
procedure. This is bacause it also retrieves the available local variable
of the current call frame.
Returns local
part of the nth backtrace arguments.
Returns free
part of the nth backtrace arguments.
Returns a human readable string representation of the given backtrace.
Returns the slot value of given obj.
Returns the available slots of the given obj.
Prints the given args and newline at the end.
The first form uses display
to print, the latter form uses write/ss
.
[SRFI-13] Returns #t
if the given s1 is the prefix of s2.
[SRFI-13] Returns #t
if the given s1 is the suffix of s2.