You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Debugger does not honor selected environment #4098
The new environment switch in the status bar is a welcome enhancement. Unfortunately, it is not honored by the debugger. Instead, the debugger uses the first environment or the one selected by default_envs.
As the environment switch applies to IntelliSense and the Build and Upload actions in the status bar, users expect that the debugger behaves the same. I did so too.
In my case it even lead to a very confusing situation:
Clicking the green arrow the debugger pane started a rebuild of the project (debug configuration) – as expected.
After that, nothing happened anymore.
It took me quite some time until I remembered to switch to the DEBUG CONSOLE. I found an error basically saying unexpected idcode: 0x0bb11477, expected 1 of 1: 0x2ba01477.
It took me even more time to figure out that this error message was not due to a Chinese clone of the STM32 chip, but rather due to a mismatch between the environment use by the debugger and the board connected to my computer.
I see two options to fix it:
Honor the currently select environment when starting the debugger (preferred)
Label the debug configuration (launch.json) such that it is obvious which one is used
Note that the selected environment is part of the executable path and the board type also affects svdPath. So the selected environment is very relevant.
I've jus tried it and it didn't work. The correct environment was used to build a debug version. But the debugger is then started with a different (incorrect) environment.
launch.json looks ok. But the first line in the DEBUG CONSOLE already points at the incorrect environment (the selected environment is nucleo-f303re, the debugger however used nucleo_f042k6, which is the top most in platformio.ini):
Strangely enough, it looks as if the target was build twice: the output of the correct one appears in the TERMINAL view, the output of the incorrect one appears in DEBUG CONSOLE.
And I'm having more troubles. On a project with a single environment, I can't start the debugger anymore. I always get the error message "Could not find the specified task." This is new. It has worked before I upgraded to the development version.
And I don't know if it is related... Quite often Build and Upload in the status bar don't work. Instead of executing something, they just display a pop up (the kind VSC displays to let you select something):
This isn't new. It has occurred from time to time since the environment selector in the status bar was introduced. The workaround is to again select the already selected environment from the status bar.
I moved to "platformIO dev" branch and I also checked that I had the latest "PlafformIO IDE" extension installed. Moving to the dev branch, solved my "Error could not find specified task"
I've jus tried it and it didn't work. The correct environment was used to build a debug version. But the debugger is then started with a different (incorrect) environment.
launch.json looks ok. But the first line in the DEBUG CONSOLE already points at the incorrect environment (the selected environment is nucleo-f303re, the debugger however used nucleo_f042k6, which is the top most in platformio.ini):
Strangely enough, it looks as if the target was build twice: the output of the correct one appears in the TERMINAL view, the output of the incorrect one appears in DEBUG CONSOLE.
I still have this problem.
Debug console uses an environment from default_envs rather than one containing build_type = debug and the whole thing builds twice (reason or a symptom? Maybe unrelated).
I am poking around because I get the annoying full double rebuild when debugging.
I am on Windows - VSCode.
I think the problem is related to how launch.json is interpreted by the terminal and debug console, because when I change the default env on the toolbar or modify "projectEnvName": to "ServoCAN_debug" manually then both terminal and debug_console build the same thing. ...Albeit still the whole thing is rebuild twice which is my main trouble.
Does it makes sense to set "Environment Switcher" to "Auto"?
This function seems to be ignored by the debug console.
I am not sure but I think only CLI uses get_default_debug_env, but the debug console build uses whatever is in launch.json. When Environment Switcher is set to Default, then launch.json; happens to have non-debug env specified (i.e. "projectEnvName": "ServoCAN",). Then CLI will build ServoCAN_debug and debug console will build ServoCAN (even though it will say "building in debug mode". If I change I type "projectEnvName": "ServoCAN)debug", in launch.json, only then debug console builds the debug env.
Activity
ivankravets commentedon Oct 4, 2020
I don’t remember, do we provide different debug profiles when you switch to Debugging activity?
manuelbl commentedon Oct 4, 2020
I'm not sure I fully understand your question. But the below information might answer it.
If you change
platformio.iniand either rearrange the order of environments or changeddefault_envs, thenlaunch.jsonis updated.A configuration in
launch.jsonlooks like so:Note that the selected environment is part of the executable path and the board type also affects svdPath. So the selected environment is very relevant.
ivankravets commentedon Oct 31, 2020
platformio/platformio-vscode-ide#2018 (comment)
You will also need the latest PlatformIO Core 5.0.3 Dev.
Does it work now? Thanks!
P.S: Also would be thankful for the feedback with upcoming chnages in 2.2.0.
manuelbl commentedon Nov 1, 2020
I've jus tried it and it didn't work. The correct environment was used to build a debug version. But the debugger is then started with a different (incorrect) environment.
launch.jsonlooks ok. But the first line in the DEBUG CONSOLE already points at the incorrect environment (the selected environment is nucleo-f303re, the debugger however used nucleo_f042k6, which is the top most inplatformio.ini):Strangely enough, it looks as if the target was build twice: the output of the correct one appears in the TERMINAL view, the output of the incorrect one appears in DEBUG CONSOLE.
ivankravets commentedon Nov 1, 2020
Do you use the latest PlatformIO Core 5.0.3 Dev?
manuelbl commentedon Nov 1, 2020
Yes, I do.
And I'm having more troubles. On a project with a single environment, I can't start the debugger anymore. I always get the error message "Could not find the specified task." This is new. It has worked before I upgraded to the development version.
And I don't know if it is related... Quite often Build and Upload in the status bar don't work. Instead of executing something, they just display a pop up (the kind VSC displays to let you select something):
This isn't new. It has occurred from time to time since the environment selector in the status bar was introduced. The workaround is to again select the already selected environment from the status bar.
ivankravets commentedon Nov 1, 2020
Keep PlatformIO IDe extension at 2.2.0-beta and downgrade PlatformIO Core to the latest stable 5.0.2. I'll try to investigate this issue.
Another workaround is to use
"PIO Debug (skip Pre-Debug)"instead of"PIO Debug".manuelbl commentedon Nov 1, 2020
I have been using the new core 5.0.3a1 but the old extension (2.1.3). How do I upgrade to the beta version?
ivankravets commentedon Nov 1, 2020
See instruction by a link above. Thanks.
ivankravets commentedon Nov 3, 2020
2.2.0 has been released! You will just need the latest PIO Core 5.0.3-dev.
3 remaining items
maxgerhardt commentedon Feb 2, 2021
Also noted as a bug in community thread
GadgetAngel commentedon Feb 6, 2021
THANK YOU
I moved to "platformIO dev" branch and I also checked that I had the latest "PlafformIO IDE" extension installed. Moving to the dev branch, solved my "Error could not find specified task"
Thankyou!
dzid26 commentedon Apr 6, 2023
I still have this problem.
Debug console uses an environment from
default_envsrather than one containingbuild_type = debugand the whole thing builds twice (reason or a symptom? Maybe unrelated).I am poking around because I get the annoying full double rebuild when debugging.
I am on Windows - VSCode.
ivankravets commentedon Apr 11, 2023
@dzid26, could you share your
platformio.inicontent?dzid26 commentedon Apr 11, 2023
I am using this normally.
But I was also testing separate debug environment in relation to this issue with the following:
I think the problem is related to how
launch.jsonis interpreted by the terminal and debug console, because when I change the default env on the toolbar or modify"projectEnvName":to"ServoCAN_debug"manually then both terminal and debug_console build the same thing. ...Albeit still the whole thing is rebuild twice which is my main trouble.ivankravets commentedon Apr 12, 2023
See https://github.com/platformio/platformio-core/blob/develop/platformio/debug/helpers.py#L65
Does it makes sense to set "Environment Switcher" to "Auto"?
dzid26 commentedon Apr 12, 2023
This function seems to be ignored by the debug console.
I am not sure but I think only CLI uses
get_default_debug_env, but the debug console build uses whatever is inlaunch.json. When Environment Switcher is set to Default, thenlaunch.json;happens to have non-debug env specified (i.e."projectEnvName": "ServoCAN",). Then CLI will buildServoCAN_debugand debug console will buildServoCAN(even though it will say "building in debug mode". If I change I type"projectEnvName": "ServoCAN)debug",inlaunch.json, only then debug console builds the debug env.Terminal uses https://github.com/platformio/platformio-core/blob/develop/platformio/debug/helpers.py#L65.
Debug console uses https://github.com/platformio/platformio-core/blob/develop/platformio/run/cli.py#L135 logic for some reason.
ivankravets commentedon Apr 12, 2023
@dzid26, thanks, I reproduced this issue. This is a bug and is different from this issue. Could I ask you to open a new issue at https://github.com/platformio/platformio-core/issues to track this problem?
Fixed an issue when VSCode's debugger does not honor default environm…