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

Sync launch.json with project files #75

Open
davidanderle opened this issue Apr 5, 2024 · 6 comments
Open

Sync launch.json with project files #75

davidanderle opened this issue Apr 5, 2024 · 6 comments
Labels
enhancement New feature or request

Comments

@davidanderle
Copy link

Is there a way to automatically sync the launch.json file with the IAR project files? At the moment if the user changes a debug setting in IAR when the launch.json file already exists, the change does not sync to the VSCode environment. I could create tools to parse the relevant files and update the launch.json on a trigger (eg before a Launch task), but it seems like i'd be reinventing the wheel...

Since Run > Add configuration: IAR C-SPY Debug command can automatically create a basic template file, I was wondering if I could somehow access this "parsing tool". I would also like to add the extra "preLaunchTask": "iar: Build Project" key to the template file by default.

@davidanderle davidanderle added the bug Something isn't working label Apr 5, 2024
@HampusAdolfsson
Copy link
Collaborator

I would also like to add the extra "preLaunchTask": "iar: Build Project" key to the template file by default.

Adding an extension option called "Build before debug" (or something to that effect) definitely sounds like something we want to do. This would cause the preLaunchTask to be added by default, and would also take effect if debugging without a launch.json file.

For your main question, the intended solution is to not use a launch.json file. In the debug configuration dropdown, you can press "IAR C-SPY Debug..." to use the automatic debug configurations without creating a launch.json file:

image
When you go into the menu again (or restart VS Code), the configurations are regenerated from the project files.
I realize this has its issues and pain points, and doesn't work well if you need to customize the launch.json file in some way (for example to add a preLaunchTask). Would this work well enough for you?

Otherwise, we could look at allowing you to omit certain fields from a launch.json configuration, such as the program or driverOptions, and having the extension fill in missing fields automatically from the project files.

@HampusAdolfsson HampusAdolfsson added enhancement New feature or request and removed bug Something isn't working labels Apr 9, 2024
@davidanderle
Copy link
Author

davidanderle commented Apr 9, 2024

Thanks, I've managed to debug the target without the launch.json file as you suggested. Is there a way I could set up non-iar task that could potentially use this method to debug and add my preLaunchTask? Trouble is that I'm so used to IAR building the project before debugging, that this will cause me a lot of headache :)

Can I, perhaps, create a command line script for a task if CSPY supports this?

I think going forward your suggestion would be really convenient

@HampusAdolfsson
Copy link
Collaborator

Unfortunately, there is no command line interface to the VS Code debugger or our launch.json generator. I can't think of any other quick solutions to make this easier, either.

To clarify, with my suggestion above, you would be able to define a minimal launch.json configuration like this:

{
    "type": "cspy",
    "request": "launch",
    "name": "Debug with C-SPY",
    "preLaunchTask": "iar: Build Project",
    "workbenchPath": "${command:iar-config.toolchain}",
    "projectPath": "${command:iar-config.project-file}",
    "projectConfiguration": "${command:iar-config.project-configuration}",
},

This just says to debug the project and configuration currently selected in the "IAR Build" extension GUI, but not how to debug. All the details, like the program path and driver, would be filled in from the project files every time you launch it.

@davidanderle
Copy link
Author

davidanderle commented Apr 9, 2024

This would work for us I think, but I'm having this problem and therefore the debugger is not starting:
image
image

@HampusAdolfsson
Copy link
Collaborator

Sorry, I might have been a bit unclear:

This type of "minimal" launch.json configuration is not something we support yet. I've created a feature request for it internally and we'll consider implementing it in a future release. Until then, the best suggestion I can give is to debug without a launch.json file as I described in my first message.

@davidanderle
Copy link
Author

Ah, I see! Thanks, we will wait for the new release

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

No branches or pull requests

2 participants