Page 1 of 1

Is there a simple method for writing traces from multiple sb

Posted: Fri Sep 03, 2010 9:31 am
by pTymN
Using SBCL, I'm writing a small server and I would like to trace the server thread, but when I use mclide/swank, I do not see any output from the server thread.

Code: Select all

? (require 'sb-posix) 
NIL 
? (sb-thread:make-thread (lambda () (format t "hi from the thread")))
#<SB-THREAD:THREAD FINISHED values: NIL {10041ABC31}>
?
When I try the same thing from sbcl directly, I see what I expect:

Code: Select all

* (require 'sb-posix)

; loading system definition from
; /opt/local/var/macports/software/sbcl/1.0.39_0+html+threads/opt/local/lib/sbcl/sb-grovel/sb-grovel.asd
; into #<PACKAGE "ASDF1">
; registering #<SYSTEM SB-GROVEL {10030F8371}> as SB-GROVEL
("SB-POSIX" "SB-GROVEL" "ASDF")
* (sb-thread:make-thread (lambda () (format t "hi from the thread")))
hi from the thread#<SB-THREAD:THREAD FINISHED values: NIL {1002BBC0E1}>
* 
Does swank have issues capturing standard output from non-foreground threads? If I used slime, would this kind of thing work?

Re: Is there a simple method for writing traces from multiple sb

Posted: Fri Sep 03, 2010 9:42 am
by ramarren
This is a Swank feature. See the documention.

Re: Is there a simple method for writing traces from multiple sb

Posted: Fri Sep 03, 2010 12:16 pm
by pTymN
Thank you!

Re: Is there a simple method for writing traces from multiple sb

Posted: Fri Sep 03, 2010 2:53 pm
by pseudo-cat
sorry, I have a question,
normally if I bind *standard-output* to another symbol on global environment? as is:

Code: Select all

CL-USER> (defparameter *std-out* *standard-output*)
*STD-OUT*
CL-USER> (sb-thread:make-thread #'(lambda () 
				    (let ((*standard-output* *std-out*))
				      (print 123))))

123 #<SB-THREAD:THREAD RUNNING {B097991}>
CL-USER> (sb-thread:make-thread #'(lambda () 
				    (print 123 *std-out*)))


123 #<SB-THREAD:THREAD FINISHED values: 123 {B0FB241}>
CL-USER> 
In my programs code i did like this. It is'nt bad hack?

Re: Is there a simple method for writing traces from multiple sb

Posted: Fri Sep 03, 2010 11:19 pm
by ramarren
I am not exactly sure what you are asking, but *standard-output* is a standard special variable, and can be rebound as any other. Note that in SBCL at least special bindings are thread-local, but inherited.

Re: Is there a simple method for writing traces from multiple sb

Posted: Sat Sep 04, 2010 1:38 am
by pseudo-cat
I meant normally if I don't set *globally-redirect-io* but use another binding to *standrard-output* (*standrard-output* on the time create thread).