From dbd0141eac5a634d0932a45d2719728ec608426a Mon Sep 17 00:00:00 2001 From: Martin Date: Sun, 14 Jan 2024 14:24:20 +0100 Subject: [PATCH] FpDebug: MemModel for Win/Darwin / fixes --- components/fpdebug/fpdbgcallcontextinfo.pas | 5 +++-- components/fpdebug/fpdbgcontroller.pas | 2 +- components/fpdebug/fpdbgdarwinclasses.pas | 6 +++--- components/fpdebug/fpdbgdwarf.pas | 2 +- components/fpdebug/fpdbginfo.pas | 13 ++++++++++--- components/fpdebug/fpdbgwinclasses.pas | 9 +++++---- 6 files changed, 23 insertions(+), 14 deletions(-) diff --git a/components/fpdebug/fpdbgcallcontextinfo.pas b/components/fpdebug/fpdbgcallcontextinfo.pas index 9e51c0f8b2..1aff5a9624 100644 --- a/components/fpdebug/fpdbgcallcontextinfo.pas +++ b/components/fpdebug/fpdbgcallcontextinfo.pas @@ -72,6 +72,7 @@ type public constructor Create(const ABaseContext: TFpDbgLocationContext; AMemReader: TFpDbgMemReaderBase; + AMemModel: TFpDbgMemModel; AMemConverter: TFpDbgMemConvertor; ADbgProcess: TDbgProcess; ADbgThread: TDbgThread); @@ -450,10 +451,10 @@ end; constructor TFpDbgInfoCallContext.Create( const ABaseContext: TFpDbgLocationContext; AMemReader: TFpDbgMemReaderBase; - AMemConverter: TFpDbgMemConvertor; ADbgProcess: TDbgProcess; + AMemModel: TFpDbgMemModel; AMemConverter: TFpDbgMemConvertor; ADbgProcess: TDbgProcess; ADbgThread: TDbgThread); begin - inherited Create(ABaseContext, AMemReader, AMemConverter); + inherited Create(ABaseContext, AMemReader, AMemModel, AMemConverter); FDbgProcess := ADbgProcess; FDbgThread := ADbgThread; FNextParamRegister := 0; diff --git a/components/fpdebug/fpdbgcontroller.pas b/components/fpdebug/fpdbgcontroller.pas index b2659c08a7..bc9dfad21f 100644 --- a/components/fpdebug/fpdbgcontroller.pas +++ b/components/fpdebug/fpdbgcontroller.pas @@ -2133,7 +2133,7 @@ begin then exit; - Context := TFpDbgInfoCallContext.Create(ABaseContext, AMemReader, AMemConverter, FCurrentProcess, FCurrentThread); + Context := TFpDbgInfoCallContext.Create(ABaseContext, AMemReader, MemModel, AMemConverter, FCurrentProcess, FCurrentThread); Context.AddReference; InitializeCommand(TDbgControllerCallRoutineCmd.Create(self, FunctionAddress, Context)); Result := Context; diff --git a/components/fpdebug/fpdbgdarwinclasses.pas b/components/fpdebug/fpdbgdarwinclasses.pas index 0c77d46c8c..cd3d1019f7 100644 --- a/components/fpdebug/fpdbgdarwinclasses.pas +++ b/components/fpdebug/fpdbgdarwinclasses.pas @@ -155,7 +155,7 @@ type AWorkingDirectory, AConsoleTty: string; AFlags: TStartInstanceFlags; out AnError: TFpError): boolean; override; class function isSupported(ATargetInfo: TTargetDescriptor): boolean; override; - constructor Create(const AFileName: string; AnOsClasses: TOSDbgClasses; AMemManager: TFpDbgMemManager; AProcessConfig: TDbgProcessConfig = nil); override; + constructor Create(const AFileName: string; AnOsClasses: TOSDbgClasses; AMemManager: TFpDbgMemManager; AMemModel: TFpDbgMemModel; AProcessConfig: TDbgProcessConfig = nil); override; destructor Destroy; override; function ReadData(const AAdress: TDbgPtr; const ASize: Cardinal; out AData): Boolean; override; @@ -637,10 +637,10 @@ begin end; constructor TDbgDarwinProcess.Create(const AFileName: string; - AnOsClasses: TOSDbgClasses; AMemManager: TFpDbgMemManager; + AnOsClasses: TOSDbgClasses; AMemManager: TFpDbgMemManager; AMemModel: TFpDbgMemModel; AProcessConfig: TDbgProcessConfig); begin - inherited Create(AFileName, AnOsClasses, AMemManager, AProcessConfig); + inherited Create(AFileName, AnOsClasses, AMemManager, AMemModel, AProcessConfig); GetDebugAccessRights; end; diff --git a/components/fpdebug/fpdbgdwarf.pas b/components/fpdebug/fpdbgdwarf.pas index 568e9b9a64..17f4e197a1 100644 --- a/components/fpdebug/fpdbgdwarf.pas +++ b/components/fpdebug/fpdbgdwarf.pas @@ -5728,7 +5728,7 @@ end; function TFpSymbolDwarfTypeSubroutine.GetDataAddress(AValueObj: TFpValueDwarf; var AnAddress: TFpDbgMemLocation; ATargetType: TFpSymbolDwarfType): Boolean; begin - inherited; + Result := inherited GetDataAddress(AValueObj, AnAddress, ATargetType); AnAddress := AValueObj.Context.MemModel.UpdateLocationToCodeAddress(AnAddress); end; diff --git a/components/fpdebug/fpdbginfo.pas b/components/fpdebug/fpdbginfo.pas index 9d0bc2a9bd..5ff5a6cd4e 100644 --- a/components/fpdebug/fpdbginfo.pas +++ b/components/fpdebug/fpdbginfo.pas @@ -662,12 +662,14 @@ type FMessage: string; protected function GetMemManager: TFpDbgMemManager; override; + function GetMemModel: TFpDbgMemModel; override; function GetAddress: TDbgPtr; override; function GetThreadId: Integer; override; function GetStackFrame: Integer; override; function GetSizeOfAddress: Integer; override; public - constructor Create(const ABaseContext: TFpDbgLocationContext; AMemReader: TFpDbgMemReaderBase; AMemConverter: TFpDbgMemConvertor); + constructor Create(const ABaseContext: TFpDbgLocationContext; + AMemReader: TFpDbgMemReaderBase; AMemModel: TFpDbgMemModel; AMemConverter: TFpDbgMemConvertor); destructor Destroy; override; procedure SetRegisterValue(ARegNum: Cardinal; AValue: TDbgPtr); @@ -783,12 +785,12 @@ end; constructor TFpDbgAbstractCallContext.Create( const ABaseContext: TFpDbgLocationContext; AMemReader: TFpDbgMemReaderBase; - AMemConverter: TFpDbgMemConvertor); + AMemModel: TFpDbgMemModel; AMemConverter: TFpDbgMemConvertor); begin FBaseContext:=ABaseContext; FBaseContext.AddReference; - FMemModel := TFpDbgMemModel.Create; + FMemModel := AMemModel; FMemReader := TFpDbgCallMemReader.Create(AMemReader); FMemManager := TFpDbgMemManager.Create(FMemReader, AMemConverter, FMemModel); @@ -815,6 +817,11 @@ begin Result := FMemManager; end; +function TFpDbgAbstractCallContext.GetMemModel: TFpDbgMemModel; +begin + Result := FMemModel; +end; + function TFpDbgAbstractCallContext.GetSizeOfAddress: Integer; begin Result := FBaseContext.SizeOfAddress; diff --git a/components/fpdebug/fpdbgwinclasses.pas b/components/fpdebug/fpdbgwinclasses.pas index 4572616fd5..10cd392115 100644 --- a/components/fpdebug/fpdbgwinclasses.pas +++ b/components/fpdebug/fpdbgwinclasses.pas @@ -198,7 +198,7 @@ type function CreateWatchPointData: TFpWatchPointData; override; public constructor Create(const AFileName: string; AnOsClasses: TOSDbgClasses; - AMemManager: TFpDbgMemManager; AProcessConfig: TDbgProcessConfig = nil); override; + AMemManager: TFpDbgMemManager; AMemModel: TFpDbgMemModel; AProcessConfig: TDbgProcessConfig = nil); override; destructor Destroy; override; function ReadData(const AAdress: TDbgPtr; const ASize: Cardinal; out AData): Boolean; override; @@ -555,15 +555,16 @@ begin Result := TFpIntelWatchPointData.Create; end; -constructor TDbgWinProcess.Create(const AFileName: string; AnOsClasses: TOSDbgClasses; - AMemManager: TFpDbgMemManager; AProcessConfig: TDbgProcessConfig); +constructor TDbgWinProcess.Create(const AFileName: string; + AnOsClasses: TOSDbgClasses; AMemManager: TFpDbgMemManager; + AMemModel: TFpDbgMemModel; AProcessConfig: TDbgProcessConfig); begin {$ifdef cpui386} FBitness := b32; {$else} FBitness := b64; {$endif} - inherited Create(AFileName, AnOsClasses, AMemManager, AProcessConfig); + inherited Create(AFileName, AnOsClasses, AMemManager, AMemModel, AProcessConfig); end; destructor TDbgWinProcess.Destroy;