Thanks for the hint.

After you connect Slime to the remote Lisp, use m-x slime-iist-threads. In the buffer listing all the threads in the remote Lisp, type “d” on the line of the thread you’re interested in and SLDB will activate on that thread. (Typing “d” runs slime-debug-thread which gets which thread to debug based on the current line in the thread list.)

  - Gary


On May 2, 2023, at 1:13 AM, Christopher Stacy <cstacy@dtpq.com> wrote:

Hi there!

I am no slime expert.


As a baseline, here's what happens when
I use slime from Emacs 28.2, CCL 1.12 DarwinX8664.

; SLIME 2.26.1
CL-USER> (ql:quickload "bt-semaphore")
CL-USER> (not (null (member :thread-support *features*)))
T
CL-USER>  bt:*supports-threads-p*
T
CL-USER> (defvar *loser
       (bt:make-thread
        (lambda ()
              (sleep 5)
              (error "tired of you"))))
*LOSER
CL-USER>

That subsequently pops up an sldb window
in the erring thread. This is what we want
to happen remotely, too.

What I've read suggests that it's supposed to
automagically work remotely, too.
Your standalone app should call
swank:create-server
before calling bc:make-thread.

I tried that (with the same program above)
from a shell:

  % ccl64 --load /tmp/test.lisp
  ;; Swank started at port: 4006.
  ?
  > Error: tired of you
  > While executing: #<Anonymous Function #x302000C99B6F>, in process Anonymous thread(4).
  ;;;
  ;;; #<PROCESS Anonymous thread(4) [Active] #x302000C996ED> requires access to Shared Terminal Input
  ;;; Type (:y 4) to yield control to this thread.
  ;;;

Back in Emacs I did:  m-x slime-connect.

That worked, but warned me that I had
a different version of slime than the
remote end. I can see the erring thread
over there (I have no local inferior lisp):

; SLIME 2.26.1
CL-USER> *loser
#<PROCESS Anonymous thread(4) [semaphore wait] #x302000C996ED>

Then I did:      m-x slime-thread-debug
which is a command I discovered from
emacs command completion fishing.

That blew me into the debugger in Emacs.
There was no corresponding visible output
on the remote test/erring program in bash.
Here are the slime events:

(swank:debug-nth-thread nil)
 "COMMON-LISP-USER" :repl-thread 5)
(:debug 12 1
    ("The value NIL is not of the expected type UNSIGNED-BYTE." "   [Condition of type TYPE-ERROR]" nil)
    (("USE-VALUE" "Use a new value of type UNSIGNED-BYTE instead of NIL.")

which I imagine is due to the incompatible
versions of slime/swank I was trying to use.
Or maybe I am using the wrong command.
But it looked like it was supposed to work!

THat's the first time I've tried anything
like this in many years, and it's all I know.
Hopefully someone with a clue will come
along here shortly.

One final note. Apparently there is a wrinkle for sbcl threads.
https://stackoverflow.com/questions/41502921/handling-an-exception-in-a-thread

Hope my experiment helps you at all.