microsoft / microsoft/vscode-cpptools
"Unable to start debugging. Failed to find thread 1 for break event" when debugging Zephyr app
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 1.7k
- Avg merge
- 14h 46m
- Merged PRs (30d)
- 61
Description
Environment
- OS and version: Windows 11 build 22621, WSL2 Ubuntu 22.04.1 LTS
- VS Code: 1.73.1
- C/C++ extension: 1.12.4
- OS and version of remote machine (if applicable): nRF5340 dev kit, Zephyr RTOS version 3.0
- GDB / LLDB version: GNU gdb (Zephyr SDK 0.15.1) 12.1
The USB JLink debugger from the nRF5340 DK is passed through to WSL as described in https://learn.microsoft.com/en-us/windows/wsl/connect-usb
Bug Summary and Steps to Reproduce
Bug Summary:
I am trying to debug a Zephyr application on an nRF5340 DK using its built-in JLink. When the application is built with CONFIG_DEBUG_THREAD_INFO=y, the debug session fails immediately with
ERROR: Unable to start debugging. Failed to find thread 1 for break event
When I debug from the command line, it works properly. It appears that thread 1 is only used for system initialization in Zephyr, and it exits shortly after the program starts, which may be the source of the error.
Steps to reproduce:
- Build a Zephyr application with
-b nrf5340dk_nrf5340_cpuapp. (I am using https://zmk.dev/ which doesn't have support for the nRF5340 DK in mainline code yet, but I expect this could be reproduced with one of the Zephyr sample apps, like https://docs.zephyrproject.org/latest/samples/basic/blinky/README.html) - Add to prj.conf
CONFIG_DEBUG=y CONFIG_DEBUG_INFO=y CONFIG_DEBUG_THREAD_INFO=y - Run
west debugserverto start the GDB server. - Start the vscode debugger.
Debugger Configurations
// Launch configuration
{
"name": "GDB,
"type": "cppdbg",
"request": "launch",
"cwd": "${workspaceFolder:zmk}/app",
"program": "${workspaceFolder:zmk}/app/build/zmk_uno/zephyr/zmk.elf",
"miDebuggerPath": "/home/joel/.local/zephyr-sdk-0.15.1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gdb",
"miDebuggerServerAddress": "localhost:2331",
"preLaunchTask": "gdbserver",
"launchCompleteCommand": "exec-continue",
"logging": {
"trace": true,
"traceResponse": true,
"engineLogging": true
}
},
// Tasks
{
"label": "gdbserver",
"type": "shell",
"options": {
"cwd": "${workspaceFolder:zmk}/app"
},
"command": "west debugserver -d build/zmk_uno",
"isBackground": true,
"problemMatcher": {
"owner": "jlink",
"fileLocation": "autoDetect",
"pattern":[
{
"regexp": "$^",
"file": 1,
"location": 2,
"message": 3
}
],
"background": {
"activeOnStart": true,
"beginsPattern": "west debugserver: rebuilding",
"endsPattern": "J-Link GDB server running"
}
}
}
Debugger Logs
See error.log in additional information.
Other Extensions
No response
Additional Information
The debug console log is too large to paste directly, so I've attached it here:
error.log
When debugging from the command line, where GDB works properly, I get the following output:
debug.log
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the attached error.log and debug.log, then reproduce with a Zephyr sample built for nrf5340dk_nrf5340_cpuapp and CONFIG_DEBUG_THREAD_INFO=y. Check the VS Code debugger launch configuration and the C/C++ extension's GDB thread and break-event handling. Done means the VS Code session starts successfully without the missing-thread error, matching command-line GDB behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- devtools, embedded-iot
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100