MCPcopy
hub / github.com/microsoft/vscode-js-debug / logStackTrace

Method logStackTrace

src/test/logger.ts:154–210  ·  view source on GitHub ↗
(threadId: number, withScopes = 0)

Source from the content-addressed store, hash-verified

152 }
153
154 async logStackTrace(threadId: number, withScopes = 0) {
155 const initial = await this._dap.stackTrace({ threadId });
156 const stack = initial.stackFrames;
157 let totalFrames = initial.totalFrames || stack.length;
158 while (stack.length < totalFrames) {
159 const response = await this._dap.stackTrace({
160 threadId,
161 startFrame: stack.length,
162 levels: Math.min(20, totalFrames - stack.length),
163 });
164 stack.push(...response.stackFrames);
165 if (response.totalFrames) totalFrames = Math.min(totalFrames, response.totalFrames);
166 }
167 let emptyLine = withScopes > 0;
168 for (const frame of stack) {
169 if (emptyLine) this._log('');
170 if (frame.presentationHint === 'label') {
171 this._log(`----${frame.name}----`);
172 emptyLine = false;
173 continue;
174 }
175 const origin = frame.source && frame.source.presentationHint === 'deemphasize'
176 ? ` <hidden: ${frame.source.origin || ''}>`
177 : '';
178 this._log(
179 `${frame.name} @ ${
180 frame.source ? frame.source.path! : 'unknown'
181 }:${frame.line}:${frame.column}${origin}`,
182 );
183 if (withScopes-- <= 0) continue;
184 const scopes = await this._dap.scopes({ frameId: frame.id });
185 if (typeof scopes === 'string') {
186 this._log(` scope error: ${scopes}`);
187 } else {
188 for (let i = 0; i < scopes.scopes.length; i++) {
189 const scope = scopes.scopes[i];
190 if (scope.expensive) {
191 this._log(` scope #${i}: ${scope.name} [expensive]`);
192 continue;
193 }
194 await this.logVariable(
195 {
196 name: 'scope #' + i,
197 value: scope.name,
198 variablesReference: scope.variablesReference,
199 namedVariables: scope.namedVariables,
200 indexedVariables: scope.indexedVariables,
201 },
202 {},
203 ' ',
204 );
205 }
206 }
207 }
208
209 return stack;
210 }
211

Callers 15

waitForPauseFunction · 0.80
wasm.test.tsFile · 0.80
waitForPauseFunction · 0.80
breakpointsTest.tsFile · 0.80
pauseAndNextFunction · 0.80
variablesTest.tsFile · 0.80
waitAndStayPausedFunction · 0.80
waitForPauseFunction · 0.80
threadsTest.tsFile · 0.80
runCrossThreadTestFunction · 0.80
waitForPauseFunction · 0.80

Calls 5

logVariableMethod · 0.95
minMethod · 0.80
stackTraceMethod · 0.65
pushMethod · 0.65
scopesMethod · 0.65

Tested by 4

waitAndStayPausedFunction · 0.64
waitForPauseFunction · 0.64
waitForPauseFunction · 0.64
waitForPauseFunction · 0.64