Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add registerLimit config option to specify the registers to list in Registers view (continuation of PR #444) #446

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Versioning].
enabled by default ([@JacquesLucke])
- Suppress error for hover as the user may just play with the mouse ([@oltolm]).
- solve the problem of failed parsing of containers ([@henryriley0])
- Fixes #421 - Added `registerLimit` option to specify the registers to
display - PR #444 ([@chenzhiy2001])

## [0.27.0] - 2024-02-07

Expand Down Expand Up @@ -243,6 +245,7 @@ Versioning].
[@abussy-aldebaran]: https://github.com/abussy-aldebaran
[@anshulrouthu]: https://github.com/anshulrouthu
[@brownts]: https://github.com/brownts
[@chenzhiy2001]: https://github.com/chenzhiy2001
[@coldencullen]: https://github.com/ColdenCullen
[@eamousing]: https://github.com/eamousing
[@evangrayk]: https://github.com/evangrayk
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,20 @@ 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 view. As we fetch all registers at once, there can
be cases where a register that cannot be fetched causes the entire register request to fail,
corrupting the entire Registers output. If this happens, you might need to set the
`registerLimit` option to specify which registers you want the debugger to fetch
automatically.

For example, to display only registers `rax` and `rip` in an x64 debug session, send the
command `-data-list-register-names` in the debug console of an active x64 debug session.
You will then receive a response 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 response text hard to navigate, you can paste
it into a browser's developer tools console and press enter to get an expandable response
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
Loading