aboutsummaryrefslogtreecommitdiff
path: root/include/lldb/Utility
diff options
context:
space:
mode:
Diffstat (limited to 'include/lldb/Utility')
-rw-r--r--include/lldb/Utility/CleanUp.h6
-rw-r--r--include/lldb/Utility/PseudoTerminal.h4
-rw-r--r--include/lldb/Utility/SafeMachO.h113
-rw-r--r--include/lldb/Utility/SharedCluster.h23
-rw-r--r--include/lldb/Utility/SharingPtr.h15
-rw-r--r--include/lldb/Utility/StringLexer.h62
6 files changed, 201 insertions, 22 deletions
diff --git a/include/lldb/Utility/CleanUp.h b/include/lldb/Utility/CleanUp.h
index ab15d1999b7d..9dd3ca5fe12b 100644
--- a/include/lldb/Utility/CleanUp.h
+++ b/include/lldb/Utility/CleanUp.h
@@ -27,7 +27,7 @@ namespace lldb_utility {
// file descriptors, opaque handles, pointers, etc). If more complex
// type T objects are desired, we need to probably specialize this class
// to take "const T&" for all input T parameters. Yet if a type T is
-// complex already it might be better to build the cleanup funcionality
+// complex already it might be better to build the cleanup functionality
// into T.
//
// The cleanup function must take one argument that is of type T.
@@ -163,7 +163,7 @@ public:
//----------------------------------------------------------------------
// Cancels the cleanup that would have been called on "m_current_value"
// if it was valid. This function can be used to release the value
- // contained in this object so ownership can be transfered to the caller.
+ // contained in this object so ownership can be transferred to the caller.
//----------------------------------------------------------------------
value_type
release ()
@@ -296,7 +296,7 @@ public:
//----------------------------------------------------------------------
// Cancels the cleanup that would have been called on "m_current_value"
// if it was valid. This function can be used to release the value
- // contained in this object so ownership can be transfered to the caller.
+ // contained in this object so ownership can be transferred to the caller.
//----------------------------------------------------------------------
value_type
release ()
diff --git a/include/lldb/Utility/PseudoTerminal.h b/include/lldb/Utility/PseudoTerminal.h
index c79800fab75c..6ee598cefe08 100644
--- a/include/lldb/Utility/PseudoTerminal.h
+++ b/include/lldb/Utility/PseudoTerminal.h
@@ -23,7 +23,7 @@ namespace lldb_utility {
/// @class PseudoTerminal PseudoTerminal.h "lldb/Core/PseudoTerminal.h"
/// @brief A pseudo terminal helper class.
///
-/// The pseudo terminal class abtracts the use of pseudo terminals on
+/// The pseudo terminal class abstracts the use of pseudo terminals on
/// the host system.
//----------------------------------------------------------------------
class PseudoTerminal
@@ -46,7 +46,7 @@ public:
/// Destructor
///
/// The destructor will close the master and slave file descriptors
- /// if they are valid and ownwership has not been released using
+ /// if they are valid and ownership has not been released using
/// one of:
/// @li PseudoTerminal::ReleaseMasterFileDescriptor()
/// @li PseudoTerminal::ReleaseSaveFileDescriptor()
diff --git a/include/lldb/Utility/SafeMachO.h b/include/lldb/Utility/SafeMachO.h
new file mode 100644
index 000000000000..2a831ed89b80
--- /dev/null
+++ b/include/lldb/Utility/SafeMachO.h
@@ -0,0 +1,113 @@
+//===-- SafeMachO.h -----------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+#ifndef liblldb_SafeMachO_h_
+#define liblldb_SafeMachO_h_
+
+// This header file is required to work around collisions between the defines in mach/machine.h, and enum members
+// of the same name in llvm's MachO.h. If you want to use llvm/Support/MachO.h, use this file instead.
+// The caveats are:
+// 1) You can only use the MachO.h enums, you can't use the defines. That won't make a difference since the values
+// are the same.
+// 2) If you need any header file that relies on mach/machine.h, you must include that first.
+// 3) This isn't a total solution, it doesn't undef every define that MachO.h has borrowed from various system headers,
+// only the ones that come from mach/machine.h because that is the one we ended up pulling in from various places.
+//
+
+#undef CPU_ARCH_MASK
+#undef CPU_ARCH_ABI64
+
+#undef CPU_TYPE_ANY
+#undef CPU_TYPE_X86
+#undef CPU_TYPE_I386
+#undef CPU_TYPE_X86_64
+#undef CPU_TYPE_MC98000
+#undef CPU_TYPE_ARM
+#undef CPU_TYPE_ARM64
+#undef CPU_TYPE_SPARC
+#undef CPU_TYPE_POWERPC
+#undef CPU_TYPE_POWERPC64
+
+#undef CPU_SUB_TYPE_MASK
+#undef CPU_SUB_TYPE_LIB64
+
+#undef CPU_SUBTYPE_MULTIPLE
+
+#undef CPU_SUBTYPE_I386_ALL
+#undef CPU_SUBTYPE_386
+#undef CPU_SUBTYPE_486
+#undef CPU_SUBTYPE_486SX
+#undef CPU_SUBTYPE_586
+#undef CPU_SUBTYPE_PENT
+#undef CPU_SUBTYPE_PENTPRO
+#undef CPU_SUBTYPE_PENTII_M3
+#undef CPU_SUBTYPE_PENTII_M5
+#undef CPU_SUBTYPE_CELERON
+#undef CPU_SUBTYPE_CELERON_MOBILE
+#undef CPU_SUBTYPE_PENTIUM_3
+#undef CPU_SUBTYPE_PENTIUM_3_M
+#undef CPU_SUBTYPE_PENTIUM_3_XEON
+#undef CPU_SUBTYPE_PENTIUM_M
+#undef CPU_SUBTYPE_PENTIUM_4
+#undef CPU_SUBTYPE_PENTIUM_4_M
+#undef CPU_SUBTYPE_ITANIUM
+#undef CPU_SUBTYPE_ITANIUM_2
+#undef CPU_SUBTYPE_XEON
+#undef CPU_SUBTYPE_XEON_MP
+
+#undef CPU_SUBTYPE_X86_ALL
+#undef CPU_SUBTYPE_X86_64_ALL
+#undef CPU_SUBTYPE_X86_ARCH1
+#undef CPU_SUBTYPE_X86_64_H
+
+#undef CPU_SUBTYPE_INTEL
+#undef CPU_SUBTYPE_INTEL_FAMILY
+#undef CPU_SUBTYPE_INTEL_FAMILY_MAX
+#undef CPU_SUBTYPE_INTEL_MODEL
+#undef CPU_SUBTYPE_INTEL_MODEL_ALL
+
+#undef CPU_SUBTYPE_ARM
+#undef CPU_SUBTYPE_ARM_ALL
+#undef CPU_SUBTYPE_ARM_V4T
+#undef CPU_SUBTYPE_ARM_V6
+#undef CPU_SUBTYPE_ARM_V5
+#undef CPU_SUBTYPE_ARM_V5TEJ
+#undef CPU_SUBTYPE_ARM_XSCALE
+#undef CPU_SUBTYPE_ARM_V7
+
+#undef CPU_SUBTYPE_ARM_V7S
+#undef CPU_SUBTYPE_ARM_V7K
+#undef CPU_SUBTYPE_ARM_V6M
+#undef CPU_SUBTYPE_ARM_V7M
+#undef CPU_SUBTYPE_ARM_V7EM
+
+#undef CPU_SUBTYPE_ARM64_ALL
+
+#undef CPU_SUBTYPE_SPARC_ALL
+
+#undef CPU_SUBTYPE_POWERPC
+#undef CPU_SUBTYPE_POWERPC_ALL
+#undef CPU_SUBTYPE_POWERPC_601
+#undef CPU_SUBTYPE_POWERPC_602
+#undef CPU_SUBTYPE_POWERPC_603
+#undef CPU_SUBTYPE_POWERPC_603e
+#undef CPU_SUBTYPE_POWERPC_603ev
+#undef CPU_SUBTYPE_POWERPC_604
+#undef CPU_SUBTYPE_POWERPC_604e
+#undef CPU_SUBTYPE_POWERPC_620
+#undef CPU_SUBTYPE_POWERPC_750
+#undef CPU_SUBTYPE_POWERPC_7400
+#undef CPU_SUBTYPE_POWERPC_7450
+#undef CPU_SUBTYPE_POWERPC_970
+
+#undef CPU_SUBTYPE_MC980000_ALL
+#undef CPU_SUBTYPE_MC98601
+
+#include "llvm/Support/MachO.h"
+
+#endif // liblldb_SafeMachO_h_
diff --git a/include/lldb/Utility/SharedCluster.h b/include/lldb/Utility/SharedCluster.h
index 991af4b4fa49..3a34d8ddb415 100644
--- a/include/lldb/Utility/SharedCluster.h
+++ b/include/lldb/Utility/SharedCluster.h
@@ -13,6 +13,8 @@
#include "lldb/Utility/SharingPtr.h"
#include "lldb/Host/Mutex.h"
+#include "llvm/ADT/SmallPtrSet.h"
+
namespace lldb_private {
namespace imp
@@ -50,11 +52,12 @@ public:
~ClusterManager ()
{
- size_t n_items = m_objects.size();
- for (size_t i = 0; i < n_items; i++)
+ for (typename llvm::SmallPtrSet<T *, 16>::iterator pos = m_objects.begin(), end = m_objects.end(); pos != end; ++pos)
{
- delete m_objects[i];
+ T *object = *pos;
+ delete object;
}
+
// Decrement refcount should have been called on this ClusterManager,
// and it should have locked the mutex, now we will unlock it before
// we destroy it...
@@ -64,8 +67,7 @@ public:
void ManageObject (T *new_object)
{
Mutex::Locker locker (m_mutex);
- if (!ContainsObject(new_object))
- m_objects.push_back (new_object);
+ m_objects.insert (new_object);
}
typename lldb_private::SharingPtr<T> GetSharedPointer(T *desired_object)
@@ -73,20 +75,13 @@ public:
{
Mutex::Locker locker (m_mutex);
m_external_ref++;
- assert (ContainsObject(desired_object));
+ assert (m_objects.count(desired_object));
}
return typename lldb_private::SharingPtr<T> (desired_object, new imp::shared_ptr_refcount<ClusterManager> (this));
}
private:
- bool ContainsObject (const T *desired_object)
- {
- typename std::vector<T *>::iterator pos, end = m_objects.end();
- pos = std::find(m_objects.begin(), end, desired_object);
- return pos != end;
- }
-
void DecrementRefCount ()
{
m_mutex.Lock();
@@ -99,7 +94,7 @@ private:
friend class imp::shared_ptr_refcount<ClusterManager>;
- std::vector<T *> m_objects;
+ llvm::SmallPtrSet<T *, 16> m_objects;
int m_external_ref;
Mutex m_mutex;
};
diff --git a/include/lldb/Utility/SharingPtr.h b/include/lldb/Utility/SharingPtr.h
index c451ee6e3593..1b5f86bbe2df 100644
--- a/include/lldb/Utility/SharingPtr.h
+++ b/include/lldb/Utility/SharingPtr.h
@@ -15,7 +15,7 @@
// Microsoft Visual C++ currently does not enable std::atomic to work
// in CLR mode - as such we need to "hack around it" for MSVC++ builds only
-// using Windows specific instrinsics instead of the C++11 atomic support
+// using Windows specific intrinsics instead of the C++11 atomic support
#ifdef _MSC_VER
#include <intrin.h>
#else
@@ -69,8 +69,8 @@ public:
private:
virtual void on_zero_shared();
- // Outlaw copy constructor and assignment operator to keep effictive C++
- // warnings down to a minumum
+ // Outlaw copy constructor and assignment operator to keep effective C++
+ // warnings down to a minimum
shared_ptr_pointer (const shared_ptr_pointer &);
shared_ptr_pointer & operator=(const shared_ptr_pointer &);
};
@@ -138,6 +138,7 @@ private:
struct nat {int for_bool_;};
public:
SharingPtr();
+ SharingPtr(std::nullptr_t);
template<class Y> explicit SharingPtr(Y* p);
template<class Y> explicit SharingPtr(Y* p, imp::shared_count *ctrl_block);
template<class Y> SharingPtr(const SharingPtr<Y>& r, element_type *p);
@@ -191,6 +192,14 @@ SharingPtr<T>::SharingPtr()
cntrl_(0)
{
}
+
+template<class T>
+inline
+SharingPtr<T>::SharingPtr(std::nullptr_t)
+: ptr_(0),
+cntrl_(0)
+{
+}
template<class T>
template<class Y>
diff --git a/include/lldb/Utility/StringLexer.h b/include/lldb/Utility/StringLexer.h
new file mode 100644
index 000000000000..42c169c5cf94
--- /dev/null
+++ b/include/lldb/Utility/StringLexer.h
@@ -0,0 +1,62 @@
+//===--------------------- StringLexer.h -------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef utility_StringLexer_h_
+#define utility_StringLexer_h_
+
+#include <string>
+#include <list>
+
+namespace lldb_utility {
+
+class StringLexer
+{
+public:
+ typedef std::string::size_type Position;
+ typedef std::string::size_type Size;
+
+ typedef std::string::value_type Character;
+
+ StringLexer (std::string s);
+
+ StringLexer (const StringLexer& rhs);
+
+ Character
+ Peek ();
+
+ bool
+ NextIf (Character c);
+
+ Character
+ Next ();
+
+ bool
+ HasAtLeast (Size s);
+
+ bool
+ HasAny (Character c);
+
+ void
+ PutBack (Character c);
+
+ StringLexer&
+ operator = (const StringLexer& rhs);
+
+private:
+ std::string m_data;
+ Position m_position;
+ std::list<Character> m_putback_data;
+
+ void
+ Consume();
+};
+
+} // namespace lldb_private
+
+#endif // #ifndef utility_StringLexer_h_