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
Extension hangs after disconnecting from external GDB server #1176
I'm seeing a similar behavior as described in #635; the debug extension hangs after I'm trying to disconnect from an external GDB server.
The exact steps that I'm performing are:
starting a GDB server with west gdbserver, which starts an STLink GDB server.
attach to the external server
click the "Restart" button
click the "Disconnect" button
With this, the debug extension still shows as active until I reload the vscode window. The external GDB server is stopped normally, debugging as such also works, and it doesn't seem to be a problem if I don't restart the target (then, the disconnect closes the debug session normally).
Expected behavior
After disconnecting, the session should be closed.
Environment (please complete the following information):
Cortex-Debug Version 1.12.1
OS: Linux 36f1283a19f2 6.12.54-linuxkit 1 SMP Tue Nov 4 21:21:47 UTC 2025 aarch64 aarch64 aarch64 GNU/Linux
Hmmm. We probably did not notify VSCode that the session ended. That would be strange because that is tied to gdb exiting (because we started it) and since it is external, we don't wait for the server exiting...in fact people let the server running after a disconnect (with some servers)
It is possible the second gdb (for live-watch) is still holding on and not letting the session end. Will look into it.
Btw, for us, "Restart" button ends the current session and VSCode starts a brand new one. We don't handle a "Restart". To us, it is a brand new session start, with no history of the prior session. We did this because VSCode went back and forth on what actually happens during a "Restart". So, we decided VSCode to handle it like a total Restart.
Are there any logs just after you did a "Restart". overrideRestartCommands was even deprecated a couple of years ago.
I admit that I clicked "Reset" and "Restart" exchangeably since for the GDB server usecase that didn't seem to make much of a difference (it doesn't reset the GDB server anyhow). Now it seems that
with a "reset device" I can always cleanly disconnect
What is also a bit of a pity is that we can't tell cortex-debug what kind of GDB server we're using. I read the https://github.com/Marus/cortex-debug/wiki/External-gdb-server-configuration which claims that with servertype:external it can't know what GDB commands to use, e.g., for a reset. It'd be great if there was another option to tell cortex-debug that this external GDB server is a stlink and it should use the same commands as if it was launched by the extension.
The difference between reset (handled by us) and restart (handled by Microsoft) is huge.
We don't do it that way because the orchestration can be very tricky and unreliable...because we don't know what commands you have issued, what command-line args you used etc, and we also know the quirks of every other gdb-server. You can clearly see what commands we give to the gdb-server (both in source code and in the Debug Console). There is nothing hidden.
Another thing. The first line I see in the logfile says
41-interpreter-exec console "monitor reset"
That is a LOT of commands (40) that preceded this one. That doesn't make sense. There should be less than 10 at this point. So, I am lost until I can duplicate it. It feels like Microsoft didn't actually do a Restart.
Yeah there's a lot happening, in the following logs I copied the log before executing the restart so you really have the full log - vscode clears the debug log each time you hit reset ...
With the officially released version of your extension you're right, it seems like it isn't really restarted. With the pre-released version (from VSIX) the debug session restarts.
With the pre-released version the restart only fails since the STLink GDB server terminates after a client disconnects (I fear that's not configurable, but not a problem with vscode and/or your extension of course).
This is in the ST gdbserver manual -- use the --persistent mode when you start yur stlink. Default is single-shot
• -e, --persistant
Specifying the option -e starts the server in persistent mode. By default, the persistent mode is disabled,
meaning that the server starts in non-persistent mode.
But then, you have to kill the server manually. Pick your evil :-)
Btw, curious, why are you using the external mode -- doesn't look like you are doing anything special. With all those override options and pre/post thingys, most people can manage.
Ah yes, its just not (yet) exposed as an argument in the Zephyr wrapper/runner, but that works perfectly for me, thanks!
I'm exploring options for a containerized development environment, but I'm on a mac, which means I can't forward USB interfaces into the container. So my current approach is to minimize the tools that I need to install on the host whilst everything else is only installed in the image.
Due to the USB forwarding restriction (docker/for-mac#900) I'm launching the GDB server on the host, and connect to it from within the container for debugging. It's not ideal but I hate trashing my computer with tools (which won't even be compatible between projects).
Activity
haneefdm commentedon Dec 13, 2025
Hmmm. We probably did not notify VSCode that the session ended. That would be strange because that is tied to gdb exiting (because we started it) and since it is external, we don't wait for the server exiting...in fact people let the server running after a disconnect (with some servers)
It is possible the second gdb (for live-watch) is still holding on and not letting the session end. Will look into it.
haneefdm commentedon Dec 13, 2025
Btw, for us, "Restart" button ends the current session and VSCode starts a brand new one. We don't handle a "Restart". To us, it is a brand new session start, with no history of the prior session. We did this because VSCode went back and forth on what actually happens during a "Restart". So, we decided VSCode to handle it like a total Restart.
Are there any logs just after you did a "Restart".
overrideRestartCommandswas even deprecated a couple of years ago.lmapii commentedon Dec 13, 2025
I admit that I clicked "Reset" and "Restart" exchangeably since for the GDB server usecase that didn't seem to make much of a difference (it doesn't reset the GDB server anyhow). Now it seems that
Regarding deprecation I didn't find that much since those options are still listed in https://github.com/Marus/cortex-debug/blob/master/debug_attributes.md, also vscode doesn't seem to complain that the option is deprecated.
This is a debug log where
lmapii commentedon Dec 13, 2025
What is also a bit of a pity is that we can't tell
cortex-debugwhat kind of GDB server we're using. I read the https://github.com/Marus/cortex-debug/wiki/External-gdb-server-configuration which claims that withservertype:externalit can't know what GDB commands to use, e.g., for a reset. It'd be great if there was another option to tellcortex-debugthat this external GDB server is astlinkand it should use the same commands as if it was launched by the extension.haneefdm commentedon Dec 13, 2025
The difference between reset (handled by us) and restart (handled by Microsoft) is huge.
We don't do it that way because the orchestration can be very tricky and unreliable...because we don't know what commands you have issued, what command-line args you used etc, and we also know the quirks of every other gdb-server. You can clearly see what commands we give to the gdb-server (both in source code and in the Debug Console). There is nothing hidden.
https://github.com/Marus/cortex-debug/blob/master/src/stlink.ts
Just in case, have you tried our pre-release version?
https://github.com/Marus/cortex-debug/releases
Another thing. The first line I see in the logfile says
That is a LOT of commands (40) that preceded this one. That doesn't make sense. There should be less than 10 at this point. So, I am lost until I can duplicate it. It feels like Microsoft didn't actually do a Restart.
lmapii commentedon Dec 13, 2025
Yeah there's a lot happening, in the following logs I copied the log before executing the restart so you really have the full log - vscode clears the debug log each time you hit reset ...
With the officially released version of your extension you're right, it seems like it isn't really restarted. With the pre-released version (from VSIX) the debug session restarts.
With the pre-released version the restart only fails since the STLink GDB server terminates after a client disconnects (I fear that's not configurable, but not a problem with vscode and/or your extension of course).
debug.log
debug-prerelease.log
haneefdm commentedon Dec 13, 2025
This is in the ST gdbserver manual -- use the --persistent mode when you start yur stlink. Default is single-shot
But then, you have to kill the server manually. Pick your evil :-)
Btw, curious, why are you using the external mode -- doesn't look like you are doing anything special. With all those override options and pre/post thingys, most people can manage.
lmapii commentedon Dec 13, 2025
Ah yes, its just not (yet) exposed as an argument in the Zephyr wrapper/runner, but that works perfectly for me, thanks!
I'm exploring options for a containerized development environment, but I'm on a mac, which means I can't forward USB interfaces into the container. So my current approach is to minimize the tools that I need to install on the host whilst everything else is only installed in the image.
Due to the USB forwarding restriction (docker/for-mac#900) I'm launching the GDB server on the host, and connect to it from within the container for debugging. It's not ideal but I hate trashing my computer with tools (which won't even be compatible between projects).