Skip to content

Commit

Permalink
Merge pull request #436 from JacquesLucke/frame-filters
Browse files Browse the repository at this point in the history
Support GDB frame filters
  • Loading branch information
GitMensch authored Aug 22, 2024
2 parents 7d61f09 + 7d276df commit 7196ed1
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Versioning].
- fix implicitly type error in log message when build vsix ([@henryriley0])
- check for configured debugger before start to provide a nicer error message
([@GitMensch])
- New `frameFilters` option for GDB that allows using custom frame filters,
enabled by default ([@JacquesLucke])

## [0.27.0] - 2024-02-07

Expand Down Expand Up @@ -245,6 +247,7 @@ Versioning].
[@gitmensch]: https://github.com/GitMensch
[@haronk]: https://github.com/HaronK
[@henryriley0]: https://github.com/HenryRiley0
[@jacqueslucke]: https://github.com/JacquesLucke
[@jelleroets]: https://github.com/JelleRoets
[@karljs]: https://github.com/karljs
[@kvinwang]: https://github.com/kvinwang
Expand Down
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@
"prettyPrinters"
]
},
"frameFilters": {
"type": "boolean",
"description": "Use frame filters registered in GDB",
"default": true
},
"printCalls": {
"type": "boolean",
"description": "Prints all GDB calls to the console",
Expand Down Expand Up @@ -322,6 +327,11 @@
"prettyPrinters"
]
},
"frameFilters": {
"type": "boolean",
"description": "Use frame filters registered in GDB",
"default": true
},
"printCalls": {
"type": "boolean",
"description": "Prints all GDB calls to the console",
Expand Down
10 changes: 9 additions & 1 deletion src/backend/mi2/mi2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class LogMessage {
}
}

logMsgProcess(parsed:any){
logMsgProcess(parsed:MINode){
this.logMsgBrkList.forEach((brk)=>{
if(parsed.outOfBandRecord[0].output[0][1] == "breakpoint-hit" && parsed.outOfBandRecord[0].output[2][1] == brk.id){
this.logMsgVar = brk?.logMessage;
Expand Down Expand Up @@ -264,6 +264,8 @@ export class MI2 extends EventEmitter implements IBackend {
cmds.push(this.sendCommand("file-exec-and-symbols \"" + escape(target) + "\""));
if (this.prettyPrint)
cmds.push(this.sendCommand("enable-pretty-printing"));
if (this.frameFilters)
cmds.push(this.sendCommand("enable-frame-filters"));
for (const cmd of this.extraCommands) {
cmds.push(this.sendCommand(cmd));
}
Expand Down Expand Up @@ -794,6 +796,11 @@ export class MI2 extends EventEmitter implements IBackend {
const func = MINode.valueOf(element, "@frame.func");
const filename = MINode.valueOf(element, "@frame.file");
let file: string = MINode.valueOf(element, "@frame.fullname");
if (!file) {
// Fallback to using `file` if `fullname` is not provided.
// GDB does this for some reason when frame filters are used.
file = MINode.valueOf(element, "@frame.file");
}
if (file) {
if (this.isSSH)
file = path.posix.normalize(file);
Expand Down Expand Up @@ -1012,6 +1019,7 @@ export class MI2 extends EventEmitter implements IBackend {
}

prettyPrint: boolean = true;
frameFilters: boolean = true;
printCalls: boolean;
debugOutput: boolean;
features: string[];
Expand Down
4 changes: 4 additions & 0 deletions src/gdb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArgum
stopAtEntry: boolean | string;
ssh: SSHArguments;
valuesFormatting: ValuesFormattingMode;
frameFilters: boolean;
printCalls: boolean;
showDevDebugOutput: boolean;
}
Expand All @@ -35,6 +36,7 @@ export interface AttachRequestArguments extends DebugProtocol.AttachRequestArgum
stopAtEntry: boolean | string;
ssh: SSHArguments;
valuesFormatting: ValuesFormattingMode;
frameFilters: boolean;
printCalls: boolean;
showDevDebugOutput: boolean;
}
Expand Down Expand Up @@ -69,6 +71,7 @@ class GDBDebugSession extends MI2DebugSession {
this.started = false;
this.crashed = false;
this.setValuesFormattingMode(args.valuesFormatting);
this.miDebugger.frameFilters = !!args.frameFilters;
this.miDebugger.printCalls = !!args.printCalls;
this.miDebugger.debugOutput = !!args.showDevDebugOutput;
this.stopAtEntry = args.stopAtEntry;
Expand Down Expand Up @@ -113,6 +116,7 @@ class GDBDebugSession extends MI2DebugSession {
this.initialRunCommand = args.stopAtConnect ? RunCommand.NONE : RunCommand.CONTINUE;
this.isSSH = false;
this.setValuesFormattingMode(args.valuesFormatting);
this.miDebugger.frameFilters = !!args.frameFilters;
this.miDebugger.printCalls = !!args.printCalls;
this.miDebugger.debugOutput = !!args.showDevDebugOutput;
this.stopAtEntry = args.stopAtEntry;
Expand Down
2 changes: 1 addition & 1 deletion src/mibase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ export class MI2DebugSession extends DebugSession {

ret.push(new StackFrame(
this.threadAndLevelToFrameId(args.threadId, element.level),
element.function + "@" + element.address,
element.function + (element.address ? "@" + element.address : ""),
source,
element.line,
0));
Expand Down

0 comments on commit 7196ed1

Please sign in to comment.