(response: DebugProtocol.ThreadsResponse)
| 2301 | } |
| 2302 | |
| 2303 | protected threadsRequest(response: DebugProtocol.ThreadsResponse): Promise<void> { |
| 2304 | response.body = { threads: [] }; |
| 2305 | if (!this.isMIStatusStopped() || !this.stopped || this.disableSendStoppedEvents || this.continuing) { |
| 2306 | this.sendResponse(response); |
| 2307 | return Promise.resolve(); |
| 2308 | } |
| 2309 | |
| 2310 | if (this.sendDummyStackTrace) { |
| 2311 | if (this.args.showDevDebugOutput) { |
| 2312 | this.handleMsg('log', 'Returning dummy thread-id to workaround VSCode issue with pause button not working\n'); |
| 2313 | } |
| 2314 | const useThread = this.currentThreadId || (this.activeThreadIds.size ? this.activeThreadIds.values[0] : 1); |
| 2315 | response.body.threads = [new Thread(useThread, 'cortex-debug-dummy-thread')]; |
| 2316 | this.sendResponse(response); |
| 2317 | return Promise.resolve(); |
| 2318 | } |
| 2319 | |
| 2320 | return new Promise<void>(async (resolve) => { |
| 2321 | try { |
| 2322 | const threadIdNode = await this.miDebugger.sendCommand('thread-list-ids'); |
| 2323 | const threadIds: number[] = threadIdNode.result('thread-ids').map((ti) => parseInt(ti[1])); |
| 2324 | const currentThread = threadIdNode.result('current-thread-id'); |
| 2325 | |
| 2326 | if (!threadIds || (threadIds.length === 0)) { |
| 2327 | // Yes, this does happen at the very beginning of an RTOS session |
| 2328 | this.sendResponse(response); |
| 2329 | resolve(); |
| 2330 | return; |
| 2331 | } |
| 2332 | |
| 2333 | for (const thId of threadIds) { |
| 2334 | // Make sure VSCode knows about all the threads. GDB may still be in the process of notifying |
| 2335 | // new threads while we already have a thread-list. Technically, this should never happen |
| 2336 | if (!this.activeThreadIds.has(thId)) { |
| 2337 | this.handleThreadCreated({ threadId: thId, threadGroupId: 'i1' }); |
| 2338 | } |
| 2339 | } |
| 2340 | |
| 2341 | if (!currentThread) { |
| 2342 | this.currentThreadId = threadIds.findIndex((x) => { |
| 2343 | return x === this.stoppedThreadId; |
| 2344 | }) >= 0 ? this.stoppedThreadId : threadIds[0]; |
| 2345 | if (traceThreads) { |
| 2346 | this.handleMsg('log', `**** thread-list-ids: no current thread, setting to ${this.currentThreadId}\n`); |
| 2347 | } |
| 2348 | if (threadIds.length > 1) { // No confusion when there is only one thread |
| 2349 | // thread-select doesn't actually work on most embedded gdb-servers. But we will at least |
| 2350 | // be in sync with gdb for querying local variables, etc. Things may rectify themselves like |
| 2351 | // they do with OpenOCD bit later. In general, this only happens with buggy gdb-servers |
| 2352 | await this.miDebugger.sendCommand(`thread-select ${this.currentThreadId}`); |
| 2353 | } |
| 2354 | } |
| 2355 | else { |
| 2356 | this.currentThreadId = parseInt(currentThread); |
| 2357 | if (traceThreads) { |
| 2358 | this.handleMsg('log', `**** thread-list-ids: current thread = ${this.currentThreadId}\n`); |
| 2359 | } |
| 2360 | } |
nothing calls this directly
no test coverage detected