ARMmbed / mbed-os

Arm Mbed OS is a platform operating system designed for the internet of things
https://mbed.com
Other
4.68k stars 2.98k forks source link

Multithreading pyOCD debugging doesn't work on visual studio code #4287

Closed c1728p9 closed 5 years ago

c1728p9 commented 7 years ago

Reporting at the request of @janjongboom

When using a project exported to visual studio code with and pyOCD with RTOS integration (https://github.com/mbedmicro/pyOCD/pull/242) the debugging session is abruptly terminated due to thread ID 1 not existing. A log of this can be found here visual_studio_log.txt.

flit commented 7 years ago

First, note that there are two types of thread IDs: the target thread ID, as reported by the gdb server, and gdb's own thread IDs. The latter start at 1 and increment for every new thread.

pyOCD uses a target thread ID of 1 as the default thread before RTOS integration is enabled. This will also end up with a gdb thread ID of 1 since it's the first thread reported by pyOCD.

I think this error is caused by thread ID 1 disappearing and being replaced with the RTOS threads. You can see this being reported here in the log:

1: (5528) <-1020-thread-info
1: (5593) ->=thread-exited,id="1",group-id="i1"
1: (5600) ->=thread-created,id="2",group-id="i1"
1: (5600) ->~"[New Thread -2146959359]\n"
1: (5600) ->=thread-created,id="3",group-id="i1"
1: (5600) ->~"[New Thread -2117580494]\n"

What I don't fully understand is who is reporting the error? Is it gdb, or Visual Studio Code?

There also seems to be some connection to having a breakpoint set on thread 1 based on the error message: "Failed to find thread 1 for break event".

Interestingly, on rare occasions I've seen Eclipse report an error about thread ID 1 not being found. But it hasn't been consistent enough that I could track it down. And it's not fatal to the debug session. [Mirrored to Jira]

adbridge commented 6 years ago

Internal Jira reference: https://jira.arm.com/browse/IOTCORE-113

0xc0170 commented 5 years ago

@flit Shall this be moved to pyOCD? Is it still relevant?

flit commented 5 years ago

I never got any more information about this bug and don't know if it applies anymore. Several people are successfully using pyOCD with the cortex-debug plugin for VSC. But I don't know if they are using a supported RTOS.

For ISG, with Mbed Studio it probably isn't very important. Threaded debugging certainly works with Mbed Studio.

I guess we can move it to pyOCD and see if anyone else chimes in?

0xc0170 commented 5 years ago

You can only transfer issues between repositories owned by the same user or organization account.

I can't transfer this to pyOCD. I'll close this and if you find this still relevant, please create it in pyOCD repository. Thanks!