Open
Description
Environment
- OS and version: Win10
- VS Code: 1.98
- C/C++ extension: 1.23.6
- OS and version of remote machine (if applicable): NA
- GDB / LLDB version: 12.1
Bug Summary and Steps to Reproduce
Bug Summary:
Steps to reproduce:
- Launch a debug configuration with gdb and gdb-server invoked from the launch file, launch configuration is given.
- Terminate the launch after halting the target
- kill and vkill packets send by the debugger but without waiting for the response, the debugger kills the gdb-server. This cause some important hardware register changes handled in kill packet not executed!
Debugger Configurations
{
"configurations": [
{
"logging": {
"engineLogging": "error"
},
"name": "qemu",
"type": "cppdbg",
"request": "launch",
"program": "c:\\Users\\TestUser\\AppData\\Local\\Ashling\\RiscFree_IDEv25.1.0_Sp1.2\\workspace\\riscv32-picojpeg\\Debug\\riscv32-picojpeg.elf",
"args": [],
"stopAtConnect": false,
"stopAtEntry": false,
"cwd": "c:\\Users\\TestUser\\AppData\\Local\\Ashling\\RiscFree_IDEv25.1.0_Sp1.2\\workspace\\riscv32-picojpeg",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "riscv32-unknown-elf-gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set RISC-V architecture",
"text": "set arch riscv:rv32",
"ignoreFailures": true
},
{
"description": "Set remote timeout",
"text": "set remotetimeout 250",
"ignoreFailures": true
},
{
"description": "Disable thread event printing",
"text": "set print thread-events off",
"ignoreFailures": true
}
],
"postRemoteConnectCommands": [
{
"description": "Load command",
"text": "load",
"ignoreFailures": true
}
],
"miDebuggerServerAddress": "localhost:1234",
"serverLaunchTimeout": 5000,
"debugServerArgs": "--gdb-port 51996 --transport-type jtag --jtag-frequency 16000KHz",
"debugServerPath": "c:\\Users\\TestUser\\AppData\\Local\\Ashling\\RiscFree_IDEv25.1.0_Sp1.2\debugger\gdbserver-riscv\ash-riscv-gdb-server.exe",
"filterStderr": true,
"hardwareBreakpoints": {
"require": false,
"limit": 4
},
"symbolLoadInfo": {
"loadAll": true,
"exceptionList": ""
}
}
]
}
Debugger Logs
<-- C (evaluate-29): {"command":"evaluate","arguments":{"expression":"","frameId":1003,"context":"hover","line":16,"column":0,"source":{"name":"main.c","path":"c:\\Users\\TestUser\\AppData\\Local\\Ashling\\RiscFree_IDEv25.1.0_Sp1.2\\workspace\\qemu-riscv32-picojpeg\\src\\main.c","sources":[],"checksums":[]}},"type":"request","seq":29}
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (9101) <-1051-var-create --thread 1 --frame 0 - * \"\"\r\n"},"seq":1031}
1: (9101) <-1051-var-create --thread 1 --frame 0 - * ""
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (9112) ->1051^error,msg=\"-var-create: unable to create variable object\"\r\n"},"seq":1033}
1: (9112) ->1051^error,msg="-var-create: unable to create variable object"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (9112) ->(gdb)\r\n"},"seq":1035}
1: (9112) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (9113) 1051: elapsed time 11\r\n"},"seq":1037}
1: (9113) 1051: elapsed time 11
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (9113) ->&\"\\n\"\r\n"},"seq":1039}
1: (9113) ->&"\n"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (9113) ->^done\r\n"},"seq":1041}
1: (9113) ->^done
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (9113) ->(gdb)\r\n"},"seq":1043}
1: (9113) ->(gdb)
--> R (evaluate-29): {"type":"response","request_seq":29,"success":false,"command":"evaluate","message":"Evaluation error","body":{},"seq":1045}
<-- C (disconnect-30): {"command":"disconnect","arguments":{"restart":false},"type":"request","seq":30}
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (12332) <-1052kill\r\n"},"seq":1048}
1: (12332) <-1052kill
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (12344) ->&\"kill\\n\"\r\n"},"seq":1050}
1: (12344) ->&"kill\n"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (12344) ->~\"Kill the program being debugged? (y or n) [answered Y; input not from terminal]\\n\"\r\n"},"seq":1052}
1: (12344) ->~"Kill the program being debugged? (y or n) [answered Y; input not from terminal]\n"
--> E (output): {"type":"event","event":"output","body":{"category":"stdout","output":"Kill the program being debugged? (y or n) [answered Y; input not from terminal]\n"},"seq":1054}
Kill the program being debugged? (y or n) [answered Y; input not from terminal]
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (12360) ->=thread-exited,id=\"1\",group-id=\"i1\"\r\n"},"seq":1056}
1: (12360) ->=thread-exited,id="1",group-id="i1"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (12360) ->=thread-group-exited,id=\"i1\"\r\n"},"seq":1058}
1: (12360) ->=thread-group-exited,id="i1"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (12360) ->~\"[Inferior 1 (Remote target) killed]\\n\"\r\n"},"seq":1060}
1: (12360) ->~"[Inferior 1 (Remote target) killed]\n"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (12360) ->1052^done\r\n"},"seq":1062}
1: (12360) ->1052^done
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (12360) ->(gdb)\r\n"},"seq":1064}
1: (12360) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (12361) ->&\"\\n\"\r\n"},"seq":1066}
1: (12361) ->&"\n"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (12361) ->^done\r\n"},"seq":1068}
1: (12361) ->^done
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (12361) ->(gdb)\r\n"},"seq":1070}
1: (12361) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (12362) Send Event AD7ThreadDestroyEvent\r\n"},"seq":1072}
1: (12362) Send Event AD7ThreadDestroyEvent
--> E (output): {"type":"event","event":"output","body":{"category":"stdout","output":"[Inferior 1 (Remote target) killed]\n"},"seq":1074}
[Inferior 1 (Remote target) killed]
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (12362) 1052: elapsed time 30\r\n"},"seq":1076}
1: (12362) 1052: elapsed time 30
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (12368) <-logout\r\n"},"seq":1078}
1: (12368) <-logout
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (12369) <-logout\r\n"},"seq":1080}
1: (12369) <-logout
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (12377) Send Event AD7ProgramDestroyEvent\r\n"},"seq":1082}
1: (12377) Send Event AD7ProgramDestroyEvent
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"The program 'c:\\Users\\TestUser\\AppData\\Local\\Ashling\\RiscFree_IDEv25.1.0_Sp1.2\\workspace\\qemu-riscv32-picojpeg\\Debug\\qemu-riscv32-picojpeg.elf' has exited with code 0 (0x00000000).\r\n\r\n"},"seq":1084}
The program 'c:\Users\TestUser\AppData\Local\Ashling\RiscFree_IDEv25.1.0_Sp1.2\workspace\qemu-riscv32-picojpeg\Debug\qemu-riscv32-picojpeg.elf' has exited with code 0 (0x00000000).
--> E (output): {"type":"event","event":"output","body":{"category":"telemetry","output":"VS/Diagnostics/Debugger/DebugCompleted","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.DebugCompleted.BreakCounter":2}},"seq":1086}
--> R (disconnect-30): {"type":"response","request_seq":30,"success":true,"command":"disconnect","body":{},"seq":1088}
Other Extensions
We've tried the same sequence using cdt-gdb, where it's working perfect.
Additional Information
Comparison with Eclipse based IDE is below.
I had a detailed look into this issue as the fix mentioned below based on my initial analysis didn't work as expected.
Though I have added register restore mechanism in the GDBServer kill packet handling to address the issue, GDBServer exits too quickly(terminated by VSCode extension) without leaving enough time for this operations to complete . We are not able to catch the SIGINT(sent by RiscFree Eclipse version) or SIGTERM signals either as the VSCode extension might be using SIGKILL(can't catch this) for the termination.
Something similar we think is below.