[Lldb-commits] [lldb] r113263 - in /lldb/trunk: include/lldb/Host/Host.h lib/Makefile lldb.xcodeproj/project.pbxproj source/Host/Makefile source/Host/common/ source/Host/common/Condition.cpp source/Host/common/Host.cpp source/Host/common/Makefile source/Host/common/Mutex.cpp source/Host/common/Symbols.cpp source/Host/common/TimeValue.cpp source/Host/linux/ source/Host/macosx/Host.mm source/Host/macosx/TimeValue.cpp source/Host/posix/

Greg Clayton gclayton at apple.com
Tue Sep 7 13:11:56 PDT 2010


Author: gclayton
Date: Tue Sep  7 15:11:56 2010
New Revision: 113263

URL: http://llvm.org/viewvc/llvm-project?rev=113263&view=rev
Log:
Patch from Jay Cornwall that modifies the LLDB "Host" layer to reuse more
code between linux, darwin and BSD.


Added:
    lldb/trunk/source/Host/common/
    lldb/trunk/source/Host/common/Condition.cpp
    lldb/trunk/source/Host/common/Host.cpp
    lldb/trunk/source/Host/common/Makefile
    lldb/trunk/source/Host/common/Mutex.cpp
    lldb/trunk/source/Host/common/Symbols.cpp
    lldb/trunk/source/Host/common/TimeValue.cpp
Removed:
    lldb/trunk/source/Host/linux/
    lldb/trunk/source/Host/macosx/TimeValue.cpp
    lldb/trunk/source/Host/posix/
Modified:
    lldb/trunk/include/lldb/Host/Host.h
    lldb/trunk/lib/Makefile
    lldb/trunk/lldb.xcodeproj/project.pbxproj
    lldb/trunk/source/Host/Makefile
    lldb/trunk/source/Host/macosx/Host.mm

Modified: lldb/trunk/include/lldb/Host/Host.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=113263&r1=113262&r2=113263&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/Host.h (original)
+++ lldb/trunk/include/lldb/Host/Host.h Tue Sep  7 15:11:56 2010
@@ -148,7 +148,7 @@
     /// @return
     ///     The thread ID for the calling thread in the current process.
     //------------------------------------------------------------------
-    static lldb::pid_t
+    static lldb::tid_t
     GetCurrentThreadID ();
 
     static const char *

Modified: lldb/trunk/lib/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lib/Makefile?rev=113263&r1=113262&r2=113263&view=diff
==============================================================================
--- lldb/trunk/lib/Makefile (original)
+++ lldb/trunk/lib/Makefile Tue Sep  7 15:11:56 2010
@@ -23,7 +23,7 @@
 	lldbCommands.a \
 	lldbCore.a \
 	lldbExpression.a \
-	lldbHostPosix.a \
+	lldbHostCommon.a \
 	lldbInitAndLog.a \
 	lldbInterpreter.a \
 	lldbPluginABIMacOSX_i386.a \
@@ -69,8 +69,7 @@
 endif
 
 ifeq ($(HOST_OS),Linux)
-  USEDLIBS += lldbHostLinux.a \
-              lldbPluginProcessLinux.a
+  USEDLIBS += lldbPluginProcessLinux.a
 endif
 
 include $(LEVEL)/Makefile.common

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=113263&r1=113262&r2=113263&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Sep  7 15:11:56 2010
@@ -147,9 +147,7 @@
 		26D5B0BC11B07550009A862E /* VMRange.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E9E10F1B85900F91463 /* VMRange.cpp */; };
 		26D5B0BD11B07550009A862E /* ClangUserExpression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7ED510F1B86700F91463 /* ClangUserExpression.cpp */; };
 		26D5B0BE11B07550009A862E /* ClangExpressionVariable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7ED610F1B86700F91463 /* ClangExpressionVariable.cpp */; };
-		26D5B0C111B07550009A862E /* Condition.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7EE710F1B88F00F91463 /* Condition.cpp */; };
 		26D5B0C211B07550009A862E /* Host.mm in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7EE810F1B88F00F91463 /* Host.mm */; };
-		26D5B0C311B07550009A862E /* Mutex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7EE910F1B88F00F91463 /* Mutex.cpp */; };
 		26D5B0C411B07550009A862E /* CFCBundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7EED10F1B8AD00F91463 /* CFCBundle.cpp */; };
 		26D5B0C511B07550009A862E /* CFCData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7EEF10F1B8AD00F91463 /* CFCData.cpp */; };
 		26D5B0C611B07550009A862E /* CFCMutableArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7EF110F1B8AD00F91463 /* CFCMutableArray.cpp */; };
@@ -246,7 +244,6 @@
 		26D5B12611B07550009A862E /* ThreadPlanStepOverRange.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C43DF8A11069C3200E55CBF /* ThreadPlanStepOverRange.cpp */; };
 		26D5B12711B07550009A862E /* CommandObjectLog.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 264AD83711095BA600E0B039 /* CommandObjectLog.cpp */; };
 		26D5B12811B07550009A862E /* ValueObjectRegister.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 264334381110F63100CDB6C6 /* ValueObjectRegister.cpp */; };
-		26D5B12911B07550009A862E /* TimeValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26B4E28B112F5DCD00AB3F64 /* TimeValue.cpp */; };
 		26D5B12A11B07550009A862E /* UUID.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26C81CA511335651004BDC5A /* UUID.cpp */; };
 		26D5B12B11B07550009A862E /* ScriptInterpreterNone.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A2771FC1135A37500E6ADB6 /* ScriptInterpreterNone.cpp */; };
 		26D5B12C11B07550009A862E /* CommandObjectCrossref.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26DFBC57113B48F300DD817F /* CommandObjectCrossref.cpp */; };
@@ -352,6 +349,11 @@
 		4C5DBBC911E3FEC60035160F /* CommandObjectCommands.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C5DBBC711E3FEC60035160F /* CommandObjectCommands.h */; };
 		4C74CB6312288704006A8171 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C74CB6212288704006A8171 /* Carbon.framework */; };
 		4CA9637B11B6E99A00780E28 /* CommandObjectApropos.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CA9637911B6E99A00780E28 /* CommandObjectApropos.cpp */; };
+		69A01E211236C5D400C660B5 /* Condition.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 69A01E1B1236C5D400C660B5 /* Condition.cpp */; };
+		69A01E221236C5D400C660B5 /* Host.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 69A01E1C1236C5D400C660B5 /* Host.cpp */; };
+		69A01E241236C5D400C660B5 /* Mutex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 69A01E1E1236C5D400C660B5 /* Mutex.cpp */; };
+		69A01E251236C5D400C660B5 /* Symbols.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 69A01E1F1236C5D400C660B5 /* Symbols.cpp */; };
+		69A01E261236C5D400C660B5 /* TimeValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 69A01E201236C5D400C660B5 /* TimeValue.cpp */; };
 		9A19A6AF1163BBB200E0D453 /* SBValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A19A6A51163BB7E00E0D453 /* SBValue.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		9A19A6B01163BBB300E0D453 /* SBValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A19A6AD1163BB9800E0D453 /* SBValue.cpp */; };
 		9A357583116CFDEE00E8ED2F /* SBValueList.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A357582116CFDEE00E8ED2F /* SBValueList.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -569,7 +571,6 @@
 		26B4666F11A2091600CF6220 /* LibUnwindRegisterContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LibUnwindRegisterContext.cpp; path = Utility/LibUnwindRegisterContext.cpp; sourceTree = "<group>"; };
 		26B4667011A2091600CF6220 /* LibUnwindRegisterContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LibUnwindRegisterContext.h; path = Utility/LibUnwindRegisterContext.h; sourceTree = "<group>"; };
 		26B4E26E112F35F700AB3F64 /* TimeValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TimeValue.h; path = include/lldb/Host/TimeValue.h; sourceTree = "<group>"; };
-		26B4E28B112F5DCD00AB3F64 /* TimeValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TimeValue.cpp; path = source/Host/macosx/TimeValue.cpp; sourceTree = "<group>"; };
 		26BC7C2510F1B3BC00F91463 /* lldb-defines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "lldb-defines.h"; path = "include/lldb/lldb-defines.h"; sourceTree = "<group>"; };
 		26BC7C2610F1B3BC00F91463 /* lldb-enumerations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "lldb-enumerations.h"; path = "include/lldb/lldb-enumerations.h"; sourceTree = "<group>"; };
 		26BC7C2810F1B3BC00F91463 /* lldb-private-interfaces.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "lldb-private-interfaces.h"; path = "include/lldb/lldb-private-interfaces.h"; sourceTree = "<group>"; };
@@ -783,9 +784,7 @@
 		26BC7ED510F1B86700F91463 /* ClangUserExpression.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangUserExpression.cpp; path = source/Expression/ClangUserExpression.cpp; sourceTree = "<group>"; };
 		26BC7ED610F1B86700F91463 /* ClangExpressionVariable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangExpressionVariable.cpp; path = source/Expression/ClangExpressionVariable.cpp; sourceTree = "<group>"; };
 		26BC7ED810F1B86700F91463 /* DWARFExpression.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DWARFExpression.cpp; path = source/Expression/DWARFExpression.cpp; sourceTree = "<group>"; };
-		26BC7EE710F1B88F00F91463 /* Condition.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Condition.cpp; path = source/Host/posix/Condition.cpp; sourceTree = "<group>"; };
 		26BC7EE810F1B88F00F91463 /* Host.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = Host.mm; path = source/Host/macosx/Host.mm; sourceTree = "<group>"; };
-		26BC7EE910F1B88F00F91463 /* Mutex.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Mutex.cpp; path = source/Host/posix/Mutex.cpp; sourceTree = "<group>"; };
 		26BC7EED10F1B8AD00F91463 /* CFCBundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CFCBundle.cpp; path = source/Host/macosx/cfcpp/CFCBundle.cpp; sourceTree = "<group>"; };
 		26BC7EEE10F1B8AD00F91463 /* CFCBundle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFCBundle.h; path = source/Host/macosx/cfcpp/CFCBundle.h; sourceTree = "<group>"; };
 		26BC7EEF10F1B8AD00F91463 /* CFCData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CFCData.cpp; path = source/Host/macosx/cfcpp/CFCData.cpp; sourceTree = "<group>"; };
@@ -963,6 +962,11 @@
 		4CEE62FF1145F2130064CF93 /* ThreadGDBRemote.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadGDBRemote.h; path = "source/Plugins/Process/gdb-remote/ThreadGDBRemote.h"; sourceTree = "<group>"; };
 		4CF4473D11A8687100EF971E /* ThreadPlanStepThroughObjCTrampoline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadPlanStepThroughObjCTrampoline.h; sourceTree = "<group>"; };
 		4CF4473E11A8687100EF971E /* ThreadPlanStepThroughObjCTrampoline.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadPlanStepThroughObjCTrampoline.cpp; sourceTree = "<group>"; };
+		69A01E1B1236C5D400C660B5 /* Condition.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Condition.cpp; sourceTree = "<group>"; };
+		69A01E1C1236C5D400C660B5 /* Host.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Host.cpp; sourceTree = "<group>"; };
+		69A01E1E1236C5D400C660B5 /* Mutex.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Mutex.cpp; sourceTree = "<group>"; };
+		69A01E1F1236C5D400C660B5 /* Symbols.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Symbols.cpp; sourceTree = "<group>"; };
+		69A01E201236C5D400C660B5 /* TimeValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TimeValue.cpp; sourceTree = "<group>"; };
 		9654F79C1197DA1300F72B43 /* MacOSXLibunwindCallbacks.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MacOSXLibunwindCallbacks.cpp; path = Utility/MacOSXLibunwindCallbacks.cpp; sourceTree = "<group>"; };
 		9654F79D1197DA1300F72B43 /* MacOSXLibunwindCallbacks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MacOSXLibunwindCallbacks.h; path = Utility/MacOSXLibunwindCallbacks.h; sourceTree = "<group>"; };
 		9654F7A11197DA3F00F72B43 /* libunwind.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = libunwind.h; sourceTree = "<group>"; };
@@ -1868,8 +1872,8 @@
 		26BC7DD010F1B7C100F91463 /* Host */ = {
 			isa = PBXGroup;
 			children = (
+				69A01E1A1236C5D400C660B5 /* common */,
 				26BC7EE510F1B88100F91463 /* MacOSX */,
-				26F62BB211C5E6C300358180 /* posix */,
 				26BC7DD210F1B7D500F91463 /* Condition.h */,
 				26BC7DD310F1B7D500F91463 /* Endian.h */,
 				26BC7DD410F1B7D500F91463 /* Host.h */,
@@ -1999,7 +2003,6 @@
 				26BC7EF910F1B8AD00F91463 /* CFCString.h */,
 				26BC7EE810F1B88F00F91463 /* Host.mm */,
 				2689B0B5113EE47E00A4AEDB /* Symbols.cpp */,
-				26B4E28B112F5DCD00AB3F64 /* TimeValue.cpp */,
 			);
 			name = MacOSX;
 			sourceTree = "<group>";
@@ -2050,15 +2053,6 @@
 			sourceTree = "<group>";
 			usesTabs = 0;
 		};
