Open joelspadin opened 1 year ago
There seems to be some issue with the current state of threads from GDB.
In the response from GDB, it is not returning a thread with id 1, but claiming the current thread is 1. If thread 1 has disappeared, it should return saying current-thread-id is 2.
1: (315) ->1024^done,threads=[{id="2" ... current-thread-id="1"
1: (313) <-1024-thread-info
<-- C (threads-9): {"command":"threads","type":"request","seq":9}
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (315) ->1024^done,threads=[{id=\"2\",target-id=\"Thread 536891112\",details=\"main SUSPENDED PRIO 0\",frame={level=\"0\",addr=\"0x0000a270\",func=\"arch_swap\",args=[{name=\"key\",value=\"0\"},{name=\"key@entry\",value=\"0\"}],file=\"/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/swap.c\",fullname=\"/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/swap.c\",line=\"53\",arch=\"armv8-m.main\"},state=\"stopped\"},{id=\"3\",target-id=\"Thread 536890928\",details=\"idle 00 UNKNOWN PRIO 15\",frame={level=\"0\",addr=\"0x00009f7e\",func=\"arch_cpu_idle\",args=[],file=\"/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/cpu_idle.S\",fullname=\"/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/cpu_idle.S\",line=\"105\",arch=\"armv8-m.main\"},state=\"stopped\"},{id=\"4\",target-id=\"Thread 536874792\",details=\"logging PENDING PRIO 14\",frame={level=\"0\",addr=\"0x0000a270\",func=\"arch_swap\",args=[{name=\"key\",value=\"0\"},{name=\"key@entry\",value=\"0\"}],file=\"/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/swap.c\",fullname=\"/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/swap.c\",line=\"53\",arch=\"armv8-m.main\"},state=\"stopped\"},{id=\"5\",target-id=\"Thread 536883488\",details=\"usbworkq PENDING PRIO 255\",frame={level=\"0\",addr=\"0x0000a270\",func=\"arch_swap\",args=[{name=\"key\",value=\"0\"},{name=\"key@entry\",value=\"0\"}],file=\"/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/swap.c\",fullname=\"/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/swap.c\",line=\"53\",arch=\"armv8-m.main\"},state=\"stopped\"},{id=\"6\",target-id=\"Thread 536891296\",details=\"sysworkq PENDING PRIO 255\",frame={level=\"0\",addr=\"0x0000a270\",func=\"arch_swap\",args=[{name=\"key\",value=\"0\"},{name=\"key@entry\",value=\"0\"}],file=\"/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/swap.c\",fullname=\"/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/swap.c\",line=\"53\",arch=\"armv8-m.main\"},state=\"stopped\"},{id=\"7\",target-id=\"Thread 536883224\",details=\"ipm_work_q PENDING PRIO 240\",frame={level=\"0\",addr=\"0x0000a270\",func=\"arch_swap\",args=[{name=\"key\",value=\"0\"},{name=\"key@entry\",value=\"0\"}],file=\"/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/swap.c\",fullname=\"/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/swap.c\",line=\"53\",arch=\"armv8-m.main\"},state=\"stopped\"},{id=\"8\",target-id=\"Thread 536889384\",details=\" PENDING PRIO 255\",frame={level=\"0\",addr=\"0x0000a270\",func=\"arch_swap\",args=[{name=\"key\",value=\"0\"},{name=\"key@entry\",value=\"0\"}],file=\"/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/swap.c\",fullname=\"/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/swap.c\",line=\"53\",arch=\"armv8-m.main\"},state=\"stopped\"},{id=\"9\",target-id=\"Thread 536890744\",details=\" PENDING PRIO 250\",frame={level=\"0\",addr=\"0x0000a270\",func=\"arch_swap\",args=[{name=\"key\",value=\"0\"},{name=\"key@entry\",value=\"0\"}],file=\"/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/swap.c\",fullname=\"/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/swap.c\",line=\"53\",arch=\"armv8-m.main\"},state=\"stopped\"},{id=\"10\",target-id=\"Thread 536883704\",details=\"BT TX PENDING PRIO 247\",frame={level=\"0\",addr=\"0x0000a270\",func=\"arch_swap\",args=[{name=\"key\",value=\"0\"},{name=\"key@entry\",value=\"0\"}],file=\"/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/swap.c\",fullname=\"/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/swap.c\",line=\"53\",arch=\"armv8-m.main\"},state=\"stopped\"},{id=\"11\",target-id=\"Thread 536883888\",details=\"BT RX PENDING PRIO 248\",frame={level=\"0\",addr=\"0x0000a270\",func=\"arch_swap\",args=[{name=\"key\",value=\"0\"},{name=\"key@entry\",value=\"0\"}],file=\"/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/swap.c\",fullname=\"/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/swap.c\",line=\"53\",arch=\"armv8-m.main\"},state=\"stopped\"}],current-thread-id=\"1\"\n"},"seq":375}
1: (315) ->1024^done,threads=[{id="2",target-id="Thread 536891112",details="main SUSPENDED PRIO 0",frame={level="0",addr="0x0000a270",func="arch_swap",args=[{name="key",value="0"},{name="key@entry",value="0"}],file="/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/swap.c",fullname="/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/swap.c",line="53",arch="armv8-m.main"},state="stopped"},{id="3",target-id="Thread 536890928",details="idle 00 UNKNOWN PRIO 15",frame={level="0",addr="0x00009f7e",func="arch_cpu_idle",args=[],file="/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/cpu_idle.S",fullname="/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/cpu_idle.S",line="105",arch="armv8-m.main"},state="stopped"},{id="4",target-id="Thread 536874792",details="logging PENDING PRIO 14",frame={level="0",addr="0x0000a270",func="arch_swap",args=[{name="key",value="0"},{name="key@entry",value="0"}],file="/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/swap.c",fullname="/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/swap.c",line="53",arch="armv8-m.main"},state="stopped"},{id="5",target-id="Thread 536883488",details="usbworkq PENDING PRIO 255",frame={level="0",addr="0x0000a270",func="arch_swap",args=[{name="key",value="0"},{name="key@entry",value="0"}],file="/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/swap.c",fullname="/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/swap.c",line="53",arch="armv8-m.main"},state="stopped"},{id="6",target-id="Thread 536891296",details="sysworkq PENDING PRIO 255",frame={level="0",addr="0x0000a270",func="arch_swap",args=[{name="key",value="0"},{name="key@entry",value="0"}],file="/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/swap.c",fullname="/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/swap.c",line="53",arch="armv8-m.main"},state="stopped"},{id="7",target-id="Thread 536883224",details="ipm_work_q PENDING PRIO 240",frame={level="0",addr="0x0000a270",func="arch_swap",args=[{name="key",value="0"},{name="key@entry",value="0"}],file="/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/swap.c",fullname="/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/swap.c",line="53",arch="armv8-m.main"},state="stopped"},{id="8",target-id="Thread 536889384",details=" PENDING PRIO 255",frame={level="0",addr="0x0000a270",func="arch_swap",args=[{name="key",value="0"},{name="key@entry",value="0"}],file="/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/swap.c",fullname="/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/swap.c",line="53",arch="armv8-m.main"},state="stopped"},{id="9",target-id="Thread 536890744",details=" PENDING PRIO 250",frame={level="0",addr="0x0000a270",func="arch_swap",args=[{name="key",value="0"},{name="key@entry",value="0"}],file="/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/swap.c",fullname="/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/swap.c",line="53",arch="armv8-m.main"},state="stopped"},{id="10",target-id="Thread 536883704",details="BT TX PENDING PRIO 247",frame={level="0",addr="0x0000a270",func="arch_swap",args=[{name="key",value="0"},{name="key@entry",value="0"}],file="/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/swap.c",fullname="/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/swap.c",line="53",arch="armv8-m.main"},state="stopped"},{id="11",target-id="Thread 536883888",details="BT RX PENDING PRIO 248",frame={level="0",addr="0x0000a270",func="arch_swap",args=[{name="key",value="0"},{name="key@entry",value="0"}],file="/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/swap.c",fullname="/home/joel/projects/zmk/zephyr/arch/arm/core/aarch32/swap.c",line="53",arch="armv8-m.main"},state="stopped"}],current-thread-id="1"
I noticed when debugging from the command line that there is initially a thread 1, but that it very quickly exits. I'm guessing that Zephyr starts a thread to initialize the system and then the thread exits when it's done.
I think this may actually be a bug in the rtos plugin for JLink. This seems related to #10848.
Environment
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 withWhen 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:
-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)west debugserver
to start the GDB server.Debugger Configurations
Debugger Logs
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