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 5, 2023
1 parent cd740cd commit 7809dcf
Showing 1 changed file with 26 additions and 21 deletions.
47 changes: 26 additions & 21 deletions src/GDBTargetDebugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,26 +79,34 @@ 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
symbolFileName?: string;
symbolOffset?: string;
file: string;
offset?: string;
}

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

export interface ImageAndSymbolsArguments {
symbolFilesAndOffset?: SymbolFileAndOffset[];
imageFilesAndOffset?: ImageFileAndOffset[]
}

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 @@ -452,17 +460,13 @@ export class GDBTargetDebugSession extends GDBDebugSession {
await this.gdb.sendFileExecAndSymbols(args.program);
await this.gdb.sendEnablePrettyPrint();
if (args.imageAndSymbols) {
if (args.imageAndSymbols.symbolFileName) {
if (args.imageAndSymbols.symbolOffset) {
await this.gdb.sendAddSymbolFile(
args.imageAndSymbols.symbolFileName,
args.imageAndSymbols.symbolOffset
);
} else {
await this.gdb.sendFileSymbolFile(
args.imageAndSymbols.symbolFileName
);
}
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 @@ -510,10 +514,11 @@ export class GDBTargetDebugSession extends GDBDebugSession {
}

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

0 comments on commit 7809dcf

Please sign in to comment.