Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inspect-in-frame using wrong package? #58

Open
phmarek opened this issue Apr 9, 2017 · 8 comments
Open

inspect-in-frame using wrong package? #58

phmarek opened this issue Apr 9, 2017 · 8 comments

Comments

@phmarek
Copy link

phmarek commented Apr 9, 2017

When in the debugger, I can inspect local variables of functions from the backtrace.

But it should also be possible to inspect arbitrary forms using these variables; eg., with the cursor on a local variable DATA, I should be able to run SlimvInspect for an expression like (1+ DATA).

Thank you very much for the progress here... SLIMV is getting more and more awesome!

@kovisoft
Copy link
Owner

kovisoft commented Apr 9, 2017

Strange, it works for me, but it may be lisp implementation dependent. I tried with sbcl and evaluated the form (+ SB-DEBUG::ARG-2 1) in frame 11 (where this local variable was defined) and it just displayed the correct result. Is is possible that your swank server simply did not implement swank:inspect-in-frame? What swank server do you use with what lisp implementation?

@phmarek
Copy link
Author

phmarek commented Apr 10, 2017

SBCL 1.3.14 on Debian amd64.

And when I got asked about the expression to evaluate I didn't use SB-DEBUG::ARG, but the variable name within a form.
Perhaps slimv should embed the user-provided form into a

(macrolet
  ((data sb-debug::arg-1)
   (var2 sb-debug::arg-2))
   <expression>)

to be safe against all and every transformations that might happen (including macros etc.)

@kovisoft
Copy link
Owner

How the swank debugger handles local variables depends on the lisp implementation and the optimize settings. In sbcl normally you see variables referenced as SB-DEBUG::ARG-n (or may not see at all). But if you use this optimize setting (and recompile your code) then you'll see and be able to use your variable names:

(declaim (optimize (debug 3)))

@phmarek
Copy link
Author

phmarek commented Apr 10, 2017

Yeah, I've got that in my ~/.sbclrc.

@kovisoft
Copy link
Owner

And does it work that way? If not, did you try to add this line directly to your source code?

Even if it does not work with sbcl, I think it's more a swank/lisp implementation issue, slimv cannot possibly do much when the swank server hides variables/variable names.

@phmarek
Copy link
Author

phmarek commented Apr 10, 2017

Well, I tested right now.
FILTER I can inspect, but (IDENTITY FILTER) gives me this error (Yeah, still another problem. Brrr.):

Inspect in frame 0 (evaluated): (identity FILTER)Fehler beim Ausführen von "function SlimvInspect[28]..SlimvRefreshReplBuffer[12]..SlimvSwankResponse[3]..provider#python3#Call":
Zeile   18:                                                                                                                                                                                              
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/marek/.config/nvim//bundle/slimv/ftplugin/swank.py", line 1352, in swank_output
    append_repl(result, 0)
  File "/home/marek/.config/nvim//bundle/slimv/ftplugin/swank.py", line 1311, in append_repl
    buf.append(lines[1:])
  File "/usr/local/lib/python3.5/dist-packages/neovim/api/buffer.py", line 90, in append
    return self.request('nvim_buf_set_lines', index, index, True, lines)
  File "/usr/local/lib/python3.5/dist-packages/neovim/api/common.py", line 44, in request
    return self._session.request(name, self, *args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/neovim/api/nvim.py", line 131, in request
    res = self._session.request(name, *args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/neovim/msgpack_rpc/session.py", line 98, in request
    raise self.error_wrapper(err)
neovim.api.nvim.NvimError: b'Vim:E315: ml_get: unzul\xc3\xa4ssige lnum: 28'

followed by the normal swank debugger window saying

The variable FILTER is unbound.
  [Condition of type UNBOUND-VARIABLE]

...

Backtrace:
  0: ((LAMBDA (#:G836)) #<unused argument>)
  1: (SWANK/BACKEND:EVAL-IN-FRAME (IDENTITY FILTER) 0)
  2: ((LAMBDA NIL :IN SWANK:INSPECT-IN-FRAME))
  3: (SWANK::CALL-WITH-RETRY-RESTART "Retry SLIME inspection request." #<CLOSURE (LAMBDA NIL :IN SWANK:INSPECT-IN-FRAME) {100833DA9B}>)
  4: ((LAMBDA NIL :IN SWANK:INSPECT-IN-FRAME))
  5: (SWANK/BACKEND:CALL-WITH-SYNTAX-HOOKS #<CLOSURE (LAMBDA NIL :IN SWANK:INSPECT-IN-FRAME) {100833DA7B}>)
  6: (SWANK::CALL-WITH-BUFFER-SYNTAX NIL #<CLOSURE (LAMBDA NIL :IN SWANK:INSPECT-IN-FRAME) {100833DA7B}>)
  7: (SWANK:INSPECT-IN-FRAME "(identity FILTER)" 0)
  8: (SB-INT:SIMPLE-EVAL-IN-LEXENV (SWANK:INSPECT-IN-FRAME "(identity FILTER)" 0) #<NULL-LEXENV>)
  9: (EVAL (SWANK:INSPECT-IN-FRAME "(identity FILTER)" 0))
 10: (SWANK:EVAL-FOR-EMACS (SWANK:INSPECT-IN-FRAME "(identity FILTER)" 0) "COMMON-LISP-USER" 21)
 11: ((FLET #:FORM-FUN-6967 :IN SWANK::SLDB-LOOP))

This is slime-v2.18 from quicklisp, no newer version available.

@kovisoft
Copy link
Owner

Did you recompile your lisp code after adding the optimize option? Did you try to evaluate in the proper frame?

I did the below and it worked for me, using sbcl 1.3.1 and swank 2.19 (the one embedded in slimv).
This was my test.lisp code:

(declaim (optimize (debug 3)))

(defun test (x)
  (/ x 0))

(test 7)

I loaded it into vim, connected the swank server, then compiled and loaded the source test.lisp (by pressing ,L). It immediately dropped me into the debugger because of the division by zero. Here I located frame of the call (test 7) [it was frame 1], opened it by pressing Enter, then inspected (identity x) that dropped me into the inspect buffer displaying value 7, etc.

@phmarek
Copy link
Author

phmarek commented Apr 10, 2017

After updating to slime-2.19 (from QL) (which is a complete different adventure, again) trying (identity ...) I now get

The variable CVAR is unbound.
   [Condition of type UNBOUND-VARIABLE]

So something's amiss. Sorry for the noise...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants