Skip to content

Commit beb80f7

Browse files
committed
Add valuesFormatting parameter to launch config
1 parent d498b38 commit beb80f7

File tree

7 files changed

+201
-43
lines changed

7 files changed

+201
-43
lines changed

package.json

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,16 @@
101101
"description": "Additional arguments to pass to GDB",
102102
"default": []
103103
},
104+
"valuesFormatting": {
105+
"type": "string",
106+
"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",
107+
"default": "parseText",
108+
"enum": [
109+
"disabled",
110+
"parseText",
111+
"prettyPrinters"
112+
]
113+
},
104114
"printCalls": {
105115
"type": "boolean",
106116
"description": "Prints all GDB calls to the console",
@@ -192,6 +202,16 @@
192202
"description": "If true this will connect to a gdbserver instead of attaching to a PID",
193203
"default": false
194204
},
205+
"valuesFormatting": {
206+
"type": "string",
207+
"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",
208+
"default": "parseText",
209+
"enum": [
210+
"disabled",
211+
"parseText",
212+
"prettyPrinters"
213+
]
214+
},
195215
"printCalls": {
196216
"type": "boolean",
197217
"description": "Prints all GDB calls to the console",
@@ -466,6 +486,16 @@
466486
"description": "Additional arguments to pass to LLDB",
467487
"default": []
468488
},
489+
"valuesFormatting": {
490+
"type": "string",
491+
"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",
492+
"default": "parseText",
493+
"enum": [
494+
"disabled",
495+
"parseText",
496+
"prettyPrinters"
497+
]
498+
},
469499
"printCalls": {
470500
"type": "boolean",
471501
"description": "Prints all lldb calls to the console",
@@ -552,6 +582,16 @@
552582
"type": "string",
553583
"description": "PID of running program or program name"
554584
},
585+
"valuesFormatting": {
586+
"type": "string",
587+
"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",
588+
"default": "parseText",
589+
"enum": [
590+
"disabled",
591+
"parseText",
592+
"prettyPrinters"
593+
]
594+
},
555595
"printCalls": {
556596
"type": "boolean",
557597
"description": "Prints all LLDB calls to the console",
@@ -713,6 +753,16 @@
713753
"description": "Additional arguments to pass to mago",
714754
"default": []
715755
},
756+
"valuesFormatting": {
757+
"type": "string",
758+
"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",
759+
"default": "parseText",
760+
"enum": [
761+
"disabled",
762+
"parseText",
763+
"prettyPrinters"
764+
]
765+
},
716766
"printCalls": {
717767
"type": "boolean",
718768
"description": "Prints all mago calls to the console",
@@ -739,6 +789,16 @@
739789
"type": "string",
740790
"description": "PID of running program or program name"
741791
},
792+
"valuesFormatting": {
793+
"type": "string",
794+
"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",
795+
"default": "parseText",
796+
"enum": [
797+
"disabled",
798+
"parseText",
799+
"prettyPrinters"
800+
]
801+
},
742802
"printCalls": {
743803
"type": "boolean",
744804
"description": "Prints all mago calls to the console",
@@ -834,4 +894,4 @@
834894
"@types/node": "^7.0.5",
835895
"@types/mocha": "^2.2.39"
836896
}
837-
}
897+
}

src/backend/backend.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { MINode } from "./mi_parse";
22
import { DebugProtocol } from "vscode-debugprotocol/lib/debugProtocol";
33

4+
export type ValuesFormattingMode = "disabled" | "parseText" | "prettyPrinters";
5+
46
export interface Breakpoint {
57
file?: string;
68
line?: number;

src/backend/mi2/mi2.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,9 @@ export class MI2 extends EventEmitter implements IBackend {
196196
];
197197
if (!attach)
198198
cmds.push(this.sendCommand("file-exec-and-symbols \"" + escape(target) + "\""));
199+
if (this.prettyPrint)
200+
cmds.push(this.sendCommand("enable-pretty-printing"));
199201

200-
// TODO: add extension parameter for enabling/disabling pretty printers
201-
cmds.push(this.sendCommand("enable-pretty-printing"));
202202
return cmds;
203203
}
204204

