microsoft / microsoft/vscode-cpptools

"Unable to start debugging. Failed to find thread 1 for break event" when debugging Zephyr app

Offen
#10,195 3 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

debugger
Vorherrschende Sprache
TypeScript
Sterne
6.2k
Forks
1.7k
Ø Merge
14 Std. 46 Min.
Gemergte PRs (30 T.)
61

Beschreibung

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:

  1. 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)
  2. Add to prj.conf
    CONFIG_DEBUG=y
    CONFIG_DEBUG_INFO=y
    CONFIG_DEBUG_THREAD_INFO=y
    
  3. Run west debugserver to start the GDB server.
  4. 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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit der Durchsicht der angehängten error.log und debug.log und reproduziere den Fehler anschließend mit einem für nrf5340dk_nrf5340_cpuapp erstellten Zephyr-Beispiel und CONFIG_DEBUG_THREAD_INFO=y. Überprüfe die Startkonfiguration des VS Code-Debuggers sowie die Verarbeitung von GDB-Threads und Break-Ereignissen durch die C/C++-Erweiterung. Als abgeschlossen gilt die Aufgabe, wenn die VS Code-Sitzung ohne den Fehler zu einem fehlenden Thread erfolgreich startet und sich wie GDB über die Befehlszeile verhält.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
cpp
Bereich
devtools, embedded-iot
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
28/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.