restart_debugging hangs forever
I am using Cortex-Debug Extension.
The restart_debugging command does not work reliable and hangs most of the times.
The issue can be reproduced with this very simple sequence:
- send
start_debugging - wait 5 secs (time not relevant, just to have some interval between the tool calls)
- send
restart_debugging
I can see that the session is restarted, but the call to restart_debugging never returns.
This issue was initially reported here: #157
Hi @rhobison, the restart-hang safeguard has been merged in #163 and is available in the DebugMCP 2.4.2 VSIX build.
Please try it with your start_debugging -> wait -> restart_debugging sequence and let us know how it behaves:
- Download the 2.4.2 extension-vsix artifact and extract the ZIP.
- In VS Code, run Extensions: Install from VSIX..., select the extracted
.vsix, and reload the window. - Repeat your reproduction and share the result.
The Marketplace currently still lists 2.4.1, so please use the linked VSIX to try this change.
One important distinction: we found that Cortex-Debug v1.12.1 can successfully reset the target without sending the restart response that VS Code awaits. DebugMCP now bounds that wait by debugmcp.timeoutInSeconds and returns an explicit timeout if completion is not acknowledged, rather than leaving the operation pending. It preserves actual restart errors and does not falsely report success just because the target stopped. This safeguards DebugMCP; it does not repair the missing response in Cortex-Debug itself.
Could you also share your Cortex-Debug and VS Code versions? If you still get a timeout, please include the exact tool response and a sanitized DAP trace from a reproduction with "showDevDebugOutput": "vscode" enabled in your launch configuration. After a timeout, check get_debug_status and the Debug Console before retrying: the target may already have restarted, and the timeout does not cancel the underlying request.
Thanks for reporting this and helping us narrow it down!
I tested version v2.4.2 and this is the result.
First, the version of VSCode and tools:
VSCode:
Version: 1.139.1
Commit: 04c0d99f4fb0d8afe6ce4f0c58e31e183ac3e4b1
Date: 2026-09-25T03:40:57Z
Electron: 43.6.0
ElectronBuildId: 15274685
Chromium: 150.0.7871.250
Node.js: 24.20.0
V8: 15.0.245.31-electron.0
@github/copilot: 1.0.85.r35379093703.g3514c9a
@github/copilot-sdk: 1.0.15.35393089353.gfc44743
OS: Darwin arm64 25.6.0
Cortex-Debug:
Identifier: marus25.cortex-debug
Version: 1.12.1
Last Updated: 3 weeks ago
Source: VSIX
Size: 2.78MB
DebugMCP (from the 2.4.2 extension-vsix artifact):
Identifier: ozzafar.debugmcpextension
Version: 2.4.2
Last Updated: 21 minutes ago
Source: VSIX
Size: 29.39MB
The command restart_debugging still hangs until the timeout specified by debugmcp.timeoutInSeconds elapses (I configured it to 30s):
The first get_debug_status (not expanded in the image) returns:
{
"status": "paused",
"paused": true,
"sessionActive": true,
"configurationName": "<app> Debug",
"breakpoints": [],
"requestedWaitSeconds": 5,
"effectiveWaitSeconds": 5,
"state": {
"sessionActive": true,
"paused": true,
"configurationName": "<app> Debug",
"stackTrace": [
"main@0x080006fa:50"
],
"breakpoints": [],
"fileFullPath": null,
"fileName": null,
"currentLine": null,
"currentLineContent": null,
"nextLines": [],
"frameId": 4096,
"threadId": 1,
"frameName": "main@0x080006fa"
}
}
Note: even though the second get_debug_status returns ...DebugMCP has no active debug target for this session..., the debug session is still active and I can click the debug buttons normally and debug manually (step over, step into, etc.).
//------
Below is the Debug Console result with "showDevDebugOutput": "vscode" (note: I replaced sensible information in the output below, such as paths and MCU name):
From client: restart({"arguments":{"name":"hal-tester-stm32xxxxxx Debug","type":"cortex-debug","request":"launch","cwd":"/home/builduser/<path>","executable":"/home/builduser/<path>/build_stm32xxxx_debug/source/hal_bench.elf","loadFiles":["/home/builduser/<path>/build_stm32xxxx_debug/source/hal_bench.hex"],"serverpath":"JLinkGDBServerCL","servertype":"jlink","ipAddress":"0.250.250.254","device":"stm32xxxx_xxxx_xxxK","interface":"swd","runToEntryPoint":"main","svdFile":"/home/builduser/<path>/source/device/stm32xx/stm32xxxx.svd","showDevDebugOutput":"vscode","postLaunchCommands":["set substitute-path /home/builduser/<lib> ../<lib>"],"preLaunchTask":"cmake hal-tester-stm32xxxxxx Debug","__configurationTarget":6,"gdbServerConsolePort":60000,"pvtAvoidPorts":[],"chainedConfigurations":{"enabled":false},"debuggerArgs":[],"swoConfig":{"enabled":false,"decoders":[],"cpuFrequency":0,"swoFrequency":0,"source":"probe"},"rttConfig":{"enabled":false,"decoders":[]},"graphConfig":[],"preLaunchCommands":[],"preAttachCommands":[],"postAttachCommands":[],"preRestartCommands":[],"postRestartCommands":[],"preResetCommands":[],"postResetCommands":[],"toolchainPrefix":"arm-none-eabi","extensionPath":"/home/builduser/.vscode-server/extensions/marus25.cortex-debug-1.12.1","registerUseNaturalFormat":true,"variableUseNaturalFormat":true,"pvtVersion":"1.12.1","__sessionId":"2f010a66-da80-4caa-9461-92473fad1df7"}})
28-interpreter-exec console "monitor halt"
-> 28^done
29-interpreter-exec console "monitor reset"
-> @"Resetting target\r\n"
Resetting target
-> 29^done
30-break-insert -t --function main
-> 30^done,bkpt={number="2",type="breakpoint",disp="del",enabled="y",addr="0x080006fa",func="main",file="/home/builduser/<path>/source/src/main.c",fullname="/home/builduser/<path>/source/src/main.c",line="50",thread-groups=["i1"],times="0",original-location="-function main"}
31-exec-continue --all
-> 31^running
-> *running,thread-id="all"
mi2.status = running
To client: {"seq":0,"type":"event","event":"continued","body":{"threadId":1,"allThreadsContinued":true}}
To client: {"seq":0,"type":"event","event":"custom-continued","body":{"threadID":1,"allThreads":true}}
-> =breakpoint-modified,bkpt={number="2",type="breakpoint",disp="del",enabled="y",addr="0x080006fa",func="main",file="/home/builduser/<path>/source/src/main.c",fullname="/home/builduser/<path>/source/src/main.c",line="50",thread-groups=["i1"],times="1",original-location="-function main"}
-> ~"\n"
-> ~"Temporary breakpoint 2, main () at /home/builduser/<path>/source/src/main.c:50\n"
Temporary breakpoint 2, main () at /home/builduser/<path>/source/src/main.c:50
-> ~"50\t{\n"
50 {
-> *stopped,reason="breakpoint-hit",disp="del",bkptno="2",frame={addr="0x080006fa",func="main",args=[],file="/home/builduser/<path>/source/src/main.c",fullname="/home/builduser/<path>/source/src/main.c",line="50",arch="arm"},thread-id="1",stopped-threads="all"
mi2.status = stopped
To client: {"seq":0,"type":"event","event":"stopped","body":{"reason":"breakpoint","threadId":1,"allThreadsStopped":true}}
To client: {"seq":0,"type":"event","event":"custom-stop","body":{"reason":"breakpoint","threadID":1}}
-> =breakpoint-deleted,id="2"
From client: threads(undefined)
32-thread-list-ids
-> 32^done,thread-ids={thread-id="1"},current-thread-id="1",number-of-threads="1"
33-thread-info 1
-> 33^done,threads=[{id="1",target-id="Thread 57005",frame={level="0",addr="0x080006fa",func="main",args=[],file="/home/builduser/<path>/source/src/main.c",fullname="/home/builduser/<path>/source/src/main.c",line="50",arch="arm"},state="stopped"}]
To client: {"seq":0,"type":"response","request_seq":20,"command":"threads","success":true,"body":{"threads":[{"id":1,"name":"Thread 57005"}]}}
From client: stackTrace({"threadId":1,"startFrame":0,"levels":20})
34-stack-list-frames --thread 1 0 19
-> 34^done,stack=[frame={level="0",addr="0x080006fa",func="main",file="/home/builduser/<path>/source/src/main.c",fullname="/home/builduser/<path>/source/src/main.c",line="50",arch="arm"}]
To client: {"seq":0,"type":"response","request_seq":21,"command":"stackTrace","success":true,"body":{"stackFrames":[{"id":4096,"source":{"name":"/home/builduser/<path>/source/src/main.c","path":"/home/builduser/<path>/source/src/main.c","sourceReference":0},"line":50,"column":0,"name":"main@0x080006fa","instructionPointerReference":"0x080006fa"}]}}
From client: evaluate({"expression":"*g_status_read_info.p_values_to_return@4","frameId":4096,"context":"watch"})
35-var-create --thread 1 --frame 0 watch_8e19e93f5c3200bbdd1030f140708c0dafa5e7fc63ea89bdbd232ec653bafe34 @ "*g_status_read_info.p_values_to_return@4"
-> 35^error,msg="-var-create: unable to create variable object"
To client: {"seq":0,"type":"response","request_seq":22,"command":"evaluate","success":true,"body":{"result":"<-var-create: unable to create variable object (from var-create --thread 1 --frame 0 watch_8e19e93f5c3200bbdd1030f140708c0dafa5e7fc63ea89bdbd232ec653bafe34 @ \"*g_status_read_info.p_values_to_return@4\")>","variablesReference":0}}
watch -var-create: unable to create variable object (from var-create --thread 1 --frame 0 watch_8e19e93f5c3200bbdd1030f140708c0dafa5e7fc63ea89bdbd232ec653bafe34 @ "*g_status_read_info.p_values_to_return@4")
From client: scopes({"frameId":4096})
36-stack-info-frame --thread 1 --frame 0
-> 36^done,frame={level="0",addr="0x080006fa",func="main",file="/home/builduser/<path>/source/src/main.c",fullname="/home/builduser/<path>/source/src/main.c",line="50",arch="arm"}
To client: {"seq":0,"type":"response","request_seq":23,"command":"scopes","success":true,"body":{"scopes":[{"name":"Local","variablesReference":4096,"expensive":false},{"name":"Global","variablesReference":4294967295,"expensive":false},{"name":"Static: ./source/src/main.c","variablesReference":1052672,"expensive":false},{"name":"Registers","variablesReference":2101248,"expensive":false}]}}
From client: variables({"variablesReference":4096})
37-stack-list-variables --thread 1 --frame 0 --simple-values
-> 37^done,variables=[]
To client: {"seq":0,"type":"response","request_seq":24,"command":"variables","success":true,"body":{"variables":[]}}
Let me know if you need any other information.
@ozzafar I just realized this issue was closed, but you asked me to provide some info, which I did above. Any action required from my part? Should I reopen the issue?