Skip to content

Commit

Permalink
Add registerLimit config option to specify the registers to list in…
Browse files Browse the repository at this point in the history
… Registers view
  • Loading branch information
chenzhiy2001 committed Sep 19, 2024
1 parent d840528 commit 890e122
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Versioning].
- New `frameFilters` option for GDB that allows using custom frame filters,
enabled by default ([@JacquesLucke])
- Suppress error for hover as the user may just play with the mouse ([@oltolm]).
- Resolves #421 - Added `registerLimit` option to specify the registers to display to avoid corrupting the whole registers view - PR #444 ([@chenzhiy2001])

## [0.27.0] - 2024-02-07

Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,18 @@ that location prior to continuing execution. Note that stopping at the entry po
attach configuration assumes that the entry point has not yet been entered at the time of
attach, otherwise this will have no affect.

There is a `Registers` view in the `VARIABLES` TreeView, but since we fetch all registers
at once, there could be cases in which one unfetchable register causes the entire registers
request to fail, corrupting the whole `Registers` view. If this happens, you might need to
set the `registerLimit` option to specify what registers you want the debugger to fetch
automatically. For example, to only display registers `rax` and `rip` in an x64 debug
session, send the command `-data-list-register-names` in the debug console of an activating
x64 debug session. Then you'll receive a respond containing an array starting with
`["rax","rbx" ... `. In this array, the index of `rax` is 0 and `rip` is 16, so set the
option as `"registerLimit": "0 16"`. If you find the respond text hard to navigate, you can
paste it into a browser's developer tool console and press enter to get an expandable
respond object with array elements' indices explicitly displayed.

### Attaching to existing processes

