Skip to content

Commit eb9f5e4

Browse files
authored
Merge pull request #446 from chenzhiy2001-org/master
Add `registerLimit` config option to specify the registers to list in Registers view (continuation of PR #444)
2 parents 33bbedd + 97efe10 commit eb9f5e4

File tree

7 files changed

+61
-1
lines changed

7 files changed

+61
-1
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Versioning].
2222
enabled by default ([@JacquesLucke])
2323
- Suppress error for hover as the user may just play with the mouse ([@oltolm]).
2424
- solve the problem of failed parsing of containers ([@henryriley0])
25+
- Fixes #421 - Added `registerLimit` option to specify the registers to
26+
display - PR #444 ([@chenzhiy2001])
2527

2628
## [0.27.0] - 2024-02-07
2729

@@ -243,6 +245,7 @@ Versioning].
243245
[@abussy-aldebaran]: https://github.com/abussy-aldebaran
244246
[@anshulrouthu]: https://github.com/anshulrouthu
245247
[@brownts]: https://github.com/brownts
248+
[@chenzhiy2001]: https://github.com/chenzhiy2001
246249
[@coldencullen]: https://github.com/ColdenCullen
247250
[@eamousing]: https://github.com/eamousing
248251
[@evangrayk]: https://github.com/evangrayk

README.md

+14
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,20 @@ that location prior to continuing execution. Note that stopping at the entry po
8181
attach configuration assumes that the entry point has not yet been entered at the time of
8282
attach, otherwise this will have no affect.
8383

84+
There is a Registers view in the VARIABLES view. As we fetch all registers at once, there can
85+
be cases where a register that cannot be fetched causes the entire register request to fail,
86+
corrupting the entire Registers output. If this happens, you might need to set the
87+
`registerLimit` option to specify which registers you want the debugger to fetch
88+
automatically.
89+
90+
For example, to display only registers `rax` and `rip` in an x64 debug session, send the
91+
command `-data-list-register-names` in the debug console of an active x64 debug session.
92+
You will then receive a response containing an array starting with `["rax","rbx" ...]`.
93+
In this array, the index of `rax` is 0 and `rip` is 16, so set the option as
94+
`"registerLimit": "0 16"`. If you find the response text hard to navigate, you can paste
95+
it into a browser's developer tools console and press enter to get an expandable response
96+
object with array elements' indices explicitly displayed.
97+
8498
### Attaching to existing processes
8599

86100
Attaching to existing processes currently only works by specifying the PID in the

package.json

+30
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,11 @@
299299
"description": "Content will be executed on the SSH host before the debugger call."
300300
}
301301
}
302+
},
303+
"registerLimit": {
304+
"type": "string",
305+
"description": "List of numbers specifying the registers to display. An empty string indicates that the contents of all the registers must be returned.",
306+
"default": ""
302307
}
303308
}
304309
},
@@ -468,6 +473,11 @@
468473
"description": "Content will be executed on the SSH host before the debugger call."
469474
}
470475
}
476+
},
477+
"registerLimit": {
478+
"type": "string",
479+
"description": "List of numbers specifying the registers to display. An empty string indicates that the contents of all the registers must be returned.",
480+
"default": ""
471481
}
472482
}
473483
}
@@ -766,6 +776,11 @@
766776
"description": "Content will be executed on the SSH host before the debugger call."
767777
}
768778
}
779+
},
780+
"registerLimit": {
781+
"type": "string",
782+
"description": "List of numbers specifying the registers to display. An empty string indicates that the contents of all the registers must be returned.",
783+
"default": ""
769784
}
770785
}
771786
},
@@ -846,6 +861,11 @@
846861
],
847862
"description": "Whether debugger should stop at application entry point",
848863
"default": false
864+
},
865+
"registerLimit": {
866+
"type": "string",
867+
"description": "List of numbers specifying the registers to display. An empty string indicates that the contents of all the registers must be returned.",
868+
"default": ""
849869
}
850870
}
851871
}
@@ -992,6 +1012,11 @@
9921012
"type": "array",
9931013
"description": "mago commands to run when starting to debug",
9941014
"default": []
1015+
},
1016+
"registerLimit": {
1017+
"type": "string",
1018+
"description": "List of numbers specifying the registers to display. An empty string indicates that the contents of all the registers must be returned.",
1019+
"default": ""
9951020
}
9961021
}
9971022
},
@@ -1057,6 +1082,11 @@
10571082
"type": "boolean",
10581083
"description": "Whether debugger should stop after connecting to target",
10591084
"default": false
1085+
},
1086+
"registerLimit": {
1087+
"type": "string",
1088+
"description": "List of numbers specifying the registers to display. An empty string indicates that the contents of all the registers must be returned.",
1089+
"default": ""
10601090
}
10611091
}
10621092
}