-		26F62BB211C5E6C300358180 /* posix */ = {
-			isa = PBXGroup;
-			children = (
-				26BC7EE710F1B88F00F91463 /* Condition.cpp */,
-				26BC7EE910F1B88F00F91463 /* Mutex.cpp */,
-			);
-			name = posix;
-			sourceTree = "<group>";
-		};
 		493C63D711891A8000914D5E /* ABI */ = {
 			isa = PBXGroup;
 			children = (
@@ -2104,6 +2098,19 @@
 			path = ../../..;
 			sourceTree = "<group>";
 		};
+		69A01E1A1236C5D400C660B5 /* common */ = {
+			isa = PBXGroup;
+			children = (
+				69A01E1B1236C5D400C660B5 /* Condition.cpp */,
+				69A01E1C1236C5D400C660B5 /* Host.cpp */,
+				69A01E1E1236C5D400C660B5 /* Mutex.cpp */,
+				69A01E1F1236C5D400C660B5 /* Symbols.cpp */,
+				69A01E201236C5D400C660B5 /* TimeValue.cpp */,
+			);
+			name = common;
+			path = source/Host/common;
+			sourceTree = "<group>";
+		};
 		9654F79F1197DA3F00F72B43 /* libunwind */ = {
 			isa = PBXGroup;
 			children = (
@@ -2282,6 +2289,7 @@
 			isa = PBXProject;
 			buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */;
 			compatibilityVersion = "Xcode 3.1";
+			developmentRegion = English;
 			hasScannedForEncodings = 1;
 			knownRegions = (
 				en,
@@ -2477,9 +2485,7 @@
 				26D5B0BC11B07550009A862E /* VMRange.cpp in Sources */,
 				26D5B0BD11B07550009A862E /* ClangUserExpression.cpp in Sources */,
 				26D5B0BE11B07550009A862E /* ClangExpressionVariable.cpp in Sources */,
-				26D5B0C111B07550009A862E /* Condition.cpp in Sources */,
 				26D5B0C211B07550009A862E /* Host.mm in Sources */,
-				26D5B0C311B07550009A862E /* Mutex.cpp in Sources */,
 				26D5B0C411B07550009A862E /* CFCBundle.cpp in Sources */,
 				26D5B0C511B07550009A862E /* CFCData.cpp in Sources */,
 				26D5B0C611B07550009A862E /* CFCMutableArray.cpp in Sources */,
@@ -2576,7 +2582,6 @@
 				26D5B12611B07550009A862E /* ThreadPlanStepOverRange.cpp in Sources */,
 				26D5B12711B07550009A862E /* CommandObjectLog.cpp in Sources */,
 				26D5B12811B07550009A862E /* ValueObjectRegister.cpp in Sources */,
-				26D5B12911B07550009A862E /* TimeValue.cpp in Sources */,
 				26D5B12A11B07550009A862E /* UUID.cpp in Sources */,
 				26D5B12B11B07550009A862E /* ScriptInterpreterNone.cpp in Sources */,
 				26D5B12C11B07550009A862E /* CommandObjectCrossref.cpp in Sources */,
@@ -2680,6 +2685,11 @@
 				491193521226386000578B7F /* ASTStructExtractor.cpp in Sources */,
 				497C86BE122823D800B54702 /* ClangUtilityFunction.cpp in Sources */,
 				49CF982A122C70BD007A0B96 /* IRDynamicChecks.cpp in Sources */,
+				69A01E211236C5D400C660B5 /* Condition.cpp in Sources */,
+				69A01E221236C5D400C660B5 /* Host.cpp in Sources */,
+				69A01E241236C5D400C660B5 /* Mutex.cpp in Sources */,
+				69A01E251236C5D400C660B5 /* Symbols.cpp in Sources */,
+				69A01E261236C5D400C660B5 /* TimeValue.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Modified: lldb/trunk/source/Host/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/Makefile?rev=113263&r1=113262&r2=113263&view=diff
==============================================================================
--- lldb/trunk/source/Host/Makefile (original)
+++ lldb/trunk/source/Host/Makefile Tue Sep  7 15:11:56 2010
@@ -11,10 +11,10 @@
 
 include $(LLDB_LEVEL)/../../Makefile.config
 
+DIRS := common
+
 ifeq ($(HOST_OS),Darwin)
-DIRS := macosx posix
-else
-DIRS := linux posix
+DIRS += macosx
 endif
 
 include $(LLDB_LEVEL)/Makefile

Added: lldb/trunk/source/Host/common/Condition.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Condition.cpp?rev=113263&view=auto
==============================================================================
--- lldb/trunk/source/Host/common/Condition.cpp (added)
+++ lldb/trunk/source/Host/common/Condition.cpp Tue Sep  7 15:11:56 2010
@@ -0,0 +1,106 @@
+//===-- Condition.cpp -------------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <errno.h>
+
+#include "lldb/Host/Condition.h"
+#include "lldb/Host/TimeValue.h"
+
+
+using namespace lldb_private;
+
+//----------------------------------------------------------------------
+// Default constructor
+//
+// The default constructor will initialize a new pthread condition
+// and maintain the condition in the object state.
+//----------------------------------------------------------------------
+Condition::Condition () :
+    m_condition()
+{
+    ::pthread_cond_init (&m_condition, NULL);
+}
+
+//----------------------------------------------------------------------
+// Destructor
+//
+// Destroys the pthread condition that the object owns.
+//----------------------------------------------------------------------
+Condition::~Condition ()
+{
+    ::pthread_cond_destroy (&m_condition);
+}
+
+//----------------------------------------------------------------------
+// Unblock all threads waiting for a condition variable
+//----------------------------------------------------------------------
+int
+Condition::Broadcast ()
+{
+    return ::pthread_cond_broadcast (&m_condition);
+}
+
+//----------------------------------------------------------------------
+// Get accessor to the pthread condition object
+//----------------------------------------------------------------------
+pthread_cond_t *
+Condition::GetCondition ()
+{
+    return &m_condition;
+}
+
+//----------------------------------------------------------------------
+// Unblocks one thread waiting for the condition variable
+//----------------------------------------------------------------------
+int
+Condition::Signal ()
+{
+    return ::pthread_cond_signal (&m_condition);
+}
+
+//----------------------------------------------------------------------
+// The Wait() function atomically blocks the current thread
+// waiting on the owend condition variable, and unblocks the mutex
+// specified by "mutex".  The waiting thread unblocks only after
+// another thread calls Signal(), or Broadcast() with the same
+// condition variable, or if "abstime" is valid (non-NULL) this
+// function will return when the system time reaches the time
+// specified in "abstime". If "abstime" is NULL this function will
+// wait for an infinite amount of time for the condition variable
+// to be signaled or broadcasted.
+//
+// The current thread re-acquires the lock on "mutex".
+//----------------------------------------------------------------------
+int
+Condition::Wait (pthread_mutex_t *mutex, const TimeValue *abstime, bool *timed_out)
+{
+    int err = 0;
+    do
+    {
+        if (abstime && abstime->IsValid())
+        {
+            struct timespec abstime_ts = abstime->GetAsTimeSpec();
+            err = ::pthread_cond_timedwait (&m_condition, mutex, &abstime_ts);
+        }
+        else
+            err = ::pthread_cond_wait (&m_condition, mutex);
+    } while (err == EINTR);
+
+    if (timed_out != NULL)
+    {
+        if (err == ETIMEDOUT)
+            *timed_out = true;
+        else
+            *timed_out = false;
+    }
+
+
+    return err;
+}
+

Added: lldb/trunk/source/Host/common/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=113263&view=auto
==============================================================================
--- lldb/trunk/source/Host/common/Host.cpp (added)
+++ lldb/trunk/source/Host/common/Host.cpp Tue Sep  7 15:11:56 2010
@@ -0,0 +1,729 @@
+//===-- Host.cpp ------------------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Host/Host.h"
+#include "lldb/Core/ArchSpec.h"
+#include "lldb/Core/ConstString.h"
+#include "lldb/Core/Error.h"
+#include "lldb/Core/FileSpec.h"
+#include "lldb/Core/Log.h"
+#include "lldb/Core/StreamString.h"
+#include "lldb/Host/Mutex.h"
+
+#include <dlfcn.h>
+#include <errno.h>
+#include <sys/sysctl.h>
+#include <sys/wait.h>
+
+#if defined (__APPLE__)
+#include <libproc.h>
+#include <mach-o/dyld.h>
+#endif
+
+using namespace lldb;
+using namespace lldb_private;
+
+struct MonitorInfo
+{
+    lldb::pid_t pid;                            // The process ID to monitor
+    Host::MonitorChildProcessCallback callback; // The callback function to call when "pid" exits or signals
+    void *callback_baton;                       // The callback baton for the callback function
+    bool monitor_signals;                       // If true, call the callback when "pid" gets signaled.
+};
+
+static void *
+MonitorChildProcessThreadFunction (void *arg);
+
+lldb::thread_t
+Host::StartMonitoringChildProcess
+(
+    Host::MonitorChildProcessCallback callback,
+    void *callback_baton,
+    lldb::pid_t pid,
+    bool monitor_signals
+)
+{
+    lldb::thread_t thread = LLDB_INVALID_HOST_THREAD;
+    if (callback)
+    {
+        std::auto_ptr<MonitorInfo> info_ap(new MonitorInfo);
+            
+        info_ap->pid = pid;
+        info_ap->callback = callback;
+        info_ap->callback_baton = callback_baton;
+        info_ap->monitor_signals = monitor_signals;
+        
+        char thread_name[256];
+        ::snprintf (thread_name, sizeof(thread_name), "<lldb.host.wait4(pid=%i)>", pid);
+        thread = ThreadCreate (thread_name,
+                               MonitorChildProcessThreadFunction,
+                               info_ap.get(),
+                               NULL);
+                               
+        if (thread != LLDB_INVALID_HOST_THREAD)
+            info_ap.release();
+    }
+    return thread;
+}
+
+//------------------------------------------------------------------
+// Scoped class that will disable thread canceling when it is
+// constructed, and exception safely restore the previous value it
+// when it goes out of scope.
+//------------------------------------------------------------------
+class ScopedPThreadCancelDisabler
+{
+public:
+    ScopedPThreadCancelDisabler()
+    {
+        // Disable the ability for this thread to be cancelled
+        int err = ::pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &m_old_state);
+        if (err != 0)
+            m_old_state = -1;
+
+    }
+
+    ~ScopedPThreadCancelDisabler()
+    {
+        // Restore the ability for this thread to be cancelled to what it
+        // previously was.
+        if (m_old_state != -1)
+            ::pthread_setcancelstate (m_old_state, 0);
+    }
+private:
+    int m_old_state;    // Save the old cancelability state.
+};
+
+static void *
+MonitorChildProcessThreadFunction (void *arg)
+{
+    Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS);
+    const char *function = __FUNCTION__;
+    if (log)
+        log->Printf ("%s (arg = %p) thread starting...", function, arg);
+
+    MonitorInfo *info = (MonitorInfo *)arg;
+
+    const Host::MonitorChildProcessCallback callback = info->callback;
+    void * const callback_baton = info->callback_baton;
+    const lldb::pid_t pid = info->pid;
+    const bool monitor_signals = info->monitor_signals;
+
+    delete info;
+
+    int status = -1;
+    const int options = 0;
+    struct rusage *rusage = NULL;
+    while (1)
+    {
+        if (log)
+            log->Printf("%s ::wait4 (pid = %i, &status, options = %i, rusage = %p)...", function, pid, options, rusage);
+
+        // Wait for all child processes
+        ::pthread_testcancel ();
+        const lldb::pid_t wait_pid = ::wait4 (pid, &status, options, rusage);
+        ::pthread_testcancel ();
+
+        if (wait_pid == -1)
+        {
+            if (errno == EINTR)
+                continue;
+            else
+                break;
+        }
+        else if (wait_pid == pid)
+        {
+            bool exited = false;
+            int signal = 0;
+            int exit_status = 0;
+            const char *status_cstr = NULL;
+            if (WIFSTOPPED(status))
+            {
+                signal = WSTOPSIG(status);
+                status_cstr = "STOPPED";
+            }
+            else if (WIFEXITED(status))
+            {
+                exit_status = WEXITSTATUS(status);
+                status_cstr = "EXITED";
+                exited = true;
+            }
+            else if (WIFSIGNALED(status))
+            {
+                signal = WTERMSIG(status);
+                status_cstr = "SIGNALED";
+                exited = true;
+                exit_status = -1;
+            }
+            else
+            {
+                status_cstr = "(???)";
+            }
+
+            // Scope for pthread_cancel_disabler
+            {
+                ScopedPThreadCancelDisabler pthread_cancel_disabler;
+
+                if (log)
+                    log->Printf ("%s ::wait4 (pid = %i, &status, options = %i, rusage = %p) => pid = %i, status = 0x%8.8x (%s), signal = %i, exit_state = %i",
+                                 function,
+                                 wait_pid,
+                                 options,
+                                 rusage,
+                                 pid,
+                                 status,
+                                 status_cstr,
+                                 signal,
+                                 exit_status);
+
+                if (exited || (signal != 0 && monitor_signals))
+                {
+                    bool callback_return = callback (callback_baton, pid, signal, exit_status);
+                    
+                    // If our process exited, then this thread should exit
+                    if (exited)
+                        break;
+                    // If the callback returns true, it means this process should
+                    // exit
+                    if (callback_return)
+                        break;
+                }
+            }
+        }
+    }
+
+    if (log)
+        log->Printf ("%s (arg = %p) thread exiting...", __FUNCTION__, arg);
+
+    return NULL;
+}
+
+size_t
+Host::GetPageSize()
+{
+    return ::getpagesize();
+}
+
+//------------------------------------------------------------------
+// Returns true if the host system is Big Endian.
+//------------------------------------------------------------------
+ByteOrder
+Host::GetByteOrder ()
+{
+    union EndianTest
+    {
+        uint32_t num;
+        uint8_t  bytes[sizeof(uint32_t)];
+    } endian = { (uint16_t)0x11223344 };
+    switch (endian.bytes[0])
+    {
+        case 0x11: return eByteOrderLittle;
+        case 0x44: return eByteOrderBig;
+        case 0x33: return eByteOrderPDP;
+    }
+    return eByteOrderInvalid;
+}
+
+const ArchSpec &
+Host::GetArchitecture ()
+{
+    static ArchSpec g_host_arch;
+    if (!g_host_arch.IsValid())
+    {
+#if defined (__APPLE__)
+        uint32_t cputype, cpusubtype;
+        uint32_t is_64_bit_capable;
+        size_t len = sizeof(cputype);
+        if  (::sysctlbyname("hw.cputype", &cputype, &len, NULL, 0) == 0)
+        {
+            len = sizeof(cpusubtype);
+            if (::sysctlbyname("hw.cpusubtype", &cpusubtype, &len, NULL, 0) == 0)
+                g_host_arch.SetArch(cputype, cpusubtype);
+            
+            len = sizeof (is_64_bit_capable);
+            if  (::sysctlbyname("hw.cpu64bit_capable", &is_64_bit_capable, &len, NULL, 0) == 0)
+            {
+                if (is_64_bit_capable)
+                {
+                    if (cputype == CPU_TYPE_I386 && cpusubtype == CPU_SUBTYPE_486)
+                        cpusubtype = CPU_SUBTYPE_I386_ALL;
+
+                    cputype |= CPU_ARCH_ABI64;
+                }
+            }
+        }
+#elif defined (__linux__)
+        g_host_arch.SetArch(7u, 144u);
+#endif
+    }
+    return g_host_arch;
+}
+
+const ConstString &
+Host::GetVendorString()
+{
+    static ConstString g_vendor;
+    if (!g_vendor)
+    {
+#if defined (__APPLE__)
+        char ostype[64];
+        size_t len = sizeof(ostype);
+        if (::sysctlbyname("kern.ostype", &ostype, &len, NULL, 0) == 0)
+            g_vendor.SetCString (ostype);
+        else
+            g_vendor.SetCString("apple");
+#elif defined (__linux__)
+        g_vendor.SetCString("gnu");
+#endif
+    }
+    return g_vendor;
+}
+
+const ConstString &
+Host::GetOSString()
+{
+    static ConstString g_os_string;
+    if (!g_os_string)
+    {
+#if defined (__APPLE__)
+        g_os_string.SetCString("darwin");
+#elif defined (__linux__)
+        g_os_string.SetCString("linux");
+#endif
+    }
+    return g_os_string;
+}
+
+const ConstString &
+Host::GetTargetTriple()
+{
+    static ConstString g_host_triple;
+    if (!(g_host_triple))
+    {
+        StreamString triple;
+        triple.Printf("%s-%s-%s", 
+                      GetArchitecture().AsCString(),
+                      GetVendorString().AsCString(),
+                      GetOSString().AsCString());
+
+        std::transform (triple.GetString().begin(), 
+                        triple.GetString().end(), 
+                        triple.GetString().begin(), 
+                        ::tolower);
+
+        g_host_triple.SetCString(triple.GetString().c_str());
+    }
+    return g_host_triple;
+}
+
+lldb::pid_t
+Host::GetCurrentProcessID()
+{
+    return ::getpid();
+}
+
+lldb::tid_t
+Host::GetCurrentThreadID()
+{
+#if defined (__APPLE__)
+    return ::mach_thread_self();
+#else
+    return lldb::tid_t(pthread_self());
+#endif
+}
+
+const char *
+Host::GetSignalAsCString (int signo)
+{
+    switch (signo)
+    {
+    case SIGHUP:    return "SIGHUP";    // 1    hangup
+    case SIGINT:    return "SIGINT";    // 2    interrupt
+    case SIGQUIT:   return "SIGQUIT";   // 3    quit
+    case SIGILL:    return "SIGILL";    // 4    illegal instruction (not reset when caught)
+    case SIGTRAP:   return "SIGTRAP";   // 5    trace trap (not reset when caught)
+    case SIGABRT:   return "SIGABRT";   // 6    abort()
+#if  defined(_POSIX_C_SOURCE)
+    case SIGPOLL:   return "SIGPOLL";   // 7    pollable event ([XSR] generated, not supported)
+#else    // !_POSIX_C_SOURCE
+    case SIGEMT:    return "SIGEMT";    // 7    EMT instruction
+#endif    // !_POSIX_C_SOURCE
+    case SIGFPE:    return "SIGFPE";    // 8    floating point exception
+    case SIGKILL:   return "SIGKILL";   // 9    kill (cannot be caught or ignored)
+    case SIGBUS:    return "SIGBUS";    // 10    bus error
+    case SIGSEGV:   return "SIGSEGV";   // 11    segmentation violation
+    case SIGSYS:    return "SIGSYS";    // 12    bad argument to system call
+    case SIGPIPE:   return "SIGPIPE";   // 13    write on a pipe with no one to read it
+    case SIGALRM:   return "SIGALRM";   // 14    alarm clock
+    case SIGTERM:   return "SIGTERM";   // 15    software termination signal from kill
+    case SIGURG:    return "SIGURG";    // 16    urgent condition on IO channel
+    case SIGSTOP:   return "SIGSTOP";   // 17    sendable stop signal not from tty
+    case SIGTSTP:   return "SIGTSTP";   // 18    stop signal from tty
+    case SIGCONT:   return "SIGCONT";   // 19    continue a stopped process
+    case SIGCHLD:   return "SIGCHLD";   // 20    to parent on child stop or exit
+    case SIGTTIN:   return "SIGTTIN";   // 21    to readers pgrp upon background tty read
+    case SIGTTOU:   return "SIGTTOU";   // 22    like TTIN for output if (tp->t_local&LTOSTOP)
+#if  !defined(_POSIX_C_SOURCE)
+    case SIGIO:     return "SIGIO";     // 23    input/output possible signal
+#endif
+    case SIGXCPU:   return "SIGXCPU";   // 24    exceeded CPU time limit
+    case SIGXFSZ:   return "SIGXFSZ";   // 25    exceeded file size limit
+    case SIGVTALRM: return "SIGVTALRM"; // 26    virtual time alarm
+    case SIGPROF:   return "SIGPROF";   // 27    profiling time alarm
+#if  !defined(_POSIX_C_SOURCE)
+    case SIGWINCH:  return "SIGWINCH";  // 28    window size changes
+    case SIGINFO:   return "SIGINFO";   // 29    information request
+#endif
+    case SIGUSR1:   return "SIGUSR1";   // 30    user defined signal 1
+    case SIGUSR2:   return "SIGUSR2";   // 31    user defined signal 2
+    default:
+        break;
+    }
+    return NULL;
+}
+
+void
+Host::WillTerminate ()
+{
+}
+
+#if !defined (__APPLE__) // see macosx/Host.mm
+void
+Host::ThreadCreated (const char *thread_name)
+{
+}
+#endif
+
+struct HostThreadCreateInfo
+{
+    std::string thread_name;
+    thread_func_t thread_fptr;
+    thread_arg_t thread_arg;
+    
+    HostThreadCreateInfo (const char *name, thread_func_t fptr, thread_arg_t arg) :
+        thread_name (name ? name : ""),
+        thread_fptr (fptr),
+        thread_arg (arg)
+    {
+    }
+};
+
+static thread_result_t
+ThreadCreateTrampoline (thread_arg_t arg)
+{
+    HostThreadCreateInfo *info = (HostThreadCreateInfo *)arg;
+    Host::ThreadCreated (info->thread_name.c_str());
+    thread_func_t thread_fptr = info->thread_fptr;
+    thread_arg_t thread_arg = info->thread_arg;
+    
+    Log * log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD);
+    if (log)
+        log->Printf("thread created");
+    
+    delete info;
+    return thread_fptr (thread_arg);
+}
+
+lldb::thread_t
+Host::ThreadCreate
+(
+    const char *thread_name,
+    thread_func_t thread_fptr,
+    thread_arg_t thread_arg,
+    Error *error
+)
+{
+    lldb::thread_t thread = LLDB_INVALID_HOST_THREAD;
+    
+    // Host::ThreadCreateTrampoline will delete this pointer for us.
+    HostThreadCreateInfo *info_ptr = new HostThreadCreateInfo (thread_name, thread_fptr, thread_arg);
+    
+    int err = ::pthread_create (&thread, NULL, ThreadCreateTrampoline, info_ptr);
+    if (err == 0)
+    {
+        if (error)
+            error->Clear();
+        return thread;
+    }
+    
+    if (error)
+        error->SetError (err, eErrorTypePOSIX);
+    
+    return LLDB_INVALID_HOST_THREAD;
+}
+
+bool
+Host::ThreadCancel (lldb::thread_t thread, Error *error)
+{
+    int err = ::pthread_cancel (thread);
+    if (error)
+        error->SetError(err, eErrorTypePOSIX);
+    return err == 0;
+}
+
+bool
+Host::ThreadDetach (lldb::thread_t thread, Error *error)
+{
+    int err = ::pthread_detach (thread);
+    if (error)
+        error->SetError(err, eErrorTypePOSIX);
+    return err == 0;
+}
+
+bool
+Host::ThreadJoin (lldb::thread_t thread, thread_result_t *thread_result_ptr, Error *error)
+{
+    int err = ::pthread_join (thread, thread_result_ptr);
+    if (error)
+        error->SetError(err, eErrorTypePOSIX);
+    return err == 0;
+}
+
+//------------------------------------------------------------------
+// Control access to a static file thread name map using a single
+// static function to avoid a static constructor.
+//------------------------------------------------------------------
+static const char *
+ThreadNameAccessor (bool get, lldb::pid_t pid, lldb::tid_t tid, const char *name)
+{
+    uint64_t pid_tid = ((uint64_t)pid << 32) | (uint64_t)tid;
+
+    static pthread_mutex_t g_mutex = PTHREAD_MUTEX_INITIALIZER;
+    Mutex::Locker locker(&g_mutex);
+
+    typedef std::map<uint64_t, std::string> thread_name_map;
+    // rdar://problem/8153284
+    // Fixed a crasher where during shutdown, loggings attempted to access the
+    // thread name but the static map instance had already been destructed.
+    // Another approach is to introduce a static guard object which monitors its
+    // own destruction and raises a flag, but this incurs more overhead.
+    static thread_name_map *g_thread_names_ptr = new thread_name_map();
+    thread_name_map &g_thread_names = *g_thread_names_ptr;
+
+    if (get)
+    {
+        // See if the thread name exists in our thread name pool
+        thread_name_map::iterator pos = g_thread_names.find(pid_tid);
+        if (pos != g_thread_names.end())
+            return pos->second.c_str();
+    }
+    else
+    {
+        // Set the thread name
+        g_thread_names[pid_tid] = name;
+    }
+    return NULL;
+}
+
+const char *
+Host::GetThreadName (lldb::pid_t pid, lldb::tid_t tid)
+{
+    const char *name = ThreadNameAccessor (true, pid, tid, NULL);
+    if (name == NULL)
+    {
+#if defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5
+        // We currently can only get the name of a thread in the current process.
+        if (pid == Host::GetCurrentProcessID())
+        {
+            char pthread_name[1024];
+            if (::pthread_getname_np (::pthread_from_mach_thread_np (tid), pthread_name, sizeof(pthread_name)) == 0)
+            {
+                if (pthread_name[0])
+                {
+                    // Set the thread in our string pool
+                    ThreadNameAccessor (false, pid, tid, pthread_name);
+                    // Get our copy of the thread name string
+                    name = ThreadNameAccessor (true, pid, tid, NULL);
+                }
+            }
+        }
+#endif
+    }
+    return name;
+}
+
+void
+Host::SetThreadName (lldb::pid_t pid, lldb::tid_t tid, const char *name)
+{
+    lldb::pid_t curr_pid = Host::GetCurrentProcessID();
+    lldb::tid_t curr_tid = Host::GetCurrentThreadID();
+    if (pid == LLDB_INVALID_PROCESS_ID)
+        pid = curr_pid;
+
+    if (tid == LLDB_INVALID_THREAD_ID)
+        tid = curr_tid;
+
+#if defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5
+    // Set the pthread name if possible
+    if (pid == curr_pid && tid == curr_tid)
+    {
+        ::pthread_setname_np (name);
+    }
+#endif
+    ThreadNameAccessor (false, pid, tid, name);
+}
+
+FileSpec
+Host::GetProgramFileSpec ()
+{
+    static FileSpec g_program_filespec;
+    if (!g_program_filespec)
+    {
+#if defined (__APPLE__)
+        char program_fullpath[PATH_MAX];
+        // If DST is NULL, then return the number of bytes needed.
+        uint32_t len = sizeof(program_fullpath);
+        int err = _NSGetExecutablePath (program_fullpath, &len);
+        if (err == 0)
+            g_program_filespec.SetFile (program_fullpath);
+        else if (err == -1)
+        {
+            char *large_program_fullpath = (char *)::malloc (len + 1);
+
+            err = _NSGetExecutablePath (large_program_fullpath, &len);
+            if (err == 0)
+                g_program_filespec.SetFile (large_program_fullpath);
+
+            ::free (large_program_fullpath);
+        }
+#elif defined (__linux__)
+        char exe_path[PATH_MAX];
+        ssize_t len = readlink("/proc/self/exe", exe_path, sizeof(exe_path));
+        if (len >= 0)
+            g_program_filespec = FileSpec(exe_path);
+#elif defined (__FreeBSD__)
+        int exe_path_mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, getpid() };
+        size_t exe_path_size;
+        if (sysctl(exe_path_mib, 4, NULL, &exe_path_size, NULL, 0) == 0)
+        {
+          char *exe_path = new char[exe_path_size];
+          if (sysctl(exe_path_mib, 4, exe_path, &exe_path_size, NULL, 0) == 0)
+              g_program_filespec = FileSpec(exe_path);
+        }
+#endif
+    }
+    return g_program_filespec;
+}
+
+FileSpec
+Host::GetModuleFileSpecForHostAddress (const void *host_addr)
+{
+    FileSpec module_filespec;
+    Dl_info info;
+    if (::dladdr (host_addr, &info))
+    {
+        if (info.dli_fname)
+            module_filespec.SetFile(info.dli_fname);
+    }
+    return module_filespec;
+}
+
+#if !defined (__APPLE__) // see Host.mm
+bool
+Host::ResolveExecutableInBundle (FileSpec *file)
+{
+  return false;
+}
+#endif
+
+uint32_t
+Host::ListProcessesMatchingName (const char *name, StringList &matches, std::vector<lldb::pid_t> &pids)
+{
+    uint32_t num_matches = 0;
+
+#if defined (__APPLE__)
+    int num_pids;
+    int size_of_pids;
+    int *pid_list;
+    
+    size_of_pids = proc_listpids(PROC_ALL_PIDS, 0, NULL, 0);
+    if (size_of_pids == -1)
+        return 0;
+        
+    num_pids = size_of_pids/sizeof(int);
+    pid_list = (int *) malloc(size_of_pids);
+    size_of_pids = proc_listpids(PROC_ALL_PIDS, 0, pid_list, size_of_pids);
+    if (size_of_pids == -1)
+        return 0;
+        
+    lldb::pid_t our_pid = getpid();
+    
+    for (int i = 0; i < num_pids; i++)
+    {
+        struct proc_bsdinfo bsd_info;
+        int error = proc_pidinfo (pid_list[i], PROC_PIDTBSDINFO, (uint64_t) 0, &bsd_info, PROC_PIDTBSDINFO_SIZE);
+        if (error == 0)
+            continue;
+        
+        // Don't offer to attach to zombie processes, already traced or exiting
+        // processes, and of course, ourselves...  It looks like passing the second arg of
+        // 0 to proc_listpids will exclude zombies anyway, but that's not documented so...
+        if (((bsd_info.pbi_flags & (PROC_FLAG_TRACED | PROC_FLAG_INEXIT)) != 0)
+             || (bsd_info.pbi_status == SZOMB)
+             || (bsd_info.pbi_pid == our_pid))
+             continue;
+        char pid_name[MAXCOMLEN * 2 + 1];
+        int name_len;
+        name_len = proc_name(bsd_info.pbi_pid, pid_name, MAXCOMLEN * 2);
+        if (name_len == 0)
+            continue;
+        
+        if (strstr(pid_name, name) != pid_name)
+            continue;
+        matches.AppendString (pid_name);
+        pids.push_back (bsd_info.pbi_pid);
+        num_matches++;        
+    }
+#endif
+    
+    return num_matches;
+}
+
+ArchSpec
+Host::GetArchSpecForExistingProcess (lldb::pid_t pid)
+{
+    ArchSpec return_spec;
+
+#if defined (__APPLE__)
+    struct proc_bsdinfo bsd_info;
+    int error = proc_pidinfo (pid, PROC_PIDTBSDINFO, (uint64_t) 0, &bsd_info, PROC_PIDTBSDINFO_SIZE);
+    if (error == 0)
+        return return_spec;
+    if (bsd_info.pbi_flags & PROC_FLAG_LP64)
+        return_spec.SetArch(LLDB_ARCH_DEFAULT_64BIT);
+    else 
+        return_spec.SetArch(LLDB_ARCH_DEFAULT_32BIT);
+#endif
+        
+    return return_spec;
+}
+
+ArchSpec
+Host::GetArchSpecForExistingProcess (const char *process_name)
+{
+    ArchSpec returnSpec;
+    StringList matches;
+    std::vector<lldb::pid_t> pids;
+    if (ListProcessesMatchingName(process_name, matches, pids))
+    {
+        if (matches.GetSize() == 1)
+        {
+            return GetArchSpecForExistingProcess(pids[0]);
+        }
+    }
+    return returnSpec;
+}
+
+#if !defined (__APPLE__) // see macosx/Host.mm
+bool
+Host::OpenFileInExternalEditor (FileSpec &file_spec, uint32_t line_no)
+{
+    return false;
+}
+#endif

Added: lldb/trunk/source/Host/common/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Makefile?rev=113263&view=auto
==============================================================================
--- lldb/trunk/source/Host/common/Makefile (added)
+++ lldb/trunk/source/Host/common/Makefile Tue Sep  7 15:11:56 2010
@@ -0,0 +1,14 @@
+##===- source/Host/common/Makefile -------------------------*- Makefile -*-===##
+# 
+#                     The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+# 
+##===----------------------------------------------------------------------===##
+
+LLDB_LEVEL := ../../..
+LIBRARYNAME := lldbHostCommon
+BUILD_ARCHIVE = 1
+
+include $(LLDB_LEVEL)/Makefile

Added: lldb/trunk/source/Host/common/Mutex.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Mutex.cpp?rev=113263&view=auto
==============================================================================
--- lldb/trunk/source/Host/common/Mutex.cpp (added)
+++ lldb/trunk/source/Host/common/Mutex.cpp Tue Sep  7 15:11:56 2010
@@ -0,0 +1,252 @@
+//===-- Mutex.cpp -----------------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Host/Mutex.h"
+
+#if 0
+// This logging is way too verbose to enable even for a log channel. 
+// This logging can be enabled by changing the "#if 0", but should be
+// reverted prior to checking in.
+#include <cstdio>
+#define DEBUG_LOG(fmt, ...) printf(fmt, ## __VA_ARGS__)
+#else
+#define DEBUG_LOG(fmt, ...)
+#endif
+
+using namespace lldb_private;
+
+//----------------------------------------------------------------------
+// Default constructor.
+//
+// This will create a scoped mutex locking object that doesn't have
+// a mutex to lock. One will need to be provided using the Reset()
+// method.
+//----------------------------------------------------------------------
+Mutex::Locker::Locker () :
+    m_mutex_ptr(NULL)
+{
+}
+
+//----------------------------------------------------------------------
+// Constructor with a Mutex object.
+//
+// This will create a scoped mutex locking object that extracts the
+// mutex owned by "m" and locks it.
+//----------------------------------------------------------------------
+Mutex::Locker::Locker (Mutex& m) :
+    m_mutex_ptr(m.GetMutex())
+{
+    if (m_mutex_ptr)
+        Mutex::Lock (m_mutex_ptr);
+}
+
+//----------------------------------------------------------------------
+// Constructor with a Mutex object pointer.
+//
+// This will create a scoped mutex locking object that extracts the
+// mutex owned by "m" and locks it.
+//----------------------------------------------------------------------
+Mutex::Locker::Locker (Mutex* m) :
+    m_mutex_ptr(m ? m->GetMutex() : NULL)
+{
+    if (m_mutex_ptr)
+        Mutex::Lock (m_mutex_ptr);
+}
+
+//----------------------------------------------------------------------
+// Constructor with a raw pthread mutex object pointer.
+//
+// This will create a scoped mutex locking object that locks "mutex"
+//----------------------------------------------------------------------
+Mutex::Locker::Locker (pthread_mutex_t *mutex_ptr) :
+    m_mutex_ptr(mutex_ptr)
+{
+    if (m_mutex_ptr)
+        Mutex::Lock (m_mutex_ptr);
+}
+
+//----------------------------------------------------------------------
+// Desstructor
+//
+// Unlocks any owned mutex object (if it is valid).
+//----------------------------------------------------------------------
+Mutex::Locker::~Locker ()
+{
+    Reset();
+}
+
+//----------------------------------------------------------------------
+// Unlock the current mutex in this object (if this owns a valid
+// mutex) and lock the new "mutex" object if it is non-NULL.
+//----------------------------------------------------------------------
+void
+Mutex::Locker::Reset (pthread_mutex_t *mutex_ptr)
+{
+    // We already have this mutex locked or both are NULL...
+    if (m_mutex_ptr == mutex_ptr)
+        return;
+
+    if (m_mutex_ptr)
+        Mutex::Unlock (m_mutex_ptr);
+
+    m_mutex_ptr = mutex_ptr;
+    if (m_mutex_ptr)
+        Mutex::Lock (m_mutex_ptr);
+}
+
+bool
+Mutex::Locker::TryLock (pthread_mutex_t *mutex_ptr)
+{
+    // We already have this mutex locked!
+    if (m_mutex_ptr == mutex_ptr)
+        return true;
+
+    Reset ();
+
+    if (mutex_ptr)
+    {
+        if (Mutex::TryLock (mutex_ptr) == 0)
+            m_mutex_ptr = mutex_ptr;
+    }
+    return m_mutex_ptr != NULL;
+}
+
+//----------------------------------------------------------------------
+// Default constructor.
+//
+// Creates a pthread mutex with no attributes.
+//----------------------------------------------------------------------
+Mutex::Mutex () :
+    m_mutex()
+{
+    int err;
+    err = ::pthread_mutex_init (&m_mutex, NULL);
+    assert(err == 0);
+}
+
+//----------------------------------------------------------------------
+// Default constructor.
+//
+// Creates a pthread mutex with "type" as the mutex type.
+//----------------------------------------------------------------------
+Mutex::Mutex (Mutex::Type type) :
+    m_mutex()
+{
+    int err;
+    ::pthread_mutexattr_t attr;
+    err = ::pthread_mutexattr_init (&attr);
+    assert(err == 0);
+    switch (type)
+    {
+    case eMutexTypeNormal:
+        err = ::pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_NORMAL);
+        break;
+
+    case eMutexTypeRecursive:
+        err = ::pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE);
+        break;
+
+    default:
+        err = -1;
+        break;
+    }
+    assert(err == 0);
+    err = ::pthread_mutex_init (&m_mutex, &attr);
+    assert(err == 0);
+    err = ::pthread_mutexattr_destroy (&attr);
+    assert(err == 0);
+}
+
+//----------------------------------------------------------------------
+// Destructor.
+//
+// Destroys the mutex owned by this object.
+//----------------------------------------------------------------------
+Mutex::~Mutex()
+{
+    int err;
+    err = ::pthread_mutex_destroy (&m_mutex);
+}
+
+//----------------------------------------------------------------------
+// Mutex get accessor.
+//----------------------------------------------------------------------
+pthread_mutex_t *
+Mutex::GetMutex()
+{
+    return &m_mutex;
+}
+
+int
+Mutex::Lock (pthread_mutex_t *mutex_ptr)
+{
+    DEBUG_LOG ("[%4.4x/%4.4x] pthread_mutex_lock (%p)...\n", Host::GetCurrentProcessID(), Host::GetCurrentThreadID(), mutex_ptr);
+    int err = ::pthread_mutex_lock (mutex_ptr);
+    DEBUG_LOG ("[%4.4x/%4.4x] pthread_mutex_lock (%p) => %i\n", Host::GetCurrentProcessID(), Host::GetCurrentThreadID(), mutex_ptr, err);
+    return err;
+}
+
+int
+Mutex::TryLock (pthread_mutex_t *mutex_ptr)
+{
+    int err = ::pthread_mutex_trylock (mutex_ptr);
+    DEBUG_LOG ("[%4.4x/%4.4x] pthread_mutex_trylock (%p) => %i\n", Host::GetCurrentProcessID(), Host::GetCurrentThreadID(), mutex_ptr, err);
+    return err;
+}
+
+int
+Mutex::Unlock (pthread_mutex_t *mutex_ptr)
+{
+    int err = ::pthread_mutex_unlock (mutex_ptr);
+    DEBUG_LOG ("[%4.4x/%4.4x] pthread_mutex_unlock (%p) => %i\n", Host::GetCurrentProcessID(), Host::GetCurrentThreadID(), mutex_ptr, err);
+    return err;
+}
+
+//----------------------------------------------------------------------
+// Locks the mutex owned by this object, if the mutex is already
+// locked, the calling thread will block until the mutex becomes
+// available.
+//
+// RETURNS
+//  The error code from the pthread_mutex_lock() function call.
+//----------------------------------------------------------------------
+int
+Mutex::Lock()
+{
+    return Mutex::Lock (&m_mutex);
+}
+
+//----------------------------------------------------------------------
+// Attempts to lock the mutex owned by this object without blocking.
+// If the mutex is already locked, TryLock() will not block waiting
+// for the mutex, but will return an error condition.
+//
+// RETURNS
+//  The error code from the pthread_mutex_trylock() function call.
+//----------------------------------------------------------------------
+int
+Mutex::TryLock()
+{
+    return Mutex::TryLock (&m_mutex);
+}
+
+//----------------------------------------------------------------------
+// If the current thread holds the lock on the owned mutex, then
+// Unlock() will unlock the mutex. Calling Unlock() on this object
+// that the calling thread does not hold will result in undefined
+// behavior.
+//
+// RETURNS
+//  The error code from the pthread_mutex_unlock() function call.
+//----------------------------------------------------------------------
+int
+Mutex::Unlock()
+{
+    return Mutex::Unlock (&m_mutex);
+}

Added: lldb/trunk/source/Host/common/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Symbols.cpp?rev=113263&view=auto
==============================================================================
--- lldb/trunk/source/Host/common/Symbols.cpp (added)
+++ lldb/trunk/source/Host/common/Symbols.cpp Tue Sep  7 15:11:56 2010
@@ -0,0 +1,31 @@
+//===-- Symbols.cpp ---------------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Host/Symbols.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+#if !defined (__APPLE__)
+
+FileSpec
+Symbols::LocateExecutableObjectFile (const FileSpec *exec_fspec, const ArchSpec* arch, const UUID *uuid)
+{
+    // FIXME
+    return FileSpec();
+}
+
+FileSpec
+Symbols::LocateExecutableSymbolFile (const FileSpec *exec_fspec, const ArchSpec* arch, const UUID *uuid)
+{
+    // FIXME
+    return FileSpec();
+}
+
+#endif

Added: lldb/trunk/source/Host/common/TimeValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/TimeValue.cpp?rev=113263&view=auto
==============================================================================
--- lldb/trunk/source/Host/common/TimeValue.cpp (added)
+++ lldb/trunk/source/Host/common/TimeValue.cpp Tue Sep  7 15:11:56 2010
@@ -0,0 +1,180 @@
+//===-- TimeValue.cpp -------------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Host/TimeValue.h"
+#include <stddef.h>
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+
+#define NSEC_PER_USEC   1000ull
+#define USEC_PER_SEC    1000000ull
+#define NSEC_PER_SEC    1000000000ull
+
+using namespace lldb_private;
+
+//----------------------------------------------------------------------
+// TimeValue constructor
+//----------------------------------------------------------------------
+TimeValue::TimeValue() :
+    m_nano_seconds (0)
+{
+}
+
+//----------------------------------------------------------------------
+// TimeValue copy constructor
+//----------------------------------------------------------------------
+TimeValue::TimeValue(const TimeValue& rhs) :
+    m_nano_seconds (rhs.m_nano_seconds)
+{
+}
+
+TimeValue::TimeValue(const struct timespec& ts) :
+    m_nano_seconds (ts.tv_sec * NSEC_PER_SEC + ts.tv_nsec)
+{
+}
+
+TimeValue::TimeValue(const struct timeval& tv) :
+    m_nano_seconds (tv.tv_sec * NSEC_PER_SEC + tv.tv_usec * NSEC_PER_USEC)
+{
+}
+
+//----------------------------------------------------------------------
+// Destructor
+//----------------------------------------------------------------------
+TimeValue::~TimeValue()
+{
+}
+
+
+uint64_t
+TimeValue::GetAsNanoSecondsSinceJan1_1970() const
+{
+    return m_nano_seconds;
+}
+
+uint64_t
+TimeValue::GetAsMicroSecondsSinceJan1_1970() const
+{
+    return m_nano_seconds / NSEC_PER_USEC;
+}
+
+struct timespec
+TimeValue::GetAsTimeSpec () const
+{
+    struct timespec ts;
+    ts.tv_sec = m_nano_seconds / NSEC_PER_SEC;
+    ts.tv_nsec = m_nano_seconds % NSEC_PER_SEC;
+    return ts;
+}
+
+struct timeval
+TimeValue::GetAsTimeVal () const
+{
+    struct timeval tv;
+    tv.tv_sec = m_nano_seconds / NSEC_PER_SEC;
+    tv.tv_usec = (m_nano_seconds % NSEC_PER_SEC) / NSEC_PER_USEC;
+    return tv;
+}
+
+void
+TimeValue::Clear ()
+{
+    m_nano_seconds = 0;
+}
+
+bool
+TimeValue::IsValid () const
+{
+    return m_nano_seconds != 0;
+}
+
+void
+TimeValue::OffsetWithSeconds (uint64_t sec)
+{
+    m_nano_seconds += sec * NSEC_PER_SEC;
+}
+
+void
+TimeValue::OffsetWithMicroSeconds (uint64_t usec)
+{
+    m_nano_seconds += usec * NSEC_PER_USEC;
+}
+
+void
+TimeValue::OffsetWithNanoSeconds (uint64_t nsec)
+{
+    m_nano_seconds += nsec;
+}
+
+TimeValue
+TimeValue::Now()
+{
+    struct timeval tv;
+    gettimeofday(&tv, NULL);
+    TimeValue now(tv);
+    return now;
+}
+
+//----------------------------------------------------------------------
+// TimeValue assignment operator
+//----------------------------------------------------------------------
+const TimeValue&
+TimeValue::operator=(const TimeValue& rhs)
+{
+    m_nano_seconds = rhs.m_nano_seconds;
+    return *this;
+}
+
+
+bool
+lldb_private::operator == (const TimeValue &lhs, const TimeValue &rhs)
+{
+    return lhs.GetAsNanoSecondsSinceJan1_1970() == rhs.GetAsNanoSecondsSinceJan1_1970();
+}
+
+bool
+lldb_private::operator != (const TimeValue &lhs, const TimeValue &rhs)
+{
+    return lhs.GetAsNanoSecondsSinceJan1_1970() != rhs.GetAsNanoSecondsSinceJan1_1970();
+}
+
+bool
+lldb_private::operator <  (const TimeValue &lhs, const TimeValue &rhs)
+{
+    return lhs.GetAsNanoSecondsSinceJan1_1970() < rhs.GetAsNanoSecondsSinceJan1_1970();
+}
+
+bool
+lldb_private::operator <= (const TimeValue &lhs, const TimeValue &rhs)
+{
+    return lhs.GetAsNanoSecondsSinceJan1_1970() <= rhs.GetAsNanoSecondsSinceJan1_1970();
+}
+
+bool
+lldb_private::operator >  (const TimeValue &lhs, const TimeValue &rhs)
+{
+    return lhs.GetAsNanoSecondsSinceJan1_1970() > rhs.GetAsNanoSecondsSinceJan1_1970();
+}
+
+bool
+lldb_private::operator >= (const TimeValue &lhs, const TimeValue &rhs)
+{
+    return lhs.GetAsNanoSecondsSinceJan1_1970() >= rhs.GetAsNanoSecondsSinceJan1_1970();
+}
+
+uint64_t
+lldb_private::operator - (const TimeValue &lhs, const TimeValue &rhs)
+{
+    return lhs.GetAsNanoSecondsSinceJan1_1970() - rhs.GetAsNanoSecondsSinceJan1_1970();
+}
+
+

Modified: lldb/trunk/source/Host/macosx/Host.mm
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=113263&r1=113262&r2=113263&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/Host.mm (original)
+++ lldb/trunk/source/Host/macosx/Host.mm Tue Sep  7 15:11:56 2010
@@ -7,163 +7,22 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include <dlfcn.h>
-#include <libgen.h>
-#include <mach/mach.h>
-#include <mach-o/dyld.h>
-#include <signal.h>
-#include <stddef.h>
-#include <sys/sysctl.h>
-#include <unistd.h>
-#include <libproc.h>
-#include <sys/proc_info.h>
-
-#include <map>
-#include <string>
-
-#include <objc/objc-auto.h>
-
-#include <Foundation/Foundation.h>
-#include <CoreServices/CoreServices.h>
-#include <Carbon/Carbon.h>
+#include "lldb/Host/Host.h"
+#include "lldb/Core/FileSpec.h"
+#include "lldb/Core/Log.h"
 
 #include "cfcpp/CFCBundle.h"
 #include "cfcpp/CFCReleaser.h"
 #include "cfcpp/CFCString.h"
 
-#include "lldb/Host/Host.h"
-#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/FileSpec.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Host/Mutex.h"
-#include "lldb/Target/Process.h"
-#include "lldb/Target/Target.h"
-#include "lldb/Target/TargetList.h"
-#include "lldb/lldb-private-log.h"
+#include <objc/objc-auto.h>
+
+#include <Carbon/Carbon.h>
+#include <Foundation/Foundation.h>
 
 using namespace lldb;
 using namespace lldb_private;
 
-//------------------------------------------------------------------
-// Return the size in bytes of a page on the host system
-//------------------------------------------------------------------
-size_t
-Host::GetPageSize()
-{
-    return ::getpagesize();
-}
-
-
-//------------------------------------------------------------------
-// Returns true if the host system is Big Endian.
-//------------------------------------------------------------------
-ByteOrder
-Host::GetByteOrder()
-{
-    union EndianTest
-    {
-        uint32_t num;
-        uint8_t  bytes[sizeof(uint32_t)];
-    } endian = { (uint16_t)0x11223344 };
-    switch (endian.bytes[0])
-    {
-    case 0x11: return eByteOrderLittle;
-    case 0x44: return eByteOrderBig;
-    case 0x33: return eByteOrderPDP;
-    }
-    return eByteOrderInvalid;
-}
-
-lldb::pid_t
-Host::GetCurrentProcessID()
-{
-    return ::getpid();
-}
-
-lldb::pid_t
-Host::GetCurrentThreadID()
-{
-    return ::mach_thread_self();
-}
-
-
-const ArchSpec &
-Host::GetArchitecture ()
-{
-    static ArchSpec g_host_arch;
-    if (!g_host_arch.IsValid())
-    {
-        uint32_t cputype, cpusubtype;
-        uint32_t is_64_bit_capable;
-        size_t len = sizeof(cputype);
-        if  (::sysctlbyname("hw.cputype", &cputype, &len, NULL, 0) == 0)
-        {
-            len = sizeof(cpusubtype);
-            if (::sysctlbyname("hw.cpusubtype", &cpusubtype, &len, NULL, 0) == 0)
-                g_host_arch.SetArch(cputype, cpusubtype);
-            
-            len = sizeof (is_64_bit_capable);
-            if  (::sysctlbyname("hw.cpu64bit_capable", &is_64_bit_capable, &len, NULL, 0) == 0)
-            {
-                if (is_64_bit_capable)
-                {
-                    if (cputype == CPU_TYPE_I386 && cpusubtype == CPU_SUBTYPE_486)
-                        cpusubtype = CPU_SUBTYPE_I386_ALL;
-
-                    cputype |= CPU_ARCH_ABI64;
-                }
-            }
-        }
-    }
-    return g_host_arch;
-}
-
-const ConstString &
-Host::GetVendorString()
-{
-    static ConstString g_vendor;
-    if (!g_vendor)
-    {
-        char ostype[64];
-        size_t len = sizeof(ostype);
-        if (::sysctlbyname("kern.ostype", &ostype, &len, NULL, 0) == 0)
-            g_vendor.SetCString (ostype);
-    }
-    return g_vendor;
-}
-
-const ConstString &
-Host::GetOSString()
-{
-    static ConstString g_os_string("apple");
-    return g_os_string;
-}
-
-const ConstString &
-Host::GetTargetTriple()
-{
-    static ConstString g_host_triple;
-    if (!(g_host_triple))
-    {
-        StreamString triple;
-        triple.Printf("%s-%s-%s", 
-                      GetArchitecture ().AsCString(),
-                      GetVendorString().AsCString("apple"),
-                      GetOSString().AsCString("darwin"));
-
-        std::transform (triple.GetString().begin(), 
-                        triple.GetString().end(), 
-                        triple.GetString().begin(), 
-                        ::tolower);
-
-        g_host_triple.SetCString(triple.GetString().c_str());
-    }
-    return g_host_triple;
-}
-
 class MacOSXDarwinThread
 {
 public:
@@ -217,92 +76,6 @@
     ::pthread_key_create (&g_thread_create_key, MacOSXDarwinThread::PThreadDestructor);
 }
 
-struct HostThreadCreateInfo
-{
-    std::string thread_name;
-    thread_func_t thread_fptr;
-    thread_arg_t thread_arg;
-
-    HostThreadCreateInfo (const char *name, thread_func_t fptr, thread_arg_t arg) :
-        thread_name (name ? name : ""),
-        thread_fptr (fptr),
-        thread_arg (arg)
-    {
-    }
-};
-
-static thread_result_t
-ThreadCreateTrampoline (thread_arg_t arg)
-{
-    HostThreadCreateInfo *info = (HostThreadCreateInfo *)arg;
-    Host::ThreadCreated (info->thread_name.c_str());
-    thread_func_t thread_fptr = info->thread_fptr;
-    thread_arg_t thread_arg = info->thread_arg;
-
-    Log * log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD);
-    if (log)
-        log->Printf("thread created");
-
-    delete info;
-    return thread_fptr (thread_arg);
-}
-
-lldb::thread_t
-Host::ThreadCreate
-(
-    const char *thread_name,
-    thread_func_t thread_fptr,
-    thread_arg_t thread_arg,
-    Error *error
-)
-{
-    lldb::thread_t thread = LLDB_INVALID_HOST_THREAD;
-
-    // Host::ThreadCreateTrampoline will delete this pointer for us.
-    HostThreadCreateInfo *info_ptr = new HostThreadCreateInfo (thread_name, thread_fptr, thread_arg);
-
-    int err = ::pthread_create (&thread, NULL, ThreadCreateTrampoline, info_ptr);
-    if (err == 0)
-    {
-        if (error)
-            error->Clear();
-        return thread;
-    }
-
-    if (error)
-        error->SetError (err, eErrorTypePOSIX);
-
-    return LLDB_INVALID_HOST_THREAD;
-}
-
-bool
-Host::ThreadCancel (lldb::thread_t thread, Error *error)
-{
-
-    int err = ::pthread_cancel (thread);
-    if (error)
-        error->SetError(err, eErrorTypePOSIX);
-    return err == 0;
-}
-
-bool
-Host::ThreadDetach (lldb::thread_t thread, Error *error)
-{
-    int err = ::pthread_detach (thread);
-    if (error)
-        error->SetError(err, eErrorTypePOSIX);
-    return err == 0;
-}
-
-bool
-Host::ThreadJoin (lldb::thread_t thread, thread_result_t *thread_result_ptr, Error *error)
-{
-    int err = ::pthread_join (thread, thread_result_ptr);
-    if (error)
-        error->SetError(err, eErrorTypePOSIX);
-    return err == 0;
-}
-
 void
 Host::ThreadCreated (const char *thread_name)
 {
@@ -313,473 +86,30 @@
     }
 }
 
-//------------------------------------------------------------------
-// Control access to a static file thread name map using a single
-// static function to avoid a static constructor.
-//------------------------------------------------------------------
-static const char *
-ThreadNameAccessor (bool get, lldb::pid_t pid, lldb::tid_t tid, const char *name)
-{
-
-    uint64_t pid_tid = ((uint64_t)pid << 32) | (uint64_t)tid;
-
-    static pthread_mutex_t g_mutex = PTHREAD_MUTEX_INITIALIZER;
-    Mutex::Locker locker(&g_mutex);
-
-    typedef std::map<uint64_t, std::string> thread_name_map;
-    // rdar://problem/8153284
-    // Fixed a crasher where during shutdown, loggings attempted to access the
-    // thread name but the static map instance had already been destructed.
-    // Another approach is to introduce a static guard object which monitors its
-    // own destruction and raises a flag, but this incurs more overhead.
-    static thread_name_map *g_thread_names_ptr = new thread_name_map();
-    thread_name_map &g_thread_names = *g_thread_names_ptr;
-
-    if (get)
-    {
-        // See if the thread name exists in our thread name pool
-        thread_name_map::iterator pos = g_thread_names.find(pid_tid);
-        if (pos != g_thread_names.end())
-            return pos->second.c_str();
-    }
-    else
-    {
-        // Set the thread name
-        g_thread_names[pid_tid] = name;
-    }
-    return NULL;
-}
-
-
-
-const char *
-Host::GetSignalAsCString (int signo)
-{
-    switch (signo)
-    {
-    case SIGHUP:    return "SIGHUP";    // 1    hangup
-    case SIGINT:    return "SIGINT";    // 2    interrupt
-    case SIGQUIT:   return "SIGQUIT";   // 3    quit
-    case SIGILL:    return "SIGILL";    // 4    illegal instruction (not reset when caught)
-    case SIGTRAP:   return "SIGTRAP";   // 5    trace trap (not reset when caught)
-    case SIGABRT:   return "SIGABRT";   // 6    abort()
-#if  defined(_POSIX_C_SOURCE)
-    case SIGPOLL:   return "SIGPOLL";   // 7    pollable event ([XSR] generated, not supported)
-#else    // !_POSIX_C_SOURCE
-    case SIGEMT:    return "SIGEMT";    // 7    EMT instruction
-#endif    // !_POSIX_C_SOURCE
-    case SIGFPE:    return "SIGFPE";    // 8    floating point exception
-    case SIGKILL:   return "SIGKILL";   // 9    kill (cannot be caught or ignored)
-    case SIGBUS:    return "SIGBUS";    // 10    bus error
-    case SIGSEGV:   return "SIGSEGV";   // 11    segmentation violation
-    case SIGSYS:    return "SIGSYS";    // 12    bad argument to system call
-    case SIGPIPE:   return "SIGPIPE";   // 13    write on a pipe with no one to read it
-    case SIGALRM:   return "SIGALRM";   // 14    alarm clock
-    case SIGTERM:   return "SIGTERM";   // 15    software termination signal from kill
-    case SIGURG:    return "SIGURG";    // 16    urgent condition on IO channel
-    case SIGSTOP:   return "SIGSTOP";   // 17    sendable stop signal not from tty
-    case SIGTSTP:   return "SIGTSTP";   // 18    stop signal from tty
-    case SIGCONT:   return "SIGCONT";   // 19    continue a stopped process
-    case SIGCHLD:   return "SIGCHLD";   // 20    to parent on child stop or exit
-    case SIGTTIN:   return "SIGTTIN";   // 21    to readers pgrp upon background tty read
-    case SIGTTOU:   return "SIGTTOU";   // 22    like TTIN for output if (tp->t_local&LTOSTOP)
-#if  !defined(_POSIX_C_SOURCE)
-    case SIGIO:     return "SIGIO";     // 23    input/output possible signal
-#endif
-    case SIGXCPU:   return "SIGXCPU";   // 24    exceeded CPU time limit
-    case SIGXFSZ:   return "SIGXFSZ";   // 25    exceeded file size limit
-    case SIGVTALRM: return "SIGVTALRM"; // 26    virtual time alarm
-    case SIGPROF:   return "SIGPROF";   // 27    profiling time alarm
-#if  !defined(_POSIX_C_SOURCE)
-    case SIGWINCH:  return "SIGWINCH";  // 28    window size changes
-    case SIGINFO:   return "SIGINFO";   // 29    information request
-#endif
-    case SIGUSR1:   return "SIGUSR1";   // 30    user defined signal 1
-    case SIGUSR2:   return "SIGUSR2";   // 31    user defined signal 2
-    default:
-        break;
-    }
-    return NULL;
-}
-
-const char *
-Host::GetThreadName (lldb::pid_t pid, lldb::tid_t tid)
-{
-    const char *name = ThreadNameAccessor (true, pid, tid, NULL);
-    if (name == NULL)
-    {
-        // We currently can only get the name of a thread in the current process.
-#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5
-        if (pid == Host::GetCurrentProcessID())
-        {
-            char pthread_name[1024];
-            if (::pthread_getname_np (::pthread_from_mach_thread_np (tid), pthread_name, sizeof(pthread_name)) == 0)
-            {
-                if (pthread_name[0])
-                {
-                    // Set the thread in our string pool
-                    ThreadNameAccessor (false, pid, tid, pthread_name);
-                    // Get our copy of the thread name string
-                    name = ThreadNameAccessor (true, pid, tid, NULL);
-                }
-            }
-        }
-#endif
-    }
-    return name;
-}
-
-void
-Host::SetThreadName (lldb::pid_t pid, lldb::tid_t tid, const char *name)
-{
-    lldb::pid_t curr_pid = Host::GetCurrentProcessID();
-    lldb::tid_t curr_tid = Host::GetCurrentThreadID();
-    if (pid == LLDB_INVALID_PROCESS_ID)
-        pid = curr_pid;
-
-    if (tid == LLDB_INVALID_THREAD_ID)
-        tid = curr_tid;
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5
-    // Set the pthread name if possible
-    if (pid == curr_pid && tid == curr_tid)
-    {
-        ::pthread_setname_np (name);
-    }
-#endif
-    ThreadNameAccessor (false, pid, tid, name);
-}
-
-FileSpec
-Host::GetProgramFileSpec ()
-{
-    static FileSpec g_program_filepsec;
-    if (!g_program_filepsec)
-    {
-        char program_fullpath[PATH_MAX];
-        // If DST is NULL, then return the number of bytes needed.
-        uint32_t len = sizeof(program_fullpath);
-        int err = _NSGetExecutablePath (program_fullpath, &len);
-        if (err == 0)
-            g_program_filepsec.SetFile (program_fullpath);
-        else if (err == -1)
-        {
-            char *large_program_fullpath = (char *)::malloc (len + 1);
-
-            err = _NSGetExecutablePath (large_program_fullpath, &len);
-            if (err == 0)
-                g_program_filepsec.SetFile (large_program_fullpath);
-
-            ::free (large_program_fullpath);
-        }
-    }
-    return g_program_filepsec;
-}
-
-
-FileSpec
-Host::GetModuleFileSpecForHostAddress (const void *host_addr)
-{
-    FileSpec module_filespec;
-    Dl_info info;
-    if (::dladdr (host_addr, &info))
-    {
-        if (info.dli_fname)
-            module_filespec.SetFile(info.dli_fname);
-    }
-    return module_filespec;
-}
-
 
 bool
 Host::ResolveExecutableInBundle (FileSpec *file)
 {
-    if (file->GetFileType () == FileSpec::eFileTypeDirectory)
-    {
-        char path[PATH_MAX];
-        if (file->GetPath(path, sizeof(path)))
-        {
-            CFCBundle bundle (path);
-            CFCReleaser<CFURLRef> url(bundle.CopyExecutableURL ());
-            if (url.get())
-            {
-                if (::CFURLGetFileSystemRepresentation (url.get(), YES, (UInt8*)path, sizeof(path)))
-                {
-                    file->SetFile(path);
-                    return true;
-                }
-            }
-        }
-    }
-    return false;
-}
-
-struct MonitorInfo
-{
-    lldb::pid_t pid;                            // The process ID to monitor
-    Host::MonitorChildProcessCallback callback; // The callback function to call when "pid" exits or signals
-    void *callback_baton;                       // The callback baton for the callback function
-    bool monitor_signals;                       // If true, call the callback when "pid" gets signaled.
-};
-
-static void *
-MonitorChildProcessThreadFunction (void *arg);
-
-lldb::thread_t
-Host::StartMonitoringChildProcess
-(
-    Host::MonitorChildProcessCallback callback,
-    void *callback_baton,
-    lldb::pid_t pid,
-    bool monitor_signals
-)
-{
-    
-    lldb::thread_t thread = LLDB_INVALID_HOST_THREAD;
-    if (callback)
-    {
-        std::auto_ptr<MonitorInfo> info_ap(new MonitorInfo);
-            
-        info_ap->pid = pid;
-        info_ap->callback = callback;
-        info_ap->callback_baton = callback_baton;
-        info_ap->monitor_signals = monitor_signals;
-        
-        char thread_name[256];
-        ::snprintf (thread_name, sizeof(thread_name), "<lldb.host.wait4(pid=%i)>", pid);
-        thread = ThreadCreate (thread_name,
-                               MonitorChildProcessThreadFunction,
-                               info_ap.get(),
-                               NULL);
-                               
-        if (thread != LLDB_INVALID_HOST_THREAD)
-            info_ap.release();
-    }
-    return thread;
-}
-
-//------------------------------------------------------------------
-// Scoped class that will disable thread canceling when it is
-// constructed, and exception safely restore the previous value it
-// when it goes out of scope.
-//------------------------------------------------------------------
-class ScopedPThreadCancelDisabler
-{
-public:
-
-    ScopedPThreadCancelDisabler()
-    {
-        // Disable the ability for this thread to be cancelled
-        int err = ::pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &m_old_state);
-        if (err != 0)
-            m_old_state = -1;
-
-    }
-
-    ~ScopedPThreadCancelDisabler()
-    {
-        // Restore the ability for this thread to be cancelled to what it
-        // previously was.
-        if (m_old_state != -1)
-            ::pthread_setcancelstate (m_old_state, 0);
-    }
-private:
-    int m_old_state;    // Save the old cancelability state.
-};
-
-
-
-static void *
-MonitorChildProcessThreadFunction (void *arg)
-{
-    Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS);
-    const char *function = __FUNCTION__;
-    if (log)
-        log->Printf ("%s (arg = %p) thread starting...", function, arg);
-
-    MonitorInfo *info = (MonitorInfo *)arg;
-
-    const Host::MonitorChildProcessCallback callback = info->callback;
-    void * const callback_baton = info->callback_baton;
-    const lldb::pid_t pid = info->pid;
-    const bool monitor_signals = info->monitor_signals;
-
-    delete info;
-
-    int status = -1;
-    const int options = 0;
-    struct rusage *rusage = NULL;
-    while (1)
-    {
-        if (log)
-            log->Printf("%s ::wait4 (pid = %i, &status, options = %i, rusage = %p)...", function, pid, options, rusage);
-
-        // Wait for all child processes
-        ::pthread_testcancel ();
-        const lldb::pid_t wait_pid = ::wait4 (pid, &status, options, rusage);
-        ::pthread_testcancel ();
-
-        if (wait_pid == -1)
-        {
-            if (errno == EINTR)
-                continue;
-            else
-                break;
-        }
-        else if (wait_pid == pid)
-        {
-            bool exited = false;
-            int signal = 0;
-            int exit_status = 0;
-            const char *status_cstr = NULL;
-            if (WIFSTOPPED(status))
-            {
-                signal = WSTOPSIG(status);
-                status_cstr = "STOPPED";
-            }
-            else if (WIFEXITED(status))
-            {
-                exit_status = WEXITSTATUS(status);
-                status_cstr = "EXITED";
-                exited = true;
-            }
-            else if (WIFSIGNALED(status))
-            {
-                signal = WTERMSIG(status);
-                status_cstr = "SIGNALED";
-                exited = true;
-                exit_status = -1;
-            }
-            else
-            {
-                status_cstr = "(???)";
-            }
-
-            // Scope for pthread_cancel_disabler
-            {
-                ScopedPThreadCancelDisabler pthread_cancel_disabler;
-
-                if (log)
-                    log->Printf ("%s ::wait4 (pid = %i, &status, options = %i, rusage = %p) => pid = %i, status = 0x%8.8x (%s), signal = %i, exit_state = %i",
-                                 function,
-                                 wait_pid,
-                                 options,
-                                 rusage,
-                                 pid,
-                                 status,
-                                 status_cstr,
-                                 signal,
-                                 exit_status);
-
-                if (exited || (signal != 0 && monitor_signals))
-                {
-                    bool callback_return = callback (callback_baton, pid, signal, exit_status);
-                    
-                    // If our process exited, then this thread should exit
-                    if (exited)
-                        break;
-                    // If the callback returns true, it means this process should
-                    // exit
-                    if (callback_return)
-                        break;
-                }
-            }
-        }
-    }
-
-    if (log)
-        log->Printf ("%s (arg = %p) thread exiting...", __FUNCTION__, arg);
-
-    return NULL;
-}
-
-void
-Host::WillTerminate ()
-{
-}
-
-uint32_t
-Host::ListProcessesMatchingName (const char *name, StringList &matches, std::vector<lldb::pid_t> &pids)
-{
-
-    int num_pids;
-    int size_of_pids;
-    int *pid_list;
-    uint32_t num_matches = 0;
-    
-    size_of_pids = proc_listpids(PROC_ALL_PIDS, 0, NULL, 0);
-    if (size_of_pids == -1)
-        return 0;
-        
-    num_pids = size_of_pids/sizeof(int);
-    pid_list = (int *) malloc(size_of_pids);
-    size_of_pids = proc_listpids(PROC_ALL_PIDS, 0, pid_list, size_of_pids);
-    if (size_of_pids == -1)
-        return 0;
-        
-    lldb::pid_t our_pid = getpid();
-    
-    for (int i = 0; i < num_pids; i++)
-    {
-        struct proc_bsdinfo bsd_info;
-        int error = proc_pidinfo (pid_list[i], PROC_PIDTBSDINFO, (uint64_t) 0, &bsd_info, PROC_PIDTBSDINFO_SIZE);
-        if (error == 0)
-            continue;
-        
-        // Don't offer to attach to zombie processes, already traced or exiting
-        // processes, and of course, ourselves...  It looks like passing the second arg of
-        // 0 to proc_listpids will exclude zombies anyway, but that's not documented so...
-        if (((bsd_info.pbi_flags & (PROC_FLAG_TRACED | PROC_FLAG_INEXIT)) != 0)
-             || (bsd_info.pbi_status == SZOMB)
-             || (bsd_info.pbi_pid == our_pid))
-             continue;
-        char pid_name[MAXCOMLEN * 2 + 1];
-        int name_len;
-        name_len = proc_name(bsd_info.pbi_pid, pid_name, MAXCOMLEN * 2);
-        if (name_len == 0)
-            continue;
-        
-        if (strstr(pid_name, name) != pid_name)
-            continue;
-        matches.AppendString (pid_name);
-        pids.push_back (bsd_info.pbi_pid);
-        num_matches++;        
-    }
-    
-    return num_matches;
-}
-
-ArchSpec
-Host::GetArchSpecForExistingProcess (lldb::pid_t pid)
-{
-    ArchSpec return_spec;
-    
-    struct proc_bsdinfo bsd_info;
-    int error = proc_pidinfo (pid, PROC_PIDTBSDINFO, (uint64_t) 0, &bsd_info, PROC_PIDTBSDINFO_SIZE);
-    if (error == 0)
-        return return_spec;
-    if (bsd_info.pbi_flags & PROC_FLAG_LP64)
-        return_spec.SetArch(LLDB_ARCH_DEFAULT_64BIT);
-    else 
-        return_spec.SetArch(LLDB_ARCH_DEFAULT_32BIT);
-        
-    return return_spec;
-}
-
-ArchSpec
-Host::GetArchSpecForExistingProcess (const char *process_name)
-{
-    ArchSpec returnSpec;
-    StringList matches;
-    std::vector<lldb::pid_t> pids;
-    if (ListProcessesMatchingName(process_name, matches, pids))
-    {
-        if (matches.GetSize() == 1)
+#if defined (__APPLE__)
+  if (file->GetFileType () == FileSpec::eFileTypeDirectory)
+  {
+    char path[PATH_MAX];
+    if (file->GetPath(path, sizeof(path)))
+    {
+      CFCBundle bundle (path);
+      CFCReleaser<CFURLRef> url(bundle.CopyExecutableURL ());
+      if (url.get())
+      {
+        if (::CFURLGetFileSystemRepresentation (url.get(), YES, (UInt8*)path, sizeof(path)))
         {
-            return GetArchSpecForExistingProcess(pids[0]);
+          file->SetFile(path);
+          return true;
         }
+      }
     }
-    return returnSpec;
+  }
+#endif
+  return false;
 }
 
 bool

Removed: lldb/trunk/source/Host/macosx/TimeValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/TimeValue.cpp?rev=113262&view=auto
==============================================================================
--- lldb/trunk/source/Host/macosx/TimeValue.cpp (original)
+++ lldb/trunk/source/Host/macosx/TimeValue.cpp (removed)
@@ -1,180 +0,0 @@
-//===-- TimeValue.cpp -------------------------------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/Host/TimeValue.h"
-#include <stddef.h>
-
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-
-#define NSEC_PER_USEC   1000ull
-#define USEC_PER_SEC    1000000ull
-#define NSEC_PER_SEC    1000000000ull
-
-using namespace lldb_private;
-
-//----------------------------------------------------------------------
-// TimeValue constructor
-//----------------------------------------------------------------------
-TimeValue::TimeValue() :
-    m_nano_seconds (0)
-{
-}
-
-//----------------------------------------------------------------------
-// TimeValue copy constructor
-//----------------------------------------------------------------------
-TimeValue::TimeValue(const TimeValue& rhs) :
-    m_nano_seconds (rhs.m_nano_seconds)
-{
-}
-
-TimeValue::TimeValue(const struct timespec& ts) :
-    m_nano_seconds (ts.tv_sec * NSEC_PER_SEC + ts.tv_nsec)
-{
-}
-
-TimeValue::TimeValue(const struct timeval& tv) :
-    m_nano_seconds (tv.tv_sec * NSEC_PER_SEC + tv.tv_usec * NSEC_PER_USEC)
-{
-}
-
-//----------------------------------------------------------------------
-// Destructor
-//----------------------------------------------------------------------
-TimeValue::~TimeValue()
-{
-}
-
-
-uint64_t
-TimeValue::GetAsNanoSecondsSinceJan1_1970() const
-{
-    return m_nano_seconds;
-}
-
-uint64_t
-TimeValue::GetAsMicroSecondsSinceJan1_1970() const
-{
-    return m_nano_seconds / NSEC_PER_USEC;
-}
-
-struct timespec
-TimeValue::GetAsTimeSpec () const
-{
-    struct timespec ts;
-    ts.tv_sec = m_nano_seconds / NSEC_PER_SEC;
-    ts.tv_nsec = m_nano_seconds % NSEC_PER_SEC;
-    return ts;
-}
-
-struct timeval
-TimeValue::GetAsTimeVal () const
-{
-    struct timeval tv;
-    tv.tv_sec = m_nano_seconds / NSEC_PER_SEC;
-    tv.tv_usec = (m_nano_seconds % NSEC_PER_SEC) / NSEC_PER_USEC;
-    return tv;
-}
-
-void
-TimeValue::Clear ()
-{
-    m_nano_seconds = 0;
-}
-
-bool
-TimeValue::IsValid () const
-{
-    return m_nano_seconds != 0;
-}
-
-void
-TimeValue::OffsetWithSeconds (uint64_t sec)
-{
-    m_nano_seconds += sec * NSEC_PER_SEC;
-}
-
-void
-TimeValue::OffsetWithMicroSeconds (uint64_t usec)
-{
-    m_nano_seconds += usec * NSEC_PER_USEC;
-}
-
-void
-TimeValue::OffsetWithNanoSeconds (uint64_t nsec)
-{
-    m_nano_seconds += nsec;
-}
-
-TimeValue
-TimeValue::Now()
-{
-    struct timeval tv;
-    gettimeofday(&tv, NULL);
-    TimeValue now(tv);
-    return now;
-}
-
-//----------------------------------------------------------------------
-// TimeValue assignment operator
-//----------------------------------------------------------------------
-const TimeValue&
-TimeValue::operator=(const TimeValue& rhs)
-{
-    m_nano_seconds = rhs.m_nano_seconds;
-    return *this;
-}
-
-
-bool
-lldb_private::operator == (const TimeValue &lhs, const TimeValue &rhs)
-{
-    return lhs.GetAsNanoSecondsSinceJan1_1970() == rhs.GetAsNanoSecondsSinceJan1_1970();
-}
-
-bool
-lldb_private::operator != (const TimeValue &lhs, const TimeValue &rhs)
-{
-    return lhs.GetAsNanoSecondsSinceJan1_1970() != rhs.GetAsNanoSecondsSinceJan1_1970();
-}
-
-bool
-lldb_private::operator <  (const TimeValue &lhs, const TimeValue &rhs)
-{
-    return lhs.GetAsNanoSecondsSinceJan1_1970() < rhs.GetAsNanoSecondsSinceJan1_1970();
-}
-
-bool
-lldb_private::operator <= (const TimeValue &lhs, const TimeValue &rhs)
-{
-    return lhs.GetAsNanoSecondsSinceJan1_1970() <= rhs.GetAsNanoSecondsSinceJan1_1970();
-}
-
-bool
-lldb_private::operator >  (const TimeValue &lhs, const TimeValue &rhs)
-{
-    return lhs.GetAsNanoSecondsSinceJan1_1970() > rhs.GetAsNanoSecondsSinceJan1_1970();
-}
-
-bool
-lldb_private::operator >= (const TimeValue &lhs, const TimeValue &rhs)
-{
-    return lhs.GetAsNanoSecondsSinceJan1_1970() >= rhs.GetAsNanoSecondsSinceJan1_1970();
-}
-
-uint64_t
-lldb_private::operator - (const TimeValue &lhs, const TimeValue &rhs)
-{
-    return lhs.GetAsNanoSecondsSinceJan1_1970() - rhs.GetAsNanoSecondsSinceJan1_1970();
-}
-
-





More information about the lldb-commits mailing list