From 7809dcf6c8044a130a765a39aa809de06f93c597 Mon Sep 17 00:00:00 2001 From: Florent Vion Date: Tue, 5 Dec 2023 10:10:20 +0100 Subject: [PATCH] Enhancing ImageAndSymbols to load several binaries Signed-off-by: Florent Vion --- src/GDBTargetDebugSession.ts | 47 ++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/src/GDBTargetDebugSession.ts b/src/GDBTargetDebugSession.ts index d558bd55..3bbe7ae1 100644 --- a/src/GDBTargetDebugSession.ts +++ b/src/GDBTargetDebugSession.ts @@ -79,18 +79,26 @@ 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[]; } @@ -98,7 +106,7 @@ export interface TargetAttachRequestArguments extends RequestArguments { export interface TargetLaunchRequestArguments extends TargetAttachRequestArguments { target?: TargetLaunchArguments; - imageAndSymbols?: ImageAndSymbolArguments; + imageAndSymbols?: ImageAndSymbolsArguments; // Optional commands to issue between loading image and resuming target preRunCommands?: string[]; } @@ -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 + ); } } @@ -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 ); } }