mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 21:41:35 +02:00
FpDebug: Give a warning when the UUID of the dSym-bundle and the debuggee do not match
git-svn-id: trunk@46149 -
This commit is contained in:
parent
9da887b714
commit
2725568fae
@ -189,13 +189,14 @@ type
|
|||||||
FMode: TFPDMode;
|
FMode: TFPDMode;
|
||||||
FName: String;
|
FName: String;
|
||||||
FProcess: TDbgProcess;
|
FProcess: TDbgProcess;
|
||||||
FDbgInfo: TDbgInfo;
|
|
||||||
FSymbolTableInfo: TFpSymbolInfo;
|
FSymbolTableInfo: TFpSymbolInfo;
|
||||||
FLoader: TDbgImageLoader;
|
FLoader: TDbgImageLoader;
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
FDbgInfo: TDbgInfo;
|
||||||
function InitializeLoader: TDbgImageLoader; virtual;
|
function InitializeLoader: TDbgImageLoader; virtual;
|
||||||
procedure SetName(const AValue: String);
|
procedure SetName(const AValue: String);
|
||||||
|
property Loader: TDbgImageLoader read FLoader write FLoader;
|
||||||
public
|
public
|
||||||
constructor Create(const AProcess: TDbgProcess); virtual;
|
constructor Create(const AProcess: TDbgProcess); virtual;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -975,9 +976,7 @@ begin
|
|||||||
inherited LoadInfo;
|
inherited LoadInfo;
|
||||||
|
|
||||||
if DbgInfo.HasInfo then
|
if DbgInfo.HasInfo then
|
||||||
FSymInstances.Add(Self)
|
FSymInstances.Add(Self);
|
||||||
else
|
|
||||||
Log('No Dwarf-debug information available. The debugger will not function properly.',dllInfo);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TDbgProcess.GetLastEventProcessIdentifier: THandle;
|
function TDbgProcess.GetLastEventProcessIdentifier: THandle;
|
||||||
|
@ -692,6 +692,9 @@ begin
|
|||||||
deCreateProcess:
|
deCreateProcess:
|
||||||
begin
|
begin
|
||||||
FCurrentProcess.LoadInfo;
|
FCurrentProcess.LoadInfo;
|
||||||
|
if not FCurrentProcess.DbgInfo.HasInfo then
|
||||||
|
Log('No Dwarf-debug information available. The debugger will not function properly.',dllInfo);
|
||||||
|
|
||||||
DoOnDebugInfoLoaded(self);
|
DoOnDebugInfoLoaded(self);
|
||||||
|
|
||||||
continue:=true;
|
continue:=true;
|
||||||
|
@ -15,6 +15,7 @@ uses
|
|||||||
FpDbgLoader,
|
FpDbgLoader,
|
||||||
DbgIntfBaseTypes,
|
DbgIntfBaseTypes,
|
||||||
FpDbgLinuxExtra,
|
FpDbgLinuxExtra,
|
||||||
|
FpDbgDwarfDataClasses,
|
||||||
FpDbgInfo,
|
FpDbgInfo,
|
||||||
MacOSAll,
|
MacOSAll,
|
||||||
FpDbgUtil,
|
FpDbgUtil,
|
||||||
@ -139,6 +140,7 @@ type
|
|||||||
class function StartInstance(AFileName: string; AParams, AnEnvironment: TStrings; AWorkingDirectory: string; AOnLog: TOnLog): TDbgProcess; override;
|
class function StartInstance(AFileName: string; AParams, AnEnvironment: TStrings; AWorkingDirectory: string; AOnLog: TOnLog): TDbgProcess; override;
|
||||||
constructor Create(const AName: string; const AProcessID, AThreadID: Integer; AOnLog: TOnLog); override;
|
constructor Create(const AName: string; const AProcessID, AThreadID: Integer; AOnLog: TOnLog); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
procedure LoadInfo; override;
|
||||||
|
|
||||||
function ReadData(const AAdress: TDbgPtr; const ASize: Cardinal; out AData): Boolean; override;
|
function ReadData(const AAdress: TDbgPtr; const ASize: Cardinal; out AData): Boolean; override;
|
||||||
function WriteData(const AAdress: TDbgPtr; const ASize: Cardinal; const AData): Boolean; override;
|
function WriteData(const AAdress: TDbgPtr; const ASize: Cardinal; const AData): Boolean; override;
|
||||||
@ -617,27 +619,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TDbgDarwinProcess.InitializeLoader: TDbgImageLoader;
|
function TDbgDarwinProcess.InitializeLoader: TDbgImageLoader;
|
||||||
var
|
|
||||||
dSYMFilename: string;
|
|
||||||
begin
|
begin
|
||||||
// JvdS: Mach-O binaries do not contain DWARF-debug info. Instead this info
|
result := TDbgImageLoader.Create(Name);
|
||||||
// is stored inside the .o files, and the executable contains a map (in stabs-
|
|
||||||
// format) of all these .o files. An alternative to parsing this map and reading
|
|
||||||
// those .o files a dSYM-bundle could be used, which could be generated
|
|
||||||
// with dsymutil.
|
|
||||||
dSYMFilename:=ChangeFileExt(Name, '.dSYM');
|
|
||||||
dSYMFilename:=dSYMFilename+'/Contents/Resources/DWARF/'+ExtractFileName(Name);
|
|
||||||
|
|
||||||
if ExtractFileExt(dSYMFilename)='.app' then
|
|
||||||
dSYMFilename := ChangeFileExt(dSYMFilename,'');
|
|
||||||
|
|
||||||
if FileExists(dSYMFilename) then
|
|
||||||
result := TDbgImageLoader.Create(dSYMFilename)
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
log('No dSYM bundle ('+dSYMFilename+') found.', dllInfo);
|
|
||||||
result := TDbgImageLoader.Create(Name);
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TDbgDarwinProcess.CreateThread(AthreadIdentifier: THandle; out IsMainThread: boolean): TDbgThread;
|
function TDbgDarwinProcess.CreateThread(AthreadIdentifier: THandle; out IsMainThread: boolean): TDbgThread;
|
||||||
@ -672,6 +655,45 @@ begin
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TDbgDarwinProcess.LoadInfo;
|
||||||
|
var
|
||||||
|
dSYMFilename: string;
|
||||||
|
ALoader: TDbgImageLoader;
|
||||||
|
begin
|
||||||
|
inherited LoadInfo;
|
||||||
|
|
||||||
|
// JvdS: Mach-O binaries do not contain DWARF-debug info. Instead this info
|
||||||
|
// is stored inside the .o files, and the executable contains a map (in stabs-
|
||||||
|
// format) of all these .o files. An alternative to parsing this map and reading
|
||||||
|
// those .o files a dSYM-bundle could be used, which could be generated
|
||||||
|
// with dsymutil.
|
||||||
|
dSYMFilename:=ChangeFileExt(Name, '.dSYM');
|
||||||
|
dSYMFilename:=dSYMFilename+'/Contents/Resources/DWARF/'+ExtractFileName(Name);
|
||||||
|
|
||||||
|
if ExtractFileExt(dSYMFilename)='.app' then
|
||||||
|
dSYMFilename := ChangeFileExt(dSYMFilename,'');
|
||||||
|
|
||||||
|
if FileExists(dSYMFilename) then
|
||||||
|
begin
|
||||||
|
ALoader := TDbgImageLoader.Create(dSYMFilename);
|
||||||
|
if GUIDToString(ALoader.UUID)<>GUIDToString(Loader.UUID) then
|
||||||
|
log('The unique UUID''s of the executable and the dSYM bundle with debug-info ('+dSYMFilename+') do not match. This can lead to problems during debugging.', dllInfo);
|
||||||
|
FDbgInfo.Free;
|
||||||
|
Loader.Free;
|
||||||
|
Loader := ALoader;
|
||||||
|
FDbgInfo := TFpDwarfInfo.Create(Loader);
|
||||||
|
TFpDwarfInfo(FDbgInfo).LoadCompilationUnits;
|
||||||
|
|
||||||
|
if FDbgInfo.HasInfo then
|
||||||
|
begin
|
||||||
|
if FSymInstances.IndexOf(Self)=-1 then
|
||||||
|
FSymInstances.Add(Self);
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
log('No dSYM bundle ('+dSYMFilename+') found.', dllInfo);
|
||||||
|
end;
|
||||||
|
|
||||||
class function TDbgDarwinProcess.StartInstance(AFileName: string; AParams, AnEnvironment: TStrings; AWorkingDirectory: string; AOnLog: TOnLog): TDbgProcess;
|
class function TDbgDarwinProcess.StartInstance(AFileName: string; AParams, AnEnvironment: TStrings; AWorkingDirectory: string; AOnLog: TOnLog): TDbgProcess;
|
||||||
var
|
var
|
||||||
PID: TPid;
|
PID: TPid;
|
||||||
|
@ -57,6 +57,7 @@ type
|
|||||||
FFileLoader: TDbgFileLoader;
|
FFileLoader: TDbgFileLoader;
|
||||||
FImgReader: TDbgImageReader;
|
FImgReader: TDbgImageReader;
|
||||||
function GetImage64Bit: Boolean;
|
function GetImage64Bit: Boolean;
|
||||||
|
function GetUUID: TGuid;
|
||||||
protected
|
protected
|
||||||
FImageBase: QWord unimplemented;
|
FImageBase: QWord unimplemented;
|
||||||
function GetSection(const AName: String): PDbgImageSection; virtual;
|
function GetSection(const AName: String): PDbgImageSection; virtual;
|
||||||
@ -73,6 +74,7 @@ type
|
|||||||
function IsValid: Boolean;
|
function IsValid: Boolean;
|
||||||
property ImageBase: QWord read FImageBase; unimplemented;
|
property ImageBase: QWord read FImageBase; unimplemented;
|
||||||
Property Image64Bit: Boolean read GetImage64Bit;
|
Property Image64Bit: Boolean read GetImage64Bit;
|
||||||
|
property UUID: TGuid read GetUUID;
|
||||||
property Section[const AName: String]: PDbgImageSection read GetSection;
|
property Section[const AName: String]: PDbgImageSection read GetSection;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -94,6 +96,14 @@ begin
|
|||||||
result := ImgReader.Image64Bit;
|
result := ImgReader.Image64Bit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TDbgImageLoader.GetUUID: TGuid;
|
||||||
|
begin
|
||||||
|
if assigned(FImgReader) then
|
||||||
|
result := FImgReader.UUID
|
||||||
|
else
|
||||||
|
result := GUID_NULL;
|
||||||
|
end;
|
||||||
|
|
||||||
function TDbgImageLoader.GetSection(const AName: String): PDbgImageSection;
|
function TDbgImageLoader.GetSection(const AName: String): PDbgImageSection;
|
||||||
begin
|
begin
|
||||||
if FImgReader <> nil then
|
if FImgReader <> nil then
|
||||||
|
@ -58,8 +58,10 @@ type
|
|||||||
private
|
private
|
||||||
FImage64Bit: Boolean;
|
FImage64Bit: Boolean;
|
||||||
FImageBase: QWord;
|
FImageBase: QWord;
|
||||||
|
FUUID: TGuid;
|
||||||
protected
|
protected
|
||||||
function GetSection(const AName: String): PDbgImageSection; virtual; abstract;
|
function GetSection(const AName: String): PDbgImageSection; virtual; abstract;
|
||||||
|
procedure SetUUID(AGuid: TGuid);
|
||||||
procedure SetImageBase(ABase: QWord);
|
procedure SetImageBase(ABase: QWord);
|
||||||
procedure SetImage64Bit(AValue: Boolean);
|
procedure SetImage64Bit(AValue: Boolean);
|
||||||
public
|
public
|
||||||
@ -70,6 +72,7 @@ type
|
|||||||
|
|
||||||
property ImageBase: QWord read FImageBase;
|
property ImageBase: QWord read FImageBase;
|
||||||
Property Image64Bit: Boolean read FImage64Bit;
|
Property Image64Bit: Boolean read FImage64Bit;
|
||||||
|
property UUID: TGuid read FUUID;
|
||||||
property Section[const AName: String]: PDbgImageSection read GetSection;
|
property Section[const AName: String]: PDbgImageSection read GetSection;
|
||||||
end;
|
end;
|
||||||
TDbgImageReaderClass = class of TDbgImageReader;
|
TDbgImageReaderClass = class of TDbgImageReader;
|
||||||
@ -226,6 +229,11 @@ end;
|
|||||||
|
|
||||||
{ TDbgImageReader }
|
{ TDbgImageReader }
|
||||||
|
|
||||||
|
procedure TDbgImageReader.SetUUID(AGuid: TGuid);
|
||||||
|
begin
|
||||||
|
FUUID := AGuid;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TDbgImageReader.SetImageBase(ABase: QWord);
|
procedure TDbgImageReader.SetImageBase(ABase: QWord);
|
||||||
begin
|
begin
|
||||||
FImageBase := ABase;
|
FImageBase := ABase;
|
||||||
|
@ -134,6 +134,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
SetImage64Bit((fFile.header.cputype and CPU_ARCH_ABI64)=CPU_ARCH_ABI64);
|
SetImage64Bit((fFile.header.cputype and CPU_ARCH_ABI64)=CPU_ARCH_ABI64);
|
||||||
|
SetUUID(fFile.UUID);
|
||||||
fileRead := true;
|
fileRead := true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ type
|
|||||||
header : mach_header;
|
header : mach_header;
|
||||||
commands : array of pload_command;
|
commands : array of pload_command;
|
||||||
sections : TFPList;
|
sections : TFPList;
|
||||||
|
UUID : TGuid;
|
||||||
constructor Create;
|
constructor Create;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
function LoadFromFile(ALoader: TDbgFileLoader): Boolean;
|
function LoadFromFile(ALoader: TDbgFileLoader): Boolean;
|
||||||
@ -57,6 +58,7 @@ var
|
|||||||
ofs : Integer;
|
ofs : Integer;
|
||||||
sc32: psection;
|
sc32: psection;
|
||||||
sc64: psection_64;
|
sc64: psection_64;
|
||||||
|
idcm: puuid_command;
|
||||||
s : TMachOsection;
|
s : TMachOsection;
|
||||||
hs : integer;
|
hs : integer;
|
||||||
i64 : boolean;
|
i64 : boolean;
|
||||||
@ -97,7 +99,10 @@ begin
|
|||||||
sections.add(s);
|
sections.add(s);
|
||||||
inc(sc64);
|
inc(sc64);
|
||||||
end;
|
end;
|
||||||
|
end
|
||||||
|
else if commands[i]^.cmd = LC_UUID then begin
|
||||||
|
idcm := @cmdbuf[ofs];
|
||||||
|
UUID:=PGuid(@(idcm^.uuid))^;
|
||||||
end;
|
end;
|
||||||
inc(ofs, commands[i]^.cmdsize);
|
inc(ofs, commands[i]^.cmdsize);
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user