Skip to content

Commit

Permalink
OS X FullDebugMode support added by Sebastian Zierer (Thanks!)
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://svn.code.sf.net/p/fastmm/code@67 44d7434a-5e0e-4369-a90d-a9762bd98437
  • Loading branch information
pierre_le_riche committed Mar 25, 2014
1 parent 13f860e commit 4b0cdb4
Show file tree
Hide file tree
Showing 10 changed files with 974 additions and 177 deletions.
24 changes: 17 additions & 7 deletions FastMM4.pas
Expand Up @@ -835,6 +835,8 @@
do linger longer than they should.
- OS X support added by Sebastian Zierer
- Compatible with Delphi XE3
Version 4.??? (? ??? 2014)
- OS X full debug mode added by Sebastian Zierer
*)

Expand Down Expand Up @@ -941,9 +943,11 @@ interface

{Some features not currently supported under Kylix / OS X}
{$ifdef POSIX}
{$undef FullDebugMode}
{$undef LogErrorsToFile}
{$undef LogMemoryLeakDetailToFile}
{$ifndef MACOS}
{$undef FullDebugMode}
{$undef LogErrorsToFile}
{$undef LogMemoryLeakDetailToFile}
{$endif}
{$undef ShareMM}
{$undef AttemptToUseSharedMM}
{$undef RequireIDEPresenceForLeakReporting}
Expand Down Expand Up @@ -1350,7 +1354,7 @@ function DetectStringData(APMemoryBlock: Pointer;
{Walks all allocated blocks, calling ACallBack for each. Passes the user block size and AUserData to the callback.
Important note: All block types will be locked during the callback, so the memory manager cannot be used inside it.}
procedure WalkAllocatedBlocks(ACallBack: TWalkAllocatedBlocksCallback; AUserData: Pointer);
{Writes a log file containing a summary of the memory mananger state and a summary of allocated blocks grouped by
{Writes a log file containing a summary of the memory manager state and a summary of allocated blocks grouped by
class. The file will be saved in UTF-8 encoding (in supported Delphi versions). Returns True on success. }
function LogMemoryManagerStateToFile(const AFileName: string; const AAdditionalDetails: string = ''): Boolean;

Expand Down Expand Up @@ -1473,7 +1477,7 @@ implementation
{$endif}
{$else}
{$ifdef MACOS}
Posix.Stdlib, Posix.Unistd, Posix.Fcntl,
Posix.Stdlib, Posix.Unistd, Posix.Fcntl, Posix.PThread, FastMM_OSXUtil,
{$ELSE}
Libc,
{$endif}
Expand Down Expand Up @@ -2241,7 +2245,7 @@ function GetModuleFileName(Module: HMODULE; Buffer: PAnsiChar; BufLen: Integer):
else
begin
Result := Length(CUnknown);
StrLCopy(Buffer, Pointer(CUnknown), Result + 1);
StrLCopy(Buffer, PAnsiChar(CUnknown), Result + 1);
end;
end;

Expand Down Expand Up @@ -2807,6 +2811,7 @@ procedure MessageBoxA(hWnd: Cardinal; AMessageText, AMessageTitle: PAnsiChar; uT
__write(STDERR_FILENO, AMessageText, StrLen(AMessageText));
end;

{$IFNDEF MACOS}
function VirtualAlloc(lpvAddress: Pointer; dwSize, flAllocationType, flProtect: Cardinal): Pointer; stdcall;
begin
Result := valloc(dwSize);
Expand All @@ -2817,6 +2822,7 @@ function VirtualFree(lpAddress: Pointer; dwSize, dwFreeType: Cardinal): LongBool
free(lpAddress);
Result := True;
end;
{$ENDIF}

function WriteFile(hFile: THandle; const Buffer; nNumberOfBytesToWrite: Cardinal;
var lpNumberOfBytesWritten: Cardinal; lpOverlapped: Pointer): Boolean; stdcall;
Expand Down Expand Up @@ -2846,7 +2852,7 @@ procedure Sleep(dwMilliseconds: Cardinal); stdcall;

{Returns the current thread ID}
function GetThreadID: Cardinal;
{$ifdef 32Bit}
{$ifdef WIN32}
asm
mov eax, FS:[$24]
end;
Expand Down Expand Up @@ -7972,12 +7978,16 @@ procedure AppendEventLog(ABuffer: Pointer; ACount: Cardinal);
{Did log file creation fail? If so, the destination folder is perhaps read-only:
Try to redirect logging to a file in the user's "My Documents" folder.}
if (LFileHandle = INVALID_HANDLE_VALUE)
{$IFNDEF MACOS}
{$ifdef Delphi4or5}
and SHGetSpecialFolderPathA(0, @LAlternateLogFileName, CSIDL_PERSONAL, True) then
{$else}
and (SHGetFolderPathA(0, CSIDL_PERSONAL or CSIDL_FLAG_CREATE, 0,
SHGFP_TYPE_CURRENT, @LAlternateLogFileName) = S_OK) then
{$endif}
{$ELSE}
then
{$ENDIF}
begin
{Extract the filename part from MMLogFileName and append it to the path of
the "My Documents" folder.}
Expand Down
4 changes: 4 additions & 0 deletions FastMM4Messages.pas
Expand Up @@ -14,7 +14,11 @@ interface

const
{The name of the debug info support DLL}
{$IFDEF MACOS}
FullDebugModeLibraryName32Bit = 'libFastMM_FullDebugMode.dylib';
{$ELSE}
FullDebugModeLibraryName32Bit = 'FastMM_FullDebugMode.dll';
{$ENDIF}
FullDebugModeLibraryName64Bit = 'FastMM_FullDebugMode64.dll';
{Event log strings}
LogFileExtension = '_MemoryManager_EventLog.txt'#0;
Expand Down

0 comments on commit 4b0cdb4

Please sign in to comment.