I am using VSCode debug APIs from an extension. My goal is to read CPU registers for a C++ program from a gdb/lldb debugger during a debug session. I also have similar requests for other things (reading memory, disassembly, etc.) that current debuggers don't provide
I have the following in my extension...I can provide a full test case if needed. Yes, I know I have a bug here in that after the first await, the session may not be active anymore and I don't have full error checking shown.
static async getRegisters() {
const session = vscode.debug.activeDebugSession;
if (session && text) { // Make sure we still have a session
// The following gets me the right result
const sTrace = await session.customRequest('stackTrace', { threadId: 1 });
const frameId = sTrace.stackFrames[0].id;
// The following does execute but the results are printed to debug console
// rather than returning the result
// I tried many variations of arguments and contexts types
const text = '-exec -data-list-register-names';
const arg : DebugProtocol.EvaluateArguments = {expression: text, frameId: frameId, context:'hover'};
session.customRequest('evaluate', arg).then((response) => {
console.log(response.result);
});
}
}
I want the results of gdb somehow provided back to my extension. The results are being printed to the Debug Console instead and I get an empty string. I have also tried setting up an event handler vscode.debug.onDidReceiveDebugSessionCustomEvent for custom commands but nothing fires. Is there a better way?
Maybe the first argument to customRequest should not be 'evaluate' but I don't see anything else in the DebugProtocol spec. to send a custom command to the actual debugger.
Same issue! Here is my solution:
It seems instead of a response with proper values, the DA directly triggers an event to print on the debug console.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With