Skip to content

Commit 7196ed1

Browse files
authored
Merge pull request #436 from JacquesLucke/frame-filters
Support GDB frame filters
2 parents 7d61f09 + 7d276df commit 7196ed1

File tree

5 files changed

+27
-2
lines changed

5 files changed

+27
-2
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ Versioning].
1616
- fix implicitly type error in log message when build vsix ([@henryriley0])
1717
- check for configured debugger before start to provide a nicer error message
1818
([@GitMensch])
19+
- New `frameFilters` option for GDB that allows using custom frame filters,
20+
enabled by default ([@JacquesLucke])
1921

2022
## [0.27.0] - 2024-02-07
2123

@@ -245,6 +247,7 @@ Versioning].
245247
[@gitmensch]: https://github.com/GitMensch
246248
[@haronk]: https://github.com/HaronK
247249
[@henryriley0]: https://github.com/HenryRiley0
250+
[@jacqueslucke]: https://github.com/JacquesLucke
248251
[@jelleroets]: https://github.com/JelleRoets
249252
[@karljs]: https://github.com/karljs
250253
[@kvinwang]: https://github.com/kvinwang

package.json

+10
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,11 @@
194194
"prettyPrinters"
195195
]
196196
},
197+
"frameFilters": {
198+
"type": "boolean",
199+
"description": "Use frame filters registered in GDB",
200+
"default": true
201+
},
197202
"printCalls": {
198203
"type": "boolean",
199204
"description": "Prints all GDB calls to the console",
@@ -322,6 +327,11 @@
322327
"prettyPrinters"
323328
]
324329
},
330+
"frameFilters": {
331+
"type": "boolean",
332+
"description": "Use frame filters registered in GDB",
333+
"default": true
334+
},
325335
"printCalls": {
326336
"type": "boolean",
327337
"description": "Prints all GDB calls to the console",

src/backend/mi2/mi2.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class LogMessage {
5454
}
5555
}
5656

57-
logMsgProcess(parsed:any){
57+
logMsgProcess(parsed:MINode){
5858
this.logMsgBrkList.forEach((brk)=>{
5959
if(parsed.outOfBandRecord[0].output[0][1] == "breakpoint-hit" && parsed.outOfBandRecord[0].output[2][1] == brk.id){
6060
this.logMsgVar = brk?.logMessage;
@@ -264,6 +264,8 @@ export class MI2 extends EventEmitter implements IBackend {
264264
cmds.push(this.sendCommand("file-exec-and-symbols \"" + escape(target) + "\""));
265265
if (this.prettyPrint)
266266
cmds.push(this.sendCommand("enable-pretty-printing"));
267+
if (this.frameFilters)
268+
cmds.push(this.sendCommand("enable-frame-filters"));
267269
for (const cmd of this.extraCommands) {
268270
cmds.push(this.sendCommand(cmd));
269271
}
@@ -794,6 +796,11 @@ export class MI2 extends EventEmitter implements IBackend {
794796
const func = MINode.valueOf(element, "@frame.func");
795797
const filename = MINode.valueOf(element, "@frame.file");
796798
let file: string = MINode.valueOf(element, "@frame.fullname");
799+
if (!file) {
800+
// Fallback to using `file` if `fullname` is not provided.
801+
// GDB does this for some reason when frame filters are used.
802+
file = MINode.valueOf(element, "@frame.file");
803+
}
797804
if (file) {
798805
if (this.isSSH)
799806
file = path.posix.normalize(file);
@@ -1012,6 +1019,7 @@ export class MI2 extends EventEmitter implements IBackend {
10121019
}
10131020

10141021
prettyPrint: boolean = true;
1022+
frameFilters: boolean = true;
10151023
printCalls: boolean;
10161024
debugOutput: boolean;
10171025
features: string[];

src/gdb.ts

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArgum
1717
stopAtEntry: boolean | string;
1818
ssh: SSHArguments;
1919
valuesFormatting: ValuesFormattingMode;
20+
frameFilters: boolean;
2021
printCalls: boolean;
2122
showDevDebugOutput: boolean;
2223
}
@@ -35,6 +36,7 @@ export interface AttachRequestArguments extends DebugProtocol.AttachRequestArgum
3536
stopAtEntry: boolean | string;
3637
ssh: SSHArguments;
3738
valuesFormatting: ValuesFormattingMode;
39+
frameFilters: boolean;
3840
printCalls: boolean;
3941
showDevDebugOutput: boolean;
4042
}
@@ -69,6 +71,7 @@ class GDBDebugSession extends MI2DebugSession {
6971
this.started = false;
7072
this.crashed = false;
7173
this.setValuesFormattingMode(args.valuesFormatting);
74+
this.miDebugger.frameFilters = !!args.frameFilters;
7275
this.miDebugger.printCalls = !!args.printCalls;
7376
this.miDebugger.debugOutput = !!args.showDevDebugOutput;
7477
this.stopAtEntry = args.stopAtEntry;
@@ -113,6 +116,7 @@ class GDBDebugSession extends MI2DebugSession {
113116
this.initialRunCommand = args.stopAtConnect ? RunCommand.NONE : RunCommand.CONTINUE;
114117
this.isSSH = false;
115118
this.setValuesFormattingMode(args.valuesFormatting);
119+
this.miDebugger.frameFilters = !!args.frameFilters;
116120
this.miDebugger.printCalls = !!args.printCalls;
117121
this.miDebugger.debugOutput = !!args.showDevDebugOutput;
118122
this.stopAtEntry = args.stopAtEntry;

src/mibase.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ export class MI2DebugSession extends DebugSession {
320320

321321
ret.push(new StackFrame(
322322
this.threadAndLevelToFrameId(args.threadId, element.level),
323-
element.function + "@" + element.address,
323+
element.function + (element.address ? "@" + element.address : ""),
324324
source,
325325
element.line,
326326
0));

0 commit comments

Comments
 (0)