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

Keep sub-entries expanded when stepping through code #97

Closed
igorlfs opened this issue Apr 23, 2022 · 11 comments
Closed

Keep sub-entries expanded when stepping through code #97

igorlfs opened this issue Apr 23, 2022 · 11 comments
Labels
bug Something isn't working

Comments

@igorlfs
Copy link

igorlfs commented Apr 23, 2022

Stepping collapses sub-entries, eg
image
becomes
image

@rcarriga
Copy link
Owner

I'm not seeing the same behaviour. Can you supply a reproduction (including nvim-dap config/adapter settings)?

@igorlfs
Copy link
Author

igorlfs commented Apr 23, 2022

I'm not seeing the same behaviour.

Whoops, should have been more clear with a reproduction 😅

Can you supply a reproduction (including nvim-dap config/adapter settings)?

I've tested with 2 adapters. The original one was lldb-vscode, with the following:

adapter settings
dap.adapters.lldb = {
    type = "executable",
    command = "/usr/bin/lldb-vscode",
    name = "lldb",
}

and

config
dap.configurations.cpp = {
    {
        name = "Launch",
        type = "lldb",
        request = "launch",
        program = vim.fn.getcwd() .. "/binary",
        cwd = vim.fn.getcwd(),
        stopOnEntry = false,
    },
}

Additionally, I also decided to test with debugpy:

(adapter settings)
dap.adapters.python = {
    type = "executable";
    command = "/usr/bin/python3";
    args = { "-m", "debugpy.adapter" };
}
(config)
dap.configurations.python = {
    {
        type = "python";
        request = "launch";
        name = "Launch file";

        program = "${file}";
        pythonPath = "/usr/bin/python"
    },
}

With debugpy, I observed a different behavior: while sub-entries don't get collapsed when stepping, they also don't get updated, needing to be manually closed and opened to become so. To reproduce this issue, you can create a simple python file, e.g.

rows = 3
cols = 2
b = [[1, 2], [2, 1], [0, 1]]
for i in range(rows):
    for j in range(cols):
        b[i][j] += 1

Set a breakpoint at the last line, watch 'b' (expanding its members) and step with require'dap'.continue(). Using C++ coupled with lldb-vscode requires a similar setup.

@rcarriga rcarriga added the bug Something isn't working label Apr 27, 2022
rcarriga added a commit that referenced this issue Jun 5, 2022
@rcarriga
Copy link
Owner

rcarriga commented Jun 5, 2022

OK I've fixed the issue for Python anyway and believe it'll fix the lldb-vscode. Let me know if not 😄

@igorlfs
Copy link
Author

igorlfs commented Jun 5, 2022

Hey, thanks for fixing the issue with debugpy! Unfortunately, I'm still having the issue with lldb-vscode :(

I can record a demo if you think that it would be helpful.

rcarriga added a commit that referenced this issue Jun 6, 2022
This seems to fix an issue in lldb-vscode where a variable response
would be empty despite the variable having children. See #97 for
details. As a consequence of this fix, the fix from the previous commit
is unnecessary and is undone.
@rcarriga
Copy link
Owner

rcarriga commented Jun 6, 2022

OK I don't use C++ but managed to reproduce it with Rust (forgot they used the same adapter). I believe this is actually an lldb issue but managed to find a workaround. Please try the latest commit

@igorlfs
Copy link
Author

igorlfs commented Jun 6, 2022

Please try the latest commit

Apparently it's working but I still want to investigate a little further. I think under some circunstances a visual glitch may happen where a collapsed entry expands, overlaping with the actually expandend entries (I'm unsure how to reproduce this). Feel free to close this issue though, as I think this behavior is unrelated and the main problem I had was solved. Thanks for the amazing job :)

I believe this is actually an lldb issue

Should I file a bug report on llvm's repo?

@rcarriga
Copy link
Owner

rcarriga commented Jun 9, 2022

I think under some circunstances a visual glitch may happen where a collapsed entry expands, overlaping with the actually expandend entries (I'm unsure how to reproduce this)

If you turn on nvim-dap debug logs and see it happen again, I should be able to spot the cause. Happy to keep open for a while anyway.

Should I file a bug report on llvm's repo?

You could but it's a weird bug and I didn't try reproducing with the CLI (which I imagine they'll want). I wasn't able to reproduce with VSCode either. The issue occurring was that the adapter was responding to the variables request of the list element (in your screenshot c[0]) with no variables meaning they are empty whereas it actually has c[0][0] and c[0][1]. This only happened after stepping once, and then it would respond with the correct data for following steps. It was pretty odd. Once I get a bit of time I could try put together a reproduction

@igorlfs
Copy link
Author

igorlfs commented Jun 9, 2022

I've managed to find a way to reproduce the aforementioned visual glitch:

  1. Set a breakpoint and start a debugging session normally
  2. Add a variable to the watch list and fully expand it
  3. Add a second variable to the watch list, but only toggle it's first layer, eg
    image
  4. Step through the code such that the second variable's collapsed members change. Now you get this:
    image
    Here's the nvim-dap log

@rcarriga
Copy link
Owner

Thanks for that, I was able to reproduce. I haven't had the time to figure out the issue but will take a look when I can

rcarriga added a commit that referenced this issue Jun 17, 2022
Restoring previous fix to avoid issues with re-used variable refs (as
done by clangd).

This points to a broader issue in the design where variable references
should not be maintained across frames as they are not guaranteed to be
consistent.

See #97
@rcarriga
Copy link
Owner

OK should be working now 😅

@igorlfs
Copy link
Author

igorlfs commented Jun 17, 2022

Everything is working perfectly now, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants