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

HIGHLY EXPERIMENTAL - Debugger #21

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

reubent
Copy link
Contributor

@reubent reubent commented Jul 27, 2020

Needs tidy up and some docs. Just put here for visibility for now.

@bmatsuo-at-luthersystems
Copy link
Contributor

bmatsuo-at-luthersystems commented Sep 25, 2020

I was testing out the delve debugger and got a panic in the go runtime.

elps run -d -t delve approx.lisp (connected the debugger with dlv connect localhost:8883)

approx.lisp is in the _examples/sicp/ directory.

Then I just run continue in delve without setting any breakpoints or anything. I got the following log output and stack trace:

INFO[0155] RUN
panic: runtime error: index out of range [7] with length 7

goroutine 1 [running]:
github.com/luthersystems/elps/lisp/x/debugger.(*Debugger).Start(0xc0001c4a00, 0xc0004c0360, 0xc00021c0c0)
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/lisp/x/debugger/debugger.go:197 +0x14a3
github.com/luthersystems/elps/lisp.(*LEnv).EvalSExpr(0xc00057f980, 0xc0004c0360, 0x0)
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/lisp/env.go:775 +0x2c2
github.com/luthersystems/elps/lisp.(*LEnv).Eval(0xc00057f980, 0xc0004c0360, 0x4)
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/lisp/env.go:734 +0xc0
github.com/luthersystems/elps/lisp.(*LEnv).call(0xc00057f800, 0xc00021cf60, 0xc000221080, 0x0)
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/lisp/env.go:1078 +0x264
github.com/luthersystems/elps/lisp.(*LEnv).funCall(0xc00057f800, 0xc00021cf60, 0xc000221080, 0x0)
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/lisp/env.go:914 +0x2be
github.com/luthersystems/elps/lisp.(*LEnv).FunCall(0xc00057f800, 0xc00021cf60, 0xc000221080, 0x58)
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/lisp/env.go:884 +0x3f
github.com/luthersystems/elps/lisp.(*LEnv).EvalSExpr(0xc00057f800, 0xc0004c0ba0, 0x0)
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/lisp/env.go:780 +0x283
github.com/luthersystems/elps/lisp.(*LEnv).Eval(0xc00057f800, 0xc0004c0ba0, 0xc0004c0b40)
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/lisp/env.go:734 +0xc0
github.com/luthersystems/elps/lisp.opLet(0xc00015ae40, 0xc000220a20, 0x0)
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/lisp/op.go:443 +0x207
github.com/luthersystems/elps/lisp.(*langBuiltin).Eval(0x1b30520, 0xc00015ae40, 0xc000220a20, 0x100)
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/lisp/builtins.go:39 +0x3e
github.com/luthersystems/elps/lisp.(*LEnv).call(0xc00015ae40, 0xc00025c9c0, 0xc000220840, 0x0)
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/lisp/env.go:1037 +0x427
github.com/luthersystems/elps/lisp.(*LEnv).SpecialOpCall(0xc00015ae40, 0xc00025c9c0, 0xc000220840, 0x0)
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/lisp/env.go:857 +0x1a7
github.com/luthersystems/elps/lisp.(*LEnv).EvalSExpr(0xc00015ae40, 0xc0002206c0, 0x0)
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/lisp/env.go:782 +0x217
github.com/luthersystems/elps/lisp.(*LEnv).Eval(0xc00015ae40, 0xc0004c0a80, 0xc00021d9e0)
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/lisp/env.go:734 +0xc0
github.com/luthersystems/elps/lisp.(*LEnv).load(0xc00015ae40, 0xc000072400, 0x52, 0x80, 0x0)
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/lisp/env.go:235 +0x22e
github.com/luthersystems/elps/lisp.(*LEnv).LoadLocation(0xc00015ae40, 0xc00046e5a0, 0x9, 0xc00046e5a0, 0x9, 0x1755d20, 0xc000348480, 0xc00046e5a0)
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/lisp/env.go:216 +0x174
github.com/luthersystems/elps/lisp.(*LEnv).LoadFile(0xc00015ae40, 0xc00046e5a0, 0x9, 0x1148c70)
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/lisp/env.go:171 +0x2c8
github.com/luthersystems/elps/lisp.builtinLoadFile(0xc00015ae40, 0xc00047be00, 0x0)
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/lisp/builtins.go:229 +0xb7
github.com/luthersystems/elps/lisp.(*langBuiltin).Eval(0x1b30660, 0xc00015ae40, 0xc00047be00, 0x100)
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/lisp/builtins.go:39 +0x3e
github.com/luthersystems/elps/lisp.(*LEnv).call(0xc00015ae40, 0xc00025dc80, 0xc00047bce0, 0x0)
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/lisp/env.go:1037 +0x427
github.com/luthersystems/elps/lisp.(*LEnv).funCall(0xc00015ae40, 0xc00025dc80, 0xc00047bce0, 0x0)
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/lisp/env.go:914 +0x2be
github.com/luthersystems/elps/lisp.(*LEnv).FunCall(0xc00015ae40, 0xc00025dc80, 0xc00047bce0, 0xc00047bbc0)
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/lisp/env.go:884 +0x3f
github.com/luthersystems/elps/lisp.(*LEnv).EvalSExpr(0xc00015ae40, 0xc0003d12c0, 0x0)
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/lisp/env.go:780 +0x283
github.com/luthersystems/elps/lisp.(*LEnv).Eval(0xc00015ae40, 0xc0003d12c0, 0xc00047bbc0)
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/lisp/env.go:734 +0xc0
github.com/luthersystems/elps/lisp.(*LEnv).load(0xc00015ae40, 0xc0002ea400, 0x41, 0x80, 0x0)
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/lisp/env.go:235 +0x22e
github.com/luthersystems/elps/lisp.(*LEnv).LoadLocation(0xc00015ae40, 0xc000381860, 0xb, 0xc000381860, 0xb, 0x1755d20, 0xc000348360, 0xc000381860)
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/lisp/env.go:216 +0x174
github.com/luthersystems/elps/lisp.(*LEnv).LoadFile(0xc00015ae40, 0xc000381860, 0xb, 0x1148c70)
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/lisp/env.go:171 +0x2c8
github.com/luthersystems/elps/lisp.builtinLoadFile(0xc00015ae40, 0xc0003d1080, 0x0)
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/lisp/builtins.go:229 +0xb7
github.com/luthersystems/elps/lisp.(*langBuiltin).Eval(0x1b30660, 0xc00015ae40, 0xc0003d1080, 0x100)
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/lisp/builtins.go:39 +0x3e
github.com/luthersystems/elps/lisp.(*LEnv).call(0xc00015ae40, 0xc00025dc80, 0xc0003d0f60, 0x0)
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/lisp/env.go:1037 +0x427
github.com/luthersystems/elps/lisp.(*LEnv).funCall(0xc00015ae40, 0xc00025dc80, 0xc0003d0f60, 0x0)
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/lisp/env.go:914 +0x2be
github.com/luthersystems/elps/lisp.(*LEnv).FunCall(0xc00015ae40, 0xc00025dc80, 0xc0003d0f60, 0xc0003d0e40)
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/lisp/env.go:884 +0x3f
github.com/luthersystems/elps/lisp.(*LEnv).EvalSExpr(0xc00015ae40, 0xc000346a80, 0x0)
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/lisp/env.go:780 +0x283
github.com/luthersystems/elps/lisp.(*LEnv).Eval(0xc00015ae40, 0xc000346a80, 0xc0003d0e40)
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/lisp/env.go:734 +0xc0
github.com/luthersystems/elps/lisp.(*LEnv).load(0xc00015ae40, 0xc000256a00, 0x14, 0x20, 0x0)
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/lisp/env.go:235 +0x22e
github.com/luthersystems/elps/lisp.(*LEnv).LoadLocation(0xc00015ae40, 0x7ffeefbff84d, 0xb, 0x7ffeefbff84d, 0xb, 0x1755d20, 0xc000348120, 0x7ffeefbff84d)
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/lisp/env.go:216 +0x174
github.com/luthersystems/elps/lisp.(*LEnv).LoadFile(0xc00015ae40, 0x7ffeefbff84d, 0xb, 0x1678f9a)
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/lisp/env.go:171 +0x2c8
github.com/luthersystems/elps/cmd.glob..func2(0x1b37ae0, 0xc000172300, 0x1, 0x4)
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/cmd/run.go:71 +0x495
github.com/spf13/cobra.(*Command).execute(0x1b37ae0, 0xc0001722c0, 0x4, 0x4, 0x1b37ae0, 0xc0001722c0)
        /Users/bmatsuo/go/pkg/mod/github.com/spf13/cobra@v0.0.3/command.go:766 +0x2aa
