Is there a simple method for writing traces from multiple sb

Discussion of Common Lisp
Post Reply
pTymN
Posts: 20
Joined: Sat Jun 28, 2008 7:15 am
Location: Columbia, SC
Contact:

Is there a simple method for writing traces from multiple sb

Post by pTymN » Fri Sep 03, 2010 9:31 am

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?

ramarren
Posts: 613
Joined: Sun Jun 29, 2008 4:02 am
Location: Warsaw, Poland
Contact:

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

Post by ramarren » Fri Sep 03, 2010 9:42 am

This is a Swank feature. See the documention.

pTymN
Posts: 20
Joined: Sat Jun 28, 2008 7:15 am
Location: Columbia, SC
Contact:

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

Post by pTymN » Fri Sep 03, 2010 12:16 pm

Thank you!

pseudo-cat
Posts: 6
Joined: Thu Sep 02, 2010 3:53 pm
Location: Russia

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

Post by pseudo-cat » Fri Sep 03, 2010 2:53 pm

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?

ramarren
Posts: 613
Joined: Sun Jun 29, 2008 4:02 am
Location: Warsaw, Poland
Contact:

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

Post by ramarren » Fri Sep 03, 2010 11:19 pm

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.

pseudo-cat
Posts: 6
Joined: Thu Sep 02, 2010 3:53 pm
Location: Russia

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

Post by pseudo-cat » Sat Sep 04, 2010 1:38 am

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).

Post Reply