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

How to see current execution line lower in stack #185

Open
wenzelkinsky opened this issue Jun 4, 2024 · 2 comments
Open

How to see current execution line lower in stack #185

wenzelkinsky opened this issue Jun 4, 2024 · 2 comments

Comments

@wenzelkinsky
Copy link

wenzelkinsky commented Jun 4, 2024

Can't see current execution line when stepping into functions

I am currently trying to migrate from RStudio to VS Code and would like to know whether it is possible to have a seamless execution trace when debugging custom functions. I can see the different environments / stack layers under the call stack. But I can't call variables from the current environment in the debug console and the code of the function being executed.

image

Currently executed line is somewhere within function backtestsLS. If I use recover() to step into the correct frame all completions and variables dissapear.

image

What I would ideally have is that on step in I can see the currently executed line within the function and possibly set breakpoints within the function code.

Current debug config (launch.json) is;

{
  "version": "0.2.0",
    "configurations": [
      {
        "type": "R-Debugger",
        "request": "launch",
        "name": "Launch Workspace",
        "debugMode": "workspace",
        "workingDirectory": "${workspaceFolder}",
        "allowGlobalDebugging": true,
        "includePackageScopes": true,
        "debuggedPackages": ["DPMtrading", "dplyr"]
      },
  ]
}

I also attempted via debug file and attach to session with similar results. This is using R 4.2.3 with vscDebugger version 0.5.2.

Session Info

R version 4.2.3 Patched (2023-04-13 r84428 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Would be great to know if I need to change something in the config or R Settings to get this working better.

@ManuelHentschel
Copy link
Owner

The expected/intended behavior for this is the following:

  • In the top left corner you have the variables pane, showing the variables in the current frame. You can expand some of these to get more info (e.g. list entries)
  • In the bottom left corner you see the call stack. Clicking on a frame makes this the "active" frame. Now, the corresponding line of code is highlighted (if it is in a known file), the variables pane shows the variables from this frame, and anything entered in the debug console will be evaluated in this frame
  • I am not familiar with recover(), but from what I have read it should not be necessary when using the debug extension, and will most likely cause errors.

To debug package code, it is recommended to use the debug config entry loadPackages, assuming that the working directory is the root of the package. Otherwise, debuggedPackages should also work, if you installed the package from source and set --with-keep.source.

Note that the debugger tries to hide stack frames belonging to its own function calls. If you suspect that some of your own frames are hidden, you can chekc by setting the R option "vsc.showInternalFrames" = TRUE (and please report if you find such an instance).

If this is not the behavior you get, please post a reproducible example, so I can have a look!

@wenzelkinsky
Copy link
Author

wenzelkinsky commented Jul 3, 2024 via email

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