Re: Debugging an existing error

Gary Palter <[email protected]> Tue, 2 May 2023 09:19:38 -0400
Newsgroups gmane.lisp.slime.devel
Message-ID <[email protected]>
--Apple-Mail=_3AD6F431-4D54-48CB-88B7-5B8A02C7EA05
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=utf-8

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 =E2=80=9Cd=E2=
=80=9D on the line of the thread you=E2=80=99re interested in and SLDB =
will activate on that thread. (Typing =E2=80=9Cd=E2=80=9D 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 <[email protected]> wrote:
>=20
> Hi there!
>=20
> I am no slime expert.
>=20
>=20
> As a baseline, here's what happens when
> I use slime from Emacs 28.2, CCL 1.12 DarwinX8664.
>=20
> ; 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>
>=20
> That subsequently pops up an sldb window
> in the erring thread. This is what we want
> to happen remotely, too.
>=20
> 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.
>=20
> I tried that (with the same program above)
> from a shell:
>=20
>   % 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.
>   ;;;
>=20
> Back in Emacs I did:  m-x slime-connect.
>=20
> 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):
>=20
> ; SLIME 2.26.1
> CL-USER> *loser
> #<PROCESS Anonymous thread(4) [semaphore wait] #x302000C996ED>
>=20
> Then I did:      m-x slime-thread-debug
> which is a command I discovered from
> emacs command completion fishing.
>=20
> 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:
>=20
> (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.")
>=20
> 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!
>=20
> 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.
>=20
> One final note. Apparently there is a wrinkle for sbcl threads.
> =
https://stackoverflow.com/questions/41502921/handling-an-exception-in-a-th=
read
>=20
> Hope my experiment helps you at all.
>=20
>=20


--Apple-Mail=_3AD6F431-4D54-48CB-88B7-5B8A02C7EA05
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
	charset=utf-8

<html><head><meta http-equiv=3D"content-type" content=3D"text/html; =
charset=3Dutf-8"></head><body style=3D"overflow-wrap: break-word; =
-webkit-nbsp-mode: space; line-break: after-white-space;">Thanks for the =
hint.<div><br></div><div>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 =E2=80=9Cd=E2=80=9D on the line of the thread you=E2=80=99=
re interested in and SLDB will activate on that thread. (Typing =E2=80=9Cd=
=E2=80=9D runs slime-debug-thread which gets which thread to debug based =
on the current line in the thread list.)</div><div><br><div>
<div>&nbsp; - Gary</div><div><br class=3D"khtml-block-placeholder"></div>

</div>
<div><br><blockquote type=3D"cite"><div>On May 2, 2023, at 1:13 AM, =
Christopher Stacy &lt;[email protected]&gt; wrote:</div><br =
class=3D"Apple-interchange-newline"><div><div>Hi there!<br><br>I am no =
slime expert.<br><br><br>As a baseline, here's what happens when<br>I =
use slime from Emacs 28.2, CCL 1.12 DarwinX8664.<br><br>; SLIME =
2.26.1<br>CL-USER&gt; (ql:quickload "bt-semaphore")<br>CL-USER&gt; (not =
(null (member :thread-support *features*)))<br>T<br>CL-USER&gt;&nbsp; =
bt:*supports-threads-p*<br>T<br>CL-USER&gt; (defvar =
*loser<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
(bt:make-thread<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; (lambda =
()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp; (sleep =
5)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp; (error "tired of =
you"))))<br>*LOSER<br>CL-USER&gt;<br><br>That subsequently pops up an =
sldb window<br>in the erring thread. This is what we want<br>to happen =
remotely, too.<br><br>What I've read suggests that it's supposed =
to<br>automagically work remotely, too.<br>Your standalone app should =
call<br>swank:create-server<br>before calling bc:make-thread.<br><br>I =
tried that (with the same program above)<br>from a shell:<br><br>&nbsp; =
% ccl64 --load /tmp/test.lisp<br>&nbsp; ;; Swank started at port: =
4006.<br>&nbsp; ?<br>&nbsp; &gt; Error: tired of you<br>&nbsp; &gt; =
While executing: #&lt;Anonymous Function #x302000C99B6F&gt;, in process =
Anonymous thread(4).<br>&nbsp; ;;;<br>&nbsp; ;;; #&lt;PROCESS Anonymous =
thread(4) [Active] #x302000C996ED&gt; requires access to Shared Terminal =
Input<br>&nbsp; ;;; Type (:y 4) to yield control to this =
thread.<br>&nbsp; ;;;<br><br>Back in Emacs I did:&nbsp; m-x =
slime-connect.<br><br>That worked, but warned me that I had<br>a =
different version of slime than the<br>remote end. I can see the erring =
thread<br>over there (I have no local inferior lisp):<br><br>; SLIME =
2.26.1<br>CL-USER&gt; *loser<br>#&lt;PROCESS Anonymous thread(4) =
[semaphore wait] #x302000C996ED&gt;<br><br>Then I =
did:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m-x slime-thread-debug<br>which is a =
command I discovered from<br>emacs command completion =
fishing.<br><br>That blew me into the debugger in Emacs.<br>There was no =
corresponding visible output<br>on the remote test/erring program in =
bash.<br>Here are the slime events:<br><br>(swank:debug-nth-thread =
nil)<br>&nbsp;"COMMON-LISP-USER" :repl-thread 5)<br>(:debug 12 =
1<br>&nbsp;&nbsp; &nbsp;("The value NIL is not of the expected type =
UNSIGNED-BYTE." "&nbsp;&nbsp; [Condition of type TYPE-ERROR]" =
nil)<br>&nbsp;&nbsp; &nbsp;(("USE-VALUE" "Use a new value of type =
UNSIGNED-BYTE instead of NIL.")<br><br>which I imagine is due to the =
incompatible<br>versions of slime/swank I was trying to use.<br>Or maybe =
I am using the wrong command.<br>But it looked like it was supposed to =
work!<br><br>THat's the first time I've tried anything<br>like this in =
many years, and it's all I know.<br>Hopefully someone with a clue will =
come<br>along here shortly.<br><br>One final note. Apparently there is a =
wrinkle for sbcl =
threads.<br>https://stackoverflow.com/questions/41502921/handling-an-excep=
tion-in-a-thread<br><br>Hope my experiment helps you at =
all.<br><br><br></div></div></blockquote></div><br></div></body></html>=

--Apple-Mail=_3AD6F431-4D54-48CB-88B7-5B8A02C7EA05--