@@ -668,7 +668,7 @@ export class MI2 extends EventEmitter implements IBackend {
668668
return new VariableObject(res.result(""));
669669
}
670670

671-
async varEvalExpression(name: string): Promise < MINode > {
671+
async varEvalExpression(name: string): Promise<MINode> {
672672
if (trace)
673673
this.log("stderr", "varEvalExpression");
674674
return this.sendCommand(`var-evaluate-expression ${name}`);
@@ -746,6 +746,7 @@ export class MI2 extends EventEmitter implements IBackend {
746746
return this.isSSH ? this.sshReady : !!this.process;
747747
}
748748

749+
prettyPrint: boolean = true;
749750
printCalls: boolean;
750751
debugOutput: boolean;
751752
public procEnv: any;

src/gdb.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { MI2DebugSession } from './mibase';
22
import { DebugSession, InitializedEvent, TerminatedEvent, StoppedEvent, OutputEvent, Thread, StackFrame, Scope, Source, Handles } from 'vscode-debugadapter';
33
import { DebugProtocol } from 'vscode-debugprotocol';
44
import { MI2 } from "./backend/mi2/mi2";
5-
import { SSHArguments } from './backend/backend';
5+
import { SSHArguments, ValuesFormattingMode } from './backend/backend';
66

77
export interface LaunchRequestArguments {
88
cwd: string;
@@ -14,6 +14,7 @@ export interface LaunchRequestArguments {
1414
terminal: string;
1515
autorun: string[];
1616
ssh: SSHArguments;
17+
valuesFormatting: ValuesFormattingMode;
1718
printCalls: boolean;
1819
showDevDebugOutput: boolean;
1920
}
@@ -28,6 +29,7 @@ export interface AttachRequestArguments {
2829
remote: boolean;
2930
autorun: string[];
3031
ssh: SSHArguments;
32+
valuesFormatting: ValuesFormattingMode;
3133
printCalls: boolean;
3234
showDevDebugOutput: boolean;
3335
}
@@ -54,6 +56,7 @@ class GDBDebugSession extends MI2DebugSession {
5456
this.started = false;
5557
this.crashed = false;
5658
this.debugReady = false;
59+
this.setValuesFormattingMode(args.valuesFormatting);
5760
this.miDebugger.printCalls = !!args.printCalls;
5861
this.miDebugger.debugOutput = !!args.showDevDebugOutput;
5962
if (args.ssh !== undefined) {
@@ -121,6 +124,7 @@ class GDBDebugSession extends MI2DebugSession {
121124
this.needContinue = true;
122125
this.isSSH = false;
123126
this.debugReady = false;
127+
this.setValuesFormattingMode(args.valuesFormatting);
124128
this.miDebugger.printCalls = !!args.printCalls;
125129
this.miDebugger.debugOutput = !!args.showDevDebugOutput;
126130
if (args.ssh !== undefined) {
@@ -177,4 +181,4 @@ class GDBDebugSession extends MI2DebugSession {
177181
}
178182
}
179183

180-
DebugSession.run(GDBDebugSession);
184+
DebugSession.run(GDBDebugSession);

src/lldb.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { MI2DebugSession } from './mibase';
22
import { DebugSession, InitializedEvent, TerminatedEvent, StoppedEvent, OutputEvent, Thread, StackFrame, Scope, Source, Handles } from 'vscode-debugadapter';
33
import { DebugProtocol } from 'vscode-debugprotocol';
44
import { MI2_LLDB } from "./backend/mi2/mi2lldb";
5-
import { SSHArguments } from './backend/backend';
5+
import { SSHArguments, ValuesFormattingMode } from './backend/backend';
66

77
export interface LaunchRequestArguments {
88
cwd: string;
@@ -13,6 +13,7 @@ export interface LaunchRequestArguments {
1313
arguments: string;
1414
autorun: string[];
1515
ssh: SSHArguments;
16+
valuesFormatting: ValuesFormattingMode;
1617
printCalls: boolean;
1718
showDevDebugOutput: boolean;
1819
}
@@ -25,6 +26,7 @@ export interface AttachRequestArguments {
2526
debugger_args: string[];
2627
executable: string;
2728
autorun: string[];
29+
valuesFormatting: ValuesFormattingMode;
2830
printCalls: boolean;
2931
showDevDebugOutput: boolean;
3032
}
@@ -49,6 +51,7 @@ class LLDBDebugSession extends MI2DebugSession {
4951
this.started = false;
5052
this.crashed = false;
5153
this.debugReady = false;
54+
this.setValuesFormattingMode(args.valuesFormatting);
5255
this.miDebugger.printCalls = !!args.printCalls;
5356
this.miDebugger.debugOutput = !!args.showDevDebugOutput;
5457
if (args.ssh !== undefined) {
@@ -108,6 +111,7 @@ class LLDBDebugSession extends MI2DebugSession {
108111
this.needContinue = true;
109112
this.isSSH = false;
110113
this.debugReady = false;
114+
this.setValuesFormattingMode(args.valuesFormatting);
111115
this.miDebugger.printCalls = !!args.printCalls;
112116
this.miDebugger.debugOutput = !!args.showDevDebugOutput;
113117
this.miDebugger.attach(args.cwd, args.executable, args.target).then(() => {
@@ -120,4 +124,4 @@ class LLDBDebugSession extends MI2DebugSession {
120124
}
121125
}
122126

123-
DebugSession.run(LLDBDebugSession);
127+
DebugSession.run(LLDBDebugSession);

src/mago.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { MI2DebugSession } from './mibase';
22
import { DebugSession, InitializedEvent, TerminatedEvent, StoppedEvent, OutputEvent, Thread, StackFrame, Scope, Source, Handles } from 'vscode-debugadapter';
33
import { DebugProtocol } from 'vscode-debugprotocol';
44
import { MI2_Mago } from "./backend/mi2/mi2mago";
5-
import { SSHArguments } from './backend/backend';
5+
import { SSHArguments, ValuesFormattingMode } from './backend/backend';
66

77
export interface LaunchRequestArguments {
88
cwd: string;
@@ -12,6 +12,7 @@ export interface LaunchRequestArguments {
1212
debugger_args: string[];
1313
arguments: string;
1414
autorun: string[];
15+
valuesFormatting: ValuesFormattingMode;
1516
printCalls: boolean;
1617
showDevDebugOutput: boolean;
1718
}
@@ -24,6 +25,7 @@ export interface AttachRequestArguments {
2425
debugger_args: string[];
2526
executable: string;
2627
autorun: string[];
28+
valuesFormatting: ValuesFormattingMode;
2729
printCalls: boolean;
2830
showDevDebugOutput: boolean;
2931
}
@@ -56,6 +58,7 @@ class MagoDebugSession extends MI2DebugSession {
5658
this.started = false;
5759
this.crashed = false;
5860
this.debugReady = false;
61+
this.setValuesFormattingMode(args.valuesFormatting);
5962
this.miDebugger.printCalls = !!args.printCalls;
6063
this.miDebugger.debugOutput = !!args.showDevDebugOutput;
6164
this.miDebugger.load(args.cwd, args.target, args.arguments, undefined).then(() => {
@@ -83,6 +86,7 @@ class MagoDebugSession extends MI2DebugSession {
8386
this.needContinue = true;
8487
this.isSSH = false;
8588
this.debugReady = false;
89+
this.setValuesFormattingMode(args.valuesFormatting);
8690
this.miDebugger.printCalls = !!args.printCalls;
8791
this.miDebugger.debugOutput = !!args.showDevDebugOutput;
8892
this.miDebugger.attach(args.cwd, args.executable, args.target).then(() => {
@@ -95,4 +99,4 @@ class MagoDebugSession extends MI2DebugSession {
9599
}
96100
}
97101

98-
DebugSession.run(MagoDebugSession);
102+
DebugSession.run(MagoDebugSession);

0 commit comments

Comments
 (0)