Add valuesFormatting parameter to launch config
This commit is contained in:
parent
d498b381bf
commit
beb80f7375
7 changed files with 201 additions and 43 deletions
62
package.json
62
package.json
|
|
@ -101,6 +101,16 @@
|
||||||
"description": "Additional arguments to pass to GDB",
|
"description": "Additional arguments to pass to GDB",
|
||||||
"default": []
|
"default": []
|
||||||
},
|
},
|
||||||
|
"valuesFormatting": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Set the way of showing variable values. 'disabled' - show value as is, 'parseText' - parse debuggers output text into structure, 'prettyPrinters' - enable debuggers custom pretty-printers if there are any",
|
||||||
|
"default": "parseText",
|
||||||
|
"enum": [
|
||||||
|
"disabled",
|
||||||
|
"parseText",
|
||||||
|
"prettyPrinters"
|
||||||
|
]
|
||||||
|
},
|
||||||
"printCalls": {
|
"printCalls": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Prints all GDB calls to the console",
|
"description": "Prints all GDB calls to the console",
|
||||||
|
|
@ -192,6 +202,16 @@
|
||||||
"description": "If true this will connect to a gdbserver instead of attaching to a PID",
|
"description": "If true this will connect to a gdbserver instead of attaching to a PID",
|
||||||
"default": false
|
"default": false
|
||||||
},
|
},
|
||||||
|
"valuesFormatting": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Set the way of showing variable values. 'disabled' - show value as is, 'parseText' - parse debuggers output text into structure, 'prettyPrinters' - enable debuggers custom pretty-printers if there are any",
|
||||||
|
"default": "parseText",
|
||||||
|
"enum": [
|
||||||
|
"disabled",
|
||||||
|
"parseText",
|
||||||
|
"prettyPrinters"
|
||||||
|
]
|
||||||
|
},
|
||||||
"printCalls": {
|
"printCalls": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Prints all GDB calls to the console",
|
"description": "Prints all GDB calls to the console",
|
||||||
|
|
@ -466,6 +486,16 @@
|
||||||
"description": "Additional arguments to pass to LLDB",
|
"description": "Additional arguments to pass to LLDB",
|
||||||
"default": []
|
"default": []
|
||||||
},
|
},
|
||||||
|
"valuesFormatting": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Set the way of showing variable values. 'disabled' - show value as is, 'parseText' - parse debuggers output text into structure, 'prettyPrinters' - enable debuggers custom pretty-printers if there are any",
|
||||||
|
"default": "parseText",
|
||||||
|
"enum": [
|
||||||
|
"disabled",
|
||||||
|
"parseText",
|
||||||
|
"prettyPrinters"
|
||||||
|
]
|
||||||
|
},
|
||||||
"printCalls": {
|
"printCalls": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Prints all lldb calls to the console",
|
"description": "Prints all lldb calls to the console",
|
||||||
|
|
@ -552,6 +582,16 @@
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "PID of running program or program name"
|
"description": "PID of running program or program name"
|
||||||
},
|
},
|
||||||
|
"valuesFormatting": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Set the way of showing variable values. 'disabled' - show value as is, 'parseText' - parse debuggers output text into structure, 'prettyPrinters' - enable debuggers custom pretty-printers if there are any",
|
||||||
|
"default": "parseText",
|
||||||
|
"enum": [
|
||||||
|
"disabled",
|
||||||
|
"parseText",
|
||||||
|
"prettyPrinters"
|
||||||
|
]
|
||||||
|
},
|
||||||
"printCalls": {
|
"printCalls": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Prints all LLDB calls to the console",
|
"description": "Prints all LLDB calls to the console",
|
||||||
|
|
@ -713,6 +753,16 @@
|
||||||
"description": "Additional arguments to pass to mago",
|
"description": "Additional arguments to pass to mago",
|
||||||
"default": []
|
"default": []
|
||||||
},
|
},
|
||||||
|
"valuesFormatting": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Set the way of showing variable values. 'disabled' - show value as is, 'parseText' - parse debuggers output text into structure, 'prettyPrinters' - enable debuggers custom pretty-printers if there are any",
|
||||||
|
"default": "parseText",
|
||||||
|
"enum": [
|
||||||
|
"disabled",
|
||||||
|
"parseText",
|
||||||
|
"prettyPrinters"
|
||||||
|
]
|
||||||
|
},
|
||||||
"printCalls": {
|
"printCalls": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Prints all mago calls to the console",
|
"description": "Prints all mago calls to the console",
|
||||||
|
|
@ -739,6 +789,16 @@
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "PID of running program or program name"
|
"description": "PID of running program or program name"
|
||||||
},
|
},
|
||||||
|
"valuesFormatting": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Set the way of showing variable values. 'disabled' - show value as is, 'parseText' - parse debuggers output text into structure, 'prettyPrinters' - enable debuggers custom pretty-printers if there are any",
|
||||||
|
"default": "parseText",
|
||||||
|
"enum": [
|
||||||
|
"disabled",
|
||||||
|
"parseText",
|
||||||
|
"prettyPrinters"
|
||||||
|
]
|
||||||
|
},
|
||||||
"printCalls": {
|
"printCalls": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Prints all mago calls to the console",
|
"description": "Prints all mago calls to the console",
|
||||||
|
|
@ -834,4 +894,4 @@
|
||||||
"@types/node": "^7.0.5",
|
"@types/node": "^7.0.5",
|
||||||
"@types/mocha": "^2.2.39"
|
"@types/mocha": "^2.2.39"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
import { MINode } from "./mi_parse";
|
import { MINode } from "./mi_parse";
|
||||||
import { DebugProtocol } from "vscode-debugprotocol/lib/debugProtocol";
|
import { DebugProtocol } from "vscode-debugprotocol/lib/debugProtocol";
|
||||||
|
|
||||||
|
export type ValuesFormattingMode = "disabled" | "parseText" | "prettyPrinters";
|
||||||
|
|
||||||
export interface Breakpoint {
|
export interface Breakpoint {
|
||||||
file?: string;
|
file?: string;
|
||||||
line?: number;
|
line?: number;
|
||||||
|
|
|
||||||
|
|
@ -196,9 +196,9 @@ export class MI2 extends EventEmitter implements IBackend {
|
||||||
];
|
];
|
||||||
if (!attach)
|
if (!attach)
|
||||||
cmds.push(this.sendCommand("file-exec-and-symbols \"" + escape(target) + "\""));
|
cmds.push(this.sendCommand("file-exec-and-symbols \"" + escape(target) + "\""));
|
||||||
|
if (this.prettyPrint)
|
||||||
|
cmds.push(this.sendCommand("enable-pretty-printing"));
|
||||||
|
|
||||||
// TODO: add extension parameter for enabling/disabling pretty printers
|
|
||||||
cmds.push(this.sendCommand("enable-pretty-printing"));
|
|
||||||
return cmds;
|
return cmds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -668,7 +668,7 @@ export class MI2 extends EventEmitter implements IBackend {
|
||||||
return new VariableObject(res.result(""));
|
return new VariableObject(res.result(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
async varEvalExpression(name: string): Promise < MINode > {
|
async varEvalExpression(name: string): Promise<MINode> {
|
||||||
if (trace)
|
if (trace)
|
||||||
this.log("stderr", "varEvalExpression");
|
this.log("stderr", "varEvalExpression");
|
||||||
return this.sendCommand(`var-evaluate-expression ${name}`);
|
return this.sendCommand(`var-evaluate-expression ${name}`);
|
||||||
|
|
@ -746,6 +746,7 @@ export class MI2 extends EventEmitter implements IBackend {
|
||||||
return this.isSSH ? this.sshReady : !!this.process;
|
return this.isSSH ? this.sshReady : !!this.process;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prettyPrint: boolean = true;
|
||||||
printCalls: boolean;
|
printCalls: boolean;
|
||||||
debugOutput: boolean;
|
debugOutput: boolean;
|
||||||
public procEnv: any;
|
public procEnv: any;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import { MI2DebugSession } from './mibase';
|
||||||
import { DebugSession, InitializedEvent, TerminatedEvent, StoppedEvent, OutputEvent, Thread, StackFrame, Scope, Source, Handles } from 'vscode-debugadapter';
|
import { DebugSession, InitializedEvent, TerminatedEvent, StoppedEvent, OutputEvent, Thread, StackFrame, Scope, Source, Handles } from 'vscode-debugadapter';
|
||||||
import { DebugProtocol } from 'vscode-debugprotocol';
|
import { DebugProtocol } from 'vscode-debugprotocol';
|
||||||
import { MI2 } from "./backend/mi2/mi2";
|
import { MI2 } from "./backend/mi2/mi2";
|
||||||
import { SSHArguments } from './backend/backend';
|
import { SSHArguments, ValuesFormattingMode } from './backend/backend';
|
||||||
|
|
||||||
export interface LaunchRequestArguments {
|
export interface LaunchRequestArguments {
|
||||||
cwd: string;
|
cwd: string;
|
||||||
|
|
@ -14,6 +14,7 @@ export interface LaunchRequestArguments {
|
||||||
terminal: string;
|
terminal: string;
|
||||||
autorun: string[];
|
autorun: string[];
|
||||||
ssh: SSHArguments;
|
ssh: SSHArguments;
|
||||||
|
valuesFormatting: ValuesFormattingMode;
|
||||||
printCalls: boolean;
|
printCalls: boolean;
|
||||||
showDevDebugOutput: boolean;
|
showDevDebugOutput: boolean;
|
||||||
}
|
}
|
||||||
|
|
@ -28,6 +29,7 @@ export interface AttachRequestArguments {
|
||||||
remote: boolean;
|
remote: boolean;
|
||||||
autorun: string[];
|
autorun: string[];
|
||||||
ssh: SSHArguments;
|
ssh: SSHArguments;
|
||||||
|
valuesFormatting: ValuesFormattingMode;
|
||||||
printCalls: boolean;
|
printCalls: boolean;
|
||||||
showDevDebugOutput: boolean;
|
showDevDebugOutput: boolean;
|
||||||
}
|
}
|
||||||
|
|
@ -54,6 +56,7 @@ class GDBDebugSession extends MI2DebugSession {
|
||||||
this.started = false;
|
this.started = false;
|
||||||
this.crashed = false;
|
this.crashed = false;
|
||||||
this.debugReady = false;
|
this.debugReady = false;
|
||||||
|
this.setValuesFormattingMode(args.valuesFormatting);
|
||||||
this.miDebugger.printCalls = !!args.printCalls;
|
this.miDebugger.printCalls = !!args.printCalls;
|
||||||
this.miDebugger.debugOutput = !!args.showDevDebugOutput;
|
this.miDebugger.debugOutput = !!args.showDevDebugOutput;
|
||||||
if (args.ssh !== undefined) {
|
if (args.ssh !== undefined) {
|
||||||
|
|
@ -121,6 +124,7 @@ class GDBDebugSession extends MI2DebugSession {
|
||||||
this.needContinue = true;
|
this.needContinue = true;
|
||||||
this.isSSH = false;
|
this.isSSH = false;
|
||||||
this.debugReady = false;
|
this.debugReady = false;
|
||||||
|
this.setValuesFormattingMode(args.valuesFormatting);
|
||||||
this.miDebugger.printCalls = !!args.printCalls;
|
this.miDebugger.printCalls = !!args.printCalls;
|
||||||
this.miDebugger.debugOutput = !!args.showDevDebugOutput;
|
this.miDebugger.debugOutput = !!args.showDevDebugOutput;
|
||||||
if (args.ssh !== undefined) {
|
if (args.ssh !== undefined) {
|
||||||
|
|
@ -177,4 +181,4 @@ class GDBDebugSession extends MI2DebugSession {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DebugSession.run(GDBDebugSession);
|
DebugSession.run(GDBDebugSession);
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import { MI2DebugSession } from './mibase';
|
||||||
import { DebugSession, InitializedEvent, TerminatedEvent, StoppedEvent, OutputEvent, Thread, StackFrame, Scope, Source, Handles } from 'vscode-debugadapter';
|
import { DebugSession, InitializedEvent, TerminatedEvent, StoppedEvent, OutputEvent, Thread, StackFrame, Scope, Source, Handles } from 'vscode-debugadapter';
|
||||||
import { DebugProtocol } from 'vscode-debugprotocol';
|
import { DebugProtocol } from 'vscode-debugprotocol';
|
||||||
import { MI2_LLDB } from "./backend/mi2/mi2lldb";
|
import { MI2_LLDB } from "./backend/mi2/mi2lldb";
|
||||||
import { SSHArguments } from './backend/backend';
|
import { SSHArguments, ValuesFormattingMode } from './backend/backend';
|
||||||
|
|
||||||
export interface LaunchRequestArguments {
|
export interface LaunchRequestArguments {
|
||||||
cwd: string;
|
cwd: string;
|
||||||
|
|
@ -13,6 +13,7 @@ export interface LaunchRequestArguments {
|
||||||
arguments: string;
|
arguments: string;
|
||||||
autorun: string[];
|
autorun: string[];
|
||||||
ssh: SSHArguments;
|
ssh: SSHArguments;
|
||||||
|
valuesFormatting: ValuesFormattingMode;
|
||||||
printCalls: boolean;
|
printCalls: boolean;
|
||||||
showDevDebugOutput: boolean;
|
showDevDebugOutput: boolean;
|
||||||
}
|
}
|
||||||
|
|
@ -25,6 +26,7 @@ export interface AttachRequestArguments {
|
||||||
debugger_args: string[];
|
debugger_args: string[];
|
||||||
executable: string;
|
executable: string;
|
||||||
autorun: string[];
|
autorun: string[];
|
||||||
|
valuesFormatting: ValuesFormattingMode;
|
||||||
printCalls: boolean;
|
printCalls: boolean;
|
||||||
showDevDebugOutput: boolean;
|
showDevDebugOutput: boolean;
|
||||||
}
|
}
|
||||||
|
|
@ -49,6 +51,7 @@ class LLDBDebugSession extends MI2DebugSession {
|
||||||
this.started = false;
|
this.started = false;
|
||||||
this.crashed = false;
|
this.crashed = false;
|
||||||
this.debugReady = false;
|
this.debugReady = false;
|
||||||
|
this.setValuesFormattingMode(args.valuesFormatting);
|
||||||
this.miDebugger.printCalls = !!args.printCalls;
|
this.miDebugger.printCalls = !!args.printCalls;
|
||||||
this.miDebugger.debugOutput = !!args.showDevDebugOutput;
|
this.miDebugger.debugOutput = !!args.showDevDebugOutput;
|
||||||
if (args.ssh !== undefined) {
|
if (args.ssh !== undefined) {
|
||||||
|
|
@ -108,6 +111,7 @@ class LLDBDebugSession extends MI2DebugSession {
|
||||||
this.needContinue = true;
|
this.needContinue = true;
|
||||||
this.isSSH = false;
|
this.isSSH = false;
|
||||||
this.debugReady = false;
|
this.debugReady = false;
|
||||||
|
this.setValuesFormattingMode(args.valuesFormatting);
|
||||||
this.miDebugger.printCalls = !!args.printCalls;
|
this.miDebugger.printCalls = !!args.printCalls;
|
||||||
this.miDebugger.debugOutput = !!args.showDevDebugOutput;
|
this.miDebugger.debugOutput = !!args.showDevDebugOutput;
|
||||||
this.miDebugger.attach(args.cwd, args.executable, args.target).then(() => {
|
this.miDebugger.attach(args.cwd, args.executable, args.target).then(() => {
|
||||||
|
|
@ -120,4 +124,4 @@ class LLDBDebugSession extends MI2DebugSession {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DebugSession.run(LLDBDebugSession);
|
DebugSession.run(LLDBDebugSession);
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import { MI2DebugSession } from './mibase';
|
||||||
import { DebugSession, InitializedEvent, TerminatedEvent, StoppedEvent, OutputEvent, Thread, StackFrame, Scope, Source, Handles } from 'vscode-debugadapter';
|
import { DebugSession, InitializedEvent, TerminatedEvent, StoppedEvent, OutputEvent, Thread, StackFrame, Scope, Source, Handles } from 'vscode-debugadapter';
|
||||||
import { DebugProtocol } from 'vscode-debugprotocol';
|
import { DebugProtocol } from 'vscode-debugprotocol';
|
||||||
import { MI2_Mago } from "./backend/mi2/mi2mago";
|
import { MI2_Mago } from "./backend/mi2/mi2mago";
|
||||||
import { SSHArguments } from './backend/backend';
|
import { SSHArguments, ValuesFormattingMode } from './backend/backend';
|
||||||
|
|
||||||
export interface LaunchRequestArguments {
|
export interface LaunchRequestArguments {
|
||||||
cwd: string;
|
cwd: string;
|
||||||
|
|
@ -12,6 +12,7 @@ export interface LaunchRequestArguments {
|
||||||
debugger_args: string[];
|
debugger_args: string[];
|
||||||
arguments: string;
|
arguments: string;
|
||||||
autorun: string[];
|
autorun: string[];
|
||||||
|
valuesFormatting: ValuesFormattingMode;
|
||||||
printCalls: boolean;
|
printCalls: boolean;
|
||||||
showDevDebugOutput: boolean;
|
showDevDebugOutput: boolean;
|
||||||
}
|
}
|
||||||
|
|
@ -24,6 +25,7 @@ export interface AttachRequestArguments {
|
||||||
debugger_args: string[];
|
debugger_args: string[];
|
||||||
executable: string;
|
executable: string;
|
||||||
autorun: string[];
|
autorun: string[];
|
||||||
|
valuesFormatting: ValuesFormattingMode;
|
||||||
printCalls: boolean;
|
printCalls: boolean;
|
||||||
showDevDebugOutput: boolean;
|
showDevDebugOutput: boolean;
|
||||||
}
|
}
|
||||||
|
|
@ -56,6 +58,7 @@ class MagoDebugSession extends MI2DebugSession {
|
||||||
this.started = false;
|
this.started = false;
|
||||||
this.crashed = false;
|
this.crashed = false;
|
||||||
this.debugReady = false;
|
this.debugReady = false;
|
||||||
|
this.setValuesFormattingMode(args.valuesFormatting);
|
||||||
this.miDebugger.printCalls = !!args.printCalls;
|
this.miDebugger.printCalls = !!args.printCalls;
|
||||||
this.miDebugger.debugOutput = !!args.showDevDebugOutput;
|
this.miDebugger.debugOutput = !!args.showDevDebugOutput;
|
||||||
this.miDebugger.load(args.cwd, args.target, args.arguments, undefined).then(() => {
|
this.miDebugger.load(args.cwd, args.target, args.arguments, undefined).then(() => {
|
||||||
|
|
@ -83,6 +86,7 @@ class MagoDebugSession extends MI2DebugSession {
|
||||||
this.needContinue = true;
|
this.needContinue = true;
|
||||||
this.isSSH = false;
|
this.isSSH = false;
|
||||||
this.debugReady = false;
|
this.debugReady = false;
|
||||||
|
this.setValuesFormattingMode(args.valuesFormatting);
|
||||||
this.miDebugger.printCalls = !!args.printCalls;
|
this.miDebugger.printCalls = !!args.printCalls;
|
||||||
this.miDebugger.debugOutput = !!args.showDevDebugOutput;
|
this.miDebugger.debugOutput = !!args.showDevDebugOutput;
|
||||||
this.miDebugger.attach(args.cwd, args.executable, args.target).then(() => {
|
this.miDebugger.attach(args.cwd, args.executable, args.target).then(() => {
|
||||||
|
|
@ -95,4 +99,4 @@ class MagoDebugSession extends MI2DebugSession {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DebugSession.run(MagoDebugSession);
|
DebugSession.run(MagoDebugSession);
|
||||||
|
|
|
||||||
149
src/mibase.ts
149
src/mibase.ts
|
|
@ -1,6 +1,6 @@
|
||||||
import { DebugSession, InitializedEvent, TerminatedEvent, StoppedEvent, OutputEvent, Thread, StackFrame, Scope, Source, Handles } from 'vscode-debugadapter';
|
import { DebugSession, InitializedEvent, TerminatedEvent, StoppedEvent, OutputEvent, Thread, StackFrame, Scope, Source, Handles } from 'vscode-debugadapter';
|
||||||
import { DebugProtocol } from 'vscode-debugprotocol';
|
import { DebugProtocol } from 'vscode-debugprotocol';
|
||||||
import { Breakpoint, IBackend, Variable, VariableObject } from './backend/backend';
|
import { Breakpoint, IBackend, Variable, VariableObject, ValuesFormattingMode } from './backend/backend';
|
||||||
import { MINode } from './backend/mi_parse';
|
import { MINode } from './backend/mi_parse';
|
||||||
import { expandValue, isExpandable } from './backend/gdb_expansion';
|
import { expandValue, isExpandable } from './backend/gdb_expansion';
|
||||||
import { MI2 } from './backend/mi2/mi2';
|
import { MI2 } from './backend/mi2/mi2';
|
||||||
|
|
@ -24,6 +24,7 @@ const VAR_HANDLES_START = 2000;
|
||||||
export class MI2DebugSession extends DebugSession {
|
export class MI2DebugSession extends DebugSession {
|
||||||
protected variableHandles = new Handles<string | VariableObject | ExtendedVariable>(VAR_HANDLES_START);
|
protected variableHandles = new Handles<string | VariableObject | ExtendedVariable>(VAR_HANDLES_START);
|
||||||
protected variableHandlesReverse: { [id: string]: number } = {};
|
protected variableHandlesReverse: { [id: string]: number } = {};
|
||||||
|
protected useVarObjects: boolean;
|
||||||
protected quit: boolean;
|
protected quit: boolean;
|
||||||
protected attached: boolean;
|
protected attached: boolean;
|
||||||
protected needContinue: boolean;
|
protected needContinue: boolean;
|
||||||
|
|
@ -82,6 +83,23 @@ export class MI2DebugSession extends DebugSession {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected setValuesFormattingMode(mode: ValuesFormattingMode) {
|
||||||
|
switch (mode) {
|
||||||
|
case "disabled":
|
||||||
|
this.useVarObjects = true;
|
||||||
|
this.miDebugger.prettyPrint = false;
|
||||||
|
break;
|
||||||
|
case "prettyPrinters":
|
||||||
|
this.useVarObjects = true;
|
||||||
|
this.miDebugger.prettyPrint = true;
|
||||||
|
break;
|
||||||
|
case "parseText":
|
||||||
|
default:
|
||||||
|
this.useVarObjects = false;
|
||||||
|
this.miDebugger.prettyPrint = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected handleMsg(type: string, msg: string) {
|
protected handleMsg(type: string, msg: string) {
|
||||||
if (type == "target")
|
if (type == "target")
|
||||||
type = "stdout";
|
type = "stdout";
|
||||||
|
|
@ -132,16 +150,24 @@ export class MI2DebugSession extends DebugSession {
|
||||||
|
|
||||||
protected async setVariableRequest(response: DebugProtocol.SetVariableResponse, args: DebugProtocol.SetVariableArguments): Promise<void> {
|
protected async setVariableRequest(response: DebugProtocol.SetVariableResponse, args: DebugProtocol.SetVariableArguments): Promise<void> {
|
||||||
try {
|
try {
|
||||||
let name = args.name;
|
if (this.useVarObjects) {
|
||||||
if (args.variablesReference >= VAR_HANDLES_START) {
|
let name = args.name;
|
||||||
const parent = this.variableHandles.get(args.variablesReference) as VariableObject;
|
if (args.variablesReference >= VAR_HANDLES_START) {
|
||||||
name = `${parent.name}.${name}`;
|
const parent = this.variableHandles.get(args.variablesReference) as VariableObject;
|
||||||
}
|
name = `${parent.name}.${name}`;
|
||||||
|
}
|
||||||
|
|
||||||
let res = await this.miDebugger.varAssign(name, args.value);
|
let res = await this.miDebugger.varAssign(name, args.value);
|
||||||
response.body = {
|
response.body = {
|
||||||
value: res.result("value")
|
value: res.result("value")
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
await this.miDebugger.changeVariable(args.name, args.value);
|
||||||
|
response.body = {
|
||||||
|
value: args.value
|
||||||
|
};
|
||||||
|
}
|
||||||
this.sendResponse(response);
|
this.sendResponse(response);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
|
@ -307,34 +333,58 @@ export class MI2DebugSession extends DebugSession {
|
||||||
try {
|
try {
|
||||||
stack = await this.miDebugger.getStackVariables(this.threadID, id);
|
stack = await this.miDebugger.getStackVariables(this.threadID, id);
|
||||||
for (const variable of stack) {
|
for (const variable of stack) {
|
||||||
try {
|
if (this.useVarObjects) {
|
||||||
let varObj: VariableObject;
|
|
||||||
try {
|
try {
|
||||||
const changes = await this.miDebugger.varUpdate(variable.name);
|
let varObj: VariableObject;
|
||||||
const changelist = changes.result("changelist");
|
try {
|
||||||
changelist.forEach((change) => {
|
const changes = await this.miDebugger.varUpdate(variable.name);
|
||||||
const name = MINode.valueOf(change, "name");
|
const changelist = changes.result("changelist");
|
||||||
const vId = this.variableHandlesReverse[variable.name];
|
changelist.forEach((change) => {
|
||||||
const v = this.variableHandles.get(vId) as any;
|
const name = MINode.valueOf(change, "name");
|
||||||
v.applyChanges(change);
|
const vId = this.variableHandlesReverse[variable.name];
|
||||||
});
|
const v = this.variableHandles.get(vId) as any;
|
||||||
const varId = this.variableHandlesReverse[variable.name];
|
v.applyChanges(change);
|
||||||
varObj = this.variableHandles.get(varId) as any;
|
});
|
||||||
|
const varId = this.variableHandlesReverse[variable.name];
|
||||||
|
varObj = this.variableHandles.get(varId) as any;
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
varObj = await this.miDebugger.varCreate(variable.name, variable.name);
|
||||||
|
const varId = findOrCreateVariable(varObj);
|
||||||
|
varObj.exp = variable.name;
|
||||||
|
varObj.id = varId;
|
||||||
|
}
|
||||||
|
variables.push(varObj.toProtocolVariable());
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
varObj = await this.miDebugger.varCreate(variable.name, variable.name);
|
variables.push({
|
||||||
const varId = findOrCreateVariable(varObj);
|
name: variable.name,
|
||||||
varObj.exp = variable.name;
|
value: `<${err}>`,
|
||||||
varObj.id = varId;
|
variablesReference: 0
|
||||||
|
});
|
||||||
}
|
}
|
||||||
variables.push(varObj.toProtocolVariable());
|
|
||||||
}
|
}
|
||||||
catch (err) {
|
else {
|
||||||
variables.push({
|
if (variable.valueStr !== undefined) {
|
||||||
name: variable.name,
|
let expanded = expandValue(createVariable, `{${variable.name}=${variable.valueStr})`, "", variable.raw);
|
||||||
value: `<${err}>`,
|
if (expanded) {
|
||||||
variablesReference: 0
|
if (typeof expanded[0] == "string")
|
||||||
});
|
expanded = [
|
||||||
|
{
|
||||||
|
name: "<value>",
|
||||||
|
value: prettyStringArray(expanded),
|
||||||
|
variablesReference: 0
|
||||||
|
}
|
||||||
|
];
|
||||||
|
variables.push(expanded[0]);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
variables.push({
|
||||||
|
name: variable.name,
|
||||||
|
type: variable.type,
|
||||||
|
value: "<unknown>",
|
||||||
|
variablesReference: createVariable(variable.name)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
response.body = {
|
response.body = {
|
||||||
|
|
@ -346,6 +396,39 @@ export class MI2DebugSession extends DebugSession {
|
||||||
this.sendErrorResponse(response, 1, `Could not expand variable: ${err}`);
|
this.sendErrorResponse(response, 1, `Could not expand variable: ${err}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (typeof id == "string") {
|
||||||
|
// Variable members
|
||||||
|
let variable;
|
||||||
|
try {
|
||||||
|
variable = await this.miDebugger.evalExpression(JSON.stringify(id));
|
||||||
|
try {
|
||||||
|
let expanded = expandValue(createVariable, variable.result("value"), id, variable);
|
||||||
|
if (!expanded) {
|
||||||
|
this.sendErrorResponse(response, 2, `Could not expand variable`);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (typeof expanded[0] == "string")
|
||||||
|
expanded = [
|
||||||
|
{
|
||||||
|
name: "<value>",
|
||||||
|
value: prettyStringArray(expanded),
|
||||||
|
variablesReference: 0
|
||||||
|
}
|
||||||
|
];
|
||||||
|
response.body = {
|
||||||
|
variables: expanded
|
||||||
|
};
|
||||||
|
this.sendResponse(response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
this.sendErrorResponse(response, 2, `Could not expand variable: ${e}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
this.sendErrorResponse(response, 1, `Could not expand variable: ${err}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (typeof id == "object") {
|
else if (typeof id == "object") {
|
||||||
if (id instanceof VariableObject) {
|
if (id instanceof VariableObject) {
|
||||||
// Variable members
|
// Variable members
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue