I am currently building a VS code extension to visualize C# variables and datatables. And I have successfully achieved this in single threaded application by calling these in sequence:
This is what i have done for single threaded C# application in javascript.
// Get Active Debug Session
const session = vscode.debug.activeDebugSession;
// Get Thread
const threadResponse = await session.customRequest('threads');
const threadId = threadResponse.threads[0].id;
// Get StackFrame
const stackResponse = await session.customRequest('stackTrace', { threadId: threadId, startFrame: 0 });
const frameId = stackResponse.stackFrames[0].id;
// Get Scope
const scopeResponse = await session.customRequest('scopes', { frameId: frameId });
const variableReference = scopeResponse.scopes[0].variablesReference;
// Get Variable
const variableResponse = await session.customRequest('variables', { variablesReference: variableReference });
const variables = variableResponse.variables;
You can check this out: https://code.visualstudio.com/updates/v1_90#_debug-stack-focus-api.
The new activeStackItem
interface can directly return the currently focused thread or stack frame:
const activeStackItem = vscode.debug.activeStackItem;
let frameId = undefined
if (activeStackItem instanceof vscode.DebugStackFrame) {
frameId = activeStackItem.frameId;
}