Attaching to existing processes currently only works by specifying the PID in the
Expand Down
30 changes: 30 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,11 @@
"description": "Content will be executed on the SSH host before the debugger call."
}
}
},
"registerLimit": {
"type": "string",
"description": "List of numbers specifying the registers to display. An empty string indicates that the contents of all the registers must be returned.",
"default": ""
}
}
},
Expand Down Expand Up @@ -468,6 +473,11 @@
"description": "Content will be executed on the SSH host before the debugger call."
}
}
},
"registerLimit": {
"type": "string",
"description": "List of numbers specifying the registers to display. An empty string indicates that the contents of all the registers must be returned.",
"default": ""
}
}
}
Expand Down Expand Up @@ -766,6 +776,11 @@
"description": "Content will be executed on the SSH host before the debugger call."
}
}
},
"registerLimit": {
"type": "string",
"description": "List of numbers specifying the registers to display. An empty string indicates that the contents of all the registers must be returned.",
"default": ""
}
}
},
Expand Down Expand Up @@ -846,6 +861,11 @@
],
"description": "Whether debugger should stop at application entry point",
"default": false
},
"registerLimit": {
"type": "string",
"description": "List of numbers specifying the registers to display. An empty string indicates that the contents of all the registers must be returned.",
"default": ""
}
}
}
Expand Down Expand Up @@ -992,6 +1012,11 @@
"type": "array",
"description": "mago commands to run when starting to debug",
"default": []
},
"registerLimit": {
"type": "string",
"description": "List of numbers specifying the registers to display. An empty string indicates that the contents of all the registers must be returned.",
"default": ""
}
}
},
Expand Down Expand Up @@ -1057,6 +1082,11 @@
"type": "boolean",
"description": "Whether debugger should stop after connecting to target",
"default": false
},
"registerLimit": {
"type": "string",
"description": "List of numbers specifying the registers to display. An empty string indicates that the contents of all the registers must be returned.",
"default": ""
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/backend/mi2/mi2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ export class MI2 extends EventEmitter implements IBackend {
async getRegisterValues(): Promise<RegisterValue[]> {
if (trace)
this.log("stderr", "getRegisterValues");
const result = await this.sendCommand("data-list-register-values N");
const result = await this.sendCommand("data-list-register-values --skip-unavailable N " + this.registerLimit);
const nodes = result.result('register-values');
if (!Array.isArray(nodes)) {
throw new Error('Failed to retrieve register values.');
Expand Down Expand Up @@ -1024,6 +1024,7 @@ export class MI2 extends EventEmitter implements IBackend {
debugOutput: boolean;
features: string[];
public procEnv: any;
public registerLimit: string;
protected isSSH: boolean;
protected sshReady: boolean;
protected currentToken: number = 1;
Expand Down
4 changes: 4 additions & 0 deletions src/gdb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArgum
frameFilters: boolean;
printCalls: boolean;
showDevDebugOutput: boolean;
registerLimit: string;
}

export interface AttachRequestArguments extends DebugProtocol.AttachRequestArguments {
Expand All @@ -39,6 +40,7 @@ export interface AttachRequestArguments extends DebugProtocol.AttachRequestArgum
frameFilters: boolean;
printCalls: boolean;
showDevDebugOutput: boolean;
registerLimit: string;
}

class GDBDebugSession extends MI2DebugSession {
Expand Down Expand Up @@ -75,6 +77,7 @@ class GDBDebugSession extends MI2DebugSession {
this.miDebugger.printCalls = !!args.printCalls;
this.miDebugger.debugOutput = !!args.showDevDebugOutput;
this.stopAtEntry = args.stopAtEntry;
this.miDebugger.registerLimit = args.registerLimit ?? "";
if (args.ssh !== undefined) {
if (args.ssh.forwardX11 === undefined)
args.ssh.forwardX11 = true;
Expand Down Expand Up @@ -120,6 +123,7 @@ class GDBDebugSession extends MI2DebugSession {
this.miDebugger.printCalls = !!args.printCalls;
this.miDebugger.debugOutput = !!args.showDevDebugOutput;
this.stopAtEntry = args.stopAtEntry;
this.miDebugger.registerLimit = args.registerLimit ?? "";
if (args.ssh !== undefined) {
if (args.ssh.forwardX11 === undefined)
args.ssh.forwardX11 = true;
Expand Down
4 changes: 4 additions & 0 deletions src/lldb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArgum
valuesFormatting: ValuesFormattingMode;
printCalls: boolean;
showDevDebugOutput: boolean;
registerLimit: string;
}

export interface AttachRequestArguments extends DebugProtocol.AttachRequestArguments {
Expand All @@ -34,6 +35,7 @@ export interface AttachRequestArguments extends DebugProtocol.AttachRequestArgum
valuesFormatting: ValuesFormattingMode;
printCalls: boolean;
showDevDebugOutput: boolean;
registerLimit: string;
}

class LLDBDebugSession extends MI2DebugSession {
Expand Down Expand Up @@ -66,6 +68,7 @@ class LLDBDebugSession extends MI2DebugSession {
this.miDebugger.printCalls = !!args.printCalls;
this.miDebugger.debugOutput = !!args.showDevDebugOutput;
this.stopAtEntry = args.stopAtEntry;
this.miDebugger.registerLimit = args.registerLimit ?? "";
if (args.ssh !== undefined) {
if (args.ssh.forwardX11 === undefined)
args.ssh.forwardX11 = true;
Expand Down Expand Up @@ -110,6 +113,7 @@ class LLDBDebugSession extends MI2DebugSession {
this.miDebugger.printCalls = !!args.printCalls;
this.miDebugger.debugOutput = !!args.showDevDebugOutput;
this.stopAtEntry = args.stopAtEntry;
this.miDebugger.registerLimit = args.registerLimit ?? "";
this.miDebugger.attach(args.cwd, args.executable, args.target, args.autorun || []).then(() => {
this.sendResponse(response);
}, err => {
Expand Down
4 changes: 4 additions & 0 deletions src/mago.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArgum
valuesFormatting: ValuesFormattingMode;
printCalls: boolean;
showDevDebugOutput: boolean;
registerLimit: string;
}

export interface AttachRequestArguments extends DebugProtocol.AttachRequestArguments {
Expand All @@ -29,6 +30,7 @@ export interface AttachRequestArguments extends DebugProtocol.AttachRequestArgum
valuesFormatting: ValuesFormattingMode;
printCalls: boolean;
showDevDebugOutput: boolean;
registerLimit: string;
}

class MagoDebugSession extends MI2DebugSession {
Expand Down Expand Up @@ -66,6 +68,7 @@ class MagoDebugSession extends MI2DebugSession {
this.setValuesFormattingMode(args.valuesFormatting);
this.miDebugger.printCalls = !!args.printCalls;
this.miDebugger.debugOutput = !!args.showDevDebugOutput;
this.miDebugger.registerLimit = args.registerLimit ?? "";
this.miDebugger.load(args.cwd, args.target, args.arguments, undefined, args.autorun || []).then(() => {
this.sendResponse(response);
}, err => {
Expand All @@ -88,6 +91,7 @@ class MagoDebugSession extends MI2DebugSession {
this.setValuesFormattingMode(args.valuesFormatting);
this.miDebugger.printCalls = !!args.printCalls;
this.miDebugger.debugOutput = !!args.showDevDebugOutput;
this.miDebugger.registerLimit = args.registerLimit ?? "";
this.miDebugger.attach(args.cwd, args.executable, args.target, args.autorun || []).then(() => {
this.sendResponse(response);
}, err => {
Expand Down

0 comments on commit 890e122

Please sign in to comment.