(output: string, params: DebugStackParams)
| 99 | } |
| 100 | |
| 101 | function parseStackOutput(output: string, params: DebugStackParams): DebugThread[] { |
| 102 | const lines = output |
| 103 | .split(/\r?\n/) |
| 104 | .map((line) => line.trimEnd()) |
| 105 | .filter((line) => line.trim().length > 0); |
| 106 | |
| 107 | const threads: DebugThread[] = []; |
| 108 | let currentThread: DebugThread | null = null; |
| 109 | |
| 110 | for (const line of lines) { |
| 111 | const parsedThread = parseThreadLine(line); |
| 112 | if (parsedThread) { |
| 113 | currentThread = { |
| 114 | threadId: parsedThread.threadId, |
| 115 | name: parsedThread.name, |
| 116 | truncated: false, |
| 117 | frames: [], |
| 118 | }; |
| 119 | threads.push(currentThread); |
| 120 | continue; |
| 121 | } |
| 122 | |
| 123 | const frame = parseFrameLine(line); |
| 124 | if (!frame) { |
| 125 | continue; |
| 126 | } |
| 127 | |
| 128 | if (!currentThread) { |
| 129 | const threadId = typeof params.threadIndex === 'number' ? params.threadIndex + 1 : 1; |
| 130 | currentThread = { |
| 131 | threadId, |
| 132 | name: `Thread ${threadId}`, |
| 133 | truncated: false, |
| 134 | frames: [], |
| 135 | }; |
| 136 | threads.push(currentThread); |
| 137 | } |
| 138 | |
| 139 | currentThread.frames.push(frame); |
| 140 | } |
| 141 | |
| 142 | if (typeof params.maxFrames === 'number') { |
| 143 | for (const thread of threads) { |
| 144 | thread.truncated = thread.frames.length >= params.maxFrames; |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | return threads; |
| 149 | } |
| 150 | |
| 151 | export function createDebugStackExecutor( |
| 152 | debuggerManager: DebuggerToolContext['debugger'], |
no test coverage detected