mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-10 06:08:17 +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;
|
||||
FName: String;
|
||||
FProcess: TDbgProcess;
|
||||
FDbgInfo: TDbgInfo;
|
||||
FSymbolTableInfo: TFpSymbolInfo;
|
||||
FLoader: TDbgImageLoader;
|
||||
|
||||
protected
|
||||
FDbgInfo: TDbgInfo;
|
||||
function InitializeLoader: TDbgImageLoader; virtual;
|
||||
procedure SetName(const AValue: String);
|
||||
property Loader: TDbgImageLoader read FLoader write FLoader;
|
||||
public
|
||||
constructor Create(const AProcess: TDbgProcess); virtual;
|
||||
destructor Destroy; override;
|
||||
@ -975,9 +976,7 @@ begin
|
||||
inherited LoadInfo;
|
||||
|
||||
if DbgInfo.HasInfo then
|
||||
FSymInstances.Add(Self)
|
||||
else
|
||||
Log('No Dwarf-debug information available. The debugger will not function properly.',dllInfo);
|
||||
FSymInstances.Add(Self);
|
||||
end;
|
||||
|
||||
function TDbgProcess.GetLastEventProcessIdentifier: THandle;
|
||||
|
@ -692,6 +692,9 @@ begin
|
||||
deCreateProcess:
|
||||
begin
|
||||
FCurrentProcess.LoadInfo;
|
||||
if not FCurrentProcess.DbgInfo.HasInfo then
|
||||
Log('No Dwarf-debug information available. The debugger will not function properly.',dllInfo);
|
||||
|
||||
DoOnDebugInfoLoaded(self);
|
||||
|
||||
continue:=true;
|
||||
|
@ -15,6 +15,7 @@ uses
|
||||
FpDbgLoader,
|
||||
DbgIntfBaseTypes,
|
||||
FpDbgLinuxExtra,
|
||||
FpDbgDwarfDataClasses,
|
||||
FpDbgInfo,
|
||||
MacOSAll,
|
||||
FpDbgUtil,
|
||||
@ -139,6 +140,7 @@ type
|
||||
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;
|
||||
destructor Destroy; override;
|
||||
procedure LoadInfo; 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;
|
||||
@ -617,27 +619,8 @@ begin
|
||||
end;
|
||||
|
||||
function TDbgDarwinProcess.InitializeLoader: TDbgImageLoader;
|
||||
var
|
||||
dSYMFilename: string;
|
||||
begin
|
||||
// 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
|
||||
result := TDbgImageLoader.Create(dSYMFilename)
|
||||
else
|
||||
begin
|
||||
log('No dSYM bundle ('+dSYMFilename+') found.', dllInfo);
|
||||
result := TDbgImageLoader.Create(Name);
|
||||
end;
|
||||
result := TDbgImageLoader.Create(Name);
|
||||
end;
|
||||
|
||||
function TDbgDarwinProcess.CreateThread(AthreadIdentifier: THandle; out IsMainThread: boolean): TDbgThread;
|
||||
@ -672,6 +655,45 @@ begin
|
||||
inherited Destroy;
|
||||
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;
|
||||
var
|
||||
PID: TPid;
|
||||
|
@ -57,6 +57,7 @@ type
|
||||
FFileLoader: TDbgFileLoader;
|
||||
FImgReader: TDbgImageReader;
|
||||
function GetImage64Bit: Boolean;
|
||||
function GetUUID: TGuid;
|
||||
protected
|
||||
FImageBase: QWord unimplemented;
|
||||
function GetSection(const AName: String): PDbgImageSection; virtual;
|
||||
@ -73,6 +74,7 @@ type
|
||||
function IsValid: Boolean;
|
||||
property ImageBase: QWord read FImageBase; unimplemented;
|
||||
Property Image64Bit: Boolean read GetImage64Bit;
|
||||
property UUID: TGuid read GetUUID;
|
||||
property Section[const AName: String]: PDbgImageSection read GetSection;
|
||||
end;
|
||||
|
||||
@ -94,6 +96,14 @@ begin
|
||||
result := ImgReader.Image64Bit;
|
||||
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;
|
||||
begin
|
||||
if FImgReader <> nil then
|
||||
|
@ -58,8 +58,10 @@ type
|
||||
private
|
||||
FImage64Bit: Boolean;
|
||||
FImageBase: QWord;
|
||||
FUUID: TGuid;
|
||||
protected
|
||||
function GetSection(const AName: String): PDbgImageSection; virtual; abstract;
|
||||
procedure SetUUID(AGuid: TGuid);
|
||||
procedure SetImageBase(ABase: QWord);
|
||||
procedure SetImage64Bit(AValue: Boolean);
|
||||
public
|
||||
@ -70,6 +72,7 @@ type
|
||||
|
||||
property ImageBase: QWord read FImageBase;
|
||||
Property Image64Bit: Boolean read FImage64Bit;
|
||||
property UUID: TGuid read FUUID;
|
||||
property Section[const AName: String]: PDbgImageSection read GetSection;
|
||||
end;
|
||||
TDbgImageReaderClass = class of TDbgImageReader;
|
||||
@ -226,6 +229,11 @@ end;
|
||||
|
||||
{ TDbgImageReader }
|
||||
|
||||
procedure TDbgImageReader.SetUUID(AGuid: TGuid);
|
||||
begin
|
||||
FUUID := AGuid;
|
||||
end;
|
||||
|
||||
procedure TDbgImageReader.SetImageBase(ABase: QWord);
|
||||
begin
|
||||
FImageBase := ABase;
|
||||
|
@ -134,6 +134,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
SetImage64Bit((fFile.header.cputype and CPU_ARCH_ABI64)=CPU_ARCH_ABI64);
|
||||
SetUUID(fFile.UUID);
|
||||
fileRead := true;
|
||||
end;
|
||||
|
||||
|
@ -25,6 +25,7 @@ type
|
||||
header : mach_header;
|
||||
commands : array of pload_command;
|
||||
sections : TFPList;
|
||||
UUID : TGuid;
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
function LoadFromFile(ALoader: TDbgFileLoader): Boolean;
|
||||
@ -57,6 +58,7 @@ var
|
||||
ofs : Integer;
|
||||
sc32: psection;
|
||||
sc64: psection_64;
|
||||
idcm: puuid_command;
|
||||
s : TMachOsection;
|
||||
hs : integer;
|
||||
i64 : boolean;
|
||||
@ -97,7 +99,10 @@ begin
|
||||
sections.add(s);
|
||||
inc(sc64);
|
||||
end;
|
||||
|
||||
end
|
||||
else if commands[i]^.cmd = LC_UUID then begin
|
||||
idcm := @cmdbuf[ofs];
|
||||
UUID:=PGuid(@(idcm^.uuid))^;
|
||||
end;
|
||||
inc(ofs, commands[i]^.cmdsize);
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user