Skip to content

Commit 7809dcf

Browse files
committed
Enhancing ImageAndSymbols to load several binaries
Signed-off-by: Florent Vion <[email protected]>
1 parent cd740cd commit 7809dcf

File tree

1 file changed

+26
-21
lines changed

1 file changed

+26
-21
lines changed

src/GDBTargetDebugSession.ts

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -79,26 +79,34 @@ export interface TargetLaunchArguments extends TargetAttachArguments {
7979
cwd?: string;
8080
}
8181

82-
export interface ImageAndSymbolArguments {
82+
export interface SymbolFileAndOffset {
8383
// If specified, a symbol file to load at the given (optional) offset
84-
symbolFileName?: string;
85-
symbolOffset?: string;
84+
file: string;
85+
offset?: string;
86+
}
87+
88+
export interface ImageFileAndOffset {
8689
// If specified, an image file to load at the given (optional) offset
87-
imageFileName?: string;
88-
imageOffset?: string;
90+
file: string;
91+
offset?: string;
92+
}
93+
94+
export interface ImageAndSymbolsArguments {
95+
symbolFilesAndOffset?: SymbolFileAndOffset[];
96+
imageFilesAndOffset?: ImageFileAndOffset[]
8997
}
9098

9199
export interface TargetAttachRequestArguments extends RequestArguments {
92100
target?: TargetAttachArguments;
93-
imageAndSymbols?: ImageAndSymbolArguments;
101+
imageAndSymbols?: ImageAndSymbolsArguments;
94102
// Optional commands to issue between loading image and resuming target
95103
preRunCommands?: string[];
96104
}
97105

98106
export interface TargetLaunchRequestArguments
99107
extends TargetAttachRequestArguments {
100108
target?: TargetLaunchArguments;
101-
imageAndSymbols?: ImageAndSymbolArguments;
109+
imageAndSymbols?: ImageAndSymbolsArguments;
102110
// Optional commands to issue between loading image and resuming target
103111
preRunCommands?: string[];
104112
}
@@ -452,17 +460,13 @@ export class GDBTargetDebugSession extends GDBDebugSession {
452460
await this.gdb.sendFileExecAndSymbols(args.program);
453461
await this.gdb.sendEnablePrettyPrint();
454462
if (args.imageAndSymbols) {
455-
if (args.imageAndSymbols.symbolFileName) {
456-
if (args.imageAndSymbols.symbolOffset) {
457-
await this.gdb.sendAddSymbolFile(
458-
args.imageAndSymbols.symbolFileName,
459-
args.imageAndSymbols.symbolOffset
460-
);
461-
} else {
462-
await this.gdb.sendFileSymbolFile(
463-
args.imageAndSymbols.symbolFileName
464-
);
465-
}
463+
const symFiles: SymbolFileAndOffset[] = args.imageAndSymbols.symbolFilesAndOffset ?? [];
464+
for (const symF of symFiles) {
465+
const offset: string = symF.offset ? symF.offset : '';
466+
await this.gdb.sendAddSymbolFile(
467+
symF.file,
468+
offset
469+
);
466470
}
467471
}
468472

@@ -510,10 +514,11 @@ export class GDBTargetDebugSession extends GDBDebugSession {
510514
}
511515

512516
if (args.imageAndSymbols) {
513-
if (args.imageAndSymbols.imageFileName) {
517+
const imgFiles: ImageFileAndOffset[] = args.imageAndSymbols.imageFilesAndOffset ?? [];
518+
for (const imgF of imgFiles) {
514519
await this.gdb.sendLoad(
515-
args.imageAndSymbols.imageFileName,
516-
args.imageAndSymbols.imageOffset
520+
imgF.file,
521+
imgF.offset
517522
);
518523
}
519524
}

0 commit comments

Comments
 (0)