src/backend/mi2/mi2.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ export class MI2 extends EventEmitter implements IBackend {
883883
async getRegisterValues(): Promise<RegisterValue[]> {
884884
if (trace)
885885
this.log("stderr", "getRegisterValues");
886-
const result = await this.sendCommand("data-list-register-values N");
886+
const result = await this.sendCommand("data-list-register-values --skip-unavailable N " + this.registerLimit);
887887
const nodes = result.result('register-values');
888888
if (!Array.isArray(nodes)) {
889889
throw new Error('Failed to retrieve register values.');
@@ -1024,6 +1024,7 @@ export class MI2 extends EventEmitter implements IBackend {
10241024
debugOutput: boolean;
10251025
features: string[];
10261026
public procEnv: any;
1027+
public registerLimit: string;
10271028
protected isSSH: boolean;
10281029
protected sshReady: boolean;
10291030
protected currentToken: number = 1;

src/gdb.ts

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArgum
2020
frameFilters: boolean;
2121
printCalls: boolean;
2222
showDevDebugOutput: boolean;
23+
registerLimit: string;
2324
}
2425

2526
export interface AttachRequestArguments extends DebugProtocol.AttachRequestArguments {
@@ -39,6 +40,7 @@ export interface AttachRequestArguments extends DebugProtocol.AttachRequestArgum
3940
frameFilters: boolean;
4041
printCalls: boolean;
4142
showDevDebugOutput: boolean;
43+
registerLimit: string;
4244
}
4345

4446
class GDBDebugSession extends MI2DebugSession {
@@ -75,6 +77,7 @@ class GDBDebugSession extends MI2DebugSession {
7577
this.miDebugger.printCalls = !!args.printCalls;
7678
this.miDebugger.debugOutput = !!args.showDevDebugOutput;
7779
this.stopAtEntry = args.stopAtEntry;
80+
this.miDebugger.registerLimit = args.registerLimit ?? "";
7881
if (args.ssh !== undefined) {
7982
if (args.ssh.forwardX11 === undefined)
8083
args.ssh.forwardX11 = true;
@@ -120,6 +123,7 @@ class GDBDebugSession extends MI2DebugSession {
120123
this.miDebugger.printCalls = !!args.printCalls;
121124
this.miDebugger.debugOutput = !!args.showDevDebugOutput;
122125
this.stopAtEntry = args.stopAtEntry;
126+
this.miDebugger.registerLimit = args.registerLimit ?? "";
123127
if (args.ssh !== undefined) {
124128
if (args.ssh.forwardX11 === undefined)
125129
args.ssh.forwardX11 = true;

src/lldb.ts

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArgum
1818
valuesFormatting: ValuesFormattingMode;
1919
printCalls: boolean;
2020
showDevDebugOutput: boolean;
21+
registerLimit: string;
2122
}
2223

2324
export interface AttachRequestArguments extends DebugProtocol.AttachRequestArguments {
@@ -34,6 +35,7 @@ export interface AttachRequestArguments extends DebugProtocol.AttachRequestArgum
3435
valuesFormatting: ValuesFormattingMode;
3536
printCalls: boolean;
3637
showDevDebugOutput: boolean;
38+
registerLimit: string;
3739
}
3840

3941
class LLDBDebugSession extends MI2DebugSession {
@@ -66,6 +68,7 @@ class LLDBDebugSession extends MI2DebugSession {
6668
this.miDebugger.printCalls = !!args.printCalls;
6769
this.miDebugger.debugOutput = !!args.showDevDebugOutput;
6870
this.stopAtEntry = args.stopAtEntry;
71+
this.miDebugger.registerLimit = args.registerLimit ?? "";
6972
if (args.ssh !== undefined) {
7073
if (args.ssh.forwardX11 === undefined)
7174
args.ssh.forwardX11 = true;
@@ -110,6 +113,7 @@ class LLDBDebugSession extends MI2DebugSession {
110113
this.miDebugger.printCalls = !!args.printCalls;
111114
this.miDebugger.debugOutput = !!args.showDevDebugOutput;
112115
this.stopAtEntry = args.stopAtEntry;
116+
this.miDebugger.registerLimit = args.registerLimit ?? "";
113117
this.miDebugger.attach(args.cwd, args.executable, args.target, args.autorun || []).then(() => {
114118
this.sendResponse(response);
115119
}, err => {

src/mago.ts

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArgum
1515
valuesFormatting: ValuesFormattingMode;
1616
printCalls: boolean;
1717
showDevDebugOutput: boolean;
18+
registerLimit: string;
1819
}
1920

2021
export interface AttachRequestArguments extends DebugProtocol.AttachRequestArguments {
@@ -29,6 +30,7 @@ export interface AttachRequestArguments extends DebugProtocol.AttachRequestArgum
2930
valuesFormatting: ValuesFormattingMode;
3031
printCalls: boolean;
3132
showDevDebugOutput: boolean;
33+
registerLimit: string;
3234
}
3335

3436
class MagoDebugSession extends MI2DebugSession {
@@ -66,6 +68,7 @@ class MagoDebugSession extends MI2DebugSession {
6668
this.setValuesFormattingMode(args.valuesFormatting);
6769
this.miDebugger.printCalls = !!args.printCalls;
6870
this.miDebugger.debugOutput = !!args.showDevDebugOutput;
71+
this.miDebugger.registerLimit = args.registerLimit ?? "";
6972
this.miDebugger.load(args.cwd, args.target, args.arguments, undefined, args.autorun || []).then(() => {
7073
this.sendResponse(response);
7174
}, err => {
@@ -88,6 +91,7 @@ class MagoDebugSession extends MI2DebugSession {
8891
this.setValuesFormattingMode(args.valuesFormatting);
8992
this.miDebugger.printCalls = !!args.printCalls;
9093
this.miDebugger.debugOutput = !!args.showDevDebugOutput;
94+
this.miDebugger.registerLimit = args.registerLimit ?? "";
9195
this.miDebugger.attach(args.cwd, args.executable, args.target, args.autorun || []).then(() => {
9296
this.sendResponse(response);
9397
}, err => {

0 commit comments

Comments
 (0)