mirror of
https://github.com/intel/llvm.git
synced 2026-01-16 05:32:28 +08:00
<rdar://problem/3535148>
Added ability to debug root processes on OS X. This uses XPC service that is available on Lion and above only. llvm-svn: 151419
This commit is contained in:
@@ -117,6 +117,19 @@ public:
|
||||
|
||||
static const char *
|
||||
GetGroupName (uint32_t gid, std::string &group_name);
|
||||
|
||||
static uint32_t
|
||||
GetUserID ();
|
||||
|
||||
static uint32_t
|
||||
GetGroupID ();
|
||||
|
||||
static uint32_t
|
||||
GetEffectiveUserID ();
|
||||
|
||||
static uint32_t
|
||||
GetEffectiveGroupID ();
|
||||
|
||||
|
||||
enum SystemLogType
|
||||
{
|
||||
|
||||
@@ -1888,6 +1888,29 @@ public:
|
||||
return error;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
/// Attach to an existing process using a process ID.
|
||||
///
|
||||
/// @param[in] pid
|
||||
/// The process ID that we should attempt to attach to.
|
||||
///
|
||||
/// @param[in] attach_info
|
||||
/// Information on how to do the attach. For example, GetUserID()
|
||||
/// will return the uid to attach as.
|
||||
///
|
||||
/// @return
|
||||
/// Returns \a pid if attaching was successful, or
|
||||
/// LLDB_INVALID_PROCESS_ID if attaching fails.
|
||||
/// hanming : need flag
|
||||
//------------------------------------------------------------------
|
||||
virtual Error
|
||||
DoAttachToProcessWithID (lldb::pid_t pid, const ProcessAttachInfo &attach_info)
|
||||
{
|
||||
Error error;
|
||||
error.SetErrorStringWithFormat("error: %s does not support attaching to a process by pid", GetShortPluginName());
|
||||
return error;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
/// Attach to an existing process using a partial process name.
|
||||
///
|
||||
@@ -1899,12 +1922,16 @@ public:
|
||||
/// as soon as possible after it does launch. If \b false, then
|
||||
/// search for a matching process the currently exists.
|
||||
///
|
||||
/// @param[in] attach_info
|
||||
/// Information on how to do the attach. For example, GetUserID()
|
||||
/// will return the uid to attach as.
|
||||
///
|
||||
/// @return
|
||||
/// Returns \a pid if attaching was successful, or
|
||||
/// LLDB_INVALID_PROCESS_ID if attaching fails.
|
||||
//------------------------------------------------------------------
|
||||
virtual Error
|
||||
DoAttachToProcessWithName (const char *process_name, bool wait_for_launch)
|
||||
DoAttachToProcessWithName (const char *process_name, bool wait_for_launch, const ProcessAttachInfo &attach_info)
|
||||
{
|
||||
Error error;
|
||||
error.SetErrorString("attach by name is not supported");
|
||||
|
||||
@@ -458,6 +458,11 @@
|
||||
B299580B14F2FA1400050A04 /* DisassemblerLLVMC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B299580A14F2FA1400050A04 /* DisassemblerLLVMC.cpp */; };
|
||||
B2A58722143119810092BFBA /* SBWatchpoint.h in Headers */ = {isa = PBXBuildFile; fileRef = B2A58721143119810092BFBA /* SBWatchpoint.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
B2A58724143119D50092BFBA /* SBWatchpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2A58723143119D50092BFBA /* SBWatchpoint.cpp */; };
|
||||
ED236E0814F84F6800153F6F /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EDB919B414F6F10D008FF64B /* Security.framework */; };
|
||||
EDB919B314F6EC85008FF64B /* LauncherXPCService.h in Headers */ = {isa = PBXBuildFile; fileRef = EDB919B214F6EC85008FF64B /* LauncherXPCService.h */; };
|
||||
EDB919B714F6F22D008FF64B /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EDB919B414F6F10D008FF64B /* Security.framework */; };
|
||||
EDC6D4AA14E5C49E001B75F8 /* LauncherXPCService.mm in Sources */ = {isa = PBXBuildFile; fileRef = EDC6D49414E5C15C001B75F8 /* LauncherXPCService.mm */; };
|
||||
EDE274E414EDCE1F005B0F75 /* LauncherXPCService.mm in Sources */ = {isa = PBXBuildFile; fileRef = EDC6D49414E5C15C001B75F8 /* LauncherXPCService.mm */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
@@ -524,6 +529,20 @@
|
||||
remoteGlobalIDString = 26DC6A0F1337FE6900FF7998;
|
||||
remoteInfo = "lldb-platform";
|
||||
};
|
||||
ED00234514F6B471008CF6DD /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = EDE274E214EDCE1F005B0F75;
|
||||
remoteInfo = launcherRootXPCService;
|
||||
};
|
||||
EDC09A4C14E5CAA40062243E /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = EDC6D49814E5C19B001B75F8;
|
||||
remoteInfo = launcherXPCService;
|
||||
};
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
@@ -1407,6 +1426,14 @@
|
||||
B2A58723143119D50092BFBA /* SBWatchpoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBWatchpoint.cpp; path = source/API/SBWatchpoint.cpp; sourceTree = "<group>"; };
|
||||
B2A5872514313B480092BFBA /* SBWatchpoint.i */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; path = SBWatchpoint.i; sourceTree = "<group>"; };
|
||||
B2D3033612EFA5C500F84EB3 /* InstructionUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = InstructionUtils.h; path = Utility/InstructionUtils.h; sourceTree = "<group>"; };
|
||||
EDB919B214F6EC85008FF64B /* LauncherXPCService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LauncherXPCService.h; sourceTree = "<group>"; };
|
||||
EDB919B414F6F10D008FF64B /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = /System/Library/Frameworks/Security.framework; sourceTree = "<absolute>"; };
|
||||
EDC6D49214E5C15C001B75F8 /* LauncherXPCService-Info.plist */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; path = "LauncherXPCService-Info.plist"; sourceTree = "<group>"; };
|
||||
EDC6D49314E5C15C001B75F8 /* LauncherXPCService.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = LauncherXPCService.entitlements; sourceTree = "<group>"; };
|
||||
EDC6D49414E5C15C001B75F8 /* LauncherXPCService.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = LauncherXPCService.mm; sourceTree = "<group>"; };
|
||||
EDC6D49914E5C19B001B75F8 /* com.apple.lldb.launcherXPCService.xpc */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = com.apple.lldb.launcherXPCService.xpc; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
EDE274E114EDCE0D005B0F75 /* LauncherRootXPCService-Info.plist */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; path = "LauncherRootXPCService-Info.plist"; sourceTree = "<group>"; };
|
||||
EDE274EC14EDCE1F005B0F75 /* com.apple.lldb.launcherRootXPCService.xpc */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = com.apple.lldb.launcherRootXPCService.xpc; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -1424,6 +1451,7 @@
|
||||
268901161335BBC300698AC0 /* liblldb-core.a in Frameworks */,
|
||||
2668022F115FD19D008E1FE4 /* CoreFoundation.framework in Frameworks */,
|
||||
26680233115FD1A7008E1FE4 /* libobjc.dylib in Frameworks */,
|
||||
ED236E0814F84F6800153F6F /* Security.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -1441,6 +1469,7 @@
|
||||
26DC6A171337FE8000FF7998 /* liblldb-core.a in Frameworks */,
|
||||
26B1FCB813381071002886E2 /* CoreFoundation.framework in Frameworks */,
|
||||
26B1FCBC13381071002886E2 /* libobjc.dylib in Frameworks */,
|
||||
EDB919B714F6F22D008FF64B /* Security.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -1454,6 +1483,20 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
EDC6D49614E5C19B001B75F8 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
EDE274E514EDCE1F005B0F75 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
@@ -1503,6 +1546,8 @@
|
||||
26680207115FD0ED008E1FE4 /* LLDB.framework */,
|
||||
26579F68126A25920007C5CB /* darwin-debug */,
|
||||
26DC6A101337FE6900FF7998 /* lldb-platform */,
|
||||
EDC6D49914E5C19B001B75F8 /* com.apple.lldb.launcherXPCService.xpc */,
|
||||
EDE274EC14EDCE1F005B0F75 /* com.apple.lldb.launcherRootXPCService.xpc */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
@@ -2659,6 +2704,7 @@
|
||||
26BC7EF910F1B8AD00F91463 /* CFCString.h */,
|
||||
26BC7EE810F1B88F00F91463 /* Host.mm */,
|
||||
2689B0B5113EE47E00A4AEDB /* Symbols.cpp */,
|
||||
EDC6D49114E5C15C001B75F8 /* launcherXPCService */,
|
||||
);
|
||||
name = MacOSX;
|
||||
sourceTree = "<group>";
|
||||
@@ -2793,6 +2839,7 @@
|
||||
26F5C32410F3DF23009D5894 /* libpython.dylib */,
|
||||
26F5C32B10F3DFDD009D5894 /* libtermcap.dylib */,
|
||||
4C74CB6212288704006A8171 /* Carbon.framework */,
|
||||
EDB919B414F6F10D008FF64B /* Security.framework */,
|
||||
);
|
||||
name = Libraries;
|
||||
sourceTree = "<group>";
|
||||
@@ -2889,6 +2936,19 @@
|
||||
path = source/Host/common;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
EDC6D49114E5C15C001B75F8 /* launcherXPCService */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
EDC6D49214E5C15C001B75F8 /* LauncherXPCService-Info.plist */,
|
||||
EDE274E114EDCE0D005B0F75 /* LauncherRootXPCService-Info.plist */,
|
||||
EDC6D49314E5C15C001B75F8 /* LauncherXPCService.entitlements */,
|
||||
EDB919B214F6EC85008FF64B /* LauncherXPCService.h */,
|
||||
EDC6D49414E5C15C001B75F8 /* LauncherXPCService.mm */,
|
||||
);
|
||||
name = launcherXPCService;
|
||||
path = source/Host/macosx/launcherXPCService;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXHeadersBuildPhase section */
|
||||
@@ -2949,6 +3009,7 @@
|
||||
4CAA56131422D96A001FFA01 /* BreakpointResolverFileRegex.h in Headers */,
|
||||
26B8283D142D01E9002DBC64 /* SBSection.h in Headers */,
|
||||
B2A58722143119810092BFBA /* SBWatchpoint.h in Headers */,
|
||||
EDB919B314F6EC85008FF64B /* LauncherXPCService.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -3001,6 +3062,8 @@
|
||||
2689011513353E9B00698AC0 /* PBXTargetDependency */,
|
||||
262CFC7211A450CB00946C6C /* PBXTargetDependency */,
|
||||
26368AF6126B95FA00E8659F /* PBXTargetDependency */,
|
||||
EDC09A4D14E5CAA40062243E /* PBXTargetDependency */,
|
||||
ED00234614F6B471008CF6DD /* PBXTargetDependency */,
|
||||
);
|
||||
name = LLDB;
|
||||
productName = LLDB;
|
||||
@@ -3063,6 +3126,40 @@
|
||||
productReference = 26F5C26A10F3D9A4009D5894 /* lldb */;
|
||||
productType = "com.apple.product-type.tool";
|
||||
};
|
||||
EDC6D49814E5C19B001B75F8 /* launcherXPCService */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = EDC6D4A614E5C19B001B75F8 /* Build configuration list for PBXNativeTarget "launcherXPCService" */;
|
||||
buildPhases = (
|
||||
EDC6D49514E5C19B001B75F8 /* Sources */,
|
||||
EDC6D49614E5C19B001B75F8 /* Frameworks */,
|
||||
EDC6D49714E5C19B001B75F8 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = launcherXPCService;
|
||||
productName = launcherXPCService;
|
||||
productReference = EDC6D49914E5C19B001B75F8 /* com.apple.lldb.launcherXPCService.xpc */;
|
||||
productType = "com.apple.product-type.bundle";
|
||||
};
|
||||
EDE274E214EDCE1F005B0F75 /* launcherRootXPCService */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = EDE274E814EDCE1F005B0F75 /* Build configuration list for PBXNativeTarget "launcherRootXPCService" */;
|
||||
buildPhases = (
|
||||
EDE274E314EDCE1F005B0F75 /* Sources */,
|
||||
EDE274E514EDCE1F005B0F75 /* Frameworks */,
|
||||
EDE274E714EDCE1F005B0F75 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = launcherRootXPCService;
|
||||
productName = launcherXPCService;
|
||||
productReference = EDE274EC14EDCE1F005B0F75 /* com.apple.lldb.launcherRootXPCService.xpc */;
|
||||
productType = "com.apple.product-type.bundle";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
@@ -3093,6 +3190,8 @@
|
||||
26579F67126A25920007C5CB /* darwin-debug */,
|
||||
2689FFC913353D7A00698AC0 /* lldb-core */,
|
||||
26DC6A0F1337FE6900FF7998 /* lldb-platform */,
|
||||
EDC6D49814E5C19B001B75F8 /* launcherXPCService */,
|
||||
EDE274E214EDCE1F005B0F75 /* launcherRootXPCService */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
@@ -3118,6 +3217,20 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
EDC6D49714E5C19B001B75F8 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
EDE274E714EDCE1F005B0F75 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
@@ -3649,6 +3762,22 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
EDC6D49514E5C19B001B75F8 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
EDC6D4AA14E5C49E001B75F8 /* LauncherXPCService.mm in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
EDE274E314EDCE1F005B0F75 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
EDE274E414EDCE1F005B0F75 /* LauncherXPCService.mm in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXTargetDependency section */
|
||||
@@ -3692,6 +3821,16 @@
|
||||
target = 26DC6A0F1337FE6900FF7998 /* lldb-platform */;
|
||||
targetProxy = 26DC6A201338008100FF7998 /* PBXContainerItemProxy */;
|
||||
};
|
||||
ED00234614F6B471008CF6DD /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = EDE274E214EDCE1F005B0F75 /* launcherRootXPCService */;
|
||||
targetProxy = ED00234514F6B471008CF6DD /* PBXContainerItemProxy */;
|
||||
};
|
||||
EDC09A4D14E5CAA40062243E /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = EDC6D49814E5C19B001B75F8 /* launcherXPCService */;
|
||||
targetProxy = EDC09A4C14E5CAA40062243E /* PBXContainerItemProxy */;
|
||||
};
|
||||
/* End PBXTargetDependency section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
@@ -4429,6 +4568,177 @@
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
EDC6D4A714E5C19B001B75F8 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CODE_SIGN_IDENTITY = "-";
|
||||
DEPLOYMENT_LOCATION = YES;
|
||||
DSTROOT = "$(SYMROOT)";
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
INFOPLIST_FILE = "source/Host/macosx/launcherXPCService/launcherXPCService-Info.plist";
|
||||
INFOPLIST_PREPROCESS = YES;
|
||||
INFOPLIST_PREPROCESSOR_DEFINITIONS = (
|
||||
"NO0=0",
|
||||
"YES0=1",
|
||||
"RC_XBS=${RC_XBS}0",
|
||||
"RC_BUILDIT=${RC_BUILDIT}0",
|
||||
);
|
||||
INSTALL_PATH = "/$(CONFIGURATION)/LLDB.framework/XPCServices";
|
||||
IS_APPLE_CODE_SIGNED = "(anchor apple or (anchor apple generic and certificate leaf[field.1.2.840.113635.100.6.1.9]))";
|
||||
MACH_O_TYPE = mh_execute;
|
||||
PRODUCT_NAME = "com.apple.lldb.$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE = "";
|
||||
WRAPPER_EXTENSION = xpc;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
EDC6D4A814E5C19B001B75F8 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CODE_SIGN_IDENTITY = "-";
|
||||
COPY_PHASE_STRIP = YES;
|
||||
DEPLOYMENT_LOCATION = YES;
|
||||
DSTROOT = "$(SYMROOT)";
|
||||
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
INFOPLIST_FILE = "source/Host/macosx/launcherXPCService/launcherXPCService-Info.plist";
|
||||
INFOPLIST_PREPROCESS = YES;
|
||||
INFOPLIST_PREPROCESSOR_DEFINITIONS = (
|
||||
"NO0=0",
|
||||
"YES0=1",
|
||||
"RC_XBS=${RC_XBS}0",
|
||||
"RC_BUILDIT=${RC_BUILDIT}0",
|
||||
);
|
||||
INSTALL_PATH = "/$(CONFIGURATION)/LLDB.framework/XPCServices";
|
||||
IS_APPLE_CODE_SIGNED = "(anchor apple or (anchor apple generic and certificate leaf[field.1.2.840.113635.100.6.1.9]))";
|
||||
MACH_O_TYPE = mh_execute;
|
||||
PRODUCT_NAME = "com.apple.lldb.$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE = "";
|
||||
WRAPPER_EXTENSION = xpc;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
EDC6D4A914E5C19B001B75F8 /* BuildAndIntegration */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CODE_SIGN_IDENTITY = "-";
|
||||
COPY_PHASE_STRIP = YES;
|
||||
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
INFOPLIST_FILE = "source/Host/macosx/launcherXPCService/launcherXPCService-Info.plist";
|
||||
INFOPLIST_PREPROCESS = YES;
|
||||
INFOPLIST_PREPROCESSOR_DEFINITIONS = (
|
||||
"NO0=0",
|
||||
"YES0=1",
|
||||
"RC_XBS=${RC_XBS}0",
|
||||
"RC_BUILDIT=${RC_BUILDIT}0",
|
||||
);
|
||||
INSTALL_PATH = "$(DSTROOT)/LLDB.framework/XPCServices";
|
||||
IS_APPLE_CODE_SIGNED = "(anchor apple or (anchor apple generic and certificate leaf[field.1.2.840.113635.100.6.1.9]))";
|
||||
MACH_O_TYPE = mh_execute;
|
||||
PRODUCT_NAME = "com.apple.lldb.$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE = "";
|
||||
WRAPPER_EXTENSION = xpc;
|
||||
};
|
||||
name = BuildAndIntegration;
|
||||
};
|
||||
EDE274E914EDCE1F005B0F75 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CODE_SIGN_ENTITLEMENTS = source/Host/macosx/launcherXPCService/LauncherXPCService.entitlements;
|
||||
CODE_SIGN_IDENTITY = "-";
|
||||
DEPLOYMENT_LOCATION = YES;
|
||||
DSTROOT = "$(SYMROOT)";
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
INFOPLIST_FILE = "source/Host/macosx/launcherXPCService/launcherRootXPCService-Info.plist";
|
||||
INFOPLIST_PREPROCESS = YES;
|
||||
INFOPLIST_PREPROCESSOR_DEFINITIONS = (
|
||||
"NO0=0",
|
||||
"YES0=1",
|
||||
"RC_XBS=${RC_XBS}0",
|
||||
"RC_BUILDIT=${RC_BUILDIT}0",
|
||||
);
|
||||
INSTALL_PATH = "/$(CONFIGURATION)/LLDB.framework/XPCServices";
|
||||
IS_APPLE_CODE_SIGNED = "(anchor apple or (anchor apple generic and certificate leaf[field.1.2.840.113635.100.6.1.9]))";
|
||||
MACH_O_TYPE = mh_execute;
|
||||
PRODUCT_NAME = "com.apple.lldb.$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE = "";
|
||||
WRAPPER_EXTENSION = xpc;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
EDE274EA14EDCE1F005B0F75 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CODE_SIGN_ENTITLEMENTS = source/Host/macosx/launcherXPCService/LauncherXPCService.entitlements;
|
||||
CODE_SIGN_IDENTITY = "-";
|
||||
COPY_PHASE_STRIP = YES;
|
||||
DEPLOYMENT_LOCATION = YES;
|
||||
DSTROOT = "$(SYMROOT)";
|
||||
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
INFOPLIST_FILE = "source/Host/macosx/launcherXPCService/launcherRootXPCService-Info.plist";
|
||||
INFOPLIST_PREPROCESS = YES;
|
||||
INFOPLIST_PREPROCESSOR_DEFINITIONS = (
|
||||
"NO0=0",
|
||||
"YES0=1",
|
||||
"RC_XBS=${RC_XBS}0",
|
||||
"RC_BUILDIT=${RC_BUILDIT}0",
|
||||
);
|
||||
INSTALL_PATH = "/$(CONFIGURATION)/LLDB.framework/XPCServices";
|
||||
IS_APPLE_CODE_SIGNED = "(anchor apple or (anchor apple generic and certificate leaf[field.1.2.840.113635.100.6.1.9]))";
|
||||
MACH_O_TYPE = mh_execute;
|
||||
PRODUCT_NAME = "com.apple.lldb.$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE = "";
|
||||
WRAPPER_EXTENSION = xpc;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
EDE274EB14EDCE1F005B0F75 /* BuildAndIntegration */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CODE_SIGN_ENTITLEMENTS = source/Host/macosx/launcherXPCService/LauncherXPCService.entitlements;
|
||||
CODE_SIGN_IDENTITY = "-";
|
||||
COPY_PHASE_STRIP = YES;
|
||||
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
INFOPLIST_FILE = "source/Host/macosx/launcherXPCService/launcherRootXPCService-Info.plist";
|
||||
INFOPLIST_PREPROCESS = YES;
|
||||
INFOPLIST_PREPROCESSOR_DEFINITIONS = (
|
||||
"NO0=0",
|
||||
"YES0=1",
|
||||
"RC_XBS=${RC_XBS}0",
|
||||
"RC_BUILDIT=${RC_BUILDIT}0",
|
||||
);
|
||||
INSTALL_PATH = "$(DSTROOT)/LLDB.framework/XPCServices";
|
||||
IS_APPLE_CODE_SIGNED = "(anchor apple or (anchor apple generic and certificate leaf[field.1.2.840.113635.100.6.1.9]))";
|
||||
MACH_O_TYPE = mh_execute;
|
||||
PRODUCT_NAME = "com.apple.lldb.$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE = "";
|
||||
WRAPPER_EXTENSION = xpc;
|
||||
};
|
||||
name = BuildAndIntegration;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
@@ -4492,6 +4802,26 @@
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = BuildAndIntegration;
|
||||
};
|
||||
EDC6D4A614E5C19B001B75F8 /* Build configuration list for PBXNativeTarget "launcherXPCService" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
EDC6D4A714E5C19B001B75F8 /* Debug */,
|
||||
EDC6D4A814E5C19B001B75F8 /* Release */,
|
||||
EDC6D4A914E5C19B001B75F8 /* BuildAndIntegration */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = BuildAndIntegration;
|
||||
};
|
||||
EDE274E814EDCE1F005B0F75 /* Build configuration list for PBXNativeTarget "launcherRootXPCService" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
EDE274E914EDCE1F005B0F75 /* Debug */,
|
||||
EDE274EA14EDCE1F005B0F75 /* Release */,
|
||||
EDE274EB14EDCE1F005B0F75 /* BuildAndIntegration */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = BuildAndIntegration;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 08FB7793FE84155DC02AAC07 /* Project object */;
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "EDE274E214EDCE1F005B0F75"
|
||||
BuildableName = "com.apple.lldb.launcherRootXPCService.xpc"
|
||||
BlueprintName = "launcherRootXPCService"
|
||||
ReferencedContainer = "container:lldb.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
buildConfiguration = "Debug">
|
||||
<Testables>
|
||||
</Testables>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Debug"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
allowLocationSimulation = "YES">
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Release"
|
||||
debugDocumentVersioning = "YES">
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "EDC6D49814E5C19B001B75F8"
|
||||
BuildableName = "com.apple.lldb.launcherXPCService.xpc"
|
||||
BlueprintName = "launcherXPCService"
|
||||
ReferencedContainer = "container:lldb.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
buildConfiguration = "Debug">
|
||||
<Testables>
|
||||
</Testables>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
|
||||
launchStyle = "1"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Debug"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
allowLocationSimulation = "YES">
|
||||
<PathRunnable
|
||||
FilePath = "/Users/moi/Library/Developer/Xcode/DerivedData/Xcode-ezhudafllefyhcfivqaeslnymjsj/Build/Products/Debug/LLDB.framework/XPCServices/com.apple.lldb.launcherXPCService.xpc/Contents/MacOS/com.apple.lldb.launcherXPCService">
|
||||
</PathRunnable>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Release"
|
||||
debugDocumentVersioning = "YES">
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -901,6 +901,14 @@ SBTarget::AttachToProcessWithID
|
||||
|
||||
ProcessAttachInfo attach_info;
|
||||
attach_info.SetProcessID (pid);
|
||||
|
||||
PlatformSP platform_sp = target_sp->GetPlatform();
|
||||
ProcessInstanceInfo instance_info;
|
||||
if (platform_sp->GetProcessInfo(pid, instance_info))
|
||||
{
|
||||
attach_info.SetUserID(instance_info.GetEffectiveUserID());
|
||||
|
||||
}
|
||||
error.SetError (process_sp->Attach (attach_info));
|
||||
// If we are doing synchronous mode, then wait for the
|
||||
// process to stop!
|
||||
|
||||
@@ -1173,7 +1173,31 @@ Host::GetOSKernelDescription (std::string &s)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(__APPLE__)
|
||||
uint32_t
|
||||
Host::GetUserID ()
|
||||
{
|
||||
return getuid();
|
||||
}
|
||||
|
||||
uint32_t
|
||||
Host::GetGroupID ()
|
||||
{
|
||||
return getgid();
|
||||
}
|
||||
|
||||
uint32_t
|
||||
Host::GetEffectiveUserID ()
|
||||
{
|
||||
return geteuid();
|
||||
}
|
||||
|
||||
uint32_t
|
||||
Host::GetEffectiveGroupID ()
|
||||
{
|
||||
return getegid();
|
||||
}
|
||||
|
||||
#if !defined (__APPLE__)
|
||||
uint32_t
|
||||
Host::FindProcesses (const ProcessInstanceInfoMatch &match_info, ProcessInstanceInfoList &process_infos)
|
||||
{
|
||||
|
||||
@@ -9,6 +9,17 @@
|
||||
|
||||
#include "lldb/Host/Host.h"
|
||||
|
||||
#include <AvailabilityMacros.h>
|
||||
|
||||
#if !defined(MAC_OS_X_VERSION_10_7) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
|
||||
#define BUILDING_ON_SNOW_LEOPARD 1
|
||||
#endif
|
||||
|
||||
#if !BUILDING_ON_SNOW_LEOPARD
|
||||
#include <xpc/xpc.h>
|
||||
#include "LauncherXPCService.h"
|
||||
#endif
|
||||
|
||||
#include <asl.h>
|
||||
#include <crt_externs.h>
|
||||
#include <execinfo.h>
|
||||
@@ -53,8 +64,8 @@
|
||||
#else
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
#include <Carbon/Carbon.h>
|
||||
#include <Security/Security.h>
|
||||
#endif
|
||||
#include <Foundation/Foundation.h>
|
||||
|
||||
#ifndef _POSIX_SPAWN_DISABLE_ASLR
|
||||
#define _POSIX_SPAWN_DISABLE_ASLR 0x0100
|
||||
@@ -1219,57 +1230,216 @@ Host::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info)
|
||||
return false;
|
||||
}
|
||||
|
||||
Error
|
||||
Host::LaunchProcess (ProcessLaunchInfo &launch_info)
|
||||
static short
|
||||
GetPosixspawnFlags (ProcessLaunchInfo &launch_info)
|
||||
{
|
||||
short flags = POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETSIGMASK;
|
||||
if (launch_info.GetFlags().Test (eLaunchFlagExec))
|
||||
flags |= POSIX_SPAWN_SETEXEC; // Darwin specific posix_spawn flag
|
||||
|
||||
if (launch_info.GetFlags().Test (eLaunchFlagDebug))
|
||||
flags |= POSIX_SPAWN_START_SUSPENDED; // Darwin specific posix_spawn flag
|
||||
|
||||
if (launch_info.GetFlags().Test (eLaunchFlagDisableASLR))
|
||||
flags |= _POSIX_SPAWN_DISABLE_ASLR; // Darwin specific posix_spawn flag
|
||||
|
||||
//#ifdef POSIX_SPAWN_CLOEXEC_DEFAULT
|
||||
// // Close all files exception those with file actions if this is supported.
|
||||
// flags |= POSIX_SPAWN_CLOEXEC_DEFAULT;
|
||||
//#endif
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
#if !BUILDING_ON_SNOW_LEOPARD
|
||||
static void
|
||||
PackageXPCArguments (xpc_object_t message, const char *prefix, const Args& args)
|
||||
{
|
||||
size_t count = args.GetArgumentCount();
|
||||
char buf[50]; // long enough for 'argXXX'
|
||||
memset(buf, 0, 50);
|
||||
sprintf(buf, "%sCount", prefix);
|
||||
xpc_dictionary_set_int64(message, buf, count);
|
||||
for (int i=0; i<count; i++) {
|
||||
memset(buf, 0, 50);
|
||||
sprintf(buf, "%s%i", prefix, i);
|
||||
xpc_dictionary_set_string(message, buf, args.GetArgumentAtIndex(i));
|
||||
}
|
||||
}
|
||||
|
||||
static Error
|
||||
getXPCAuthorization (ProcessLaunchInfo &launch_info)
|
||||
{
|
||||
Error error;
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_HOST | LIBLLDB_LOG_PROCESS));
|
||||
char exe_path[PATH_MAX];
|
||||
PlatformSP host_platform_sp (Platform::GetDefaultPlatform ());
|
||||
|
||||
const ArchSpec &arch_spec = launch_info.GetArchitecture();
|
||||
|
||||
FileSpec exe_spec(launch_info.GetExecutableFile());
|
||||
|
||||
FileSpec::FileType file_type = exe_spec.GetFileType();
|
||||
if (file_type != FileSpec::eFileTypeRegular)
|
||||
if (launch_info.GetUserID() == 0)
|
||||
{
|
||||
lldb::ModuleSP exe_module_sp;
|
||||
error = host_platform_sp->ResolveExecutable (exe_spec,
|
||||
arch_spec,
|
||||
exe_module_sp,
|
||||
NULL);
|
||||
|
||||
if (error.Fail())
|
||||
CFDictionaryRef dict = NULL;
|
||||
OSStatus osStatus;
|
||||
const char *rightName = "com.apple.lldb.LaunchUsingXPC";
|
||||
|
||||
osStatus = AuthorizationRightGet(rightName, &dict);
|
||||
if (dict) CFRelease(dict);
|
||||
if (osStatus == errAuthorizationSuccess)
|
||||
{
|
||||
// Got the right already.
|
||||
return error;
|
||||
|
||||
if (exe_module_sp)
|
||||
exe_spec = exe_module_sp->GetFileSpec();
|
||||
}
|
||||
|
||||
AuthorizationFlags authorizationFlags = kAuthorizationFlagDefaults;
|
||||
AuthorizationRef authorizationRef = NULL;
|
||||
osStatus = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, authorizationFlags, &authorizationRef);
|
||||
if (osStatus != errAuthorizationSuccess)
|
||||
{
|
||||
error.SetError(1, eErrorTypeGeneric);
|
||||
if (log)
|
||||
{
|
||||
error.PutToLog(log.get(), "Can't create authorizationRef.");
|
||||
}
|
||||
else {
|
||||
error.SetErrorString("Can't create authorizationRef.");
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
CFStringRef prompt = CFSTR("The debugger is debugging a root process. Please authenticate as an administrator.");
|
||||
// CFStringRef keys[] = { CFSTR("") };
|
||||
// CFTypeRef values[] = { prompt };
|
||||
// CFDictionaryRef promptDict = CFDictionaryCreate( kCFAllocatorDefault, (const void **)keys, (const void **)values, 1, &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
|
||||
|
||||
int timeout = 1; // Make this 10
|
||||
CFNumberRef timeoutRef = CFNumberCreate(NULL, kCFNumberIntType, &timeout);
|
||||
CFStringRef keys1[] = { CFSTR("class"), CFSTR("group"), CFSTR("comment"), CFSTR("shared"), CFSTR("timeout") };
|
||||
CFTypeRef values1[] = { CFSTR("user"), CFSTR("admin"), CFSTR("com.apple.lldb.LaunchUsingXPC"), kCFBooleanFalse, timeoutRef};
|
||||
dict = CFDictionaryCreate( kCFAllocatorDefault, (const void **)keys1, (const void **)values1, 5, &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
|
||||
|
||||
osStatus = AuthorizationRightSet(authorizationRef, rightName, dict, prompt, NULL, NULL);
|
||||
if (osStatus != errAuthorizationSuccess)
|
||||
{
|
||||
// Eventually when the commandline supports running as root and the user is not
|
||||
// logged in in the current audit session, we will need the trick in gdb where
|
||||
// we ask the user to type in the root passwd in the terminal.
|
||||
error.SetError(2, eErrorTypeGeneric);
|
||||
if (log)
|
||||
{
|
||||
error.PutToLog(log.get(), "Launching as root needs root authorization.");
|
||||
}
|
||||
else
|
||||
{
|
||||
error.SetErrorStringWithFormat("Launching as root needs root authorization.");
|
||||
}
|
||||
}
|
||||
CFRelease(timeoutRef);
|
||||
// CFRelease(promptDict);
|
||||
CFRelease(dict);
|
||||
if (authorizationRef) {
|
||||
AuthorizationFree(authorizationRef, kAuthorizationFlagDestroyRights);
|
||||
}
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
#endif
|
||||
|
||||
static Error
|
||||
LaunchProcessXPC (const char *exe_path, ProcessLaunchInfo &launch_info, ::pid_t &pid)
|
||||
{
|
||||
#if !BUILDING_ON_SNOW_LEOPARD
|
||||
Error error = getXPCAuthorization(launch_info);
|
||||
if (error.Fail())
|
||||
return error;
|
||||
|
||||
if (exe_spec.Exists())
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_HOST | LIBLLDB_LOG_PROCESS));
|
||||
|
||||
uid_t requested_uid = launch_info.GetUserID();
|
||||
const char *xpc_service = nil;
|
||||
if ((requested_uid == UINT32_MAX) || (requested_uid == Host::GetEffectiveUserID()))
|
||||
{
|
||||
exe_spec.GetPath (exe_path, sizeof(exe_path));
|
||||
xpc_service = "com.apple.lldb.launcherXPCService";
|
||||
}
|
||||
else if (requested_uid == 0)
|
||||
{
|
||||
xpc_service = "com.apple.lldb.launcherRootXPCService";
|
||||
}
|
||||
else
|
||||
{
|
||||
launch_info.GetExecutableFile().GetPath (exe_path, sizeof(exe_path));
|
||||
error.SetErrorStringWithFormat ("executable doesn't exist: '%s'", exe_path);
|
||||
error.SetError(2, eErrorTypeGeneric);
|
||||
if (log)
|
||||
{
|
||||
error.PutToLog(log.get(), "Launching via XPC is only currently available for either the login user or root.");
|
||||
}
|
||||
else
|
||||
{
|
||||
error.SetErrorStringWithFormat("Launching via XPC is only currently available for either the login user or root.");
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
if (launch_info.GetFlags().Test (eLaunchFlagLaunchInTTY))
|
||||
xpc_connection_t conn = xpc_connection_create(xpc_service, NULL);
|
||||
|
||||
xpc_connection_set_event_handler(conn, ^(xpc_object_t event) {
|
||||
xpc_type_t type = xpc_get_type(event);
|
||||
|
||||
if (type == XPC_TYPE_ERROR) {
|
||||
if (event == XPC_ERROR_CONNECTION_INTERRUPTED) {
|
||||
// The service has either canceled itself, crashed, or been terminated.
|
||||
// The XPC connection is still valid and sending a message to it will re-launch the service.
|
||||
// If the service is state-full, this is the time to initialize the new service.
|
||||
return;
|
||||
} else if (event == XPC_ERROR_CONNECTION_INVALID) {
|
||||
// The service is invalid. Either the service name supplied to xpc_connection_create() is incorrect
|
||||
// or we (this process) have canceled the service; we can do any cleanup of appliation state at this point.
|
||||
// printf("Service disconnected");
|
||||
return;
|
||||
} else {
|
||||
// printf("Unexpected error from service: %s", xpc_dictionary_get_string(event, XPC_ERROR_KEY_DESCRIPTION));
|
||||
}
|
||||
|
||||
} else {
|
||||
// printf("Received unexpected event in handler");
|
||||
}
|
||||
});
|
||||
|
||||
xpc_connection_set_finalizer_f (conn, xpc_release);
|
||||
xpc_connection_resume (conn);
|
||||
xpc_object_t message = xpc_dictionary_create (nil, nil, 0);
|
||||
|
||||
PackageXPCArguments(message, LauncherXPCServiceArgPrefxKey, launch_info.GetArguments());
|
||||
PackageXPCArguments(message, LauncherXPCServiceEnvPrefxKey, launch_info.GetEnvironmentEntries());
|
||||
|
||||
// Posix spawn stuff.
|
||||
xpc_dictionary_set_int64(message, LauncherXPCServiceCPUTypeKey, launch_info.GetArchitecture().GetMachOCPUType());
|
||||
xpc_dictionary_set_int64(message, LauncherXPCServicePosixspawnFlagsKey, GetPosixspawnFlags(launch_info));
|
||||
|
||||
xpc_object_t reply = xpc_connection_send_message_with_reply_sync(conn, message);
|
||||
|
||||
pid = xpc_dictionary_get_int64(reply, LauncherXPCServiceChildPIDKey);
|
||||
if (pid == 0)
|
||||
{
|
||||
#if !defined(__arm__)
|
||||
return LaunchInNewTerminalWithAppleScript (exe_path, launch_info);
|
||||
#else
|
||||
error.SetErrorString ("launching a processs in a new terminal is not supported on iOS devices");
|
||||
return error;
|
||||
#endif
|
||||
int errorType = xpc_dictionary_get_int64(reply, LauncherXPCServiceErrorTypeKey);
|
||||
int errorCode = xpc_dictionary_get_int64(reply, LauncherXPCServiceCodeTypeKey);
|
||||
|
||||
error.SetError(errorCode, eErrorTypeGeneric);
|
||||
if (log)
|
||||
{
|
||||
error.PutToLog(log.get(), "Problems with launching via XPC. Error type : %i, code : %i", errorType, errorCode);
|
||||
}
|
||||
else {
|
||||
error.SetErrorStringWithFormat("Problems with launching via XPC. Error type : %i, code : %i", errorType, errorCode);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
static Error
|
||||
LaunchProcessPosixSpawn (const char *exe_path, ProcessLaunchInfo &launch_info, ::pid_t &pid)
|
||||
{
|
||||
Error error;
|
||||
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_HOST | LIBLLDB_LOG_PROCESS));
|
||||
|
||||
Error local_err; // Errors that don't affect the spawning.
|
||||
posix_spawnattr_t attr;
|
||||
error.SetError( ::posix_spawnattr_init (&attr), eErrorTypePOSIX);
|
||||
|
||||
@@ -1289,21 +1459,7 @@ Host::LaunchProcess (ProcessLaunchInfo &launch_info)
|
||||
::posix_spawnattr_setsigmask(&attr, &no_signals);
|
||||
::posix_spawnattr_setsigdefault(&attr, &all_signals);
|
||||
|
||||
short flags = POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETSIGMASK;
|
||||
if (launch_info.GetFlags().Test (eLaunchFlagExec))
|
||||
flags |= POSIX_SPAWN_SETEXEC; // Darwin specific posix_spawn flag
|
||||
|
||||
if (launch_info.GetFlags().Test (eLaunchFlagDebug))
|
||||
flags |= POSIX_SPAWN_START_SUSPENDED; // Darwin specific posix_spawn flag
|
||||
|
||||
if (launch_info.GetFlags().Test (eLaunchFlagDisableASLR))
|
||||
flags |= _POSIX_SPAWN_DISABLE_ASLR; // Darwin specific posix_spawn flag
|
||||
|
||||
//#ifdef POSIX_SPAWN_CLOEXEC_DEFAULT
|
||||
// // Close all files exception those with file actions if this is supported.
|
||||
// flags |= POSIX_SPAWN_CLOEXEC_DEFAULT;
|
||||
//#endif
|
||||
|
||||
short flags = GetPosixspawnFlags(launch_info);
|
||||
error.SetError( ::posix_spawnattr_setflags (&attr, flags), eErrorTypePOSIX);
|
||||
if (error.Fail() || log)
|
||||
error.PutToLog(log.get(), "::posix_spawnattr_setflags ( &attr, flags=0x%8.8x )", flags);
|
||||
@@ -1315,6 +1471,7 @@ Host::LaunchProcess (ProcessLaunchInfo &launch_info)
|
||||
// We don't need to do this for ARM, and we really shouldn't now that we
|
||||
// have multiple CPU subtypes and no posix_spawnattr call that allows us
|
||||
// to set which CPU subtype to launch...
|
||||
const ArchSpec &arch_spec = launch_info.GetArchitecture();
|
||||
cpu_type_t cpu = arch_spec.GetMachOCPUType();
|
||||
if (cpu != 0 &&
|
||||
cpu != UINT32_MAX &&
|
||||
@@ -1330,7 +1487,7 @@ Host::LaunchProcess (ProcessLaunchInfo &launch_info)
|
||||
}
|
||||
|
||||
#endif
|
||||
::pid_t pid = LLDB_INVALID_PROCESS_ID;
|
||||
|
||||
const char *tmp_argv[2];
|
||||
char * const *argv = (char * const*)launch_info.GetArguments().GetConstArgumentVector();
|
||||
char * const *envp = (char * const*)launch_info.GetEnvironmentEntries().GetConstArgumentVector();
|
||||
@@ -1420,7 +1577,98 @@ Host::LaunchProcess (ProcessLaunchInfo &launch_info)
|
||||
// No more thread specific current working directory
|
||||
__pthread_fchdir (-1);
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
static bool
|
||||
ShouldLaunchUsingXPC(const char *exe_path, ProcessLaunchInfo &launch_info)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
#if !BUILDING_ON_SNOW_LEOPARD
|
||||
const char *debugserver = "/debugserver";
|
||||
int len = strlen(debugserver);
|
||||
int exe_len = strlen(exe_path);
|
||||
if (exe_len >= len)
|
||||
{
|
||||
const char *part = exe_path + (exe_len - len);
|
||||
if (strcmp(part, debugserver) == 0)
|
||||
{
|
||||
// We are dealing with debugserver.
|
||||
uid_t requested_uid = launch_info.GetUserID();
|
||||
if (requested_uid == 0)
|
||||
{
|
||||
// Launching XPC works for root. It also works for the non-attaching case for current login
|
||||
// but unfortunately, we can't detect it here.
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Error
|
||||
Host::LaunchProcess (ProcessLaunchInfo &launch_info)
|
||||
{
|
||||
Error error;
|
||||
char exe_path[PATH_MAX];
|
||||
PlatformSP host_platform_sp (Platform::GetDefaultPlatform ());
|
||||
|
||||
const ArchSpec &arch_spec = launch_info.GetArchitecture();
|
||||
|
||||
FileSpec exe_spec(launch_info.GetExecutableFile());
|
||||
|
||||
FileSpec::FileType file_type = exe_spec.GetFileType();
|
||||
if (file_type != FileSpec::eFileTypeRegular)
|
||||
{
|
||||
lldb::ModuleSP exe_module_sp;
|
||||
error = host_platform_sp->ResolveExecutable (exe_spec,
|
||||
arch_spec,
|
||||
exe_module_sp,
|
||||
NULL);
|
||||
|
||||
if (error.Fail())
|
||||
return error;
|
||||
|
||||
if (exe_module_sp)
|
||||
exe_spec = exe_module_sp->GetFileSpec();
|
||||
}
|
||||
|
||||
if (exe_spec.Exists())
|
||||
{
|
||||
exe_spec.GetPath (exe_path, sizeof(exe_path));
|
||||
}
|
||||
else
|
||||
{
|
||||
launch_info.GetExecutableFile().GetPath (exe_path, sizeof(exe_path));
|
||||
error.SetErrorStringWithFormat ("executable doesn't exist: '%s'", exe_path);
|
||||
return error;
|
||||
}
|
||||
|
||||
if (launch_info.GetFlags().Test (eLaunchFlagLaunchInTTY))
|
||||
{
|
||||
#if !defined(__arm__)
|
||||
return LaunchInNewTerminalWithAppleScript (exe_path, launch_info);
|
||||
#else
|
||||
error.SetErrorString ("launching a processs in a new terminal is not supported on iOS devices");
|
||||
return error;
|
||||
#endif
|
||||
}
|
||||
|
||||
::pid_t pid = LLDB_INVALID_PROCESS_ID;
|
||||
|
||||
if (ShouldLaunchUsingXPC(exe_path, launch_info))
|
||||
{
|
||||
error = LaunchProcessXPC(exe_path, launch_info, pid);
|
||||
}
|
||||
else
|
||||
{
|
||||
error = LaunchProcessPosixSpawn(exe_path, launch_info, pid);
|
||||
}
|
||||
|
||||
if (pid != LLDB_INVALID_PROCESS_ID)
|
||||
{
|
||||
// If all went well, then set the process ID into the launch info
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
#if RC_XBS && !RC_BUILDIT
|
||||
#define AND_APPLE_CODE_SIGNED and ${IS_APPLE_CODE_SIGNED}
|
||||
#else
|
||||
#define AND_APPLE_CODE_SIGNED
|
||||
#endif
|
||||
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>XPC!</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2012 Apple Inc. All rights reserved.</string>
|
||||
<key>XPCService</key>
|
||||
<dict>
|
||||
<key>_AllowedClients</key>
|
||||
<array>
|
||||
<string> identifier = com.apple.lldb AND_APPLE_CODE_SIGNED</string>
|
||||
<string> identifier = com.apple.dt.Xcode AND_APPLE_CODE_SIGNED</string>
|
||||
</array>
|
||||
<key>_RoleAccount</key>
|
||||
<string>root</string>
|
||||
<key>ServiceType</key>
|
||||
<string>Application</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,44 @@
|
||||
#if RC_XBS && !RC_BUILDIT
|
||||
#define AND_APPLE_CODE_SIGNED and ${IS_APPLE_CODE_SIGNED}
|
||||
#else
|
||||
#define AND_APPLE_CODE_SIGNED
|
||||
#endif
|
||||
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>XPC!</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2012 Apple Inc. All rights reserved.</string>
|
||||
<key>XPCService</key>
|
||||
<dict>
|
||||
<key>_AllowedClients</key>
|
||||
<array>
|
||||
<string> identifier = com.apple.lldb AND_APPLE_CODE_SIGNED</string>
|
||||
<string> identifier = com.apple.dt.Xcode AND_APPLE_CODE_SIGNED</string>
|
||||
</array>
|
||||
<key>ServiceType</key>
|
||||
<string>Application</string>
|
||||
<key>JoinExistingSession</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.private.xpc.role-account</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,13 @@
|
||||
#ifndef LLDB_LauncherXPCService_h
|
||||
#define LLDB_LauncherXPCService_h
|
||||
|
||||
// These XPC messaging keys are used for communication between Host.mm and the XPC service.
|
||||
#define LauncherXPCServiceArgPrefxKey "arg"
|
||||
#define LauncherXPCServiceEnvPrefxKey "env"
|
||||
#define LauncherXPCServiceCPUTypeKey "cpuType"
|
||||
#define LauncherXPCServicePosixspawnFlagsKey "posixspawnFlags"
|
||||
#define LauncherXPCServiceChildPIDKey "childPID"
|
||||
#define LauncherXPCServiceErrorTypeKey "errorType"
|
||||
#define LauncherXPCServiceCodeTypeKey "errorCode"
|
||||
|
||||
#endif
|
||||
185
lldb/source/Host/macosx/launcherXPCService/LauncherXPCService.mm
Normal file
185
lldb/source/Host/macosx/launcherXPCService/LauncherXPCService.mm
Normal file
@@ -0,0 +1,185 @@
|
||||
//
|
||||
// LauncherXPCService.m
|
||||
// LauncherXPCService
|
||||
//
|
||||
// Copyright (c) 2012 Apple Inc. All rights reserved.
|
||||
//
|
||||
#include <AvailabilityMacros.h>
|
||||
|
||||
#if !defined(MAC_OS_X_VERSION_10_7) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
|
||||
#define BUILDING_ON_SNOW_LEOPARD 1
|
||||
#endif
|
||||
|
||||
#if !BUILDING_ON_SNOW_LEOPARD
|
||||
#include <xpc/xpc.h>
|
||||
#include <spawn.h>
|
||||
#include <signal.h>
|
||||
#include <assert.h>
|
||||
#include "LauncherXPCService.h"
|
||||
|
||||
// Returns 0 if successful.
|
||||
int _setup_posixspawn_attributes_file_actions(xpc_object_t message, posix_spawnattr_t *attr, posix_spawn_file_actions_t *file_actions)
|
||||
{
|
||||
*attr = 0;
|
||||
|
||||
int errorCode = posix_spawnattr_init(attr);
|
||||
if (errorCode)
|
||||
return errorCode;
|
||||
|
||||
cpu_type_t cpuType = xpc_dictionary_get_int64(message, LauncherXPCServiceCPUTypeKey);
|
||||
if (cpuType == -2) {
|
||||
cpuType= CPU_TYPE_ANY;
|
||||
}
|
||||
size_t realCount;
|
||||
errorCode = posix_spawnattr_setbinpref_np(attr, 1, &cpuType, &realCount);
|
||||
if (errorCode)
|
||||
return errorCode;
|
||||
|
||||
sigset_t no_signals;
|
||||
sigset_t all_signals;
|
||||
sigemptyset (&no_signals);
|
||||
sigfillset (&all_signals);
|
||||
posix_spawnattr_setsigmask(attr, &no_signals);
|
||||
posix_spawnattr_setsigdefault(attr, &all_signals);
|
||||
|
||||
short flags = xpc_dictionary_get_int64(message, LauncherXPCServicePosixspawnFlagsKey);
|
||||
errorCode = posix_spawnattr_setflags(attr, flags);
|
||||
if (errorCode)
|
||||
return errorCode;
|
||||
|
||||
// Setup any file actions. Here we are emulating what debugserver would do normally in Host.mm since the XPC service meant only for debugserver.
|
||||
errorCode = posix_spawn_file_actions_init(file_actions);
|
||||
if (errorCode)
|
||||
return errorCode;
|
||||
errorCode = posix_spawn_file_actions_addclose(file_actions, STDIN_FILENO);
|
||||
if (errorCode)
|
||||
return errorCode;
|
||||
errorCode = posix_spawn_file_actions_addclose(file_actions, STDOUT_FILENO);
|
||||
if (errorCode)
|
||||
return errorCode;
|
||||
errorCode = posix_spawn_file_actions_addclose(file_actions, STDERR_FILENO);
|
||||
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
bool extract_args(xpc_object_t message, const char *prefix, const char ***argsOut)
|
||||
{
|
||||
char buf[50]; // long enough for 'argXXX'
|
||||
memset(buf, 0, 50);
|
||||
sprintf(buf, "%sCount", prefix);
|
||||
int argsCount = xpc_dictionary_get_int64(message, buf);
|
||||
if (argsCount == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const char **argsp = NULL;
|
||||
argsp = (const char **)malloc((argsCount+1) * sizeof(argsp[0]));
|
||||
if (argsp == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i=0; i<argsCount; i++) {
|
||||
memset(buf, 0, 50);
|
||||
sprintf(buf, "%s%i", prefix, i);
|
||||
const char *arg = xpc_dictionary_get_string(message, buf);
|
||||
argsp[i] = arg;
|
||||
}
|
||||
argsp[argsCount] = NULL;
|
||||
|
||||
*argsOut = argsp;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Returns 0 if successful.
|
||||
int get_args(xpc_object_t message, const char **path, const char ***argsOut, const char ***envOut)
|
||||
{
|
||||
if (!extract_args(message, LauncherXPCServiceArgPrefxKey, argsOut)) {
|
||||
return 1;
|
||||
}
|
||||
*path = (*argsOut)[0];
|
||||
|
||||
if (!extract_args(message, LauncherXPCServiceEnvPrefxKey, envOut)) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void launcherXPC_peer_event_handler(xpc_connection_t peer, xpc_object_t event)
|
||||
{
|
||||
xpc_type_t type = xpc_get_type(event);
|
||||
if (type == XPC_TYPE_ERROR) {
|
||||
if (event == XPC_ERROR_CONNECTION_INVALID) {
|
||||
// The client process on the other end of the connection has either
|
||||
// crashed or cancelled the connection. After receiving this error,
|
||||
// the connection is in an invalid state, and you do not need to
|
||||
// call xpc_connection_cancel(). Just tear down any associated state
|
||||
// here.
|
||||
} else if (event == XPC_ERROR_TERMINATION_IMMINENT) {
|
||||
// Handle per-connection termination cleanup.
|
||||
}
|
||||
} else {
|
||||
assert(type == XPC_TYPE_DICTIONARY);
|
||||
// Handle the message.
|
||||
|
||||
pid_t childPID = 0;
|
||||
posix_spawn_file_actions_t file_actions;
|
||||
posix_spawnattr_t attributes;
|
||||
|
||||
/*
|
||||
Types of error. Error code will be specific to each type.
|
||||
1 - posixspawn attributes problem
|
||||
2 - get args/env problem
|
||||
3 - posixspawn problem
|
||||
*/
|
||||
int errorType = 1;
|
||||
int errorCode = _setup_posixspawn_attributes_file_actions(event, &attributes, &file_actions);
|
||||
if (!errorCode) {
|
||||
const char *path = NULL;
|
||||
const char **argvp = NULL;
|
||||
const char **envp = NULL;
|
||||
errorType = 2;
|
||||
errorCode = get_args(event, &path, &argvp, &envp);
|
||||
if (!errorCode) {
|
||||
errorType = 3;
|
||||
errorCode = posix_spawn(&childPID, path, &file_actions, &attributes, (char * const *)argvp, (char * const *)envp);
|
||||
|
||||
if (argvp) free(argvp);
|
||||
if (envp) free(envp);
|
||||
}
|
||||
}
|
||||
|
||||
xpc_object_t reply = xpc_dictionary_create_reply(event);
|
||||
|
||||
xpc_dictionary_set_int64(reply, LauncherXPCServiceChildPIDKey, childPID);
|
||||
if (!childPID) {
|
||||
xpc_dictionary_set_int64(reply, LauncherXPCServiceErrorTypeKey, errorType);
|
||||
xpc_dictionary_set_int64(reply, LauncherXPCServiceCodeTypeKey, errorCode);
|
||||
}
|
||||
|
||||
xpc_connection_send_message(peer, reply);
|
||||
xpc_release(reply);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static void launcherXPC_event_handler(xpc_connection_t peer)
|
||||
{
|
||||
// By defaults, new connections will target the default dispatch
|
||||
// concurrent queue.
|
||||
xpc_connection_set_event_handler(peer, ^(xpc_object_t event) {
|
||||
launcherXPC_peer_event_handler(peer, event);
|
||||
});
|
||||
|
||||
// This will tell the connection to begin listening for events. If you
|
||||
// have some other initialization that must be done asynchronously, then
|
||||
// you can defer this call until after that initialization is done.
|
||||
xpc_connection_resume(peer);
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
xpc_main(launcherXPC_event_handler);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@@ -258,7 +258,15 @@ ProcessKDP::DoAttachToProcessWithID (lldb::pid_t attach_pid)
|
||||
}
|
||||
|
||||
Error
|
||||
ProcessKDP::DoAttachToProcessWithName (const char *process_name, bool wait_for_launch)
|
||||
ProcessKDP::DoAttachToProcessWithID (lldb::pid_t attach_pid, const ProcessAttachInfo &attach_info)
|
||||
{
|
||||
Error error;
|
||||
error.SetErrorString ("attach to process by ID is not suppported in kdp remote debugging");
|
||||
return error;
|
||||
}
|
||||
|
||||
Error
|
||||
ProcessKDP::DoAttachToProcessWithName (const char *process_name, bool wait_for_launch, const ProcessAttachInfo &attach_info)
|
||||
{
|
||||
Error error;
|
||||
error.SetErrorString ("attach to process by name is not suppported in kdp remote debugging");
|
||||
|
||||
@@ -96,7 +96,10 @@ public:
|
||||
DoAttachToProcessWithID (lldb::pid_t pid);
|
||||
|
||||
virtual lldb_private::Error
|
||||
DoAttachToProcessWithName (const char *process_name, bool wait_for_launch);
|
||||
DoAttachToProcessWithID (lldb::pid_t pid, const lldb_private::ProcessAttachInfo &attach_info);
|
||||
|
||||
virtual lldb_private::Error
|
||||
DoAttachToProcessWithName (const char *process_name, bool wait_for_launch, const lldb_private::ProcessAttachInfo &attach_info);
|
||||
|
||||
virtual void
|
||||
DidAttach ();
|
||||
|
||||
@@ -496,7 +496,7 @@ ProcessGDBRemote::DoLaunch (Module *exe_module, const ProcessLaunchInfo &launch_
|
||||
// Make sure we aren't already connected?
|
||||
if (!m_gdb_comm.IsConnected())
|
||||
{
|
||||
error = StartDebugserverProcess (host_port);
|
||||
error = StartDebugserverProcess (host_port, launch_info);
|
||||
if (error.Fail())
|
||||
{
|
||||
if (log)
|
||||
@@ -761,6 +761,13 @@ ProcessGDBRemote::DidLaunch ()
|
||||
|
||||
Error
|
||||
ProcessGDBRemote::DoAttachToProcessWithID (lldb::pid_t attach_pid)
|
||||
{
|
||||
ProcessAttachInfo attach_info;
|
||||
return DoAttachToProcessWithID(attach_pid, attach_info);
|
||||
}
|
||||
|
||||
Error
|
||||
ProcessGDBRemote::DoAttachToProcessWithID (lldb::pid_t attach_pid, const ProcessAttachInfo &attach_info)
|
||||
{
|
||||
Error error;
|
||||
// Clear out and clean up from any current state
|
||||
@@ -775,7 +782,7 @@ ProcessGDBRemote::DoAttachToProcessWithID (lldb::pid_t attach_pid)
|
||||
char connect_url[128];
|
||||
snprintf (connect_url, sizeof(connect_url), "connect://%s", host_port);
|
||||
|
||||
error = StartDebugserverProcess (host_port);
|
||||
error = StartDebugserverProcess (host_port, attach_info);
|
||||
|
||||
if (error.Fail())
|
||||
{
|
||||
@@ -824,7 +831,7 @@ ProcessGDBRemote::AttachInputReaderCallback
|
||||
}
|
||||
|
||||
Error
|
||||
ProcessGDBRemote::DoAttachToProcessWithName (const char *process_name, bool wait_for_launch)
|
||||
ProcessGDBRemote::DoAttachToProcessWithName (const char *process_name, bool wait_for_launch, const ProcessAttachInfo &attach_info)
|
||||
{
|
||||
Error error;
|
||||
// Clear out and clean up from any current state
|
||||
@@ -840,7 +847,7 @@ ProcessGDBRemote::DoAttachToProcessWithName (const char *process_name, bool wait
|
||||
char connect_url[128];
|
||||
snprintf (connect_url, sizeof(connect_url), "connect://%s", host_port);
|
||||
|
||||
error = StartDebugserverProcess (host_port);
|
||||
error = StartDebugserverProcess (host_port, attach_info);
|
||||
if (error.Fail())
|
||||
{
|
||||
const char *error_string = error.AsCString();
|
||||
@@ -2019,7 +2026,14 @@ ProcessGDBRemote::DoSignal (int signo)
|
||||
}
|
||||
|
||||
Error
|
||||
ProcessGDBRemote::StartDebugserverProcess (const char *debugserver_url) // The connection string to use in the spawned debugserver ("localhost:1234" or "/dev/tty...")
|
||||
ProcessGDBRemote::StartDebugserverProcess (const char *debugserver_url)
|
||||
{
|
||||
ProcessLaunchInfo launch_info;
|
||||
return StartDebugserverProcess(debugserver_url, launch_info);
|
||||
}
|
||||
|
||||
Error
|
||||
ProcessGDBRemote::StartDebugserverProcess (const char *debugserver_url, const ProcessInfo &process_info) // The connection string to use in the spawned debugserver ("localhost:1234" or "/dev/tty...")
|
||||
{
|
||||
Error error;
|
||||
if (m_debugserver_pid == LLDB_INVALID_PROCESS_ID)
|
||||
@@ -2027,9 +2041,9 @@ ProcessGDBRemote::StartDebugserverProcess (const char *debugserver_url) // Th
|
||||
// If we locate debugserver, keep that located version around
|
||||
static FileSpec g_debugserver_file_spec;
|
||||
|
||||
ProcessLaunchInfo launch_info;
|
||||
ProcessLaunchInfo debugserver_launch_info;
|
||||
char debugserver_path[PATH_MAX];
|
||||
FileSpec &debugserver_file_spec = launch_info.GetExecutableFile();
|
||||
FileSpec &debugserver_file_spec = debugserver_launch_info.GetExecutableFile();
|
||||
|
||||
// Always check to see if we have an environment override for the path
|
||||
// to the debugserver to use and use it if we do.
|
||||
@@ -2067,7 +2081,7 @@ ProcessGDBRemote::StartDebugserverProcess (const char *debugserver_url) // Th
|
||||
|
||||
LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS));
|
||||
|
||||
Args &debugserver_args = launch_info.GetArguments();
|
||||
Args &debugserver_args = debugserver_launch_info.GetArguments();
|
||||
char arg_cstr[PATH_MAX];
|
||||
|
||||
// Start args with "debugserver /file/path -r --"
|
||||
@@ -2130,11 +2144,11 @@ ProcessGDBRemote::StartDebugserverProcess (const char *debugserver_url) // Th
|
||||
// Close STDIN, STDOUT and STDERR. We might need to redirect them
|
||||
// to "/dev/null" if we run into any problems.
|
||||
file_action.Close (STDIN_FILENO);
|
||||
launch_info.AppendFileAction (file_action);
|
||||
debugserver_launch_info.AppendFileAction (file_action);
|
||||
file_action.Close (STDOUT_FILENO);
|
||||
launch_info.AppendFileAction (file_action);
|
||||
debugserver_launch_info.AppendFileAction (file_action);
|
||||
file_action.Close (STDERR_FILENO);
|
||||
launch_info.AppendFileAction (file_action);
|
||||
debugserver_launch_info.AppendFileAction (file_action);
|
||||
|
||||
if (log)
|
||||
{
|
||||
@@ -2143,12 +2157,13 @@ ProcessGDBRemote::StartDebugserverProcess (const char *debugserver_url) // Th
|
||||
log->Printf("%s arguments:\n%s", debugserver_args.GetArgumentAtIndex(0), strm.GetData());
|
||||
}
|
||||
|
||||
launch_info.SetMonitorProcessCallback (MonitorDebugserverProcess, this, false);
|
||||
debugserver_launch_info.SetMonitorProcessCallback (MonitorDebugserverProcess, this, false);
|
||||
debugserver_launch_info.SetUserID(process_info.GetUserID());
|
||||
|
||||
error = Host::LaunchProcess(launch_info);
|
||||
error = Host::LaunchProcess(debugserver_launch_info);
|
||||
|
||||
if (error.Success ())
|
||||
m_debugserver_pid = launch_info.GetProcessID();
|
||||
m_debugserver_pid = debugserver_launch_info.GetProcessID();
|
||||
else
|
||||
m_debugserver_pid = LLDB_INVALID_PROCESS_ID;
|
||||
|
||||
|
||||
@@ -103,7 +103,12 @@ public:
|
||||
DoAttachToProcessWithID (lldb::pid_t pid);
|
||||
|
||||
virtual lldb_private::Error
|
||||
DoAttachToProcessWithName (const char *process_name, bool wait_for_launch);
|
||||
DoAttachToProcessWithID (lldb::pid_t pid, const lldb_private::ProcessAttachInfo &attach_info);
|
||||
|
||||
virtual lldb_private::Error
|
||||
DoAttachToProcessWithName (const char *process_name,
|
||||
bool wait_for_launch,
|
||||
const lldb_private::ProcessAttachInfo &attach_info);
|
||||
|
||||
virtual void
|
||||
DidAttach ();
|
||||
@@ -260,6 +265,9 @@ protected:
|
||||
|
||||
lldb_private::Error
|
||||
StartDebugserverProcess (const char *debugserver_url);
|
||||
|
||||
lldb_private::Error
|
||||
StartDebugserverProcess (const char *debugserver_url, const lldb_private::ProcessInfo &process_info);
|
||||
|
||||
void
|
||||
KillDebugserverProcess ();
|
||||
|
||||
@@ -2490,7 +2490,7 @@ Process::Attach (ProcessAttachInfo &attach_info)
|
||||
m_should_detach = true;
|
||||
|
||||
SetPublicState (eStateAttaching);
|
||||
error = DoAttachToProcessWithName (process_name, wait_for_launch);
|
||||
error = DoAttachToProcessWithName (process_name, wait_for_launch, attach_info);
|
||||
if (error.Fail())
|
||||
{
|
||||
if (GetID() != LLDB_INVALID_PROCESS_ID)
|
||||
@@ -2557,7 +2557,7 @@ Process::Attach (ProcessAttachInfo &attach_info)
|
||||
m_should_detach = true;
|
||||
SetPublicState (eStateAttaching);
|
||||
|
||||
error = DoAttachToProcessWithID (attach_pid);
|
||||
error = DoAttachToProcessWithID (attach_pid, attach_info);
|
||||
if (error.Success())
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user