Skip to content

Commit

Permalink
Enhancing ImageAndSymbols to load several binaries
Browse files Browse the repository at this point in the history
Signed-off-by: Florent Vion <[email protected]>
  • Loading branch information
FlorentVSTM committed Dec 11, 2023
1 parent cd740cd commit 6de25ed
Showing 1 changed file with 33 additions and 4 deletions.
37 changes: 33 additions & 4 deletions src/GDBTargetDebugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,26 +79,40 @@ export interface TargetLaunchArguments extends TargetAttachArguments {
cwd?: string;
}

export interface ImageAndSymbolArguments {
export interface SymbolFileAndOffset {
// If specified, a symbol file to load at the given (optional) offset
file: string;
offset?: string;
}

export interface ImageFileAndOffset {
// If specified, an image file to load at the given (optional) offset
file: string;
offset?: string;
}

export interface ImageAndSymbolsArguments {
symbolFilesAndOffset?: SymbolFileAndOffset[];
imageFilesAndOffset?: ImageFileAndOffset[];
// Deprecated, use symbolFilesAndOffset instead. If specified, a symbol file to load at the given (optional) offset
symbolFileName?: string;
symbolOffset?: string;
// If specified, an image file to load at the given (optional) offset
// Deprecated, use imageFilesAndOffset instead. If specified, an image file to load at the given (optional) offset
imageFileName?: string;
imageOffset?: string;
}

export interface TargetAttachRequestArguments extends RequestArguments {
target?: TargetAttachArguments;
imageAndSymbols?: ImageAndSymbolArguments;
imageAndSymbols?: ImageAndSymbolsArguments;
// Optional commands to issue between loading image and resuming target
preRunCommands?: string[];
}

export interface TargetLaunchRequestArguments
extends TargetAttachRequestArguments {
target?: TargetLaunchArguments;
imageAndSymbols?: ImageAndSymbolArguments;
imageAndSymbols?: ImageAndSymbolsArguments;
// Optional commands to issue between loading image and resuming target
preRunCommands?: string[];
}
Expand Down Expand Up @@ -453,6 +467,7 @@ export class GDBTargetDebugSession extends GDBDebugSession {
await this.gdb.sendEnablePrettyPrint();
if (args.imageAndSymbols) {
if (args.imageAndSymbols.symbolFileName) {
// Deprecated
if (args.imageAndSymbols.symbolOffset) {
await this.gdb.sendAddSymbolFile(
args.imageAndSymbols.symbolFileName,
Expand All @@ -463,6 +478,13 @@ export class GDBTargetDebugSession extends GDBDebugSession {
args.imageAndSymbols.symbolFileName
);
}
} else {
const symFiles: SymbolFileAndOffset[] =
args.imageAndSymbols.symbolFilesAndOffset ?? [];
for (const symF of symFiles) {
const offset: string = symF.offset ? symF.offset : '';
await this.gdb.sendAddSymbolFile(symF.file, offset);
}
}
}

Expand Down Expand Up @@ -511,10 +533,17 @@ export class GDBTargetDebugSession extends GDBDebugSession {

if (args.imageAndSymbols) {
if (args.imageAndSymbols.imageFileName) {
// Deprecated
await this.gdb.sendLoad(
args.imageAndSymbols.imageFileName,
args.imageAndSymbols.imageOffset
);
} else {
const imgFiles: ImageFileAndOffset[] =
args.imageAndSymbols.imageFilesAndOffset ?? [];
for (const imgF of imgFiles) {
await this.gdb.sendLoad(imgF.file, imgF.offset);
}
}
}
await this.gdb.sendCommands(args.preRunCommands);
Expand Down

0 comments on commit 6de25ed

Please sign in to comment.