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

What is the workflow for debugging node-clangd code? #17

Open
HighCommander4 opened this issue Oct 17, 2022 · 6 comments
Open

What is the workflow for debugging node-clangd code? #17

HighCommander4 opened this issue Oct 17, 2022 · 6 comments

Comments

@HighCommander4
Copy link
Contributor

HighCommander4 commented Oct 17, 2022

To investigate clangd/vscode-clangd#396, I'd like to step through some code in node-clangd in the debugger. However, I'm not clear on how to do this:

  • If I start debugging in a vscode-clangd workspace, I don't have access to node-clangd source files to set a breakpoint in.
  • If I start debugging in a node-clangd workspace, trying to set a breakpoint doesn't succeed (the breakpoint isn't "bound").

What is the proper way to do this? My apologies if this should be obvious, I'm not well versed in node or vscode extension development.

@HighCommander4
Copy link
Contributor Author

HighCommander4 commented Oct 17, 2022

What I ended up doing is setting a breakpoint in the vscode-clangd workspace, in the generated code at node_modules/@clangd/install/out/src/index.js.

However, that still doesn't get me to an edit/debug cycle for node-clangd code.

@HighCommander4
Copy link
Contributor Author

HighCommander4 commented Oct 22, 2022

To get vscode-clangd to consume a locally modified node-clangd, I did the following:

  • Deleted vscode-clangd/node_modules/@clangd/install
  • Made a copy of the node-clangd checkout (with my modified files) as vscode-clangd/node_modules/@clangd/install
  • Rebuilt the vscode extension package

I think npm link is supposed to be a more proper way to do this (symlinking rather than copying the local version of the dependency), but that runs into a vsce bug (microsoft/vscode-vsce#203).

On the plus side, having copied node-clangd in this way, I can now set a breakpoint in vscode-clangd/node_modules/@clangd/install/src/index.ts (i.e. in typescript code, not in generated JS code) and that seems to work.

@HighCommander4
Copy link
Contributor Author

On the plus side, having copied node-clangd in this way, I can now set a breakpoint in vscode-clangd/node_modules/@clangd/install/src/index.ts (i.e. in typescript code, not in generated JS code) and that seems to work.

(But editing the file in that location does not work, so it doesn't quite give me an edit/debug workflow...)

@sam-mccall
Copy link
Member

Hi Nathan,
Sorry I wish I had a good answer here, I don't do enough JS stuff to know how to use these tools well.

I think npm link is supposed to be a more proper way to do this (symlinking rather than copying the local version of the dependency), but that runs into a vsce bug (microsoft/vscode-vsce#203).

I use npm link (or a manual symlink) while editing node-clangd. I hadn't hit that bug because I never need to use vsce, just npm run compile and code --extensionDevelopmentPath=$PWD .

(If you want to test the final packaged artifact that makes sense, but I've never done that with an unpublished version of node-clangd).

(But editing the file in that location does not work, so it doesn't quite give me an edit/debug workflow...)

My guess: this might work if you use the symlink + rebuild both projects (or run a watch-recompile in both directories).

@HighCommander4
Copy link
Contributor Author

I use npm link (or a manual symlink) while editing node-clangd. I hadn't hit that bug because I never need to use vsce, just npm run compile and code --extensionDevelopmentPath=$PWD .

Thanks! This is helpful (also as a way to test a locally modified vscode-clangd without packaging it in general)

@tamird
Copy link

tamird commented Jul 31, 2024

@sam-mccall what if you need the extension to run on a remote host while you're debugging?

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

3 participants