From fa16dcdf525fc4f400f50f6aea998399c4b0466c Mon Sep 17 00:00:00 2001 From: joost Date: Sun, 23 Mar 2014 15:05:31 +0000 Subject: [PATCH] FpDbg: Use dSYM bundle on Darwin to read Dwarf debug-info for executable git-svn-id: trunk@44495 - --- components/fpdebug/fpdbgdarwinclasses.pas | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/components/fpdebug/fpdbgdarwinclasses.pas b/components/fpdebug/fpdbgdarwinclasses.pas index c7f0807474..3ac79b2f91 100644 --- a/components/fpdebug/fpdbgdarwinclasses.pas +++ b/components/fpdebug/fpdbgdarwinclasses.pas @@ -189,8 +189,24 @@ begin end; function TDbgDarwinProcess.InitializeLoader: TDbgImageLoader; +var + FObjFileName: string; + dSYMFilename: string; begin - result := TDbgImageLoader.Create(Name); + // 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 FileExists(dSYMFilename) then + result := TDbgImageLoader.Create(dSYMFilename) + else + begin + log('No dSYM bundle ('+dSYMFilename+') found.'); + result := TDbgImageLoader.Create(Name); + end; end; constructor TDbgDarwinProcess.Create(const AName: string; const AProcessID, AThreadID: Integer);