github.com/spf13/cobra.(*Command).ExecuteC(0x1b37880, 0x103cffa, 0x1af44e0, 0xc000000180)
        /Users/bmatsuo/go/pkg/mod/github.com/spf13/cobra@v0.0.3/command.go:852 +0x2ea
github.com/spf13/cobra.(*Command).Execute(...)
        /Users/bmatsuo/go/pkg/mod/github.com/spf13/cobra@v0.0.3/command.go:800
github.com/luthersystems/elps/cmd.Execute()
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/cmd/root.go:31 +0x31
main.main()
        /Users/bmatsuo/go/src/github.com/luthersystems/elps/main.go:11 +0x20

File: fmt.Sprintf("%s", source.Path),
Line: source.Line,
Function: &api.Function{
Name_: "f",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it not possible to use LEnv.GetFunName here? I noticed this in delve.

(dlv) bt
0  0x0000000000000000 in f
   at approx.lisp:5
1  0x0000000000000000 in f
   at stream.lisp:5
2  0x0000000000000000 in f
   at :0
3  0x0000000000000000 in f
   at sicp.lisp:21
4  0x0000000000000000 in f
   at sicp.lisp:14

If the function name isn't available might it be better to just use the FID from the stack from?

@reubent
Copy link
Contributor Author

reubent commented Oct 26, 2020

@bmatsuo-at-luthersystems Personally, I much prefer the JetBrains IDEs to VSCode, but since everyone I know who is using ELPS is using VSCode, I've put 99% of the effort into that. Hence, I've not done as much work on the delve version as the DAP one and would recommend that you use the DAP one - you can use it by running this version of Amir's VSCode extension https://gitlab.com/amirH.A/vscode-elps/-/merge_requests/1/diffs

The DAP version is much more stable and does pretty much everything you'd expect a debugger to do. There's a nice video of how to use it floating about - I am pretty sure Sam has it, but if not drop me an email and I'll dig it out for you.

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

Successfully merging this pull request may close these issues.

2 participants