File tree Expand file tree Collapse file tree 3 files changed +23
-7
lines changed
Expand file tree Collapse file tree 3 files changed +23
-7
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import {
1818 MIBreakpointInsertOptions ,
1919 MIBreakpointLocation ,
2020 MIShowResponse ,
21+ sendDataEvaluateExpression ,
2122 sendExecInterrupt ,
2223} from '../mi' ;
2324import { VarManager } from '../varManager' ;
@@ -297,6 +298,17 @@ export class GDBBackend extends events.EventEmitter implements IGDBBackend {
297298 return isProcessActive ( this . proc ) ;
298299 }
299300
301+ public async queryCurrentThreadId ( ) : Promise < number > {
302+ const threadIdResult = await sendDataEvaluateExpression (
303+ this ,
304+ this . gdbVersionAtLeast ( '7.11' ) ? '$_gthread' : '$_thread'
305+ ) ;
306+ return threadIdResult . value !== undefined &&
307+ threadIdResult . value !== 'void'
308+ ? parseInt ( threadIdResult . value , 10 )
309+ : - 1 ;
310+ }
311+
300312 protected nextToken ( ) {
301313 return this . token ++ ;
302314 }
Original file line number Diff line number Diff line change @@ -436,12 +436,7 @@ export abstract class GDBDebugSessionBase extends LoggingDebugSession {
436436 this . waitPaused = resolve ;
437437 } ) ;
438438 if ( this . gdb . isNonStopMode ( ) ) {
439- const threadInfo = await mi . sendThreadInfoRequest ( this . gdb , { } ) ;
440-
441- this . waitPausedThreadId = parseInt (
442- threadInfo [ 'current-thread-id' ] ,
443- 10
444- ) ;
439+ this . waitPausedThreadId = await this . gdb . queryCurrentThreadId ( ) ;
445440 this . gdb . pause ( this . waitPausedThreadId ) ;
446441 } else {
447442 this . gdb . pause ( ) ;
@@ -1934,7 +1929,8 @@ export abstract class GDBDebugSessionBase extends LoggingDebugSession {
19341929 if (
19351930 this . waitPaused &&
19361931 resultData . reason === 'signal-received' &&
1937- this . waitPausedThreadId === id
1932+ ( this . waitPausedThreadId === id ||
1933+ this . waitPausedThreadId === - 1 )
19381934 ) {
19391935 suppressHandleGDBStopped = true ;
19401936 }
Original file line number Diff line number Diff line change @@ -128,6 +128,14 @@ export interface IGDBBackend extends EventEmitter {
128128 sendCommands ( commands ?: string [ ] ) : Promise < void > ;
129129 gdbVersionAtLeast ( targetVersion : string ) : boolean ;
130130
131+ /** Ask GDB for its current thread ID.
132+ *
133+ * Can return 0 when GDB has no threads, or -1 in case of unexpected errors
134+ * (which will in some cases make things work anyway because "--thread -1"
135+ * is equivalent to omitting "--thread" - that is probably an implementation
136+ * detail though). */
137+ queryCurrentThreadId ( ) : Promise < number > ;
138+
131139 on (
132140 event : 'consoleStreamOutput' ,
133141 listener : ( output : string , category : string ) => void
You can’t perform that action at this time.
0 commit comments