From 6de25ed8b852a04eb246d5bf305f8c73d15d8d9a 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 | 37 ++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/src/GDBTargetDebugSession.ts b/src/GDBTargetDebugSession.ts index d558bd55..26011d2b 100644 --- a/src/GDBTargetDebugSession.ts +++ b/src/GDBTargetDebugSession.ts @@ -79,18 +79,32 @@ 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[]; } @@ -98,7 +112,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[]; } @@ -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, @@ -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); + } } } @@ -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);