mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 17:59:22 +02:00
debugger: add pid enumeration code for Mac
git-svn-id: trunk@43290 -
This commit is contained in:
parent
74bd6a45c6
commit
484e98ecf4
@ -1,6 +1,9 @@
|
|||||||
unit DebugAttachDialog;
|
unit DebugAttachDialog;
|
||||||
|
|
||||||
{$mode objfpc}{$H+}
|
{$mode objfpc}{$H+}
|
||||||
|
{$ifdef darwin}
|
||||||
|
{$modeswitch ObjectiveC1}
|
||||||
|
{$endif}
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
@ -137,12 +140,70 @@ begin
|
|||||||
FindCloseUTF8(Rec);
|
FindCloseUTF8(Rec);
|
||||||
end;
|
end;
|
||||||
{$else}
|
{$else}
|
||||||
|
{$ifdef darwin}
|
||||||
|
uses
|
||||||
|
MacOSAll, CocoaAll;
|
||||||
|
|
||||||
|
function CFStringToStr(AString: CFStringRef; Encoding: CFStringEncoding = kCFStringEncodingUTF8): String;
|
||||||
|
var
|
||||||
|
Str: Pointer;
|
||||||
|
StrSize: CFIndex;
|
||||||
|
StrRange: CFRange;
|
||||||
|
begin
|
||||||
|
if AString = nil then
|
||||||
|
begin
|
||||||
|
Result := '';
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
// Try the quick way first
|
||||||
|
Str := CFStringGetCStringPtr(AString, Encoding);
|
||||||
|
if Str <> nil then
|
||||||
|
Result := PChar(Str)
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
// if that doesn't work this will
|
||||||
|
StrRange.location := 0;
|
||||||
|
StrRange.length := CFStringGetLength(AString);
|
||||||
|
|
||||||
|
CFStringGetBytes(AString, StrRange, Encoding,
|
||||||
|
Ord('?'), False, nil, 0, StrSize);
|
||||||
|
SetLength(Result, StrSize);
|
||||||
|
|
||||||
|
if StrSize > 0 then
|
||||||
|
CFStringGetBytes(AString, StrRange, Encoding,
|
||||||
|
Ord('?'), False, @Result[1], StrSize, StrSize);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function EnumerateProcesses(AList: TRunningProcessInfoList): boolean;
|
||||||
|
var
|
||||||
|
Arr: NSArray;
|
||||||
|
App: NSRunningApplication;
|
||||||
|
I: Integer;
|
||||||
|
item: TRunningProcessInfo;
|
||||||
|
begin
|
||||||
|
Result := True; // we can enumerate processes
|
||||||
|
|
||||||
|
if not Assigned(AList) then
|
||||||
|
Exit;
|
||||||
|
|
||||||
|
Arr := NSWorkspace.sharedWorkspace.runningApplications;
|
||||||
|
for I := 0 to Arr.count - 1 do
|
||||||
|
begin
|
||||||
|
App := NSRunningApplication(Arr.objectAtIndex(I));
|
||||||
|
item := TRunningProcessInfo.Create(App.processIdentifier, CFStringToStr(CFStringRef(App.localizedName)));
|
||||||
|
AList.Add(item);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
{$else}
|
||||||
function EnumerateProcesses(AList: TRunningProcessInfoList): boolean;
|
function EnumerateProcesses(AList: TRunningProcessInfoList): boolean;
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
end;
|
end;
|
||||||
{$endif}
|
{$endif}
|
||||||
{$endif}
|
{$endif}
|
||||||
|
{$endif}
|
||||||
|
|
||||||
{ TRunningProcessInfo }
|
{ TRunningProcessInfo }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user