vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

Launch started the debug server successfully, but timeout and return a failed to initialize error

Open dev-pac opened this issue 8 months ago • 1 comments

Environment

  • OS and version: linux manjaro 24.2.1
  • VS Code: 1.98.2
  • C/C++ extension: 1.23.6
  • OS and version of remote machine (if applicable): ubuntu 22.04 executed in a docker
  • GDB / LLDB version: 14.2

I use an SDK for yocto 5.0, Qemu version is 8.2.2

Bug Summary and Steps to Reproduce

Bug Summary:

cpp tools waits for qemu to start and timeout without trying to connect to it.

Steps to reproduce:

I start the debug.

Error message is displayed Unable to start debugging. Debug server process failed to initialize.

Debugger Configurations

`{
	"name": "Launch with QEMU",
	"type": "cppdbg",
	"request": "launch",
	"program": "${workspaceFolder}/build/my_binary",
	"cwd": "${workspaceFolder}",
	"MIMode": "gdb",
	"miDebuggerPath": "aarch64-poky-linux-gdb",
	"miDebuggerServerAddress": "localhost:1333",
	"stopAtEntry": false,
	"externalConsole": false,
	"debugServerPath": "qemu-aarch64",
	"debugServerArgs": "-L /opt/summitsom-wayland/5.0.3/sysroots/armv8a-poky-linux -g 1333 ${workspaceFolder}/build/my_binary",
	"filterStderr": true,
	"filterStdout": true,
}`

Debugger Logs

--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (86) LaunchOptions{\"name\":\"Launch with QEMU\",\"type\":\"cppdbg\",\"request\":\"launch\",\"program\":\"/workspaces/firmware/build/my_binary\",\"cwd\":\"/workspaces/firmware/mpu\",\"MIMode\":\"gdb\",\"miDebuggerPath\":\"aarch64-poky-linux-gdb\",\"miDebuggerServerAddress\":\"localhost:1333\",\"stopAtEntry\":false,\"externalConsole\":false,\"debugServerPath\":\"qemu-aarch64\",\"debugServerArgs\":\"-L /opt/summitsom-wayland/5.0.3/sysroots/armv8a-poky-linux -g 1333 /workspaces/firmware/build/my_binary\",\"filterStderr\":true,\"filterStdout\":true,\"logging\":{\"engineLogging\":true,\"trace\":true,\"traceResponse\":true},\"__configurationTarget\":5,\"__sessionId\":\"7e78a92d-2e2d-49b0-9467-d407ccc367ed\"}\n"},"seq":2}
1: (86) LaunchOptions{"name":"Launch with QEMU","type":"cppdbg","request":"launch","program":"/workspaces/firmware/build/my_binary","cwd":"/workspaces/firmware/mpu","MIMode":"gdb","miDebuggerPath":"aarch64-poky-linux-gdb","miDebuggerServerAddress":"localhost:1333","stopAtEntry":false,"externalConsole":false,"debugServerPath":"qemu-aarch64","debugServerArgs":"-L /opt/summitsom-wayland/5.0.3/sysroots/armv8a-poky-linux -g 1333 /workspaces/firmware/build/my_binary","filterStderr":true,"filterStdout":true,"logging":{"engineLogging":true,"trace":true,"traceResponse":true},"__configurationTarget":5,"__sessionId":"7e78a92d-2e2d-49b0-9467-d407ccc367ed"}
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (144) Starting: \"qemu-aarch64\" -L /opt/summitsom-wayland/5.0.3/sysroots/armv8a-poky-linux -g 1333 /workspaces/firmware/build/my_binary\n"},"seq":4}
1: (144) Starting: "qemu-aarch64" -L /opt/summitsom-wayland/5.0.3/sysroots/armv8a-poky-linux -g 1333 /workspaces/firmware/build/my_binary
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (10185) <-logout\n"},"seq":6}
1: (10185) <-logout
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (10193) Send Event AD7MessageEvent\n"},"seq":8}
1: (10193) Send Event AD7MessageEvent
--> E (output): {"type":"event","event":"output","body":{"category":"telemetry","output":"VS/Diagnostics/Debugger/Launch","data":{"VS.Diagnostics.Debugger.ImplementationName":"Microsoft.MIDebugEngine","VS.Diagnostics.Debugger.EngineVersion":"17.12.21003.1","VS.Diagnostics.Debugger.HostVersion":"17.12.21003.1","VS.Diagnostics.Debugger.AdapterId":"cppdbg","VS.Diagnostics.Debugger.Launch.ErrorCode":1005,"VS.Diagnostics.Debugger.Launch.IsError":true}},"seq":10}
--> R (launch-2): {"type":"response","request_seq":2,"success":false,"command":"launch","message":"Unable to start debugging. Debug server process failed to initialize.","body":{"error":{"id":1005,"format":"Unable to start debugging. Debug server process failed to initialize."}},"seq":12}

Other Extensions

No response

Additional Information

If I increase the serverLaunchTimeout, the error take more time to occurs. Indicating that the timeout is reached. During the timeout, I verified and quemu was running as expected.

Before trying to do it in one action, I had this configuration: { "name": "Launch with QEMU", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/my_binary", "cwd": "${workspaceFolder}", "MIMode": "gdb", "miDebuggerPath": "aarch64-poky-linux-gdb", "miDebuggerServerAddress": "localhost:1333", "stopAtEntry": false, }

And I started manually qemu with: qemu-aarch64 -L /opt/summitsom-wayland/5.0.3/sysroots/armv8a-poky-linux -g 1333 /workspace/firmware/build/my_binary

Then when launching the debug, it worked perfectly.

dev-pac avatar Mar 18 '25 16:03 dev-pac

Just met the same problem...

shoudlee avatar Jun 04 '25 14:06 shoudlee