[Lldb-commits] [lldb] r280751 - *** This commit represents a complete reformatting of the LLDB source code

Kate Stone via lldb-commits lldb-commits at lists.llvm.org
Tue Sep 6 13:58:36 PDT 2016


Modified: lldb/trunk/source/Symbol/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Type.cpp (original)
+++ lldb/trunk/source/Symbol/Type.cpp Tue Sep  6 15:57:50 2016
@@ -13,8 +13,8 @@
 // C++ Includes
 // Other libraries and framework includes
 // Project includes
-#include "lldb/Core/DataExtractor.h"
 #include "lldb/Core/DataBufferHeap.h"
+#include "lldb/Core/DataExtractor.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/Scalar.h"
 #include "lldb/Core/StreamString.h"
@@ -40,1339 +40,1076 @@
 using namespace lldb;
 using namespace lldb_private;
 
-void
-CompilerContext::Dump() const
-{
-    switch (type)
-    {
-        case CompilerContextKind::Invalid:          printf("Invalid"); break;
-        case CompilerContextKind::TranslationUnit:  printf("TranslationUnit"); break;
-        case CompilerContextKind::Module:           printf("Module"); break;
-        case CompilerContextKind::Namespace:        printf("Namespace"); break;
-        case CompilerContextKind::Class:            printf("Class"); break;
-        case CompilerContextKind::Structure:        printf("Structure"); break;
-        case CompilerContextKind::Union:            printf("Union"); break;
-        case CompilerContextKind::Function:         printf("Function"); break;
-        case CompilerContextKind::Variable:         printf("Variable"); break;
-        case CompilerContextKind::Enumeration:      printf("Enumeration"); break;
-        case CompilerContextKind::Typedef:          printf("Typedef"); break;
-    }
-    printf("(\"%s\")\n", name.GetCString());
+void CompilerContext::Dump() const {
+  switch (type) {
+  case CompilerContextKind::Invalid:
+    printf("Invalid");
+    break;
+  case CompilerContextKind::TranslationUnit:
+    printf("TranslationUnit");
+    break;
+  case CompilerContextKind::Module:
+    printf("Module");
+    break;
+  case CompilerContextKind::Namespace:
+    printf("Namespace");
+    break;
+  case CompilerContextKind::Class:
+    printf("Class");
+    break;
+  case CompilerContextKind::Structure:
+    printf("Structure");
+    break;
+  case CompilerContextKind::Union:
+    printf("Union");
+    break;
+  case CompilerContextKind::Function:
+    printf("Function");
+    break;
+  case CompilerContextKind::Variable:
+    printf("Variable");
+    break;
+  case CompilerContextKind::Enumeration:
+    printf("Enumeration");
+    break;
+  case CompilerContextKind::Typedef:
+    printf("Typedef");
+    break;
+  }
+  printf("(\"%s\")\n", name.GetCString());
 }
 
-class TypeAppendVisitor
-{
+class TypeAppendVisitor {
 public:
-    TypeAppendVisitor(TypeListImpl &type_list) :
-        m_type_list(type_list)
-    {
-    }
-    
-    bool
-    operator() (const lldb::TypeSP& type)
-    {
-        m_type_list.Append(TypeImplSP(new TypeImpl(type)));
-        return true;
-    }
-    
-private:
-    TypeListImpl &m_type_list;
-};
-
-void
-TypeListImpl::Append (const lldb_private::TypeList &type_list)
-{
-    TypeAppendVisitor cb(*this);
-    type_list.ForEach(cb);
-}
-
-SymbolFileType::SymbolFileType (SymbolFile &symbol_file, const lldb::TypeSP &type_sp) :
-    UserID (type_sp ? type_sp->GetID() : LLDB_INVALID_UID),
-    m_symbol_file (symbol_file),
-    m_type_sp (type_sp)
-{
-}
-
-
-Type *
-SymbolFileType::GetType ()
-{
-    if (!m_type_sp)
-    {
-        Type *resolved_type = m_symbol_file.ResolveTypeUID (GetID());
-        if (resolved_type)
-            m_type_sp = resolved_type->shared_from_this();
-    }
-    return m_type_sp.get();
-}
-
-
-Type::Type
-(
-    lldb::user_id_t uid,
-    SymbolFile* symbol_file,
-    const ConstString &name,
-    uint64_t byte_size,
-    SymbolContextScope *context,
-    user_id_t encoding_uid,
-    EncodingDataType encoding_uid_type,
-    const Declaration& decl,
-    const CompilerType &compiler_type,
-    ResolveState compiler_type_resolve_state
-) :
-    std::enable_shared_from_this<Type> (),
-    UserID (uid),
-    m_name (name),
-    m_symbol_file (symbol_file),
-    m_context (context),
-    m_encoding_type (nullptr),
-    m_encoding_uid (encoding_uid),
-    m_encoding_uid_type (encoding_uid_type),
-    m_byte_size (byte_size),
-    m_decl (decl),
-    m_compiler_type (compiler_type)
-{
-    m_flags.compiler_type_resolve_state = (compiler_type ? compiler_type_resolve_state : eResolveStateUnresolved);
-    m_flags.is_complete_objc_class = false;
-}
-
-Type::Type () :
-    std::enable_shared_from_this<Type> (),
-    UserID (0),
-    m_name ("<INVALID TYPE>"),
-    m_symbol_file (nullptr),
-    m_context (nullptr),
-    m_encoding_type (nullptr),
-    m_encoding_uid (LLDB_INVALID_UID),
-    m_encoding_uid_type (eEncodingInvalid),
-    m_byte_size (0),
-    m_decl (),
-    m_compiler_type ()
-{
-    m_flags.compiler_type_resolve_state = eResolveStateUnresolved;
-    m_flags.is_complete_objc_class = false;
-}
-
-
-Type::Type (const Type &rhs) :
-    std::enable_shared_from_this<Type> (rhs),
-    UserID (rhs),
-    m_name (rhs.m_name),
-    m_symbol_file (rhs.m_symbol_file),
-    m_context (rhs.m_context),
-    m_encoding_type (rhs.m_encoding_type),
-    m_encoding_uid (rhs.m_encoding_uid),
-    m_encoding_uid_type (rhs.m_encoding_uid_type),
-    m_byte_size (rhs.m_byte_size),
-    m_decl (rhs.m_decl),
-    m_compiler_type (rhs.m_compiler_type),
-    m_flags (rhs.m_flags)
-{
-}
-
-const Type&
-Type::operator= (const Type& rhs)
-{
-    if (this != &rhs)
-    {
-    }
-    return *this;
-}
-
-
-void
-Type::GetDescription (Stream *s, lldb::DescriptionLevel level, bool show_name)
-{
-    *s << "id = " << (const UserID&)*this;
-
-    // Call the name accessor to make sure we resolve the type name
-    if (show_name)
-    {
-        const ConstString &type_name = GetName();
-        if (type_name)
-        {
-            *s << ", name = \"" << type_name << '"';
-            ConstString qualified_type_name (GetQualifiedName());
-            if (qualified_type_name != type_name)
-            {
-                *s << ", qualified = \"" << qualified_type_name << '"';
-            }
-        }
-    }
-
-    // Call the get byte size accesor so we resolve our byte size
-    if (GetByteSize())
-        s->Printf(", byte-size = %" PRIu64, m_byte_size);
-    bool show_fullpaths = (level == lldb::eDescriptionLevelVerbose);
-    m_decl.Dump(s, show_fullpaths);
+  TypeAppendVisitor(TypeListImpl &type_list) : m_type_list(type_list) {}
 
-    if (m_compiler_type.IsValid())
-    {
-        *s << ", compiler_type = \"";
-        GetForwardCompilerType ().DumpTypeDescription(s);
-        *s << '"';
-    }
-    else if (m_encoding_uid != LLDB_INVALID_UID)
-    {
-        s->Printf(", type_uid = 0x%8.8" PRIx64, m_encoding_uid);
-        switch (m_encoding_uid_type)
-        {
-        case eEncodingInvalid: break;
-        case eEncodingIsUID: s->PutCString(" (unresolved type)"); break;
-        case eEncodingIsConstUID: s->PutCString(" (unresolved const type)"); break;
-        case eEncodingIsRestrictUID: s->PutCString(" (unresolved restrict type)"); break;
-        case eEncodingIsVolatileUID: s->PutCString(" (unresolved volatile type)"); break;
-        case eEncodingIsTypedefUID: s->PutCString(" (unresolved typedef)"); break;
-        case eEncodingIsPointerUID: s->PutCString(" (unresolved pointer)"); break;
-        case eEncodingIsLValueReferenceUID: s->PutCString(" (unresolved L value reference)"); break;
-        case eEncodingIsRValueReferenceUID: s->PutCString(" (unresolved R value reference)"); break;
-        case eEncodingIsSyntheticUID: s->PutCString(" (synthetic type)"); break;
-        }
-    }    
-}
-
-
-void
-Type::Dump (Stream *s, bool show_context)
-{
-    s->Printf("%p: ", static_cast<void*>(this));
-    s->Indent();
-    *s << "Type" << static_cast<const UserID&>(*this) << ' ';
-    if (m_name)
-        *s << ", name = \"" << m_name << "\"";
-
-    if (m_byte_size != 0)
-        s->Printf(", size = %" PRIu64, m_byte_size);
+  bool operator()(const lldb::TypeSP &type) {
+    m_type_list.Append(TypeImplSP(new TypeImpl(type)));
+    return true;
+  }
 
-    if (show_context && m_context != nullptr)
-    {
-        s->PutCString(", context = ( ");
-        m_context->DumpSymbolContext(s);
-        s->PutCString(" )");
-    }
+private:
+  TypeListImpl &m_type_list;
+};
 
-    bool show_fullpaths = false;
-    m_decl.Dump (s,show_fullpaths);
+void TypeListImpl::Append(const lldb_private::TypeList &type_list) {
+  TypeAppendVisitor cb(*this);
+  type_list.ForEach(cb);
+}
+
+SymbolFileType::SymbolFileType(SymbolFile &symbol_file,
+                               const lldb::TypeSP &type_sp)
+    : UserID(type_sp ? type_sp->GetID() : LLDB_INVALID_UID),
+      m_symbol_file(symbol_file), m_type_sp(type_sp) {}
+
+Type *SymbolFileType::GetType() {
+  if (!m_type_sp) {
+    Type *resolved_type = m_symbol_file.ResolveTypeUID(GetID());
+    if (resolved_type)
+      m_type_sp = resolved_type->shared_from_this();
+  }
+  return m_type_sp.get();
+}
+
+Type::Type(lldb::user_id_t uid, SymbolFile *symbol_file,
+           const ConstString &name, uint64_t byte_size,
+           SymbolContextScope *context, user_id_t encoding_uid,
+           EncodingDataType encoding_uid_type, const Declaration &decl,
+           const CompilerType &compiler_type,
+           ResolveState compiler_type_resolve_state)
+    : std::enable_shared_from_this<Type>(), UserID(uid), m_name(name),
+      m_symbol_file(symbol_file), m_context(context), m_encoding_type(nullptr),
+      m_encoding_uid(encoding_uid), m_encoding_uid_type(encoding_uid_type),
+      m_byte_size(byte_size), m_decl(decl), m_compiler_type(compiler_type) {
+  m_flags.compiler_type_resolve_state =
+      (compiler_type ? compiler_type_resolve_state : eResolveStateUnresolved);
+  m_flags.is_complete_objc_class = false;
+}
+
+Type::Type()
+    : std::enable_shared_from_this<Type>(), UserID(0), m_name("<INVALID TYPE>"),
+      m_symbol_file(nullptr), m_context(nullptr), m_encoding_type(nullptr),
+      m_encoding_uid(LLDB_INVALID_UID), m_encoding_uid_type(eEncodingInvalid),
+      m_byte_size(0), m_decl(), m_compiler_type() {
+  m_flags.compiler_type_resolve_state = eResolveStateUnresolved;
+  m_flags.is_complete_objc_class = false;
+}
+
+Type::Type(const Type &rhs)
+    : std::enable_shared_from_this<Type>(rhs), UserID(rhs), m_name(rhs.m_name),
+      m_symbol_file(rhs.m_symbol_file), m_context(rhs.m_context),
+      m_encoding_type(rhs.m_encoding_type), m_encoding_uid(rhs.m_encoding_uid),
+      m_encoding_uid_type(rhs.m_encoding_uid_type),
+      m_byte_size(rhs.m_byte_size), m_decl(rhs.m_decl),
+      m_compiler_type(rhs.m_compiler_type), m_flags(rhs.m_flags) {}
+
+const Type &Type::operator=(const Type &rhs) {
+  if (this != &rhs) {
+  }
+  return *this;
+}
+
+void Type::GetDescription(Stream *s, lldb::DescriptionLevel level,
+                          bool show_name) {
+  *s << "id = " << (const UserID &)*this;
+
+  // Call the name accessor to make sure we resolve the type name
+  if (show_name) {
+    const ConstString &type_name = GetName();
+    if (type_name) {
+      *s << ", name = \"" << type_name << '"';
+      ConstString qualified_type_name(GetQualifiedName());
+      if (qualified_type_name != type_name) {
+        *s << ", qualified = \"" << qualified_type_name << '"';
+      }
+    }
+  }
+
+  // Call the get byte size accesor so we resolve our byte size
+  if (GetByteSize())
+    s->Printf(", byte-size = %" PRIu64, m_byte_size);
+  bool show_fullpaths = (level == lldb::eDescriptionLevelVerbose);
+  m_decl.Dump(s, show_fullpaths);
+
+  if (m_compiler_type.IsValid()) {
+    *s << ", compiler_type = \"";
+    GetForwardCompilerType().DumpTypeDescription(s);
+    *s << '"';
+  } else if (m_encoding_uid != LLDB_INVALID_UID) {
+    s->Printf(", type_uid = 0x%8.8" PRIx64, m_encoding_uid);
+    switch (m_encoding_uid_type) {
+    case eEncodingInvalid:
+      break;
+    case eEncodingIsUID:
+      s->PutCString(" (unresolved type)");
+      break;
+    case eEncodingIsConstUID:
+      s->PutCString(" (unresolved const type)");
+      break;
+    case eEncodingIsRestrictUID:
+      s->PutCString(" (unresolved restrict type)");
+      break;
+    case eEncodingIsVolatileUID:
+      s->PutCString(" (unresolved volatile type)");
+      break;
+    case eEncodingIsTypedefUID:
+      s->PutCString(" (unresolved typedef)");
+      break;
+    case eEncodingIsPointerUID:
+      s->PutCString(" (unresolved pointer)");
+      break;
+    case eEncodingIsLValueReferenceUID:
+      s->PutCString(" (unresolved L value reference)");
+      break;
+    case eEncodingIsRValueReferenceUID:
+      s->PutCString(" (unresolved R value reference)");
+      break;
+    case eEncodingIsSyntheticUID:
+      s->PutCString(" (synthetic type)");
+      break;
+    }
+  }
+}
+
+void Type::Dump(Stream *s, bool show_context) {
+  s->Printf("%p: ", static_cast<void *>(this));
+  s->Indent();
+  *s << "Type" << static_cast<const UserID &>(*this) << ' ';
+  if (m_name)
+    *s << ", name = \"" << m_name << "\"";
+
+  if (m_byte_size != 0)
+    s->Printf(", size = %" PRIu64, m_byte_size);
+
+  if (show_context && m_context != nullptr) {
+    s->PutCString(", context = ( ");
+    m_context->DumpSymbolContext(s);
+    s->PutCString(" )");
+  }
+
+  bool show_fullpaths = false;
+  m_decl.Dump(s, show_fullpaths);
+
+  if (m_compiler_type.IsValid()) {
+    *s << ", compiler_type = " << m_compiler_type.GetOpaqueQualType() << ' ';
+    GetForwardCompilerType().DumpTypeDescription(s);
+  } else if (m_encoding_uid != LLDB_INVALID_UID) {
+    *s << ", type_data = " << (uint64_t)m_encoding_uid;
+    switch (m_encoding_uid_type) {
+    case eEncodingInvalid:
+      break;
+    case eEncodingIsUID:
+      s->PutCString(" (unresolved type)");
+      break;
+    case eEncodingIsConstUID:
+      s->PutCString(" (unresolved const type)");
+      break;
+    case eEncodingIsRestrictUID:
+      s->PutCString(" (unresolved restrict type)");
+      break;
+    case eEncodingIsVolatileUID:
+      s->PutCString(" (unresolved volatile type)");
+      break;
+    case eEncodingIsTypedefUID:
+      s->PutCString(" (unresolved typedef)");
+      break;
+    case eEncodingIsPointerUID:
+      s->PutCString(" (unresolved pointer)");
+      break;
+    case eEncodingIsLValueReferenceUID:
+      s->PutCString(" (unresolved L value reference)");
+      break;
+    case eEncodingIsRValueReferenceUID:
+      s->PutCString(" (unresolved R value reference)");
+      break;
+    case eEncodingIsSyntheticUID:
+      s->PutCString(" (synthetic type)");
+      break;
+    }
+  }
+
+  //
+  //  if (m_access)
+  //      s->Printf(", access = %u", m_access);
+  s->EOL();
+}
+
+const ConstString &Type::GetName() {
+  if (!m_name)
+    m_name = GetForwardCompilerType().GetConstTypeName();
+  return m_name;
+}
+
+void Type::DumpTypeName(Stream *s) { GetName().Dump(s, "<invalid-type-name>"); }
+
+void Type::DumpValue(ExecutionContext *exe_ctx, Stream *s,
+                     const DataExtractor &data, uint32_t data_byte_offset,
+                     bool show_types, bool show_summary, bool verbose,
+                     lldb::Format format) {
+  if (ResolveClangType(eResolveStateForward)) {
+    if (show_types) {
+      s->PutChar('(');
+      if (verbose)
+        s->Printf("Type{0x%8.8" PRIx64 "} ", GetID());
+      DumpTypeName(s);
+      s->PutCString(") ");
+    }
+
+    GetForwardCompilerType().DumpValue(
+        exe_ctx, s, format == lldb::eFormatDefault ? GetFormat() : format, data,
+        data_byte_offset, GetByteSize(),
+        0, // Bitfield bit size
+        0, // Bitfield bit offset
+        show_types, show_summary, verbose, 0);
+  }
+}
+
+Type *Type::GetEncodingType() {
+  if (m_encoding_type == nullptr && m_encoding_uid != LLDB_INVALID_UID)
+    m_encoding_type = m_symbol_file->ResolveTypeUID(m_encoding_uid);
+  return m_encoding_type;
+}
+
+uint64_t Type::GetByteSize() {
+  if (m_byte_size == 0) {
+    switch (m_encoding_uid_type) {
+    case eEncodingInvalid:
+    case eEncodingIsSyntheticUID:
+      break;
+    case eEncodingIsUID:
+    case eEncodingIsConstUID:
+    case eEncodingIsRestrictUID:
+    case eEncodingIsVolatileUID:
+    case eEncodingIsTypedefUID: {
+      Type *encoding_type = GetEncodingType();
+      if (encoding_type)
+        m_byte_size = encoding_type->GetByteSize();
+      if (m_byte_size == 0)
+        m_byte_size = GetLayoutCompilerType().GetByteSize(nullptr);
+    } break;
+
+    // If we are a pointer or reference, then this is just a pointer size;
+    case eEncodingIsPointerUID:
+    case eEncodingIsLValueReferenceUID:
+    case eEncodingIsRValueReferenceUID: {
+      ArchSpec arch;
+      if (m_symbol_file->GetObjectFile()->GetArchitecture(arch))
+        m_byte_size = arch.GetAddressByteSize();
+    } break;
+    }
+  }
+  return m_byte_size;
+}
+
+uint32_t Type::GetNumChildren(bool omit_empty_base_classes) {
+  return GetForwardCompilerType().GetNumChildren(omit_empty_base_classes);
+}
+
+bool Type::IsAggregateType() {
+  return GetForwardCompilerType().IsAggregateType();
+}
+
+lldb::TypeSP Type::GetTypedefType() {
+  lldb::TypeSP type_sp;
+  if (IsTypedef()) {
+    Type *typedef_type = m_symbol_file->ResolveTypeUID(m_encoding_uid);
+    if (typedef_type)
+      type_sp = typedef_type->shared_from_this();
+  }
+  return type_sp;
+}
+
+lldb::Format Type::GetFormat() { return GetForwardCompilerType().GetFormat(); }
+
+lldb::Encoding Type::GetEncoding(uint64_t &count) {
+  // Make sure we resolve our type if it already hasn't been.
+  return GetForwardCompilerType().GetEncoding(count);
+}
+
+bool Type::DumpValueInMemory(ExecutionContext *exe_ctx, Stream *s,
+                             lldb::addr_t address, AddressType address_type,
+                             bool show_types, bool show_summary, bool verbose) {
+  if (address != LLDB_INVALID_ADDRESS) {
+    DataExtractor data;
+    Target *target = nullptr;
+    if (exe_ctx)
+      target = exe_ctx->GetTargetPtr();
+    if (target)
+      data.SetByteOrder(target->GetArchitecture().GetByteOrder());
+    if (ReadFromMemory(exe_ctx, address, address_type, data)) {
+      DumpValue(exe_ctx, s, data, 0, show_types, show_summary, verbose);
+      return true;
+    }
+  }
+  return false;
+}
+
+bool Type::ReadFromMemory(ExecutionContext *exe_ctx, lldb::addr_t addr,
+                          AddressType address_type, DataExtractor &data) {
+  if (address_type == eAddressTypeFile) {
+    // Can't convert a file address to anything valid without more
+    // context (which Module it came from)
+    return false;
+  }
 
+  const uint64_t byte_size = GetByteSize();
+  if (data.GetByteSize() < byte_size) {
+    lldb::DataBufferSP data_sp(new DataBufferHeap(byte_size, '\0'));
+    data.SetData(data_sp);
+  }
+
+  uint8_t *dst = const_cast<uint8_t *>(data.PeekData(0, byte_size));
+  if (dst != nullptr) {
+    if (address_type == eAddressTypeHost) {
+      // The address is an address in this process, so just copy it
+      if (addr == 0)
+        return false;
+      memcpy(dst, (uint8_t *)nullptr + addr, byte_size);
+      return true;
+    } else {
+      if (exe_ctx) {
+        Process *process = exe_ctx->GetProcessPtr();
+        if (process) {
+          Error error;
+          return exe_ctx->GetProcessPtr()->ReadMemory(addr, dst, byte_size,
+                                                      error) == byte_size;
+        }
+      }
+    }
+  }
+  return false;
+}
+
+bool Type::WriteToMemory(ExecutionContext *exe_ctx, lldb::addr_t addr,
+                         AddressType address_type, DataExtractor &data) {
+  return false;
+}
+
+TypeList *Type::GetTypeList() { return GetSymbolFile()->GetTypeList(); }
+
+const Declaration &Type::GetDeclaration() const { return m_decl; }
+
+bool Type::ResolveClangType(ResolveState compiler_type_resolve_state) {
+  // TODO: This needs to consider the correct type system to use.
+  Type *encoding_type = nullptr;
+  if (!m_compiler_type.IsValid()) {
+    encoding_type = GetEncodingType();
+    if (encoding_type) {
+      switch (m_encoding_uid_type) {
+      case eEncodingIsUID: {
+        CompilerType encoding_compiler_type =
+            encoding_type->GetForwardCompilerType();
+        if (encoding_compiler_type.IsValid()) {
+          m_compiler_type = encoding_compiler_type;
+          m_flags.compiler_type_resolve_state =
+              encoding_type->m_flags.compiler_type_resolve_state;
+        }
+      } break;
+
+      case eEncodingIsConstUID:
+        m_compiler_type =
+            encoding_type->GetForwardCompilerType().AddConstModifier();
+        break;
+
+      case eEncodingIsRestrictUID:
+        m_compiler_type =
+            encoding_type->GetForwardCompilerType().AddRestrictModifier();
+        break;
+
+      case eEncodingIsVolatileUID:
+        m_compiler_type =
+            encoding_type->GetForwardCompilerType().AddVolatileModifier();
+        break;
+
+      case eEncodingIsTypedefUID:
+        m_compiler_type = encoding_type->GetForwardCompilerType().CreateTypedef(
+            m_name.AsCString("__lldb_invalid_typedef_name"),
+            GetSymbolFile()->GetDeclContextContainingUID(GetID()));
+        m_name.Clear();
+        break;
+
+      case eEncodingIsPointerUID:
+        m_compiler_type =
+            encoding_type->GetForwardCompilerType().GetPointerType();
+        break;
+
+      case eEncodingIsLValueReferenceUID:
+        m_compiler_type =
+            encoding_type->GetForwardCompilerType().GetLValueReferenceType();
+        break;
+
+      case eEncodingIsRValueReferenceUID:
+        m_compiler_type =
+            encoding_type->GetForwardCompilerType().GetRValueReferenceType();
+        break;
+
+      default:
+        assert(!"Unhandled encoding_data_type.");
+        break;
+      }
+    } else {
+      // We have no encoding type, return void?
+      TypeSystem *type_system =
+          m_symbol_file->GetTypeSystemForLanguage(eLanguageTypeC);
+      CompilerType void_compiler_type =
+          type_system->GetBasicTypeFromAST(eBasicTypeVoid);
+      switch (m_encoding_uid_type) {
+      case eEncodingIsUID:
+        m_compiler_type = void_compiler_type;
+        break;
+
+      case eEncodingIsConstUID:
+        m_compiler_type = void_compiler_type.AddConstModifier();
+        break;
+
+      case eEncodingIsRestrictUID:
+        m_compiler_type = void_compiler_type.AddRestrictModifier();
+        break;
+
+      case eEncodingIsVolatileUID:
+        m_compiler_type = void_compiler_type.AddVolatileModifier();
+        break;
+
+      case eEncodingIsTypedefUID:
+        m_compiler_type = void_compiler_type.CreateTypedef(
+            m_name.AsCString("__lldb_invalid_typedef_name"),
+            GetSymbolFile()->GetDeclContextContainingUID(GetID()));
+        break;
+
+      case eEncodingIsPointerUID:
+        m_compiler_type = void_compiler_type.GetPointerType();
+        break;
+
+      case eEncodingIsLValueReferenceUID:
+        m_compiler_type = void_compiler_type.GetLValueReferenceType();
+        break;
+
+      case eEncodingIsRValueReferenceUID:
+        m_compiler_type = void_compiler_type.GetRValueReferenceType();
+        break;
+
+      default:
+        assert(!"Unhandled encoding_data_type.");
+        break;
+      }
+    }
+
+    // When we have a EncodingUID, our "m_flags.compiler_type_resolve_state" is
+    // set to eResolveStateUnresolved
+    // so we need to update it to say that we now have a forward declaration
+    // since that is what we created
+    // above.
     if (m_compiler_type.IsValid())
-    {
-        *s << ", compiler_type = " << m_compiler_type.GetOpaqueQualType() << ' ';
-        GetForwardCompilerType ().DumpTypeDescription (s);
-    }
-    else if (m_encoding_uid != LLDB_INVALID_UID)
-    {
-        *s << ", type_data = " << (uint64_t)m_encoding_uid;
-        switch (m_encoding_uid_type)
-        {
-        case eEncodingInvalid: break;
-        case eEncodingIsUID: s->PutCString(" (unresolved type)"); break;
-        case eEncodingIsConstUID: s->PutCString(" (unresolved const type)"); break;
-        case eEncodingIsRestrictUID: s->PutCString(" (unresolved restrict type)"); break;
-        case eEncodingIsVolatileUID: s->PutCString(" (unresolved volatile type)"); break;
-        case eEncodingIsTypedefUID: s->PutCString(" (unresolved typedef)"); break;
-        case eEncodingIsPointerUID: s->PutCString(" (unresolved pointer)"); break;
-        case eEncodingIsLValueReferenceUID: s->PutCString(" (unresolved L value reference)"); break;
-        case eEncodingIsRValueReferenceUID: s->PutCString(" (unresolved R value reference)"); break;
-        case eEncodingIsSyntheticUID: s->PutCString(" (synthetic type)"); break;
-        }
-    }
-
-//
-//  if (m_access)
-//      s->Printf(", access = %u", m_access);
-    s->EOL();
-}
-
-const ConstString &
-Type::GetName()
-{
-    if (!m_name)
-        m_name = GetForwardCompilerType ().GetConstTypeName();
-    return m_name;
-}
-
-void
-Type::DumpTypeName(Stream *s)
-{
-    GetName().Dump(s, "<invalid-type-name>");
-}
-
-
-void
-Type::DumpValue
-(
-    ExecutionContext *exe_ctx,
-    Stream *s,
-    const DataExtractor &data,
-    uint32_t data_byte_offset,
-    bool show_types,
-    bool show_summary,
-    bool verbose,
-    lldb::Format format
-)
-{
-    if (ResolveClangType(eResolveStateForward))
-    {
-        if (show_types)
-        {
-            s->PutChar('(');
-            if (verbose)
-                s->Printf("Type{0x%8.8" PRIx64 "} ", GetID());
-            DumpTypeName (s);
-            s->PutCString(") ");
-        }
-
-        GetForwardCompilerType ().DumpValue (exe_ctx,
-                                         s,
-                                         format == lldb::eFormatDefault ? GetFormat() : format,
-                                         data,
-                                         data_byte_offset,
-                                         GetByteSize(),
-                                         0, // Bitfield bit size
-                                         0, // Bitfield bit offset
-                                         show_types,
-                                         show_summary,
-                                         verbose,
-                                         0);
-    }
-}
+      m_flags.compiler_type_resolve_state = eResolveStateForward;
+  }
 
-Type *
-Type::GetEncodingType ()
-{
-    if (m_encoding_type == nullptr && m_encoding_uid != LLDB_INVALID_UID)
-        m_encoding_type = m_symbol_file->ResolveTypeUID(m_encoding_uid);
-    return m_encoding_type;
-}
-    
-
-
-uint64_t
-Type::GetByteSize()
-{
-    if (m_byte_size == 0)
-    {
-        switch (m_encoding_uid_type)
-        {
-        case eEncodingInvalid:
-        case eEncodingIsSyntheticUID:
-            break;
-        case eEncodingIsUID:
-        case eEncodingIsConstUID:
-        case eEncodingIsRestrictUID:
-        case eEncodingIsVolatileUID:
-        case eEncodingIsTypedefUID:
-            {
-                Type *encoding_type = GetEncodingType ();
-                if (encoding_type)
-                    m_byte_size = encoding_type->GetByteSize();
-                if (m_byte_size == 0)
-                    m_byte_size = GetLayoutCompilerType ().GetByteSize(nullptr);
-            }
-            break;
+  // Check if we have a forward reference to a class/struct/union/enum?
+  if (compiler_type_resolve_state == eResolveStateLayout ||
+      compiler_type_resolve_state == eResolveStateFull) {
+    // Check if we have a forward reference to a class/struct/union/enum?
+    if (m_compiler_type.IsValid() &&
+        m_flags.compiler_type_resolve_state < compiler_type_resolve_state) {
+      m_flags.compiler_type_resolve_state = eResolveStateFull;
+      if (!m_compiler_type.IsDefined()) {
+        // We have a forward declaration, we need to resolve it to a complete
+        // definition.
+        m_symbol_file->CompleteType(m_compiler_type);
+      }
+    }
+  }
+
+  // If we have an encoding type, then we need to make sure it is
+  // resolved appropriately.
+  if (m_encoding_uid != LLDB_INVALID_UID) {
+    if (encoding_type == nullptr)
+      encoding_type = GetEncodingType();
+    if (encoding_type) {
+      ResolveState encoding_compiler_type_resolve_state =
+          compiler_type_resolve_state;
 
-        // If we are a pointer or reference, then this is just a pointer size;
+      if (compiler_type_resolve_state == eResolveStateLayout) {
+        switch (m_encoding_uid_type) {
         case eEncodingIsPointerUID:
         case eEncodingIsLValueReferenceUID:
         case eEncodingIsRValueReferenceUID:
-            {
-                ArchSpec arch;
-                if (m_symbol_file->GetObjectFile()->GetArchitecture(arch))
-                    m_byte_size = arch.GetAddressByteSize();
-            }
-            break;
-        }
-    }
-    return m_byte_size;
-}
-
-
-uint32_t
-Type::GetNumChildren (bool omit_empty_base_classes)
-{
-    return GetForwardCompilerType ().GetNumChildren(omit_empty_base_classes);
-}
-
-bool
-Type::IsAggregateType ()
-{
-    return GetForwardCompilerType ().IsAggregateType();
-}
-
-lldb::TypeSP
-Type::GetTypedefType()
-{
-    lldb::TypeSP type_sp;
-    if (IsTypedef())
-    {
-        Type *typedef_type = m_symbol_file->ResolveTypeUID(m_encoding_uid);
-        if (typedef_type)
-            type_sp = typedef_type->shared_from_this();
+          encoding_compiler_type_resolve_state = eResolveStateForward;
+          break;
+        default:
+          break;
+        }
+      }
+      encoding_type->ResolveClangType(encoding_compiler_type_resolve_state);
+    }
+  }
+  return m_compiler_type.IsValid();
+}
+uint32_t Type::GetEncodingMask() {
+  uint32_t encoding_mask = 1u << m_encoding_uid_type;
+  Type *encoding_type = GetEncodingType();
+  assert(encoding_type != this);
+  if (encoding_type)
+    encoding_mask |= encoding_type->GetEncodingMask();
+  return encoding_mask;
+}
+
+CompilerType Type::GetFullCompilerType() {
+  ResolveClangType(eResolveStateFull);
+  return m_compiler_type;
+}
+
+CompilerType Type::GetLayoutCompilerType() {
+  ResolveClangType(eResolveStateLayout);
+  return m_compiler_type;
+}
+
+CompilerType Type::GetForwardCompilerType() {
+  ResolveClangType(eResolveStateForward);
+  return m_compiler_type;
+}
+
+int Type::Compare(const Type &a, const Type &b) {
+  // Just compare the UID values for now...
+  lldb::user_id_t a_uid = a.GetID();
+  lldb::user_id_t b_uid = b.GetID();
+  if (a_uid < b_uid)
+    return -1;
+  if (a_uid > b_uid)
+    return 1;
+  return 0;
+}
+
+ConstString Type::GetQualifiedName() {
+  return GetForwardCompilerType().GetConstTypeName();
+}
+
+bool Type::GetTypeScopeAndBasename(const char *&name_cstr, std::string &scope,
+                                   std::string &basename,
+                                   TypeClass &type_class) {
+  // Protect against null c string.
+
+  type_class = eTypeClassAny;
+
+  if (name_cstr && name_cstr[0]) {
+    llvm::StringRef name_strref(name_cstr);
+    if (name_strref.startswith("struct ")) {
+      name_cstr += 7;
+      type_class = eTypeClassStruct;
+    } else if (name_strref.startswith("class ")) {
+      name_cstr += 6;
+      type_class = eTypeClassClass;
+    } else if (name_strref.startswith("union ")) {
+      name_cstr += 6;
+      type_class = eTypeClassUnion;
+    } else if (name_strref.startswith("enum ")) {
+      name_cstr += 5;
+      type_class = eTypeClassEnumeration;
+    } else if (name_strref.startswith("typedef ")) {
+      name_cstr += 8;
+      type_class = eTypeClassTypedef;
+    }
+    const char *basename_cstr = name_cstr;
+    const char *namespace_separator = ::strstr(basename_cstr, "::");
+    if (namespace_separator) {
+      const char *template_arg_char = ::strchr(basename_cstr, '<');
+      while (namespace_separator != nullptr) {
+        if (template_arg_char &&
+            namespace_separator > template_arg_char) // but namespace'd template
+                                                     // arguments are still good
+                                                     // to go
+          break;
+        basename_cstr = namespace_separator + 2;
+        namespace_separator = strstr(basename_cstr, "::");
+      }
+      if (basename_cstr > name_cstr) {
+        scope.assign(name_cstr, basename_cstr - name_cstr);
+        basename.assign(basename_cstr);
+        return true;
+      }
     }
-    return type_sp;
+  }
+  return false;
 }
 
-
-
-lldb::Format
-Type::GetFormat ()
-{
-    return GetForwardCompilerType ().GetFormat();
+ModuleSP Type::GetModule() {
+  if (m_symbol_file)
+    return m_symbol_file->GetObjectFile()->GetModule();
+  return ModuleSP();
 }
 
+TypeAndOrName::TypeAndOrName() : m_type_pair(), m_type_name() {}
 
-
-lldb::Encoding
-Type::GetEncoding (uint64_t &count)
-{
-    // Make sure we resolve our type if it already hasn't been.
-    return GetForwardCompilerType ().GetEncoding(count);
+TypeAndOrName::TypeAndOrName(TypeSP &in_type_sp) : m_type_pair(in_type_sp) {
+  if (in_type_sp)
+    m_type_name = in_type_sp->GetName();
 }
 
-bool
-Type::DumpValueInMemory
-(
-    ExecutionContext *exe_ctx,
-    Stream *s,
-    lldb::addr_t address,
-    AddressType address_type,
-    bool show_types,
-    bool show_summary,
-    bool verbose
-)
-{
-    if (address != LLDB_INVALID_ADDRESS)
-    {
-        DataExtractor data;
-        Target *target = nullptr;
-        if (exe_ctx)
-            target = exe_ctx->GetTargetPtr();
-        if (target)
-            data.SetByteOrder (target->GetArchitecture().GetByteOrder());
-        if (ReadFromMemory (exe_ctx, address, address_type, data))
-        {
-            DumpValue(exe_ctx, s, data, 0, show_types, show_summary, verbose);
-            return true;
-        }
-    }
-    return false;
-}
+TypeAndOrName::TypeAndOrName(const char *in_type_str)
+    : m_type_name(in_type_str) {}
 
+TypeAndOrName::TypeAndOrName(const TypeAndOrName &rhs)
+    : m_type_pair(rhs.m_type_pair), m_type_name(rhs.m_type_name) {}
 
-bool
-Type::ReadFromMemory (ExecutionContext *exe_ctx, lldb::addr_t addr, AddressType address_type, DataExtractor &data)
-{
-    if (address_type == eAddressTypeFile)
-    {
-        // Can't convert a file address to anything valid without more
-        // context (which Module it came from)
-        return false;
-    }
+TypeAndOrName::TypeAndOrName(ConstString &in_type_const_string)
+    : m_type_name(in_type_const_string) {}
 
-    const uint64_t byte_size = GetByteSize();
-    if (data.GetByteSize() < byte_size)
-    {
-        lldb::DataBufferSP data_sp(new DataBufferHeap (byte_size, '\0'));
-        data.SetData(data_sp);
-    }
-
-    uint8_t* dst = const_cast<uint8_t*>(data.PeekData(0, byte_size));
-    if (dst != nullptr)
-    {
-        if (address_type == eAddressTypeHost)
-        {
-            // The address is an address in this process, so just copy it
-            if (addr == 0)
-                return false;
-            memcpy (dst, (uint8_t*)nullptr + addr, byte_size);
-            return true;
-        }
-        else
-        {
-            if (exe_ctx)
-            {
-                Process *process = exe_ctx->GetProcessPtr();
-                if (process)
-                {
-                    Error error;
-                    return exe_ctx->GetProcessPtr()->ReadMemory(addr, dst, byte_size, error) == byte_size;
-                }
-            }
-        }
-    }
-    return false;
+TypeAndOrName &TypeAndOrName::operator=(const TypeAndOrName &rhs) {
+  if (this != &rhs) {
+    m_type_name = rhs.m_type_name;
+    m_type_pair = rhs.m_type_pair;
+  }
+  return *this;
 }
 
-
-bool
-Type::WriteToMemory (ExecutionContext *exe_ctx, lldb::addr_t addr, AddressType address_type, DataExtractor &data)
-{
+bool TypeAndOrName::operator==(const TypeAndOrName &other) const {
+  if (m_type_pair != other.m_type_pair)
     return false;
-}
-
-
-TypeList*
-Type::GetTypeList()
-{
-    return GetSymbolFile()->GetTypeList();
-}
-
-const Declaration &
-Type::GetDeclaration () const
-{
-    return m_decl;
-}
-
-bool
-Type::ResolveClangType (ResolveState compiler_type_resolve_state)
-{
-    // TODO: This needs to consider the correct type system to use.
-    Type *encoding_type = nullptr;
-    if (!m_compiler_type.IsValid())
-    {
-        encoding_type = GetEncodingType();
-        if (encoding_type)
-        {
-            switch (m_encoding_uid_type)
-            {
-            case eEncodingIsUID:
-                {
-                    CompilerType encoding_compiler_type = encoding_type->GetForwardCompilerType ();
-                    if (encoding_compiler_type.IsValid())
-                    {
-                        m_compiler_type = encoding_compiler_type;
-                        m_flags.compiler_type_resolve_state = encoding_type->m_flags.compiler_type_resolve_state;
-                    }
-                }
-                break;
-
-            case eEncodingIsConstUID:
-                m_compiler_type = encoding_type->GetForwardCompilerType ().AddConstModifier();
-                break;
-
-            case eEncodingIsRestrictUID:
-                m_compiler_type = encoding_type->GetForwardCompilerType ().AddRestrictModifier();
-                break;
-
-            case eEncodingIsVolatileUID:
-                m_compiler_type = encoding_type->GetForwardCompilerType ().AddVolatileModifier();
-                break;
-
-            case eEncodingIsTypedefUID:
-                m_compiler_type = encoding_type->GetForwardCompilerType ().CreateTypedef(m_name.AsCString("__lldb_invalid_typedef_name"),
-                                                                                         GetSymbolFile()->GetDeclContextContainingUID(GetID()));
-                m_name.Clear();
-                break;
-
-            case eEncodingIsPointerUID:
-                m_compiler_type = encoding_type->GetForwardCompilerType ().GetPointerType();
-                break;
-
-            case eEncodingIsLValueReferenceUID:
-                m_compiler_type = encoding_type->GetForwardCompilerType ().GetLValueReferenceType();
-                break;
-
-            case eEncodingIsRValueReferenceUID:
-                m_compiler_type = encoding_type->GetForwardCompilerType ().GetRValueReferenceType();
-                break;
-
-            default:
-                assert(!"Unhandled encoding_data_type.");
-                break;
-            }
-        }
-        else
-        {
-            // We have no encoding type, return void?
-            TypeSystem *type_system = m_symbol_file->GetTypeSystemForLanguage(eLanguageTypeC);
-            CompilerType void_compiler_type = type_system->GetBasicTypeFromAST(eBasicTypeVoid);
-            switch (m_encoding_uid_type)
-            {
-            case eEncodingIsUID:
-                m_compiler_type = void_compiler_type;
-                break;
-
-            case eEncodingIsConstUID:
-                m_compiler_type = void_compiler_type.AddConstModifier();
-                break;
-
-            case eEncodingIsRestrictUID:
-                m_compiler_type = void_compiler_type.AddRestrictModifier();
-                break;
-
-            case eEncodingIsVolatileUID:
-                m_compiler_type = void_compiler_type.AddVolatileModifier();
-                break;
-
-            case eEncodingIsTypedefUID:
-                m_compiler_type = void_compiler_type.CreateTypedef(m_name.AsCString("__lldb_invalid_typedef_name"),
-                                                                   GetSymbolFile()->GetDeclContextContainingUID(GetID()));
-                break;
-
-            case eEncodingIsPointerUID:
-                m_compiler_type = void_compiler_type.GetPointerType ();
-                break;
-
-            case eEncodingIsLValueReferenceUID:
-                m_compiler_type = void_compiler_type.GetLValueReferenceType();
-                break;
-
-            case eEncodingIsRValueReferenceUID:
-                m_compiler_type = void_compiler_type.GetRValueReferenceType();
-                break;
-
-            default:
-                assert(!"Unhandled encoding_data_type.");
-                break;
-            }
-        }
-
-        // When we have a EncodingUID, our "m_flags.compiler_type_resolve_state" is set to eResolveStateUnresolved
-        // so we need to update it to say that we now have a forward declaration since that is what we created
-        // above.
-        if (m_compiler_type.IsValid())
-            m_flags.compiler_type_resolve_state = eResolveStateForward;
-
-    }
-
-    // Check if we have a forward reference to a class/struct/union/enum?
-    if (compiler_type_resolve_state == eResolveStateLayout || compiler_type_resolve_state == eResolveStateFull)
-    {
-        // Check if we have a forward reference to a class/struct/union/enum?
-        if (m_compiler_type.IsValid() && m_flags.compiler_type_resolve_state < compiler_type_resolve_state)
-        {
-            m_flags.compiler_type_resolve_state = eResolveStateFull;
-            if (!m_compiler_type.IsDefined ())
-            {
-                // We have a forward declaration, we need to resolve it to a complete definition.
-                m_symbol_file->CompleteType (m_compiler_type);
-            }
-        }
-    }
-    
-    // If we have an encoding type, then we need to make sure it is 
-    // resolved appropriately.
-    if (m_encoding_uid != LLDB_INVALID_UID)
-    {
-        if (encoding_type == nullptr)
-            encoding_type = GetEncodingType();
-        if (encoding_type)
-        {
-            ResolveState encoding_compiler_type_resolve_state = compiler_type_resolve_state;
-            
-            if (compiler_type_resolve_state == eResolveStateLayout)
-            {
-                switch (m_encoding_uid_type)
-                {
-                case eEncodingIsPointerUID:
-                case eEncodingIsLValueReferenceUID:
-                case eEncodingIsRValueReferenceUID:
-                    encoding_compiler_type_resolve_state = eResolveStateForward;
-                    break;
-                default:
-                    break;
-                }
-            }
-            encoding_type->ResolveClangType (encoding_compiler_type_resolve_state);
-        }
-    }
-    return m_compiler_type.IsValid();
-}
-uint32_t
-Type::GetEncodingMask ()
-{
-    uint32_t encoding_mask = 1u << m_encoding_uid_type;
-    Type *encoding_type = GetEncodingType();
-    assert (encoding_type != this);
-    if (encoding_type)
-        encoding_mask |= encoding_type->GetEncodingMask ();
-    return encoding_mask;
-}
-
-CompilerType
-Type::GetFullCompilerType ()
-{
-    ResolveClangType(eResolveStateFull);
-    return m_compiler_type;
-}
-
-CompilerType
-Type::GetLayoutCompilerType ()
-{
-    ResolveClangType(eResolveStateLayout);
-    return m_compiler_type;
-}
-
-CompilerType 
-Type::GetForwardCompilerType ()
-{
-    ResolveClangType (eResolveStateForward);
-    return m_compiler_type;
-}
-
-int
-Type::Compare(const Type &a, const Type &b)
-{
-    // Just compare the UID values for now...
-    lldb::user_id_t a_uid = a.GetID();
-    lldb::user_id_t b_uid = b.GetID();
-    if (a_uid < b_uid)
-        return -1;
-    if (a_uid > b_uid)
-        return 1;
-    return 0;
-}
-
-ConstString
-Type::GetQualifiedName ()
-{
-    return GetForwardCompilerType ().GetConstTypeName();
-}
-
-bool
-Type::GetTypeScopeAndBasename (const char* &name_cstr,
-                               std::string &scope,
-                               std::string &basename,
-                               TypeClass &type_class)
-{
-    // Protect against null c string.
-    
-    type_class = eTypeClassAny;
-
-    if (name_cstr && name_cstr[0])
-    {
-        llvm::StringRef name_strref(name_cstr);
-        if (name_strref.startswith("struct "))
-        {
-            name_cstr += 7;
-            type_class = eTypeClassStruct;
-        }
-        else if (name_strref.startswith("class "))
-        {
-            name_cstr += 6;
-            type_class = eTypeClassClass;
-        }
-        else if (name_strref.startswith("union "))
-        {
-            name_cstr += 6;
-            type_class = eTypeClassUnion;
-        }
-        else if (name_strref.startswith("enum "))
-        {
-            name_cstr += 5;
-            type_class = eTypeClassEnumeration;
-        }
-        else if (name_strref.startswith("typedef "))
-        {
-            name_cstr += 8;
-            type_class = eTypeClassTypedef;
-        }
-        const char *basename_cstr = name_cstr;
-        const char* namespace_separator = ::strstr (basename_cstr, "::");
-        if (namespace_separator)
-        {
-            const char* template_arg_char = ::strchr (basename_cstr, '<');
-            while (namespace_separator != nullptr)
-            {
-                if (template_arg_char && namespace_separator > template_arg_char) // but namespace'd template arguments are still good to go
-                    break;
-                basename_cstr = namespace_separator + 2;
-                namespace_separator = strstr(basename_cstr, "::");
-            }
-            if (basename_cstr > name_cstr)
-            {
-                scope.assign (name_cstr, basename_cstr - name_cstr);
-                basename.assign (basename_cstr);
-                return true;
-            }
-        }
-    }
+  if (m_type_name != other.m_type_name)
     return false;
+  return true;
 }
 
-
-ModuleSP
-Type::GetModule()
-{
-    if (m_symbol_file)
-        return m_symbol_file->GetObjectFile()->GetModule();
-    return ModuleSP();
-}
-
-
-TypeAndOrName::TypeAndOrName () : m_type_pair(), m_type_name()
-{
-
-}
-
-TypeAndOrName::TypeAndOrName (TypeSP &in_type_sp) : m_type_pair(in_type_sp)
-{
-    if (in_type_sp)
-        m_type_name = in_type_sp->GetName();
+bool TypeAndOrName::operator!=(const TypeAndOrName &other) const {
+  if (m_type_pair != other.m_type_pair)
+    return true;
+  if (m_type_name != other.m_type_name)
+    return true;
+  return false;
 }
 
-TypeAndOrName::TypeAndOrName (const char *in_type_str) : m_type_name(in_type_str)
-{
+ConstString TypeAndOrName::GetName() const {
+  if (m_type_name)
+    return m_type_name;
+  if (m_type_pair)
+    return m_type_pair.GetName();
+  return ConstString("<invalid>");
 }
 
-TypeAndOrName::TypeAndOrName (const TypeAndOrName &rhs) : m_type_pair (rhs.m_type_pair), m_type_name (rhs.m_type_name)
-{
-
+void TypeAndOrName::SetName(const ConstString &type_name) {
+  m_type_name = type_name;
 }
 
-TypeAndOrName::TypeAndOrName (ConstString &in_type_const_string) : m_type_name (in_type_const_string)
-{
+void TypeAndOrName::SetName(const char *type_name_cstr) {
+  m_type_name.SetCString(type_name_cstr);
 }
 
-TypeAndOrName &
-TypeAndOrName::operator= (const TypeAndOrName &rhs)
-{
-    if (this != &rhs)
-    {
-        m_type_name = rhs.m_type_name;
-        m_type_pair = rhs.m_type_pair;
-    }
-    return *this;
+void TypeAndOrName::SetTypeSP(lldb::TypeSP type_sp) {
+  m_type_pair.SetType(type_sp);
+  if (m_type_pair)
+    m_type_name = m_type_pair.GetName();
 }
 
-bool
-TypeAndOrName::operator==(const TypeAndOrName &other) const
-{
-    if (m_type_pair != other.m_type_pair)
-        return false;
-    if (m_type_name != other.m_type_name)
-        return false;
-    return true;
+void TypeAndOrName::SetCompilerType(CompilerType compiler_type) {
+  m_type_pair.SetType(compiler_type);
+  if (m_type_pair)
+    m_type_name = m_type_pair.GetName();
 }
 
-bool
-TypeAndOrName::operator!=(const TypeAndOrName &other) const
-{
-    if (m_type_pair != other.m_type_pair)
-        return true;
-    if (m_type_name != other.m_type_name)
-        return true;
+bool TypeAndOrName::IsEmpty() const {
+  if ((bool)m_type_name || (bool)m_type_pair)
     return false;
+  else
+    return true;
 }
 
-ConstString
-TypeAndOrName::GetName () const
-{
-    if (m_type_name)
-        return m_type_name;
-    if (m_type_pair)
-        return m_type_pair.GetName();
-    return ConstString("<invalid>");
-}
-
-void
-TypeAndOrName::SetName (const ConstString &type_name)
-{
-    m_type_name = type_name;
-}
-
-void
-TypeAndOrName::SetName (const char *type_name_cstr)
-{
-    m_type_name.SetCString (type_name_cstr);
-}
-
-void
-TypeAndOrName::SetTypeSP (lldb::TypeSP type_sp)
-{
-    m_type_pair.SetType(type_sp);
-    if (m_type_pair)
-        m_type_name = m_type_pair.GetName();
-}
-
-void
-TypeAndOrName::SetCompilerType (CompilerType compiler_type)
-{
-    m_type_pair.SetType(compiler_type);
-    if (m_type_pair)
-        m_type_name = m_type_pair.GetName();
-}
-
-bool
-TypeAndOrName::IsEmpty()  const
-{
-    if ((bool)m_type_name || (bool)m_type_pair)
-        return false;
-    else
-        return true;
-}
-
-void
-TypeAndOrName::Clear ()
-{
-    m_type_name.Clear();
-    m_type_pair.Clear();
+void TypeAndOrName::Clear() {
+  m_type_name.Clear();
+  m_type_pair.Clear();
 }
 
-bool
-TypeAndOrName::HasName () const
-{
-    return (bool)m_type_name;
-}
+bool TypeAndOrName::HasName() const { return (bool)m_type_name; }
 
-bool
-TypeAndOrName::HasTypeSP () const
-{
-    return m_type_pair.GetTypeSP().get() != nullptr;
+bool TypeAndOrName::HasTypeSP() const {
+  return m_type_pair.GetTypeSP().get() != nullptr;
 }
 
-bool
-TypeAndOrName::HasCompilerType () const
-{
-    return m_type_pair.GetCompilerType().IsValid();
+bool TypeAndOrName::HasCompilerType() const {
+  return m_type_pair.GetCompilerType().IsValid();
 }
 
+TypeImpl::TypeImpl() : m_module_wp(), m_static_type(), m_dynamic_type() {}
 
-TypeImpl::TypeImpl() :
-    m_module_wp(),
-    m_static_type(),
-    m_dynamic_type()
-{
-}
+TypeImpl::TypeImpl(const TypeImpl &rhs)
+    : m_module_wp(rhs.m_module_wp), m_static_type(rhs.m_static_type),
+      m_dynamic_type(rhs.m_dynamic_type) {}
 
-TypeImpl::TypeImpl(const TypeImpl& rhs) :
-    m_module_wp (rhs.m_module_wp),
-    m_static_type(rhs.m_static_type),
-    m_dynamic_type(rhs.m_dynamic_type)
-{
+TypeImpl::TypeImpl(const lldb::TypeSP &type_sp)
+    : m_module_wp(), m_static_type(), m_dynamic_type() {
+  SetType(type_sp);
 }
 
-TypeImpl::TypeImpl (const lldb::TypeSP &type_sp) :
-    m_module_wp (),
-    m_static_type(),
-    m_dynamic_type()
-{
-    SetType (type_sp);
+TypeImpl::TypeImpl(const CompilerType &compiler_type)
+    : m_module_wp(), m_static_type(), m_dynamic_type() {
+  SetType(compiler_type);
 }
 
-TypeImpl::TypeImpl (const CompilerType &compiler_type) :
-    m_module_wp (),
-    m_static_type(),
-    m_dynamic_type()
-{
-    SetType (compiler_type);
+TypeImpl::TypeImpl(const lldb::TypeSP &type_sp, const CompilerType &dynamic)
+    : m_module_wp(), m_static_type(type_sp), m_dynamic_type(dynamic) {
+  SetType(type_sp, dynamic);
 }
 
-TypeImpl::TypeImpl (const lldb::TypeSP &type_sp, const CompilerType &dynamic) :
-    m_module_wp (),
-    m_static_type (type_sp),
-    m_dynamic_type(dynamic)
-{
-    SetType (type_sp, dynamic);
+TypeImpl::TypeImpl(const CompilerType &static_type,
+                   const CompilerType &dynamic_type)
+    : m_module_wp(), m_static_type(), m_dynamic_type() {
+  SetType(static_type, dynamic_type);
 }
 
-TypeImpl::TypeImpl (const CompilerType &static_type, const CompilerType &dynamic_type) :
-    m_module_wp (),
-    m_static_type (),
-    m_dynamic_type()
-{
-    SetType (static_type, dynamic_type);
+TypeImpl::TypeImpl(const TypePair &pair, const CompilerType &dynamic)
+    : m_module_wp(), m_static_type(), m_dynamic_type() {
+  SetType(pair, dynamic);
 }
 
-TypeImpl::TypeImpl (const TypePair &pair, const CompilerType &dynamic) :
-    m_module_wp (),
-    m_static_type (),
-    m_dynamic_type()
-{
-    SetType (pair, dynamic);
-}
-
-void
-TypeImpl::SetType (const lldb::TypeSP &type_sp)
-{
-    m_static_type.SetType(type_sp);
-    if (type_sp)
-        m_module_wp = type_sp->GetModule();
-    else
-        m_module_wp = lldb::ModuleWP();
-}
-
-void
-TypeImpl::SetType (const CompilerType &compiler_type)
-{
+void TypeImpl::SetType(const lldb::TypeSP &type_sp) {
+  m_static_type.SetType(type_sp);
+  if (type_sp)
+    m_module_wp = type_sp->GetModule();
+  else
     m_module_wp = lldb::ModuleWP();
-    m_static_type.SetType (compiler_type);
 }
 
-void
-TypeImpl::SetType (const lldb::TypeSP &type_sp, const CompilerType &dynamic)
-{
-    SetType (type_sp);
-    m_dynamic_type = dynamic;
-}
-
-void
-TypeImpl::SetType (const CompilerType &compiler_type, const CompilerType &dynamic)
-{
-    m_module_wp = lldb::ModuleWP();
-    m_static_type.SetType (compiler_type);
-    m_dynamic_type = dynamic;
-}
-
-void
-TypeImpl::SetType (const TypePair &pair, const CompilerType &dynamic)
-{
-    m_module_wp = pair.GetModule();
-    m_static_type = pair;
-    m_dynamic_type = dynamic;
-}
-
-TypeImpl&
-TypeImpl::operator = (const TypeImpl& rhs)
-{
-    if (rhs != *this)
-    {
-        m_module_wp = rhs.m_module_wp;
-        m_static_type = rhs.m_static_type;
-        m_dynamic_type = rhs.m_dynamic_type;
-    }
-    return *this;
-}
-
-bool
-TypeImpl::CheckModule (lldb::ModuleSP &module_sp) const
-{
-    // Check if we have a module for this type. If we do and the shared pointer is
-    // can be successfully initialized with m_module_wp, return true. Else return false
-    // if we didn't have a module, or if we had a module and it has been deleted. Any
-    // functions doing anything with a TypeSP in this TypeImpl class should call this
-    // function and only do anything with the ivars if this function returns true. If
-    // we have a module, the "module_sp" will be filled in with a strong reference to the
-    // module so that the module will at least stay around long enough for the type
-    // query to succeed.
-    module_sp = m_module_wp.lock();
-    if (!module_sp)
-    {
-        lldb::ModuleWP empty_module_wp;
-        // If either call to "std::weak_ptr::owner_before(...) value returns true, this
-        // indicates that m_module_wp once contained (possibly still does) a reference
-        // to a valid shared pointer. This helps us know if we had a valid reference to
-        // a section which is now invalid because the module it was in was deleted
-        if (empty_module_wp.owner_before(m_module_wp) || m_module_wp.owner_before(empty_module_wp))
-        {
-            // m_module_wp had a valid reference to a module, but all strong references
-            // have been released and the module has been deleted
-            return false;
-        }
-    }
-    // We either successfully locked the module, or didn't have one to begin with
-    return true;
-}
-
-bool
-TypeImpl::operator == (const TypeImpl& rhs) const
-{
-    return m_static_type == rhs.m_static_type && m_dynamic_type == rhs.m_dynamic_type;
-}
-
-bool
-TypeImpl::operator != (const TypeImpl& rhs) const
-{
-    return m_static_type != rhs.m_static_type || m_dynamic_type != rhs.m_dynamic_type;
-}
-
-bool
-TypeImpl::IsValid() const
-{
-    // just a name is not valid
-    ModuleSP module_sp;
-    if (CheckModule (module_sp))
-        return m_static_type.IsValid() || m_dynamic_type.IsValid();
+void TypeImpl::SetType(const CompilerType &compiler_type) {
+  m_module_wp = lldb::ModuleWP();
+  m_static_type.SetType(compiler_type);
+}
+
+void TypeImpl::SetType(const lldb::TypeSP &type_sp,
+                       const CompilerType &dynamic) {
+  SetType(type_sp);
+  m_dynamic_type = dynamic;
+}
+
+void TypeImpl::SetType(const CompilerType &compiler_type,
+                       const CompilerType &dynamic) {
+  m_module_wp = lldb::ModuleWP();
+  m_static_type.SetType(compiler_type);
+  m_dynamic_type = dynamic;
+}
+
+void TypeImpl::SetType(const TypePair &pair, const CompilerType &dynamic) {
+  m_module_wp = pair.GetModule();
+  m_static_type = pair;
+  m_dynamic_type = dynamic;
+}
+
+TypeImpl &TypeImpl::operator=(const TypeImpl &rhs) {
+  if (rhs != *this) {
+    m_module_wp = rhs.m_module_wp;
+    m_static_type = rhs.m_static_type;
+    m_dynamic_type = rhs.m_dynamic_type;
+  }
+  return *this;
+}
+
+bool TypeImpl::CheckModule(lldb::ModuleSP &module_sp) const {
+  // Check if we have a module for this type. If we do and the shared pointer is
+  // can be successfully initialized with m_module_wp, return true. Else return
+  // false
+  // if we didn't have a module, or if we had a module and it has been deleted.
+  // Any
+  // functions doing anything with a TypeSP in this TypeImpl class should call
+  // this
+  // function and only do anything with the ivars if this function returns true.
+  // If
+  // we have a module, the "module_sp" will be filled in with a strong reference
+  // to the
+  // module so that the module will at least stay around long enough for the
+  // type
+  // query to succeed.
+  module_sp = m_module_wp.lock();
+  if (!module_sp) {
+    lldb::ModuleWP empty_module_wp;
+    // If either call to "std::weak_ptr::owner_before(...) value returns true,
+    // this
+    // indicates that m_module_wp once contained (possibly still does) a
+    // reference
+    // to a valid shared pointer. This helps us know if we had a valid reference
+    // to
+    // a section which is now invalid because the module it was in was deleted
+    if (empty_module_wp.owner_before(m_module_wp) ||
+        m_module_wp.owner_before(empty_module_wp)) {
+      // m_module_wp had a valid reference to a module, but all strong
+      // references
+      // have been released and the module has been deleted
+      return false;
+    }
+  }
+  // We either successfully locked the module, or didn't have one to begin with
+  return true;
+}
+
+bool TypeImpl::operator==(const TypeImpl &rhs) const {
+  return m_static_type == rhs.m_static_type &&
+         m_dynamic_type == rhs.m_dynamic_type;
+}
+
+bool TypeImpl::operator!=(const TypeImpl &rhs) const {
+  return m_static_type != rhs.m_static_type ||
+         m_dynamic_type != rhs.m_dynamic_type;
+}
+
+bool TypeImpl::IsValid() const {
+  // just a name is not valid
+  ModuleSP module_sp;
+  if (CheckModule(module_sp))
+    return m_static_type.IsValid() || m_dynamic_type.IsValid();
+  return false;
+}
+
+TypeImpl::operator bool() const { return IsValid(); }
+
+void TypeImpl::Clear() {
+  m_module_wp = lldb::ModuleWP();
+  m_static_type.Clear();
+  m_dynamic_type.Clear();
+}
+
+ConstString TypeImpl::GetName() const {
+  ModuleSP module_sp;
+  if (CheckModule(module_sp)) {
+    if (m_dynamic_type)
+      return m_dynamic_type.GetTypeName();
+    return m_static_type.GetName();
+  }
+  return ConstString();
+}
+
+ConstString TypeImpl::GetDisplayTypeName() const {
+  ModuleSP module_sp;
+  if (CheckModule(module_sp)) {
+    if (m_dynamic_type)
+      return m_dynamic_type.GetDisplayTypeName();
+    return m_static_type.GetDisplayTypeName();
+  }
+  return ConstString();
+}
+
+TypeImpl TypeImpl::GetPointerType() const {
+  ModuleSP module_sp;
+  if (CheckModule(module_sp)) {
+    if (m_dynamic_type.IsValid()) {
+      return TypeImpl(m_static_type.GetPointerType(),
+                      m_dynamic_type.GetPointerType());
+    }
+    return TypeImpl(m_static_type.GetPointerType());
+  }
+  return TypeImpl();
+}
+
+TypeImpl TypeImpl::GetPointeeType() const {
+  ModuleSP module_sp;
+  if (CheckModule(module_sp)) {
+    if (m_dynamic_type.IsValid()) {
+      return TypeImpl(m_static_type.GetPointeeType(),
+                      m_dynamic_type.GetPointeeType());
+    }
+    return TypeImpl(m_static_type.GetPointeeType());
+  }
+  return TypeImpl();
+}
+
+TypeImpl TypeImpl::GetReferenceType() const {
+  ModuleSP module_sp;
+  if (CheckModule(module_sp)) {
+    if (m_dynamic_type.IsValid()) {
+      return TypeImpl(m_static_type.GetReferenceType(),
+                      m_dynamic_type.GetLValueReferenceType());
+    }
+    return TypeImpl(m_static_type.GetReferenceType());
+  }
+  return TypeImpl();
+}
+
+TypeImpl TypeImpl::GetTypedefedType() const {
+  ModuleSP module_sp;
+  if (CheckModule(module_sp)) {
+    if (m_dynamic_type.IsValid()) {
+      return TypeImpl(m_static_type.GetTypedefedType(),
+                      m_dynamic_type.GetTypedefedType());
+    }
+    return TypeImpl(m_static_type.GetTypedefedType());
+  }
+  return TypeImpl();
+}
+
+TypeImpl TypeImpl::GetDereferencedType() const {
+  ModuleSP module_sp;
+  if (CheckModule(module_sp)) {
+    if (m_dynamic_type.IsValid()) {
+      return TypeImpl(m_static_type.GetDereferencedType(),
+                      m_dynamic_type.GetNonReferenceType());
+    }
+    return TypeImpl(m_static_type.GetDereferencedType());
+  }
+  return TypeImpl();
+}
+
+TypeImpl TypeImpl::GetUnqualifiedType() const {
+  ModuleSP module_sp;
+  if (CheckModule(module_sp)) {
+    if (m_dynamic_type.IsValid()) {
+      return TypeImpl(m_static_type.GetUnqualifiedType(),
+                      m_dynamic_type.GetFullyUnqualifiedType());
+    }
+    return TypeImpl(m_static_type.GetUnqualifiedType());
+  }
+  return TypeImpl();
+}
+
+TypeImpl TypeImpl::GetCanonicalType() const {
+  ModuleSP module_sp;
+  if (CheckModule(module_sp)) {
+    if (m_dynamic_type.IsValid()) {
+      return TypeImpl(m_static_type.GetCanonicalType(),
+                      m_dynamic_type.GetCanonicalType());
+    }
+    return TypeImpl(m_static_type.GetCanonicalType());
+  }
+  return TypeImpl();
+}
+
+CompilerType TypeImpl::GetCompilerType(bool prefer_dynamic) {
+  ModuleSP module_sp;
+  if (CheckModule(module_sp)) {
+    if (prefer_dynamic) {
+      if (m_dynamic_type.IsValid())
+        return m_dynamic_type;
+    }
+    return m_static_type.GetCompilerType();
+  }
+  return CompilerType();
+}
+
+TypeSystem *TypeImpl::GetTypeSystem(bool prefer_dynamic) {
+  ModuleSP module_sp;
+  if (CheckModule(module_sp)) {
+    if (prefer_dynamic) {
+      if (m_dynamic_type.IsValid())
+        return m_dynamic_type.GetTypeSystem();
+    }
+    return m_static_type.GetCompilerType().GetTypeSystem();
+  }
+  return NULL;
+}
+
+bool TypeImpl::GetDescription(lldb_private::Stream &strm,
+                              lldb::DescriptionLevel description_level) {
+  ModuleSP module_sp;
+  if (CheckModule(module_sp)) {
+    if (m_dynamic_type.IsValid()) {
+      strm.Printf("Dynamic:\n");
+      m_dynamic_type.DumpTypeDescription(&strm);
+      strm.Printf("\nStatic:\n");
+    }
+    m_static_type.GetCompilerType().DumpTypeDescription(&strm);
+  } else {
+    strm.PutCString("Invalid TypeImpl module for type has been deleted\n");
+  }
+  return true;
+}
+
+bool TypeMemberFunctionImpl::IsValid() {
+  return m_type.IsValid() && m_kind != lldb::eMemberFunctionKindUnknown;
+}
+
+ConstString TypeMemberFunctionImpl::GetName() const { return m_name; }
+
+ConstString TypeMemberFunctionImpl::GetMangledName() const {
+  return m_decl.GetMangledName();
+}
+
+CompilerType TypeMemberFunctionImpl::GetType() const { return m_type; }
+
+lldb::MemberFunctionKind TypeMemberFunctionImpl::GetKind() const {
+  return m_kind;
+}
+
+bool TypeMemberFunctionImpl::GetDescription(Stream &stream) {
+  switch (m_kind) {
+  case lldb::eMemberFunctionKindUnknown:
     return false;
-}
+  case lldb::eMemberFunctionKindConstructor:
+    stream.Printf("constructor for %s",
+                  m_type.GetTypeName().AsCString("<unknown>"));
+    break;
+  case lldb::eMemberFunctionKindDestructor:
+    stream.Printf("destructor for %s",
+                  m_type.GetTypeName().AsCString("<unknown>"));
+    break;
+  case lldb::eMemberFunctionKindInstanceMethod:
+    stream.Printf("instance method %s of type %s", m_name.AsCString(),
+                  m_decl.GetDeclContext().GetName().AsCString());
+    break;
+  case lldb::eMemberFunctionKindStaticMethod:
+    stream.Printf("static method %s of type %s", m_name.AsCString(),
+                  m_decl.GetDeclContext().GetName().AsCString());
+    break;
+  }
+  return true;
+}
+
+CompilerType TypeMemberFunctionImpl::GetReturnType() const {
+  if (m_type)
+    return m_type.GetFunctionReturnType();
+  return m_decl.GetFunctionReturnType();
+}
+
+size_t TypeMemberFunctionImpl::GetNumArguments() const {
+  if (m_type)
+    return m_type.GetNumberOfFunctionArguments();
+  else
+    return m_decl.GetNumFunctionArguments();
+}
+
+CompilerType TypeMemberFunctionImpl::GetArgumentAtIndex(size_t idx) const {
+  if (m_type)
+    return m_type.GetFunctionArgumentAtIndex(idx);
+  else
+    return m_decl.GetFunctionArgumentType(idx);
+}
+
+TypeEnumMemberImpl::TypeEnumMemberImpl(const lldb::TypeImplSP &integer_type_sp,
+                                       const ConstString &name,
+                                       const llvm::APSInt &value)
+    : m_integer_type_sp(integer_type_sp), m_name(name), m_value(value),
+      m_valid((bool)name && (bool)integer_type_sp)
 
-TypeImpl::operator bool () const
-{
-    return IsValid();
-}
-
-void
-TypeImpl::Clear()
-{
-    m_module_wp = lldb::ModuleWP();
-    m_static_type.Clear();
-    m_dynamic_type.Clear();
-}
-
-ConstString
-TypeImpl::GetName ()  const
-{
-    ModuleSP module_sp;
-    if (CheckModule (module_sp))
-    {
-        if (m_dynamic_type)
-            return m_dynamic_type.GetTypeName();
-        return m_static_type.GetName ();
-    }
-    return ConstString();
-}
-
-ConstString
-TypeImpl::GetDisplayTypeName ()  const
-{
-    ModuleSP module_sp;
-    if (CheckModule (module_sp))
-    {
-        if (m_dynamic_type)
-            return m_dynamic_type.GetDisplayTypeName();
-        return m_static_type.GetDisplayTypeName();
-    }
-    return ConstString();
-}
-
-TypeImpl
-TypeImpl::GetPointerType () const
-{
-    ModuleSP module_sp;
-    if (CheckModule (module_sp))
-    {
-        if (m_dynamic_type.IsValid())
-        {
-            return TypeImpl(m_static_type.GetPointerType(), m_dynamic_type.GetPointerType());
-        }
-        return TypeImpl(m_static_type.GetPointerType());
-    }
-    return TypeImpl();
-}
-
-TypeImpl
-TypeImpl::GetPointeeType () const
-{
-    ModuleSP module_sp;
-    if (CheckModule (module_sp))
-    {
-        if (m_dynamic_type.IsValid())
-        {
-            return TypeImpl(m_static_type.GetPointeeType(), m_dynamic_type.GetPointeeType());
-        }
-        return TypeImpl(m_static_type.GetPointeeType());
-    }
-    return TypeImpl();
-}
-
-TypeImpl
-TypeImpl::GetReferenceType () const
-{
-    ModuleSP module_sp;
-    if (CheckModule (module_sp))
-    {
-        if (m_dynamic_type.IsValid())
-        {
-            return TypeImpl(m_static_type.GetReferenceType(), m_dynamic_type.GetLValueReferenceType());
-        }
-        return TypeImpl(m_static_type.GetReferenceType());
-    }
-    return TypeImpl();
-}
-
-TypeImpl
-TypeImpl::GetTypedefedType () const
-{
-    ModuleSP module_sp;
-    if (CheckModule (module_sp))
-    {
-        if (m_dynamic_type.IsValid())
-        {
-            return TypeImpl(m_static_type.GetTypedefedType(), m_dynamic_type.GetTypedefedType());
-        }
-        return TypeImpl(m_static_type.GetTypedefedType());
-    }
-    return TypeImpl();
-}
-
-TypeImpl
-TypeImpl::GetDereferencedType () const
-{
-    ModuleSP module_sp;
-    if (CheckModule (module_sp))
-    {
-        if (m_dynamic_type.IsValid())
-        {
-            return TypeImpl(m_static_type.GetDereferencedType(), m_dynamic_type.GetNonReferenceType());
-        }
-        return TypeImpl(m_static_type.GetDereferencedType());
-    }
-    return TypeImpl();
-}
-
-TypeImpl
-TypeImpl::GetUnqualifiedType() const
-{
-    ModuleSP module_sp;
-    if (CheckModule (module_sp))
-    {
-        if (m_dynamic_type.IsValid())
-        {
-            return TypeImpl(m_static_type.GetUnqualifiedType(), m_dynamic_type.GetFullyUnqualifiedType());
-        }
-        return TypeImpl(m_static_type.GetUnqualifiedType());
-    }
-    return TypeImpl();
-}
-
-TypeImpl
-TypeImpl::GetCanonicalType() const
-{
-    ModuleSP module_sp;
-    if (CheckModule (module_sp))
-    {
-        if (m_dynamic_type.IsValid())
-        {
-            return TypeImpl(m_static_type.GetCanonicalType(), m_dynamic_type.GetCanonicalType());
-        }
-        return TypeImpl(m_static_type.GetCanonicalType());
-    }
-    return TypeImpl();
-}
-
-CompilerType
-TypeImpl::GetCompilerType (bool prefer_dynamic)
-{
-    ModuleSP module_sp;
-    if (CheckModule (module_sp))
-    {
-        if (prefer_dynamic)
-        {
-            if (m_dynamic_type.IsValid())
-                return m_dynamic_type;
-        }
-        return m_static_type.GetCompilerType();
-    }
-    return CompilerType();
-}
-
-TypeSystem *
-TypeImpl::GetTypeSystem (bool prefer_dynamic)
-{
-    ModuleSP module_sp;
-    if (CheckModule (module_sp))
-    {
-        if (prefer_dynamic)
-        {
-            if (m_dynamic_type.IsValid())
-                return m_dynamic_type.GetTypeSystem();
-        }
-        return m_static_type.GetCompilerType().GetTypeSystem();
-    }
-    return NULL;
-}
-
-bool
-TypeImpl::GetDescription (lldb_private::Stream &strm,
-                          lldb::DescriptionLevel description_level)
-{
-    ModuleSP module_sp;
-    if (CheckModule (module_sp))
-    {
-        if (m_dynamic_type.IsValid())
-        {
-            strm.Printf("Dynamic:\n");
-            m_dynamic_type.DumpTypeDescription(&strm);
-            strm.Printf("\nStatic:\n");
-        }
-        m_static_type.GetCompilerType().DumpTypeDescription(&strm);
-    }
-    else
-    {
-        strm.PutCString("Invalid TypeImpl module for type has been deleted\n");
-    }
-    return true;
-}
-
-bool
-TypeMemberFunctionImpl::IsValid ()
-{
-    return m_type.IsValid() && m_kind != lldb::eMemberFunctionKindUnknown;
-}
-
-ConstString
-TypeMemberFunctionImpl::GetName () const
-{
-    return m_name;
-}
-
-ConstString
-TypeMemberFunctionImpl::GetMangledName () const
-{
-    return m_decl.GetMangledName();
-}
-
-CompilerType
-TypeMemberFunctionImpl::GetType () const
-{
-    return m_type;
-}
-
-lldb::MemberFunctionKind
-TypeMemberFunctionImpl::GetKind () const
-{
-    return m_kind;
-}
-
-bool
-TypeMemberFunctionImpl::GetDescription (Stream& stream)
-{
-    switch (m_kind) {
-        case lldb::eMemberFunctionKindUnknown:
-            return false;
-        case lldb::eMemberFunctionKindConstructor:
-            stream.Printf("constructor for %s", m_type.GetTypeName().AsCString("<unknown>"));
-            break;
-        case lldb::eMemberFunctionKindDestructor:
-            stream.Printf("destructor for %s",  m_type.GetTypeName().AsCString("<unknown>"));
-            break;
-        case lldb::eMemberFunctionKindInstanceMethod:
-            stream.Printf("instance method %s of type %s",
-                          m_name.AsCString(),
-                          m_decl.GetDeclContext().GetName().AsCString());
-            break;
-        case lldb::eMemberFunctionKindStaticMethod:
-            stream.Printf("static method %s of type %s",
-                          m_name.AsCString(),
-                          m_decl.GetDeclContext().GetName().AsCString());
-            break;
-    }
-    return true;
-}
-
-CompilerType
-TypeMemberFunctionImpl::GetReturnType () const
-{
-    if (m_type)
-        return m_type.GetFunctionReturnType();
-    return m_decl.GetFunctionReturnType();
-}
-
-size_t
-TypeMemberFunctionImpl::GetNumArguments () const
-{
-    if (m_type)
-        return m_type.GetNumberOfFunctionArguments();
-    else
-        return m_decl.GetNumFunctionArguments();
-}
-
-CompilerType
-TypeMemberFunctionImpl::GetArgumentAtIndex (size_t idx) const
-{
-    if (m_type)
-        return m_type.GetFunctionArgumentAtIndex (idx);
-    else
-        return m_decl.GetFunctionArgumentType(idx);
-}
-
-TypeEnumMemberImpl::TypeEnumMemberImpl (const lldb::TypeImplSP &integer_type_sp,
-                                        const ConstString &name,
-                                        const llvm::APSInt &value) :
-    m_integer_type_sp(integer_type_sp),
-    m_name(name),
-    m_value(value),
-    m_valid((bool)name && (bool)integer_type_sp)
-
-{
-}
+{}

Modified: lldb/trunk/source/Symbol/TypeList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/TypeList.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/TypeList.cpp (original)
+++ lldb/trunk/source/Symbol/TypeList.cpp Tue Sep  6 15:57:50 2016
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-
 // C Includes
 // C++ Includes
 #include <vector>
@@ -25,31 +24,24 @@
 using namespace lldb;
 using namespace lldb_private;
 
-TypeList::TypeList() :
-    m_types ()
-{
-}
+TypeList::TypeList() : m_types() {}
 
 //----------------------------------------------------------------------
 // Destructor
 //----------------------------------------------------------------------
-TypeList::~TypeList()
-{
-}
+TypeList::~TypeList() {}
 
-void
-TypeList::Insert (const TypeSP& type_sp)
-{
-    // Just push each type on the back for now. We will worry about uniquing later
-    if (type_sp)
-        m_types.push_back(type_sp);
+void TypeList::Insert(const TypeSP &type_sp) {
+  // Just push each type on the back for now. We will worry about uniquing later
+  if (type_sp)
+    m_types.push_back(type_sp);
 }
 
 //----------------------------------------------------------------------
 // Find a base type by its unique ID.
 //----------------------------------------------------------------------
-//TypeSP
-//TypeList::FindType(lldb::user_id_t uid)
+// TypeSP
+// TypeList::FindType(lldb::user_id_t uid)
 //{
 //    iterator pos = m_types.find(uid);
 //    if (pos != m_types.end())
@@ -60,8 +52,8 @@ TypeList::Insert (const TypeSP& type_sp)
 //----------------------------------------------------------------------
 // Find a type by name.
 //----------------------------------------------------------------------
-//TypeList
-//TypeList::FindTypes (const ConstString &name)
+// TypeList
+// TypeList::FindTypes (const ConstString &name)
 //{
 //    // Do we ever need to make a lookup by name map? Here we are doing
 //    // a linear search which isn't going to be fast.
@@ -73,194 +65,158 @@ TypeList::Insert (const TypeSP& type_sp)
 //    return types;
 //}
 
-void
-TypeList::Clear()
-{
-    m_types.clear();
-}
+void TypeList::Clear() { m_types.clear(); }
 
-uint32_t
-TypeList::GetSize() const
-{
-    return m_types.size();
-}
+uint32_t TypeList::GetSize() const { return m_types.size(); }
 
 // GetTypeAtIndex isn't used a lot for large type lists, currently only for
 // type lists that are returned for "image dump -t TYPENAME" commands and other
 // simple symbol queries that grab the first result...
 
-TypeSP
-TypeList::GetTypeAtIndex(uint32_t idx)
-{
-    iterator pos, end;
-    uint32_t i = idx;
-    for (pos = m_types.begin(), end = m_types.end(); pos != end; ++pos)
-    {
-        if (i == 0)
-            return *pos;
-        --i;
-    }
-    return TypeSP();
-}
-
-void
-TypeList::ForEach (std::function <bool(const lldb::TypeSP &type_sp)> const &callback) const
-{
-    for (auto pos = m_types.begin(), end = m_types.end(); pos != end; ++pos)
-    {
-        if (!callback(*pos))
-            break;
-    }
-}
-
-void
-TypeList::ForEach (std::function <bool(lldb::TypeSP &type_sp)> const &callback)
-{
-    for (auto pos = m_types.begin(), end = m_types.end(); pos != end; ++pos)
-    {
-        if (!callback(*pos))
-            break;
-    }
-}
-
-void
-TypeList::Dump(Stream *s, bool show_context)
-{
-    for (iterator pos = m_types.begin(), end = m_types.end(); pos != end; ++pos)
-    {
-        pos->get()->Dump(s, show_context);
-    }
-}
-
-void
-TypeList::RemoveMismatchedTypes (const char *qualified_typename,
-                                 bool exact_match)
-{
-    std::string type_scope;
-    std::string type_basename;
-    TypeClass type_class = eTypeClassAny;
-    if (!Type::GetTypeScopeAndBasename (qualified_typename, type_scope, type_basename, type_class))
-    {
-        type_basename = qualified_typename;
-        type_scope.clear();
-    }
-    return RemoveMismatchedTypes (type_scope, type_basename, type_class, exact_match);
-}
-
-void
-TypeList::RemoveMismatchedTypes (const std::string &type_scope,
-                                 const std::string &type_basename,
-                                 TypeClass type_class,
-                                 bool exact_match)
-{
-    // Our "collection" type currently is a std::map which doesn't
-    // have any good way to iterate and remove items from the map
-    // so we currently just make a new list and add all of the matching
-    // types to it, and then swap it into m_types at the end
-    collection matching_types;
-
-    iterator pos, end = m_types.end();
-    
-    for (pos = m_types.begin(); pos != end; ++pos)
-    {
-        Type* the_type = pos->get();
-        bool keep_match = false;
-        TypeClass match_type_class = eTypeClassAny;
-
-        if (type_class != eTypeClassAny)
-        {
-            match_type_class = the_type->GetForwardCompilerType ().GetTypeClass ();
-            if ((match_type_class & type_class) == 0)
-                continue;
-        }
-
-        ConstString match_type_name_const_str (the_type->GetQualifiedName());
-        if (match_type_name_const_str)
-        {
-            const char *match_type_name = match_type_name_const_str.GetCString();
-            std::string match_type_scope;
-            std::string match_type_basename;
-            if (Type::GetTypeScopeAndBasename (match_type_name,
-                                               match_type_scope,
-                                               match_type_basename,
-                                               match_type_class))
-            {
-                if (match_type_basename == type_basename)
-                {
-                    const size_t type_scope_size = type_scope.size();
-                    const size_t match_type_scope_size = match_type_scope.size();
-                    if (exact_match || (type_scope_size == match_type_scope_size))
-                    {
-                        keep_match = match_type_scope == type_scope;
-                    }
-                    else
-                    {
-                        if (match_type_scope_size > type_scope_size)
-                        {
-                            const size_t type_scope_pos = match_type_scope.rfind(type_scope);
-                            if (type_scope_pos == match_type_scope_size - type_scope_size)
-                            {
-                                if (type_scope_pos >= 2)
-                                {
-                                    // Our match scope ends with the type scope we were looking for,
-                                    // but we need to make sure what comes before the matching
-                                    // type scope is a namespace boundary in case we are trying to match:
-                                    // type_basename = "d"
-                                    // type_scope = "b::c::"
-                                    // We want to match:
-                                    //  match_type_scope "a::b::c::"
-                                    // But not:
-                                    //  match_type_scope "a::bb::c::"
-                                    // So below we make sure what comes before "b::c::" in match_type_scope
-                                    // is "::", or the namespace boundary
-                                    if (match_type_scope[type_scope_pos - 1] == ':' &&
-                                        match_type_scope[type_scope_pos - 2] == ':')
-                                    {
-                                        keep_match = true;
-                                    }
-                                }
-                            }
-                        }
-                    }
+TypeSP TypeList::GetTypeAtIndex(uint32_t idx) {
+  iterator pos, end;
+  uint32_t i = idx;
+  for (pos = m_types.begin(), end = m_types.end(); pos != end; ++pos) {
+    if (i == 0)
+      return *pos;
+    --i;
+  }
+  return TypeSP();
+}
+
+void TypeList::ForEach(
+    std::function<bool(const lldb::TypeSP &type_sp)> const &callback) const {
+  for (auto pos = m_types.begin(), end = m_types.end(); pos != end; ++pos) {
+    if (!callback(*pos))
+      break;
+  }
+}
+
+void TypeList::ForEach(
+    std::function<bool(lldb::TypeSP &type_sp)> const &callback) {
+  for (auto pos = m_types.begin(), end = m_types.end(); pos != end; ++pos) {
+    if (!callback(*pos))
+      break;
+  }
+}
+
+void TypeList::Dump(Stream *s, bool show_context) {
+  for (iterator pos = m_types.begin(), end = m_types.end(); pos != end; ++pos) {
+    pos->get()->Dump(s, show_context);
+  }
+}
+
+void TypeList::RemoveMismatchedTypes(const char *qualified_typename,
+                                     bool exact_match) {
+  std::string type_scope;
+  std::string type_basename;
+  TypeClass type_class = eTypeClassAny;
+  if (!Type::GetTypeScopeAndBasename(qualified_typename, type_scope,
+                                     type_basename, type_class)) {
+    type_basename = qualified_typename;
+    type_scope.clear();
+  }
+  return RemoveMismatchedTypes(type_scope, type_basename, type_class,
+                               exact_match);
+}
+
+void TypeList::RemoveMismatchedTypes(const std::string &type_scope,
+                                     const std::string &type_basename,
+                                     TypeClass type_class, bool exact_match) {
+  // Our "collection" type currently is a std::map which doesn't
+  // have any good way to iterate and remove items from the map
+  // so we currently just make a new list and add all of the matching
+  // types to it, and then swap it into m_types at the end
+  collection matching_types;
+
+  iterator pos, end = m_types.end();
+
+  for (pos = m_types.begin(); pos != end; ++pos) {
+    Type *the_type = pos->get();
+    bool keep_match = false;
+    TypeClass match_type_class = eTypeClassAny;
+
+    if (type_class != eTypeClassAny) {
+      match_type_class = the_type->GetForwardCompilerType().GetTypeClass();
+      if ((match_type_class & type_class) == 0)
+        continue;
+    }
+
+    ConstString match_type_name_const_str(the_type->GetQualifiedName());
+    if (match_type_name_const_str) {
+      const char *match_type_name = match_type_name_const_str.GetCString();
+      std::string match_type_scope;
+      std::string match_type_basename;
+      if (Type::GetTypeScopeAndBasename(match_type_name, match_type_scope,
+                                        match_type_basename,
+                                        match_type_class)) {
+        if (match_type_basename == type_basename) {
+          const size_t type_scope_size = type_scope.size();
+          const size_t match_type_scope_size = match_type_scope.size();
+          if (exact_match || (type_scope_size == match_type_scope_size)) {
+            keep_match = match_type_scope == type_scope;
+          } else {
+            if (match_type_scope_size > type_scope_size) {
+              const size_t type_scope_pos = match_type_scope.rfind(type_scope);
+              if (type_scope_pos == match_type_scope_size - type_scope_size) {
+                if (type_scope_pos >= 2) {
+                  // Our match scope ends with the type scope we were looking
+                  // for,
+                  // but we need to make sure what comes before the matching
+                  // type scope is a namespace boundary in case we are trying to
+                  // match:
+                  // type_basename = "d"
+                  // type_scope = "b::c::"
+                  // We want to match:
+                  //  match_type_scope "a::b::c::"
+                  // But not:
+                  //  match_type_scope "a::bb::c::"
+                  // So below we make sure what comes before "b::c::" in
+                  // match_type_scope
+                  // is "::", or the namespace boundary
+                  if (match_type_scope[type_scope_pos - 1] == ':' &&
+                      match_type_scope[type_scope_pos - 2] == ':') {
+                    keep_match = true;
+                  }
                 }
+              }
             }
-            else
-            {
-                // The type we are currently looking at doesn't exists
-                // in a namespace or class, so it only matches if there
-                // is no type scope...
-                keep_match = type_scope.empty() && type_basename.compare(match_type_name) == 0;
-            }
+          }
         }
-        
-        if (keep_match)
-        {
-            matching_types.push_back(*pos);
-        }
-    }
-    m_types.swap(matching_types);
-}
-
-void
-TypeList::RemoveMismatchedTypes (TypeClass type_class)
-{
-    if (type_class == eTypeClassAny)
-        return;
-
-    // Our "collection" type currently is a std::map which doesn't
-    // have any good way to iterate and remove items from the map
-    // so we currently just make a new list and add all of the matching
-    // types to it, and then swap it into m_types at the end
-    collection matching_types;
-    
-    iterator pos, end = m_types.end();
-    
-    for (pos = m_types.begin(); pos != end; ++pos)
-    {
-        Type* the_type = pos->get();
-        TypeClass match_type_class = the_type->GetForwardCompilerType ().GetTypeClass ();
-        if (match_type_class & type_class)
-            matching_types.push_back (*pos);
-    }
-    m_types.swap(matching_types);
+      } else {
+        // The type we are currently looking at doesn't exists
+        // in a namespace or class, so it only matches if there
+        // is no type scope...
+        keep_match =
+            type_scope.empty() && type_basename.compare(match_type_name) == 0;
+      }
+    }
+
+    if (keep_match) {
+      matching_types.push_back(*pos);
+    }
+  }
+  m_types.swap(matching_types);
+}
+
+void TypeList::RemoveMismatchedTypes(TypeClass type_class) {
+  if (type_class == eTypeClassAny)
+    return;
+
+  // Our "collection" type currently is a std::map which doesn't
+  // have any good way to iterate and remove items from the map
+  // so we currently just make a new list and add all of the matching
+  // types to it, and then swap it into m_types at the end
+  collection matching_types;
+
+  iterator pos, end = m_types.end();
+
+  for (pos = m_types.begin(); pos != end; ++pos) {
+    Type *the_type = pos->get();
+    TypeClass match_type_class =
+        the_type->GetForwardCompilerType().GetTypeClass();
+    if (match_type_class & type_class)
+      matching_types.push_back(*pos);
+  }
+  m_types.swap(matching_types);
 }

Modified: lldb/trunk/source/Symbol/TypeMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/TypeMap.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/TypeMap.cpp (original)
+++ lldb/trunk/source/Symbol/TypeMap.cpp Tue Sep  6 15:57:50 2016
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-
 // C Includes
 // C++ Includes
 #include <vector>
@@ -38,50 +37,39 @@ using namespace lldb;
 using namespace lldb_private;
 using namespace clang;
 
-TypeMap::TypeMap() :
-    m_types ()
-{
-}
+TypeMap::TypeMap() : m_types() {}
 
 //----------------------------------------------------------------------
 // Destructor
 //----------------------------------------------------------------------
-TypeMap::~TypeMap()
-{
-}
+TypeMap::~TypeMap() {}
 
-void
-TypeMap::Insert (const TypeSP& type_sp)
-{
-    // Just push each type on the back for now. We will worry about uniquing later
-    if (type_sp)
-        m_types.insert(std::make_pair(type_sp->GetID(), type_sp));
+void TypeMap::Insert(const TypeSP &type_sp) {
+  // Just push each type on the back for now. We will worry about uniquing later
+  if (type_sp)
+    m_types.insert(std::make_pair(type_sp->GetID(), type_sp));
 }
 
+bool TypeMap::InsertUnique(const TypeSP &type_sp) {
+  if (type_sp) {
+    user_id_t type_uid = type_sp->GetID();
+    iterator pos, end = m_types.end();
 
-bool
-TypeMap::InsertUnique (const TypeSP& type_sp)
-{
-    if (type_sp)
-    {
-        user_id_t type_uid = type_sp->GetID();
-        iterator pos, end = m_types.end();
-        
-        for (pos = m_types.find(type_uid); pos != end && pos->second->GetID() == type_uid; ++pos)
-        {
-            if (pos->second.get() == type_sp.get())
-                return false;
-        }
-        Insert (type_sp);
+    for (pos = m_types.find(type_uid);
+         pos != end && pos->second->GetID() == type_uid; ++pos) {
+      if (pos->second.get() == type_sp.get())
+        return false;
     }
-    return true;
+    Insert(type_sp);
+  }
+  return true;
 }
 
 //----------------------------------------------------------------------
 // Find a base type by its unique ID.
 //----------------------------------------------------------------------
-//TypeSP
-//TypeMap::FindType(lldb::user_id_t uid)
+// TypeSP
+// TypeMap::FindType(lldb::user_id_t uid)
 //{
 //    iterator pos = m_types.find(uid);
 //    if (pos != m_types.end())
@@ -92,8 +80,8 @@ TypeMap::InsertUnique (const TypeSP& typ
 //----------------------------------------------------------------------
 // Find a type by name.
 //----------------------------------------------------------------------
-//TypeMap
-//TypeMap::FindTypes (const ConstString &name)
+// TypeMap
+// TypeMap::FindTypes (const ConstString &name)
 //{
 //    // Do we ever need to make a lookup by name map? Here we are doing
 //    // a linear search which isn't going to be fast.
@@ -105,218 +93,174 @@ TypeMap::InsertUnique (const TypeSP& typ
 //    return types;
 //}
 
-void
-TypeMap::Clear()
-{
-    m_types.clear();
-}
+void TypeMap::Clear() { m_types.clear(); }
 
-uint32_t
-TypeMap::GetSize() const
-{
-    return m_types.size();
-}
+uint32_t TypeMap::GetSize() const { return m_types.size(); }
 
-bool
-TypeMap::Empty() const
-{
-    return m_types.empty();
-}
+bool TypeMap::Empty() const { return m_types.empty(); }
 
 // GetTypeAtIndex isn't used a lot for large type lists, currently only for
 // type lists that are returned for "image dump -t TYPENAME" commands and other
 // simple symbol queries that grab the first result...
 
-TypeSP
-TypeMap::GetTypeAtIndex(uint32_t idx)
-{
-    iterator pos, end;
-    uint32_t i = idx;
-    for (pos = m_types.begin(), end = m_types.end(); pos != end; ++pos)
-    {
-        if (i == 0)
-            return pos->second;
-        --i;
+TypeSP TypeMap::GetTypeAtIndex(uint32_t idx) {
+  iterator pos, end;
+  uint32_t i = idx;
+  for (pos = m_types.begin(), end = m_types.end(); pos != end; ++pos) {
+    if (i == 0)
+      return pos->second;
+    --i;
+  }
+  return TypeSP();
+}
+
+void TypeMap::ForEach(
+    std::function<bool(const lldb::TypeSP &type_sp)> const &callback) const {
+  for (auto pos = m_types.begin(), end = m_types.end(); pos != end; ++pos) {
+    if (!callback(pos->second))
+      break;
+  }
+}
+
+void TypeMap::ForEach(
+    std::function<bool(lldb::TypeSP &type_sp)> const &callback) {
+  for (auto pos = m_types.begin(), end = m_types.end(); pos != end; ++pos) {
+    if (!callback(pos->second))
+      break;
+  }
+}
+
+bool TypeMap::Remove(const lldb::TypeSP &type_sp) {
+  if (type_sp) {
+    lldb::user_id_t uid = type_sp->GetID();
+    for (iterator pos = m_types.find(uid), end = m_types.end();
+         pos != end && pos->first == uid; ++pos) {
+      if (pos->second == type_sp) {
+        m_types.erase(pos);
+        return true;
+      }
     }
-    return TypeSP();
+  }
+  return false;
 }
 
-void
-TypeMap::ForEach (std::function <bool(const lldb::TypeSP &type_sp)> const &callback) const
-{
-    for (auto pos = m_types.begin(), end = m_types.end(); pos != end; ++pos)
-    {
-        if (!callback(pos->second))
-            break;
+void TypeMap::Dump(Stream *s, bool show_context) {
+  for (iterator pos = m_types.begin(), end = m_types.end(); pos != end; ++pos) {
+    pos->second->Dump(s, show_context);
+  }
+}
+
+void TypeMap::RemoveMismatchedTypes(const char *qualified_typename,
+                                    bool exact_match) {
+  std::string type_scope;
+  std::string type_basename;
+  TypeClass type_class = eTypeClassAny;
+  if (!Type::GetTypeScopeAndBasename(qualified_typename, type_scope,
+                                     type_basename, type_class)) {
+    type_basename = qualified_typename;
+    type_scope.clear();
+  }
+  return RemoveMismatchedTypes(type_scope, type_basename, type_class,
+                               exact_match);
+}
+
+void TypeMap::RemoveMismatchedTypes(const std::string &type_scope,
+                                    const std::string &type_basename,
+                                    TypeClass type_class, bool exact_match) {
+  // Our "collection" type currently is a std::map which doesn't
+  // have any good way to iterate and remove items from the map
+  // so we currently just make a new list and add all of the matching
+  // types to it, and then swap it into m_types at the end
+  collection matching_types;
+
+  iterator pos, end = m_types.end();
+
+  for (pos = m_types.begin(); pos != end; ++pos) {
+    Type *the_type = pos->second.get();
+    bool keep_match = false;
+    TypeClass match_type_class = eTypeClassAny;
+
+    if (type_class != eTypeClassAny) {
+      match_type_class = the_type->GetForwardCompilerType().GetTypeClass();
+      if ((match_type_class & type_class) == 0)
+        continue;
     }
-}
-
-void
-TypeMap::ForEach (std::function <bool(lldb::TypeSP &type_sp)> const &callback)
-{
-    for (auto pos = m_types.begin(), end = m_types.end(); pos != end; ++pos)
-    {
-        if (!callback(pos->second))
-            break;
-    }
-}
 
-bool
-TypeMap::Remove (const lldb::TypeSP &type_sp)
-{
-    if (type_sp)
-    {
-        lldb::user_id_t uid = type_sp->GetID();
-        for (iterator pos = m_types.find(uid), end = m_types.end(); pos != end && pos->first == uid; ++pos)
-        {
-            if (pos->second == type_sp)
-            {
-                m_types.erase(pos);
-                return true;
+    ConstString match_type_name_const_str(the_type->GetQualifiedName());
+    if (match_type_name_const_str) {
+      const char *match_type_name = match_type_name_const_str.GetCString();
+      std::string match_type_scope;
+      std::string match_type_basename;
+      if (Type::GetTypeScopeAndBasename(match_type_name, match_type_scope,
+                                        match_type_basename,
+                                        match_type_class)) {
+        if (match_type_basename == type_basename) {
+          const size_t type_scope_size = type_scope.size();
+          const size_t match_type_scope_size = match_type_scope.size();
+          if (exact_match || (type_scope_size == match_type_scope_size)) {
+            keep_match = match_type_scope == type_scope;
+          } else {
+            if (match_type_scope_size > type_scope_size) {
+              const size_t type_scope_pos = match_type_scope.rfind(type_scope);
+              if (type_scope_pos == match_type_scope_size - type_scope_size) {
+                if (type_scope_pos >= 2) {
+                  // Our match scope ends with the type scope we were looking
+                  // for,
+                  // but we need to make sure what comes before the matching
+                  // type scope is a namespace boundary in case we are trying to
+                  // match:
+                  // type_basename = "d"
+                  // type_scope = "b::c::"
+                  // We want to match:
+                  //  match_type_scope "a::b::c::"
+                  // But not:
+                  //  match_type_scope "a::bb::c::"
+                  // So below we make sure what comes before "b::c::" in
+                  // match_type_scope
+                  // is "::", or the namespace boundary
+                  if (match_type_scope[type_scope_pos - 1] == ':' &&
+                      match_type_scope[type_scope_pos - 2] == ':') {
+                    keep_match = true;
+                  }
+                }
+              }
             }
+          }
         }
+      } else {
+        // The type we are currently looking at doesn't exists
+        // in a namespace or class, so it only matches if there
+        // is no type scope...
+        keep_match =
+            type_scope.empty() && type_basename.compare(match_type_name) == 0;
+      }
     }
-    return false;
-}
 
-void
-TypeMap::Dump(Stream *s, bool show_context)
-{
-    for (iterator pos = m_types.begin(), end = m_types.end(); pos != end; ++pos)
-    {
-        pos->second->Dump(s, show_context);
+    if (keep_match) {
+      matching_types.insert(*pos);
     }
+  }
+  m_types.swap(matching_types);
 }
 
-void
-TypeMap::RemoveMismatchedTypes (const char *qualified_typename,
-                                 bool exact_match)
-{
-    std::string type_scope;
-    std::string type_basename;
-    TypeClass type_class = eTypeClassAny;
-    if (!Type::GetTypeScopeAndBasename (qualified_typename, type_scope, type_basename, type_class))
-    {
-        type_basename = qualified_typename;
-        type_scope.clear();
-    }
-    return RemoveMismatchedTypes (type_scope, type_basename, type_class, exact_match);
-}
-
-void
-TypeMap::RemoveMismatchedTypes (const std::string &type_scope,
-                                 const std::string &type_basename,
-                                 TypeClass type_class,
-                                 bool exact_match)
-{
-    // Our "collection" type currently is a std::map which doesn't
-    // have any good way to iterate and remove items from the map
-    // so we currently just make a new list and add all of the matching
-    // types to it, and then swap it into m_types at the end
-    collection matching_types;
-
-    iterator pos, end = m_types.end();
-    
-    for (pos = m_types.begin(); pos != end; ++pos)
-    {
-        Type* the_type = pos->second.get();
-        bool keep_match = false;
-        TypeClass match_type_class = eTypeClassAny;
-
-        if (type_class != eTypeClassAny)
-        {
-            match_type_class = the_type->GetForwardCompilerType ().GetTypeClass ();
-            if ((match_type_class & type_class) == 0)
-                continue;
-        }
-
-        ConstString match_type_name_const_str (the_type->GetQualifiedName());
-        if (match_type_name_const_str)
-        {
-            const char *match_type_name = match_type_name_const_str.GetCString();
-            std::string match_type_scope;
-            std::string match_type_basename;
-            if (Type::GetTypeScopeAndBasename (match_type_name,
-                                               match_type_scope,
-                                               match_type_basename,
-                                               match_type_class))
-            {
-                if (match_type_basename == type_basename)
-                {
-                    const size_t type_scope_size = type_scope.size();
-                    const size_t match_type_scope_size = match_type_scope.size();
-                    if (exact_match || (type_scope_size == match_type_scope_size))
-                    {
-                        keep_match = match_type_scope == type_scope;
-                    }
-                    else
-                    {
-                        if (match_type_scope_size > type_scope_size)
-                        {
-                            const size_t type_scope_pos = match_type_scope.rfind(type_scope);
-                            if (type_scope_pos == match_type_scope_size - type_scope_size)
-                            {
-                                if (type_scope_pos >= 2)
-                                {
-                                    // Our match scope ends with the type scope we were looking for,
-                                    // but we need to make sure what comes before the matching
-                                    // type scope is a namespace boundary in case we are trying to match:
-                                    // type_basename = "d"
-                                    // type_scope = "b::c::"
-                                    // We want to match:
-                                    //  match_type_scope "a::b::c::"
-                                    // But not:
-                                    //  match_type_scope "a::bb::c::"
-                                    // So below we make sure what comes before "b::c::" in match_type_scope
-                                    // is "::", or the namespace boundary
-                                    if (match_type_scope[type_scope_pos - 1] == ':' &&
-                                        match_type_scope[type_scope_pos - 2] == ':')
-                                    {
-                                        keep_match = true;
-                                    }
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-            else
-            {
-                // The type we are currently looking at doesn't exists
-                // in a namespace or class, so it only matches if there
-                // is no type scope...
-                keep_match = type_scope.empty() && type_basename.compare(match_type_name) == 0;
-            }
-        }
-        
-        if (keep_match)
-        {
-            matching_types.insert (*pos);
-        }
-    }
-    m_types.swap(matching_types);
-}
-
-void
-TypeMap::RemoveMismatchedTypes (TypeClass type_class)
-{
-    if (type_class == eTypeClassAny)
-        return;
-
-    // Our "collection" type currently is a std::map which doesn't
-    // have any good way to iterate and remove items from the map
-    // so we currently just make a new list and add all of the matching
-    // types to it, and then swap it into m_types at the end
-    collection matching_types;
-    
-    iterator pos, end = m_types.end();
-    
-    for (pos = m_types.begin(); pos != end; ++pos)
-    {
-        Type* the_type = pos->second.get();
-        TypeClass match_type_class = the_type->GetForwardCompilerType ().GetTypeClass ();
-        if (match_type_class & type_class)
-            matching_types.insert (*pos);
-    }
-    m_types.swap(matching_types);
+void TypeMap::RemoveMismatchedTypes(TypeClass type_class) {
+  if (type_class == eTypeClassAny)
+    return;
+
+  // Our "collection" type currently is a std::map which doesn't
+  // have any good way to iterate and remove items from the map
+  // so we currently just make a new list and add all of the matching
+  // types to it, and then swap it into m_types at the end
+  collection matching_types;
+
+  iterator pos, end = m_types.end();
+
+  for (pos = m_types.begin(); pos != end; ++pos) {
+    Type *the_type = pos->second.get();
+    TypeClass match_type_class =
+        the_type->GetForwardCompilerType().GetTypeClass();
+    if (match_type_class & type_class)
+      matching_types.insert(*pos);
+  }
+  m_types.swap(matching_types);
 }

Modified: lldb/trunk/source/Symbol/TypeSystem.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/TypeSystem.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/TypeSystem.cpp (original)
+++ lldb/trunk/source/Symbol/TypeSystem.cpp Tue Sep  6 15:57:50 2016
@@ -15,278 +15,224 @@
 
 using namespace lldb_private;
 
-TypeSystem::TypeSystem(LLVMCastKind kind) :
-    m_kind (kind),
-    m_sym_file (nullptr)
-{
-}
-
-TypeSystem::~TypeSystem()
-{
-}
-
-lldb::TypeSystemSP
-TypeSystem::CreateInstance (lldb::LanguageType language, Module *module)
-{
-    uint32_t i = 0;
-    TypeSystemCreateInstance create_callback;
-    while ((create_callback = PluginManager::GetTypeSystemCreateCallbackAtIndex (i++)) != nullptr)
-    {
-        lldb::TypeSystemSP type_system_sp = create_callback(language, module, nullptr);
-        if (type_system_sp)
-            return type_system_sp;
-    }
+TypeSystem::TypeSystem(LLVMCastKind kind) : m_kind(kind), m_sym_file(nullptr) {}
 
-    return lldb::TypeSystemSP();
-}
+TypeSystem::~TypeSystem() {}
 
-lldb::TypeSystemSP
-TypeSystem::CreateInstance (lldb::LanguageType language, Target *target)
-{
-    uint32_t i = 0;
-    TypeSystemCreateInstance create_callback;
-    while ((create_callback = PluginManager::GetTypeSystemCreateCallbackAtIndex (i++)) != nullptr)
-    {
-        lldb::TypeSystemSP type_system_sp = create_callback(language, nullptr, target);
-        if (type_system_sp)
-            return type_system_sp;
-    }
+lldb::TypeSystemSP TypeSystem::CreateInstance(lldb::LanguageType language,
+                                              Module *module) {
+  uint32_t i = 0;
+  TypeSystemCreateInstance create_callback;
+  while ((create_callback = PluginManager::GetTypeSystemCreateCallbackAtIndex(
+              i++)) != nullptr) {
+    lldb::TypeSystemSP type_system_sp =
+        create_callback(language, module, nullptr);
+    if (type_system_sp)
+      return type_system_sp;
+  }
 
-    return lldb::TypeSystemSP();
+  return lldb::TypeSystemSP();
 }
 
-bool
-TypeSystem::IsAnonymousType (lldb::opaque_compiler_type_t type)
-{
-    return false;
-}
+lldb::TypeSystemSP TypeSystem::CreateInstance(lldb::LanguageType language,
+                                              Target *target) {
+  uint32_t i = 0;
+  TypeSystemCreateInstance create_callback;
+  while ((create_callback = PluginManager::GetTypeSystemCreateCallbackAtIndex(
+              i++)) != nullptr) {
+    lldb::TypeSystemSP type_system_sp =
+        create_callback(language, nullptr, target);
+    if (type_system_sp)
+      return type_system_sp;
+  }
 
-CompilerType
-TypeSystem::GetArrayType (lldb::opaque_compiler_type_t type, uint64_t size)
-{
-    return CompilerType();
+  return lldb::TypeSystemSP();
 }
 
-CompilerType
-TypeSystem::GetLValueReferenceType (lldb::opaque_compiler_type_t type)
-{
-    return CompilerType();
+bool TypeSystem::IsAnonymousType(lldb::opaque_compiler_type_t type) {
+  return false;
 }
 
-CompilerType
-TypeSystem::GetRValueReferenceType (lldb::opaque_compiler_type_t type)
-{
-    return CompilerType();
+CompilerType TypeSystem::GetArrayType(lldb::opaque_compiler_type_t type,
+                                      uint64_t size) {
+  return CompilerType();
 }
 
 CompilerType
-TypeSystem::AddConstModifier (lldb::opaque_compiler_type_t type)
-{
-    return CompilerType();
+TypeSystem::GetLValueReferenceType(lldb::opaque_compiler_type_t type) {
+  return CompilerType();
 }
 
 CompilerType
-TypeSystem::AddVolatileModifier (lldb::opaque_compiler_type_t type)
-{
-    return CompilerType();
+TypeSystem::GetRValueReferenceType(lldb::opaque_compiler_type_t type) {
+  return CompilerType();
 }
 
-CompilerType
-TypeSystem::AddRestrictModifier (lldb::opaque_compiler_type_t type)
-{
-    return CompilerType();
+CompilerType TypeSystem::AddConstModifier(lldb::opaque_compiler_type_t type) {
+  return CompilerType();
 }
 
 CompilerType
-TypeSystem::CreateTypedef (lldb::opaque_compiler_type_t type, const char *name, const CompilerDeclContext &decl_ctx)
-{
-    return CompilerType();
+TypeSystem::AddVolatileModifier(lldb::opaque_compiler_type_t type) {
+  return CompilerType();
 }
 
 CompilerType
-TypeSystem::GetBuiltinTypeByName (const ConstString &name)
-{
-    return CompilerType();
+TypeSystem::AddRestrictModifier(lldb::opaque_compiler_type_t type) {
+  return CompilerType();
 }
 
-CompilerType
-TypeSystem::GetTypeForFormatters (void* type)
-{
-    return CompilerType(this, type);
+CompilerType TypeSystem::CreateTypedef(lldb::opaque_compiler_type_t type,
+                                       const char *name,
+                                       const CompilerDeclContext &decl_ctx) {
+  return CompilerType();
 }
 
-LazyBool
-TypeSystem::ShouldPrintAsOneLiner (void* type, ValueObject* valobj)
-{
-    return eLazyBoolCalculate;
+CompilerType TypeSystem::GetBuiltinTypeByName(const ConstString &name) {
+  return CompilerType();
 }
 
-bool
-TypeSystem::IsMeaninglessWithoutDynamicResolution (void* type)
-{
-    return false;
+CompilerType TypeSystem::GetTypeForFormatters(void *type) {
+  return CompilerType(this, type);
 }
 
-ConstString
-TypeSystem::DeclGetMangledName (void *opaque_decl)
-{
-    return ConstString();
+LazyBool TypeSystem::ShouldPrintAsOneLiner(void *type, ValueObject *valobj) {
+  return eLazyBoolCalculate;
 }
 
-CompilerDeclContext
-TypeSystem::DeclGetDeclContext (void *opaque_decl)
-{
-    return CompilerDeclContext();
+bool TypeSystem::IsMeaninglessWithoutDynamicResolution(void *type) {
+  return false;
 }
 
-CompilerType
-TypeSystem::DeclGetFunctionReturnType(void *opaque_decl)
-{
-    return CompilerType();
-}
-
-size_t
-TypeSystem::DeclGetFunctionNumArguments(void *opaque_decl)
-{
-    return 0;
+ConstString TypeSystem::DeclGetMangledName(void *opaque_decl) {
+  return ConstString();
 }
 
-CompilerType
-TypeSystem::DeclGetFunctionArgumentType (void *opaque_decl, size_t arg_idx)
-{
-    return CompilerType();
+CompilerDeclContext TypeSystem::DeclGetDeclContext(void *opaque_decl) {
+  return CompilerDeclContext();
 }
 
-
-std::vector<CompilerDecl>
-TypeSystem::DeclContextFindDeclByName (void *opaque_decl_ctx,
-                                       ConstString name,
-                                       bool ignore_imported_decls)
-{
-    return std::vector<CompilerDecl>();
+CompilerType TypeSystem::DeclGetFunctionReturnType(void *opaque_decl) {
+  return CompilerType();
 }
 
+size_t TypeSystem::DeclGetFunctionNumArguments(void *opaque_decl) { return 0; }
 
-#pragma mark TypeSystemMap
-
-TypeSystemMap::TypeSystemMap() : m_mutex(), m_map(), m_clear_in_progress(false)
-{
+CompilerType TypeSystem::DeclGetFunctionArgumentType(void *opaque_decl,
+                                                     size_t arg_idx) {
+  return CompilerType();
 }
 
-TypeSystemMap::~TypeSystemMap()
-{
+std::vector<CompilerDecl>
+TypeSystem::DeclContextFindDeclByName(void *opaque_decl_ctx, ConstString name,
+                                      bool ignore_imported_decls) {
+  return std::vector<CompilerDecl>();
 }
 
-void
-TypeSystemMap::Clear ()
-{
-    collection map;
-    {
-        std::lock_guard<std::mutex> guard(m_mutex);
-        map = m_map;
-        m_clear_in_progress = true;
-    }
-    std::set<TypeSystem *> visited;
-    for (auto pair : map)
-    {
-        TypeSystem *type_system = pair.second.get();
-        if (type_system && !visited.count(type_system))
-        {
-            visited.insert(type_system);
-            type_system->Finalize();
-        }
-    }
-    map.clear();
-    {
-        std::lock_guard<std::mutex> guard(m_mutex);
-        m_map.clear();
-        m_clear_in_progress = false;
-    }
-}
+#pragma mark TypeSystemMap
 
+TypeSystemMap::TypeSystemMap()
+    : m_mutex(), m_map(), m_clear_in_progress(false) {}
 
-void
-TypeSystemMap::ForEach (std::function <bool(TypeSystem *)> const &callback)
-{
-    std::lock_guard<std::mutex> guard(m_mutex);
-    // Use a std::set so we only call the callback once for each unique
-    // TypeSystem instance
-    std::set<TypeSystem *> visited;
-    for (auto pair : m_map)
-    {
-        TypeSystem *type_system = pair.second.get();
-        if (type_system && !visited.count(type_system))
-        {
-            visited.insert(type_system);
-            if (callback (type_system) == false)
-                break;
-        }
-    }
-}
+TypeSystemMap::~TypeSystemMap() {}
 
-TypeSystem *
-TypeSystemMap::GetTypeSystemForLanguage (lldb::LanguageType language, Module *module, bool can_create)
-{
+void TypeSystemMap::Clear() {
+  collection map;
+  {
     std::lock_guard<std::mutex> guard(m_mutex);
-    collection::iterator pos = m_map.find(language);
-    if (pos != m_map.end())
-        return pos->second.get();
-
-    for (const auto &pair : m_map)
-    {
-        if (pair.second && pair.second->SupportsLanguage(language))
-        {
-            // Add a new mapping for "language" to point to an already existing
-            // TypeSystem that supports this language
-            AddToMap(language, pair.second);
-            return pair.second.get();
-        }
-    }
-
-    if (!can_create)
-        return nullptr;
-
-    // Cache even if we get a shared pointer that contains null type system back
-    lldb::TypeSystemSP type_system_sp = TypeSystem::CreateInstance (language, module);
-    AddToMap (language, type_system_sp);
-    return type_system_sp.get();
-}
-
-TypeSystem *
-TypeSystemMap::GetTypeSystemForLanguage (lldb::LanguageType language, Target *target, bool can_create)
-{
+    map = m_map;
+    m_clear_in_progress = true;
+  }
+  std::set<TypeSystem *> visited;
+  for (auto pair : map) {
+    TypeSystem *type_system = pair.second.get();
+    if (type_system && !visited.count(type_system)) {
+      visited.insert(type_system);
+      type_system->Finalize();
+    }
+  }
+  map.clear();
+  {
     std::lock_guard<std::mutex> guard(m_mutex);
-    collection::iterator pos = m_map.find(language);
-    if (pos != m_map.end())
-        return pos->second.get();
-
-    for (const auto &pair : m_map)
-    {
-        if (pair.second && pair.second->SupportsLanguage(language))
-        {
-            // Add a new mapping for "language" to point to an already existing
-            // TypeSystem that supports this language
-
-            AddToMap(language, pair.second);
-            return pair.second.get();
-        }
-    }
-
-    if (!can_create)
-        return nullptr;
-
-    // Cache even if we get a shared pointer that contains null type system back
-    lldb::TypeSystemSP type_system_sp;
-    if (!m_clear_in_progress)
-        type_system_sp = TypeSystem::CreateInstance (language, target);
-
-    AddToMap(language, type_system_sp);
-    return type_system_sp.get();
-}
-
-void
-TypeSystemMap::AddToMap (lldb::LanguageType language, lldb::TypeSystemSP const &type_system_sp)
-{
-    if (!m_clear_in_progress)
-        m_map[language] = type_system_sp;
+    m_map.clear();
+    m_clear_in_progress = false;
+  }
+}
+
+void TypeSystemMap::ForEach(std::function<bool(TypeSystem *)> const &callback) {
+  std::lock_guard<std::mutex> guard(m_mutex);
+  // Use a std::set so we only call the callback once for each unique
+  // TypeSystem instance
+  std::set<TypeSystem *> visited;
+  for (auto pair : m_map) {
+    TypeSystem *type_system = pair.second.get();
+    if (type_system && !visited.count(type_system)) {
+      visited.insert(type_system);
+      if (callback(type_system) == false)
+        break;
+    }
+  }
+}
+
+TypeSystem *TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType language,
+                                                    Module *module,
+                                                    bool can_create) {
+  std::lock_guard<std::mutex> guard(m_mutex);
+  collection::iterator pos = m_map.find(language);
+  if (pos != m_map.end())
+    return pos->second.get();
+
+  for (const auto &pair : m_map) {
+    if (pair.second && pair.second->SupportsLanguage(language)) {
+      // Add a new mapping for "language" to point to an already existing
+      // TypeSystem that supports this language
+      AddToMap(language, pair.second);
+      return pair.second.get();
+    }
+  }
+
+  if (!can_create)
+    return nullptr;
+
+  // Cache even if we get a shared pointer that contains null type system back
+  lldb::TypeSystemSP type_system_sp =
+      TypeSystem::CreateInstance(language, module);
+  AddToMap(language, type_system_sp);
+  return type_system_sp.get();
+}
+
+TypeSystem *TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType language,
+                                                    Target *target,
+                                                    bool can_create) {
+  std::lock_guard<std::mutex> guard(m_mutex);
+  collection::iterator pos = m_map.find(language);
+  if (pos != m_map.end())
+    return pos->second.get();
+
+  for (const auto &pair : m_map) {
+    if (pair.second && pair.second->SupportsLanguage(language)) {
+      // Add a new mapping for "language" to point to an already existing
+      // TypeSystem that supports this language
+
+      AddToMap(language, pair.second);
+      return pair.second.get();
+    }
+  }
+
+  if (!can_create)
+    return nullptr;
+
+  // Cache even if we get a shared pointer that contains null type system back
+  lldb::TypeSystemSP type_system_sp;
+  if (!m_clear_in_progress)
+    type_system_sp = TypeSystem::CreateInstance(language, target);
+
+  AddToMap(language, type_system_sp);
+  return type_system_sp.get();
+}
+
+void TypeSystemMap::AddToMap(lldb::LanguageType language,
+                             lldb::TypeSystemSP const &type_system_sp) {
+  if (!m_clear_in_progress)
+    m_map[language] = type_system_sp;
 }

Modified: lldb/trunk/source/Symbol/UnwindPlan.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/UnwindPlan.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/UnwindPlan.cpp (original)
+++ lldb/trunk/source/Symbol/UnwindPlan.cpp Tue Sep  6 15:57:50 2016
@@ -18,558 +18,497 @@
 using namespace lldb;
 using namespace lldb_private;
 
-bool
-UnwindPlan::Row::RegisterLocation::operator == (const UnwindPlan::Row::RegisterLocation& rhs) const
-{
-    if (m_type == rhs.m_type)
-    {
-        switch (m_type)
-        {
-            case unspecified:
-            case undefined:
-            case same:
-                return true;
-                
-            case atCFAPlusOffset:
-            case isCFAPlusOffset:
-                return m_location.offset == rhs.m_location.offset;
-
-            case inOtherRegister:
-                return m_location.reg_num == rhs.m_location.reg_num;
-            
-            case atDWARFExpression:
-            case isDWARFExpression:
-                if (m_location.expr.length == rhs.m_location.expr.length)
-                    return !memcmp (m_location.expr.opcodes, rhs.m_location.expr.opcodes, m_location.expr.length);
-                break;
-        }
-    }
-    return false;
-}
-
-// This function doesn't copy the dwarf expression bytes; they must remain in allocated
-// memory for the lifespan of this UnwindPlan object.
-void
-UnwindPlan::Row::RegisterLocation::SetAtDWARFExpression (const uint8_t *opcodes, uint32_t len)
-{
-    m_type = atDWARFExpression;
-    m_location.expr.opcodes = opcodes;
-    m_location.expr.length = len;
-}
-
-// This function doesn't copy the dwarf expression bytes; they must remain in allocated
-// memory for the lifespan of this UnwindPlan object.
-void
-UnwindPlan::Row::RegisterLocation::SetIsDWARFExpression (const uint8_t *opcodes, uint32_t len)
-{
-    m_type = isDWARFExpression;
-    m_location.expr.opcodes = opcodes;
-    m_location.expr.length = len;
-}
-
-void
-UnwindPlan::Row::RegisterLocation::Dump (Stream &s, const UnwindPlan* unwind_plan, const UnwindPlan::Row* row, Thread* thread, bool verbose) const
-{
-    switch (m_type)
-    {
-        case unspecified: 
-            if (verbose)
-                s.PutCString ("=<unspec>"); 
-            else
-                s.PutCString ("=!"); 
-            break;
-        case undefined: 
-            if (verbose)
-                s.PutCString ("=<undef>"); 
-            else
-                s.PutCString ("=?"); 
-            break;
-        case same: 
-            s.PutCString ("= <same>"); 
-            break;
-
-        case atCFAPlusOffset: 
-        case isCFAPlusOffset: 
-            {
-                s.PutChar('=');
-                if (m_type == atCFAPlusOffset)
-                    s.PutChar('[');
-                s.Printf ("CFA%+d", m_location.offset);
-                if (m_type == atCFAPlusOffset)
-                    s.PutChar(']');
-            }
-            break;
-
-        case inOtherRegister: 
-            {
-                const RegisterInfo *other_reg_info = nullptr;
-                if (unwind_plan)
-                    other_reg_info = unwind_plan->GetRegisterInfo (thread, m_location.reg_num);
-                if (other_reg_info)
-                    s.Printf ("=%s", other_reg_info->name); 
-                else
-                    s.Printf ("=reg(%u)", m_location.reg_num); 
-            }
-            break;
-
-        case atDWARFExpression: 
-        case isDWARFExpression: 
-            {
-                s.PutChar('=');
-                if (m_type == atDWARFExpression)
-                    s.PutCString("[dwarf-expr]");
-                else
-                    s.PutCString("dwarf-expr");
-            }
-            break;
-        
-    }
-}
+bool UnwindPlan::Row::RegisterLocation::
+operator==(const UnwindPlan::Row::RegisterLocation &rhs) const {
+  if (m_type == rhs.m_type) {
+    switch (m_type) {
+    case unspecified:
+    case undefined:
+    case same:
+      return true;
+
+    case atCFAPlusOffset:
+    case isCFAPlusOffset:
+      return m_location.offset == rhs.m_location.offset;
 
-static void
-DumpRegisterName (Stream &s, const UnwindPlan* unwind_plan, Thread *thread, uint32_t reg_num) {
-    const RegisterInfo *reg_info = unwind_plan->GetRegisterInfo (thread, reg_num);
-    if (reg_info)
-        s.PutCString (reg_info->name);
-    else
-        s.Printf ("reg(%u)", reg_num);
-}
-
-bool
-UnwindPlan::Row::CFAValue::operator == (const UnwindPlan::Row::CFAValue& rhs) const
-{
-    if (m_type == rhs.m_type)
-    {
-        switch (m_type)
-        {
-            case unspecified:
-                return true;
-
-            case isRegisterPlusOffset:
-                return m_value.reg.offset == rhs.m_value.reg.offset;
-
-            case isRegisterDereferenced:
-                return m_value.reg.reg_num == rhs.m_value.reg.reg_num;
-
-            case isDWARFExpression:
-                if (m_value.expr.length == rhs.m_value.expr.length)
-                    return !memcmp (m_value.expr.opcodes, rhs.m_value.expr.opcodes, m_value.expr.length);
-                break;
-        }
-    }
-    return false;
-}
+    case inOtherRegister:
+      return m_location.reg_num == rhs.m_location.reg_num;
 
-void
-UnwindPlan::Row::CFAValue::Dump(Stream &s, const UnwindPlan* unwind_plan, Thread* thread) const
-{
-    switch(m_type) {
-    case isRegisterPlusOffset:
-        DumpRegisterName(s, unwind_plan, thread, m_value.reg.reg_num);
-        s.Printf ("%+3d", m_value.reg.offset);
-        break;
-    case isRegisterDereferenced:
-        s.PutChar ('[');
-        DumpRegisterName(s, unwind_plan, thread, m_value.reg.reg_num);
-        s.PutChar (']');
-        break;
+    case atDWARFExpression:
     case isDWARFExpression:
-        s.PutCString ("dwarf-expr");
-        break;
-    default:
-        s.PutCString ("unspecified");
-        break;
+      if (m_location.expr.length == rhs.m_location.expr.length)
+        return !memcmp(m_location.expr.opcodes, rhs.m_location.expr.opcodes,
+                       m_location.expr.length);
+      break;
     }
+  }
+  return false;
 }
 
-void
-UnwindPlan::Row::Clear ()
-{
-    m_cfa_value.SetUnspecified();
-    m_offset = 0;
-    m_register_locations.clear();
+// This function doesn't copy the dwarf expression bytes; they must remain in
+// allocated
+// memory for the lifespan of this UnwindPlan object.
+void UnwindPlan::Row::RegisterLocation::SetAtDWARFExpression(
+    const uint8_t *opcodes, uint32_t len) {
+  m_type = atDWARFExpression;
+  m_location.expr.opcodes = opcodes;
+  m_location.expr.length = len;
 }
 
-void
-UnwindPlan::Row::Dump (Stream& s, const UnwindPlan* unwind_plan, Thread* thread, addr_t base_addr) const
-{
-    if (base_addr != LLDB_INVALID_ADDRESS)
-        s.Printf ("0x%16.16" PRIx64 ": CFA=", base_addr + GetOffset());
+// This function doesn't copy the dwarf expression bytes; they must remain in
+// allocated
+// memory for the lifespan of this UnwindPlan object.
+void UnwindPlan::Row::RegisterLocation::SetIsDWARFExpression(
+    const uint8_t *opcodes, uint32_t len) {
+  m_type = isDWARFExpression;
+  m_location.expr.opcodes = opcodes;
+  m_location.expr.length = len;
+}
+
+void UnwindPlan::Row::RegisterLocation::Dump(Stream &s,
+                                             const UnwindPlan *unwind_plan,
+                                             const UnwindPlan::Row *row,
+                                             Thread *thread,
+                                             bool verbose) const {
+  switch (m_type) {
+  case unspecified:
+    if (verbose)
+      s.PutCString("=<unspec>");
     else
-        s.Printf ("%4" PRId64 ": CFA=", GetOffset());
-            
-    m_cfa_value.Dump(s, unwind_plan, thread);
-    s.Printf(" => ");
-    for (collection::const_iterator idx = m_register_locations.begin (); idx != m_register_locations.end (); ++idx)
-    {
-        DumpRegisterName(s, unwind_plan, thread, idx->first);
-        const bool verbose = false;
-        idx->second.Dump(s, unwind_plan, this, thread, verbose);
-        s.PutChar (' ');
-    }
-    s.EOL();
-}
-
-UnwindPlan::Row::Row() :
-    m_offset (0),
-    m_cfa_value (),
-    m_register_locations ()
-{
-}
-
-bool
-UnwindPlan::Row::GetRegisterInfo (uint32_t reg_num, UnwindPlan::Row::RegisterLocation& register_location) const
-{
-    collection::const_iterator pos = m_register_locations.find(reg_num);
-    if (pos != m_register_locations.end())
-    {
-        register_location = pos->second;
-        return true;
-    }
-    return false;
-}
-
-void
-UnwindPlan::Row::RemoveRegisterInfo (uint32_t reg_num)
-{
-    collection::const_iterator pos = m_register_locations.find(reg_num);
-    if (pos != m_register_locations.end())
-    {
-        m_register_locations.erase(pos);
-    }
-}
-
-void
-UnwindPlan::Row::SetRegisterInfo (uint32_t reg_num, const UnwindPlan::Row::RegisterLocation register_location)
-{
-    m_register_locations[reg_num] = register_location;
-}
+      s.PutCString("=!");
+    break;
+  case undefined:
+    if (verbose)
+      s.PutCString("=<undef>");
+    else
+      s.PutCString("=?");
+    break;
+  case same:
+    s.PutCString("= <same>");
+    break;
+
+  case atCFAPlusOffset:
+  case isCFAPlusOffset: {
+    s.PutChar('=');
+    if (m_type == atCFAPlusOffset)
+      s.PutChar('[');
+    s.Printf("CFA%+d", m_location.offset);
+    if (m_type == atCFAPlusOffset)
+      s.PutChar(']');
+  } break;
+
+  case inOtherRegister: {
+    const RegisterInfo *other_reg_info = nullptr;
+    if (unwind_plan)
+      other_reg_info = unwind_plan->GetRegisterInfo(thread, m_location.reg_num);
+    if (other_reg_info)
+      s.Printf("=%s", other_reg_info->name);
+    else
+      s.Printf("=reg(%u)", m_location.reg_num);
+  } break;
 
-bool
-UnwindPlan::Row::SetRegisterLocationToAtCFAPlusOffset (uint32_t reg_num, int32_t offset, bool can_replace)
-{
-    if (!can_replace && m_register_locations.find(reg_num) != m_register_locations.end())
-        return false;
-    RegisterLocation reg_loc;
-    reg_loc.SetAtCFAPlusOffset(offset);
-    m_register_locations[reg_num] = reg_loc;
-    return true;
-}
+  case atDWARFExpression:
+  case isDWARFExpression: {
+    s.PutChar('=');
+    if (m_type == atDWARFExpression)
+      s.PutCString("[dwarf-expr]");
+    else
+      s.PutCString("dwarf-expr");
+  } break;
+  }
+}
+
+static void DumpRegisterName(Stream &s, const UnwindPlan *unwind_plan,
+                             Thread *thread, uint32_t reg_num) {
+  const RegisterInfo *reg_info = unwind_plan->GetRegisterInfo(thread, reg_num);
+  if (reg_info)
+    s.PutCString(reg_info->name);
+  else
+    s.Printf("reg(%u)", reg_num);
+}
+
+bool UnwindPlan::Row::CFAValue::
+operator==(const UnwindPlan::Row::CFAValue &rhs) const {
+  if (m_type == rhs.m_type) {
+    switch (m_type) {
+    case unspecified:
+      return true;
 
-bool
-UnwindPlan::Row::SetRegisterLocationToIsCFAPlusOffset (uint32_t reg_num, int32_t offset, bool can_replace)
-{
-    if (!can_replace && m_register_locations.find(reg_num) != m_register_locations.end())
-        return false;
-    RegisterLocation reg_loc;
-    reg_loc.SetIsCFAPlusOffset(offset);
-    m_register_locations[reg_num] = reg_loc;
-    return true;
-}
+    case isRegisterPlusOffset:
+      return m_value.reg.offset == rhs.m_value.reg.offset;
 
-bool
-UnwindPlan::Row::SetRegisterLocationToUndefined (uint32_t reg_num, bool can_replace, bool can_replace_only_if_unspecified)
-{
-    collection::iterator pos = m_register_locations.find(reg_num);
-    collection::iterator end = m_register_locations.end();
-    
-    if (pos != end)
-    {
-        if (!can_replace)
-            return false;
-        if (can_replace_only_if_unspecified && !pos->second.IsUnspecified())
-            return false;
-    }
-    RegisterLocation reg_loc;
-    reg_loc.SetUndefined();
-    m_register_locations[reg_num] = reg_loc;
-    return true;
-}
+    case isRegisterDereferenced:
+      return m_value.reg.reg_num == rhs.m_value.reg.reg_num;
 
-bool
-UnwindPlan::Row::SetRegisterLocationToUnspecified (uint32_t reg_num, bool can_replace)
-{
-    if (!can_replace && m_register_locations.find(reg_num) != m_register_locations.end())
-        return false;
-    RegisterLocation reg_loc;
-    reg_loc.SetUnspecified();
-    m_register_locations[reg_num] = reg_loc;
+    case isDWARFExpression:
+      if (m_value.expr.length == rhs.m_value.expr.length)
+        return !memcmp(m_value.expr.opcodes, rhs.m_value.expr.opcodes,
+                       m_value.expr.length);
+      break;
+    }
+  }
+  return false;
+}
+
+void UnwindPlan::Row::CFAValue::Dump(Stream &s, const UnwindPlan *unwind_plan,
+                                     Thread *thread) const {
+  switch (m_type) {
+  case isRegisterPlusOffset:
+    DumpRegisterName(s, unwind_plan, thread, m_value.reg.reg_num);
+    s.Printf("%+3d", m_value.reg.offset);
+    break;
+  case isRegisterDereferenced:
+    s.PutChar('[');
+    DumpRegisterName(s, unwind_plan, thread, m_value.reg.reg_num);
+    s.PutChar(']');
+    break;
+  case isDWARFExpression:
+    s.PutCString("dwarf-expr");
+    break;
+  default:
+    s.PutCString("unspecified");
+    break;
+  }
+}
+
+void UnwindPlan::Row::Clear() {
+  m_cfa_value.SetUnspecified();
+  m_offset = 0;
+  m_register_locations.clear();
+}
+
+void UnwindPlan::Row::Dump(Stream &s, const UnwindPlan *unwind_plan,
+                           Thread *thread, addr_t base_addr) const {
+  if (base_addr != LLDB_INVALID_ADDRESS)
+    s.Printf("0x%16.16" PRIx64 ": CFA=", base_addr + GetOffset());
+  else
+    s.Printf("%4" PRId64 ": CFA=", GetOffset());
+
+  m_cfa_value.Dump(s, unwind_plan, thread);
+  s.Printf(" => ");
+  for (collection::const_iterator idx = m_register_locations.begin();
+       idx != m_register_locations.end(); ++idx) {
+    DumpRegisterName(s, unwind_plan, thread, idx->first);
+    const bool verbose = false;
+    idx->second.Dump(s, unwind_plan, this, thread, verbose);
+    s.PutChar(' ');
+  }
+  s.EOL();
+}
+
+UnwindPlan::Row::Row() : m_offset(0), m_cfa_value(), m_register_locations() {}
+
+bool UnwindPlan::Row::GetRegisterInfo(
+    uint32_t reg_num,
+    UnwindPlan::Row::RegisterLocation &register_location) const {
+  collection::const_iterator pos = m_register_locations.find(reg_num);
+  if (pos != m_register_locations.end()) {
+    register_location = pos->second;
     return true;
+  }
+  return false;
 }
 
-bool
-UnwindPlan::Row::SetRegisterLocationToRegister (uint32_t reg_num, 
-                                                uint32_t other_reg_num,
-                                                bool can_replace)
-{
-    if (!can_replace && m_register_locations.find(reg_num) != m_register_locations.end())
-        return false;
-    RegisterLocation reg_loc;
-    reg_loc.SetInRegister(other_reg_num);
-    m_register_locations[reg_num] = reg_loc;
-    return true;
+void UnwindPlan::Row::RemoveRegisterInfo(uint32_t reg_num) {
+  collection::const_iterator pos = m_register_locations.find(reg_num);
+  if (pos != m_register_locations.end()) {
+    m_register_locations.erase(pos);
+  }
 }
 
-bool
-UnwindPlan::Row::SetRegisterLocationToSame (uint32_t reg_num, bool must_replace)
-{
-    if (must_replace && m_register_locations.find(reg_num) == m_register_locations.end())
-        return false;
-    RegisterLocation reg_loc;
-    reg_loc.SetSame();
-    m_register_locations[reg_num] = reg_loc;
-    return true;
+void UnwindPlan::Row::SetRegisterInfo(
+    uint32_t reg_num,
+    const UnwindPlan::Row::RegisterLocation register_location) {
+  m_register_locations[reg_num] = register_location;
 }
 
-bool
-UnwindPlan::Row::operator == (const UnwindPlan::Row& rhs) const
-{
-    return m_offset == rhs.m_offset && m_cfa_value == rhs.m_cfa_value &&
-        m_register_locations == rhs.m_register_locations;
+bool UnwindPlan::Row::SetRegisterLocationToAtCFAPlusOffset(uint32_t reg_num,
+                                                           int32_t offset,
+                                                           bool can_replace) {
+  if (!can_replace &&
+      m_register_locations.find(reg_num) != m_register_locations.end())
+    return false;
+  RegisterLocation reg_loc;
+  reg_loc.SetAtCFAPlusOffset(offset);
+  m_register_locations[reg_num] = reg_loc;
+  return true;
 }
 
-void
-UnwindPlan::AppendRow (const UnwindPlan::RowSP &row_sp)
-{
-    if (m_row_list.empty() || m_row_list.back()->GetOffset() != row_sp->GetOffset())
-        m_row_list.push_back(row_sp);
-    else
-        m_row_list.back() = row_sp;
+bool UnwindPlan::Row::SetRegisterLocationToIsCFAPlusOffset(uint32_t reg_num,
+                                                           int32_t offset,
+                                                           bool can_replace) {
+  if (!can_replace &&
+      m_register_locations.find(reg_num) != m_register_locations.end())
+    return false;
+  RegisterLocation reg_loc;
+  reg_loc.SetIsCFAPlusOffset(offset);
+  m_register_locations[reg_num] = reg_loc;
+  return true;
+}
+
+bool UnwindPlan::Row::SetRegisterLocationToUndefined(
+    uint32_t reg_num, bool can_replace, bool can_replace_only_if_unspecified) {
+  collection::iterator pos = m_register_locations.find(reg_num);
+  collection::iterator end = m_register_locations.end();
+
+  if (pos != end) {
+    if (!can_replace)
+      return false;
+    if (can_replace_only_if_unspecified && !pos->second.IsUnspecified())
+      return false;
+  }
+  RegisterLocation reg_loc;
+  reg_loc.SetUndefined();
+  m_register_locations[reg_num] = reg_loc;
+  return true;
+}
+
+bool UnwindPlan::Row::SetRegisterLocationToUnspecified(uint32_t reg_num,
+                                                       bool can_replace) {
+  if (!can_replace &&
+      m_register_locations.find(reg_num) != m_register_locations.end())
+    return false;
+  RegisterLocation reg_loc;
+  reg_loc.SetUnspecified();
+  m_register_locations[reg_num] = reg_loc;
+  return true;
 }
 
-void
-UnwindPlan::InsertRow (const UnwindPlan::RowSP &row_sp, bool replace_existing)
-{
-    collection::iterator it = m_row_list.begin();
-    while (it != m_row_list.end()) {
-        RowSP row = *it;
-        if (row->GetOffset() >= row_sp->GetOffset())
-            break;
-        it++;
-    }
-    if (it == m_row_list.end() || (*it)->GetOffset() != row_sp->GetOffset())
-        m_row_list.insert(it, row_sp);
-    else if (replace_existing)
-        *it = row_sp;
+bool UnwindPlan::Row::SetRegisterLocationToRegister(uint32_t reg_num,
+                                                    uint32_t other_reg_num,
+                                                    bool can_replace) {
+  if (!can_replace &&
+      m_register_locations.find(reg_num) != m_register_locations.end())
+    return false;
+  RegisterLocation reg_loc;
+  reg_loc.SetInRegister(other_reg_num);
+  m_register_locations[reg_num] = reg_loc;
+  return true;
 }
 
-UnwindPlan::RowSP
-UnwindPlan::GetRowForFunctionOffset (int offset) const
-{
-    RowSP row;
-    if (!m_row_list.empty())
-    {
-        if (offset == -1)
-            row = m_row_list.back();
+bool UnwindPlan::Row::SetRegisterLocationToSame(uint32_t reg_num,
+                                                bool must_replace) {
+  if (must_replace &&
+      m_register_locations.find(reg_num) == m_register_locations.end())
+    return false;
+  RegisterLocation reg_loc;
+  reg_loc.SetSame();
+  m_register_locations[reg_num] = reg_loc;
+  return true;
+}
+
+bool UnwindPlan::Row::operator==(const UnwindPlan::Row &rhs) const {
+  return m_offset == rhs.m_offset && m_cfa_value == rhs.m_cfa_value &&
+         m_register_locations == rhs.m_register_locations;
+}
+
+void UnwindPlan::AppendRow(const UnwindPlan::RowSP &row_sp) {
+  if (m_row_list.empty() ||
+      m_row_list.back()->GetOffset() != row_sp->GetOffset())
+    m_row_list.push_back(row_sp);
+  else
+    m_row_list.back() = row_sp;
+}
+
+void UnwindPlan::InsertRow(const UnwindPlan::RowSP &row_sp,
+                           bool replace_existing) {
+  collection::iterator it = m_row_list.begin();
+  while (it != m_row_list.end()) {
+    RowSP row = *it;
+    if (row->GetOffset() >= row_sp->GetOffset())
+      break;
+    it++;
+  }
+  if (it == m_row_list.end() || (*it)->GetOffset() != row_sp->GetOffset())
+    m_row_list.insert(it, row_sp);
+  else if (replace_existing)
+    *it = row_sp;
+}
+
+UnwindPlan::RowSP UnwindPlan::GetRowForFunctionOffset(int offset) const {
+  RowSP row;
+  if (!m_row_list.empty()) {
+    if (offset == -1)
+      row = m_row_list.back();
+    else {
+      collection::const_iterator pos, end = m_row_list.end();
+      for (pos = m_row_list.begin(); pos != end; ++pos) {
+        if ((*pos)->GetOffset() <= static_cast<lldb::offset_t>(offset))
+          row = *pos;
         else
-        {
-            collection::const_iterator pos, end = m_row_list.end();
-            for (pos = m_row_list.begin(); pos != end; ++pos)
-            {
-                if ((*pos)->GetOffset() <= static_cast<lldb::offset_t>(offset))
-                    row = *pos;
-                else
-                    break;
-            }
-        }
-    }
-    return row;
-}
-
-bool
-UnwindPlan::IsValidRowIndex (uint32_t idx) const
-{
-    return idx < m_row_list.size();
-}
-
-const UnwindPlan::RowSP
-UnwindPlan::GetRowAtIndex (uint32_t idx) const
-{
-    if (idx < m_row_list.size())
-        return m_row_list[idx];
-    else
-    {
-        Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND));
-        if (log)
-            log->Printf ("error: UnwindPlan::GetRowAtIndex(idx = %u) invalid index (number rows is %u)", idx, (uint32_t)m_row_list.size());
-        return UnwindPlan::RowSP();
-    }
-}
-
-const UnwindPlan::RowSP
-UnwindPlan::GetLastRow () const
-{
-    if (m_row_list.empty())
-    {
-        Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND));
-        if (log)
-            log->Printf ("UnwindPlan::GetLastRow() when rows are empty");
-        return UnwindPlan::RowSP();
+          break;
+      }
     }
-    return m_row_list.back();
+  }
+  return row;
 }
 
-int
-UnwindPlan::GetRowCount () const
-{
-    return m_row_list.size ();
-}
-
-void
-UnwindPlan::SetPlanValidAddressRange (const AddressRange& range)
-{
-   if (range.GetBaseAddress().IsValid() && range.GetByteSize() != 0)
-       m_plan_valid_address_range = range;
-}
-
-bool
-UnwindPlan::PlanValidAtAddress (Address addr)
-{
-    // If this UnwindPlan has no rows, it is an invalid UnwindPlan.
-    if (GetRowCount() == 0)
-    {
-        Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND));
-        if (log)
-        {
-            StreamString s;
-            if (addr.Dump (&s, nullptr, Address::DumpStyleSectionNameOffset))
-            {
-                log->Printf ("UnwindPlan is invalid -- no unwind rows for UnwindPlan '%s' at address %s",
-                             m_source_name.GetCString(), s.GetData());
-            }
-            else
-            {
-                log->Printf ("UnwindPlan is invalid -- no unwind rows for UnwindPlan '%s'",
-                             m_source_name.GetCString());
-            }
-        }
-        return false;
+bool UnwindPlan::IsValidRowIndex(uint32_t idx) const {
+  return idx < m_row_list.size();
+}
+
+const UnwindPlan::RowSP UnwindPlan::GetRowAtIndex(uint32_t idx) const {
+  if (idx < m_row_list.size())
+    return m_row_list[idx];
+  else {
+    Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_UNWIND));
+    if (log)
+      log->Printf("error: UnwindPlan::GetRowAtIndex(idx = %u) invalid index "
+                  "(number rows is %u)",
+                  idx, (uint32_t)m_row_list.size());
+    return UnwindPlan::RowSP();
+  }
+}
+
+const UnwindPlan::RowSP UnwindPlan::GetLastRow() const {
+  if (m_row_list.empty()) {
+    Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_UNWIND));
+    if (log)
+      log->Printf("UnwindPlan::GetLastRow() when rows are empty");
+    return UnwindPlan::RowSP();
+  }
+  return m_row_list.back();
+}
+
+int UnwindPlan::GetRowCount() const { return m_row_list.size(); }
+
+void UnwindPlan::SetPlanValidAddressRange(const AddressRange &range) {
+  if (range.GetBaseAddress().IsValid() && range.GetByteSize() != 0)
+    m_plan_valid_address_range = range;
+}
+
+bool UnwindPlan::PlanValidAtAddress(Address addr) {
+  // If this UnwindPlan has no rows, it is an invalid UnwindPlan.
+  if (GetRowCount() == 0) {
+    Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_UNWIND));
+    if (log) {
+      StreamString s;
+      if (addr.Dump(&s, nullptr, Address::DumpStyleSectionNameOffset)) {
+        log->Printf("UnwindPlan is invalid -- no unwind rows for UnwindPlan "
+                    "'%s' at address %s",
+                    m_source_name.GetCString(), s.GetData());
+      } else {
+        log->Printf(
+            "UnwindPlan is invalid -- no unwind rows for UnwindPlan '%s'",
+            m_source_name.GetCString());
+      }
     }
+    return false;
+  }
 
-    // If the 0th Row of unwind instructions is missing, or if it doesn't provide
-    // a register to use to find the Canonical Frame Address, this is not a valid UnwindPlan.
-    if (GetRowAtIndex(0).get() == nullptr ||
-            GetRowAtIndex(0)->GetCFAValue().GetValueType() == Row::CFAValue::unspecified)
-    {
-        Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND));
-        if (log)
-        {
-            StreamString s;
-            if (addr.Dump (&s, nullptr, Address::DumpStyleSectionNameOffset))
-            {
-                log->Printf ("UnwindPlan is invalid -- no CFA register defined in row 0 for UnwindPlan '%s' at address %s",
-                             m_source_name.GetCString(), s.GetData());
-            }
-            else
-            {
-                log->Printf ("UnwindPlan is invalid -- no CFA register defined in row 0 for UnwindPlan '%s'",
-                             m_source_name.GetCString());
-            }
-        }
-        return false;
+  // If the 0th Row of unwind instructions is missing, or if it doesn't provide
+  // a register to use to find the Canonical Frame Address, this is not a valid
+  // UnwindPlan.
+  if (GetRowAtIndex(0).get() == nullptr ||
+      GetRowAtIndex(0)->GetCFAValue().GetValueType() ==
+          Row::CFAValue::unspecified) {
+    Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_UNWIND));
+    if (log) {
+      StreamString s;
+      if (addr.Dump(&s, nullptr, Address::DumpStyleSectionNameOffset)) {
+        log->Printf("UnwindPlan is invalid -- no CFA register defined in row 0 "
+                    "for UnwindPlan '%s' at address %s",
+                    m_source_name.GetCString(), s.GetData());
+      } else {
+        log->Printf("UnwindPlan is invalid -- no CFA register defined in row 0 "
+                    "for UnwindPlan '%s'",
+                    m_source_name.GetCString());
+      }
     }
+    return false;
+  }
 
-    if (!m_plan_valid_address_range.GetBaseAddress().IsValid() || m_plan_valid_address_range.GetByteSize() == 0)
-        return true;
-
-    if (!addr.IsValid())
-        return true;
+  if (!m_plan_valid_address_range.GetBaseAddress().IsValid() ||
+      m_plan_valid_address_range.GetByteSize() == 0)
+    return true;
 
-    if (m_plan_valid_address_range.ContainsFileAddress (addr))
-        return true;
+  if (!addr.IsValid())
+    return true;
 
-    return false;
-}
+  if (m_plan_valid_address_range.ContainsFileAddress(addr))
+    return true;
 
-void
-UnwindPlan::Dump (Stream& s, Thread *thread, lldb::addr_t base_addr) const
-{
-    if (!m_source_name.IsEmpty())
-    {
-        s.Printf ("This UnwindPlan originally sourced from %s\n", m_source_name.GetCString());
-    }
-    if (m_lsda_address.IsValid() && m_personality_func_addr.IsValid())
-    {
-        TargetSP target_sp(thread->CalculateTarget());
-        addr_t lsda_load_addr = m_lsda_address.GetLoadAddress (target_sp.get());
-        addr_t personality_func_load_addr = m_personality_func_addr.GetLoadAddress (target_sp.get());
-        
-        if (lsda_load_addr != LLDB_INVALID_ADDRESS && personality_func_load_addr != LLDB_INVALID_ADDRESS)
-        {
-            s.Printf("LSDA address 0x%" PRIx64 ", personality routine is at address 0x%" PRIx64 "\n",
-                     lsda_load_addr, personality_func_load_addr);
-        }
-    }
-    s.Printf ("This UnwindPlan is sourced from the compiler: ");
-    switch (m_plan_is_sourced_from_compiler)
-    {
-        case eLazyBoolYes:
-            s.Printf ("yes.\n");
-            break;
-        case eLazyBoolNo:
-            s.Printf ("no.\n");
-            break;
-        case eLazyBoolCalculate:
-            s.Printf ("not specified.\n");
-            break;
-    }
-    s.Printf ("This UnwindPlan is valid at all instruction locations: ");
-    switch (m_plan_is_valid_at_all_instruction_locations)
-    {
-        case eLazyBoolYes:
-            s.Printf ("yes.\n");
-            break;
-        case eLazyBoolNo:
-            s.Printf ("no.\n");
-            break;
-        case eLazyBoolCalculate:
-            s.Printf ("not specified.\n");
-            break;
-    }
-    if (m_plan_valid_address_range.GetBaseAddress().IsValid() && m_plan_valid_address_range.GetByteSize() > 0)
-    {
-        s.PutCString ("Address range of this UnwindPlan: ");
-        TargetSP target_sp(thread->CalculateTarget());
-        m_plan_valid_address_range.Dump (&s, target_sp.get(), Address::DumpStyleSectionNameOffset);
-        s.EOL();
-    }
-    collection::const_iterator pos, begin = m_row_list.begin(), end = m_row_list.end();
-    for (pos = begin; pos != end; ++pos)
-    {
-        s.Printf ("row[%u]: ", (uint32_t)std::distance (begin, pos));
-        (*pos)->Dump(s, this, thread, base_addr);
-    }
+  return false;
 }
 
-void
-UnwindPlan::SetSourceName (const char *source)
-{
-    m_source_name = ConstString (source);
-}
-
-ConstString
-UnwindPlan::GetSourceName () const
-{
-    return m_source_name;
-}
-
-const RegisterInfo *
-UnwindPlan::GetRegisterInfo (Thread* thread, uint32_t unwind_reg) const
-{
-    if (thread)
-    {
-        RegisterContext *reg_ctx = thread->GetRegisterContext().get();
-        if (reg_ctx)
-        {
-            uint32_t reg;
-            if (m_register_kind == eRegisterKindLLDB)
-                reg = unwind_reg;
-            else
-                reg = reg_ctx->ConvertRegisterKindToRegisterNumber (m_register_kind, unwind_reg);
-            if (reg != LLDB_INVALID_REGNUM)
-                return reg_ctx->GetRegisterInfoAtIndex (reg);
-        }
+void UnwindPlan::Dump(Stream &s, Thread *thread, lldb::addr_t base_addr) const {
+  if (!m_source_name.IsEmpty()) {
+    s.Printf("This UnwindPlan originally sourced from %s\n",
+             m_source_name.GetCString());
+  }
+  if (m_lsda_address.IsValid() && m_personality_func_addr.IsValid()) {
+    TargetSP target_sp(thread->CalculateTarget());
+    addr_t lsda_load_addr = m_lsda_address.GetLoadAddress(target_sp.get());
+    addr_t personality_func_load_addr =
+        m_personality_func_addr.GetLoadAddress(target_sp.get());
+
+    if (lsda_load_addr != LLDB_INVALID_ADDRESS &&
+        personality_func_load_addr != LLDB_INVALID_ADDRESS) {
+      s.Printf("LSDA address 0x%" PRIx64
+               ", personality routine is at address 0x%" PRIx64 "\n",
+               lsda_load_addr, personality_func_load_addr);
+    }
+  }
+  s.Printf("This UnwindPlan is sourced from the compiler: ");
+  switch (m_plan_is_sourced_from_compiler) {
+  case eLazyBoolYes:
+    s.Printf("yes.\n");
+    break;
+  case eLazyBoolNo:
+    s.Printf("no.\n");
+    break;
+  case eLazyBoolCalculate:
+    s.Printf("not specified.\n");
+    break;
+  }
+  s.Printf("This UnwindPlan is valid at all instruction locations: ");
+  switch (m_plan_is_valid_at_all_instruction_locations) {
+  case eLazyBoolYes:
+    s.Printf("yes.\n");
+    break;
+  case eLazyBoolNo:
+    s.Printf("no.\n");
+    break;
+  case eLazyBoolCalculate:
+    s.Printf("not specified.\n");
+    break;
+  }
+  if (m_plan_valid_address_range.GetBaseAddress().IsValid() &&
+      m_plan_valid_address_range.GetByteSize() > 0) {
+    s.PutCString("Address range of this UnwindPlan: ");
+    TargetSP target_sp(thread->CalculateTarget());
+    m_plan_valid_address_range.Dump(&s, target_sp.get(),
+                                    Address::DumpStyleSectionNameOffset);
+    s.EOL();
+  }
+  collection::const_iterator pos, begin = m_row_list.begin(),
+                                  end = m_row_list.end();
+  for (pos = begin; pos != end; ++pos) {
+    s.Printf("row[%u]: ", (uint32_t)std::distance(begin, pos));
+    (*pos)->Dump(s, this, thread, base_addr);
+  }
+}
+
+void UnwindPlan::SetSourceName(const char *source) {
+  m_source_name = ConstString(source);
+}
+
+ConstString UnwindPlan::GetSourceName() const { return m_source_name; }
+
+const RegisterInfo *UnwindPlan::GetRegisterInfo(Thread *thread,
+                                                uint32_t unwind_reg) const {
+  if (thread) {
+    RegisterContext *reg_ctx = thread->GetRegisterContext().get();
+    if (reg_ctx) {
+      uint32_t reg;
+      if (m_register_kind == eRegisterKindLLDB)
+        reg = unwind_reg;
+      else
+        reg = reg_ctx->ConvertRegisterKindToRegisterNumber(m_register_kind,
+                                                           unwind_reg);
+      if (reg != LLDB_INVALID_REGNUM)
+        return reg_ctx->GetRegisterInfoAtIndex(reg);
     }
-    return nullptr;
+  }
+  return nullptr;
 }
-    

Modified: lldb/trunk/source/Symbol/UnwindTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/UnwindTable.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/UnwindTable.cpp (original)
+++ lldb/trunk/source/Symbol/UnwindTable.cpp Tue Sep  6 15:57:50 2016
@@ -13,185 +13,168 @@
 
 #include "lldb/Core/Module.h"
 #include "lldb/Core/Section.h"
-#include "lldb/Symbol/ObjectFile.h"
-#include "lldb/Symbol/FuncUnwinders.h"
-#include "lldb/Symbol/SymbolContext.h"
-#include "lldb/Symbol/DWARFCallFrameInfo.h"
 #include "lldb/Symbol/ArmUnwindInfo.h"
 #include "lldb/Symbol/CompactUnwindInfo.h"
+#include "lldb/Symbol/DWARFCallFrameInfo.h"
+#include "lldb/Symbol/FuncUnwinders.h"
+#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Symbol/SymbolContext.h"
 
 // There is one UnwindTable object per ObjectFile.
-// It contains a list of Unwind objects -- one per function, populated lazily -- for the ObjectFile.
+// It contains a list of Unwind objects -- one per function, populated lazily --
+// for the ObjectFile.
 // Each Unwind object has multiple UnwindPlans for different scenarios.
 
 using namespace lldb;
 using namespace lldb_private;
 
 UnwindTable::UnwindTable(ObjectFile &objfile)
-    : m_object_file(objfile),
-      m_unwinds(),
-      m_initialized(false),
-      m_mutex(),
-      m_eh_frame_up(),
-      m_compact_unwind_up(),
-      m_arm_unwind_up()
-{
-}
+    : m_object_file(objfile), m_unwinds(), m_initialized(false), m_mutex(),
+      m_eh_frame_up(), m_compact_unwind_up(), m_arm_unwind_up() {}
 
-// We can't do some of this initialization when the ObjectFile is running its ctor; delay doing it
+// We can't do some of this initialization when the ObjectFile is running its
+// ctor; delay doing it
 // until needed for something.
 
-void
-UnwindTable::Initialize ()
-{
-    if (m_initialized)
-        return;
-
-    std::lock_guard<std::mutex> guard(m_mutex);
-
-    if (m_initialized) // check again once we've acquired the lock
-        return;
-
-    SectionList* sl = m_object_file.GetSectionList ();
-    if (sl)
-    {
-        SectionSP sect = sl->FindSectionByType (eSectionTypeEHFrame, true);
-        if (sect.get())
-        {
-            m_eh_frame_up.reset(new DWARFCallFrameInfo(m_object_file, sect, eRegisterKindEHFrame, true));
-        }
-        sect = sl->FindSectionByType (eSectionTypeCompactUnwind, true);
-        if (sect.get())
-        {
-            m_compact_unwind_up.reset(new CompactUnwindInfo(m_object_file, sect));
-        }
-        sect = sl->FindSectionByType (eSectionTypeARMexidx, true);
-        if (sect.get())
-        {
-            SectionSP sect_extab = sl->FindSectionByType (eSectionTypeARMextab, true);
-            if (sect_extab.get())
-            {
-                m_arm_unwind_up.reset(new ArmUnwindInfo(m_object_file, sect, sect_extab));
-            }
-        }
+void UnwindTable::Initialize() {
+  if (m_initialized)
+    return;
+
+  std::lock_guard<std::mutex> guard(m_mutex);
+
+  if (m_initialized) // check again once we've acquired the lock
+    return;
+
+  SectionList *sl = m_object_file.GetSectionList();
+  if (sl) {
+    SectionSP sect = sl->FindSectionByType(eSectionTypeEHFrame, true);
+    if (sect.get()) {
+      m_eh_frame_up.reset(new DWARFCallFrameInfo(m_object_file, sect,
+                                                 eRegisterKindEHFrame, true));
     }
-    
-    m_initialized = true;
-}
+    sect = sl->FindSectionByType(eSectionTypeCompactUnwind, true);
+    if (sect.get()) {
+      m_compact_unwind_up.reset(new CompactUnwindInfo(m_object_file, sect));
+    }
+    sect = sl->FindSectionByType(eSectionTypeARMexidx, true);
+    if (sect.get()) {
+      SectionSP sect_extab = sl->FindSectionByType(eSectionTypeARMextab, true);
+      if (sect_extab.get()) {
+        m_arm_unwind_up.reset(
+            new ArmUnwindInfo(m_object_file, sect, sect_extab));
+      }
+    }
+  }
 
-UnwindTable::~UnwindTable ()
-{
+  m_initialized = true;
 }
 
-FuncUnwindersSP
-UnwindTable::GetFuncUnwindersContainingAddress (const Address& addr, SymbolContext &sc)
-{
-    FuncUnwindersSP no_unwind_found;
-
-    Initialize();
-
-    std::lock_guard<std::mutex> guard(m_mutex);
-
-    // There is an UnwindTable per object file, so we can safely use file handles
-    addr_t file_addr = addr.GetFileAddress();
-    iterator end = m_unwinds.end ();
-    iterator insert_pos = end;
-    if (!m_unwinds.empty())
-    {
-        insert_pos = m_unwinds.lower_bound (file_addr);
-        iterator pos = insert_pos;
-        if ((pos == m_unwinds.end ()) || (pos != m_unwinds.begin() && pos->second->GetFunctionStartAddress() != addr))
-            --pos;
+UnwindTable::~UnwindTable() {}
 
-        if (pos->second->ContainsAddress (addr))
-            return pos->second;
-    }
-
-    AddressRange range;
-    if (!sc.GetAddressRange(eSymbolContextFunction | eSymbolContextSymbol, 0, false, range) || !range.GetBaseAddress().IsValid())
-    {
-        // Does the eh_frame unwind info has a function bounds for this addr?
-        if (m_eh_frame_up == nullptr || !m_eh_frame_up->GetAddressRange (addr, range))
-        {
-            return no_unwind_found;
-        }
+FuncUnwindersSP
+UnwindTable::GetFuncUnwindersContainingAddress(const Address &addr,
+                                               SymbolContext &sc) {
+  FuncUnwindersSP no_unwind_found;
+
+  Initialize();
+
+  std::lock_guard<std::mutex> guard(m_mutex);
+
+  // There is an UnwindTable per object file, so we can safely use file handles
+  addr_t file_addr = addr.GetFileAddress();
+  iterator end = m_unwinds.end();
+  iterator insert_pos = end;
+  if (!m_unwinds.empty()) {
+    insert_pos = m_unwinds.lower_bound(file_addr);
+    iterator pos = insert_pos;
+    if ((pos == m_unwinds.end()) ||
+        (pos != m_unwinds.begin() &&
+         pos->second->GetFunctionStartAddress() != addr))
+      --pos;
+
+    if (pos->second->ContainsAddress(addr))
+      return pos->second;
+  }
+
+  AddressRange range;
+  if (!sc.GetAddressRange(eSymbolContextFunction | eSymbolContextSymbol, 0,
+                          false, range) ||
+      !range.GetBaseAddress().IsValid()) {
+    // Does the eh_frame unwind info has a function bounds for this addr?
+    if (m_eh_frame_up == nullptr ||
+        !m_eh_frame_up->GetAddressRange(addr, range)) {
+      return no_unwind_found;
     }
+  }
 
-    FuncUnwindersSP func_unwinder_sp(new FuncUnwinders(*this, range));
-    m_unwinds.insert (insert_pos, std::make_pair(range.GetBaseAddress().GetFileAddress(), func_unwinder_sp));
-//    StreamFile s(stdout, false);
-//    Dump (s);
-    return func_unwinder_sp;
+  FuncUnwindersSP func_unwinder_sp(new FuncUnwinders(*this, range));
+  m_unwinds.insert(insert_pos,
+                   std::make_pair(range.GetBaseAddress().GetFileAddress(),
+                                  func_unwinder_sp));
+  //    StreamFile s(stdout, false);
+  //    Dump (s);
+  return func_unwinder_sp;
 }
 
-// Ignore any existing FuncUnwinders for this function, create a new one and don't add it to the
-// UnwindTable.  This is intended for use by target modules show-unwind where we want to create 
+// Ignore any existing FuncUnwinders for this function, create a new one and
+// don't add it to the
+// UnwindTable.  This is intended for use by target modules show-unwind where we
+// want to create
 // new UnwindPlans, not re-use existing ones.
 
 FuncUnwindersSP
-UnwindTable::GetUncachedFuncUnwindersContainingAddress (const Address& addr, SymbolContext &sc)
-{
-    FuncUnwindersSP no_unwind_found;
-    Initialize();
-
-    AddressRange range;
-    if (!sc.GetAddressRange(eSymbolContextFunction | eSymbolContextSymbol, 0, false, range) || !range.GetBaseAddress().IsValid())
-    {
-        // Does the eh_frame unwind info has a function bounds for this addr?
-        if (m_eh_frame_up == nullptr || !m_eh_frame_up->GetAddressRange (addr, range))
-        {
-            return no_unwind_found;
-        }
+UnwindTable::GetUncachedFuncUnwindersContainingAddress(const Address &addr,
+                                                       SymbolContext &sc) {
+  FuncUnwindersSP no_unwind_found;
+  Initialize();
+
+  AddressRange range;
+  if (!sc.GetAddressRange(eSymbolContextFunction | eSymbolContextSymbol, 0,
+                          false, range) ||
+      !range.GetBaseAddress().IsValid()) {
+    // Does the eh_frame unwind info has a function bounds for this addr?
+    if (m_eh_frame_up == nullptr ||
+        !m_eh_frame_up->GetAddressRange(addr, range)) {
+      return no_unwind_found;
     }
+  }
 
-    FuncUnwindersSP func_unwinder_sp(new FuncUnwinders(*this, range));
-    return func_unwinder_sp;
+  FuncUnwindersSP func_unwinder_sp(new FuncUnwinders(*this, range));
+  return func_unwinder_sp;
 }
 
-
-void
-UnwindTable::Dump (Stream &s)
-{
-    std::lock_guard<std::mutex> guard(m_mutex);
-    s.Printf("UnwindTable for '%s':\n", m_object_file.GetFileSpec().GetPath().c_str());
-    const_iterator begin = m_unwinds.begin();
-    const_iterator end = m_unwinds.end();
-    for (const_iterator pos = begin; pos != end; ++pos)
-    {
-        s.Printf ("[%u] 0x%16.16" PRIx64 "\n", (unsigned)std::distance (begin, pos), pos->first);
-    }
-    s.EOL();
+void UnwindTable::Dump(Stream &s) {
+  std::lock_guard<std::mutex> guard(m_mutex);
+  s.Printf("UnwindTable for '%s':\n",
+           m_object_file.GetFileSpec().GetPath().c_str());
+  const_iterator begin = m_unwinds.begin();
+  const_iterator end = m_unwinds.end();
+  for (const_iterator pos = begin; pos != end; ++pos) {
+    s.Printf("[%u] 0x%16.16" PRIx64 "\n", (unsigned)std::distance(begin, pos),
+             pos->first);
+  }
+  s.EOL();
 }
 
-DWARFCallFrameInfo *
-UnwindTable::GetEHFrameInfo ()
-{
-    Initialize();
-    return m_eh_frame_up.get();
+DWARFCallFrameInfo *UnwindTable::GetEHFrameInfo() {
+  Initialize();
+  return m_eh_frame_up.get();
 }
 
-CompactUnwindInfo *
-UnwindTable::GetCompactUnwindInfo ()
-{
-    Initialize();
-    return m_compact_unwind_up.get();
+CompactUnwindInfo *UnwindTable::GetCompactUnwindInfo() {
+  Initialize();
+  return m_compact_unwind_up.get();
 }
 
-ArmUnwindInfo *
-UnwindTable::GetArmUnwindInfo ()
-{
-    Initialize();
-    return m_arm_unwind_up.get();
+ArmUnwindInfo *UnwindTable::GetArmUnwindInfo() {
+  Initialize();
+  return m_arm_unwind_up.get();
 }
 
-bool
-UnwindTable::GetArchitecture (lldb_private::ArchSpec &arch)
-{
-    return m_object_file.GetArchitecture (arch);
+bool UnwindTable::GetArchitecture(lldb_private::ArchSpec &arch) {
+  return m_object_file.GetArchitecture(arch);
 }
 
-bool
-UnwindTable::GetAllowAssemblyEmulationUnwindPlans ()
-{
-    return m_object_file.AllowAssemblyEmulationUnwindPlans ();
+bool UnwindTable::GetAllowAssemblyEmulationUnwindPlans() {
+  return m_object_file.AllowAssemblyEmulationUnwindPlans();
 }

Modified: lldb/trunk/source/Symbol/Variable.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Variable.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Variable.cpp (original)
+++ lldb/trunk/source/Symbol/Variable.cpp Tue Sep  6 15:57:50 2016
@@ -10,14 +10,14 @@
 #include "lldb/Symbol/Variable.h"
 
 #include "lldb/Core/Module.h"
-#include "lldb/Core/Stream.h"
 #include "lldb/Core/RegularExpression.h"
+#include "lldb/Core/Stream.h"
 #include "lldb/Core/ValueObject.h"
 #include "lldb/Core/ValueObjectVariable.h"
 #include "lldb/Symbol/Block.h"
+#include "lldb/Symbol/CompileUnit.h"
 #include "lldb/Symbol/CompilerDecl.h"
 #include "lldb/Symbol/CompilerDeclContext.h"
-#include "lldb/Symbol/CompileUnit.h"
 #include "lldb/Symbol/Function.h"
 #include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Symbol/SymbolFile.h"
@@ -28,8 +28,8 @@
 #include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/StackFrame.h"
-#include "lldb/Target/Thread.h"
 #include "lldb/Target/Target.h"
+#include "lldb/Target/Thread.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -37,948 +37,732 @@ using namespace lldb_private;
 //----------------------------------------------------------------------
 // Variable constructor
 //----------------------------------------------------------------------
-Variable::Variable (lldb::user_id_t uid,
-                    const char *name,
-                    const char *mangled,  // The mangled or fully qualified name of the variable.
-                    const lldb::SymbolFileTypeSP &symfile_type_sp,
-                    ValueType scope,
-                    SymbolContextScope *context,
-                    const RangeList& scope_range,
-                    Declaration* decl_ptr,
-                    const DWARFExpression& location,
-                    bool external,
-                    bool artificial,
-                    bool static_member) :
-    UserID(uid),
-    m_name(name),
-    m_mangled (ConstString(mangled)),
-    m_symfile_type_sp(symfile_type_sp),
-    m_scope(scope),
-    m_owner_scope(context),
-    m_scope_range(scope_range),
-    m_declaration(decl_ptr),
-    m_location(location),
-    m_external(external),
-    m_artificial(artificial),
-    m_static_member(static_member)
-{
-}
+Variable::Variable(
+    lldb::user_id_t uid, const char *name,
+    const char *mangled, // The mangled or fully qualified name of the variable.
+    const lldb::SymbolFileTypeSP &symfile_type_sp, ValueType scope,
+    SymbolContextScope *context, const RangeList &scope_range,
+    Declaration *decl_ptr, const DWARFExpression &location, bool external,
+    bool artificial, bool static_member)
+    : UserID(uid), m_name(name), m_mangled(ConstString(mangled)),
+      m_symfile_type_sp(symfile_type_sp), m_scope(scope),
+      m_owner_scope(context), m_scope_range(scope_range),
+      m_declaration(decl_ptr), m_location(location), m_external(external),
+      m_artificial(artificial), m_static_member(static_member) {}
 
 //----------------------------------------------------------------------
 // Destructor
 //----------------------------------------------------------------------
-Variable::~Variable()
-{
-}
+Variable::~Variable() {}
 
-lldb::LanguageType
-Variable::GetLanguage () const
-{
-    SymbolContext variable_sc;
-    m_owner_scope->CalculateSymbolContext(&variable_sc);
-    if (variable_sc.comp_unit)
-        return variable_sc.comp_unit->GetLanguage();
-    return lldb::eLanguageTypeUnknown;
-}
-
-
-
-ConstString
-Variable::GetName() const
-{
-    ConstString name = m_mangled.GetName(GetLanguage());
-    if (name)
-        return name;
-    return m_name;
-}
-
-ConstString
-Variable::GetUnqualifiedName() const
-{
-    return m_name;
-}
-
-
-bool
-Variable::NameMatches (const ConstString &name) const
-{
-    if (m_name == name)
-        return true;
-    SymbolContext variable_sc;
-    m_owner_scope->CalculateSymbolContext(&variable_sc);
-
-    LanguageType language = eLanguageTypeUnknown;
-    if (variable_sc.comp_unit)
-        language = variable_sc.comp_unit->GetLanguage();
-    return m_mangled.NameMatches (name, language);
-}
-bool
-Variable::NameMatches (const RegularExpression& regex) const
-{
-    if (regex.Execute (m_name.AsCString()))
-        return true;
-    if (m_mangled)
-        return m_mangled.NameMatches (regex, GetLanguage());
-    return false;
-}
-
-Type *
-Variable::GetType()
-{
-    if (m_symfile_type_sp)
-        return m_symfile_type_sp->GetType();
-    return nullptr;
-}
-
-void
-Variable::Dump(Stream *s, bool show_context) const
-{
-    s->Printf("%p: ", static_cast<const void*>(this));
-    s->Indent();
-    *s << "Variable" << (const UserID&)*this;
-
-    if (m_name)
-        *s << ", name = \"" << m_name << "\"";
-
-    if (m_symfile_type_sp)
-    {
-        Type *type = m_symfile_type_sp->GetType();
-        if (type)
-        {
-            *s << ", type = {" << type->GetID() << "} " << (void*)type << " (";
-            type->DumpTypeName(s);
-            s->PutChar(')');
-        }
-    }
-
-    if (m_scope != eValueTypeInvalid)
-    {
-        s->PutCString(", scope = ");
-        switch (m_scope)
-        {
-        case eValueTypeVariableGlobal:       s->PutCString(m_external ? "global" : "static"); break;
-        case eValueTypeVariableArgument:
-            s->PutCString("parameter");
-            break;
-        case eValueTypeVariableLocal:        s->PutCString("local"); break;
-        case eValueTypeVariableThreadLocal:
-            s->PutCString("thread local");
-            break;
-        default:            *s << "??? (" << m_scope << ')';
-        }
-    }
-
-    if (show_context && m_owner_scope != nullptr)
-    {
-        s->PutCString(", context = ( ");
-        m_owner_scope->DumpSymbolContext(s);
-        s->PutCString(" )");
-    }
-
-    bool show_fullpaths = false;
-    m_declaration.Dump(s, show_fullpaths);
-
-    if (m_location.IsValid())
-    {
-        s->PutCString(", location = ");
-        lldb::addr_t loclist_base_addr = LLDB_INVALID_ADDRESS;
-        if (m_location.IsLocationList())
-        {
-            SymbolContext variable_sc;
-            m_owner_scope->CalculateSymbolContext(&variable_sc);
-            if (variable_sc.function)
-                loclist_base_addr = variable_sc.function->GetAddressRange().GetBaseAddress().GetFileAddress();
-        }
-        ABI *abi = nullptr;
-        if (m_owner_scope)
-        {
-            ModuleSP module_sp (m_owner_scope->CalculateSymbolContextModule());
-            if (module_sp)
-                abi = ABI::FindPlugin (module_sp->GetArchitecture()).get();
-        }
-        m_location.GetDescription(s, lldb::eDescriptionLevelBrief, loclist_base_addr, abi);
-    }
-
-    if (m_external)
-        s->PutCString(", external");
-
-    if (m_artificial)
-        s->PutCString(", artificial");
-
-    s->EOL();
-}
-
-bool
-Variable::DumpDeclaration (Stream *s, bool show_fullpaths, bool show_module)
-{
-    bool dumped_declaration_info = false;
-    if (m_owner_scope)
-    {
-        SymbolContext sc;
-        m_owner_scope->CalculateSymbolContext(&sc);
-        sc.block = nullptr;
-        sc.line_entry.Clear();
-        bool show_inlined_frames = false;
-        const bool show_function_arguments = true;
-        const bool show_function_name = true;
-    
-        dumped_declaration_info = sc.DumpStopContext (s, 
-                                                      nullptr,
-                                                      Address(), 
-                                                      show_fullpaths, 
-                                                      show_module, 
-                                                      show_inlined_frames,
-                                                      show_function_arguments,
-                                                      show_function_name);
-        
-        if (sc.function)
-            s->PutChar(':');
-    }
-    if (m_declaration.DumpStopContext (s, false))
-        dumped_declaration_info = true;
-    return dumped_declaration_info;
-}
-
-size_t
-Variable::MemorySize() const
-{
-    return sizeof(Variable);
-}
-
-CompilerDeclContext
-Variable::GetDeclContext ()
-{
-    Type *type = GetType();
-    if (type)
-        return type->GetSymbolFile()->GetDeclContextContainingUID(GetID());
-    return CompilerDeclContext();
-}
-
-CompilerDecl
-Variable::GetDecl ()
-{
-    Type *type = GetType();
-    return type ? type->GetSymbolFile()->GetDeclForUID(GetID()) : CompilerDecl();
-}
-
-void
-Variable::CalculateSymbolContext (SymbolContext *sc)
-{
-    if (m_owner_scope)
-    {
-        m_owner_scope->CalculateSymbolContext(sc);
-        sc->variable = this;
-    }
-    else
-        sc->Clear(false);
-}
-
-bool
-Variable::LocationIsValidForFrame (StackFrame *frame)
-{
-    // Is the variable is described by a single location?
-    if (!m_location.IsLocationList())
-    {
-        // Yes it is, the location is valid. 
-        return true;
-    }
-
-    if (frame)
-    {
-        Function *function = frame->GetSymbolContext(eSymbolContextFunction).function;
-        if (function)
-        {
-            TargetSP target_sp (frame->CalculateTarget());
-            
-            addr_t loclist_base_load_addr = function->GetAddressRange().GetBaseAddress().GetLoadAddress (target_sp.get());
-            if (loclist_base_load_addr == LLDB_INVALID_ADDRESS)
-                return false;
-            // It is a location list. We just need to tell if the location
-            // list contains the current address when converted to a load
-            // address
-            return m_location.LocationListContainsAddress (loclist_base_load_addr, 
-                                                           frame->GetFrameCodeAddress().GetLoadAddress (target_sp.get()));
-        }
-    }
-    return false;
-}
-
-bool
-Variable::LocationIsValidForAddress (const Address &address)
-{
-    // Be sure to resolve the address to section offset prior to 
-    // calling this function.
-    if (address.IsSectionOffset())
-    {
-        SymbolContext sc;
-        CalculateSymbolContext(&sc);
-        if (sc.module_sp == address.GetModule())
-        {
-            // Is the variable is described by a single location?
-            if (!m_location.IsLocationList())
-            {
-                // Yes it is, the location is valid. 
-                return true;
-            }
-            
-            if (sc.function)
-            {
-                addr_t loclist_base_file_addr = sc.function->GetAddressRange().GetBaseAddress().GetFileAddress();
-                if (loclist_base_file_addr == LLDB_INVALID_ADDRESS)
-                    return false;
-                // It is a location list. We just need to tell if the location
-                // list contains the current address when converted to a load
-                // address
-                return m_location.LocationListContainsAddress (loclist_base_file_addr, 
-                                                               address.GetFileAddress());
-            }
-        }
-    }
-    return false;
-}
-
-bool
-Variable::IsInScope (StackFrame *frame)
-{
-    switch (m_scope)
-    {
-    case eValueTypeRegister:
-    case eValueTypeRegisterSet:
-        return frame != nullptr;
-
-    case eValueTypeConstResult:
+lldb::LanguageType Variable::GetLanguage() const {
+  SymbolContext variable_sc;
+  m_owner_scope->CalculateSymbolContext(&variable_sc);
+  if (variable_sc.comp_unit)
+    return variable_sc.comp_unit->GetLanguage();
+  return lldb::eLanguageTypeUnknown;
+}
+
+ConstString Variable::GetName() const {
+  ConstString name = m_mangled.GetName(GetLanguage());
+  if (name)
+    return name;
+  return m_name;
+}
+
+ConstString Variable::GetUnqualifiedName() const { return m_name; }
+
+bool Variable::NameMatches(const ConstString &name) const {
+  if (m_name == name)
+    return true;
+  SymbolContext variable_sc;
+  m_owner_scope->CalculateSymbolContext(&variable_sc);
+
+  LanguageType language = eLanguageTypeUnknown;
+  if (variable_sc.comp_unit)
+    language = variable_sc.comp_unit->GetLanguage();
+  return m_mangled.NameMatches(name, language);
+}
+bool Variable::NameMatches(const RegularExpression &regex) const {
+  if (regex.Execute(m_name.AsCString()))
+    return true;
+  if (m_mangled)
+    return m_mangled.NameMatches(regex, GetLanguage());
+  return false;
+}
+
+Type *Variable::GetType() {
+  if (m_symfile_type_sp)
+    return m_symfile_type_sp->GetType();
+  return nullptr;
+}
+
+void Variable::Dump(Stream *s, bool show_context) const {
+  s->Printf("%p: ", static_cast<const void *>(this));
+  s->Indent();
+  *s << "Variable" << (const UserID &)*this;
+
+  if (m_name)
+    *s << ", name = \"" << m_name << "\"";
+
+  if (m_symfile_type_sp) {
+    Type *type = m_symfile_type_sp->GetType();
+    if (type) {
+      *s << ", type = {" << type->GetID() << "} " << (void *)type << " (";
+      type->DumpTypeName(s);
+      s->PutChar(')');
+    }
+  }
+
+  if (m_scope != eValueTypeInvalid) {
+    s->PutCString(", scope = ");
+    switch (m_scope) {
     case eValueTypeVariableGlobal:
-    case eValueTypeVariableStatic:
-    case eValueTypeVariableThreadLocal:
-        return true;
-
+      s->PutCString(m_external ? "global" : "static");
+      break;
     case eValueTypeVariableArgument:
+      s->PutCString("parameter");
+      break;
     case eValueTypeVariableLocal:
-        if (frame)
-        {
-            // We don't have a location list, we just need to see if the block
-            // that this variable was defined in is currently
-            Block *deepest_frame_block = frame->GetSymbolContext(eSymbolContextBlock).block;
-            if (deepest_frame_block)
-            {
-                SymbolContext variable_sc;
-                CalculateSymbolContext (&variable_sc);
-
-                // Check for static or global variable defined at the compile unit 
-                // level that wasn't defined in a block
-                if (variable_sc.block == nullptr)
-                    return true;
-
-                // Check if the variable is valid in the current block
-                if (variable_sc.block != deepest_frame_block &&
-                    !variable_sc.block->Contains(deepest_frame_block))
-                    return false;
-
-                // If no scope range is specified then it means that the scope is the same as the
-                // scope of the enclosing lexical block.
-                if (m_scope_range.IsEmpty())
-                    return true;
-
-                addr_t file_address = frame->GetFrameCodeAddress().GetFileAddress();
-                return m_scope_range.FindEntryThatContains(file_address) != nullptr;
-            }
-        }
-        break;
-
+      s->PutCString("local");
+      break;
+    case eValueTypeVariableThreadLocal:
+      s->PutCString("thread local");
+      break;
     default:
-        break;
+      *s << "??? (" << m_scope << ')';
     }
-    return false;
-}
+  }
 
-Error
-Variable::GetValuesForVariableExpressionPath (const char *variable_expr_path,
-                                              ExecutionContextScope *scope,
-                                              GetVariableCallback callback,
-                                              void *baton,
-                                              VariableList &variable_list,
-                                              ValueObjectList &valobj_list)
-{
-    Error error;
-    if (variable_expr_path && callback)
-    {
-        switch (variable_expr_path[0])
-        {
-        case '*':
-            {
-                error = Variable::GetValuesForVariableExpressionPath (variable_expr_path + 1,
-                                                                      scope,
-                                                                      callback,
-                                                                      baton,
-                                                                      variable_list,
-                                                                      valobj_list);
-                if (error.Success())
-                {
-                    for (uint32_t i=0; i<valobj_list.GetSize(); )
-                    {
-                        Error tmp_error;
-                        ValueObjectSP valobj_sp (valobj_list.GetValueObjectAtIndex(i)->Dereference(tmp_error));
-                        if (tmp_error.Fail())
-                        {
-                            variable_list.RemoveVariableAtIndex (i);
-                            valobj_list.RemoveValueObjectAtIndex (i);
-                        }
-                        else
-                        {
-                            valobj_list.SetValueObjectAtIndex (i, valobj_sp);
-                            ++i;
-                        }
-                    }
-                }
-                else
-                {
-                    error.SetErrorString ("unknown error");
-                }
-                return error;
-            }
-            break;
-        
-        case '&':
-            {
-                error = Variable::GetValuesForVariableExpressionPath (variable_expr_path + 1,
-                                                                      scope,
-                                                                      callback,
-                                                                      baton,
-                                                                      variable_list,
-                                                                      valobj_list);
-                if (error.Success())
-                {
-                    for (uint32_t i=0; i<valobj_list.GetSize(); )
-                    {
-                        Error tmp_error;
-                        ValueObjectSP valobj_sp (valobj_list.GetValueObjectAtIndex(i)->AddressOf(tmp_error));
-                        if (tmp_error.Fail())
-                        {
-                            variable_list.RemoveVariableAtIndex (i);
-                            valobj_list.RemoveValueObjectAtIndex (i);
-                        }
-                        else
-                        {
-                            valobj_list.SetValueObjectAtIndex (i, valobj_sp);
-                            ++i;
-                        }
-                    }
-                }
-                else
-                {
-                    error.SetErrorString ("unknown error");
-                }
-                return error;
-            }
-            break;
-            
-        default:
-            {
-                static RegularExpression g_regex ("^([A-Za-z_:][A-Za-z_0-9:]*)(.*)");
-                RegularExpression::Match regex_match(1);
-                if (g_regex.Execute(variable_expr_path, &regex_match))
-                {
-                    std::string variable_name;
-                    if (regex_match.GetMatchAtIndex(variable_expr_path, 1, variable_name))
-                    {
-                        variable_list.Clear();
-                        if (callback (baton, variable_name.c_str(), variable_list))
-                        {
-                            uint32_t i=0;
-                            while (i < variable_list.GetSize())
-                            {
-                                VariableSP var_sp (variable_list.GetVariableAtIndex (i));
-                                ValueObjectSP valobj_sp;
-                                if (var_sp)
-                                {
-                                    ValueObjectSP variable_valobj_sp(ValueObjectVariable::Create (scope, var_sp));
-                                    if (variable_valobj_sp)
-                                    {
-                                        const char *variable_sub_expr_path = variable_expr_path + variable_name.size();
-                                        if (*variable_sub_expr_path)
-                                        {
-                                            const char* first_unparsed = nullptr;
-                                            ValueObject::ExpressionPathScanEndReason reason_to_stop;
-                                            ValueObject::ExpressionPathEndResultType final_value_type;
-                                            ValueObject::GetValueForExpressionPathOptions options;
-                                            ValueObject::ExpressionPathAftermath final_task_on_target;
-
-                                            valobj_sp = variable_valobj_sp->GetValueForExpressionPath (variable_sub_expr_path,
-                                                                                                       &first_unparsed,
-                                                                                                       &reason_to_stop,
-                                                                                                       &final_value_type,
-                                                                                                       options,
-                                                                                                       &final_task_on_target);
-                                            if (!valobj_sp)
-                                            {
-                                                error.SetErrorStringWithFormat ("invalid expression path '%s' for variable '%s'",
-                                                                                variable_sub_expr_path,
-                                                                                var_sp->GetName().GetCString());
-                                            }
-                                        }
-                                        else
-                                        {
-                                            // Just the name of a variable with no extras
-                                            valobj_sp = variable_valobj_sp;
-                                        }
-                                    }
-                                }
-
-                                if (!var_sp || !valobj_sp)
-                                {
-                                    variable_list.RemoveVariableAtIndex (i);
-                                }
-                                else
-                                {
-                                    valobj_list.Append(valobj_sp);
-                                    ++i;
-                                }
-                            }
-                            
-                            if (variable_list.GetSize() > 0)
-                            {
-                                error.Clear();
-                                return error;
-                            }
-                        }
-                    }
-                }
-                error.SetErrorStringWithFormat ("unable to extract a variable name from '%s'", variable_expr_path);
-            }
-            break;
-        }
-    }
-    error.SetErrorString ("unknown error");
-    return error;
-}
+  if (show_context && m_owner_scope != nullptr) {
+    s->PutCString(", context = ( ");
+    m_owner_scope->DumpSymbolContext(s);
+    s->PutCString(" )");
+  }
+
+  bool show_fullpaths = false;
+  m_declaration.Dump(s, show_fullpaths);
+
+  if (m_location.IsValid()) {
+    s->PutCString(", location = ");
+    lldb::addr_t loclist_base_addr = LLDB_INVALID_ADDRESS;
+    if (m_location.IsLocationList()) {
+      SymbolContext variable_sc;
+      m_owner_scope->CalculateSymbolContext(&variable_sc);
+      if (variable_sc.function)
+        loclist_base_addr = variable_sc.function->GetAddressRange()
+                                .GetBaseAddress()
+                                .GetFileAddress();
+    }
+    ABI *abi = nullptr;
+    if (m_owner_scope) {
+      ModuleSP module_sp(m_owner_scope->CalculateSymbolContextModule());
+      if (module_sp)
+        abi = ABI::FindPlugin(module_sp->GetArchitecture()).get();
+    }
+    m_location.GetDescription(s, lldb::eDescriptionLevelBrief,
+                              loclist_base_addr, abi);
+  }
+
+  if (m_external)
+    s->PutCString(", external");
+
+  if (m_artificial)
+    s->PutCString(", artificial");
+
+  s->EOL();
+}
+
+bool Variable::DumpDeclaration(Stream *s, bool show_fullpaths,
+                               bool show_module) {
+  bool dumped_declaration_info = false;
+  if (m_owner_scope) {
+    SymbolContext sc;
+    m_owner_scope->CalculateSymbolContext(&sc);
+    sc.block = nullptr;
+    sc.line_entry.Clear();
+    bool show_inlined_frames = false;
+    const bool show_function_arguments = true;
+    const bool show_function_name = true;
+
+    dumped_declaration_info = sc.DumpStopContext(
+        s, nullptr, Address(), show_fullpaths, show_module, show_inlined_frames,
+        show_function_arguments, show_function_name);
+
+    if (sc.function)
+      s->PutChar(':');
+  }
+  if (m_declaration.DumpStopContext(s, false))
+    dumped_declaration_info = true;
+  return dumped_declaration_info;
+}
+
+size_t Variable::MemorySize() const { return sizeof(Variable); }
+
+CompilerDeclContext Variable::GetDeclContext() {
+  Type *type = GetType();
+  if (type)
+    return type->GetSymbolFile()->GetDeclContextContainingUID(GetID());
+  return CompilerDeclContext();
+}
+
+CompilerDecl Variable::GetDecl() {
+  Type *type = GetType();
+  return type ? type->GetSymbolFile()->GetDeclForUID(GetID()) : CompilerDecl();
+}
+
+void Variable::CalculateSymbolContext(SymbolContext *sc) {
+  if (m_owner_scope) {
+    m_owner_scope->CalculateSymbolContext(sc);
+    sc->variable = this;
+  } else
+    sc->Clear(false);
+}
+
+bool Variable::LocationIsValidForFrame(StackFrame *frame) {
+  // Is the variable is described by a single location?
+  if (!m_location.IsLocationList()) {
+    // Yes it is, the location is valid.
+    return true;
+  }
+
+  if (frame) {
+    Function *function =
+        frame->GetSymbolContext(eSymbolContextFunction).function;
+    if (function) {
+      TargetSP target_sp(frame->CalculateTarget());
+
+      addr_t loclist_base_load_addr =
+          function->GetAddressRange().GetBaseAddress().GetLoadAddress(
+              target_sp.get());
+      if (loclist_base_load_addr == LLDB_INVALID_ADDRESS)
+        return false;
+      // It is a location list. We just need to tell if the location
+      // list contains the current address when converted to a load
+      // address
+      return m_location.LocationListContainsAddress(
+          loclist_base_load_addr,
+          frame->GetFrameCodeAddress().GetLoadAddress(target_sp.get()));
+    }
+  }
+  return false;
+}
+
+bool Variable::LocationIsValidForAddress(const Address &address) {
+  // Be sure to resolve the address to section offset prior to
+  // calling this function.
+  if (address.IsSectionOffset()) {
+    SymbolContext sc;
+    CalculateSymbolContext(&sc);
+    if (sc.module_sp == address.GetModule()) {
+      // Is the variable is described by a single location?
+      if (!m_location.IsLocationList()) {
+        // Yes it is, the location is valid.
+        return true;
+      }
 
-bool
-Variable::DumpLocationForAddress (Stream *s, const Address &address)
-{
-    // Be sure to resolve the address to section offset prior to 
-    // calling this function.
-    if (address.IsSectionOffset())
-    {
-        SymbolContext sc;
-        CalculateSymbolContext(&sc);
-        if (sc.module_sp == address.GetModule())
-        {
-            ABI *abi = nullptr;
-            if (m_owner_scope)
-            {
-                ModuleSP module_sp (m_owner_scope->CalculateSymbolContextModule());
-                if (module_sp)
-                    abi = ABI::FindPlugin (module_sp->GetArchitecture()).get();
-            }
+      if (sc.function) {
+        addr_t loclist_base_file_addr =
+            sc.function->GetAddressRange().GetBaseAddress().GetFileAddress();
+        if (loclist_base_file_addr == LLDB_INVALID_ADDRESS)
+          return false;
+        // It is a location list. We just need to tell if the location
+        // list contains the current address when converted to a load
+        // address
+        return m_location.LocationListContainsAddress(loclist_base_file_addr,
+                                                      address.GetFileAddress());
+      }
+    }
+  }
+  return false;
+}
+
+bool Variable::IsInScope(StackFrame *frame) {
+  switch (m_scope) {
+  case eValueTypeRegister:
+  case eValueTypeRegisterSet:
+    return frame != nullptr;
+
+  case eValueTypeConstResult:
+  case eValueTypeVariableGlobal:
+  case eValueTypeVariableStatic:
+  case eValueTypeVariableThreadLocal:
+    return true;
+
+  case eValueTypeVariableArgument:
+  case eValueTypeVariableLocal:
+    if (frame) {
+      // We don't have a location list, we just need to see if the block
+      // that this variable was defined in is currently
+      Block *deepest_frame_block =
+          frame->GetSymbolContext(eSymbolContextBlock).block;
+      if (deepest_frame_block) {
+        SymbolContext variable_sc;
+        CalculateSymbolContext(&variable_sc);
+
+        // Check for static or global variable defined at the compile unit
+        // level that wasn't defined in a block
+        if (variable_sc.block == nullptr)
+          return true;
+
+        // Check if the variable is valid in the current block
+        if (variable_sc.block != deepest_frame_block &&
+            !variable_sc.block->Contains(deepest_frame_block))
+          return false;
+
+        // If no scope range is specified then it means that the scope is the
+        // same as the
+        // scope of the enclosing lexical block.
+        if (m_scope_range.IsEmpty())
+          return true;
+
+        addr_t file_address = frame->GetFrameCodeAddress().GetFileAddress();
+        return m_scope_range.FindEntryThatContains(file_address) != nullptr;
+      }
+    }
+    break;
+
+  default:
+    break;
+  }
+  return false;
+}
+
+Error Variable::GetValuesForVariableExpressionPath(
+    const char *variable_expr_path, ExecutionContextScope *scope,
+    GetVariableCallback callback, void *baton, VariableList &variable_list,
+    ValueObjectList &valobj_list) {
+  Error error;
+  if (variable_expr_path && callback) {
+    switch (variable_expr_path[0]) {
+    case '*': {
+      error = Variable::GetValuesForVariableExpressionPath(
+          variable_expr_path + 1, scope, callback, baton, variable_list,
+          valobj_list);
+      if (error.Success()) {
+        for (uint32_t i = 0; i < valobj_list.GetSize();) {
+          Error tmp_error;
+          ValueObjectSP valobj_sp(
+              valobj_list.GetValueObjectAtIndex(i)->Dereference(tmp_error));
+          if (tmp_error.Fail()) {
+            variable_list.RemoveVariableAtIndex(i);
+            valobj_list.RemoveValueObjectAtIndex(i);
+          } else {
+            valobj_list.SetValueObjectAtIndex(i, valobj_sp);
+            ++i;
+          }
+        }
+      } else {
+        error.SetErrorString("unknown error");
+      }
+      return error;
+    } break;
+
+    case '&': {
+      error = Variable::GetValuesForVariableExpressionPath(
+          variable_expr_path + 1, scope, callback, baton, variable_list,
+          valobj_list);
+      if (error.Success()) {
+        for (uint32_t i = 0; i < valobj_list.GetSize();) {
+          Error tmp_error;
+          ValueObjectSP valobj_sp(
+              valobj_list.GetValueObjectAtIndex(i)->AddressOf(tmp_error));
+          if (tmp_error.Fail()) {
+            variable_list.RemoveVariableAtIndex(i);
+            valobj_list.RemoveValueObjectAtIndex(i);
+          } else {
+            valobj_list.SetValueObjectAtIndex(i, valobj_sp);
+            ++i;
+          }
+        }
+      } else {
+        error.SetErrorString("unknown error");
+      }
+      return error;
+    } break;
+
+    default: {
+      static RegularExpression g_regex("^([A-Za-z_:][A-Za-z_0-9:]*)(.*)");
+      RegularExpression::Match regex_match(1);
+      if (g_regex.Execute(variable_expr_path, &regex_match)) {
+        std::string variable_name;
+        if (regex_match.GetMatchAtIndex(variable_expr_path, 1, variable_name)) {
+          variable_list.Clear();
+          if (callback(baton, variable_name.c_str(), variable_list)) {
+            uint32_t i = 0;
+            while (i < variable_list.GetSize()) {
+              VariableSP var_sp(variable_list.GetVariableAtIndex(i));
+              ValueObjectSP valobj_sp;
+              if (var_sp) {
+                ValueObjectSP variable_valobj_sp(
+                    ValueObjectVariable::Create(scope, var_sp));
+                if (variable_valobj_sp) {
+                  const char *variable_sub_expr_path =
+                      variable_expr_path + variable_name.size();
+                  if (*variable_sub_expr_path) {
+                    const char *first_unparsed = nullptr;
+                    ValueObject::ExpressionPathScanEndReason reason_to_stop;
+                    ValueObject::ExpressionPathEndResultType final_value_type;
+                    ValueObject::GetValueForExpressionPathOptions options;
+                    ValueObject::ExpressionPathAftermath final_task_on_target;
+
+                    valobj_sp = variable_valobj_sp->GetValueForExpressionPath(
+                        variable_sub_expr_path, &first_unparsed,
+                        &reason_to_stop, &final_value_type, options,
+                        &final_task_on_target);
+                    if (!valobj_sp) {
+                      error.SetErrorStringWithFormat(
+                          "invalid expression path '%s' for variable '%s'",
+                          variable_sub_expr_path,
+                          var_sp->GetName().GetCString());
+                    }
+                  } else {
+                    // Just the name of a variable with no extras
+                    valobj_sp = variable_valobj_sp;
+                  }
+                }
+              }
+
+              if (!var_sp || !valobj_sp) {
+                variable_list.RemoveVariableAtIndex(i);
+              } else {
+                valobj_list.Append(valobj_sp);
+                ++i;
+              }
+            }
+
+            if (variable_list.GetSize() > 0) {
+              error.Clear();
+              return error;
+            }
+          }
+        }
+      }
+      error.SetErrorStringWithFormat(
+          "unable to extract a variable name from '%s'", variable_expr_path);
+    } break;
+    }
+  }
+  error.SetErrorString("unknown error");
+  return error;
+}
+
+bool Variable::DumpLocationForAddress(Stream *s, const Address &address) {
+  // Be sure to resolve the address to section offset prior to
+  // calling this function.
+  if (address.IsSectionOffset()) {
+    SymbolContext sc;
+    CalculateSymbolContext(&sc);
+    if (sc.module_sp == address.GetModule()) {
+      ABI *abi = nullptr;
+      if (m_owner_scope) {
+        ModuleSP module_sp(m_owner_scope->CalculateSymbolContextModule());
+        if (module_sp)
+          abi = ABI::FindPlugin(module_sp->GetArchitecture()).get();
+      }
+
+      const addr_t file_addr = address.GetFileAddress();
+      if (sc.function) {
+        if (sc.function->GetAddressRange().ContainsFileAddress(address)) {
+          addr_t loclist_base_file_addr =
+              sc.function->GetAddressRange().GetBaseAddress().GetFileAddress();
+          if (loclist_base_file_addr == LLDB_INVALID_ADDRESS)
+            return false;
+          return m_location.DumpLocationForAddress(s, eDescriptionLevelBrief,
+                                                   loclist_base_file_addr,
+                                                   file_addr, abi);
+        }
+      }
+      return m_location.DumpLocationForAddress(
+          s, eDescriptionLevelBrief, LLDB_INVALID_ADDRESS, file_addr, abi);
+    }
+  }
+  return false;
+}
+
+static void PrivateAutoComplete(
+    StackFrame *frame, const std::string &partial_path,
+    const std::string
+        &prefix_path, // Anything that has been resolved already will be in here
+    const CompilerType &compiler_type,
+    StringList &matches, bool &word_complete);
+
+static void PrivateAutoCompleteMembers(
+    StackFrame *frame, const std::string &partial_member_name,
+    const std::string &partial_path,
+    const std::string
+        &prefix_path, // Anything that has been resolved already will be in here
+    const CompilerType &compiler_type,
+    StringList &matches, bool &word_complete);
+
+static void PrivateAutoCompleteMembers(
+    StackFrame *frame, const std::string &partial_member_name,
+    const std::string &partial_path,
+    const std::string
+        &prefix_path, // Anything that has been resolved already will be in here
+    const CompilerType &compiler_type,
+    StringList &matches, bool &word_complete) {
+
+  // We are in a type parsing child members
+  const uint32_t num_bases = compiler_type.GetNumDirectBaseClasses();
+
+  if (num_bases > 0) {
+    for (uint32_t i = 0; i < num_bases; ++i) {
+      CompilerType base_class_type =
+          compiler_type.GetDirectBaseClassAtIndex(i, nullptr);
+
+      PrivateAutoCompleteMembers(
+          frame, partial_member_name, partial_path, prefix_path,
+          base_class_type.GetCanonicalType(), matches, word_complete);
+    }
+  }
+
+  const uint32_t num_vbases = compiler_type.GetNumVirtualBaseClasses();
+
+  if (num_vbases > 0) {
+    for (uint32_t i = 0; i < num_vbases; ++i) {
+      CompilerType vbase_class_type =
+          compiler_type.GetVirtualBaseClassAtIndex(i, nullptr);
+
+      PrivateAutoCompleteMembers(
+          frame, partial_member_name, partial_path, prefix_path,
+          vbase_class_type.GetCanonicalType(), matches, word_complete);
+    }
+  }
+
+  // We are in a type parsing child members
+  const uint32_t num_fields = compiler_type.GetNumFields();
+
+  if (num_fields > 0) {
+    for (uint32_t i = 0; i < num_fields; ++i) {
+      std::string member_name;
+
+      CompilerType member_compiler_type = compiler_type.GetFieldAtIndex(
+          i, member_name, nullptr, nullptr, nullptr);
+
+      if (partial_member_name.empty() ||
+          member_name.find(partial_member_name) == 0) {
+        if (member_name == partial_member_name) {
+          PrivateAutoComplete(
+              frame, partial_path,
+              prefix_path + member_name, // Anything that has been resolved
+                                         // already will be in here
+              member_compiler_type.GetCanonicalType(), matches, word_complete);
+        } else {
+          matches.AppendString(prefix_path + member_name);
+        }
+      }
+    }
+  }
+}
+
+static void PrivateAutoComplete(
+    StackFrame *frame, const std::string &partial_path,
+    const std::string
+        &prefix_path, // Anything that has been resolved already will be in here
+    const CompilerType &compiler_type,
+    StringList &matches, bool &word_complete) {
+  //    printf ("\nPrivateAutoComplete()\n\tprefix_path = '%s'\n\tpartial_path =
+  //    '%s'\n", prefix_path.c_str(), partial_path.c_str());
+  std::string remaining_partial_path;
+
+  const lldb::TypeClass type_class = compiler_type.GetTypeClass();
+  if (partial_path.empty()) {
+    if (compiler_type.IsValid()) {
+      switch (type_class) {
+      default:
+      case eTypeClassArray:
+      case eTypeClassBlockPointer:
+      case eTypeClassBuiltin:
+      case eTypeClassComplexFloat:
+      case eTypeClassComplexInteger:
+      case eTypeClassEnumeration:
+      case eTypeClassFunction:
+      case eTypeClassMemberPointer:
+      case eTypeClassReference:
+      case eTypeClassTypedef:
+      case eTypeClassVector: {
+        matches.AppendString(prefix_path);
+        word_complete = matches.GetSize() == 1;
+      } break;
+
+      case eTypeClassClass:
+      case eTypeClassStruct:
+      case eTypeClassUnion:
+        if (prefix_path.back() != '.')
+          matches.AppendString(prefix_path + '.');
+        break;
 
-            const addr_t file_addr = address.GetFileAddress();
-            if (sc.function)
-            {
-                if (sc.function->GetAddressRange().ContainsFileAddress(address))
-                {
-                    addr_t loclist_base_file_addr = sc.function->GetAddressRange().GetBaseAddress().GetFileAddress();
-                    if (loclist_base_file_addr == LLDB_INVALID_ADDRESS)
-                        return false;
-                    return m_location.DumpLocationForAddress (s, 
-                                                              eDescriptionLevelBrief, 
-                                                              loclist_base_file_addr, 
-                                                              file_addr,
-                                                              abi);
-                }
-            }
-            return m_location.DumpLocationForAddress (s, 
-                                                      eDescriptionLevelBrief, 
-                                                      LLDB_INVALID_ADDRESS, 
-                                                      file_addr,
-                                                      abi);
-        }
-    }
-    return false;
-}
-
-
-static void
-PrivateAutoComplete (StackFrame *frame,
-                     const std::string &partial_path,
-                     const std::string &prefix_path, // Anything that has been resolved already will be in here
-                     const CompilerType& compiler_type,
-                     StringList &matches,
-                     bool &word_complete);
-
-static void
-PrivateAutoCompleteMembers (StackFrame *frame,
-                            const std::string &partial_member_name,
-                            const std::string &partial_path,
-                            const std::string &prefix_path, // Anything that has been resolved already will be in here
-                            const CompilerType& compiler_type,
-                            StringList &matches,
-                            bool &word_complete);
-
-static void
-PrivateAutoCompleteMembers (StackFrame *frame,
-                            const std::string &partial_member_name,
-                            const std::string &partial_path,
-                            const std::string &prefix_path, // Anything that has been resolved already will be in here
-                            const CompilerType& compiler_type,
-                            StringList &matches,
-                            bool &word_complete)
-{
-
-    // We are in a type parsing child members
-    const uint32_t num_bases = compiler_type.GetNumDirectBaseClasses();
-    
-    if (num_bases > 0)
-    {
-        for (uint32_t i = 0; i < num_bases; ++i)
-        {
-            CompilerType base_class_type = compiler_type.GetDirectBaseClassAtIndex(i, nullptr);
-            
-            PrivateAutoCompleteMembers (frame,
-                                        partial_member_name,
-                                        partial_path,
-                                        prefix_path,
-                                        base_class_type.GetCanonicalType(),
-                                        matches,
-                                        word_complete);
-        }
-    }
-
-    const uint32_t num_vbases = compiler_type.GetNumVirtualBaseClasses();
-    
-    if (num_vbases > 0)
-    {
-        for (uint32_t i = 0; i < num_vbases; ++i)
-        {
-            CompilerType vbase_class_type = compiler_type.GetVirtualBaseClassAtIndex(i,nullptr);
-            
-            PrivateAutoCompleteMembers (frame,
-                                        partial_member_name,
-                                        partial_path,
-                                        prefix_path,
-                                        vbase_class_type.GetCanonicalType(),
-                                        matches,
-                                        word_complete);
-        }
-    }
-
-    // We are in a type parsing child members
-    const uint32_t num_fields = compiler_type.GetNumFields();
-    
-    if (num_fields > 0)
-    {
-        for (uint32_t i = 0; i < num_fields; ++i)
-        {
-            std::string member_name;
-            
-            CompilerType member_compiler_type = compiler_type.GetFieldAtIndex (i, member_name, nullptr, nullptr, nullptr);
-            
-            if (partial_member_name.empty() ||
-                member_name.find(partial_member_name) == 0)
-            {
-                if (member_name == partial_member_name)
-                {
-                    PrivateAutoComplete (frame,
-                                         partial_path,
-                                         prefix_path + member_name, // Anything that has been resolved already will be in here
-                                         member_compiler_type.GetCanonicalType(),
-                                         matches,
-                                         word_complete);
-                }
-                else
-                {
-                    matches.AppendString (prefix_path + member_name);
-                }
-            }
+      case eTypeClassObjCObject:
+      case eTypeClassObjCInterface:
+        break;
+      case eTypeClassObjCObjectPointer:
+      case eTypeClassPointer: {
+        bool omit_empty_base_classes = true;
+        if (compiler_type.GetNumChildren(omit_empty_base_classes) > 0)
+          matches.AppendString(prefix_path + "->");
+        else {
+          matches.AppendString(prefix_path);
+          word_complete = true;
+        }
+      } break;
+      }
+    } else {
+      if (frame) {
+        const bool get_file_globals = true;
+
+        VariableList *variable_list = frame->GetVariableList(get_file_globals);
+
+        if (variable_list) {
+          const size_t num_variables = variable_list->GetSize();
+          for (size_t i = 0; i < num_variables; ++i) {
+            Variable *variable = variable_list->GetVariableAtIndex(i).get();
+            matches.AppendString(variable->GetName().AsCString());
+          }
+        }
+      }
+    }
+  } else {
+    const char ch = partial_path[0];
+    switch (ch) {
+    case '*':
+      if (prefix_path.empty()) {
+        PrivateAutoComplete(frame, partial_path.substr(1), std::string("*"),
+                            compiler_type, matches, word_complete);
+      }
+      break;
+
+    case '&':
+      if (prefix_path.empty()) {
+        PrivateAutoComplete(frame, partial_path.substr(1), std::string("&"),
+                            compiler_type, matches, word_complete);
+      }
+      break;
+
+    case '-':
+      if (partial_path[1] == '>' && !prefix_path.empty()) {
+        switch (type_class) {
+        case lldb::eTypeClassPointer: {
+          CompilerType pointee_type(compiler_type.GetPointeeType());
+          if (partial_path[2]) {
+            // If there is more after the "->", then search deeper
+            PrivateAutoComplete(
+                frame, partial_path.substr(2), prefix_path + "->",
+                pointee_type.GetCanonicalType(), matches, word_complete);
+          } else {
+            // Nothing after the "->", so list all members
+            PrivateAutoCompleteMembers(
+                frame, std::string(), std::string(), prefix_path + "->",
+                pointee_type.GetCanonicalType(), matches, word_complete);
+          }
+        } break;
+        default:
+          break;
         }
-    }
-}
+      }
+      break;
 
-static void
-PrivateAutoComplete (StackFrame *frame,
-                     const std::string &partial_path,
-                     const std::string &prefix_path, // Anything that has been resolved already will be in here
-                     const CompilerType& compiler_type,
-                     StringList &matches,
-                     bool &word_complete)
-{
-//    printf ("\nPrivateAutoComplete()\n\tprefix_path = '%s'\n\tpartial_path = '%s'\n", prefix_path.c_str(), partial_path.c_str());
-    std::string remaining_partial_path;
-
-    const lldb::TypeClass type_class = compiler_type.GetTypeClass();
-    if (partial_path.empty())
-    {
-        if (compiler_type.IsValid())
-        {
-            switch (type_class)
-            {
-                default:
-                case eTypeClassArray:
-                case eTypeClassBlockPointer:
-                case eTypeClassBuiltin:
-                case eTypeClassComplexFloat:
-                case eTypeClassComplexInteger:
-                case eTypeClassEnumeration:
-                case eTypeClassFunction:
-                case eTypeClassMemberPointer:
-                case eTypeClassReference:
-                case eTypeClassTypedef:
-                case eTypeClassVector:
-                    {
-                        matches.AppendString (prefix_path);
-                        word_complete = matches.GetSize() == 1;
-                    }
-                    break;
-                    
-                case eTypeClassClass:
-                case eTypeClassStruct:
-                case eTypeClassUnion:
-                    if (prefix_path.back() != '.')
-                        matches.AppendString (prefix_path + '.');
-                    break;
-
-                case eTypeClassObjCObject:
-                case eTypeClassObjCInterface:
-                    break;
-                case eTypeClassObjCObjectPointer:
-                case eTypeClassPointer:
-                    {
-                        bool omit_empty_base_classes = true;
-                        if (compiler_type.GetNumChildren (omit_empty_base_classes) > 0)
-                            matches.AppendString (prefix_path + "->");
-                        else
-                        {
-                            matches.AppendString (prefix_path);
-                            word_complete = true;
-                        }
-                    }
-                    break;
-            }
-        }
-        else
-        {
-            if (frame)
-            {
-                const bool get_file_globals = true;
-                
-                VariableList *variable_list = frame->GetVariableList(get_file_globals);
-                
-                if (variable_list)
-                {
-                    const size_t num_variables = variable_list->GetSize();
-                    for (size_t i=0; i<num_variables; ++i)
-                    {
-                        Variable *variable = variable_list->GetVariableAtIndex(i).get();
-                        matches.AppendString (variable->GetName().AsCString());
-                    }
-                }
-            }
+    case '.':
+      if (compiler_type.IsValid()) {
+        switch (type_class) {
+        case lldb::eTypeClassUnion:
+        case lldb::eTypeClassStruct:
+        case lldb::eTypeClassClass:
+          if (partial_path[1]) {
+            // If there is more after the ".", then search deeper
+            PrivateAutoComplete(frame, partial_path.substr(1),
+                                prefix_path + ".", compiler_type, matches,
+                                word_complete);
+
+          } else {
+            // Nothing after the ".", so list all members
+            PrivateAutoCompleteMembers(frame, std::string(), partial_path,
+                                       prefix_path + ".", compiler_type,
+                                       matches, word_complete);
+          }
+          break;
+        default:
+          break;
         }
-    }
-    else
-    {
-        const char ch = partial_path[0];
-        switch (ch)
-        {
-        case '*':
-            if (prefix_path.empty())
-            {
-                PrivateAutoComplete (frame,
-                                     partial_path.substr(1),
-                                     std::string("*"),
-                                     compiler_type,
-                                     matches,
-                                     word_complete);
-            }
-            break;
-
-        case '&':
-            if (prefix_path.empty())
-            {
-                PrivateAutoComplete (frame,
-                                     partial_path.substr(1),
-                                     std::string("&"),
-                                     compiler_type,
-                                     matches,
+      }
+      break;
+    default:
+      if (isalpha(ch) || ch == '_' || ch == '$') {
+        const size_t partial_path_len = partial_path.size();
+        size_t pos = 1;
+        while (pos < partial_path_len) {
+          const char curr_ch = partial_path[pos];
+          if (isalnum(curr_ch) || curr_ch == '_' || curr_ch == '$') {
+            ++pos;
+            continue;
+          }
+          break;
+        }
+
+        std::string token(partial_path, 0, pos);
+        remaining_partial_path = partial_path.substr(pos);
+
+        if (compiler_type.IsValid()) {
+          PrivateAutoCompleteMembers(frame, token, remaining_partial_path,
+                                     prefix_path, compiler_type, matches,
                                      word_complete);
-            }
-            break;
+        } else if (frame) {
+          // We haven't found our variable yet
+          const bool get_file_globals = true;
 
-        case '-':
-            if (partial_path[1] == '>' && !prefix_path.empty())
-            {
-                switch (type_class)
-                {
-                    case lldb::eTypeClassPointer:
-                        {
-                            CompilerType pointee_type(compiler_type.GetPointeeType());
-                            if (partial_path[2])
-                            {
-                                // If there is more after the "->", then search deeper
-                                PrivateAutoComplete (frame,
-                                                     partial_path.substr(2),
-                                                     prefix_path + "->",
-                                                     pointee_type.GetCanonicalType(),
-                                                     matches,
-                                                     word_complete);
-                            }
-                            else
-                            {
-                                // Nothing after the "->", so list all members
-                                PrivateAutoCompleteMembers (frame,
-                                                            std::string(),
-                                                            std::string(),
-                                                            prefix_path + "->",
-                                                            pointee_type.GetCanonicalType(),
-                                                            matches,
-                                                            word_complete);                            
-                            }
-                        }
-                        break;
-                    default:
-                        break;
-                }
-            }
-            break;
-            
-        case '.':
-            if (compiler_type.IsValid())
-            {
-                switch (type_class)
-                {
-                    case lldb::eTypeClassUnion:
-                    case lldb::eTypeClassStruct:
-                    case lldb::eTypeClassClass:
-                        if (partial_path[1])
-                        {
-                            // If there is more after the ".", then search deeper
-                            PrivateAutoComplete (frame,
-                                                 partial_path.substr(1),
-                                                 prefix_path + ".",
-                                                 compiler_type,
-                                                 matches,
-                                                 word_complete);
-                            
-                        }
-                        else
-                        {
-                            // Nothing after the ".", so list all members
-                            PrivateAutoCompleteMembers (frame,
-                                                        std::string(),
-                                                        partial_path,
-                                                        prefix_path + ".",
-                                                        compiler_type,
-                                                        matches,
-                                                        word_complete);
-                        }
-                        break;
-                    default:
-                        break;
-                }
-            }
-            break;
-        default:
-            if (isalpha(ch) || ch == '_' || ch == '$')
-            {
-                const size_t partial_path_len = partial_path.size();
-                size_t pos = 1;
-                while (pos < partial_path_len)
-                {
-                    const char curr_ch = partial_path[pos];
-                    if (isalnum(curr_ch) || curr_ch == '_'  || curr_ch == '$')
-                    {
-                        ++pos;
-                        continue;
-                    }
-                    break;
-                }
+          VariableList *variable_list =
+              frame->GetVariableList(get_file_globals);
 
-                std::string token(partial_path, 0, pos);
-                remaining_partial_path = partial_path.substr(pos);
-                
-                if (compiler_type.IsValid())
-                {
-                    PrivateAutoCompleteMembers (frame,
-                                                token,
-                                                remaining_partial_path,
-                                                prefix_path,
-                                                compiler_type,
-                                                matches,
-                                                word_complete);
-                }
-                else if (frame)
-                {
-                    // We haven't found our variable yet
-                    const bool get_file_globals = true;
-                    
-                    VariableList *variable_list = frame->GetVariableList(get_file_globals);
-                    
-                    if (!variable_list)
-                        break;
-                    
-                    const size_t num_variables = variable_list->GetSize();
-                    for (size_t i=0; i<num_variables; ++i)
-                    {
-                        Variable *variable = variable_list->GetVariableAtIndex(i).get();
-                        
-                        if (!variable)
-                            continue;
-                        
-                        const char *variable_name = variable->GetName().AsCString();
-                        if (strstr(variable_name, token.c_str()) == variable_name)
-                        {
-                            if (strcmp (variable_name, token.c_str()) == 0)
-                            {
-                                Type *variable_type = variable->GetType();
-                                if (variable_type)
-                                {
-                                    CompilerType variable_compiler_type (variable_type->GetForwardCompilerType ());
-                                    PrivateAutoComplete (frame,
-                                                         remaining_partial_path,
-                                                         prefix_path + token, // Anything that has been resolved already will be in here
-                                                         variable_compiler_type.GetCanonicalType(),
-                                                         matches,
-                                                         word_complete);
-                                }
-                                else
-                                {
-                                    matches.AppendString (prefix_path + variable_name);
-                                }
-                            }
-                            else if (remaining_partial_path.empty())
-                            {
-                                matches.AppendString (prefix_path + variable_name);
-                            }
-                        }
-                    }
-                }
-            }
+          if (!variable_list)
             break;
-        }
-    }
-}
-
 
+          const size_t num_variables = variable_list->GetSize();
+          for (size_t i = 0; i < num_variables; ++i) {
+            Variable *variable = variable_list->GetVariableAtIndex(i).get();
+
+            if (!variable)
+              continue;
+
+            const char *variable_name = variable->GetName().AsCString();
+            if (strstr(variable_name, token.c_str()) == variable_name) {
+              if (strcmp(variable_name, token.c_str()) == 0) {
+                Type *variable_type = variable->GetType();
+                if (variable_type) {
+                  CompilerType variable_compiler_type(
+                      variable_type->GetForwardCompilerType());
+                  PrivateAutoComplete(
+                      frame, remaining_partial_path,
+                      prefix_path + token, // Anything that has been resolved
+                                           // already will be in here
+                      variable_compiler_type.GetCanonicalType(), matches,
+                      word_complete);
+                } else {
+                  matches.AppendString(prefix_path + variable_name);
+                }
+              } else if (remaining_partial_path.empty()) {
+                matches.AppendString(prefix_path + variable_name);
+              }
+            }
+          }
+        }
+      }
+      break;
+    }
+  }
+}
+
+size_t Variable::AutoComplete(const ExecutionContext &exe_ctx,
+                              const char *partial_path_cstr,
+                              StringList &matches, bool &word_complete) {
+  word_complete = false;
+  std::string partial_path;
+  std::string prefix_path;
+  CompilerType compiler_type;
+  if (partial_path_cstr && partial_path_cstr[0])
+    partial_path = partial_path_cstr;
 
-size_t
-Variable::AutoComplete (const ExecutionContext &exe_ctx,
-                        const char *partial_path_cstr,
-                        StringList &matches,
-                        bool &word_complete)
-{
-    word_complete = false;
-    std::string partial_path;
-    std::string prefix_path;
-    CompilerType compiler_type;
-    if (partial_path_cstr && partial_path_cstr[0])
-        partial_path = partial_path_cstr;
-
-    PrivateAutoComplete (exe_ctx.GetFramePtr(),
-                         partial_path,
-                         prefix_path,
-                         compiler_type,
-                         matches,
-                         word_complete);
+  PrivateAutoComplete(exe_ctx.GetFramePtr(), partial_path, prefix_path,
+                      compiler_type, matches, word_complete);
 
-    return matches.GetSize();
+  return matches.GetSize();
 }
-

Modified: lldb/trunk/source/Symbol/VariableList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/VariableList.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/VariableList.cpp (original)
+++ lldb/trunk/source/Symbol/VariableList.cpp Tue Sep  6 15:57:50 2016
@@ -11,8 +11,8 @@
 
 #include "lldb/Core/RegularExpression.h"
 #include "lldb/Symbol/Block.h"
-#include "lldb/Symbol/Function.h"
 #include "lldb/Symbol/CompileUnit.h"
+#include "lldb/Symbol/Function.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -20,214 +20,162 @@ using namespace lldb_private;
 //----------------------------------------------------------------------
 // VariableList constructor
 //----------------------------------------------------------------------
-VariableList::VariableList() :
-    m_variables()
-{
-}
+VariableList::VariableList() : m_variables() {}
 
 //----------------------------------------------------------------------
 // Destructor
 //----------------------------------------------------------------------
-VariableList::~VariableList()
-{
-}
-
-void
-VariableList::AddVariable(const VariableSP &var_sp)
-{
-    m_variables.push_back(var_sp);
-}
-
-bool
-VariableList::AddVariableIfUnique (const lldb::VariableSP &var_sp)
-{
-    if (FindVariableIndex (var_sp) == UINT32_MAX)
-    {
-        m_variables.push_back(var_sp);
-        return true;
-    }
-    return false;
-}
+VariableList::~VariableList() {}
 
-void
-VariableList::AddVariables(VariableList *variable_list)
-{
-    if (variable_list)
-    {
-        std::copy(variable_list->m_variables.begin(), // source begin
-                  variable_list->m_variables.end(),   // source end
-                  back_inserter(m_variables));        // destination
-    }
-}
-
-void
-VariableList::Clear()
-{
-    m_variables.clear();
-}
-
-VariableSP
-VariableList::GetVariableAtIndex(size_t idx) const
-{
-    VariableSP var_sp;
-    if (idx < m_variables.size())
-        var_sp = m_variables[idx];
-    return var_sp;
-}
-
-VariableSP
-VariableList::RemoveVariableAtIndex(size_t idx)
-{
-    VariableSP var_sp;
-    if (idx < m_variables.size())
-    {
-        var_sp = m_variables[idx];
-        m_variables.erase (m_variables.begin() + idx);
-    }
-    return var_sp;
+void VariableList::AddVariable(const VariableSP &var_sp) {
+  m_variables.push_back(var_sp);
 }
 
-uint32_t
-VariableList::FindVariableIndex (const VariableSP &var_sp)
-{
-    iterator pos, end = m_variables.end();
-    for (pos = m_variables.begin(); pos != end; ++pos)
-    {
-        if (pos->get() == var_sp.get())
-            return std::distance (m_variables.begin(), pos);
-    }
-    return UINT32_MAX;
-}
-
-VariableSP
-VariableList::FindVariable(const ConstString& name, bool include_static_members)
-{
-    VariableSP var_sp;
-    iterator pos, end = m_variables.end();
-    for (pos = m_variables.begin(); pos != end; ++pos)
-    {
-        if ((*pos)->NameMatches(name))
-        {
-            if (include_static_members || !(*pos)->IsStaticMember())
-            {
-                var_sp = (*pos);
-                break;
-            }
-        }
-    }
-    return var_sp;
-}
-
-VariableSP
-VariableList::FindVariable (const ConstString& name, lldb::ValueType value_type, bool include_static_members)
-{
-    VariableSP var_sp;
-    iterator pos, end = m_variables.end();
-    for (pos = m_variables.begin(); pos != end; ++pos)
-    {
-        if ((*pos)->NameMatches(name) && (*pos)->GetScope() == value_type)
-        {
-            if (include_static_members || !(*pos)->IsStaticMember())
-            {
-                var_sp = (*pos);
-                break;
-            }
-        }
-    }
-    return var_sp;
-}
-
-size_t
-VariableList::AppendVariablesIfUnique(VariableList &var_list)
-{
-    const size_t initial_size = var_list.GetSize();
-    iterator pos, end = m_variables.end();
-    for (pos = m_variables.begin(); pos != end; ++pos)
+bool VariableList::AddVariableIfUnique(const lldb::VariableSP &var_sp) {
+  if (FindVariableIndex(var_sp) == UINT32_MAX) {
+    m_variables.push_back(var_sp);
+    return true;
+  }
+  return false;
+}
+
+void VariableList::AddVariables(VariableList *variable_list) {
+  if (variable_list) {
+    std::copy(variable_list->m_variables.begin(), // source begin
+              variable_list->m_variables.end(),   // source end
+              back_inserter(m_variables));        // destination
+  }
+}
+
+void VariableList::Clear() { m_variables.clear(); }
+
+VariableSP VariableList::GetVariableAtIndex(size_t idx) const {
+  VariableSP var_sp;
+  if (idx < m_variables.size())
+    var_sp = m_variables[idx];
+  return var_sp;
+}
+
+VariableSP VariableList::RemoveVariableAtIndex(size_t idx) {
+  VariableSP var_sp;
+  if (idx < m_variables.size()) {
+    var_sp = m_variables[idx];
+    m_variables.erase(m_variables.begin() + idx);
+  }
+  return var_sp;
+}
+
+uint32_t VariableList::FindVariableIndex(const VariableSP &var_sp) {
+  iterator pos, end = m_variables.end();
+  for (pos = m_variables.begin(); pos != end; ++pos) {
+    if (pos->get() == var_sp.get())
+      return std::distance(m_variables.begin(), pos);
+  }
+  return UINT32_MAX;
+}
+
+VariableSP VariableList::FindVariable(const ConstString &name,
+                                      bool include_static_members) {
+  VariableSP var_sp;
+  iterator pos, end = m_variables.end();
+  for (pos = m_variables.begin(); pos != end; ++pos) {
+    if ((*pos)->NameMatches(name)) {
+      if (include_static_members || !(*pos)->IsStaticMember()) {
+        var_sp = (*pos);
+        break;
+      }
+    }
+  }
+  return var_sp;
+}
+
+VariableSP VariableList::FindVariable(const ConstString &name,
+                                      lldb::ValueType value_type,
+                                      bool include_static_members) {
+  VariableSP var_sp;
+  iterator pos, end = m_variables.end();
+  for (pos = m_variables.begin(); pos != end; ++pos) {
+    if ((*pos)->NameMatches(name) && (*pos)->GetScope() == value_type) {
+      if (include_static_members || !(*pos)->IsStaticMember()) {
+        var_sp = (*pos);
+        break;
+      }
+    }
+  }
+  return var_sp;
+}
+
+size_t VariableList::AppendVariablesIfUnique(VariableList &var_list) {
+  const size_t initial_size = var_list.GetSize();
+  iterator pos, end = m_variables.end();
+  for (pos = m_variables.begin(); pos != end; ++pos)
+    var_list.AddVariableIfUnique(*pos);
+  return var_list.GetSize() - initial_size;
+}
+
+size_t VariableList::AppendVariablesIfUnique(const RegularExpression &regex,
+                                             VariableList &var_list,
+                                             size_t &total_matches) {
+  const size_t initial_size = var_list.GetSize();
+  iterator pos, end = m_variables.end();
+  for (pos = m_variables.begin(); pos != end; ++pos) {
+    if ((*pos)->NameMatches(regex)) {
+      // Note the total matches found
+      total_matches++;
+      // Only add this variable if it isn't already in the "var_list"
+      var_list.AddVariableIfUnique(*pos);
+    }
+  }
+  // Return the number of new unique variables added to "var_list"
+  return var_list.GetSize() - initial_size;
+}
+
+size_t VariableList::AppendVariablesWithScope(lldb::ValueType type,
+                                              VariableList &var_list,
+                                              bool if_unique) {
+  const size_t initial_size = var_list.GetSize();
+  iterator pos, end = m_variables.end();
+  for (pos = m_variables.begin(); pos != end; ++pos) {
+    if ((*pos)->GetScope() == type) {
+      if (if_unique)
         var_list.AddVariableIfUnique(*pos);
-    return var_list.GetSize() - initial_size;
-}
-
-size_t
-VariableList::AppendVariablesIfUnique (const RegularExpression& regex, VariableList &var_list, size_t& total_matches)
-{
-    const size_t initial_size = var_list.GetSize();
-    iterator pos, end = m_variables.end();
-    for (pos = m_variables.begin(); pos != end; ++pos)
-    {
-        if ((*pos)->NameMatches (regex))
-        {
-            // Note the total matches found
-            total_matches++;
-            // Only add this variable if it isn't already in the "var_list"
-            var_list.AddVariableIfUnique (*pos);
-        }
-    }
-    // Return the number of new unique variables added to "var_list"
-    return var_list.GetSize() - initial_size;
-}
-
-size_t
-VariableList::AppendVariablesWithScope (lldb::ValueType type,
-                                        VariableList &var_list,
-                                        bool if_unique)
-{
-    const size_t initial_size = var_list.GetSize();
-    iterator pos, end = m_variables.end();
-    for (pos = m_variables.begin(); pos != end; ++pos)
-    {
-        if ((*pos)->GetScope() == type)
-        {
-            if (if_unique)
-                var_list.AddVariableIfUnique (*pos);
-            else
-                var_list.AddVariable(*pos);
-        }
-    }
-    // Return the number of new unique variables added to "var_list"
-    return var_list.GetSize() - initial_size;
-}
-
-uint32_t
-VariableList::FindIndexForVariable (Variable* variable)
-{
-    VariableSP var_sp;
-    iterator pos;
-    const iterator begin = m_variables.begin();
-    const iterator end = m_variables.end();
-    for (pos = m_variables.begin(); pos != end; ++pos)
-    {
-        if ((*pos).get() == variable)
-            return std::distance (begin, pos);
-    }
-    return UINT32_MAX;
-}
-
-size_t
-VariableList::MemorySize() const
-{
-    size_t mem_size = sizeof(VariableList);
-    const_iterator pos, end = m_variables.end();
-    for (pos = m_variables.begin(); pos != end; ++pos)
-        mem_size += (*pos)->MemorySize();
-    return mem_size;
-}
-
-size_t
-VariableList::GetSize() const
-{
-    return m_variables.size();
-}
-
-void
-VariableList::Dump(Stream *s, bool show_context) const
-{
-//  s.Printf("%.*p: ", (int)sizeof(void*) * 2, this);
-//  s.Indent();
-//  s << "VariableList\n";
-
-    const_iterator pos, end = m_variables.end();
-    for (pos = m_variables.begin(); pos != end; ++pos)
-    {
-        (*pos)->Dump(s, show_context);
+      else
+        var_list.AddVariable(*pos);
     }
+  }
+  // Return the number of new unique variables added to "var_list"
+  return var_list.GetSize() - initial_size;
+}
+
+uint32_t VariableList::FindIndexForVariable(Variable *variable) {
+  VariableSP var_sp;
+  iterator pos;
+  const iterator begin = m_variables.begin();
+  const iterator end = m_variables.end();
+  for (pos = m_variables.begin(); pos != end; ++pos) {
+    if ((*pos).get() == variable)
+      return std::distance(begin, pos);
+  }
+  return UINT32_MAX;
+}
+
+size_t VariableList::MemorySize() const {
+  size_t mem_size = sizeof(VariableList);
+  const_iterator pos, end = m_variables.end();
+  for (pos = m_variables.begin(); pos != end; ++pos)
+    mem_size += (*pos)->MemorySize();
+  return mem_size;
+}
+
+size_t VariableList::GetSize() const { return m_variables.size(); }
+
+void VariableList::Dump(Stream *s, bool show_context) const {
+  //  s.Printf("%.*p: ", (int)sizeof(void*) * 2, this);
+  //  s.Indent();
+  //  s << "VariableList\n";
+
+  const_iterator pos, end = m_variables.end();
+  for (pos = m_variables.begin(); pos != end; ++pos) {
+    (*pos)->Dump(s, show_context);
+  }
 }

Modified: lldb/trunk/source/Symbol/VerifyDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/VerifyDecl.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/VerifyDecl.cpp (original)
+++ lldb/trunk/source/Symbol/VerifyDecl.cpp Tue Sep  6 15:57:50 2016
@@ -10,7 +10,4 @@
 #include "lldb/Symbol/VerifyDecl.h"
 #include "clang/AST/DeclBase.h"
 
-void lldb_private::VerifyDecl (clang::Decl *decl)
-{
-    decl->getAccess();
-}
+void lldb_private::VerifyDecl(clang::Decl *decl) { decl->getAccess(); }

Modified: lldb/trunk/source/Target/ABI.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ABI.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/ABI.cpp (original)
+++ lldb/trunk/source/Target/ABI.cpp Tue Sep  6 15:57:50 2016
@@ -12,10 +12,10 @@
 // Other libraries and framework includes
 // Project includes
 #include "lldb/Target/ABI.h"
+#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/Value.h"
 #include "lldb/Core/ValueObjectConstResult.h"
-#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
 #include "lldb/Symbol/CompilerType.h"
 #include "lldb/Symbol/TypeSystem.h"
 #include "lldb/Target/Target.h"
@@ -25,207 +25,193 @@ using namespace lldb;
 using namespace lldb_private;
 
 ABISP
-ABI::FindPlugin (const ArchSpec &arch)
-{
-    ABISP abi_sp;
-    ABICreateInstance create_callback;
-
-    for (uint32_t idx = 0;
-         (create_callback = PluginManager::GetABICreateCallbackAtIndex(idx)) != nullptr;
-         ++idx)
-    {
-        abi_sp = create_callback(arch);
-
-        if (abi_sp)
-            return abi_sp;
-    }
-    abi_sp.reset();
-    return abi_sp;
+ABI::FindPlugin(const ArchSpec &arch) {
+  ABISP abi_sp;
+  ABICreateInstance create_callback;
+
+  for (uint32_t idx = 0;
+       (create_callback = PluginManager::GetABICreateCallbackAtIndex(idx)) !=
+       nullptr;
+       ++idx) {
+    abi_sp = create_callback(arch);
+
+    if (abi_sp)
+      return abi_sp;
+  }
+  abi_sp.reset();
+  return abi_sp;
 }
 
 ABI::ABI() = default;
 
 ABI::~ABI() = default;
 
-bool
-ABI::GetRegisterInfoByName (const ConstString &name, RegisterInfo &info)
-{
-    uint32_t count = 0;
-    const RegisterInfo *register_info_array = GetRegisterInfoArray (count);
-    if (register_info_array)
-    {
-        const char *unique_name_cstr = name.GetCString();
-        uint32_t i;
-        for (i = 0; i < count; ++i)
-        {
-            if (register_info_array[i].name == unique_name_cstr)
-            {
-                info = register_info_array[i];
-                return true;
-            }
-        }
-        for (i = 0; i < count; ++i)
-        {
-            if (register_info_array[i].alt_name == unique_name_cstr)
-            {
-                info = register_info_array[i];
-                return true;
-            }
-        }
+bool ABI::GetRegisterInfoByName(const ConstString &name, RegisterInfo &info) {
+  uint32_t count = 0;
+  const RegisterInfo *register_info_array = GetRegisterInfoArray(count);
+  if (register_info_array) {
+    const char *unique_name_cstr = name.GetCString();
+    uint32_t i;
+    for (i = 0; i < count; ++i) {
+      if (register_info_array[i].name == unique_name_cstr) {
+        info = register_info_array[i];
+        return true;
+      }
     }
-    return false;
+    for (i = 0; i < count; ++i) {
+      if (register_info_array[i].alt_name == unique_name_cstr) {
+        info = register_info_array[i];
+        return true;
+      }
+    }
+  }
+  return false;
 }
 
-bool
-ABI::GetRegisterInfoByKind (RegisterKind reg_kind, uint32_t reg_num, RegisterInfo &info)
-{
-    if (reg_kind < eRegisterKindEHFrame || reg_kind >= kNumRegisterKinds)
-        return false;
-        
-    uint32_t count = 0;
-    const RegisterInfo *register_info_array = GetRegisterInfoArray (count);
-    if (register_info_array)
-    {
-        for (uint32_t i = 0; i < count; ++i)
-        {
-            if (register_info_array[i].kinds[reg_kind] == reg_num)
-            {
-                info = register_info_array[i];
-                return true;
-            }
-        }
-    }
+bool ABI::GetRegisterInfoByKind(RegisterKind reg_kind, uint32_t reg_num,
+                                RegisterInfo &info) {
+  if (reg_kind < eRegisterKindEHFrame || reg_kind >= kNumRegisterKinds)
     return false;
-}
 
-ValueObjectSP
-ABI::GetReturnValueObject (Thread &thread,
-                           CompilerType &ast_type,
-                           bool persistent) const
-{
-    if (!ast_type.IsValid())
-        return ValueObjectSP();
-        
-    ValueObjectSP return_valobj_sp;
-        
-    return_valobj_sp = GetReturnValueObjectImpl(thread, ast_type);
-    if (!return_valobj_sp)
-        return return_valobj_sp;
-    
-    // Now turn this into a persistent variable.
-    // FIXME: This code is duplicated from Target::EvaluateExpression, and it is used in similar form in a couple
-    // of other places.  Figure out the correct Create function to do all this work.
-    
-    if (persistent)
-    {
-        PersistentExpressionState *persistent_expression_state = thread.CalculateTarget()->GetPersistentExpressionStateForLanguage(ast_type.GetMinimumLanguage());
-        
-        if (!persistent_expression_state)
-            return ValueObjectSP();
-        
-        ConstString persistent_variable_name (persistent_expression_state->GetNextPersistentVariableName());
-
-        lldb::ValueObjectSP const_valobj_sp;
-        
-        // Check in case our value is already a constant value
-        if (return_valobj_sp->GetIsConstant())
-        {
-            const_valobj_sp = return_valobj_sp;
-            const_valobj_sp->SetName (persistent_variable_name);
-        }
-        else
-            const_valobj_sp = return_valobj_sp->CreateConstantValue (persistent_variable_name);
-
-        lldb::ValueObjectSP live_valobj_sp = return_valobj_sp;
-        
-        return_valobj_sp = const_valobj_sp;
-
-        ExpressionVariableSP clang_expr_variable_sp(persistent_expression_state->CreatePersistentVariable(return_valobj_sp));
-               
-        assert (clang_expr_variable_sp);
-        
-        // Set flags and live data as appropriate
-
-        const Value &result_value = live_valobj_sp->GetValue();
-        
-        switch (result_value.GetValueType())
-        {
-        case Value::eValueTypeHostAddress:
-        case Value::eValueTypeFileAddress:
-            // we don't do anything with these for now
-            break;
-        case Value::eValueTypeScalar:
-        case Value::eValueTypeVector:
-            clang_expr_variable_sp->m_flags |= ClangExpressionVariable::EVIsFreezeDried;
-            clang_expr_variable_sp->m_flags |= ClangExpressionVariable::EVIsLLDBAllocated;
-            clang_expr_variable_sp->m_flags |= ClangExpressionVariable::EVNeedsAllocation;
-            break;
-        case Value::eValueTypeLoadAddress:
-            clang_expr_variable_sp->m_live_sp = live_valobj_sp;
-            clang_expr_variable_sp->m_flags |= ClangExpressionVariable::EVIsProgramReference;
-            break;
-        }
-        
-        return_valobj_sp = clang_expr_variable_sp->GetValueObject();
+  uint32_t count = 0;
+  const RegisterInfo *register_info_array = GetRegisterInfoArray(count);
+  if (register_info_array) {
+    for (uint32_t i = 0; i < count; ++i) {
+      if (register_info_array[i].kinds[reg_kind] == reg_num) {
+        info = register_info_array[i];
+        return true;
+      }
     }
-    return return_valobj_sp;
+  }
+  return false;
 }
 
-ValueObjectSP
-ABI::GetReturnValueObject(Thread &thread, llvm::Type &ast_type, bool persistent) const
-{
-    ValueObjectSP return_valobj_sp;
-    return_valobj_sp = GetReturnValueObjectImpl( thread, ast_type );
+ValueObjectSP ABI::GetReturnValueObject(Thread &thread, CompilerType &ast_type,
+                                        bool persistent) const {
+  if (!ast_type.IsValid())
+    return ValueObjectSP();
+
+  ValueObjectSP return_valobj_sp;
+
+  return_valobj_sp = GetReturnValueObjectImpl(thread, ast_type);
+  if (!return_valobj_sp)
     return return_valobj_sp;
+
+  // Now turn this into a persistent variable.
+  // FIXME: This code is duplicated from Target::EvaluateExpression, and it is
+  // used in similar form in a couple
+  // of other places.  Figure out the correct Create function to do all this
+  // work.
+
+  if (persistent) {
+    PersistentExpressionState *persistent_expression_state =
+        thread.CalculateTarget()->GetPersistentExpressionStateForLanguage(
+            ast_type.GetMinimumLanguage());
+
+    if (!persistent_expression_state)
+      return ValueObjectSP();
+
+    ConstString persistent_variable_name(
+        persistent_expression_state->GetNextPersistentVariableName());
+
+    lldb::ValueObjectSP const_valobj_sp;
+
+    // Check in case our value is already a constant value
+    if (return_valobj_sp->GetIsConstant()) {
+      const_valobj_sp = return_valobj_sp;
+      const_valobj_sp->SetName(persistent_variable_name);
+    } else
+      const_valobj_sp =
+          return_valobj_sp->CreateConstantValue(persistent_variable_name);
+
+    lldb::ValueObjectSP live_valobj_sp = return_valobj_sp;
+
+    return_valobj_sp = const_valobj_sp;
+
+    ExpressionVariableSP clang_expr_variable_sp(
+        persistent_expression_state->CreatePersistentVariable(
+            return_valobj_sp));
+
+    assert(clang_expr_variable_sp);
+
+    // Set flags and live data as appropriate
+
+    const Value &result_value = live_valobj_sp->GetValue();
+
+    switch (result_value.GetValueType()) {
+    case Value::eValueTypeHostAddress:
+    case Value::eValueTypeFileAddress:
+      // we don't do anything with these for now
+      break;
+    case Value::eValueTypeScalar:
+    case Value::eValueTypeVector:
+      clang_expr_variable_sp->m_flags |=
+          ClangExpressionVariable::EVIsFreezeDried;
+      clang_expr_variable_sp->m_flags |=
+          ClangExpressionVariable::EVIsLLDBAllocated;
+      clang_expr_variable_sp->m_flags |=
+          ClangExpressionVariable::EVNeedsAllocation;
+      break;
+    case Value::eValueTypeLoadAddress:
+      clang_expr_variable_sp->m_live_sp = live_valobj_sp;
+      clang_expr_variable_sp->m_flags |=
+          ClangExpressionVariable::EVIsProgramReference;
+      break;
+    }
+
+    return_valobj_sp = clang_expr_variable_sp->GetValueObject();
+  }
+  return return_valobj_sp;
+}
+
+ValueObjectSP ABI::GetReturnValueObject(Thread &thread, llvm::Type &ast_type,
+                                        bool persistent) const {
+  ValueObjectSP return_valobj_sp;
+  return_valobj_sp = GetReturnValueObjectImpl(thread, ast_type);
+  return return_valobj_sp;
 }
 
 // specialized to work with llvm IR types
 //
 // for now we will specify a default implementation so that we don't need to
 // modify other ABIs
-lldb::ValueObjectSP
-ABI::GetReturnValueObjectImpl( Thread &thread, llvm::Type &ir_type ) const
-{
-    ValueObjectSP return_valobj_sp;
+lldb::ValueObjectSP ABI::GetReturnValueObjectImpl(Thread &thread,
+                                                  llvm::Type &ir_type) const {
+  ValueObjectSP return_valobj_sp;
+
+  /* this is a dummy and will only be called if an ABI does not override this */
+
+  return return_valobj_sp;
+}
+
+bool ABI::PrepareTrivialCall(Thread &thread, lldb::addr_t sp,
+                             lldb::addr_t functionAddress,
+                             lldb::addr_t returnAddress, llvm::Type &returntype,
+                             llvm::ArrayRef<ABI::CallArgument> args) const {
+  // dummy prepare trivial call
+  assert(!"Should never get here!");
+  return false;
+}
+
+bool ABI::GetFallbackRegisterLocation(
+    const RegisterInfo *reg_info,
+    UnwindPlan::Row::RegisterLocation &unwind_regloc) {
+  // Did the UnwindPlan fail to give us the caller's stack pointer?
+  // The stack pointer is defined to be the same as THIS frame's CFA, so return
+  // the CFA value as
+  // the caller's stack pointer.  This is true on x86-32/x86-64 at least.
+  if (reg_info->kinds[eRegisterKindGeneric] == LLDB_REGNUM_GENERIC_SP) {
+    unwind_regloc.SetIsCFAPlusOffset(0);
+    return true;
+  }
+
+  // If a volatile register is being requested, we don't want to forward the
+  // next frame's register contents
+  // up the stack -- the register is not retrievable at this frame.
+  if (RegisterIsVolatile(reg_info)) {
+    unwind_regloc.SetUndefined();
+    return true;
+  }
 
-    /* this is a dummy and will only be called if an ABI does not override this */
-
-    return return_valobj_sp;
-}
-
-bool
-ABI::PrepareTrivialCall (Thread &thread, 
-                    lldb::addr_t sp,
-                    lldb::addr_t functionAddress,
-                    lldb::addr_t returnAddress,
-                    llvm::Type  &returntype,
-                    llvm::ArrayRef<ABI::CallArgument> args) const
-{
-    // dummy prepare trivial call
-    assert( !"Should never get here!" );
-    return false;
-}
-
-bool
-ABI::GetFallbackRegisterLocation (const RegisterInfo *reg_info,
-                                  UnwindPlan::Row::RegisterLocation &unwind_regloc)
-{
-    // Did the UnwindPlan fail to give us the caller's stack pointer?
-    // The stack pointer is defined to be the same as THIS frame's CFA, so return the CFA value as
-    // the caller's stack pointer.  This is true on x86-32/x86-64 at least.
-    if (reg_info->kinds[eRegisterKindGeneric] == LLDB_REGNUM_GENERIC_SP)
-    {
-        unwind_regloc.SetIsCFAPlusOffset(0);
-        return true;
-    }
-
-    // If a volatile register is being requested, we don't want to forward the next frame's register contents
-    // up the stack -- the register is not retrievable at this frame.
-    if (RegisterIsVolatile(reg_info))
-    {
-        unwind_regloc.SetUndefined();
-        return true;
-    }
-
-    return false;
+  return false;
 }

Modified: lldb/trunk/source/Target/CPPLanguageRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/CPPLanguageRuntime.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/CPPLanguageRuntime.cpp (original)
+++ lldb/trunk/source/Target/CPPLanguageRuntime.cpp Tue Sep  6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- CPPLanguageRuntime.cpp -------------------------------------------------*- C++ -*-===//
+//===-- CPPLanguageRuntime.cpp
+//-------------------------------------------------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -23,26 +24,19 @@ using namespace lldb_private;
 //----------------------------------------------------------------------
 // Destructor
 //----------------------------------------------------------------------
-CPPLanguageRuntime::~CPPLanguageRuntime()
-{
-}
-
-CPPLanguageRuntime::CPPLanguageRuntime (Process *process) :
-    LanguageRuntime (process)
-{
+CPPLanguageRuntime::~CPPLanguageRuntime() {}
 
-}
+CPPLanguageRuntime::CPPLanguageRuntime(Process *process)
+    : LanguageRuntime(process) {}
 
-bool
-CPPLanguageRuntime::GetObjectDescription (Stream &str, ValueObject &object)
-{
-    // C++ has no generic way to do this.
-    return false;
+bool CPPLanguageRuntime::GetObjectDescription(Stream &str,
+                                              ValueObject &object) {
+  // C++ has no generic way to do this.
+  return false;
 }
 
-bool
-CPPLanguageRuntime::GetObjectDescription (Stream &str, Value &value, ExecutionContextScope *exe_scope)
-{
-    // C++ has no generic way to do this.
-    return false;
+bool CPPLanguageRuntime::GetObjectDescription(
+    Stream &str, Value &value, ExecutionContextScope *exe_scope) {
+  // C++ has no generic way to do this.
+  return false;
 }

Modified: lldb/trunk/source/Target/ExecutionContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ExecutionContext.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/ExecutionContext.cpp (original)
+++ lldb/trunk/source/Target/ExecutionContext.cpp Tue Sep  6 15:57:50 2016
@@ -14,826 +14,620 @@
 #include "lldb/Target/ExecutionContext.h"
 #include "lldb/Core/State.h"
 #include "lldb/Target/ExecutionContextScope.h"
-#include "lldb/Target/StackFrame.h"
 #include "lldb/Target/Process.h"
+#include "lldb/Target/StackFrame.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Target/Thread.h"
 
 using namespace lldb_private;
 
-ExecutionContext::ExecutionContext() :
-    m_target_sp (),
-    m_process_sp (),
-    m_thread_sp (),
-    m_frame_sp ()
-{
-}
-
-ExecutionContext::ExecutionContext (const ExecutionContext &rhs) :
-    m_target_sp(rhs.m_target_sp),
-    m_process_sp(rhs.m_process_sp),
-    m_thread_sp(rhs.m_thread_sp),
-    m_frame_sp(rhs.m_frame_sp)
-{
-}
-
-ExecutionContext::ExecutionContext (const lldb::TargetSP &target_sp, bool get_process) :
-    m_target_sp (),
-    m_process_sp (),
-    m_thread_sp (),
-    m_frame_sp ()
-{
-    if (target_sp)
-        SetContext (target_sp, get_process);
-}
-
-ExecutionContext::ExecutionContext (const lldb::ProcessSP &process_sp) :
-    m_target_sp (),
-    m_process_sp (),
-    m_thread_sp (),
-    m_frame_sp ()
-{
-    if (process_sp)
-        SetContext (process_sp);
-}
-
-ExecutionContext::ExecutionContext (const lldb::ThreadSP &thread_sp) :
-    m_target_sp (),
-    m_process_sp (),
-    m_thread_sp (),
-    m_frame_sp ()
-{
-    if (thread_sp)
-        SetContext (thread_sp);
+ExecutionContext::ExecutionContext()
+    : m_target_sp(), m_process_sp(), m_thread_sp(), m_frame_sp() {}
+
+ExecutionContext::ExecutionContext(const ExecutionContext &rhs)
+    : m_target_sp(rhs.m_target_sp), m_process_sp(rhs.m_process_sp),
+      m_thread_sp(rhs.m_thread_sp), m_frame_sp(rhs.m_frame_sp) {}
+
+ExecutionContext::ExecutionContext(const lldb::TargetSP &target_sp,
+                                   bool get_process)
+    : m_target_sp(), m_process_sp(), m_thread_sp(), m_frame_sp() {
+  if (target_sp)
+    SetContext(target_sp, get_process);
 }
 
-ExecutionContext::ExecutionContext (const lldb::StackFrameSP &frame_sp) :
-    m_target_sp (),
-    m_process_sp (),
-    m_thread_sp (),
-    m_frame_sp ()
-{
-    if (frame_sp)
-        SetContext (frame_sp);
-}
-
-ExecutionContext::ExecutionContext (const lldb::TargetWP &target_wp, bool get_process) :
-    m_target_sp (),
-    m_process_sp (),
-    m_thread_sp (),
-    m_frame_sp ()
-{
-    lldb::TargetSP target_sp(target_wp.lock());
-    if (target_sp)
-        SetContext (target_sp, get_process);
-}
-
-ExecutionContext::ExecutionContext (const lldb::ProcessWP &process_wp) :
-    m_target_sp (),
-    m_process_sp (),
-    m_thread_sp (),
-    m_frame_sp ()
-{
-    lldb::ProcessSP process_sp(process_wp.lock());
-    if (process_sp)
-        SetContext (process_sp);
-}
-
-ExecutionContext::ExecutionContext (const lldb::ThreadWP &thread_wp) :
-    m_target_sp (),
-    m_process_sp (),
-    m_thread_sp (),
-    m_frame_sp ()
-{
-    lldb::ThreadSP thread_sp(thread_wp.lock());
-    if (thread_sp)
-        SetContext (thread_sp);
+ExecutionContext::ExecutionContext(const lldb::ProcessSP &process_sp)
+    : m_target_sp(), m_process_sp(), m_thread_sp(), m_frame_sp() {
+  if (process_sp)
+    SetContext(process_sp);
 }
 
-ExecutionContext::ExecutionContext (const lldb::StackFrameWP &frame_wp) :
-    m_target_sp (),
-    m_process_sp (),
-    m_thread_sp (),
-    m_frame_sp ()
-{
-    lldb::StackFrameSP frame_sp(frame_wp.lock());
-    if (frame_sp)
-        SetContext (frame_sp);
-}
-
-ExecutionContext::ExecutionContext (Target* t, bool fill_current_process_thread_frame) :
-    m_target_sp (),
-    m_process_sp (),
-    m_thread_sp (),
-    m_frame_sp ()
-{
-    if (t)
-    {
-        m_target_sp = t->shared_from_this();
-        if (fill_current_process_thread_frame)
-        {
-            m_process_sp = t->GetProcessSP();
-            if (m_process_sp)
-            {
-                m_thread_sp = m_process_sp->GetThreadList().GetSelectedThread();
-                if (m_thread_sp)
-                    m_frame_sp = m_thread_sp->GetSelectedFrame();
-            }
-        }
-    }
+ExecutionContext::ExecutionContext(const lldb::ThreadSP &thread_sp)
+    : m_target_sp(), m_process_sp(), m_thread_sp(), m_frame_sp() {
+  if (thread_sp)
+    SetContext(thread_sp);
 }
 
-ExecutionContext::ExecutionContext(Process* process, Thread *thread, StackFrame *frame) :
-    m_target_sp (),
-    m_process_sp (),
-    m_thread_sp (),
-    m_frame_sp ()
-{
-    if (process)
-    {
-        m_process_sp = process->shared_from_this();
-        m_target_sp = process->GetTarget().shared_from_this();
-    }
-    if (thread)
-        m_thread_sp = thread->shared_from_this();
-    if (frame)
-        m_frame_sp = frame->shared_from_this();
-}
-
-ExecutionContext::ExecutionContext (const ExecutionContextRef &exe_ctx_ref) :
-    m_target_sp (exe_ctx_ref.GetTargetSP()),
-    m_process_sp (exe_ctx_ref.GetProcessSP()),
-    m_thread_sp (exe_ctx_ref.GetThreadSP()),
-    m_frame_sp (exe_ctx_ref.GetFrameSP())
-{
-}
-
-ExecutionContext::ExecutionContext (const ExecutionContextRef *exe_ctx_ref_ptr, bool thread_and_frame_only_if_stopped) :
-    m_target_sp (),
-    m_process_sp (),
-    m_thread_sp (),
-    m_frame_sp ()
-{
-    if (exe_ctx_ref_ptr)
-    {
-        m_target_sp  = exe_ctx_ref_ptr->GetTargetSP();
-        m_process_sp = exe_ctx_ref_ptr->GetProcessSP();
-        if (!thread_and_frame_only_if_stopped || (m_process_sp && StateIsStoppedState(m_process_sp->GetState(), true)))
-        {
-            m_thread_sp = exe_ctx_ref_ptr->GetThreadSP();
-            m_frame_sp = exe_ctx_ref_ptr->GetFrameSP();
-        }
-    }
+ExecutionContext::ExecutionContext(const lldb::StackFrameSP &frame_sp)
+    : m_target_sp(), m_process_sp(), m_thread_sp(), m_frame_sp() {
+  if (frame_sp)
+    SetContext(frame_sp);
 }
 
-ExecutionContext::ExecutionContext(const ExecutionContextRef *exe_ctx_ref_ptr,
-                                   std::unique_lock<std::recursive_mutex> &lock)
-    : m_target_sp(), m_process_sp(), m_thread_sp(), m_frame_sp()
-{
-    if (exe_ctx_ref_ptr)
-    {
-        m_target_sp = exe_ctx_ref_ptr->GetTargetSP();
-        if (m_target_sp)
-        {
-            lock = std::unique_lock<std::recursive_mutex>(m_target_sp->GetAPIMutex());
-
-            m_process_sp = exe_ctx_ref_ptr->GetProcessSP();
-            m_thread_sp = exe_ctx_ref_ptr->GetThreadSP();
-            m_frame_sp = exe_ctx_ref_ptr->GetFrameSP();
-        }
+ExecutionContext::ExecutionContext(const lldb::TargetWP &target_wp,
+                                   bool get_process)
+    : m_target_sp(), m_process_sp(), m_thread_sp(), m_frame_sp() {
+  lldb::TargetSP target_sp(target_wp.lock());
+  if (target_sp)
+    SetContext(target_sp, get_process);
+}
+
+ExecutionContext::ExecutionContext(const lldb::ProcessWP &process_wp)
+    : m_target_sp(), m_process_sp(), m_thread_sp(), m_frame_sp() {
+  lldb::ProcessSP process_sp(process_wp.lock());
+  if (process_sp)
+    SetContext(process_sp);
+}
+
+ExecutionContext::ExecutionContext(const lldb::ThreadWP &thread_wp)
+    : m_target_sp(), m_process_sp(), m_thread_sp(), m_frame_sp() {
+  lldb::ThreadSP thread_sp(thread_wp.lock());
+  if (thread_sp)
+    SetContext(thread_sp);
+}
+
+ExecutionContext::ExecutionContext(const lldb::StackFrameWP &frame_wp)
+    : m_target_sp(), m_process_sp(), m_thread_sp(), m_frame_sp() {
+  lldb::StackFrameSP frame_sp(frame_wp.lock());
+  if (frame_sp)
+    SetContext(frame_sp);
+}
+
+ExecutionContext::ExecutionContext(Target *t,
+                                   bool fill_current_process_thread_frame)
+    : m_target_sp(), m_process_sp(), m_thread_sp(), m_frame_sp() {
+  if (t) {
+    m_target_sp = t->shared_from_this();
+    if (fill_current_process_thread_frame) {
+      m_process_sp = t->GetProcessSP();
+      if (m_process_sp) {
+        m_thread_sp = m_process_sp->GetThreadList().GetSelectedThread();
+        if (m_thread_sp)
+          m_frame_sp = m_thread_sp->GetSelectedFrame();
+      }
     }
+  }
 }
 
-ExecutionContext::ExecutionContext(const ExecutionContextRef &exe_ctx_ref, std::unique_lock<std::recursive_mutex> &lock)
-    : m_target_sp(exe_ctx_ref.GetTargetSP()), m_process_sp(), m_thread_sp(), m_frame_sp()
-{
-    if (m_target_sp)
-    {
-        lock = std::unique_lock<std::recursive_mutex>(m_target_sp->GetAPIMutex());
-
-        m_process_sp = exe_ctx_ref.GetProcessSP();
-        m_thread_sp = exe_ctx_ref.GetThreadSP();
-        m_frame_sp = exe_ctx_ref.GetFrameSP();
+ExecutionContext::ExecutionContext(Process *process, Thread *thread,
+                                   StackFrame *frame)
+    : m_target_sp(), m_process_sp(), m_thread_sp(), m_frame_sp() {
+  if (process) {
+    m_process_sp = process->shared_from_this();
+    m_target_sp = process->GetTarget().shared_from_this();
+  }
+  if (thread)
+    m_thread_sp = thread->shared_from_this();
+  if (frame)
+    m_frame_sp = frame->shared_from_this();
+}
+
+ExecutionContext::ExecutionContext(const ExecutionContextRef &exe_ctx_ref)
+    : m_target_sp(exe_ctx_ref.GetTargetSP()),
+      m_process_sp(exe_ctx_ref.GetProcessSP()),
+      m_thread_sp(exe_ctx_ref.GetThreadSP()),
+      m_frame_sp(exe_ctx_ref.GetFrameSP()) {}
+
+ExecutionContext::ExecutionContext(const ExecutionContextRef *exe_ctx_ref_ptr,
+                                   bool thread_and_frame_only_if_stopped)
+    : m_target_sp(), m_process_sp(), m_thread_sp(), m_frame_sp() {
+  if (exe_ctx_ref_ptr) {
+    m_target_sp = exe_ctx_ref_ptr->GetTargetSP();
+    m_process_sp = exe_ctx_ref_ptr->GetProcessSP();
+    if (!thread_and_frame_only_if_stopped ||
+        (m_process_sp && StateIsStoppedState(m_process_sp->GetState(), true))) {
+      m_thread_sp = exe_ctx_ref_ptr->GetThreadSP();
+      m_frame_sp = exe_ctx_ref_ptr->GetFrameSP();
     }
+  }
 }
 
-ExecutionContext::ExecutionContext (ExecutionContextScope *exe_scope_ptr) :
-    m_target_sp (),
-    m_process_sp (),
-    m_thread_sp (),
-    m_frame_sp ()
-{
-    if (exe_scope_ptr)
-        exe_scope_ptr->CalculateExecutionContext (*this);
-}
-
-ExecutionContext::ExecutionContext (ExecutionContextScope &exe_scope_ref)
-{
-    exe_scope_ref.CalculateExecutionContext (*this);
-}
-
-void
-ExecutionContext::Clear()
-{
-    m_target_sp.reset();
-    m_process_sp.reset();
-    m_thread_sp.reset();
-    m_frame_sp.reset();
+ExecutionContext::ExecutionContext(const ExecutionContextRef *exe_ctx_ref_ptr,
+                                   std::unique_lock<std::recursive_mutex> &lock)
+    : m_target_sp(), m_process_sp(), m_thread_sp(), m_frame_sp() {
+  if (exe_ctx_ref_ptr) {
+    m_target_sp = exe_ctx_ref_ptr->GetTargetSP();
+    if (m_target_sp) {
+      lock = std::unique_lock<std::recursive_mutex>(m_target_sp->GetAPIMutex());
+
+      m_process_sp = exe_ctx_ref_ptr->GetProcessSP();
+      m_thread_sp = exe_ctx_ref_ptr->GetThreadSP();
+      m_frame_sp = exe_ctx_ref_ptr->GetFrameSP();
+    }
+  }
 }
 
-ExecutionContext::~ExecutionContext() = default;
+ExecutionContext::ExecutionContext(const ExecutionContextRef &exe_ctx_ref,
+                                   std::unique_lock<std::recursive_mutex> &lock)
+    : m_target_sp(exe_ctx_ref.GetTargetSP()), m_process_sp(), m_thread_sp(),
+      m_frame_sp() {
+  if (m_target_sp) {
+    lock = std::unique_lock<std::recursive_mutex>(m_target_sp->GetAPIMutex());
 
-uint32_t
-ExecutionContext::GetAddressByteSize() const
-{
-    if (m_target_sp && m_target_sp->GetArchitecture().IsValid())
-        return m_target_sp->GetArchitecture().GetAddressByteSize();
-    if (m_process_sp)
-        return m_process_sp->GetAddressByteSize();
-    return sizeof(void *);
+    m_process_sp = exe_ctx_ref.GetProcessSP();
+    m_thread_sp = exe_ctx_ref.GetThreadSP();
+    m_frame_sp = exe_ctx_ref.GetFrameSP();
+  }
 }
 
-lldb::ByteOrder
-ExecutionContext::GetByteOrder() const
-{
-    if (m_target_sp && m_target_sp->GetArchitecture().IsValid())
-        m_target_sp->GetArchitecture().GetByteOrder();
-    if (m_process_sp)
-        m_process_sp->GetByteOrder();
-    return endian::InlHostByteOrder();
+ExecutionContext::ExecutionContext(ExecutionContextScope *exe_scope_ptr)
+    : m_target_sp(), m_process_sp(), m_thread_sp(), m_frame_sp() {
+  if (exe_scope_ptr)
+    exe_scope_ptr->CalculateExecutionContext(*this);
 }
 
-RegisterContext *
-ExecutionContext::GetRegisterContext () const
-{
-    if (m_frame_sp)
-        return m_frame_sp->GetRegisterContext().get();
-    else if (m_thread_sp)
-        return m_thread_sp->GetRegisterContext().get();
-    return nullptr;
-}
-
-Target *
-ExecutionContext::GetTargetPtr () const
-{
-    if (m_target_sp)
-        return m_target_sp.get();
-    if (m_process_sp)
-        return &m_process_sp->GetTarget();
-    return nullptr;
+ExecutionContext::ExecutionContext(ExecutionContextScope &exe_scope_ref) {
+  exe_scope_ref.CalculateExecutionContext(*this);
 }
 
-Process *
-ExecutionContext::GetProcessPtr () const
-{
-    if (m_process_sp)
-        return m_process_sp.get();
-    if (m_target_sp)
-        return m_target_sp->GetProcessSP().get();
-    return nullptr;
+void ExecutionContext::Clear() {
+  m_target_sp.reset();
+  m_process_sp.reset();
+  m_thread_sp.reset();
+  m_frame_sp.reset();
 }
 
-ExecutionContextScope *
-ExecutionContext::GetBestExecutionContextScope () const
-{
-    if (m_frame_sp)
-        return m_frame_sp.get();
-    if (m_thread_sp)
-        return m_thread_sp.get();
-    if (m_process_sp)
-        return m_process_sp.get();
-    return m_target_sp.get();
+ExecutionContext::~ExecutionContext() = default;
+
+uint32_t ExecutionContext::GetAddressByteSize() const {
+  if (m_target_sp && m_target_sp->GetArchitecture().IsValid())
+    return m_target_sp->GetArchitecture().GetAddressByteSize();
+  if (m_process_sp)
+    return m_process_sp->GetAddressByteSize();
+  return sizeof(void *);
+}
+
+lldb::ByteOrder ExecutionContext::GetByteOrder() const {
+  if (m_target_sp && m_target_sp->GetArchitecture().IsValid())
+    m_target_sp->GetArchitecture().GetByteOrder();
+  if (m_process_sp)
+    m_process_sp->GetByteOrder();
+  return endian::InlHostByteOrder();
+}
+
+RegisterContext *ExecutionContext::GetRegisterContext() const {
+  if (m_frame_sp)
+    return m_frame_sp->GetRegisterContext().get();
+  else if (m_thread_sp)
+    return m_thread_sp->GetRegisterContext().get();
+  return nullptr;
 }
 
-Target &
-ExecutionContext::GetTargetRef () const
-{
-#if defined (LLDB_CONFIGURATION_DEBUG) || defined (LLDB_CONFIGURATION_RELEASE)
-    assert (m_target_sp);
+Target *ExecutionContext::GetTargetPtr() const {
+  if (m_target_sp)
+    return m_target_sp.get();
+  if (m_process_sp)
+    return &m_process_sp->GetTarget();
+  return nullptr;
+}
+
+Process *ExecutionContext::GetProcessPtr() const {
+  if (m_process_sp)
+    return m_process_sp.get();
+  if (m_target_sp)
+    return m_target_sp->GetProcessSP().get();
+  return nullptr;
+}
+
+ExecutionContextScope *ExecutionContext::GetBestExecutionContextScope() const {
+  if (m_frame_sp)
+    return m_frame_sp.get();
+  if (m_thread_sp)
+    return m_thread_sp.get();
+  if (m_process_sp)
+    return m_process_sp.get();
+  return m_target_sp.get();
+}
+
+Target &ExecutionContext::GetTargetRef() const {
+#if defined(LLDB_CONFIGURATION_DEBUG) || defined(LLDB_CONFIGURATION_RELEASE)
+  assert(m_target_sp);
 #endif
-    return *m_target_sp;
+  return *m_target_sp;
 }
 
-Process &
-ExecutionContext::GetProcessRef () const
-{
-#if defined (LLDB_CONFIGURATION_DEBUG) || defined (LLDB_CONFIGURATION_RELEASE)
-    assert (m_process_sp);
+Process &ExecutionContext::GetProcessRef() const {
+#if defined(LLDB_CONFIGURATION_DEBUG) || defined(LLDB_CONFIGURATION_RELEASE)
+  assert(m_process_sp);
 #endif
-    return *m_process_sp;
+  return *m_process_sp;
 }
 
-Thread &
-ExecutionContext::GetThreadRef () const
-{
-#if defined (LLDB_CONFIGURATION_DEBUG) || defined (LLDB_CONFIGURATION_RELEASE)
-    assert (m_thread_sp);
+Thread &ExecutionContext::GetThreadRef() const {
+#if defined(LLDB_CONFIGURATION_DEBUG) || defined(LLDB_CONFIGURATION_RELEASE)
+  assert(m_thread_sp);
 #endif
-    return *m_thread_sp;
+  return *m_thread_sp;
 }
 
-StackFrame &
-ExecutionContext::GetFrameRef () const
-{
-#if defined (LLDB_CONFIGURATION_DEBUG) || defined (LLDB_CONFIGURATION_RELEASE)
-    assert (m_frame_sp);
+StackFrame &ExecutionContext::GetFrameRef() const {
+#if defined(LLDB_CONFIGURATION_DEBUG) || defined(LLDB_CONFIGURATION_RELEASE)
+  assert(m_frame_sp);
 #endif
-    return *m_frame_sp;
+  return *m_frame_sp;
 }
 
-void
-ExecutionContext::SetTargetSP (const lldb::TargetSP &target_sp)
-{
-    m_target_sp = target_sp;
+void ExecutionContext::SetTargetSP(const lldb::TargetSP &target_sp) {
+  m_target_sp = target_sp;
 }
 
-void
-ExecutionContext::SetProcessSP (const lldb::ProcessSP &process_sp)
-{
-    m_process_sp = process_sp;
+void ExecutionContext::SetProcessSP(const lldb::ProcessSP &process_sp) {
+  m_process_sp = process_sp;
 }
 
-void
-ExecutionContext::SetThreadSP (const lldb::ThreadSP &thread_sp)
-{
-    m_thread_sp = thread_sp;
+void ExecutionContext::SetThreadSP(const lldb::ThreadSP &thread_sp) {
+  m_thread_sp = thread_sp;
 }
 
-void
-ExecutionContext::SetFrameSP (const lldb::StackFrameSP &frame_sp)
-{
-    m_frame_sp = frame_sp;
+void ExecutionContext::SetFrameSP(const lldb::StackFrameSP &frame_sp) {
+  m_frame_sp = frame_sp;
 }
 
-void
-ExecutionContext::SetTargetPtr (Target* target)
-{
-    if (target)
-        m_target_sp = target->shared_from_this();
-    else
-        m_target_sp.reset();
+void ExecutionContext::SetTargetPtr(Target *target) {
+  if (target)
+    m_target_sp = target->shared_from_this();
+  else
+    m_target_sp.reset();
 }
 
-void
-ExecutionContext::SetProcessPtr (Process *process)
-{
-    if (process)
-        m_process_sp = process->shared_from_this();
-    else
-        m_process_sp.reset();
+void ExecutionContext::SetProcessPtr(Process *process) {
+  if (process)
+    m_process_sp = process->shared_from_this();
+  else
+    m_process_sp.reset();
 }
 
-void
-ExecutionContext::SetThreadPtr (Thread *thread)
-{
-    if (thread)
-        m_thread_sp = thread->shared_from_this();
-    else
-        m_thread_sp.reset();
+void ExecutionContext::SetThreadPtr(Thread *thread) {
+  if (thread)
+    m_thread_sp = thread->shared_from_this();
+  else
+    m_thread_sp.reset();
 }
 
-void
-ExecutionContext::SetFramePtr (StackFrame *frame)
-{
-    if (frame)
-        m_frame_sp = frame->shared_from_this();
-    else
-        m_frame_sp.reset();
+void ExecutionContext::SetFramePtr(StackFrame *frame) {
+  if (frame)
+    m_frame_sp = frame->shared_from_this();
+  else
+    m_frame_sp.reset();
 }
 
-void
-ExecutionContext::SetContext (const lldb::TargetSP &target_sp, bool get_process)
-{
-    m_target_sp = target_sp;
-    if (get_process && target_sp)
-        m_process_sp = target_sp->GetProcessSP();
-    else
-        m_process_sp.reset();
-    m_thread_sp.reset();
-    m_frame_sp.reset();
+void ExecutionContext::SetContext(const lldb::TargetSP &target_sp,
+                                  bool get_process) {
+  m_target_sp = target_sp;
+  if (get_process && target_sp)
+    m_process_sp = target_sp->GetProcessSP();
+  else
+    m_process_sp.reset();
+  m_thread_sp.reset();
+  m_frame_sp.reset();
 }
 
-void
-ExecutionContext::SetContext (const lldb::ProcessSP &process_sp)
-{
-    m_process_sp = process_sp;
-    if (process_sp)
-        m_target_sp = process_sp->GetTarget().shared_from_this();
-    else
-        m_target_sp.reset();
-    m_thread_sp.reset();
-    m_frame_sp.reset();
+void ExecutionContext::SetContext(const lldb::ProcessSP &process_sp) {
+  m_process_sp = process_sp;
+  if (process_sp)
+    m_target_sp = process_sp->GetTarget().shared_from_this();
+  else
+    m_target_sp.reset();
+  m_thread_sp.reset();
+  m_frame_sp.reset();
 }
 
-void
-ExecutionContext::SetContext (const lldb::ThreadSP &thread_sp)
-{
-    m_frame_sp.reset();
-    m_thread_sp = thread_sp;
-    if (thread_sp)
-    {
-        m_process_sp = thread_sp->GetProcess();
-        if (m_process_sp)
-            m_target_sp = m_process_sp->GetTarget().shared_from_this();
-        else
-            m_target_sp.reset();
-    }
+void ExecutionContext::SetContext(const lldb::ThreadSP &thread_sp) {
+  m_frame_sp.reset();
+  m_thread_sp = thread_sp;
+  if (thread_sp) {
+    m_process_sp = thread_sp->GetProcess();
+    if (m_process_sp)
+      m_target_sp = m_process_sp->GetTarget().shared_from_this();
     else
-    {
-        m_target_sp.reset();
-        m_process_sp.reset();
-    }
+      m_target_sp.reset();
+  } else {
+    m_target_sp.reset();
+    m_process_sp.reset();
+  }
 }
 
-void
-ExecutionContext::SetContext (const lldb::StackFrameSP &frame_sp)
-{
-    m_frame_sp = frame_sp;
-    if (frame_sp)
-    {
-        m_thread_sp = frame_sp->CalculateThread();
-        if (m_thread_sp)
-        {
-            m_process_sp = m_thread_sp->GetProcess();
-            if (m_process_sp)
-                m_target_sp = m_process_sp->GetTarget().shared_from_this();
-            else
-                m_target_sp.reset();
-        }
-        else
-        {
-            m_target_sp.reset();
-            m_process_sp.reset();
-        }
-    }
-    else
-    {
+void ExecutionContext::SetContext(const lldb::StackFrameSP &frame_sp) {
+  m_frame_sp = frame_sp;
+  if (frame_sp) {
+    m_thread_sp = frame_sp->CalculateThread();
+    if (m_thread_sp) {
+      m_process_sp = m_thread_sp->GetProcess();
+      if (m_process_sp)
+        m_target_sp = m_process_sp->GetTarget().shared_from_this();
+      else
         m_target_sp.reset();
-        m_process_sp.reset();
-        m_thread_sp.reset();
+    } else {
+      m_target_sp.reset();
+      m_process_sp.reset();
     }
+  } else {
+    m_target_sp.reset();
+    m_process_sp.reset();
+    m_thread_sp.reset();
+  }
 }
 
-ExecutionContext &
-ExecutionContext::operator =(const ExecutionContext &rhs)
-{
-    if (this != &rhs)
-    {
-        m_target_sp  = rhs.m_target_sp;
-        m_process_sp = rhs.m_process_sp;
-        m_thread_sp  = rhs.m_thread_sp;
-        m_frame_sp   = rhs.m_frame_sp;
-    }
-    return *this;
+ExecutionContext &ExecutionContext::operator=(const ExecutionContext &rhs) {
+  if (this != &rhs) {
+    m_target_sp = rhs.m_target_sp;
+    m_process_sp = rhs.m_process_sp;
+    m_thread_sp = rhs.m_thread_sp;
+    m_frame_sp = rhs.m_frame_sp;
+  }
+  return *this;
+}
+
+bool ExecutionContext::operator==(const ExecutionContext &rhs) const {
+  // Check that the frame shared pointers match, or both are valid and their
+  // stack
+  // IDs match since sometimes we get new objects that represent the same
+  // frame within a thread.
+  if ((m_frame_sp == rhs.m_frame_sp) ||
+      (m_frame_sp && rhs.m_frame_sp &&
+       m_frame_sp->GetStackID() == rhs.m_frame_sp->GetStackID())) {
+    // Check that the thread shared pointers match, or both are valid and
+    // their thread IDs match since sometimes we get new objects that
+    // represent the same thread within a process.
+    if ((m_thread_sp == rhs.m_thread_sp) ||
+        (m_thread_sp && rhs.m_thread_sp &&
+         m_thread_sp->GetID() == rhs.m_thread_sp->GetID())) {
+      // Processes and targets don't change much
+      return m_process_sp == rhs.m_process_sp && m_target_sp == rhs.m_target_sp;
+    }
+  }
+  return false;
+}
+
+bool ExecutionContext::operator!=(const ExecutionContext &rhs) const {
+  return !(*this == rhs);
+}
+
+bool ExecutionContext::HasTargetScope() const {
+  return ((bool)m_target_sp && m_target_sp->IsValid());
+}
+
+bool ExecutionContext::HasProcessScope() const {
+  return (HasTargetScope() && ((bool)m_process_sp && m_process_sp->IsValid()));
+}
+
+bool ExecutionContext::HasThreadScope() const {
+  return (HasProcessScope() && ((bool)m_thread_sp && m_thread_sp->IsValid()));
+}
+
+bool ExecutionContext::HasFrameScope() const {
+  return HasThreadScope() && m_frame_sp;
+}
+
+ExecutionContextRef::ExecutionContextRef()
+    : m_target_wp(), m_process_wp(), m_thread_wp(),
+      m_tid(LLDB_INVALID_THREAD_ID), m_stack_id() {}
+
+ExecutionContextRef::ExecutionContextRef(const ExecutionContext *exe_ctx)
+    : m_target_wp(), m_process_wp(), m_thread_wp(),
+      m_tid(LLDB_INVALID_THREAD_ID), m_stack_id() {
+  if (exe_ctx)
+    *this = *exe_ctx;
+}
+
+ExecutionContextRef::ExecutionContextRef(const ExecutionContext &exe_ctx)
+    : m_target_wp(), m_process_wp(), m_thread_wp(),
+      m_tid(LLDB_INVALID_THREAD_ID), m_stack_id() {
+  *this = exe_ctx;
+}
+
+ExecutionContextRef::ExecutionContextRef(Target *target, bool adopt_selected)
+    : m_target_wp(), m_process_wp(), m_thread_wp(),
+      m_tid(LLDB_INVALID_THREAD_ID), m_stack_id() {
+  SetTargetPtr(target, adopt_selected);
+}
+
+ExecutionContextRef::ExecutionContextRef(const ExecutionContextRef &rhs)
+    : m_target_wp(rhs.m_target_wp), m_process_wp(rhs.m_process_wp),
+      m_thread_wp(rhs.m_thread_wp), m_tid(rhs.m_tid),
+      m_stack_id(rhs.m_stack_id) {}
+
+ExecutionContextRef &ExecutionContextRef::
+operator=(const ExecutionContextRef &rhs) {
+  if (this != &rhs) {
+    m_target_wp = rhs.m_target_wp;
+    m_process_wp = rhs.m_process_wp;
+    m_thread_wp = rhs.m_thread_wp;
+    m_tid = rhs.m_tid;
+    m_stack_id = rhs.m_stack_id;
+  }
+  return *this;
+}
+
+ExecutionContextRef &ExecutionContextRef::
+operator=(const ExecutionContext &exe_ctx) {
+  m_target_wp = exe_ctx.GetTargetSP();
+  m_process_wp = exe_ctx.GetProcessSP();
+  lldb::ThreadSP thread_sp(exe_ctx.GetThreadSP());
+  m_thread_wp = thread_sp;
+  if (thread_sp)
+    m_tid = thread_sp->GetID();
+  else
+    m_tid = LLDB_INVALID_THREAD_ID;
+  lldb::StackFrameSP frame_sp(exe_ctx.GetFrameSP());
+  if (frame_sp)
+    m_stack_id = frame_sp->GetStackID();
+  else
+    m_stack_id.Clear();
+  return *this;
+}
+
+void ExecutionContextRef::Clear() {
+  m_target_wp.reset();
+  m_process_wp.reset();
+  ClearThread();
+  ClearFrame();
 }
 
-bool
-ExecutionContext::operator ==(const ExecutionContext &rhs) const
-{
-    // Check that the frame shared pointers match, or both are valid and their stack
-    // IDs match since sometimes we get new objects that represent the same 
-    // frame within a thread.
-    if ((m_frame_sp == rhs.m_frame_sp) || (m_frame_sp && rhs.m_frame_sp && m_frame_sp->GetStackID() == rhs.m_frame_sp->GetStackID()))
-    {
-        // Check that the thread shared pointers match, or both are valid and 
-        // their thread IDs match since sometimes we get new objects that 
-        // represent the same thread within a process.
-        if ((m_thread_sp == rhs.m_thread_sp) || (m_thread_sp && rhs.m_thread_sp && m_thread_sp->GetID() == rhs.m_thread_sp->GetID()))
-        {
-            // Processes and targets don't change much
-            return m_process_sp == rhs.m_process_sp && m_target_sp == rhs.m_target_sp;
-        }
-    }
-    return false;
-}
+ExecutionContextRef::~ExecutionContextRef() = default;
 
-bool
-ExecutionContext::operator !=(const ExecutionContext &rhs) const
-{
-    return !(*this == rhs);
-}
-
-bool
-ExecutionContext::HasTargetScope () const
-{
-    return ((bool) m_target_sp
-            && m_target_sp->IsValid());
-}
-
-bool
-ExecutionContext::HasProcessScope () const
-{
-    return (HasTargetScope()
-            && ((bool) m_process_sp && m_process_sp->IsValid()));
-}
-
-bool
-ExecutionContext::HasThreadScope () const
-{
-    return (HasProcessScope()
-           && ((bool) m_thread_sp && m_thread_sp->IsValid()));
-}
-
-bool
-ExecutionContext::HasFrameScope () const
-{
-    return HasThreadScope() && m_frame_sp;
-}
-
-ExecutionContextRef::ExecutionContextRef() :
-    m_target_wp (),
-    m_process_wp (),
-    m_thread_wp (),
-    m_tid(LLDB_INVALID_THREAD_ID),
-    m_stack_id ()
-{
-}
-
-ExecutionContextRef::ExecutionContextRef (const ExecutionContext *exe_ctx) :
-    m_target_wp (),
-    m_process_wp (),
-    m_thread_wp (),
-    m_tid(LLDB_INVALID_THREAD_ID),
-    m_stack_id ()
-{
-    if (exe_ctx)
-        *this = *exe_ctx;
-}
-
-ExecutionContextRef::ExecutionContextRef (const ExecutionContext &exe_ctx) :
-    m_target_wp (),
-    m_process_wp (),
-    m_thread_wp (),
-    m_tid(LLDB_INVALID_THREAD_ID),
-    m_stack_id ()
-{
-    *this = exe_ctx;
-}
-
-ExecutionContextRef::ExecutionContextRef (Target *target, bool adopt_selected) :
-    m_target_wp(),
-    m_process_wp(),
-    m_thread_wp(),
-    m_tid(LLDB_INVALID_THREAD_ID),
-    m_stack_id ()
-{
-    SetTargetPtr (target, adopt_selected);
-}
-
-ExecutionContextRef::ExecutionContextRef (const ExecutionContextRef &rhs) :
-    m_target_wp (rhs.m_target_wp),
-    m_process_wp(rhs.m_process_wp),
-    m_thread_wp (rhs.m_thread_wp),
-    m_tid       (rhs.m_tid),
-    m_stack_id  (rhs.m_stack_id)
-{
-}
-
-ExecutionContextRef &
-ExecutionContextRef::operator =(const ExecutionContextRef &rhs)
-{
-    if (this != &rhs)
-    {
-        m_target_wp  = rhs.m_target_wp;
-        m_process_wp = rhs.m_process_wp;
-        m_thread_wp  = rhs.m_thread_wp;
-        m_tid        = rhs.m_tid;
-        m_stack_id   = rhs.m_stack_id;
-    }
-    return *this;
+void ExecutionContextRef::SetTargetSP(const lldb::TargetSP &target_sp) {
+  m_target_wp = target_sp;
 }
 
-ExecutionContextRef &
-ExecutionContextRef::operator =(const ExecutionContext &exe_ctx)
-{
-    m_target_wp = exe_ctx.GetTargetSP();
-    m_process_wp = exe_ctx.GetProcessSP();
-    lldb::ThreadSP thread_sp (exe_ctx.GetThreadSP());
-    m_thread_wp = thread_sp;
-    if (thread_sp)
-        m_tid = thread_sp->GetID();
-    else
-        m_tid = LLDB_INVALID_THREAD_ID;
-    lldb::StackFrameSP frame_sp (exe_ctx.GetFrameSP());
-    if (frame_sp)
-        m_stack_id = frame_sp->GetStackID();
-    else
-        m_stack_id.Clear();
-    return *this;
+void ExecutionContextRef::SetProcessSP(const lldb::ProcessSP &process_sp) {
+  if (process_sp) {
+    m_process_wp = process_sp;
+    SetTargetSP(process_sp->GetTarget().shared_from_this());
+  } else {
+    m_process_wp.reset();
+    m_target_wp.reset();
+  }
 }
 
-void
-ExecutionContextRef::Clear()
-{
-    m_target_wp.reset();
-    m_process_wp.reset();
+void ExecutionContextRef::SetThreadSP(const lldb::ThreadSP &thread_sp) {
+  if (thread_sp) {
+    m_thread_wp = thread_sp;
+    m_tid = thread_sp->GetID();
+    SetProcessSP(thread_sp->GetProcess());
+  } else {
     ClearThread();
-    ClearFrame();
+    m_process_wp.reset();
+    m_target_wp.reset();
+  }
 }
 
-ExecutionContextRef::~ExecutionContextRef() = default;
-
-void
-ExecutionContextRef::SetTargetSP (const lldb::TargetSP &target_sp)
-{
-    m_target_wp = target_sp;
+void ExecutionContextRef::SetFrameSP(const lldb::StackFrameSP &frame_sp) {
+  if (frame_sp) {
+    m_stack_id = frame_sp->GetStackID();
+    SetThreadSP(frame_sp->GetThread());
+  } else {
+    ClearFrame();
+    ClearThread();
+    m_process_wp.reset();
+    m_target_wp.reset();
+  }
 }
 
-void
-ExecutionContextRef::SetProcessSP (const lldb::ProcessSP &process_sp)
-{
-    if (process_sp)
-    {
-        m_process_wp = process_sp;
-        SetTargetSP (process_sp->GetTarget().shared_from_this());
-    }
-    else
-    {
-        m_process_wp.reset();
-        m_target_wp.reset();
+void ExecutionContextRef::SetTargetPtr(Target *target, bool adopt_selected) {
+  Clear();
+  if (target) {
+    lldb::TargetSP target_sp(target->shared_from_this());
+    if (target_sp) {
+      m_target_wp = target_sp;
+      if (adopt_selected) {
+        lldb::ProcessSP process_sp(target_sp->GetProcessSP());
+        if (process_sp) {
+          m_process_wp = process_sp;
+          if (process_sp) {
+            // Only fill in the thread and frame if our process is stopped
+            // Don't just check the state, since we might be in the middle of
+            // resuming.
+            Process::StopLocker stop_locker;
+
+            if (stop_locker.TryLock(&process_sp->GetRunLock()) &&
+                StateIsStoppedState(process_sp->GetState(), true)) {
+              lldb::ThreadSP thread_sp(
+                  process_sp->GetThreadList().GetSelectedThread());
+              if (!thread_sp)
+                thread_sp = process_sp->GetThreadList().GetThreadAtIndex(0);
+
+              if (thread_sp) {
+                SetThreadSP(thread_sp);
+                lldb::StackFrameSP frame_sp(thread_sp->GetSelectedFrame());
+                if (!frame_sp)
+                  frame_sp = thread_sp->GetStackFrameAtIndex(0);
+                if (frame_sp)
+                  SetFrameSP(frame_sp);
+              }
+            }
+          }
+        }
+      }
     }
+  }
 }
 
-void
-ExecutionContextRef::SetThreadSP (const lldb::ThreadSP &thread_sp)
-{
-    if (thread_sp)
-    {
-        m_thread_wp = thread_sp;
-        m_tid = thread_sp->GetID();
-        SetProcessSP (thread_sp->GetProcess());
-    }
-    else
-    {
-        ClearThread();
-        m_process_wp.reset();
-        m_target_wp.reset();
-    }
+void ExecutionContextRef::SetProcessPtr(Process *process) {
+  if (process) {
+    SetProcessSP(process->shared_from_this());
+  } else {
+    m_process_wp.reset();
+    m_target_wp.reset();
+  }
 }
 
-void
-ExecutionContextRef::SetFrameSP (const lldb::StackFrameSP &frame_sp)
-{
-    if (frame_sp)
-    {
-        m_stack_id = frame_sp->GetStackID();
-        SetThreadSP (frame_sp->GetThread());
-    }
-    else
-    {
-        ClearFrame();
-        ClearThread();
-        m_process_wp.reset();
-        m_target_wp.reset();
-    }
+void ExecutionContextRef::SetThreadPtr(Thread *thread) {
+  if (thread) {
+    SetThreadSP(thread->shared_from_this());
+  } else {
+    ClearThread();
+    m_process_wp.reset();
+    m_target_wp.reset();
+  }
 }
 
-void
-ExecutionContextRef::SetTargetPtr (Target* target, bool adopt_selected)
-{
+void ExecutionContextRef::SetFramePtr(StackFrame *frame) {
+  if (frame)
+    SetFrameSP(frame->shared_from_this());
+  else
     Clear();
-    if (target)
-    {
-        lldb::TargetSP target_sp (target->shared_from_this());
-        if (target_sp)
-        {
-            m_target_wp = target_sp;
-            if (adopt_selected)
-            {
-                lldb::ProcessSP process_sp (target_sp->GetProcessSP());
-                if (process_sp)
-                {
-                    m_process_wp = process_sp;
-                    if (process_sp)
-                    {
-                        // Only fill in the thread and frame if our process is stopped
-                        // Don't just check the state, since we might be in the middle of
-                        // resuming.
-                        Process::StopLocker stop_locker;
-
-                        if (stop_locker.TryLock(&process_sp->GetRunLock()) && StateIsStoppedState (process_sp->GetState(), true))
-                        {
-                            lldb::ThreadSP thread_sp (process_sp->GetThreadList().GetSelectedThread());
-                            if (!thread_sp)
-                                thread_sp = process_sp->GetThreadList().GetThreadAtIndex(0);
-                            
-                            if (thread_sp)
-                            {
-                                SetThreadSP (thread_sp);
-                                lldb::StackFrameSP frame_sp (thread_sp->GetSelectedFrame());
-                                if (!frame_sp)
-                                    frame_sp = thread_sp->GetStackFrameAtIndex(0);
-                                if (frame_sp)
-                                    SetFrameSP (frame_sp);
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
 }
 
-void
-ExecutionContextRef::SetProcessPtr (Process *process)
-{
-    if (process)
-    {
-        SetProcessSP(process->shared_from_this());
-    }
-    else
-    {
-        m_process_wp.reset();
-        m_target_wp.reset();
+lldb::TargetSP ExecutionContextRef::GetTargetSP() const {
+  lldb::TargetSP target_sp(m_target_wp.lock());
+  if (target_sp && !target_sp->IsValid())
+    target_sp.reset();
+  return target_sp;
+}
+
+lldb::ProcessSP ExecutionContextRef::GetProcessSP() const {
+  lldb::ProcessSP process_sp(m_process_wp.lock());
+  if (process_sp && !process_sp->IsValid())
+    process_sp.reset();
+  return process_sp;
+}
+
+lldb::ThreadSP ExecutionContextRef::GetThreadSP() const {
+  lldb::ThreadSP thread_sp(m_thread_wp.lock());
+
+  if (m_tid != LLDB_INVALID_THREAD_ID) {
+    // We check if the thread has been destroyed in cases where clients
+    // might still have shared pointer to a thread, but the thread is
+    // not valid anymore (not part of the process)
+    if (!thread_sp || !thread_sp->IsValid()) {
+      lldb::ProcessSP process_sp(GetProcessSP());
+      if (process_sp && process_sp->IsValid()) {
+        thread_sp = process_sp->GetThreadList().FindThreadByID(m_tid);
+        m_thread_wp = thread_sp;
+      }
     }
-}
+  }
 
-void
-ExecutionContextRef::SetThreadPtr (Thread *thread)
-{
-    if (thread)
-    {
-        SetThreadSP (thread->shared_from_this());
-    }
-    else
-    {
-        ClearThread();
-        m_process_wp.reset();
-        m_target_wp.reset();
-    }
-}
+  // Check that we aren't about to return an invalid thread sp.  We might return
+  // a nullptr thread_sp,
+  // but don't return an invalid one.
 
-void
-ExecutionContextRef::SetFramePtr (StackFrame *frame)
-{
-    if (frame)
-        SetFrameSP (frame->shared_from_this());
-    else
-        Clear();
+  if (thread_sp && !thread_sp->IsValid())
+    thread_sp.reset();
+
+  return thread_sp;
 }
 
-lldb::TargetSP
-ExecutionContextRef::GetTargetSP () const
-{
-    lldb::TargetSP target_sp(m_target_wp.lock());
-    if (target_sp && !target_sp->IsValid())
-        target_sp.reset();
-    return target_sp;
-}
-
-lldb::ProcessSP
-ExecutionContextRef::GetProcessSP () const
-{
-    lldb::ProcessSP process_sp(m_process_wp.lock());
-    if (process_sp && !process_sp->IsValid())
-        process_sp.reset();
-    return process_sp;
-}
-
-lldb::ThreadSP
-ExecutionContextRef::GetThreadSP () const
-{
-    lldb::ThreadSP thread_sp (m_thread_wp.lock());
-    
-    if (m_tid != LLDB_INVALID_THREAD_ID)
-    {
-        // We check if the thread has been destroyed in cases where clients
-        // might still have shared pointer to a thread, but the thread is
-        // not valid anymore (not part of the process)
-        if (!thread_sp || !thread_sp->IsValid())
-        {
-            lldb::ProcessSP process_sp(GetProcessSP());
-            if (process_sp && process_sp->IsValid())
-            {
-                thread_sp = process_sp->GetThreadList().FindThreadByID(m_tid);
-                m_thread_wp = thread_sp;
-            }
-        }
-    }
-    
-    // Check that we aren't about to return an invalid thread sp.  We might return a nullptr thread_sp,
-    // but don't return an invalid one.
-    
-    if (thread_sp && !thread_sp->IsValid())
-        thread_sp.reset();
-    
-    return thread_sp;
-}
-
-lldb::StackFrameSP
-ExecutionContextRef::GetFrameSP () const
-{
-    if (m_stack_id.IsValid())
-    {
-        lldb::ThreadSP thread_sp (GetThreadSP());
-        if (thread_sp)
-            return thread_sp->GetFrameWithStackID (m_stack_id);
-    }
-    return lldb::StackFrameSP();
+lldb::StackFrameSP ExecutionContextRef::GetFrameSP() const {
+  if (m_stack_id.IsValid()) {
+    lldb::ThreadSP thread_sp(GetThreadSP());
+    if (thread_sp)
+      return thread_sp->GetFrameWithStackID(m_stack_id);
+  }
+  return lldb::StackFrameSP();
 }
 
 ExecutionContext
-ExecutionContextRef::Lock (bool thread_and_frame_only_if_stopped) const
-{
-    return ExecutionContext(this, thread_and_frame_only_if_stopped);
+ExecutionContextRef::Lock(bool thread_and_frame_only_if_stopped) const {
+  return ExecutionContext(this, thread_and_frame_only_if_stopped);
 }

Modified: lldb/trunk/source/Target/FileAction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/FileAction.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/FileAction.cpp (original)
+++ lldb/trunk/source/Target/FileAction.cpp Tue Sep  6 15:57:50 2016
@@ -19,101 +19,73 @@ using namespace lldb_private;
 // FileAction member functions
 //----------------------------------------------------------------------------
 
-FileAction::FileAction() : 
-    m_action(eFileActionNone),
-    m_fd(-1),
-    m_arg(-1),
-    m_file_spec()
-{
-}
-
-void
-FileAction::Clear()
-{
-    m_action = eFileActionNone;
-    m_fd = -1;
-    m_arg = -1;
-    m_file_spec.Clear();
-}
-
-const char *
-FileAction::GetPath() const
-{
-    return m_file_spec.GetCString();
-}
-
-const FileSpec &
-FileAction::GetFileSpec() const
-{
-    return m_file_spec;
-}
+FileAction::FileAction()
+    : m_action(eFileActionNone), m_fd(-1), m_arg(-1), m_file_spec() {}
 
-bool
-FileAction::Open(int fd, const FileSpec &file_spec, bool read, bool write)
-{
-    if ((read || write) && fd >= 0 && file_spec)
-    {
-        m_action = eFileActionOpen;
-        m_fd = fd;
-        if (read && write)
-            m_arg = O_NOCTTY | O_CREAT | O_RDWR;
-        else if (read)
-            m_arg = O_NOCTTY | O_RDONLY;
-        else
-            m_arg = O_NOCTTY | O_CREAT | O_WRONLY;
-        m_file_spec = file_spec;
-        return true;
-    }
+void FileAction::Clear() {
+  m_action = eFileActionNone;
+  m_fd = -1;
+  m_arg = -1;
+  m_file_spec.Clear();
+}
+
+const char *FileAction::GetPath() const { return m_file_spec.GetCString(); }
+
+const FileSpec &FileAction::GetFileSpec() const { return m_file_spec; }
+
+bool FileAction::Open(int fd, const FileSpec &file_spec, bool read,
+                      bool write) {
+  if ((read || write) && fd >= 0 && file_spec) {
+    m_action = eFileActionOpen;
+    m_fd = fd;
+    if (read && write)
+      m_arg = O_NOCTTY | O_CREAT | O_RDWR;
+    else if (read)
+      m_arg = O_NOCTTY | O_RDONLY;
     else
-    {
-        Clear();
-    }
-    return false;
-}
-
-bool
-FileAction::Close(int fd)
-{
-    Clear();
-    if (fd >= 0)
-    {
-        m_action = eFileActionClose;
-        m_fd = fd;
-    }
-    return m_fd >= 0;
-}
-
-bool
-FileAction::Duplicate(int fd, int dup_fd)
-{
+      m_arg = O_NOCTTY | O_CREAT | O_WRONLY;
+    m_file_spec = file_spec;
+    return true;
+  } else {
     Clear();
-    if (fd >= 0 && dup_fd >= 0)
-    {
-        m_action = eFileActionDuplicate;
-        m_fd = fd;
-        m_arg = dup_fd;
-    }
-    return m_fd >= 0;
+  }
+  return false;
 }
 
-void
-FileAction::Dump(Stream &stream) const
-{
-    stream.PutCString("file action: ");
-    switch (m_action)
-    {
-        case eFileActionClose:
-            stream.Printf("close fd %d", m_fd);
-            break;
-        case eFileActionDuplicate:
-            stream.Printf("duplicate fd %d to %d", m_fd, m_arg);
-            break;
-        case eFileActionNone:
-            stream.PutCString("no action");
-            break;
-        case eFileActionOpen:
-            stream.Printf("open fd %d with '%s', OFLAGS = 0x%x",
-                    m_fd, m_file_spec.GetCString(), m_arg);
-            break;
-    }
+bool FileAction::Close(int fd) {
+  Clear();
+  if (fd >= 0) {
+    m_action = eFileActionClose;
+    m_fd = fd;
+  }
+  return m_fd >= 0;
+}
+
+bool FileAction::Duplicate(int fd, int dup_fd) {
+  Clear();
+  if (fd >= 0 && dup_fd >= 0) {
+    m_action = eFileActionDuplicate;
+    m_fd = fd;
+    m_arg = dup_fd;
+  }
+  return m_fd >= 0;
+}
+
+void FileAction::Dump(Stream &stream) const {
+  stream.PutCString("file action: ");
+  switch (m_action) {
+  case eFileActionClose:
+    stream.Printf("close fd %d", m_fd);
+    break;
+  case eFileActionDuplicate:
+    stream.Printf("duplicate fd %d to %d", m_fd, m_arg);
+    break;
+  case eFileActionNone:
+    stream.PutCString("no action");
+    break;
+  case eFileActionOpen:
+    stream.Printf("open fd %d with '%s', OFLAGS = 0x%x", m_fd,
+                  m_file_spec.GetCString(), m_arg);
+    break;
+  }
 }

Modified: lldb/trunk/source/Target/InstrumentationRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/InstrumentationRuntime.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/InstrumentationRuntime.cpp (original)
+++ lldb/trunk/source/Target/InstrumentationRuntime.cpp Tue Sep  6 15:57:50 2016
@@ -11,72 +11,70 @@
 // C++ Includes
 // Other libraries and framework includes
 // Project includes
-#include "lldb/lldb-private.h"
-#include "lldb/Target/Process.h"
+#include "lldb/Target/InstrumentationRuntime.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleList.h"
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/RegularExpression.h"
-#include "lldb/Target/InstrumentationRuntime.h"
+#include "lldb/Target/Process.h"
+#include "lldb/lldb-private.h"
 
 using namespace lldb;
 using namespace lldb_private;
 
-void
-InstrumentationRuntime::ModulesDidLoad(lldb_private::ModuleList &module_list, lldb_private::Process *process, InstrumentationRuntimeCollection &runtimes)
-{
-    InstrumentationRuntimeCreateInstance create_callback = nullptr;
-    InstrumentationRuntimeGetType get_type_callback;
-    for (uint32_t idx = 0; ; ++idx)
-    {
-        create_callback = PluginManager::GetInstrumentationRuntimeCreateCallbackAtIndex(idx);
-        if (create_callback == nullptr)
-            break;
-        get_type_callback = PluginManager::GetInstrumentationRuntimeGetTypeCallbackAtIndex(idx);
-        InstrumentationRuntimeType type = get_type_callback();
-        
-        InstrumentationRuntimeCollection::iterator pos;
-        pos = runtimes.find (type);
-        if (pos == runtimes.end()) {
-            runtimes[type] = create_callback(process->shared_from_this());
-        }
+void InstrumentationRuntime::ModulesDidLoad(
+    lldb_private::ModuleList &module_list, lldb_private::Process *process,
+    InstrumentationRuntimeCollection &runtimes) {
+  InstrumentationRuntimeCreateInstance create_callback = nullptr;
+  InstrumentationRuntimeGetType get_type_callback;
+  for (uint32_t idx = 0;; ++idx) {
+    create_callback =
+        PluginManager::GetInstrumentationRuntimeCreateCallbackAtIndex(idx);
+    if (create_callback == nullptr)
+      break;
+    get_type_callback =
+        PluginManager::GetInstrumentationRuntimeGetTypeCallbackAtIndex(idx);
+    InstrumentationRuntimeType type = get_type_callback();
+
+    InstrumentationRuntimeCollection::iterator pos;
+    pos = runtimes.find(type);
+    if (pos == runtimes.end()) {
+      runtimes[type] = create_callback(process->shared_from_this());
     }
+  }
 }
 
-void
-InstrumentationRuntime::ModulesDidLoad(lldb_private::ModuleList &module_list)
-{
-    if (IsActive())
-        return;
-
-    if (GetRuntimeModuleSP())
-    {
+void InstrumentationRuntime::ModulesDidLoad(
+    lldb_private::ModuleList &module_list) {
+  if (IsActive())
+    return;
+
+  if (GetRuntimeModuleSP()) {
+    Activate();
+    return;
+  }
+
+  module_list.ForEach([this](const lldb::ModuleSP module_sp) -> bool {
+    const FileSpec &file_spec = module_sp->GetFileSpec();
+    if (!file_spec)
+      return true; // Keep iterating.
+
+    const RegularExpression &runtime_regex = GetPatternForRuntimeLibrary();
+    if (runtime_regex.Execute(file_spec.GetFilename().GetCString()) ||
+        module_sp->IsExecutable()) {
+      if (CheckIfRuntimeIsValid(module_sp)) {
+        SetRuntimeModuleSP(module_sp);
         Activate();
-        return;
+        return false; // Stop iterating, we're done.
+      }
     }
 
-    module_list.ForEach([this](const lldb::ModuleSP module_sp) -> bool {
-        const FileSpec &file_spec = module_sp->GetFileSpec();
-        if (!file_spec)
-            return true; // Keep iterating.
-
-        const RegularExpression &runtime_regex = GetPatternForRuntimeLibrary();
-        if (runtime_regex.Execute(file_spec.GetFilename().GetCString()) || module_sp->IsExecutable())
-        {
-            if (CheckIfRuntimeIsValid(module_sp))
-            {
-                SetRuntimeModuleSP(module_sp);
-                Activate();
-                return false; // Stop iterating, we're done.
-            }
-        }
-
-        return true;
-    });
+    return true;
+  });
 }
 
 lldb::ThreadCollectionSP
-InstrumentationRuntime::GetBacktracesFromExtendedStopInfo(StructuredData::ObjectSP info)
-{
-    return ThreadCollectionSP(new ThreadCollection());
+InstrumentationRuntime::GetBacktracesFromExtendedStopInfo(
+    StructuredData::ObjectSP info) {
+  return ThreadCollectionSP(new ThreadCollection());
 }

Modified: lldb/trunk/source/Target/InstrumentationRuntimeStopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/InstrumentationRuntimeStopInfo.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/InstrumentationRuntimeStopInfo.cpp (original)
+++ lldb/trunk/source/Target/InstrumentationRuntimeStopInfo.cpp Tue Sep  6 15:57:50 2016
@@ -9,28 +9,29 @@
 
 #include "lldb/Target/InstrumentationRuntimeStopInfo.h"
 
-#include "lldb/lldb-private.h"
-#include "lldb/Target/Process.h"
 #include "lldb/Target/InstrumentationRuntime.h"
+#include "lldb/Target/Process.h"
+#include "lldb/lldb-private.h"
 
 using namespace lldb;
 using namespace lldb_private;
 
-InstrumentationRuntimeStopInfo::InstrumentationRuntimeStopInfo(Thread &thread, std::string description, StructuredData::ObjectSP additional_data) :
-    StopInfo(thread, 0)
-{
-    m_extended_info = additional_data;
-    m_description = description;
+InstrumentationRuntimeStopInfo::InstrumentationRuntimeStopInfo(
+    Thread &thread, std::string description,
+    StructuredData::ObjectSP additional_data)
+    : StopInfo(thread, 0) {
+  m_extended_info = additional_data;
+  m_description = description;
 }
 
-const char *
-InstrumentationRuntimeStopInfo::GetDescription ()
-{
-    return m_description.c_str();
+const char *InstrumentationRuntimeStopInfo::GetDescription() {
+  return m_description.c_str();
 }
 
 StopInfoSP
-InstrumentationRuntimeStopInfo::CreateStopReasonWithInstrumentationData (Thread &thread, std::string description, StructuredData::ObjectSP additionalData)
-{
-    return StopInfoSP(new InstrumentationRuntimeStopInfo(thread, description, additionalData));
+InstrumentationRuntimeStopInfo::CreateStopReasonWithInstrumentationData(
+    Thread &thread, std::string description,
+    StructuredData::ObjectSP additionalData) {
+  return StopInfoSP(
+      new InstrumentationRuntimeStopInfo(thread, description, additionalData));
 }

Modified: lldb/trunk/source/Target/JITLoader.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/JITLoader.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/JITLoader.cpp (original)
+++ lldb/trunk/source/Target/JITLoader.cpp Tue Sep  6 15:57:50 2016
@@ -11,30 +11,27 @@
 // C++ Includes
 // Other libraries and framework includes
 // Project includes
-#include "lldb/lldb-private.h"
 #include "lldb/Target/JITLoader.h"
+#include "lldb/Core/PluginManager.h"
 #include "lldb/Target/JITLoaderList.h"
 #include "lldb/Target/Process.h"
-#include "lldb/Core/PluginManager.h"
+#include "lldb/lldb-private.h"
 
 using namespace lldb;
 using namespace lldb_private;
 
-void
-JITLoader::LoadPlugins (Process *process, JITLoaderList &list)
-{
-    JITLoaderCreateInstance create_callback = nullptr;
-    for (uint32_t idx = 0; (create_callback = PluginManager::GetJITLoaderCreateCallbackAtIndex(idx)) != nullptr; ++idx)
-    {
-        JITLoaderSP instance_sp(create_callback(process, false));
-        if (instance_sp)
-            list.Append(std::move(instance_sp));
-    }
+void JITLoader::LoadPlugins(Process *process, JITLoaderList &list) {
+  JITLoaderCreateInstance create_callback = nullptr;
+  for (uint32_t idx = 0;
+       (create_callback =
+            PluginManager::GetJITLoaderCreateCallbackAtIndex(idx)) != nullptr;
+       ++idx) {
+    JITLoaderSP instance_sp(create_callback(process, false));
+    if (instance_sp)
+      list.Append(std::move(instance_sp));
+  }
 }
 
-JITLoader::JITLoader(Process *process) :
-    m_process (process)
-{
-}
+JITLoader::JITLoader(Process *process) : m_process(process) {}
 
 JITLoader::~JITLoader() = default;

Modified: lldb/trunk/source/Target/JITLoaderList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/JITLoaderList.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/JITLoaderList.cpp (original)
+++ lldb/trunk/source/Target/JITLoaderList.cpp Tue Sep  6 15:57:50 2016
@@ -7,70 +7,50 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "lldb/lldb-private.h"
 #include "lldb/Target/JITLoader.h"
 #include "lldb/Target/JITLoaderList.h"
+#include "lldb/lldb-private.h"
 
 using namespace lldb;
 using namespace lldb_private;
 
-JITLoaderList::JITLoaderList() : m_jit_loaders_vec(), m_jit_loaders_mutex()
-{
-}
+JITLoaderList::JITLoaderList() : m_jit_loaders_vec(), m_jit_loaders_mutex() {}
 
-JITLoaderList::~JITLoaderList()
-{
-}
+JITLoaderList::~JITLoaderList() {}
 
-void
-JITLoaderList::Append (const JITLoaderSP &jit_loader_sp)
-{
-    std::lock_guard<std::recursive_mutex> guard(m_jit_loaders_mutex);
-    m_jit_loaders_vec.push_back(jit_loader_sp);
+void JITLoaderList::Append(const JITLoaderSP &jit_loader_sp) {
+  std::lock_guard<std::recursive_mutex> guard(m_jit_loaders_mutex);
+  m_jit_loaders_vec.push_back(jit_loader_sp);
 }
 
-void
-JITLoaderList::Remove (const JITLoaderSP &jit_loader_sp)
-{
-    std::lock_guard<std::recursive_mutex> guard(m_jit_loaders_mutex);
-    m_jit_loaders_vec.erase(std::remove(m_jit_loaders_vec.begin(),
-                                        m_jit_loaders_vec.end(), jit_loader_sp),
-                            m_jit_loaders_vec.end());
+void JITLoaderList::Remove(const JITLoaderSP &jit_loader_sp) {
+  std::lock_guard<std::recursive_mutex> guard(m_jit_loaders_mutex);
+  m_jit_loaders_vec.erase(std::remove(m_jit_loaders_vec.begin(),
+                                      m_jit_loaders_vec.end(), jit_loader_sp),
+                          m_jit_loaders_vec.end());
 }
 
-size_t
-JITLoaderList::GetSize() const
-{
-    return m_jit_loaders_vec.size();
-}
+size_t JITLoaderList::GetSize() const { return m_jit_loaders_vec.size(); }
 
-JITLoaderSP
-JITLoaderList::GetLoaderAtIndex (size_t idx)
-{
-    std::lock_guard<std::recursive_mutex> guard(m_jit_loaders_mutex);
-    return m_jit_loaders_vec[idx];
+JITLoaderSP JITLoaderList::GetLoaderAtIndex(size_t idx) {
+  std::lock_guard<std::recursive_mutex> guard(m_jit_loaders_mutex);
+  return m_jit_loaders_vec[idx];
 }
 
-void
-JITLoaderList::DidLaunch()
-{
-    std::lock_guard<std::recursive_mutex> guard(m_jit_loaders_mutex);
-    for (auto const &jit_loader : m_jit_loaders_vec)
-        jit_loader->DidLaunch();
+void JITLoaderList::DidLaunch() {
+  std::lock_guard<std::recursive_mutex> guard(m_jit_loaders_mutex);
+  for (auto const &jit_loader : m_jit_loaders_vec)
+    jit_loader->DidLaunch();
 }
 
-void
-JITLoaderList::DidAttach()
-{
-    std::lock_guard<std::recursive_mutex> guard(m_jit_loaders_mutex);
-    for (auto const &jit_loader : m_jit_loaders_vec)
-        jit_loader->DidAttach();
+void JITLoaderList::DidAttach() {
+  std::lock_guard<std::recursive_mutex> guard(m_jit_loaders_mutex);
+  for (auto const &jit_loader : m_jit_loaders_vec)
+    jit_loader->DidAttach();
 }
 
-void
-JITLoaderList::ModulesDidLoad(ModuleList &module_list)
-{
-    std::lock_guard<std::recursive_mutex> guard(m_jit_loaders_mutex);
-    for (auto const &jit_loader : m_jit_loaders_vec)
-        jit_loader->ModulesDidLoad(module_list);
+void JITLoaderList::ModulesDidLoad(ModuleList &module_list) {
+  std::lock_guard<std::recursive_mutex> guard(m_jit_loaders_mutex);
+  for (auto const &jit_loader : m_jit_loaders_vec)
+    jit_loader->ModulesDidLoad(module_list);
 }

Modified: lldb/trunk/source/Target/Language.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Language.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/Language.cpp (original)
+++ lldb/trunk/source/Target/Language.cpp Tue Sep  6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- Language.cpp -------------------------------------------------*- C++ -*-===//
+//===-- Language.cpp -------------------------------------------------*- C++
+//-*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -23,442 +24,365 @@ using namespace lldb_private::formatters
 typedef std::unique_ptr<Language> LanguageUP;
 typedef std::map<lldb::LanguageType, LanguageUP> LanguagesMap;
 
-static LanguagesMap&
-GetLanguagesMap ()
-{
-    static LanguagesMap *g_map = nullptr;
-    static std::once_flag g_initialize;
-    
-    std::call_once(g_initialize, [] {
-        g_map = new LanguagesMap(); // NOTE: INTENTIONAL LEAK due to global destructor chain
-    });
-    
-    return *g_map;
-}
-static std::mutex &
-GetLanguagesMutex()
-{
-    static std::mutex *g_mutex = nullptr;
-    static std::once_flag g_initialize;
-
-    std::call_once(g_initialize, [] {
-        g_mutex = new std::mutex(); // NOTE: INTENTIONAL LEAK due to global destructor chain
-    });
-
-    return *g_mutex;
-}
-
-Language*
-Language::FindPlugin (lldb::LanguageType language)
-{
-    std::lock_guard<std::mutex> guard(GetLanguagesMutex());
-    LanguagesMap& map(GetLanguagesMap());
-    auto iter = map.find(language), end = map.end();
-    if (iter != end)
-        return iter->second.get();
-    
-    Language *language_ptr = nullptr;
-    LanguageCreateInstance create_callback;
-    
-    for (uint32_t idx = 0;
-         (create_callback = PluginManager::GetLanguageCreateCallbackAtIndex(idx)) != nullptr;
-         ++idx)
-    {
-        language_ptr = create_callback(language);
-        
-        if (language_ptr)
-        {
-            map[language] = std::unique_ptr<Language>(language_ptr);
-            return language_ptr;
-        }
-    }
-    
-    return nullptr;
+static LanguagesMap &GetLanguagesMap() {
+  static LanguagesMap *g_map = nullptr;
+  static std::once_flag g_initialize;
+
+  std::call_once(g_initialize, [] {
+    g_map = new LanguagesMap(); // NOTE: INTENTIONAL LEAK due to global
+                                // destructor chain
+  });
+
+  return *g_map;
+}
+static std::mutex &GetLanguagesMutex() {
+  static std::mutex *g_mutex = nullptr;
+  static std::once_flag g_initialize;
+
+  std::call_once(g_initialize, [] {
+    g_mutex = new std::mutex(); // NOTE: INTENTIONAL LEAK due to global
+                                // destructor chain
+  });
+
+  return *g_mutex;
 }
 
-void
-Language::ForEach (std::function<bool(Language*)> callback)
-{
-    std::lock_guard<std::mutex> guard(GetLanguagesMutex());
-    LanguagesMap& map(GetLanguagesMap());
-    for (const auto& entry : map)
-    {
-        if (!callback(entry.second.get()))
-            break;
+Language *Language::FindPlugin(lldb::LanguageType language) {
+  std::lock_guard<std::mutex> guard(GetLanguagesMutex());
+  LanguagesMap &map(GetLanguagesMap());
+  auto iter = map.find(language), end = map.end();
+  if (iter != end)
+    return iter->second.get();
+
+  Language *language_ptr = nullptr;
+  LanguageCreateInstance create_callback;
+
+  for (uint32_t idx = 0;
+       (create_callback =
+            PluginManager::GetLanguageCreateCallbackAtIndex(idx)) != nullptr;
+       ++idx) {
+    language_ptr = create_callback(language);
+
+    if (language_ptr) {
+      map[language] = std::unique_ptr<Language>(language_ptr);
+      return language_ptr;
     }
+  }
+
+  return nullptr;
 }
 
-bool
-Language::IsTopLevelFunction (Function& function)
-{
-    return false;
+void Language::ForEach(std::function<bool(Language *)> callback) {
+  std::lock_guard<std::mutex> guard(GetLanguagesMutex());
+  LanguagesMap &map(GetLanguagesMap());
+  for (const auto &entry : map) {
+    if (!callback(entry.second.get()))
+      break;
+  }
 }
 
-lldb::TypeCategoryImplSP
-Language::GetFormatters ()
-{
-    return nullptr;
-}
-
-HardcodedFormatters::HardcodedFormatFinder
-Language::GetHardcodedFormats ()
-{
-    return {};
-}
-
-HardcodedFormatters::HardcodedSummaryFinder
-Language::GetHardcodedSummaries ()
-{
-    return {};
+bool Language::IsTopLevelFunction(Function &function) { return false; }
+
+lldb::TypeCategoryImplSP Language::GetFormatters() { return nullptr; }
+
+HardcodedFormatters::HardcodedFormatFinder Language::GetHardcodedFormats() {
+  return {};
+}
+
+HardcodedFormatters::HardcodedSummaryFinder Language::GetHardcodedSummaries() {
+  return {};
 }
 
 HardcodedFormatters::HardcodedSyntheticFinder
-Language::GetHardcodedSynthetics ()
-{
-    return {};
+Language::GetHardcodedSynthetics() {
+  return {};
 }
 
 HardcodedFormatters::HardcodedValidatorFinder
-Language::GetHardcodedValidators ()
-{
-    return {};
+Language::GetHardcodedValidators() {
+  return {};
 }
 
 std::vector<ConstString>
-Language::GetPossibleFormattersMatches (ValueObject& valobj, lldb::DynamicValueType use_dynamic)
-{
-    return {};
+Language::GetPossibleFormattersMatches(ValueObject &valobj,
+                                       lldb::DynamicValueType use_dynamic) {
+  return {};
 }
 
 lldb_private::formatters::StringPrinter::EscapingHelper
-Language::GetStringPrinterEscapingHelper (lldb_private::formatters::StringPrinter::GetPrintableElementType elem_type)
-{
-    return StringPrinter::GetDefaultEscapingHelper(elem_type);
+Language::GetStringPrinterEscapingHelper(
+    lldb_private::formatters::StringPrinter::GetPrintableElementType
+        elem_type) {
+  return StringPrinter::GetDefaultEscapingHelper(elem_type);
 }
 
 struct language_name_pair {
-    const char *name;
-    LanguageType type;
+  const char *name;
+  LanguageType type;
 };
 
-struct language_name_pair language_names[] =
-{
+struct language_name_pair language_names[] = {
     // To allow GetNameForLanguageType to be a simple array lookup, the first
     // part of this array must follow enum LanguageType exactly.
-    {   "unknown",          eLanguageTypeUnknown        },
-    {   "c89",              eLanguageTypeC89            },
-    {   "c",                eLanguageTypeC              },
-    {   "ada83",            eLanguageTypeAda83          },
-    {   "c++",              eLanguageTypeC_plus_plus    },
-    {   "cobol74",          eLanguageTypeCobol74        },
-    {   "cobol85",          eLanguageTypeCobol85        },
-    {   "fortran77",        eLanguageTypeFortran77      },
-    {   "fortran90",        eLanguageTypeFortran90      },
-    {   "pascal83",         eLanguageTypePascal83       },
-    {   "modula2",          eLanguageTypeModula2        },
-    {   "java",             eLanguageTypeJava           },
-    {   "c99",              eLanguageTypeC99            },
-    {   "ada95",            eLanguageTypeAda95          },
-    {   "fortran95",        eLanguageTypeFortran95      },
-    {   "pli",              eLanguageTypePLI            },
-    {   "objective-c",      eLanguageTypeObjC           },
-    {   "objective-c++",    eLanguageTypeObjC_plus_plus },
-    {   "upc",              eLanguageTypeUPC            },
-    {   "d",                eLanguageTypeD              },
-    {   "python",           eLanguageTypePython         },
-    {   "opencl",           eLanguageTypeOpenCL         },
-    {   "go",               eLanguageTypeGo             },
-    {   "modula3",          eLanguageTypeModula3        },
-    {   "haskell",          eLanguageTypeHaskell        },
-    {   "c++03",            eLanguageTypeC_plus_plus_03 },
-    {   "c++11",            eLanguageTypeC_plus_plus_11 },
-    {   "ocaml",            eLanguageTypeOCaml          },
-    {   "rust",             eLanguageTypeRust           },
-    {   "c11",              eLanguageTypeC11            },
-    {   "swift",            eLanguageTypeSwift          },
-    {   "julia",            eLanguageTypeJulia          },
-    {   "dylan",            eLanguageTypeDylan          },
-    {   "c++14",            eLanguageTypeC_plus_plus_14 },
-    {   "fortran03",        eLanguageTypeFortran03      },
-    {   "fortran08",        eLanguageTypeFortran08      },
+    {"unknown", eLanguageTypeUnknown},
+    {"c89", eLanguageTypeC89},
+    {"c", eLanguageTypeC},
+    {"ada83", eLanguageTypeAda83},
+    {"c++", eLanguageTypeC_plus_plus},
+    {"cobol74", eLanguageTypeCobol74},
+    {"cobol85", eLanguageTypeCobol85},
+    {"fortran77", eLanguageTypeFortran77},
+    {"fortran90", eLanguageTypeFortran90},
+    {"pascal83", eLanguageTypePascal83},
+    {"modula2", eLanguageTypeModula2},
+    {"java", eLanguageTypeJava},
+    {"c99", eLanguageTypeC99},
+    {"ada95", eLanguageTypeAda95},
+    {"fortran95", eLanguageTypeFortran95},
+    {"pli", eLanguageTypePLI},
+    {"objective-c", eLanguageTypeObjC},
+    {"objective-c++", eLanguageTypeObjC_plus_plus},
+    {"upc", eLanguageTypeUPC},
+    {"d", eLanguageTypeD},
+    {"python", eLanguageTypePython},
+    {"opencl", eLanguageTypeOpenCL},
+    {"go", eLanguageTypeGo},
+    {"modula3", eLanguageTypeModula3},
+    {"haskell", eLanguageTypeHaskell},
+    {"c++03", eLanguageTypeC_plus_plus_03},
+    {"c++11", eLanguageTypeC_plus_plus_11},
+    {"ocaml", eLanguageTypeOCaml},
+    {"rust", eLanguageTypeRust},
+    {"c11", eLanguageTypeC11},
+    {"swift", eLanguageTypeSwift},
+    {"julia", eLanguageTypeJulia},
+    {"dylan", eLanguageTypeDylan},
+    {"c++14", eLanguageTypeC_plus_plus_14},
+    {"fortran03", eLanguageTypeFortran03},
+    {"fortran08", eLanguageTypeFortran08},
     // Vendor Extensions
-    {   "mipsassem",        eLanguageTypeMipsAssembler  },
-    {   "renderscript",     eLanguageTypeExtRenderScript},
+    {"mipsassem", eLanguageTypeMipsAssembler},
+    {"renderscript", eLanguageTypeExtRenderScript},
     // Now synonyms, in arbitrary order
-    {   "objc",             eLanguageTypeObjC           },
-    {   "objc++",           eLanguageTypeObjC_plus_plus },
-    {   "pascal",           eLanguageTypePascal83       }
-};
-
-static uint32_t num_languages = sizeof(language_names) / sizeof (struct language_name_pair);
-
-LanguageType
-Language::GetLanguageTypeFromString (const char *string)
-{
-    for (uint32_t i = 0; i < num_languages; i++)
-    {
-        if (strcasecmp (language_names[i].name, string) == 0)
-            return (LanguageType) language_names[i].type;
-    }
-    return eLanguageTypeUnknown;
+    {"objc", eLanguageTypeObjC},
+    {"objc++", eLanguageTypeObjC_plus_plus},
+    {"pascal", eLanguageTypePascal83}};
+
+static uint32_t num_languages =
+    sizeof(language_names) / sizeof(struct language_name_pair);
+
+LanguageType Language::GetLanguageTypeFromString(const char *string) {
+  for (uint32_t i = 0; i < num_languages; i++) {
+    if (strcasecmp(language_names[i].name, string) == 0)
+      return (LanguageType)language_names[i].type;
+  }
+  return eLanguageTypeUnknown;
+}
+
+const char *Language::GetNameForLanguageType(LanguageType language) {
+  if (language < num_languages)
+    return language_names[language].name;
+  else
+    return language_names[eLanguageTypeUnknown].name;
+}
+
+void Language::PrintAllLanguages(Stream &s, const char *prefix,
+                                 const char *suffix) {
+  for (uint32_t i = 1; i < num_languages; i++) {
+    s.Printf("%s%s%s", prefix, language_names[i].name, suffix);
+  }
+}
+
+void Language::ForAllLanguages(
+    std::function<bool(lldb::LanguageType)> callback) {
+  for (uint32_t i = 1; i < num_languages; i++) {
+    if (!callback(language_names[i].type))
+      break;
+  }
+}
+
+bool Language::LanguageIsCPlusPlus(LanguageType language) {
+  switch (language) {
+  case eLanguageTypeC_plus_plus:
+  case eLanguageTypeC_plus_plus_03:
+  case eLanguageTypeC_plus_plus_11:
+  case eLanguageTypeC_plus_plus_14:
+  case eLanguageTypeObjC_plus_plus:
+    return true;
+  default:
+    return false;
+  }
 }
 
-const char *
-Language::GetNameForLanguageType (LanguageType language)
-{
-    if (language < num_languages)
-        return language_names[language].name;
-    else
-        return language_names[eLanguageTypeUnknown].name;
-}
-
-void
-Language::PrintAllLanguages (Stream &s, const char *prefix, const char *suffix)
-{
-    for (uint32_t i = 1; i < num_languages; i++)
-    {
-        s.Printf("%s%s%s", prefix, language_names[i].name, suffix);
-    }
+bool Language::LanguageIsObjC(LanguageType language) {
+  switch (language) {
+  case eLanguageTypeObjC:
+  case eLanguageTypeObjC_plus_plus:
+    return true;
+  default:
+    return false;
+  }
 }
 
-void
-Language::ForAllLanguages (std::function<bool(lldb::LanguageType)> callback)
-{
-    for (uint32_t i = 1; i < num_languages; i++)
-    {
-        if (!callback(language_names[i].type))
-            break;
-    }
+bool Language::LanguageIsC(LanguageType language) {
+  switch (language) {
+  case eLanguageTypeC:
+  case eLanguageTypeC89:
+  case eLanguageTypeC99:
+  case eLanguageTypeC11:
+    return true;
+  default:
+    return false;
+  }
 }
 
-bool
-Language::LanguageIsCPlusPlus (LanguageType language)
-{
-    switch (language)
-    {
-        case eLanguageTypeC_plus_plus:
-        case eLanguageTypeC_plus_plus_03:
-        case eLanguageTypeC_plus_plus_11:
-        case eLanguageTypeC_plus_plus_14:
-        case eLanguageTypeObjC_plus_plus:
-            return true;
-        default:
-            return false;
-    }
+bool Language::LanguageIsPascal(LanguageType language) {
+  switch (language) {
+  case eLanguageTypePascal83:
+    return true;
+  default:
+    return false;
+  }
 }
 
-bool
-Language::LanguageIsObjC (LanguageType language)
-{
-    switch (language)
-    {
-        case eLanguageTypeObjC:
-        case eLanguageTypeObjC_plus_plus:
-            return true;
-        default:
-            return false;
-    }
-}
+LanguageType Language::GetPrimaryLanguage(LanguageType language) {
+  switch (language) {
+  case eLanguageTypeC_plus_plus:
+  case eLanguageTypeC_plus_plus_03:
+  case eLanguageTypeC_plus_plus_11:
+  case eLanguageTypeC_plus_plus_14:
+    return eLanguageTypeC_plus_plus;
+  case eLanguageTypeC:
+  case eLanguageTypeC89:
+  case eLanguageTypeC99:
+  case eLanguageTypeC11:
+    return eLanguageTypeC;
+  case eLanguageTypeObjC:
+  case eLanguageTypeObjC_plus_plus:
+    return eLanguageTypeObjC;
+  case eLanguageTypePascal83:
+  case eLanguageTypeCobol74:
+  case eLanguageTypeCobol85:
+  case eLanguageTypeFortran77:
+  case eLanguageTypeFortran90:
+  case eLanguageTypeFortran95:
+  case eLanguageTypeFortran03:
+  case eLanguageTypeFortran08:
+  case eLanguageTypeAda83:
+  case eLanguageTypeAda95:
+  case eLanguageTypeModula2:
+  case eLanguageTypeJava:
+  case eLanguageTypePLI:
+  case eLanguageTypeUPC:
+  case eLanguageTypeD:
+  case eLanguageTypePython:
+  case eLanguageTypeOpenCL:
+  case eLanguageTypeGo:
+  case eLanguageTypeModula3:
+  case eLanguageTypeHaskell:
+  case eLanguageTypeOCaml:
+  case eLanguageTypeRust:
+  case eLanguageTypeSwift:
+  case eLanguageTypeJulia:
+  case eLanguageTypeDylan:
+  case eLanguageTypeMipsAssembler:
+  case eLanguageTypeExtRenderScript:
+  case eLanguageTypeUnknown:
+  default:
+    return language;
+  }
+}
+
+void Language::GetLanguagesSupportingTypeSystems(
+    std::set<lldb::LanguageType> &languages,
+    std::set<lldb::LanguageType> &languages_for_expressions) {
+  uint32_t idx = 0;
+
+  while (TypeSystemEnumerateSupportedLanguages enumerate = PluginManager::
+             GetTypeSystemEnumerateSupportedLanguagesCallbackAtIndex(idx++)) {
+    (*enumerate)(languages, languages_for_expressions);
+  }
+}
+
+void Language::GetLanguagesSupportingREPLs(
+    std::set<lldb::LanguageType> &languages) {
+  uint32_t idx = 0;
+
+  while (REPLEnumerateSupportedLanguages enumerate =
+             PluginManager::GetREPLEnumerateSupportedLanguagesCallbackAtIndex(
+                 idx++)) {
+    (*enumerate)(languages);
+  }
+}
+
+std::unique_ptr<Language::TypeScavenger> Language::GetTypeScavenger() {
+  return nullptr;
+}
+
+const char *Language::GetLanguageSpecificTypeLookupHelp() { return nullptr; }
+
+size_t Language::TypeScavenger::Find(ExecutionContextScope *exe_scope,
+                                     const char *key, ResultSet &results,
+                                     bool append) {
+  if (!exe_scope || !exe_scope->CalculateTarget().get())
+    return false;
 
-bool
-Language::LanguageIsC (LanguageType language)
-{
-    switch (language)
-    {
-        case eLanguageTypeC:
-        case eLanguageTypeC89:
-        case eLanguageTypeC99:
-        case eLanguageTypeC11:
-            return true;
-        default:
-            return false;
-    }
-}
+  if (!key || !key[0])
+    return false;
 
-bool
-Language::LanguageIsPascal (LanguageType language)
-{
-    switch (language)
-    {
-        case eLanguageTypePascal83:
-            return true;
-        default:
-            return false;
-    }
-}
+  if (!append)
+    results.clear();
 
-LanguageType
-Language::GetPrimaryLanguage (LanguageType language)
-{
-    switch (language)
-    {
-        case eLanguageTypeC_plus_plus:
-        case eLanguageTypeC_plus_plus_03:
-        case eLanguageTypeC_plus_plus_11:
-        case eLanguageTypeC_plus_plus_14:
-            return eLanguageTypeC_plus_plus;
-        case eLanguageTypeC:
-        case eLanguageTypeC89:
-        case eLanguageTypeC99:
-        case eLanguageTypeC11:
-            return eLanguageTypeC;
-        case eLanguageTypeObjC:
-        case eLanguageTypeObjC_plus_plus:
-            return eLanguageTypeObjC;
-        case eLanguageTypePascal83:
-        case eLanguageTypeCobol74:
-        case eLanguageTypeCobol85:
-        case eLanguageTypeFortran77:
-        case eLanguageTypeFortran90:
-        case eLanguageTypeFortran95:
-        case eLanguageTypeFortran03:
-        case eLanguageTypeFortran08:
-        case eLanguageTypeAda83:
-        case eLanguageTypeAda95:
-        case eLanguageTypeModula2:
-        case eLanguageTypeJava:
-        case eLanguageTypePLI:
-        case eLanguageTypeUPC:
-        case eLanguageTypeD:
-        case eLanguageTypePython:
-        case eLanguageTypeOpenCL:
-        case eLanguageTypeGo:
-        case eLanguageTypeModula3:
-        case eLanguageTypeHaskell:
-        case eLanguageTypeOCaml:
-        case eLanguageTypeRust:
-        case eLanguageTypeSwift:
-        case eLanguageTypeJulia:
-        case eLanguageTypeDylan:
-        case eLanguageTypeMipsAssembler:
-        case eLanguageTypeExtRenderScript:
-        case eLanguageTypeUnknown:
-        default:
-            return language;
-    }
-}
+  size_t old_size = results.size();
 
-void
-Language::GetLanguagesSupportingTypeSystems (std::set<lldb::LanguageType> &languages,
-                                             std::set<lldb::LanguageType> &languages_for_expressions)
-{
-    uint32_t idx = 0;
-    
-    while (TypeSystemEnumerateSupportedLanguages enumerate = PluginManager::GetTypeSystemEnumerateSupportedLanguagesCallbackAtIndex(idx++))
-    {
-        (*enumerate)(languages, languages_for_expressions);
-    }
+  if (this->Find_Impl(exe_scope, key, results))
+    return results.size() - old_size;
+  return 0;
 }
 
-void
-Language::GetLanguagesSupportingREPLs (std::set<lldb::LanguageType> &languages)
-{
-    uint32_t idx = 0;
-    
-    while (REPLEnumerateSupportedLanguages enumerate = PluginManager::GetREPLEnumerateSupportedLanguagesCallbackAtIndex(idx++))
-    {
-        (*enumerate)(languages);
-    }
+bool Language::GetFormatterPrefixSuffix(ValueObject &valobj,
+                                        ConstString type_hint,
+                                        std::string &prefix,
+                                        std::string &suffix) {
+  return false;
 }
 
-std::unique_ptr<Language::TypeScavenger>
-Language::GetTypeScavenger ()
-{
-    return nullptr;
-}
-
-const char*
-Language::GetLanguageSpecificTypeLookupHelp ()
-{
-    return nullptr;
-}
-
-size_t
-Language::TypeScavenger::Find (ExecutionContextScope *exe_scope,
-                               const char *key,
-                               ResultSet &results,
-                               bool append)
-{
-    if (!exe_scope || !exe_scope->CalculateTarget().get())
-        return false;
-    
-    if (!key || !key[0])
-        return false;
-
-    if (!append)
-        results.clear();
-    
-    size_t old_size = results.size();
-    
-    if (this->Find_Impl(exe_scope, key, results))
-        return results.size() - old_size;
-    return 0;
-}
-
-bool
-Language::GetFormatterPrefixSuffix (ValueObject& valobj, ConstString type_hint,
-                                    std::string& prefix, std::string& suffix)
-{
-    return false;
+DumpValueObjectOptions::DeclPrintingHelper Language::GetDeclPrintingHelper() {
+  return nullptr;
 }
 
-DumpValueObjectOptions::DeclPrintingHelper
-Language::GetDeclPrintingHelper ()
-{
-    return nullptr;
-}
-
-LazyBool
-Language::IsLogicalTrue (ValueObject& valobj,
-                         Error& error)
-{
-    return eLazyBoolCalculate;
-}
-
-bool
-Language::IsNilReference (ValueObject& valobj)
-{
-    return false;
+LazyBool Language::IsLogicalTrue(ValueObject &valobj, Error &error) {
+  return eLazyBoolCalculate;
 }
 
-bool
-Language::IsUninitializedReference (ValueObject& valobj)
-{
-    return false;
-}
+bool Language::IsNilReference(ValueObject &valobj) { return false; }
 
-bool
-Language::GetFunctionDisplayName (const SymbolContext *sc,
-                                  const ExecutionContext *exe_ctx,
-                                  FunctionNameRepresentation representation,
-                                  Stream& s)
-{
-    return false;
+bool Language::IsUninitializedReference(ValueObject &valobj) { return false; }
+
+bool Language::GetFunctionDisplayName(const SymbolContext *sc,
+                                      const ExecutionContext *exe_ctx,
+                                      FunctionNameRepresentation representation,
+                                      Stream &s) {
+  return false;
 }
 
-void
-Language::GetExceptionResolverDescription(bool catch_on, bool throw_on, Stream &s)
-{
-    GetDefaultExceptionResolverDescription(catch_on, throw_on, s);
+void Language::GetExceptionResolverDescription(bool catch_on, bool throw_on,
+                                               Stream &s) {
+  GetDefaultExceptionResolverDescription(catch_on, throw_on, s);
 }
 
-void
-Language::GetDefaultExceptionResolverDescription(bool catch_on, bool throw_on, Stream &s)
-{
-     s.Printf ("Exception breakpoint (catch: %s throw: %s)",
-               catch_on ? "on" : "off",
-               throw_on ? "on" : "off");
+void Language::GetDefaultExceptionResolverDescription(bool catch_on,
+                                                      bool throw_on,
+                                                      Stream &s) {
+  s.Printf("Exception breakpoint (catch: %s throw: %s)",
+           catch_on ? "on" : "off", throw_on ? "on" : "off");
 }
 //----------------------------------------------------------------------
 // Constructor
 //----------------------------------------------------------------------
-Language::Language()
-{
-}
+Language::Language() {}
 
 //----------------------------------------------------------------------
 // Destructor
 //----------------------------------------------------------------------
-Language::~Language()
-{
-}
+Language::~Language() {}

Modified: lldb/trunk/source/Target/LanguageRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/LanguageRuntime.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/LanguageRuntime.cpp (original)
+++ lldb/trunk/source/Target/LanguageRuntime.cpp Tue Sep  6 15:57:50 2016
@@ -14,340 +14,287 @@
 #include "lldb/Target/LanguageRuntime.h"
 #include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
 #include "Plugins/Language/ObjC/ObjCLanguage.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
-#include "lldb/Target/Target.h"
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/SearchFilter.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Target/ObjCLanguageRuntime.h"
+#include "lldb/Target/Target.h"
 
 using namespace lldb;
 using namespace lldb_private;
 
-class ExceptionSearchFilter : public SearchFilter
-{
+class ExceptionSearchFilter : public SearchFilter {
 public:
-    ExceptionSearchFilter (const lldb::TargetSP &target_sp,
-                           lldb::LanguageType language,
-                           bool update_module_list = true) :
-        SearchFilter(target_sp),
-        m_language(language),
-        m_language_runtime(nullptr),
-        m_filter_sp()
-    {
-        if (update_module_list)
-            UpdateModuleListIfNeeded ();
-    }
-
-    ~ExceptionSearchFilter() override = default;
-
-    bool
-    ModulePasses (const lldb::ModuleSP &module_sp) override
-    {
-        UpdateModuleListIfNeeded ();
-        if (m_filter_sp)
-            return m_filter_sp->ModulePasses (module_sp);
-        return false;
-    }
-    
-    bool
-    ModulePasses (const FileSpec &spec) override
-    {
-        UpdateModuleListIfNeeded ();
-        if (m_filter_sp)
-            return m_filter_sp->ModulePasses (spec);
-        return false;
-    }
-    
-    void
-    Search (Searcher &searcher) override
-    {
-        UpdateModuleListIfNeeded ();
-        if (m_filter_sp)
-            m_filter_sp->Search (searcher);
-    }
+  ExceptionSearchFilter(const lldb::TargetSP &target_sp,
+                        lldb::LanguageType language,
+                        bool update_module_list = true)
+      : SearchFilter(target_sp), m_language(language),
+        m_language_runtime(nullptr), m_filter_sp() {
+    if (update_module_list)
+      UpdateModuleListIfNeeded();
+  }
+
+  ~ExceptionSearchFilter() override = default;
+
+  bool ModulePasses(const lldb::ModuleSP &module_sp) override {
+    UpdateModuleListIfNeeded();
+    if (m_filter_sp)
+      return m_filter_sp->ModulePasses(module_sp);
+    return false;
+  }
+
+  bool ModulePasses(const FileSpec &spec) override {
+    UpdateModuleListIfNeeded();
+    if (m_filter_sp)
+      return m_filter_sp->ModulePasses(spec);
+    return false;
+  }
+
+  void Search(Searcher &searcher) override {
+    UpdateModuleListIfNeeded();
+    if (m_filter_sp)
+      m_filter_sp->Search(searcher);
+  }
+
+  void GetDescription(Stream *s) override {
+    UpdateModuleListIfNeeded();
+    if (m_filter_sp)
+      m_filter_sp->GetDescription(s);
+  }
 
-    void
-    GetDescription (Stream *s) override
-    {
-        UpdateModuleListIfNeeded ();
-        if (m_filter_sp)
-            m_filter_sp->GetDescription (s);
-    }
-    
 protected:
-    LanguageType m_language;
-    LanguageRuntime *m_language_runtime;
-    SearchFilterSP m_filter_sp;
-
-    SearchFilterSP
-    DoCopyForBreakpoint(Breakpoint &breakpoint) override
-    {
-        return SearchFilterSP(new ExceptionSearchFilter(TargetSP(), m_language, false));
-    }
-
-    void
-    UpdateModuleListIfNeeded ()
-    {
-        ProcessSP process_sp (m_target_sp->GetProcessSP());
-        if (process_sp)
-        {
-            bool refreash_filter = !m_filter_sp;
-            if (m_language_runtime == nullptr)
-            {
-                m_language_runtime = process_sp->GetLanguageRuntime(m_language);
-                refreash_filter = true;
-            }
-            else
-            {
-                LanguageRuntime *language_runtime = process_sp->GetLanguageRuntime(m_language);
-                if (m_language_runtime != language_runtime)
-                {
-                    m_language_runtime = language_runtime;
-                    refreash_filter = true;
-                }
-            }
-            
-            if (refreash_filter && m_language_runtime)
-            {
-                m_filter_sp = m_language_runtime->CreateExceptionSearchFilter ();
-            }
-        }
-        else
-        {
-            m_filter_sp.reset();
-            m_language_runtime = nullptr;
+  LanguageType m_language;
+  LanguageRuntime *m_language_runtime;
+  SearchFilterSP m_filter_sp;
+
+  SearchFilterSP DoCopyForBreakpoint(Breakpoint &breakpoint) override {
+    return SearchFilterSP(
+        new ExceptionSearchFilter(TargetSP(), m_language, false));
+  }
+
+  void UpdateModuleListIfNeeded() {
+    ProcessSP process_sp(m_target_sp->GetProcessSP());
+    if (process_sp) {
+      bool refreash_filter = !m_filter_sp;
+      if (m_language_runtime == nullptr) {
+        m_language_runtime = process_sp->GetLanguageRuntime(m_language);
+        refreash_filter = true;
+      } else {
+        LanguageRuntime *language_runtime =
+            process_sp->GetLanguageRuntime(m_language);
+        if (m_language_runtime != language_runtime) {
+          m_language_runtime = language_runtime;
+          refreash_filter = true;
         }
+      }
+
+      if (refreash_filter && m_language_runtime) {
+        m_filter_sp = m_language_runtime->CreateExceptionSearchFilter();
+      }
+    } else {
+      m_filter_sp.reset();
+      m_language_runtime = nullptr;
     }
+  }
 };
 
 // The Target is the one that knows how to create breakpoints, so this function
-// is meant to be used either by the target or internally in Set/ClearExceptionBreakpoints.
-class ExceptionBreakpointResolver : public BreakpointResolver
-{
+// is meant to be used either by the target or internally in
+// Set/ClearExceptionBreakpoints.
+class ExceptionBreakpointResolver : public BreakpointResolver {
 public:
-    ExceptionBreakpointResolver (lldb::LanguageType language,
-                                 bool catch_bp,
-                                 bool throw_bp) :
-        BreakpointResolver(nullptr, BreakpointResolver::ExceptionResolver),
-        m_language(language),
-        m_language_runtime(nullptr),
-        m_catch_bp(catch_bp),
-        m_throw_bp(throw_bp)
-    {
-    }
-
-    ~ExceptionBreakpointResolver() override = default;
-
-    Searcher::CallbackReturn
-    SearchCallback (SearchFilter &filter,
-                    SymbolContext &context,
-                    Address *addr,
-                    bool containing) override
-    {
-        
-        if (SetActualResolver())
-            return m_actual_resolver_sp->SearchCallback (filter, context, addr, containing);
-        else
-            return eCallbackReturnStop;
-    }
-    
-    Searcher::Depth
-    GetDepth () override
-    {
-        if (SetActualResolver())
-            return m_actual_resolver_sp->GetDepth();
-        else
-            return eDepthTarget;
-    }
-    
-    void
-    GetDescription (Stream *s) override
-    {
-       Language *language_plugin = Language::FindPlugin(m_language);
-       if (language_plugin)
-           language_plugin->GetExceptionResolverDescription(m_catch_bp, m_throw_bp, *s);
-       else
-           Language::GetDefaultExceptionResolverDescription(m_catch_bp, m_throw_bp, *s);
-           
-        SetActualResolver();
-        if (m_actual_resolver_sp)
-        {
-            s->Printf (" using: ");
-            m_actual_resolver_sp->GetDescription (s);
-        }
-        else
-            s->Printf (" the correct runtime exception handler will be determined when you run");
-    }
-
-    void
-    Dump (Stream *s) const override
-    {
-    }
-    
-    /// Methods for support type inquiry through isa, cast, and dyn_cast:
-    static inline bool classof(const BreakpointResolverName *) { return true; }
-    static inline bool classof(const BreakpointResolver *V) {
-        return V->getResolverID() == BreakpointResolver::ExceptionResolver;
-    }
+  ExceptionBreakpointResolver(lldb::LanguageType language, bool catch_bp,
+                              bool throw_bp)
+      : BreakpointResolver(nullptr, BreakpointResolver::ExceptionResolver),
+        m_language(language), m_language_runtime(nullptr), m_catch_bp(catch_bp),
+        m_throw_bp(throw_bp) {}
+
+  ~ExceptionBreakpointResolver() override = default;
+
+  Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
+                                          SymbolContext &context, Address *addr,
+                                          bool containing) override {
+
+    if (SetActualResolver())
+      return m_actual_resolver_sp->SearchCallback(filter, context, addr,
+                                                  containing);
+    else
+      return eCallbackReturnStop;
+  }
+
+  Searcher::Depth GetDepth() override {
+    if (SetActualResolver())
+      return m_actual_resolver_sp->GetDepth();
+    else
+      return eDepthTarget;
+  }
+
+  void GetDescription(Stream *s) override {
+    Language *language_plugin = Language::FindPlugin(m_language);
+    if (language_plugin)
+      language_plugin->GetExceptionResolverDescription(m_catch_bp, m_throw_bp,
+                                                       *s);
+    else
+      Language::GetDefaultExceptionResolverDescription(m_catch_bp, m_throw_bp,
+                                                       *s);
+
+    SetActualResolver();
+    if (m_actual_resolver_sp) {
+      s->Printf(" using: ");
+      m_actual_resolver_sp->GetDescription(s);
+    } else
+      s->Printf(" the correct runtime exception handler will be determined "
+                "when you run");
+  }
+
+  void Dump(Stream *s) const override {}
+
+  /// Methods for support type inquiry through isa, cast, and dyn_cast:
+  static inline bool classof(const BreakpointResolverName *) { return true; }
+  static inline bool classof(const BreakpointResolver *V) {
+    return V->getResolverID() == BreakpointResolver::ExceptionResolver;
+  }
 
 protected:
-    BreakpointResolverSP
-    CopyForBreakpoint (Breakpoint &breakpoint) override
-    {
-        return BreakpointResolverSP(new ExceptionBreakpointResolver(m_language, m_catch_bp, m_throw_bp));
-    }
-
-    bool
-    SetActualResolver()
-    {
-        ProcessSP process_sp;
-        if (m_breakpoint)
-        {
-            process_sp = m_breakpoint->GetTarget().GetProcessSP();
-            if (process_sp)
-            {
-                bool refreash_resolver = !m_actual_resolver_sp;
-                if (m_language_runtime == nullptr)
-                {
-                    m_language_runtime = process_sp->GetLanguageRuntime(m_language);
-                    refreash_resolver = true;
-                }
-                else
-                {
-                    LanguageRuntime *language_runtime = process_sp->GetLanguageRuntime(m_language);
-                    if (m_language_runtime != language_runtime)
-                    {
-                        m_language_runtime = language_runtime;
-                        refreash_resolver = true;
-                    }
-                }
-                
-                if (refreash_resolver && m_language_runtime)
-                {
-                    m_actual_resolver_sp = m_language_runtime->CreateExceptionResolver (m_breakpoint, m_catch_bp, m_throw_bp);
-                }
-            }
-            else
-            {
-                m_actual_resolver_sp.reset();
-                m_language_runtime = nullptr;
-            }
+  BreakpointResolverSP CopyForBreakpoint(Breakpoint &breakpoint) override {
+    return BreakpointResolverSP(
+        new ExceptionBreakpointResolver(m_language, m_catch_bp, m_throw_bp));
+  }
+
+  bool SetActualResolver() {
+    ProcessSP process_sp;
+    if (m_breakpoint) {
+      process_sp = m_breakpoint->GetTarget().GetProcessSP();
+      if (process_sp) {
+        bool refreash_resolver = !m_actual_resolver_sp;
+        if (m_language_runtime == nullptr) {
+          m_language_runtime = process_sp->GetLanguageRuntime(m_language);
+          refreash_resolver = true;
+        } else {
+          LanguageRuntime *language_runtime =
+              process_sp->GetLanguageRuntime(m_language);
+          if (m_language_runtime != language_runtime) {
+            m_language_runtime = language_runtime;
+            refreash_resolver = true;
+          }
         }
-        else
-        {
-            m_actual_resolver_sp.reset();
-            m_language_runtime = nullptr;
-        }
-        return (bool)m_actual_resolver_sp;
-    }
 
-    lldb::BreakpointResolverSP m_actual_resolver_sp;
-    lldb::LanguageType m_language;
-    LanguageRuntime *m_language_runtime;
-    bool m_catch_bp;
-    bool m_throw_bp;
+        if (refreash_resolver && m_language_runtime) {
+          m_actual_resolver_sp = m_language_runtime->CreateExceptionResolver(
+              m_breakpoint, m_catch_bp, m_throw_bp);
+        }
+      } else {
+        m_actual_resolver_sp.reset();
+        m_language_runtime = nullptr;
+      }
+    } else {
+      m_actual_resolver_sp.reset();
+      m_language_runtime = nullptr;
+    }
+    return (bool)m_actual_resolver_sp;
+  }
+
+  lldb::BreakpointResolverSP m_actual_resolver_sp;
+  lldb::LanguageType m_language;
+  LanguageRuntime *m_language_runtime;
+  bool m_catch_bp;
+  bool m_throw_bp;
 };
 
-LanguageRuntime*
-LanguageRuntime::FindPlugin (Process *process, lldb::LanguageType language)
-{
-    std::unique_ptr<LanguageRuntime> language_runtime_ap;
-    LanguageRuntimeCreateInstance create_callback;
-
-    for (uint32_t idx = 0;
-         (create_callback = PluginManager::GetLanguageRuntimeCreateCallbackAtIndex(idx)) != nullptr;
-         ++idx)
-    {
-        language_runtime_ap.reset (create_callback(process, language));
-
-        if (language_runtime_ap)
-            return language_runtime_ap.release();
-    }
+LanguageRuntime *LanguageRuntime::FindPlugin(Process *process,
+                                             lldb::LanguageType language) {
+  std::unique_ptr<LanguageRuntime> language_runtime_ap;
+  LanguageRuntimeCreateInstance create_callback;
+
+  for (uint32_t idx = 0;
+       (create_callback =
+            PluginManager::GetLanguageRuntimeCreateCallbackAtIndex(idx)) !=
+       nullptr;
+       ++idx) {
+    language_runtime_ap.reset(create_callback(process, language));
+
+    if (language_runtime_ap)
+      return language_runtime_ap.release();
+  }
 
-    return nullptr;
+  return nullptr;
 }
 
-LanguageRuntime::LanguageRuntime(Process *process) :
-    m_process (process)
-{
-}
+LanguageRuntime::LanguageRuntime(Process *process) : m_process(process) {}
 
 LanguageRuntime::~LanguageRuntime() = default;
 
 Breakpoint::BreakpointPreconditionSP
-LanguageRuntime::CreateExceptionPrecondition (lldb::LanguageType language,
-                                              bool catch_bp,
-                                              bool throw_bp)
-{
-    switch (language)
-    {
-    case eLanguageTypeObjC:
-        if (throw_bp)
-            return Breakpoint::BreakpointPreconditionSP(new ObjCLanguageRuntime::ObjCExceptionPrecondition ());
-        break;
-    default:
-        break;
-    }
-    return Breakpoint::BreakpointPreconditionSP();
+LanguageRuntime::CreateExceptionPrecondition(lldb::LanguageType language,
+                                             bool catch_bp, bool throw_bp) {
+  switch (language) {
+  case eLanguageTypeObjC:
+    if (throw_bp)
+      return Breakpoint::BreakpointPreconditionSP(
+          new ObjCLanguageRuntime::ObjCExceptionPrecondition());
+    break;
+  default:
+    break;
+  }
+  return Breakpoint::BreakpointPreconditionSP();
 }
 
-BreakpointSP
-LanguageRuntime::CreateExceptionBreakpoint (Target &target,
-                                            lldb::LanguageType language,
-                                            bool catch_bp,
-                                            bool throw_bp,
-                                            bool is_internal)
-{
-    BreakpointResolverSP resolver_sp(new ExceptionBreakpointResolver(language, catch_bp, throw_bp));
-    SearchFilterSP filter_sp(new ExceptionSearchFilter(target.shared_from_this(), language));
-    bool hardware = false;
-    bool resolve_indirect_functions = false;
-    BreakpointSP exc_breakpt_sp (target.CreateBreakpoint (filter_sp, resolver_sp, is_internal, hardware, resolve_indirect_functions));
-    if (exc_breakpt_sp)
-    {
-        Breakpoint::BreakpointPreconditionSP precondition_sp = CreateExceptionPrecondition(language, catch_bp, throw_bp);
-        if (precondition_sp)
-            exc_breakpt_sp->SetPrecondition(precondition_sp);
+BreakpointSP LanguageRuntime::CreateExceptionBreakpoint(
+    Target &target, lldb::LanguageType language, bool catch_bp, bool throw_bp,
+    bool is_internal) {
+  BreakpointResolverSP resolver_sp(
+      new ExceptionBreakpointResolver(language, catch_bp, throw_bp));
+  SearchFilterSP filter_sp(
+      new ExceptionSearchFilter(target.shared_from_this(), language));
+  bool hardware = false;
+  bool resolve_indirect_functions = false;
+  BreakpointSP exc_breakpt_sp(
+      target.CreateBreakpoint(filter_sp, resolver_sp, is_internal, hardware,
+                              resolve_indirect_functions));
+  if (exc_breakpt_sp) {
+    Breakpoint::BreakpointPreconditionSP precondition_sp =
+        CreateExceptionPrecondition(language, catch_bp, throw_bp);
+    if (precondition_sp)
+      exc_breakpt_sp->SetPrecondition(precondition_sp);
+
+    if (is_internal)
+      exc_breakpt_sp->SetBreakpointKind("exception");
+  }
 
-        if (is_internal)
-            exc_breakpt_sp->SetBreakpointKind("exception");
-    }
-    
-    return exc_breakpt_sp;
+  return exc_breakpt_sp;
 }
 
-void
-LanguageRuntime::InitializeCommands (CommandObject* parent)
-{
-    if (!parent)
-        return;
-
-    if (!parent->IsMultiwordObject())
-        return;
-
-    LanguageRuntimeCreateInstance create_callback;
-
-    for (uint32_t idx = 0;
-         (create_callback = PluginManager::GetLanguageRuntimeCreateCallbackAtIndex(idx)) != nullptr;
-         ++idx)
-    {
-        if (LanguageRuntimeGetCommandObject command_callback = 
-                PluginManager::GetLanguageRuntimeGetCommandObjectAtIndex(idx))
-        {
-            CommandObjectSP command = command_callback(parent->GetCommandInterpreter());
-            if (command)
-            {
-                // the CommandObject vended by a Language plugin cannot be created once and cached because
-                // we may create multiple debuggers and need one instance of the command each - the implementing function
-                // is meant to create a new instance of the command each time it is invoked
-                parent->LoadSubCommand(command->GetCommandName(), command);
-            }
-        }
+void LanguageRuntime::InitializeCommands(CommandObject *parent) {
+  if (!parent)
+    return;
+
+  if (!parent->IsMultiwordObject())
+    return;
+
+  LanguageRuntimeCreateInstance create_callback;
+
+  for (uint32_t idx = 0;
+       (create_callback =
+            PluginManager::GetLanguageRuntimeCreateCallbackAtIndex(idx)) !=
+       nullptr;
+       ++idx) {
+    if (LanguageRuntimeGetCommandObject command_callback =
+            PluginManager::GetLanguageRuntimeGetCommandObjectAtIndex(idx)) {
+      CommandObjectSP command =
+          command_callback(parent->GetCommandInterpreter());
+      if (command) {
+        // the CommandObject vended by a Language plugin cannot be created once
+        // and cached because
+        // we may create multiple debuggers and need one instance of the command
+        // each - the implementing function
+        // is meant to create a new instance of the command each time it is
+        // invoked
+        parent->LoadSubCommand(command->GetCommandName(), command);
+      }
     }
+  }
 }
 
-lldb::SearchFilterSP
-LanguageRuntime::CreateExceptionSearchFilter ()
-{
-    return m_process->GetTarget().GetSearchFilterForModule(nullptr);
+lldb::SearchFilterSP LanguageRuntime::CreateExceptionSearchFilter() {
+  return m_process->GetTarget().GetSearchFilterForModule(nullptr);
 }

Modified: lldb/trunk/source/Target/Memory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Memory.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/Memory.cpp (original)
+++ lldb/trunk/source/Target/Memory.cpp Tue Sep  6 15:57:50 2016
@@ -26,518 +26,463 @@ using namespace lldb_private;
 // MemoryCache constructor
 //----------------------------------------------------------------------
 MemoryCache::MemoryCache(Process &process)
-    : m_mutex(),
-      m_L1_cache(),
-      m_L2_cache(),
-      m_invalid_ranges(),
+    : m_mutex(), m_L1_cache(), m_L2_cache(), m_invalid_ranges(),
       m_process(process),
-      m_L2_cache_line_byte_size(process.GetMemoryCacheLineSize())
-{
-}
+      m_L2_cache_line_byte_size(process.GetMemoryCacheLineSize()) {}
 
 //----------------------------------------------------------------------
 // Destructor
 //----------------------------------------------------------------------
-MemoryCache::~MemoryCache()
-{
-}
+MemoryCache::~MemoryCache() {}
 
-void
-MemoryCache::Clear(bool clear_invalid_ranges)
-{
+void MemoryCache::Clear(bool clear_invalid_ranges) {
+  std::lock_guard<std::recursive_mutex> guard(m_mutex);
+  m_L1_cache.clear();
+  m_L2_cache.clear();
+  if (clear_invalid_ranges)
+    m_invalid_ranges.Clear();
+  m_L2_cache_line_byte_size = m_process.GetMemoryCacheLineSize();
+}
+
+void MemoryCache::AddL1CacheData(lldb::addr_t addr, const void *src,
+                                 size_t src_len) {
+  AddL1CacheData(
+      addr, DataBufferSP(new DataBufferHeap(DataBufferHeap(src, src_len))));
+}
+
+void MemoryCache::AddL1CacheData(lldb::addr_t addr,
+                                 const DataBufferSP &data_buffer_sp) {
+  std::lock_guard<std::recursive_mutex> guard(m_mutex);
+  m_L1_cache[addr] = data_buffer_sp;
+}
+
+void MemoryCache::Flush(addr_t addr, size_t size) {
+  if (size == 0)
+    return;
+
+  std::lock_guard<std::recursive_mutex> guard(m_mutex);
+
+  // Erase any blocks from the L1 cache that intersect with the flush range
+  if (!m_L1_cache.empty()) {
+    AddrRange flush_range(addr, size);
+    BlockMap::iterator pos = m_L1_cache.upper_bound(addr);
+    if (pos != m_L1_cache.begin()) {
+      --pos;
+    }
+    while (pos != m_L1_cache.end()) {
+      AddrRange chunk_range(pos->first, pos->second->GetByteSize());
+      if (!chunk_range.DoesIntersect(flush_range))
+        break;
+      pos = m_L1_cache.erase(pos);
+    }
+  }
+
+  if (!m_L2_cache.empty()) {
+    const uint32_t cache_line_byte_size = m_L2_cache_line_byte_size;
+    const addr_t end_addr = (addr + size - 1);
+    const addr_t first_cache_line_addr = addr - (addr % cache_line_byte_size);
+    const addr_t last_cache_line_addr =
+        end_addr - (end_addr % cache_line_byte_size);
+    // Watch for overflow where size will cause us to go off the end of the
+    // 64 bit address space
+    uint32_t num_cache_lines;
+    if (last_cache_line_addr >= first_cache_line_addr)
+      num_cache_lines = ((last_cache_line_addr - first_cache_line_addr) /
+                         cache_line_byte_size) +
+                        1;
+    else
+      num_cache_lines =
+          (UINT64_MAX - first_cache_line_addr + 1) / cache_line_byte_size;
+
+    uint32_t cache_idx = 0;
+    for (addr_t curr_addr = first_cache_line_addr; cache_idx < num_cache_lines;
+         curr_addr += cache_line_byte_size, ++cache_idx) {
+      BlockMap::iterator pos = m_L2_cache.find(curr_addr);
+      if (pos != m_L2_cache.end())
+        m_L2_cache.erase(pos);
+    }
+  }
+}
+
+void MemoryCache::AddInvalidRange(lldb::addr_t base_addr,
+                                  lldb::addr_t byte_size) {
+  if (byte_size > 0) {
     std::lock_guard<std::recursive_mutex> guard(m_mutex);
-    m_L1_cache.clear();
-    m_L2_cache.clear();
-    if (clear_invalid_ranges)
-        m_invalid_ranges.Clear();
-    m_L2_cache_line_byte_size = m_process.GetMemoryCacheLineSize();
+    InvalidRanges::Entry range(base_addr, byte_size);
+    m_invalid_ranges.Append(range);
+    m_invalid_ranges.Sort();
+  }
 }
 
-void
-MemoryCache::AddL1CacheData(lldb::addr_t addr, const void *src, size_t src_len)
-{
-    AddL1CacheData(addr,DataBufferSP (new DataBufferHeap(DataBufferHeap(src, src_len))));
-}
-
-void
-MemoryCache::AddL1CacheData(lldb::addr_t addr, const DataBufferSP &data_buffer_sp)
-{
+bool MemoryCache::RemoveInvalidRange(lldb::addr_t base_addr,
+                                     lldb::addr_t byte_size) {
+  if (byte_size > 0) {
     std::lock_guard<std::recursive_mutex> guard(m_mutex);
-    m_L1_cache[addr] = data_buffer_sp;
-}
-
-void
-MemoryCache::Flush (addr_t addr, size_t size)
-{
-    if (size == 0)
-        return;
-
-    std::lock_guard<std::recursive_mutex> guard(m_mutex);
-
-    // Erase any blocks from the L1 cache that intersect with the flush range
-    if (!m_L1_cache.empty())
-    {
-        AddrRange flush_range(addr, size);
-        BlockMap::iterator pos = m_L1_cache.upper_bound(addr);
-        if (pos != m_L1_cache.begin())
-        {
-            --pos;
-        }
-        while (pos != m_L1_cache.end())
-        {
-            AddrRange chunk_range(pos->first, pos->second->GetByteSize());
-            if (!chunk_range.DoesIntersect(flush_range))
-                break;
-            pos = m_L1_cache.erase(pos);
-        }
-    }
-
-    if (!m_L2_cache.empty())
-    {
-        const uint32_t cache_line_byte_size = m_L2_cache_line_byte_size;
-        const addr_t end_addr = (addr + size - 1);
-        const addr_t first_cache_line_addr = addr - (addr % cache_line_byte_size);
-        const addr_t last_cache_line_addr = end_addr - (end_addr % cache_line_byte_size);
-        // Watch for overflow where size will cause us to go off the end of the
-        // 64 bit address space
-        uint32_t num_cache_lines;
-        if (last_cache_line_addr >= first_cache_line_addr)
-            num_cache_lines = ((last_cache_line_addr - first_cache_line_addr)/cache_line_byte_size) + 1;
-        else
-            num_cache_lines = (UINT64_MAX - first_cache_line_addr + 1)/cache_line_byte_size;
-
-        uint32_t cache_idx = 0;
-        for (addr_t curr_addr = first_cache_line_addr;
-             cache_idx < num_cache_lines;
-             curr_addr += cache_line_byte_size, ++cache_idx)
-        {
-            BlockMap::iterator pos = m_L2_cache.find (curr_addr);
-            if (pos != m_L2_cache.end())
-                m_L2_cache.erase(pos);
+    const uint32_t idx = m_invalid_ranges.FindEntryIndexThatContains(base_addr);
+    if (idx != UINT32_MAX) {
+      const InvalidRanges::Entry *entry = m_invalid_ranges.GetEntryAtIndex(idx);
+      if (entry->GetRangeBase() == base_addr &&
+          entry->GetByteSize() == byte_size)
+        return m_invalid_ranges.RemoveEntrtAtIndex(idx);
+    }
+  }
+  return false;
+}
+
+size_t MemoryCache::Read(addr_t addr, void *dst, size_t dst_len, Error &error) {
+  size_t bytes_left = dst_len;
+
+  // Check the L1 cache for a range that contain the entire memory read.
+  // If we find a range in the L1 cache that does, we use it. Else we fall
+  // back to reading memory in m_L2_cache_line_byte_size byte sized chunks.
+  // The L1 cache contains chunks of memory that are not required to be
+  // m_L2_cache_line_byte_size bytes in size, so we don't try anything
+  // tricky when reading from them (no partial reads from the L1 cache).
+
+  std::lock_guard<std::recursive_mutex> guard(m_mutex);
+  if (!m_L1_cache.empty()) {
+    AddrRange read_range(addr, dst_len);
+    BlockMap::iterator pos = m_L1_cache.upper_bound(addr);
+    if (pos != m_L1_cache.begin()) {
+      --pos;
+    }
+    AddrRange chunk_range(pos->first, pos->second->GetByteSize());
+    if (chunk_range.Contains(read_range)) {
+      memcpy(dst, pos->second->GetBytes() + addr - chunk_range.GetRangeBase(),
+             dst_len);
+      return dst_len;
+    }
+  }
+
+  // If this memory read request is larger than the cache line size, then
+  // we (1) try to read as much of it at once as possible, and (2) don't
+  // add the data to the memory cache.  We don't want to split a big read
+  // up into more separate reads than necessary, and with a large memory read
+  // request, it is unlikely that the caller function will ask for the next
+  // 4 bytes after the large memory read - so there's little benefit to saving
+  // it in the cache.
+  if (dst && dst_len > m_L2_cache_line_byte_size) {
+    size_t bytes_read =
+        m_process.ReadMemoryFromInferior(addr, dst, dst_len, error);
+    // Add this non block sized range to the L1 cache if we actually read
+    // anything
+    if (bytes_read > 0)
+      AddL1CacheData(addr, dst, bytes_read);
+    return bytes_read;
+  }
+
+  if (dst && bytes_left > 0) {
+    const uint32_t cache_line_byte_size = m_L2_cache_line_byte_size;
+    uint8_t *dst_buf = (uint8_t *)dst;
+    addr_t curr_addr = addr - (addr % cache_line_byte_size);
+    addr_t cache_offset = addr - curr_addr;
+
+    while (bytes_left > 0) {
+      if (m_invalid_ranges.FindEntryThatContains(curr_addr)) {
+        error.SetErrorStringWithFormat("memory read failed for 0x%" PRIx64,
+                                       curr_addr);
+        return dst_len - bytes_left;
+      }
+
+      BlockMap::const_iterator pos = m_L2_cache.find(curr_addr);
+      BlockMap::const_iterator end = m_L2_cache.end();
+
+      if (pos != end) {
+        size_t curr_read_size = cache_line_byte_size - cache_offset;
+        if (curr_read_size > bytes_left)
+          curr_read_size = bytes_left;
+
+        memcpy(dst_buf + dst_len - bytes_left,
+               pos->second->GetBytes() + cache_offset, curr_read_size);
+
+        bytes_left -= curr_read_size;
+        curr_addr += curr_read_size + cache_offset;
+        cache_offset = 0;
+
+        if (bytes_left > 0) {
+          // Get sequential cache page hits
+          for (++pos; (pos != end) && (bytes_left > 0); ++pos) {
+            assert((curr_addr % cache_line_byte_size) == 0);
+
+            if (pos->first != curr_addr)
+              break;
+
+            curr_read_size = pos->second->GetByteSize();
+            if (curr_read_size > bytes_left)
+              curr_read_size = bytes_left;
+
+            memcpy(dst_buf + dst_len - bytes_left, pos->second->GetBytes(),
+                   curr_read_size);
+
+            bytes_left -= curr_read_size;
+            curr_addr += curr_read_size;
+
+            // We have a cache page that succeeded to read some bytes
+            // but not an entire page. If this happens, we must cap
+            // off how much data we are able to read...
+            if (pos->second->GetByteSize() != cache_line_byte_size)
+              return dst_len - bytes_left;
+          }
         }
-    }
-}
+      }
 
-void
-MemoryCache::AddInvalidRange (lldb::addr_t base_addr, lldb::addr_t byte_size)
-{
-    if (byte_size > 0)
-    {
-        std::lock_guard<std::recursive_mutex> guard(m_mutex);
-        InvalidRanges::Entry range (base_addr, byte_size);
-        m_invalid_ranges.Append(range);
-        m_invalid_ranges.Sort();
-    }
-}
+      // We need to read from the process
 
-bool
-MemoryCache::RemoveInvalidRange (lldb::addr_t base_addr, lldb::addr_t byte_size)
-{
-    if (byte_size > 0)
-    {
-        std::lock_guard<std::recursive_mutex> guard(m_mutex);
-        const uint32_t idx = m_invalid_ranges.FindEntryIndexThatContains(base_addr);
-        if (idx != UINT32_MAX)
-        {
-            const InvalidRanges::Entry *entry = m_invalid_ranges.GetEntryAtIndex (idx);
-            if (entry->GetRangeBase() == base_addr && entry->GetByteSize() == byte_size)
-                return m_invalid_ranges.RemoveEntrtAtIndex (idx);
-        }
-    }
-    return false;
-}
-
-
-
-size_t
-MemoryCache::Read (addr_t addr,  
-                   void *dst, 
-                   size_t dst_len,
-                   Error &error)
-{
-    size_t bytes_left = dst_len;
-
-    // Check the L1 cache for a range that contain the entire memory read.
-    // If we find a range in the L1 cache that does, we use it. Else we fall
-    // back to reading memory in m_L2_cache_line_byte_size byte sized chunks.
-    // The L1 cache contains chunks of memory that are not required to be
-    // m_L2_cache_line_byte_size bytes in size, so we don't try anything
-    // tricky when reading from them (no partial reads from the L1 cache).
-
-    std::lock_guard<std::recursive_mutex> guard(m_mutex);
-    if (!m_L1_cache.empty())
-    {
-        AddrRange read_range(addr, dst_len);
-        BlockMap::iterator pos = m_L1_cache.upper_bound(addr);
-        if (pos != m_L1_cache.begin ())
-        {
-            --pos;
-        }
-        AddrRange chunk_range(pos->first, pos->second->GetByteSize());
-        if (chunk_range.Contains(read_range))
-        {
-            memcpy(dst, pos->second->GetBytes() + addr - chunk_range.GetRangeBase(), dst_len);
-            return dst_len;
-        }
-    }
-
-
-    // If this memory read request is larger than the cache line size, then 
-    // we (1) try to read as much of it at once as possible, and (2) don't
-    // add the data to the memory cache.  We don't want to split a big read
-    // up into more separate reads than necessary, and with a large memory read
-    // request, it is unlikely that the caller function will ask for the next
-    // 4 bytes after the large memory read - so there's little benefit to saving
-    // it in the cache.
-    if (dst && dst_len > m_L2_cache_line_byte_size)
-    {
-        size_t bytes_read = m_process.ReadMemoryFromInferior (addr, dst, dst_len, error);
-        // Add this non block sized range to the L1 cache if we actually read anything
-        if (bytes_read > 0)
-            AddL1CacheData(addr, dst, bytes_read);
-        return bytes_read;
-    }
-
-    if (dst && bytes_left > 0)
-    {
-        const uint32_t cache_line_byte_size = m_L2_cache_line_byte_size;
-        uint8_t *dst_buf = (uint8_t *)dst;
-        addr_t curr_addr = addr - (addr % cache_line_byte_size);
-        addr_t cache_offset = addr - curr_addr;
-
-        while (bytes_left > 0)
-        {
-            if (m_invalid_ranges.FindEntryThatContains(curr_addr))
-            {
-                error.SetErrorStringWithFormat("memory read failed for 0x%" PRIx64, curr_addr);
-                return dst_len - bytes_left;
-            }
-
-            BlockMap::const_iterator pos = m_L2_cache.find (curr_addr);
-            BlockMap::const_iterator end = m_L2_cache.end ();
-            
-            if (pos != end)
-            {
-                size_t curr_read_size = cache_line_byte_size - cache_offset;
-                if (curr_read_size > bytes_left)
-                    curr_read_size = bytes_left;
-                
-                memcpy (dst_buf + dst_len - bytes_left, pos->second->GetBytes() + cache_offset, curr_read_size);
-                
-                bytes_left -= curr_read_size;
-                curr_addr += curr_read_size + cache_offset;
-                cache_offset = 0;
-                
-                if (bytes_left > 0)
-                {
-                    // Get sequential cache page hits
-                    for (++pos; (pos != end) && (bytes_left > 0); ++pos)
-                    {
-                        assert ((curr_addr % cache_line_byte_size) == 0);
-                        
-                        if (pos->first != curr_addr)
-                            break;
-                        
-                        curr_read_size = pos->second->GetByteSize();
-                        if (curr_read_size > bytes_left)
-                            curr_read_size = bytes_left;
-                        
-                        memcpy (dst_buf + dst_len - bytes_left, pos->second->GetBytes(), curr_read_size);
-                        
-                        bytes_left -= curr_read_size;
-                        curr_addr += curr_read_size;
-                        
-                        // We have a cache page that succeeded to read some bytes
-                        // but not an entire page. If this happens, we must cap
-                        // off how much data we are able to read...
-                        if (pos->second->GetByteSize() != cache_line_byte_size)
-                            return dst_len - bytes_left;
-                    }
-                }
-            }
-            
-            // We need to read from the process
-            
-            if (bytes_left > 0)
-            {
-                assert ((curr_addr % cache_line_byte_size) == 0);
-                std::unique_ptr<DataBufferHeap> data_buffer_heap_ap(new DataBufferHeap (cache_line_byte_size, 0));
-                size_t process_bytes_read = m_process.ReadMemoryFromInferior (curr_addr, 
-                                                                              data_buffer_heap_ap->GetBytes(), 
-                                                                              data_buffer_heap_ap->GetByteSize(), 
-                                                                              error);
-                if (process_bytes_read == 0)
-                    return dst_len - bytes_left;
-                
-                if (process_bytes_read != cache_line_byte_size)
-                    data_buffer_heap_ap->SetByteSize (process_bytes_read);
-                m_L2_cache[curr_addr] = DataBufferSP (data_buffer_heap_ap.release());
-                // We have read data and put it into the cache, continue through the
-                // loop again to get the data out of the cache...
-            }
-        }
-    }
-    
-    return dst_len - bytes_left;
-}
-
-
-
-AllocatedBlock::AllocatedBlock (lldb::addr_t addr, 
-                                uint32_t byte_size, 
-                                uint32_t permissions,
-                                uint32_t chunk_size) :
-    m_addr (addr),
-    m_byte_size (byte_size),
-    m_permissions (permissions),
-    m_chunk_size (chunk_size),
-    m_offset_to_chunk_size ()
+      if (bytes_left > 0) {
+        assert((curr_addr % cache_line_byte_size) == 0);
+        std::unique_ptr<DataBufferHeap> data_buffer_heap_ap(
+            new DataBufferHeap(cache_line_byte_size, 0));
+        size_t process_bytes_read = m_process.ReadMemoryFromInferior(
+            curr_addr, data_buffer_heap_ap->GetBytes(),
+            data_buffer_heap_ap->GetByteSize(), error);
+        if (process_bytes_read == 0)
+          return dst_len - bytes_left;
+
+        if (process_bytes_read != cache_line_byte_size)
+          data_buffer_heap_ap->SetByteSize(process_bytes_read);
+        m_L2_cache[curr_addr] = DataBufferSP(data_buffer_heap_ap.release());
+        // We have read data and put it into the cache, continue through the
+        // loop again to get the data out of the cache...
+      }
+    }
+  }
+
+  return dst_len - bytes_left;
+}
+
+AllocatedBlock::AllocatedBlock(lldb::addr_t addr, uint32_t byte_size,
+                               uint32_t permissions, uint32_t chunk_size)
+    : m_addr(addr), m_byte_size(byte_size), m_permissions(permissions),
+      m_chunk_size(chunk_size), m_offset_to_chunk_size()
 //    m_allocated (byte_size / chunk_size)
 {
-    assert (byte_size > chunk_size);
+  assert(byte_size > chunk_size);
 }
 
-AllocatedBlock::~AllocatedBlock ()
-{
-}
+AllocatedBlock::~AllocatedBlock() {}
 
-lldb::addr_t
-AllocatedBlock::ReserveBlock (uint32_t size)
-{
-    addr_t addr = LLDB_INVALID_ADDRESS;
-    Log *log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_VERBOSE));
-    if (size <= m_byte_size)
-    {
-        const uint32_t needed_chunks = CalculateChunksNeededForSize (size);
-
-        if (m_offset_to_chunk_size.empty())
-        {
-            m_offset_to_chunk_size[0] = needed_chunks;
+lldb::addr_t AllocatedBlock::ReserveBlock(uint32_t size) {
+  addr_t addr = LLDB_INVALID_ADDRESS;
+  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_VERBOSE));
+  if (size <= m_byte_size) {
+    const uint32_t needed_chunks = CalculateChunksNeededForSize(size);
+
+    if (m_offset_to_chunk_size.empty()) {
+      m_offset_to_chunk_size[0] = needed_chunks;
+      if (log)
+        log->Printf("[1] AllocatedBlock::ReserveBlock(%p) (size = %u (0x%x)) "
+                    "=> offset = 0x%x, %u %u bit chunks",
+                    (void *)this, size, size, 0, needed_chunks, m_chunk_size);
+      addr = m_addr;
+    } else {
+      uint32_t last_offset = 0;
+      OffsetToChunkSize::const_iterator pos = m_offset_to_chunk_size.begin();
+      OffsetToChunkSize::const_iterator end = m_offset_to_chunk_size.end();
+      while (pos != end) {
+        if (pos->first > last_offset) {
+          const uint32_t bytes_available = pos->first - last_offset;
+          const uint32_t num_chunks =
+              CalculateChunksNeededForSize(bytes_available);
+          if (num_chunks >= needed_chunks) {
+            m_offset_to_chunk_size[last_offset] = needed_chunks;
             if (log)
-                log->Printf("[1] AllocatedBlock::ReserveBlock(%p) (size = %u (0x%x)) => offset = 0x%x, %u %u bit chunks", (void *)this,
-                            size, size, 0, needed_chunks, m_chunk_size);
-            addr = m_addr;
-        }
-        else
-        {
-            uint32_t last_offset = 0;
-            OffsetToChunkSize::const_iterator pos = m_offset_to_chunk_size.begin();
-            OffsetToChunkSize::const_iterator end = m_offset_to_chunk_size.end();
-            while (pos != end)
-            {
-                if (pos->first > last_offset)
-                {
-                    const uint32_t bytes_available = pos->first - last_offset;
-                    const uint32_t num_chunks = CalculateChunksNeededForSize (bytes_available);
-                    if (num_chunks >= needed_chunks)
-                    {
-                        m_offset_to_chunk_size[last_offset] = needed_chunks;
-                        if (log)
-                            log->Printf("[2] AllocatedBlock::ReserveBlock(%p) (size = %u (0x%x)) => offset = 0x%x, %u %u bit chunks - "
-                                        "num_chunks %lu",
-                                        (void *)this, size, size, last_offset, needed_chunks, m_chunk_size, m_offset_to_chunk_size.size());
-                        addr = m_addr + last_offset;
-                        break;
-                    }
-                }
-                
-                last_offset = pos->first + pos->second * m_chunk_size;
-
-                if (++pos == end)
-                {
-                    // Last entry...
-                    const uint32_t chunks_left = CalculateChunksNeededForSize (m_byte_size - last_offset);
-                    if (chunks_left >= needed_chunks)
-                    {
-                        m_offset_to_chunk_size[last_offset] = needed_chunks;
-                        if (log)
-                            log->Printf("[3] AllocatedBlock::ReserveBlock(%p) (size = %u (0x%x)) => offset = 0x%x, %u %u bit chunks - "
-                                        "num_chunks %lu",
-                                        (void *)this, size, size, last_offset, needed_chunks, m_chunk_size, m_offset_to_chunk_size.size());
-                        addr = m_addr + last_offset;
-                        break;
-                    }
-                }
-            }
+              log->Printf("[2] AllocatedBlock::ReserveBlock(%p) (size = %u "
+                          "(0x%x)) => offset = 0x%x, %u %u bit chunks - "
+                          "num_chunks %lu",
+                          (void *)this, size, size, last_offset, needed_chunks,
+                          m_chunk_size, m_offset_to_chunk_size.size());
+            addr = m_addr + last_offset;
+            break;
+          }
         }
-//        const uint32_t total_chunks = m_allocated.size ();
-//        uint32_t unallocated_idx = 0;
-//        uint32_t allocated_idx = m_allocated.find_first();
-//        uint32_t first_chunk_idx = UINT32_MAX;
-//        uint32_t num_chunks;
-//        while (1)
-//        {
-//            if (allocated_idx == UINT32_MAX)
-//            {
-//                // No more bits are set starting from unallocated_idx, so we
-//                // either have enough chunks for the request, or we don't.
-//                // Either way we break out of the while loop...
-//                num_chunks = total_chunks - unallocated_idx;
-//                if (needed_chunks <= num_chunks)
-//                    first_chunk_idx = unallocated_idx;
-//                break;                
-//            }
-//            else if (allocated_idx > unallocated_idx)
-//            {
-//                // We have some allocated chunks, check if there are enough
-//                // free chunks to satisfy the request?
-//                num_chunks = allocated_idx - unallocated_idx;
-//                if (needed_chunks <= num_chunks)
-//                {
-//                    // Yep, we have enough!
-//                    first_chunk_idx = unallocated_idx;
-//                    break;
-//                }
-//            }
-//            
-//            while (unallocated_idx < total_chunks)
-//            {
-//                if (m_allocated[unallocated_idx])
-//                    ++unallocated_idx;
-//                else
-//                    break;
-//            }
-//            
-//            if (unallocated_idx >= total_chunks)
-//                break;
-//            
-//            allocated_idx = m_allocated.find_next(unallocated_idx);
-//        }
-//        
-//        if (first_chunk_idx != UINT32_MAX)
-//        {
-//            const uint32_t end_bit_idx = unallocated_idx + needed_chunks;
-//            for (uint32_t idx = first_chunk_idx; idx < end_bit_idx; ++idx)
-//                m_allocated.set(idx);
-//            return m_addr + m_chunk_size * first_chunk_idx;
-//        }
-    }
-
-    if (log)
-        log->Printf("AllocatedBlock::ReserveBlock(%p) (size = %u (0x%x)) => 0x%16.16" PRIx64, (void *)this, size, size, (uint64_t)addr);
-    return addr;
-}
 
-bool
-AllocatedBlock::FreeBlock (addr_t addr)
-{
-    uint32_t offset = addr - m_addr;
-    OffsetToChunkSize::iterator pos = m_offset_to_chunk_size.find (offset);
-    bool success = false;
-    if (pos != m_offset_to_chunk_size.end())
-    {
-        m_offset_to_chunk_size.erase (pos);
-        success = true;
-    }
-    Log *log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_VERBOSE));
-    if (log)
-        log->Printf("AllocatedBlock::FreeBlock(%p) (addr = 0x%16.16" PRIx64 ") => %i, num_chunks: %lu", (void *)this, (uint64_t)addr,
-                    success, m_offset_to_chunk_size.size());
-    return success;
-}
-
-AllocatedMemoryCache::AllocatedMemoryCache(Process &process) : m_process(process), m_mutex(), m_memory_map()
-{
-}
+        last_offset = pos->first + pos->second * m_chunk_size;
 
-AllocatedMemoryCache::~AllocatedMemoryCache ()
-{
-}
-
-
-void
-AllocatedMemoryCache::Clear()
-{
-    std::lock_guard<std::recursive_mutex> guard(m_mutex);
-    if (m_process.IsAlive())
-    {
-        PermissionsToBlockMap::iterator pos, end = m_memory_map.end();
-        for (pos = m_memory_map.begin(); pos != end; ++pos)
-            m_process.DoDeallocateMemory(pos->second->GetBaseAddress());
+        if (++pos == end) {
+          // Last entry...
+          const uint32_t chunks_left =
+              CalculateChunksNeededForSize(m_byte_size - last_offset);
+          if (chunks_left >= needed_chunks) {
+            m_offset_to_chunk_size[last_offset] = needed_chunks;
+            if (log)
+              log->Printf("[3] AllocatedBlock::ReserveBlock(%p) (size = %u "
+                          "(0x%x)) => offset = 0x%x, %u %u bit chunks - "
+                          "num_chunks %lu",
+                          (void *)this, size, size, last_offset, needed_chunks,
+                          m_chunk_size, m_offset_to_chunk_size.size());
+            addr = m_addr + last_offset;
+            break;
+          }
+        }
+      }
     }
-    m_memory_map.clear();
+    //        const uint32_t total_chunks = m_allocated.size ();
+    //        uint32_t unallocated_idx = 0;
+    //        uint32_t allocated_idx = m_allocated.find_first();
+    //        uint32_t first_chunk_idx = UINT32_MAX;
+    //        uint32_t num_chunks;
+    //        while (1)
+    //        {
+    //            if (allocated_idx == UINT32_MAX)
+    //            {
+    //                // No more bits are set starting from unallocated_idx, so
+    //                we
+    //                // either have enough chunks for the request, or we don't.
+    //                // Either way we break out of the while loop...
+    //                num_chunks = total_chunks - unallocated_idx;
+    //                if (needed_chunks <= num_chunks)
+    //                    first_chunk_idx = unallocated_idx;
+    //                break;
+    //            }
+    //            else if (allocated_idx > unallocated_idx)
+    //            {
+    //                // We have some allocated chunks, check if there are
+    //                enough
+    //                // free chunks to satisfy the request?
+    //                num_chunks = allocated_idx - unallocated_idx;
+    //                if (needed_chunks <= num_chunks)
+    //                {
+    //                    // Yep, we have enough!
+    //                    first_chunk_idx = unallocated_idx;
+    //                    break;
+    //                }
+    //            }
+    //
+    //            while (unallocated_idx < total_chunks)
+    //            {
+    //                if (m_allocated[unallocated_idx])
+    //                    ++unallocated_idx;
+    //                else
+    //                    break;
+    //            }
+    //
+    //            if (unallocated_idx >= total_chunks)
+    //                break;
+    //
+    //            allocated_idx = m_allocated.find_next(unallocated_idx);
+    //        }
+    //
+    //        if (first_chunk_idx != UINT32_MAX)
+    //        {
+    //            const uint32_t end_bit_idx = unallocated_idx + needed_chunks;
+    //            for (uint32_t idx = first_chunk_idx; idx < end_bit_idx; ++idx)
+    //                m_allocated.set(idx);
+    //            return m_addr + m_chunk_size * first_chunk_idx;
+    //        }
+  }
+
+  if (log)
+    log->Printf("AllocatedBlock::ReserveBlock(%p) (size = %u (0x%x)) => "
+                "0x%16.16" PRIx64,
+                (void *)this, size, size, (uint64_t)addr);
+  return addr;
+}
+
+bool AllocatedBlock::FreeBlock(addr_t addr) {
+  uint32_t offset = addr - m_addr;
+  OffsetToChunkSize::iterator pos = m_offset_to_chunk_size.find(offset);
+  bool success = false;
+  if (pos != m_offset_to_chunk_size.end()) {
+    m_offset_to_chunk_size.erase(pos);
+    success = true;
+  }
+  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_VERBOSE));
+  if (log)
+    log->Printf("AllocatedBlock::FreeBlock(%p) (addr = 0x%16.16" PRIx64
+                ") => %i, num_chunks: %lu",
+                (void *)this, (uint64_t)addr, success,
+                m_offset_to_chunk_size.size());
+  return success;
+}
+
+AllocatedMemoryCache::AllocatedMemoryCache(Process &process)
+    : m_process(process), m_mutex(), m_memory_map() {}
+
+AllocatedMemoryCache::~AllocatedMemoryCache() {}
+
+void AllocatedMemoryCache::Clear() {
+  std::lock_guard<std::recursive_mutex> guard(m_mutex);
+  if (m_process.IsAlive()) {
+    PermissionsToBlockMap::iterator pos, end = m_memory_map.end();
+    for (pos = m_memory_map.begin(); pos != end; ++pos)
+      m_process.DoDeallocateMemory(pos->second->GetBaseAddress());
+  }
+  m_memory_map.clear();
 }
 
-
 AllocatedMemoryCache::AllocatedBlockSP
-AllocatedMemoryCache::AllocatePage (uint32_t byte_size, 
-                                    uint32_t permissions, 
-                                    uint32_t chunk_size, 
-                                    Error &error)
-{
-    AllocatedBlockSP block_sp;
-    const size_t page_size = 4096;
-    const size_t num_pages = (byte_size + page_size - 1) / page_size;
-    const size_t page_byte_size = num_pages * page_size;
-
-    addr_t addr = m_process.DoAllocateMemory(page_byte_size, permissions, error);
-
-    Log *log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
-    if (log)
-    {
-        log->Printf ("Process::DoAllocateMemory (byte_size = 0x%8.8" PRIx32 ", permissions = %s) => 0x%16.16" PRIx64,
-                     (uint32_t)page_byte_size, 
-                     GetPermissionsAsCString(permissions), 
-                     (uint64_t)addr);
-    }
-
+AllocatedMemoryCache::AllocatePage(uint32_t byte_size, uint32_t permissions,
+                                   uint32_t chunk_size, Error &error) {
+  AllocatedBlockSP block_sp;
+  const size_t page_size = 4096;
+  const size_t num_pages = (byte_size + page_size - 1) / page_size;
+  const size_t page_byte_size = num_pages * page_size;
+
+  addr_t addr = m_process.DoAllocateMemory(page_byte_size, permissions, error);
+
+  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+  if (log) {
+    log->Printf("Process::DoAllocateMemory (byte_size = 0x%8.8" PRIx32
+                ", permissions = %s) => 0x%16.16" PRIx64,
+                (uint32_t)page_byte_size, GetPermissionsAsCString(permissions),
+                (uint64_t)addr);
+  }
+
+  if (addr != LLDB_INVALID_ADDRESS) {
+    block_sp.reset(
+        new AllocatedBlock(addr, page_byte_size, permissions, chunk_size));
+    m_memory_map.insert(std::make_pair(permissions, block_sp));
+  }
+  return block_sp;
+}
+
+lldb::addr_t AllocatedMemoryCache::AllocateMemory(size_t byte_size,
+                                                  uint32_t permissions,
+                                                  Error &error) {
+  std::lock_guard<std::recursive_mutex> guard(m_mutex);
+
+  addr_t addr = LLDB_INVALID_ADDRESS;
+  std::pair<PermissionsToBlockMap::iterator, PermissionsToBlockMap::iterator>
+      range = m_memory_map.equal_range(permissions);
+
+  for (PermissionsToBlockMap::iterator pos = range.first; pos != range.second;
+       ++pos) {
+    addr = (*pos).second->ReserveBlock(byte_size);
     if (addr != LLDB_INVALID_ADDRESS)
-    {
-        block_sp.reset (new AllocatedBlock (addr, page_byte_size, permissions, chunk_size));
-        m_memory_map.insert (std::make_pair (permissions, block_sp));
-    }
-    return block_sp;
-}
-
-lldb::addr_t
-AllocatedMemoryCache::AllocateMemory (size_t byte_size, 
-                                      uint32_t permissions, 
-                                      Error &error)
-{
-    std::lock_guard<std::recursive_mutex> guard(m_mutex);
-
-    addr_t addr = LLDB_INVALID_ADDRESS;
-    std::pair<PermissionsToBlockMap::iterator, PermissionsToBlockMap::iterator> range = m_memory_map.equal_range (permissions);
-
-    for (PermissionsToBlockMap::iterator pos = range.first; pos != range.second; ++pos)
-    {
-        addr = (*pos).second->ReserveBlock (byte_size);
-        if (addr != LLDB_INVALID_ADDRESS)
-            break;
-    }
-    
-    if (addr == LLDB_INVALID_ADDRESS)
-    {
-        AllocatedBlockSP block_sp (AllocatePage (byte_size, permissions, 16, error));
+      break;
+  }
 
-        if (block_sp)
-            addr = block_sp->ReserveBlock (byte_size);
-    }
-    Log *log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
-    if (log)
-        log->Printf ("AllocatedMemoryCache::AllocateMemory (byte_size = 0x%8.8" PRIx32 ", permissions = %s) => 0x%16.16" PRIx64, (uint32_t)byte_size, GetPermissionsAsCString(permissions), (uint64_t)addr);
-    return addr;
-}
-
-bool
-AllocatedMemoryCache::DeallocateMemory (lldb::addr_t addr)
-{
-    std::lock_guard<std::recursive_mutex> guard(m_mutex);
+  if (addr == LLDB_INVALID_ADDRESS) {
+    AllocatedBlockSP block_sp(AllocatePage(byte_size, permissions, 16, error));
 
-    PermissionsToBlockMap::iterator pos, end = m_memory_map.end();
-    bool success = false;
-    for (pos = m_memory_map.begin(); pos != end; ++pos)
-    {
-        if (pos->second->Contains (addr))
-        {
-            success = pos->second->FreeBlock (addr);
-            break;
-        }
-    }
-    Log *log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
-    if (log)
-        log->Printf("AllocatedMemoryCache::DeallocateMemory (addr = 0x%16.16" PRIx64 ") => %i", (uint64_t)addr, success);
-    return success;
+    if (block_sp)
+      addr = block_sp->ReserveBlock(byte_size);
+  }
+  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+  if (log)
+    log->Printf(
+        "AllocatedMemoryCache::AllocateMemory (byte_size = 0x%8.8" PRIx32
+        ", permissions = %s) => 0x%16.16" PRIx64,
+        (uint32_t)byte_size, GetPermissionsAsCString(permissions),
+        (uint64_t)addr);
+  return addr;
+}
+
+bool AllocatedMemoryCache::DeallocateMemory(lldb::addr_t addr) {
+  std::lock_guard<std::recursive_mutex> guard(m_mutex);
+
+  PermissionsToBlockMap::iterator pos, end = m_memory_map.end();
+  bool success = false;
+  for (pos = m_memory_map.begin(); pos != end; ++pos) {
+    if (pos->second->Contains(addr)) {
+      success = pos->second->FreeBlock(addr);
+      break;
+    }
+  }
+  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+  if (log)
+    log->Printf("AllocatedMemoryCache::DeallocateMemory (addr = 0x%16.16" PRIx64
+                ") => %i",
+                (uint64_t)addr, success);
+  return success;
 }
-
-

Modified: lldb/trunk/source/Target/MemoryHistory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/MemoryHistory.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/MemoryHistory.cpp (original)
+++ lldb/trunk/source/Target/MemoryHistory.cpp Tue Sep  6 15:57:50 2016
@@ -17,17 +17,17 @@
 using namespace lldb;
 using namespace lldb_private;
 
-lldb::MemoryHistorySP
-MemoryHistory::FindPlugin (const ProcessSP process)
-{
-    MemoryHistoryCreateInstance create_callback = nullptr;
-    
-    for (uint32_t idx = 0; (create_callback = PluginManager::GetMemoryHistoryCreateCallbackAtIndex(idx)) != nullptr; ++idx)
-    {
-        MemoryHistorySP memory_history_sp (create_callback (process));
-        if (memory_history_sp)
-            return memory_history_sp;
-    }
-    
-    return MemoryHistorySP();
+lldb::MemoryHistorySP MemoryHistory::FindPlugin(const ProcessSP process) {
+  MemoryHistoryCreateInstance create_callback = nullptr;
+
+  for (uint32_t idx = 0;
+       (create_callback = PluginManager::GetMemoryHistoryCreateCallbackAtIndex(
+            idx)) != nullptr;
+       ++idx) {
+    MemoryHistorySP memory_history_sp(create_callback(process));
+    if (memory_history_sp)
+      return memory_history_sp;
+  }
+
+  return MemoryHistorySP();
 }

Modified: lldb/trunk/source/Target/ObjCLanguageRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ObjCLanguageRuntime.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/ObjCLanguageRuntime.cpp (original)
+++ lldb/trunk/source/Target/ObjCLanguageRuntime.cpp Tue Sep  6 15:57:50 2016
@@ -30,414 +30,358 @@ using namespace lldb_private;
 //----------------------------------------------------------------------
 // Destructor
 //----------------------------------------------------------------------
-ObjCLanguageRuntime::~ObjCLanguageRuntime()
-{
-}
+ObjCLanguageRuntime::~ObjCLanguageRuntime() {}
 
-ObjCLanguageRuntime::ObjCLanguageRuntime (Process *process) :
-    LanguageRuntime (process),
-    m_impl_cache(),
-    m_has_new_literals_and_indexing (eLazyBoolCalculate),
-    m_isa_to_descriptor(),
-    m_hash_to_isa_map(),
-    m_type_size_cache(),
-    m_isa_to_descriptor_stop_id (UINT32_MAX),
-    m_complete_class_cache(),
-    m_negative_complete_class_cache()
-{
-}
-
-bool
-ObjCLanguageRuntime::AddClass (ObjCISA isa, const ClassDescriptorSP &descriptor_sp, const char *class_name)
-{
-    if (isa != 0)
-    {
-        m_isa_to_descriptor[isa] = descriptor_sp;
-        // class_name is assumed to be valid
-        m_hash_to_isa_map.insert(std::make_pair(MappedHash::HashStringUsingDJB(class_name), isa));
-        return true;
-    }
-    return false;
+ObjCLanguageRuntime::ObjCLanguageRuntime(Process *process)
+    : LanguageRuntime(process), m_impl_cache(),
+      m_has_new_literals_and_indexing(eLazyBoolCalculate),
+      m_isa_to_descriptor(), m_hash_to_isa_map(), m_type_size_cache(),
+      m_isa_to_descriptor_stop_id(UINT32_MAX), m_complete_class_cache(),
+      m_negative_complete_class_cache() {}
+
+bool ObjCLanguageRuntime::AddClass(ObjCISA isa,
+                                   const ClassDescriptorSP &descriptor_sp,
+                                   const char *class_name) {
+  if (isa != 0) {
+    m_isa_to_descriptor[isa] = descriptor_sp;
+    // class_name is assumed to be valid
+    m_hash_to_isa_map.insert(
+        std::make_pair(MappedHash::HashStringUsingDJB(class_name), isa));
+    return true;
+  }
+  return false;
 }
 
-void
-ObjCLanguageRuntime::AddToMethodCache (lldb::addr_t class_addr, lldb::addr_t selector, lldb::addr_t impl_addr)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-    if (log)
-    {
-        log->Printf ("Caching: class 0x%" PRIx64 " selector 0x%" PRIx64 " implementation 0x%" PRIx64 ".", class_addr, selector, impl_addr);
-    }
-    m_impl_cache.insert (std::pair<ClassAndSel,lldb::addr_t> (ClassAndSel(class_addr, selector), impl_addr));
+void ObjCLanguageRuntime::AddToMethodCache(lldb::addr_t class_addr,
+                                           lldb::addr_t selector,
+                                           lldb::addr_t impl_addr) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+  if (log) {
+    log->Printf("Caching: class 0x%" PRIx64 " selector 0x%" PRIx64
+                " implementation 0x%" PRIx64 ".",
+                class_addr, selector, impl_addr);
+  }
+  m_impl_cache.insert(std::pair<ClassAndSel, lldb::addr_t>(
+      ClassAndSel(class_addr, selector), impl_addr));
+}
+
+lldb::addr_t ObjCLanguageRuntime::LookupInMethodCache(lldb::addr_t class_addr,
+                                                      lldb::addr_t selector) {
+  MsgImplMap::iterator pos, end = m_impl_cache.end();
+  pos = m_impl_cache.find(ClassAndSel(class_addr, selector));
+  if (pos != end)
+    return (*pos).second;
+  return LLDB_INVALID_ADDRESS;
 }
 
-lldb::addr_t
-ObjCLanguageRuntime::LookupInMethodCache (lldb::addr_t class_addr, lldb::addr_t selector)
-{
-    MsgImplMap::iterator pos, end = m_impl_cache.end();
-    pos = m_impl_cache.find (ClassAndSel(class_addr, selector));
-    if (pos != end)
-        return (*pos).second;
-    return LLDB_INVALID_ADDRESS;
-}
+lldb::TypeSP
+ObjCLanguageRuntime::LookupInCompleteClassCache(ConstString &name) {
+  CompleteClassMap::iterator complete_class_iter =
+      m_complete_class_cache.find(name);
+
+  if (complete_class_iter != m_complete_class_cache.end()) {
+    // Check the weak pointer to make sure the type hasn't been unloaded
+    TypeSP complete_type_sp(complete_class_iter->second.lock());
 
+    if (complete_type_sp)
+      return complete_type_sp;
+    else
+      m_complete_class_cache.erase(name);
+  }
 
-lldb::TypeSP
-ObjCLanguageRuntime::LookupInCompleteClassCache (ConstString &name)
-{
-    CompleteClassMap::iterator complete_class_iter = m_complete_class_cache.find(name);
-    
-    if (complete_class_iter != m_complete_class_cache.end())
-    {
-        // Check the weak pointer to make sure the type hasn't been unloaded
-        TypeSP complete_type_sp (complete_class_iter->second.lock());
-        
-        if (complete_type_sp)
-            return complete_type_sp;
-        else
-            m_complete_class_cache.erase(name);
-    }
-    
-    if (m_negative_complete_class_cache.count(name) > 0)
-        return TypeSP();
-    
-    const ModuleList &modules = m_process->GetTarget().GetImages();
-
-    SymbolContextList sc_list;
-    const size_t matching_symbols = modules.FindSymbolsWithNameAndType (name,
-                                                                        eSymbolTypeObjCClass,
-                                                                        sc_list);
-    
-    if (matching_symbols)
-    {
-        SymbolContext sc;
-        
-        sc_list.GetContextAtIndex(0, sc);
-        
-        ModuleSP module_sp(sc.module_sp);
-        
-        if (!module_sp)
-            return TypeSP();
-        
-        const SymbolContext null_sc;
-        const bool exact_match = true;
-        const uint32_t max_matches = UINT32_MAX;
-        TypeList types;
-
-        llvm::DenseSet<SymbolFile *> searched_symbol_files;
-        const uint32_t num_types = module_sp->FindTypes (null_sc,
-                                                         name,
-                                                         exact_match,
-                                                         max_matches,
-                                                         searched_symbol_files,
-                                                         types);
-        
-        if (num_types)
-        {            
-            uint32_t i;
-            for (i = 0; i < num_types; ++i)
-            {
-                TypeSP type_sp (types.GetTypeAtIndex(i));
-                
-                if (ClangASTContext::IsObjCObjectOrInterfaceType(type_sp->GetForwardCompilerType ()))
-                {
-                    if (type_sp->IsCompleteObjCClass())
-                    {
-                        m_complete_class_cache[name] = type_sp;
-                        return type_sp;
-                    }
-                }
-            }
+  if (m_negative_complete_class_cache.count(name) > 0)
+    return TypeSP();
+
+  const ModuleList &modules = m_process->GetTarget().GetImages();
+
+  SymbolContextList sc_list;
+  const size_t matching_symbols =
+      modules.FindSymbolsWithNameAndType(name, eSymbolTypeObjCClass, sc_list);
+
+  if (matching_symbols) {
+    SymbolContext sc;
+
+    sc_list.GetContextAtIndex(0, sc);
+
+    ModuleSP module_sp(sc.module_sp);
+
+    if (!module_sp)
+      return TypeSP();
+
+    const SymbolContext null_sc;
+    const bool exact_match = true;
+    const uint32_t max_matches = UINT32_MAX;
+    TypeList types;
+
+    llvm::DenseSet<SymbolFile *> searched_symbol_files;
+    const uint32_t num_types = module_sp->FindTypes(
+        null_sc, name, exact_match, max_matches, searched_symbol_files, types);
+
+    if (num_types) {
+      uint32_t i;
+      for (i = 0; i < num_types; ++i) {
+        TypeSP type_sp(types.GetTypeAtIndex(i));
+
+        if (ClangASTContext::IsObjCObjectOrInterfaceType(
+                type_sp->GetForwardCompilerType())) {
+          if (type_sp->IsCompleteObjCClass()) {
+            m_complete_class_cache[name] = type_sp;
+            return type_sp;
+          }
         }
+      }
     }
-    m_negative_complete_class_cache.insert(name);
-    return TypeSP();
+  }
+  m_negative_complete_class_cache.insert(name);
+  return TypeSP();
 }
 
-size_t
-ObjCLanguageRuntime::GetByteOffsetForIvar (CompilerType &parent_qual_type, const char *ivar_name)
-{
-    return LLDB_INVALID_IVAR_OFFSET;
-}
-
-bool
-ObjCLanguageRuntime::ClassDescriptor::IsPointerValid (lldb::addr_t value,
-                                                      uint32_t ptr_size,
-                                                      bool allow_NULLs,
-                                                      bool allow_tagged,
-                                                      bool check_version_specific) const
-{
-    if (!value)
-        return allow_NULLs;
-    if ( (value % 2) == 1  && allow_tagged)
-        return true;
-    if ((value % ptr_size) == 0)
-        return (check_version_specific ? CheckPointer(value,ptr_size) : true);
-    else
-        return false;
+size_t ObjCLanguageRuntime::GetByteOffsetForIvar(CompilerType &parent_qual_type,
+                                                 const char *ivar_name) {
+  return LLDB_INVALID_IVAR_OFFSET;
+}
+
+bool ObjCLanguageRuntime::ClassDescriptor::IsPointerValid(
+    lldb::addr_t value, uint32_t ptr_size, bool allow_NULLs, bool allow_tagged,
+    bool check_version_specific) const {
+  if (!value)
+    return allow_NULLs;
+  if ((value % 2) == 1 && allow_tagged)
+    return true;
+  if ((value % ptr_size) == 0)
+    return (check_version_specific ? CheckPointer(value, ptr_size) : true);
+  else
+    return false;
 }
 
 ObjCLanguageRuntime::ObjCISA
-ObjCLanguageRuntime::GetISA(const ConstString &name)
-{
-    ISAToDescriptorIterator pos = GetDescriptorIterator (name);
-    if (pos != m_isa_to_descriptor.end())
-        return pos->first;
-    return 0;
+ObjCLanguageRuntime::GetISA(const ConstString &name) {
+  ISAToDescriptorIterator pos = GetDescriptorIterator(name);
+  if (pos != m_isa_to_descriptor.end())
+    return pos->first;
+  return 0;
 }
 
 ObjCLanguageRuntime::ISAToDescriptorIterator
-ObjCLanguageRuntime::GetDescriptorIterator (const ConstString &name)
-{
-    ISAToDescriptorIterator end = m_isa_to_descriptor.end();
-
-    if (name)
-    {
-        UpdateISAToDescriptorMap();
-        if (m_hash_to_isa_map.empty())
-        {
-            // No name hashes were provided, we need to just linearly power through the
-            // names and find a match
-            for (ISAToDescriptorIterator pos = m_isa_to_descriptor.begin(); pos != end; ++pos)
-            {
-                if (pos->second->GetClassName() == name)
-                    return pos;
-            }
-        }
-        else
-        {
-            // Name hashes were provided, so use them to efficiently lookup name to isa/descriptor
-            const uint32_t name_hash = MappedHash::HashStringUsingDJB (name.GetCString());
-            std::pair <HashToISAIterator, HashToISAIterator> range = m_hash_to_isa_map.equal_range(name_hash);
-            for (HashToISAIterator range_pos = range.first; range_pos != range.second; ++range_pos)
-            {
-                ISAToDescriptorIterator pos = m_isa_to_descriptor.find (range_pos->second);
-                if (pos != m_isa_to_descriptor.end())
-                {
-                    if (pos->second->GetClassName() == name)
-                        return pos;
-                }
-            }
+ObjCLanguageRuntime::GetDescriptorIterator(const ConstString &name) {
+  ISAToDescriptorIterator end = m_isa_to_descriptor.end();
+
+  if (name) {
+    UpdateISAToDescriptorMap();
+    if (m_hash_to_isa_map.empty()) {
+      // No name hashes were provided, we need to just linearly power through
+      // the
+      // names and find a match
+      for (ISAToDescriptorIterator pos = m_isa_to_descriptor.begin();
+           pos != end; ++pos) {
+        if (pos->second->GetClassName() == name)
+          return pos;
+      }
+    } else {
+      // Name hashes were provided, so use them to efficiently lookup name to
+      // isa/descriptor
+      const uint32_t name_hash =
+          MappedHash::HashStringUsingDJB(name.GetCString());
+      std::pair<HashToISAIterator, HashToISAIterator> range =
+          m_hash_to_isa_map.equal_range(name_hash);
+      for (HashToISAIterator range_pos = range.first; range_pos != range.second;
+           ++range_pos) {
+        ISAToDescriptorIterator pos =
+            m_isa_to_descriptor.find(range_pos->second);
+        if (pos != m_isa_to_descriptor.end()) {
+          if (pos->second->GetClassName() == name)
+            return pos;
         }
+      }
     }
-    return end;
+  }
+  return end;
 }
 
-std::pair<ObjCLanguageRuntime::ISAToDescriptorIterator,ObjCLanguageRuntime::ISAToDescriptorIterator>
-ObjCLanguageRuntime::GetDescriptorIteratorPair (bool update_if_needed)
-{
-    if (update_if_needed)
-        UpdateISAToDescriptorMapIfNeeded();
-    
-    return std::pair<ObjCLanguageRuntime::ISAToDescriptorIterator,
-                     ObjCLanguageRuntime::ISAToDescriptorIterator>(
-                        m_isa_to_descriptor.begin(),
-                        m_isa_to_descriptor.end());
-}
+std::pair<ObjCLanguageRuntime::ISAToDescriptorIterator,
+          ObjCLanguageRuntime::ISAToDescriptorIterator>
+ObjCLanguageRuntime::GetDescriptorIteratorPair(bool update_if_needed) {
+  if (update_if_needed)
+    UpdateISAToDescriptorMapIfNeeded();
 
+  return std::pair<ObjCLanguageRuntime::ISAToDescriptorIterator,
+                   ObjCLanguageRuntime::ISAToDescriptorIterator>(
+      m_isa_to_descriptor.begin(), m_isa_to_descriptor.end());
+}
 
 ObjCLanguageRuntime::ObjCISA
-ObjCLanguageRuntime::GetParentClass(ObjCLanguageRuntime::ObjCISA isa)
-{
-    ClassDescriptorSP objc_class_sp (GetClassDescriptorFromISA(isa));
-    if (objc_class_sp)
-    {
-        ClassDescriptorSP objc_super_class_sp (objc_class_sp->GetSuperclass());
-        if (objc_super_class_sp)
-            return objc_super_class_sp->GetISA();
-    }
-    return 0;
+ObjCLanguageRuntime::GetParentClass(ObjCLanguageRuntime::ObjCISA isa) {
+  ClassDescriptorSP objc_class_sp(GetClassDescriptorFromISA(isa));
+  if (objc_class_sp) {
+    ClassDescriptorSP objc_super_class_sp(objc_class_sp->GetSuperclass());
+    if (objc_super_class_sp)
+      return objc_super_class_sp->GetISA();
+  }
+  return 0;
 }
 
 ConstString
-ObjCLanguageRuntime::GetActualTypeName(ObjCLanguageRuntime::ObjCISA isa)
-{
-    ClassDescriptorSP objc_class_sp (GetNonKVOClassDescriptor(isa));
-    if (objc_class_sp)
-        return objc_class_sp->GetClassName();
-    return ConstString();
+ObjCLanguageRuntime::GetActualTypeName(ObjCLanguageRuntime::ObjCISA isa) {
+  ClassDescriptorSP objc_class_sp(GetNonKVOClassDescriptor(isa));
+  if (objc_class_sp)
+    return objc_class_sp->GetClassName();
+  return ConstString();
 }
 
 ObjCLanguageRuntime::ClassDescriptorSP
-ObjCLanguageRuntime::GetClassDescriptorFromClassName (const ConstString &class_name)
-{
-    ISAToDescriptorIterator pos = GetDescriptorIterator (class_name);
-    if (pos != m_isa_to_descriptor.end())
-        return pos->second;
-    return ClassDescriptorSP();
-
+ObjCLanguageRuntime::GetClassDescriptorFromClassName(
+    const ConstString &class_name) {
+  ISAToDescriptorIterator pos = GetDescriptorIterator(class_name);
+  if (pos != m_isa_to_descriptor.end())
+    return pos->second;
+  return ClassDescriptorSP();
 }
 
 ObjCLanguageRuntime::ClassDescriptorSP
-ObjCLanguageRuntime::GetClassDescriptor (ValueObject& valobj)
-{
-    ClassDescriptorSP objc_class_sp;
-    // if we get an invalid VO (which might still happen when playing around
-    // with pointers returned by the expression parser, don't consider this
-    // a valid ObjC object)
-    if (valobj.GetCompilerType().IsValid())
-    {
-        addr_t isa_pointer = valobj.GetPointerValue();
-        if (isa_pointer != LLDB_INVALID_ADDRESS)
-        {
-            ExecutionContext exe_ctx (valobj.GetExecutionContextRef());
-            
-            Process *process = exe_ctx.GetProcessPtr();
-            if (process)
-            {
-                Error error;
-                ObjCISA isa = process->ReadPointerFromMemory(isa_pointer, error);
-                if (isa != LLDB_INVALID_ADDRESS)
-                    objc_class_sp = GetClassDescriptorFromISA (isa);
-            }
-        }
+ObjCLanguageRuntime::GetClassDescriptor(ValueObject &valobj) {
+  ClassDescriptorSP objc_class_sp;
+  // if we get an invalid VO (which might still happen when playing around
+  // with pointers returned by the expression parser, don't consider this
+  // a valid ObjC object)
+  if (valobj.GetCompilerType().IsValid()) {
+    addr_t isa_pointer = valobj.GetPointerValue();
+    if (isa_pointer != LLDB_INVALID_ADDRESS) {
+      ExecutionContext exe_ctx(valobj.GetExecutionContextRef());
+
+      Process *process = exe_ctx.GetProcessPtr();
+      if (process) {
+        Error error;
+        ObjCISA isa = process->ReadPointerFromMemory(isa_pointer, error);
+        if (isa != LLDB_INVALID_ADDRESS)
+          objc_class_sp = GetClassDescriptorFromISA(isa);
+      }
     }
-    return objc_class_sp;
+  }
+  return objc_class_sp;
 }
 
 ObjCLanguageRuntime::ClassDescriptorSP
-ObjCLanguageRuntime::GetNonKVOClassDescriptor (ValueObject& valobj)
-{
-    ObjCLanguageRuntime::ClassDescriptorSP objc_class_sp (GetClassDescriptor (valobj));
-    if (objc_class_sp)
-    {
-        if (!objc_class_sp->IsKVO())
-            return objc_class_sp;
-        
-        ClassDescriptorSP non_kvo_objc_class_sp(objc_class_sp->GetSuperclass());
-        if (non_kvo_objc_class_sp && non_kvo_objc_class_sp->IsValid())
-            return non_kvo_objc_class_sp;
-    }
-    return ClassDescriptorSP();
+ObjCLanguageRuntime::GetNonKVOClassDescriptor(ValueObject &valobj) {
+  ObjCLanguageRuntime::ClassDescriptorSP objc_class_sp(
+      GetClassDescriptor(valobj));
+  if (objc_class_sp) {
+    if (!objc_class_sp->IsKVO())
+      return objc_class_sp;
+
+    ClassDescriptorSP non_kvo_objc_class_sp(objc_class_sp->GetSuperclass());
+    if (non_kvo_objc_class_sp && non_kvo_objc_class_sp->IsValid())
+      return non_kvo_objc_class_sp;
+  }
+  return ClassDescriptorSP();
 }
 
-
 ObjCLanguageRuntime::ClassDescriptorSP
-ObjCLanguageRuntime::GetClassDescriptorFromISA (ObjCISA isa)
-{
-    if (isa)
-    {
-        UpdateISAToDescriptorMap();
-        ObjCLanguageRuntime::ISAToDescriptorIterator pos = m_isa_to_descriptor.find(isa);    
-        if (pos != m_isa_to_descriptor.end())
-            return pos->second;
-    }
-    return ClassDescriptorSP();
+ObjCLanguageRuntime::GetClassDescriptorFromISA(ObjCISA isa) {
+  if (isa) {
+    UpdateISAToDescriptorMap();
+    ObjCLanguageRuntime::ISAToDescriptorIterator pos =
+        m_isa_to_descriptor.find(isa);
+    if (pos != m_isa_to_descriptor.end())
+      return pos->second;
+  }
+  return ClassDescriptorSP();
 }
 
 ObjCLanguageRuntime::ClassDescriptorSP
-ObjCLanguageRuntime::GetNonKVOClassDescriptor (ObjCISA isa)
-{
-    if (isa)
-    {
-        ClassDescriptorSP objc_class_sp = GetClassDescriptorFromISA (isa);
-        if (objc_class_sp && objc_class_sp->IsValid())
-        {
-            if (!objc_class_sp->IsKVO())
-                return objc_class_sp;
-
-            ClassDescriptorSP non_kvo_objc_class_sp(objc_class_sp->GetSuperclass());
-            if (non_kvo_objc_class_sp && non_kvo_objc_class_sp->IsValid())
-                return non_kvo_objc_class_sp;
-        }
+ObjCLanguageRuntime::GetNonKVOClassDescriptor(ObjCISA isa) {
+  if (isa) {
+    ClassDescriptorSP objc_class_sp = GetClassDescriptorFromISA(isa);
+    if (objc_class_sp && objc_class_sp->IsValid()) {
+      if (!objc_class_sp->IsKVO())
+        return objc_class_sp;
+
+      ClassDescriptorSP non_kvo_objc_class_sp(objc_class_sp->GetSuperclass());
+      if (non_kvo_objc_class_sp && non_kvo_objc_class_sp->IsValid())
+        return non_kvo_objc_class_sp;
     }
-    return ClassDescriptorSP();
+  }
+  return ClassDescriptorSP();
 }
 
-
 CompilerType
-ObjCLanguageRuntime::EncodingToType::RealizeType (const char* name, bool for_expression)
-{
-    if (m_scratch_ast_ctx_ap)
-        return RealizeType(*m_scratch_ast_ctx_ap, name, for_expression);
-    return CompilerType();
+ObjCLanguageRuntime::EncodingToType::RealizeType(const char *name,
+                                                 bool for_expression) {
+  if (m_scratch_ast_ctx_ap)
+    return RealizeType(*m_scratch_ast_ctx_ap, name, for_expression);
+  return CompilerType();
 }
 
-CompilerType
-ObjCLanguageRuntime::EncodingToType::RealizeType (ClangASTContext& ast_ctx, const char* name, bool for_expression)
-{
-    clang::ASTContext *clang_ast = ast_ctx.getASTContext();
-    if (!clang_ast)
-        return CompilerType();
-    return RealizeType(*clang_ast, name, for_expression);
+CompilerType ObjCLanguageRuntime::EncodingToType::RealizeType(
+    ClangASTContext &ast_ctx, const char *name, bool for_expression) {
+  clang::ASTContext *clang_ast = ast_ctx.getASTContext();
+  if (!clang_ast)
+    return CompilerType();
+  return RealizeType(*clang_ast, name, for_expression);
 }
 
 ObjCLanguageRuntime::EncodingToType::~EncodingToType() {}
 
-ObjCLanguageRuntime::EncodingToTypeSP
-ObjCLanguageRuntime::GetEncodingToType ()
-{
-    return nullptr;
-}
-
-bool
-ObjCLanguageRuntime::GetTypeBitSize (const CompilerType& compiler_type,
-                                     uint64_t &size)
-{
-    void *opaque_ptr = compiler_type.GetOpaqueQualType();
-    size = m_type_size_cache.Lookup(opaque_ptr);
-    // an ObjC object will at least have an ISA, so 0 is definitely not OK
-    if (size > 0)
-        return true;
-    
-    ClassDescriptorSP class_descriptor_sp = GetClassDescriptorFromClassName(compiler_type.GetTypeName());
-    if (!class_descriptor_sp)
-        return false;
-    
-    int32_t max_offset = INT32_MIN;
-    uint64_t sizeof_max = 0;
-    bool found = false;
-    
-    for (size_t idx = 0;
-         idx < class_descriptor_sp->GetNumIVars();
-         idx++)
-    {
-        const auto& ivar = class_descriptor_sp->GetIVarAtIndex(idx);
-        int32_t cur_offset = ivar.m_offset;
-        if (cur_offset > max_offset)
-        {
-            max_offset = cur_offset;
-            sizeof_max = ivar.m_size;
-            found = true;
-        }
-    }
-    
-    size = 8 * (max_offset + sizeof_max);
-    if (found)
-        m_type_size_cache.Insert(opaque_ptr, size);
-    
-    return found;
+ObjCLanguageRuntime::EncodingToTypeSP ObjCLanguageRuntime::GetEncodingToType() {
+  return nullptr;
+}
+
+bool ObjCLanguageRuntime::GetTypeBitSize(const CompilerType &compiler_type,
+                                         uint64_t &size) {
+  void *opaque_ptr = compiler_type.GetOpaqueQualType();
+  size = m_type_size_cache.Lookup(opaque_ptr);
+  // an ObjC object will at least have an ISA, so 0 is definitely not OK
+  if (size > 0)
+    return true;
+
+  ClassDescriptorSP class_descriptor_sp =
+      GetClassDescriptorFromClassName(compiler_type.GetTypeName());
+  if (!class_descriptor_sp)
+    return false;
+
+  int32_t max_offset = INT32_MIN;
+  uint64_t sizeof_max = 0;
+  bool found = false;
+
+  for (size_t idx = 0; idx < class_descriptor_sp->GetNumIVars(); idx++) {
+    const auto &ivar = class_descriptor_sp->GetIVarAtIndex(idx);
+    int32_t cur_offset = ivar.m_offset;
+    if (cur_offset > max_offset) {
+      max_offset = cur_offset;
+      sizeof_max = ivar.m_size;
+      found = true;
+    }
+  }
+
+  size = 8 * (max_offset + sizeof_max);
+  if (found)
+    m_type_size_cache.Insert(opaque_ptr, size);
+
+  return found;
 }
 
 //------------------------------------------------------------------
 // Exception breakpoint Precondition class for ObjC:
 //------------------------------------------------------------------
-void
-ObjCLanguageRuntime::ObjCExceptionPrecondition::AddClassName(const char *class_name)
-{
-    m_class_names.insert(class_name);
+void ObjCLanguageRuntime::ObjCExceptionPrecondition::AddClassName(
+    const char *class_name) {
+  m_class_names.insert(class_name);
 }
 
-ObjCLanguageRuntime::ObjCExceptionPrecondition::ObjCExceptionPrecondition()
-{
-}
+ObjCLanguageRuntime::ObjCExceptionPrecondition::ObjCExceptionPrecondition() {}
 
-bool
-ObjCLanguageRuntime::ObjCExceptionPrecondition::EvaluatePrecondition(StoppointCallbackContext &context)
-{
-    return true;
+bool ObjCLanguageRuntime::ObjCExceptionPrecondition::EvaluatePrecondition(
+    StoppointCallbackContext &context) {
+  return true;
 }
 
-void
-ObjCLanguageRuntime::ObjCExceptionPrecondition::GetDescription(Stream &stream, lldb::DescriptionLevel level)
-{
-}
+void ObjCLanguageRuntime::ObjCExceptionPrecondition::GetDescription(
+    Stream &stream, lldb::DescriptionLevel level) {}
 
-Error
-ObjCLanguageRuntime::ObjCExceptionPrecondition::ConfigurePrecondition(Args &args)
-{
-    Error error;
-    if (args.GetArgumentCount() > 0)
-        error.SetErrorString("The ObjC Exception breakpoint doesn't support extra options.");
-    return error;
+Error ObjCLanguageRuntime::ObjCExceptionPrecondition::ConfigurePrecondition(
+    Args &args) {
+  Error error;
+  if (args.GetArgumentCount() > 0)
+    error.SetErrorString(
+        "The ObjC Exception breakpoint doesn't support extra options.");
+  return error;
 }

Modified: lldb/trunk/source/Target/OperatingSystem.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/OperatingSystem.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/OperatingSystem.cpp (original)
+++ lldb/trunk/source/Target/OperatingSystem.cpp Tue Sep  6 15:57:50 2016
@@ -18,45 +18,42 @@
 using namespace lldb;
 using namespace lldb_private;
 
-OperatingSystem*
-OperatingSystem::FindPlugin (Process *process, const char *plugin_name)
-{
-    OperatingSystemCreateInstance create_callback = nullptr;
-    if (plugin_name)
-    {
-        ConstString const_plugin_name(plugin_name);
-        create_callback  = PluginManager::GetOperatingSystemCreateCallbackForPluginName (const_plugin_name);
-        if (create_callback)
-        {
-            std::unique_ptr<OperatingSystem> instance_ap(create_callback(process, true));
-            if (instance_ap)
-                return instance_ap.release();
-        }
+OperatingSystem *OperatingSystem::FindPlugin(Process *process,
+                                             const char *plugin_name) {
+  OperatingSystemCreateInstance create_callback = nullptr;
+  if (plugin_name) {
+    ConstString const_plugin_name(plugin_name);
+    create_callback =
+        PluginManager::GetOperatingSystemCreateCallbackForPluginName(
+            const_plugin_name);
+    if (create_callback) {
+      std::unique_ptr<OperatingSystem> instance_ap(
+          create_callback(process, true));
+      if (instance_ap)
+        return instance_ap.release();
     }
-    else
-    {
-        for (uint32_t idx = 0; (create_callback = PluginManager::GetOperatingSystemCreateCallbackAtIndex(idx)) != nullptr; ++idx)
-        {
-            std::unique_ptr<OperatingSystem> instance_ap(create_callback(process, false));
-            if (instance_ap)
-                return instance_ap.release();
-        }
+  } else {
+    for (uint32_t idx = 0;
+         (create_callback =
+              PluginManager::GetOperatingSystemCreateCallbackAtIndex(idx)) !=
+         nullptr;
+         ++idx) {
+      std::unique_ptr<OperatingSystem> instance_ap(
+          create_callback(process, false));
+      if (instance_ap)
+        return instance_ap.release();
     }
-    return nullptr;
+  }
+  return nullptr;
 }
 
-
-OperatingSystem::OperatingSystem (Process *process) :
-    m_process (process)
-{
-}
+OperatingSystem::OperatingSystem(Process *process) : m_process(process) {}
 
 OperatingSystem::~OperatingSystem() = default;
 
-bool
-OperatingSystem::IsOperatingSystemPluginThread (const lldb::ThreadSP &thread_sp)
-{
-    if (thread_sp)
-        return thread_sp->IsOperatingSystemPluginThread();
-    return false;
+bool OperatingSystem::IsOperatingSystemPluginThread(
+    const lldb::ThreadSP &thread_sp) {
+  if (thread_sp)
+    return thread_sp->IsOperatingSystemPluginThread();
+  return false;
 }

Modified: lldb/trunk/source/Target/PathMappingList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/PathMappingList.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/PathMappingList.cpp (original)
+++ lldb/trunk/source/Target/PathMappingList.cpp Tue Sep  6 15:57:50 2016
@@ -26,331 +26,265 @@ using namespace lldb_private;
 //----------------------------------------------------------------------
 // PathMappingList constructor
 //----------------------------------------------------------------------
-PathMappingList::PathMappingList () :
-    m_pairs(),
-    m_callback(nullptr),
-    m_callback_baton(nullptr),
-    m_mod_id(0)
-{
-}
-
-PathMappingList::PathMappingList (ChangedCallback callback,
-                                  void *callback_baton) :
-    m_pairs (),
-    m_callback (callback),
-    m_callback_baton (callback_baton),
-    m_mod_id (0)
-{
-}
-
-PathMappingList::PathMappingList (const PathMappingList &rhs) :
-    m_pairs(rhs.m_pairs),
-    m_callback(nullptr),
-    m_callback_baton(nullptr),
-    m_mod_id(0)
-{
-}
-
-const PathMappingList &
-PathMappingList::operator =(const PathMappingList &rhs)
-{
-    if (this != &rhs)
-    {
-        m_pairs = rhs.m_pairs;
-        m_callback = nullptr;
-        m_callback_baton = nullptr;
-        m_mod_id = rhs.m_mod_id;
-    }
-    return *this;
+PathMappingList::PathMappingList()
+    : m_pairs(), m_callback(nullptr), m_callback_baton(nullptr), m_mod_id(0) {}
+
+PathMappingList::PathMappingList(ChangedCallback callback, void *callback_baton)
+    : m_pairs(), m_callback(callback), m_callback_baton(callback_baton),
+      m_mod_id(0) {}
+
+PathMappingList::PathMappingList(const PathMappingList &rhs)
+    : m_pairs(rhs.m_pairs), m_callback(nullptr), m_callback_baton(nullptr),
+      m_mod_id(0) {}
+
+const PathMappingList &PathMappingList::operator=(const PathMappingList &rhs) {
+  if (this != &rhs) {
+    m_pairs = rhs.m_pairs;
+    m_callback = nullptr;
+    m_callback_baton = nullptr;
+    m_mod_id = rhs.m_mod_id;
+  }
+  return *this;
 }
 
 PathMappingList::~PathMappingList() = default;
 
-void
-PathMappingList::Append (const ConstString &path,
-                         const ConstString &replacement,
-                         bool notify)
-{
-    ++m_mod_id;
-    m_pairs.push_back(pair(path, replacement));
-    if (notify && m_callback)
-        m_callback (*this, m_callback_baton);
-}
-
-void
-PathMappingList::Append (const PathMappingList &rhs, bool notify)
-{
-    ++m_mod_id;
-    if (!rhs.m_pairs.empty())
-    {
-        const_iterator pos, end = rhs.m_pairs.end();
-        for (pos = rhs.m_pairs.begin(); pos != end; ++pos)
-            m_pairs.push_back(*pos);
-        if (notify && m_callback)
-            m_callback (*this, m_callback_baton);
-    }
+void PathMappingList::Append(const ConstString &path,
+                             const ConstString &replacement, bool notify) {
+  ++m_mod_id;
+  m_pairs.push_back(pair(path, replacement));
+  if (notify && m_callback)
+    m_callback(*this, m_callback_baton);
 }
 
-void
-PathMappingList::Insert (const ConstString &path,
-                         const ConstString &replacement,
-                         uint32_t index,
-                         bool notify)
-{
-    ++m_mod_id;
-    iterator insert_iter;
-    if (index >= m_pairs.size())
-        insert_iter = m_pairs.end();
-    else
-        insert_iter = m_pairs.begin() + index;
-    m_pairs.insert(insert_iter, pair(path, replacement));
+void PathMappingList::Append(const PathMappingList &rhs, bool notify) {
+  ++m_mod_id;
+  if (!rhs.m_pairs.empty()) {
+    const_iterator pos, end = rhs.m_pairs.end();
+    for (pos = rhs.m_pairs.begin(); pos != end; ++pos)
+      m_pairs.push_back(*pos);
     if (notify && m_callback)
-        m_callback (*this, m_callback_baton);
+      m_callback(*this, m_callback_baton);
+  }
 }
 
-bool
-PathMappingList::Replace (const ConstString &path,
-                          const ConstString &replacement,
-                          uint32_t index,
-                          bool notify)
-{
-    iterator insert_iter;
-    if (index >= m_pairs.size())
-        return false;
-    ++m_mod_id;
-    m_pairs[index] = pair(path, replacement);
-    if (notify && m_callback)
-        m_callback (*this, m_callback_baton);
-    return true;
+void PathMappingList::Insert(const ConstString &path,
+                             const ConstString &replacement, uint32_t index,
+                             bool notify) {
+  ++m_mod_id;
+  iterator insert_iter;
+  if (index >= m_pairs.size())
+    insert_iter = m_pairs.end();
+  else
+    insert_iter = m_pairs.begin() + index;
+  m_pairs.insert(insert_iter, pair(path, replacement));
+  if (notify && m_callback)
+    m_callback(*this, m_callback_baton);
+}
+
+bool PathMappingList::Replace(const ConstString &path,
+                              const ConstString &replacement, uint32_t index,
+                              bool notify) {
+  iterator insert_iter;
+  if (index >= m_pairs.size())
+    return false;
+  ++m_mod_id;
+  m_pairs[index] = pair(path, replacement);
+  if (notify && m_callback)
+    m_callback(*this, m_callback_baton);
+  return true;
 }
 
-bool
-PathMappingList::Remove (size_t index, bool notify)
-{
-    if (index >= m_pairs.size())
-        return false;
+bool PathMappingList::Remove(size_t index, bool notify) {
+  if (index >= m_pairs.size())
+    return false;
 
-    ++m_mod_id;
-    iterator iter = m_pairs.begin() + index;
-    m_pairs.erase(iter);
-    if (notify && m_callback)
-        m_callback (*this, m_callback_baton);
-    return true;
+  ++m_mod_id;
+  iterator iter = m_pairs.begin() + index;
+  m_pairs.erase(iter);
+  if (notify && m_callback)
+    m_callback(*this, m_callback_baton);
+  return true;
 }
 
 // For clients which do not need the pair index dumped, pass a pair_index >= 0
 // to only dump the indicated pair.
-void
-PathMappingList::Dump (Stream *s, int pair_index)
-{
-    unsigned int numPairs = m_pairs.size();
-
-    if (pair_index < 0)
-    {
-        unsigned int index;
-        for (index = 0; index < numPairs; ++index)
-            s->Printf("[%d] \"%s\" -> \"%s\"\n",
-                      index, m_pairs[index].first.GetCString(), m_pairs[index].second.GetCString());
-    }
-    else
-    {
-        if (static_cast<unsigned int>(pair_index) < numPairs)
-            s->Printf("%s -> %s",
-                      m_pairs[pair_index].first.GetCString(), m_pairs[pair_index].second.GetCString());
-    }
+void PathMappingList::Dump(Stream *s, int pair_index) {
+  unsigned int numPairs = m_pairs.size();
+
+  if (pair_index < 0) {
+    unsigned int index;
+    for (index = 0; index < numPairs; ++index)
+      s->Printf("[%d] \"%s\" -> \"%s\"\n", index,
+                m_pairs[index].first.GetCString(),
+                m_pairs[index].second.GetCString());
+  } else {
+    if (static_cast<unsigned int>(pair_index) < numPairs)
+      s->Printf("%s -> %s", m_pairs[pair_index].first.GetCString(),
+                m_pairs[pair_index].second.GetCString());
+  }
 }
 
-void
-PathMappingList::Clear (bool notify)
-{
-    if (!m_pairs.empty())
-        ++m_mod_id;
-    m_pairs.clear();
-    if (notify && m_callback)
-        m_callback (*this, m_callback_baton);
+void PathMappingList::Clear(bool notify) {
+  if (!m_pairs.empty())
+    ++m_mod_id;
+  m_pairs.clear();
+  if (notify && m_callback)
+    m_callback(*this, m_callback_baton);
 }
 
-bool
-PathMappingList::RemapPath (const ConstString &path, ConstString &new_path) const
-{
-    const char *path_cstr = path.GetCString();
-    
-    if (!path_cstr)
-        return false;
-    
-    const_iterator pos, end = m_pairs.end();
-    for (pos = m_pairs.begin(); pos != end; ++pos)
-    {
-        const size_t prefixLen = pos->first.GetLength();
-
-        if (::strncmp (pos->first.GetCString(), path_cstr, prefixLen) == 0)
-        {
-            std::string new_path_str (pos->second.GetCString());
-            new_path_str.append(path.GetCString() + prefixLen);
-            new_path.SetCString(new_path_str.c_str());
-            return true;
-        }
-    }
+bool PathMappingList::RemapPath(const ConstString &path,
+                                ConstString &new_path) const {
+  const char *path_cstr = path.GetCString();
+
+  if (!path_cstr)
     return false;
-}
 
-bool
-PathMappingList::RemapPath (const char *path, std::string &new_path) const
-{
-    if (m_pairs.empty() || path == nullptr || path[0] == '\0')
-        return false;
-
-    const_iterator pos, end = m_pairs.end();
-    for (pos = m_pairs.begin(); pos != end; ++pos)
-    {
-        const size_t prefix_len = pos->first.GetLength();
-        
-        if (::strncmp (pos->first.GetCString(), path, prefix_len) == 0)
-        {
-            new_path = pos->second.GetCString();
-            new_path.append(path + prefix_len);
-            return true;
-        }
+  const_iterator pos, end = m_pairs.end();
+  for (pos = m_pairs.begin(); pos != end; ++pos) {
+    const size_t prefixLen = pos->first.GetLength();
+
+    if (::strncmp(pos->first.GetCString(), path_cstr, prefixLen) == 0) {
+      std::string new_path_str(pos->second.GetCString());
+      new_path_str.append(path.GetCString() + prefixLen);
+      new_path.SetCString(new_path_str.c_str());
+      return true;
     }
-    return false;
+  }
+  return false;
 }
 
-bool
-PathMappingList::ReverseRemapPath (const ConstString &path, ConstString &new_path) const
-{
-    const char *path_cstr = path.GetCString();
-    if (!path_cstr)
-        return false;
-
-    for (const auto& it : m_pairs)
-    {
-        // FIXME: This should be using FileSpec API's to do the path appending.
-        const size_t prefixLen = it.second.GetLength();
-        if (::strncmp (it.second.GetCString(), path_cstr, prefixLen) == 0)
-        {
-            std::string new_path_str (it.first.GetCString());
-            new_path_str.append(path.GetCString() + prefixLen);
-            new_path.SetCString(new_path_str.c_str());
-            return true;
-        }
-    }
+bool PathMappingList::RemapPath(const char *path, std::string &new_path) const {
+  if (m_pairs.empty() || path == nullptr || path[0] == '\0')
     return false;
-}
 
-bool
-PathMappingList::FindFile (const FileSpec &orig_spec, FileSpec &new_spec) const
-{
-    if (!m_pairs.empty())
-    {
-        char orig_path[PATH_MAX];
-        const size_t orig_path_len = orig_spec.GetPath (orig_path, sizeof(orig_path));
-        if (orig_path_len > 0)
-        {
-            const_iterator pos, end = m_pairs.end();
-            for (pos = m_pairs.begin(); pos != end; ++pos)
-            {
-                const size_t prefix_len = pos->first.GetLength();
-                
-                if (orig_path_len >= prefix_len)
-                {
-                    if (::strncmp (pos->first.GetCString(), orig_path, prefix_len) == 0)
-                    {
-                        new_spec.SetFile(pos->second.GetCString(), false);
-                        new_spec.AppendPathComponent(orig_path+prefix_len);
-                        if (new_spec.Exists())
-                            return true;
-                    }
-                }
-            }
+  const_iterator pos, end = m_pairs.end();
+  for (pos = m_pairs.begin(); pos != end; ++pos) {
+    const size_t prefix_len = pos->first.GetLength();
+
+    if (::strncmp(pos->first.GetCString(), path, prefix_len) == 0) {
+      new_path = pos->second.GetCString();
+      new_path.append(path + prefix_len);
+      return true;
+    }
+  }
+  return false;
+}
+
+bool PathMappingList::ReverseRemapPath(const ConstString &path,
+                                       ConstString &new_path) const {
+  const char *path_cstr = path.GetCString();
+  if (!path_cstr)
+    return false;
+
+  for (const auto &it : m_pairs) {
+    // FIXME: This should be using FileSpec API's to do the path appending.
+    const size_t prefixLen = it.second.GetLength();
+    if (::strncmp(it.second.GetCString(), path_cstr, prefixLen) == 0) {
+      std::string new_path_str(it.first.GetCString());
+      new_path_str.append(path.GetCString() + prefixLen);
+      new_path.SetCString(new_path_str.c_str());
+      return true;
+    }
+  }
+  return false;
+}
+
+bool PathMappingList::FindFile(const FileSpec &orig_spec,
+                               FileSpec &new_spec) const {
+  if (!m_pairs.empty()) {
+    char orig_path[PATH_MAX];
+    const size_t orig_path_len =
+        orig_spec.GetPath(orig_path, sizeof(orig_path));
+    if (orig_path_len > 0) {
+      const_iterator pos, end = m_pairs.end();
+      for (pos = m_pairs.begin(); pos != end; ++pos) {
+        const size_t prefix_len = pos->first.GetLength();
+
+        if (orig_path_len >= prefix_len) {
+          if (::strncmp(pos->first.GetCString(), orig_path, prefix_len) == 0) {
+            new_spec.SetFile(pos->second.GetCString(), false);
+            new_spec.AppendPathComponent(orig_path + prefix_len);
+            if (new_spec.Exists())
+              return true;
+          }
         }
+      }
     }
-    new_spec.Clear();
-    return false;
+  }
+  new_spec.Clear();
+  return false;
 }
 
-bool
-PathMappingList::Replace (const ConstString &path, const ConstString &new_path, bool notify)
-{
-    uint32_t idx = FindIndexForPath (path);
-    if (idx < m_pairs.size())
-    {
-        ++m_mod_id;
-        m_pairs[idx].second = new_path;
-        if (notify && m_callback)
-            m_callback (*this, m_callback_baton);
-        return true;
-    }
-    return false;
+bool PathMappingList::Replace(const ConstString &path,
+                              const ConstString &new_path, bool notify) {
+  uint32_t idx = FindIndexForPath(path);
+  if (idx < m_pairs.size()) {
+    ++m_mod_id;
+    m_pairs[idx].second = new_path;
+    if (notify && m_callback)
+      m_callback(*this, m_callback_baton);
+    return true;
+  }
+  return false;
 }
 
-bool
-PathMappingList::Remove (const ConstString &path, bool notify)
-{
-    iterator pos = FindIteratorForPath (path);
-    if (pos != m_pairs.end())
-    {
-        ++m_mod_id;
-        m_pairs.erase (pos);
-        if (notify && m_callback)
-            m_callback (*this, m_callback_baton);
-        return true;        
-    }
-    return false;
+bool PathMappingList::Remove(const ConstString &path, bool notify) {
+  iterator pos = FindIteratorForPath(path);
+  if (pos != m_pairs.end()) {
+    ++m_mod_id;
+    m_pairs.erase(pos);
+    if (notify && m_callback)
+      m_callback(*this, m_callback_baton);
+    return true;
+  }
+  return false;
 }
 
 PathMappingList::const_iterator
-PathMappingList::FindIteratorForPath (const ConstString &path) const
-{
-    const_iterator pos;
-    const_iterator begin = m_pairs.begin();
-    const_iterator end = m_pairs.end();
-    
-    for (pos = begin; pos != end; ++pos)
-    {
-        if (pos->first == path)
-            break;
-    }
-    return pos;
+PathMappingList::FindIteratorForPath(const ConstString &path) const {
+  const_iterator pos;
+  const_iterator begin = m_pairs.begin();
+  const_iterator end = m_pairs.end();
+
+  for (pos = begin; pos != end; ++pos) {
+    if (pos->first == path)
+      break;
+  }
+  return pos;
 }
 
 PathMappingList::iterator
-PathMappingList::FindIteratorForPath (const ConstString &path)
-{
-    iterator pos;
-    iterator begin = m_pairs.begin();
-    iterator end = m_pairs.end();
-    
-    for (pos = begin; pos != end; ++pos)
-    {
-        if (pos->first == path)
-            break;
-    }
-    return pos;
-}
-
-bool
-PathMappingList::GetPathsAtIndex (uint32_t idx, ConstString &path, ConstString &new_path) const
-{
-    if (idx < m_pairs.size())
-    {
-        path = m_pairs[idx].first;
-        new_path = m_pairs[idx].second;
-        return true;
-    }
-    return false;
+PathMappingList::FindIteratorForPath(const ConstString &path) {
+  iterator pos;
+  iterator begin = m_pairs.begin();
+  iterator end = m_pairs.end();
+
+  for (pos = begin; pos != end; ++pos) {
+    if (pos->first == path)
+      break;
+  }
+  return pos;
+}
+
+bool PathMappingList::GetPathsAtIndex(uint32_t idx, ConstString &path,
+                                      ConstString &new_path) const {
+  if (idx < m_pairs.size()) {
+    path = m_pairs[idx].first;
+    new_path = m_pairs[idx].second;
+    return true;
+  }
+  return false;
 }
 
-uint32_t
-PathMappingList::FindIndexForPath (const ConstString &path) const
-{
-    const_iterator pos;
-    const_iterator begin = m_pairs.begin();
-    const_iterator end = m_pairs.end();
-    
-    for (pos = begin; pos != end; ++pos)
-    {
-        if (pos->first == path)
-            return std::distance (begin, pos);
-    }
-    return UINT32_MAX;
+uint32_t PathMappingList::FindIndexForPath(const ConstString &path) const {
+  const_iterator pos;
+  const_iterator begin = m_pairs.begin();
+  const_iterator end = m_pairs.end();
+
+  for (pos = begin; pos != end; ++pos) {
+    if (pos->first == path)
+      return std::distance(begin, pos);
+  }
+  return UINT32_MAX;
 }

Modified: lldb/trunk/source/Target/Platform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Platform.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Target/Platform.cpp (original)
+++ lldb/trunk/source/Target/Platform.cpp Tue Sep  6 15:57:50 2016
@@ -18,7 +18,7 @@
 #include "llvm/Support/Path.h"
 
 // Project includes
-#include "lldb/Target/Platform.h"
+#include "Utility/ModuleCache.h"
 #include "lldb/Breakpoint/BreakpointIDList.h"
 #include "lldb/Breakpoint/BreakpointLocation.h"
 #include "lldb/Core/DataBufferHeap.h"
@@ -37,11 +37,11 @@
 #include "lldb/Interpreter/OptionValueProperties.h"
 #include "lldb/Interpreter/Property.h"
 #include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Target/Platform.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Target/UnixSignals.h"
 #include "lldb/Utility/Utils.h"
-#include "Utility/ModuleCache.h"
 
 // Define these constants from POSIX mman.h rather than include the file
 // so that they will be correct even when compiled on Linux.
@@ -55,92 +55,72 @@ static uint32_t g_initialize_count = 0;
 
 // Use a singleton function for g_local_platform_sp to avoid init
 // constructors since LLDB is often part of a shared library
-static PlatformSP&
-GetHostPlatformSP ()
-{
-    static PlatformSP g_platform_sp;
-    return g_platform_sp;
+static PlatformSP &GetHostPlatformSP() {
+  static PlatformSP g_platform_sp;
+  return g_platform_sp;
 }
 
-const char *
-Platform::GetHostPlatformName ()
-{
-    return "host";
-}
+const char *Platform::GetHostPlatformName() { return "host"; }
 
 namespace {
 
-    PropertyDefinition
-    g_properties[] =
-    {
-        { "use-module-cache"      , OptionValue::eTypeBoolean , true,  true, nullptr, nullptr, "Use module cache." },
-        { "module-cache-directory", OptionValue::eTypeFileSpec, true,  0 ,   nullptr, nullptr, "Root directory for cached modules." },
-        {  nullptr                , OptionValue::eTypeInvalid , false, 0,    nullptr, nullptr, nullptr }
-    };
+PropertyDefinition g_properties[] = {
+    {"use-module-cache", OptionValue::eTypeBoolean, true, true, nullptr,
+     nullptr, "Use module cache."},
+    {"module-cache-directory", OptionValue::eTypeFileSpec, true, 0, nullptr,
+     nullptr, "Root directory for cached modules."},
+    {nullptr, OptionValue::eTypeInvalid, false, 0, nullptr, nullptr, nullptr}};
 
-    enum
-    {
-        ePropertyUseModuleCache,
-        ePropertyModuleCacheDirectory
-    };
-
-}  // namespace
+enum { ePropertyUseModuleCache, ePropertyModuleCacheDirectory };
 
+} // namespace
 
-ConstString
-PlatformProperties::GetSettingName ()
-{
-    static ConstString g_setting_name("platform");
-    return g_setting_name;
+ConstString PlatformProperties::GetSettingName() {
+  static ConstString g_setting_name("platform");
+  return g_setting_name;
 }
 
-PlatformProperties::PlatformProperties ()
-{
-    m_collection_sp.reset (new OptionValueProperties (GetSettingName ()));
-    m_collection_sp->Initialize (g_properties);
+PlatformProperties::PlatformProperties() {
+  m_collection_sp.reset(new OptionValueProperties(GetSettingName()));
+  m_collection_sp->Initialize(g_properties);
 
-    auto module_cache_dir = GetModuleCacheDirectory ();
-    if (module_cache_dir)
-        return;
+  auto module_cache_dir = GetModuleCacheDirectory();
+  if (module_cache_dir)
+    return;
 
-    llvm::SmallString<64> user_home_dir;
-    if (!llvm::sys::path::home_directory (user_home_dir))
-        return;
+  llvm::SmallString<64> user_home_dir;
+  if (!llvm::sys::path::home_directory(user_home_dir))
+    return;
 
-    module_cache_dir = FileSpec (user_home_dir.c_str(), false);
-    module_cache_dir.AppendPathComponent (".lldb");
-    module_cache_dir.AppendPathComponent ("module_cache");
-    SetModuleCacheDirectory (module_cache_dir);
+  module_cache_dir = FileSpec(user_home_dir.c_str(), false);
+  module_cache_dir.AppendPathComponent(".lldb");
+  module_cache_dir.AppendPathComponent("module_cache");
+  SetModuleCacheDirectory(module_cache_dir);
 }
 
-bool
-PlatformProperties::GetUseModuleCache () const
-{
-    const auto idx = ePropertyUseModuleCache;
-    return m_collection_sp->GetPropertyAtIndexAsBoolean (
-        nullptr, idx, g_properties[idx].default_uint_value != 0);
+bool PlatformProperties::GetUseModuleCache() const {
+  const auto idx = ePropertyUseModuleCache;
+  return m_collection_sp->GetPropertyAtIndexAsBoolean(
+      nullptr, idx, g_properties[idx].default_uint_value != 0);
 }
 
-bool
-PlatformProperties::SetUseModuleCache (bool use_module_cache)
-{
-    return m_collection_sp->SetPropertyAtIndexAsBoolean (nullptr, ePropertyUseModuleCache, use_module_cache);
+bool PlatformProperties::SetUseModuleCache(bool use_module_cache) {
+  return m_collection_sp->SetPropertyAtIndexAsBoolean(
+      nullptr, ePropertyUseModuleCache, use_module_cache);
 }
 
-FileSpec
-PlatformProperties::GetModuleCacheDirectory () const
-{
-    return m_collection_sp->GetPropertyAtIndexAsFileSpec (nullptr, ePropertyModuleCacheDirectory);
+FileSpec PlatformProperties::GetModuleCacheDirectory() const {
+  return m_collection_sp->GetPropertyAtIndexAsFileSpec(
+      nullptr, ePropertyModuleCacheDirectory);
 }
 
-bool
-PlatformProperties::SetModuleCacheDirectory (const FileSpec& dir_spec)
-{
-    return m_collection_sp->SetPropertyAtIndexAsFileSpec (nullptr, ePropertyModuleCacheDirectory, dir_spec);
+bool PlatformProperties::SetModuleCacheDirectory(const FileSpec &dir_spec) {
+  return m_collection_sp->SetPropertyAtIndexAsFileSpec(
+      nullptr, ePropertyModuleCacheDirectory, dir_spec);
 }
 
 //------------------------------------------------------------------
-/// Get the native host platform plug-in. 
+/// Get the native host platform plug-in.
 ///
 /// There should only be one of these for each host that LLDB runs
 /// upon that should be statically compiled in and registered using
@@ -149,89 +129,66 @@ PlatformProperties::SetModuleCacheDirect
 /// This platform will be used as the default platform when launching
 /// or attaching to processes unless another platform is specified.
 //------------------------------------------------------------------
-PlatformSP
-Platform::GetHostPlatform ()
-{
-    return GetHostPlatformSP ();
-}
+PlatformSP Platform::GetHostPlatform() { return GetHostPlatformSP(); }
 
-static std::vector<PlatformSP> &
-GetPlatformList()
-{
-    static std::vector<PlatformSP> g_platform_list;
-    return g_platform_list;
+static std::vector<PlatformSP> &GetPlatformList() {
+  static std::vector<PlatformSP> g_platform_list;
+  return g_platform_list;
 }
 
-static std::recursive_mutex &
-GetPlatformListMutex()
-{
-    static std::recursive_mutex g_mutex;
-    return g_mutex;
+static std::recursive_mutex &GetPlatformListMutex() {
+  static std::recursive_mutex g_mutex;
+  return g_mutex;
 }
 
-void
-Platform::Initialize ()
-{
-    g_initialize_count++;
-}
+void Platform::Initialize() { g_initialize_count++; }
 
-void
-Platform::Terminate ()
-{
-    if (g_initialize_count > 0)
-    {
-        if (--g_initialize_count == 0)
-        {
-            std::lock_guard<std::recursive_mutex> guard(GetPlatformListMutex());
-            GetPlatformList().clear();
-        }
+void Platform::Terminate() {
+  if (g_initialize_count > 0) {
+    if (--g_initialize_count == 0) {
+      std::lock_guard<std::recursive_mutex> guard(GetPlatformListMutex());
+      GetPlatformList().clear();
     }
+  }
 }
 
-const PlatformPropertiesSP &
-Platform::GetGlobalPlatformProperties ()
-{
-    static const auto g_settings_sp (std::make_shared<PlatformProperties> ());
-    return g_settings_sp;
+const PlatformPropertiesSP &Platform::GetGlobalPlatformProperties() {
+  static const auto g_settings_sp(std::make_shared<PlatformProperties>());
+  return g_settings_sp;
 }
 
-void
-Platform::SetHostPlatform (const lldb::PlatformSP &platform_sp)
-{
-    // The native platform should use its static void Platform::Initialize()
-    // function to register itself as the native platform.
-    GetHostPlatformSP () = platform_sp;
+void Platform::SetHostPlatform(const lldb::PlatformSP &platform_sp) {
+  // The native platform should use its static void Platform::Initialize()
+  // function to register itself as the native platform.
+  GetHostPlatformSP() = platform_sp;
 
-    if (platform_sp)
-    {
-        std::lock_guard<std::recursive_mutex> guard(GetPlatformListMutex());
-        GetPlatformList().push_back(platform_sp);
-    }
+  if (platform_sp) {
+    std::lock_guard<std::recursive_mutex> guard(GetPlatformListMutex());
+    GetPlatformList().push_back(platform_sp);
+  }
 }
 
-Error
-Platform::GetFileWithUUID (const FileSpec &platform_file, 
-                           const UUID *uuid_ptr,
-                           FileSpec &local_file)
-{
-    // Default to the local case
-    local_file = platform_file;
-    return Error();
+Error Platform::GetFileWithUUID(const FileSpec &platform_file,
+                                const UUID *uuid_ptr, FileSpec &local_file) {
+  // Default to the local case
+  local_file = platform_file;
+  return Error();
 }
 
 FileSpecList
-Platform::LocateExecutableScriptingResources (Target *target, Module &module, Stream* feedback_stream)
-{
-    return FileSpecList();
+Platform::LocateExecutableScriptingResources(Target *target, Module &module,
+                                             Stream *feedback_stream) {
+  return FileSpecList();
 }
 
-//PlatformSP
-//Platform::FindPlugin (Process *process, const ConstString &plugin_name)
+// PlatformSP
+// Platform::FindPlugin (Process *process, const ConstString &plugin_name)
 //{
 //    PlatformCreateInstance create_callback = nullptr;
 //    if (plugin_name)
 //    {
-//        create_callback  = PluginManager::GetPlatformCreateCallbackForPluginName (plugin_name);
+//        create_callback  =
+//        PluginManager::GetPlatformCreateCallbackForPluginName (plugin_name);
 //        if (create_callback)
 //        {
 //            ArchSpec arch;
@@ -246,7 +203,9 @@ Platform::LocateExecutableScriptingResou
 //    }
 //    else
 //    {
-//        for (uint32_t idx = 0; (create_callback = PluginManager::GetPlatformCreateCallbackAtIndex(idx)) != nullptr; ++idx)
+//        for (uint32_t idx = 0; (create_callback =
+//        PluginManager::GetPlatformCreateCallbackAtIndex(idx)) != nullptr;
+//        ++idx)
 //        {
 //            PlatformSP platform_sp(create_callback(process, nullptr));
 //            if (platform_sp)
@@ -256,195 +215,162 @@ Platform::LocateExecutableScriptingResou
 //    return PlatformSP();
 //}
 
-Error
-Platform::GetSharedModule (const ModuleSpec &module_spec,
-                           Process* process,
-                           ModuleSP &module_sp,
-                           const FileSpecList *module_search_paths_ptr,
-                           ModuleSP *old_module_sp_ptr,
-                           bool *did_create_ptr)
-{
-    if (IsHost ())
-        return ModuleList::GetSharedModule (module_spec,
-                                            module_sp,
-                                            module_search_paths_ptr,
-                                            old_module_sp_ptr,
-                                            did_create_ptr,
-                                            false);
-
-    return GetRemoteSharedModule (module_spec,
-                                  process,
-                                  module_sp,
-                                  [&](const ModuleSpec &spec)
-                                  {
-                                      Error error = ModuleList::GetSharedModule (
-                                          spec, module_sp, module_search_paths_ptr, old_module_sp_ptr, did_create_ptr, false);
-                                      if (error.Success() && module_sp)
-                                          module_sp->SetPlatformFileSpec(spec.GetFileSpec());
-                                      return error;
-                                  },
-                                  did_create_ptr);
-}
-
-bool
-Platform::GetModuleSpec (const FileSpec& module_file_spec,
-                         const ArchSpec& arch,
-                         ModuleSpec &module_spec)
-{
-    ModuleSpecList module_specs;
-    if (ObjectFile::GetModuleSpecifications (module_file_spec, 0, 0, module_specs) == 0)
-        return false;
-
-    ModuleSpec matched_module_spec;
-    return module_specs.FindMatchingModuleSpec (ModuleSpec (module_file_spec, arch),
-                                                module_spec);
-}
-
-PlatformSP
-Platform::Find (const ConstString &name)
-{
-    if (name)
-    {
-        static ConstString g_host_platform_name ("host");
-        if (name == g_host_platform_name)
-            return GetHostPlatform();
-
-        std::lock_guard<std::recursive_mutex> guard(GetPlatformListMutex());
-        for (const auto &platform_sp : GetPlatformList())
-        {
-            if (platform_sp->GetName() == name)
-                return platform_sp;
-        }
-    }
-    return PlatformSP();
-}
-
-PlatformSP
-Platform::Create (const ConstString &name, Error &error)
-{
-    PlatformCreateInstance create_callback = nullptr;
-    lldb::PlatformSP platform_sp;
-    if (name)
-    {
-        static ConstString g_host_platform_name ("host");
-        if (name == g_host_platform_name)
-            return GetHostPlatform();
-
-        create_callback = PluginManager::GetPlatformCreateCallbackForPluginName (name);
-        if (create_callback)
-            platform_sp = create_callback(true, nullptr);
-        else
-            error.SetErrorStringWithFormat ("unable to find a plug-in for the platform named \"%s\"", name.GetCString());
-    }
-    else
-        error.SetErrorString ("invalid platform name");
-
-    if (platform_sp)
-    {
-        std::lock_guard<std::recursive_mutex> guard(GetPlatformListMutex());
-        GetPlatformList().push_back(platform_sp);
-    }
-
-    return platform_sp;
-}
-
-PlatformSP
-Platform::Create (const ArchSpec &arch, ArchSpec *platform_arch_ptr, Error &error)
-{
-    lldb::PlatformSP platform_sp;
-    if (arch.IsValid())
-    {
-        // Scope for locker
-        {
-            // First try exact arch matches across all platforms already created
-            std::lock_guard<std::recursive_mutex> guard(GetPlatformListMutex());
-            for (const auto &platform_sp : GetPlatformList())
-            {
-                if (platform_sp->IsCompatibleArchitecture(arch, true, platform_arch_ptr))
-                    return platform_sp;
-            }
-
-            // Next try compatible arch matches across all platforms already created
-            for (const auto &platform_sp : GetPlatformList())
-            {
-                if (platform_sp->IsCompatibleArchitecture(arch, false, platform_arch_ptr))
-                    return platform_sp;
-            }
-        }
+Error Platform::GetSharedModule(const ModuleSpec &module_spec, Process *process,
+                                ModuleSP &module_sp,
+                                const FileSpecList *module_search_paths_ptr,
+                                ModuleSP *old_module_sp_ptr,
+                                bool *did_create_ptr) {
+  if (IsHost())
+    return ModuleList::GetSharedModule(
+        module_spec, module_sp, module_search_paths_ptr, old_module_sp_ptr,
+        did_create_ptr, false);
+
+  return GetRemoteSharedModule(module_spec, process, module_sp,
+                               [&](const ModuleSpec &spec) {
+                                 Error error = ModuleList::GetSharedModule(
+                                     spec, module_sp, module_search_paths_ptr,
+                                     old_module_sp_ptr, did_create_ptr, false);
+                                 if (error.Success() && module_sp)
+                                   module_sp->SetPlatformFileSpec(
+                                       spec.GetFileSpec());
+                                 return error;
+                               },
+                               did_create_ptr);
+}
+
+bool Platform::GetModuleSpec(const FileSpec &module_file_spec,
+                             const ArchSpec &arch, ModuleSpec &module_spec) {
+  ModuleSpecList module_specs;
+  if (ObjectFile::GetModuleSpecifications(module_file_spec, 0, 0,
+                                          module_specs) == 0)
+    return false;
 
-        PlatformCreateInstance create_callback;
-        // First try exact arch matches across all platform plug-ins
-        uint32_t idx;
-        for (idx = 0; (create_callback = PluginManager::GetPlatformCreateCallbackAtIndex (idx)); ++idx)
-        {
-            if (create_callback)
-            {
-                platform_sp = create_callback(false, &arch);
-                if (platform_sp && platform_sp->IsCompatibleArchitecture(arch, true, platform_arch_ptr))
-                {
-                    std::lock_guard<std::recursive_mutex> guard(GetPlatformListMutex());
-                    GetPlatformList().push_back(platform_sp);
-                    return platform_sp;
-                }
-            }
-        }
-        // Next try compatible arch matches across all platform plug-ins
-        for (idx = 0; (create_callback = PluginManager::GetPlatformCreateCallbackAtIndex (idx)); ++idx)
-        {
-            if (create_callback)
-            {
-                platform_sp = create_callback(false, &arch);
-                if (platform_sp && platform_sp->IsCompatibleArchitecture(arch, false, platform_arch_ptr))
-                {
-                    std::lock_guard<std::recursive_mutex> guard(GetPlatformListMutex());
-                    GetPlatformList().push_back(platform_sp);
-                    return platform_sp;
-                }
-            }
-        }
-    }
-    else
-        error.SetErrorString ("invalid platform name");
-    if (platform_arch_ptr)
-        platform_arch_ptr->Clear();
-    platform_sp.reset();
-    return platform_sp;
+  ModuleSpec matched_module_spec;
+  return module_specs.FindMatchingModuleSpec(ModuleSpec(module_file_spec, arch),
+                                             module_spec);
+}
+
+PlatformSP Platform::Find(const ConstString &name) {
+  if (name) {
+    static ConstString g_host_platform_name("host");
+    if (name == g_host_platform_name)
+      return GetHostPlatform();
+
+    std::lock_guard<std::recursive_mutex> guard(GetPlatformListMutex());
+    for (const auto &platform_sp : GetPlatformList()) {
+      if (platform_sp->GetName() == name)
+        return platform_sp;
+    }
+  }
+  return PlatformSP();
+}
+
+PlatformSP Platform::Create(const ConstString &name, Error &error) {
+  PlatformCreateInstance create_callback = nullptr;
+  lldb::PlatformSP platform_sp;
+  if (name) {
+    static ConstString g_host_platform_name("host");
+    if (name == g_host_platform_name)
+      return GetHostPlatform();
+
+    create_callback =
+        PluginManager::GetPlatformCreateCallbackForPluginName(name);
+    if (create_callback)
+      platform_sp = create_callback(true, nullptr);
+    else
+      error.SetErrorStringWithFormat(
+          "unable to find a plug-in for the platform named \"%s\"",
+          name.GetCString());
+  } else
+    error.SetErrorString("invalid platform name");
+
+  if (platform_sp) {
+    std::lock_guard<std::recursive_mutex> guard(GetPlatformListMutex());
+    GetPlatformList().push_back(platform_sp);
+  }
+
+  return platform_sp;
+}
+
+PlatformSP Platform::Create(const ArchSpec &arch, ArchSpec *platform_arch_ptr,
+                            Error &error) {
+  lldb::PlatformSP platform_sp;
+  if (arch.IsValid()) {
+    // Scope for locker
+    {
+      // First try exact arch matches across all platforms already created
+      std::lock_guard<std::recursive_mutex> guard(GetPlatformListMutex());
+      for (const auto &platform_sp : GetPlatformList()) {
+        if (platform_sp->IsCompatibleArchitecture(arch, true,
+                                                  platform_arch_ptr))
+          return platform_sp;
+      }
+
+      // Next try compatible arch matches across all platforms already created
+      for (const auto &platform_sp : GetPlatformList()) {
+        if (platform_sp->IsCompatibleArchitecture(arch, false,
+                                                  platform_arch_ptr))
+          return platform_sp;
+      }
+    }
+
+    PlatformCreateInstance create_callback;
+    // First try exact arch matches across all platform plug-ins
+    uint32_t idx;
+    for (idx = 0; (create_callback =
+                       PluginManager::GetPlatformCreateCallbackAtIndex(idx));
+         ++idx) {
+      if (create_callback) {
+        platform_sp = create_callback(false, &arch);
+        if (platform_sp &&
+            platform_sp->IsCompatibleArchitecture(arch, true,
+                                                  platform_arch_ptr)) {
+          std::lock_guard<std::recursive_mutex> guard(GetPlatformListMutex());
+          GetPlatformList().push_back(platform_sp);
+          return platform_sp;
+        }
+      }
+    }
+    // Next try compatible arch matches across all platform plug-ins
+    for (idx = 0; (create_callback =
+                       PluginManager::GetPlatformCreateCallbackAtIndex(idx));
+         ++idx) {
+      if (create_callback) {
+        platform_sp = create_callback(false, &arch);
+        if (platform_sp &&
+            platform_sp->IsCompatibleArchitecture(arch, false,
+                                                  platform_arch_ptr)) {
+          std::lock_guard<std::recursive_mutex> guard(GetPlatformListMutex());
+          GetPlatformList().push_back(platform_sp);
+          return platform_sp;
+        }
+      }
+    }
+  } else
+    error.SetErrorString("invalid platform name");
+  if (platform_arch_ptr)
+    platform_arch_ptr->Clear();
+  platform_sp.reset();
+  return platform_sp;
 }
 
 //------------------------------------------------------------------
 /// Default Constructor
 //------------------------------------------------------------------
 Platform::Platform(bool is_host)
-    : m_is_host(is_host),
-      m_os_version_set_while_connected(false),
-      m_system_arch_set_while_connected(false),
-      m_sdk_sysroot(),
-      m_sdk_build(),
-      m_working_dir(),
-      m_remote_url(),
-      m_name(),
-      m_major_os_version(UINT32_MAX),
-      m_minor_os_version(UINT32_MAX),
-      m_update_os_version(UINT32_MAX),
-      m_system_arch(),
-      m_mutex(),
-      m_uid_map(),
-      m_gid_map(),
-      m_max_uid_name_len(0),
-      m_max_gid_name_len(0),
-      m_supports_rsync(false),
-      m_rsync_opts(),
-      m_rsync_prefix(),
-      m_supports_ssh(false),
-      m_ssh_opts(),
-      m_ignores_remote_hostname(false),
-      m_trap_handlers(),
+    : m_is_host(is_host), m_os_version_set_while_connected(false),
+      m_system_arch_set_while_connected(false), m_sdk_sysroot(), m_sdk_build(),
+      m_working_dir(), m_remote_url(), m_name(), m_major_os_version(UINT32_MAX),
+      m_minor_os_version(UINT32_MAX), m_update_os_version(UINT32_MAX),
+      m_system_arch(), m_mutex(), m_uid_map(), m_gid_map(),
+      m_max_uid_name_len(0), m_max_gid_name_len(0), m_supports_rsync(false),
+      m_rsync_opts(), m_rsync_prefix(), m_supports_ssh(false), m_ssh_opts(),
+      m_ignores_remote_hostname(false), m_trap_handlers(),
       m_calculated_trap_handlers(false),
-      m_module_cache(llvm::make_unique<ModuleCache>())
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
-    if (log)
-        log->Printf("%p Platform::Platform()", static_cast<void *>(this));
+      m_module_cache(llvm::make_unique<ModuleCache>()) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
+  if (log)
+    log->Printf("%p Platform::Platform()", static_cast<void *>(this));
 }
 
 //------------------------------------------------------------------
@@ -453,1758 +379,1506 @@ Platform::Platform(bool is_host)
 /// The destructor is virtual since this class is designed to be
 /// inherited from by the plug-in instance.
 //------------------------------------------------------------------
-Platform::~Platform()
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
-    if (log)
-        log->Printf ("%p Platform::~Platform()", static_cast<void*>(this));
+Platform::~Platform() {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
+  if (log)
+    log->Printf("%p Platform::~Platform()", static_cast<void *>(this));
+}
+
+void Platform::GetStatus(Stream &strm) {
+  uint32_t major = UINT32_MAX;
+  uint32_t minor = UINT32_MAX;
+  uint32_t update = UINT32_MAX;
+  std::string s;
+  strm.Printf("  Platform: %s\n", GetPluginName().GetCString());
+
+  ArchSpec arch(GetSystemArchitecture());
+  if (arch.IsValid()) {
+    if (!arch.GetTriple().str().empty()) {
+      strm.Printf("    Triple: ");
+      arch.DumpTriple(strm);
+      strm.EOL();
+    }
+  }
+
+  if (GetOSVersion(major, minor, update)) {
+    strm.Printf("OS Version: %u", major);
+    if (minor != UINT32_MAX)
+      strm.Printf(".%u", minor);
+    if (update != UINT32_MAX)
+      strm.Printf(".%u", update);
+
+    if (GetOSBuildString(s))
+      strm.Printf(" (%s)", s.c_str());
+
+    strm.EOL();
+  }
+
+  if (GetOSKernelDescription(s))
+    strm.Printf("    Kernel: %s\n", s.c_str());
+
+  if (IsHost()) {
+    strm.Printf("  Hostname: %s\n", GetHostname());
+  } else {
+    const bool is_connected = IsConnected();
+    if (is_connected)
+      strm.Printf("  Hostname: %s\n", GetHostname());
+    strm.Printf(" Connected: %s\n", is_connected ? "yes" : "no");
+  }
+
+  if (GetWorkingDirectory()) {
+    strm.Printf("WorkingDir: %s\n", GetWorkingDirectory().GetCString());
+  }
+  if (!IsConnected())
+    return;
+
+  std::string specific_info(GetPlatformSpecificConnectionInformation());
+
+  if (!specific_info.empty())
+    strm.Printf("Platform-specific connection: %s\n", specific_info.c_str());
+}
+
+bool Platform::GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update,
+                            Process *process) {
+  std::lock_guard<std::mutex> guard(m_mutex);
+
+  bool success = m_major_os_version != UINT32_MAX;
+  if (IsHost()) {
+    if (!success) {
+      // We have a local host platform
+      success = HostInfo::GetOSVersion(m_major_os_version, m_minor_os_version,
+                                       m_update_os_version);
+      m_os_version_set_while_connected = success;
+    }
+  } else {
+    // We have a remote platform. We can only fetch the remote
+    // OS version if we are connected, and we don't want to do it
+    // more than once.
+
+    const bool is_connected = IsConnected();
+
+    bool fetch = false;
+    if (success) {
+      // We have valid OS version info, check to make sure it wasn't
+      // manually set prior to connecting. If it was manually set prior
+      // to connecting, then lets fetch the actual OS version info
+      // if we are now connected.
+      if (is_connected && !m_os_version_set_while_connected)
+        fetch = true;
+    } else {
+      // We don't have valid OS version info, fetch it if we are connected
+      fetch = is_connected;
+    }
+
+    if (fetch) {
+      success = GetRemoteOSVersion();
+      m_os_version_set_while_connected = success;
+    }
+  }
+
+  if (success) {
+    major = m_major_os_version;
+    minor = m_minor_os_version;
+    update = m_update_os_version;
+  } else if (process) {
+    // Check with the process in case it can answer the question if
+    // a process was provided
+    return process->GetHostOSVersion(major, minor, update);
+  }
+  return success;
 }
 
-void
-Platform::GetStatus (Stream &strm)
-{
-    uint32_t major = UINT32_MAX;
-    uint32_t minor = UINT32_MAX;
-    uint32_t update = UINT32_MAX;
-    std::string s;
-    strm.Printf ("  Platform: %s\n", GetPluginName().GetCString());
-
-    ArchSpec arch (GetSystemArchitecture());
-    if (arch.IsValid())
-    {
-        if (!arch.GetTriple().str().empty())
-        {
-            strm.Printf("    Triple: ");
-            arch.DumpTriple(strm);
-            strm.EOL();
-        }
-    }
-
-    if (GetOSVersion(major, minor, update))
-    {
-        strm.Printf("OS Version: %u", major);
-        if (minor != UINT32_MAX)
-            strm.Printf(".%u", minor);
-        if (update != UINT32_MAX)
-            strm.Printf(".%u", update);
+bool Platform::GetOSBuildString(std::string &s) {
+  s.clear();
 
-        if (GetOSBuildString (s))
-            strm.Printf(" (%s)", s.c_str());
-
-        strm.EOL();
-    }
-
-    if (GetOSKernelDescription (s))
-        strm.Printf("    Kernel: %s\n", s.c_str());
-
-    if (IsHost())
-    {
-        strm.Printf("  Hostname: %s\n", GetHostname());
-    }
-    else
-    {
-        const bool is_connected = IsConnected();
-        if (is_connected)
-            strm.Printf("  Hostname: %s\n", GetHostname());
-        strm.Printf(" Connected: %s\n", is_connected ? "yes" : "no");
-    }
-
-    if (GetWorkingDirectory())
-    {
-        strm.Printf("WorkingDir: %s\n", GetWorkingDirectory().GetCString());
-    }
-    if (!IsConnected())
-        return;
-
-    std::string specific_info(GetPlatformSpecificConnectionInformation());
-    
-    if (!specific_info.empty())
-        strm.Printf("Platform-specific connection: %s\n", specific_info.c_str());
-}
-
-bool
-Platform::GetOSVersion (uint32_t &major, 
-                        uint32_t &minor, 
-                        uint32_t &update,
-                        Process *process)
-{
-    std::lock_guard<std::mutex> guard(m_mutex);
-
-    bool success = m_major_os_version != UINT32_MAX;
-    if (IsHost())
-    {
-        if (!success)
-        {
-            // We have a local host platform
-            success = HostInfo::GetOSVersion(m_major_os_version, m_minor_os_version, m_update_os_version);
-            m_os_version_set_while_connected = success;
-        }
-    }
-    else 
-    {
-        // We have a remote platform. We can only fetch the remote
-        // OS version if we are connected, and we don't want to do it
-        // more than once.
-        
-        const bool is_connected = IsConnected();
-
-        bool fetch = false;
-        if (success)
-        {
-            // We have valid OS version info, check to make sure it wasn't
-            // manually set prior to connecting. If it was manually set prior
-            // to connecting, then lets fetch the actual OS version info
-            // if we are now connected.
-            if (is_connected && !m_os_version_set_while_connected)
-                fetch = true;
-        }
-        else
-        {
-            // We don't have valid OS version info, fetch it if we are connected
-            fetch = is_connected;
-        }
-
-        if (fetch)
-        {
-            success = GetRemoteOSVersion ();
-            m_os_version_set_while_connected = success;
-        }
-    }
-
-    if (success)
-    {
-        major = m_major_os_version;
-        minor = m_minor_os_version;
-        update = m_update_os_version;
-    }
-    else if (process)
-    {
-        // Check with the process in case it can answer the question if
-        // a process was provided
-        return process->GetHostOSVersion(major, minor, update);
-    }
-    return success;
-}
-
-bool
-Platform::GetOSBuildString (std::string &s)
-{
-    s.clear();
-
-    if (IsHost())
+  if (IsHost())
 #if !defined(__linux__)
-        return HostInfo::GetOSBuildString(s);
+    return HostInfo::GetOSBuildString(s);
 #else
-        return false;
+    return false;
 #endif
-    else
-        return GetRemoteOSBuildString (s);
+  else
+    return GetRemoteOSBuildString(s);
 }
 
-bool
-Platform::GetOSKernelDescription (std::string &s)
-{
-    if (IsHost())
+bool Platform::GetOSKernelDescription(std::string &s) {
+  if (IsHost())
 #if !defined(__linux__)
-        return HostInfo::GetOSKernelDescription(s);
+    return HostInfo::GetOSKernelDescription(s);
 #else
-        return false;
+    return false;
 #endif
-    else
-        return GetRemoteOSKernelDescription (s);
+  else
+    return GetRemoteOSKernelDescription(s);
 }
 
-void
-Platform::AddClangModuleCompilationOptions (Target *target, std::vector<std::string> &options)
-{
-    std::vector<std::string> default_compilation_options =
-    {
-        "-x", "c++", "-Xclang", "-nostdsysteminc", "-Xclang", "-nostdsysteminc"
-    };
-    
-    options.insert(options.end(),
-                   default_compilation_options.begin(),
-                   default_compilation_options.end());
+void Platform::AddClangModuleCompilationOptions(
+    Target *target, std::vector<std::string> &options) {
+  std::vector<std::string> default_compilation_options = {
+      "-x", "c++", "-Xclang", "-nostdsysteminc", "-Xclang", "-nostdsysteminc"};
+
+  options.insert(options.end(), default_compilation_options.begin(),
+                 default_compilation_options.end());
 }
 
-FileSpec
-Platform::GetWorkingDirectory ()
-{
-    if (IsHost())
-    {
-        char cwd[PATH_MAX];
-        if (getcwd(cwd, sizeof(cwd)))
-            return FileSpec{cwd, true};
-        else
-            return FileSpec{};
-    }
+FileSpec Platform::GetWorkingDirectory() {
+  if (IsHost()) {
+    char cwd[PATH_MAX];
+    if (getcwd(cwd, sizeof(cwd)))
+      return FileSpec{cwd, true};
     else
-    {
-        if (!m_working_dir)
-            m_working_dir = GetRemoteWorkingDirectory();
-        return m_working_dir;
-    }
+      return FileSpec{};
+  } else {
+    if (!m_working_dir)
+      m_working_dir = GetRemoteWorkingDirectory();
+    return m_working_dir;
+  }
 }
 
-struct RecurseCopyBaton
-{
-    const FileSpec& dst;
-    Platform *platform_ptr;
-    Error error;
+struct RecurseCopyBaton {
+  const FileSpec &dst;
+  Platform *platform_ptr;
+  Error error;
 };
 
 static FileSpec::EnumerateDirectoryResult
-RecurseCopy_Callback (void *baton,
-                      FileSpec::FileType file_type,
-                      const FileSpec &src)
-{
-    RecurseCopyBaton* rc_baton = (RecurseCopyBaton*)baton;
-    switch (file_type)
-    {
-        case FileSpec::eFileTypePipe:
-        case FileSpec::eFileTypeSocket:
-            // we have no way to copy pipes and sockets - ignore them and continue
-            return FileSpec::eEnumerateDirectoryResultNext;
-            break;
-            
-        case FileSpec::eFileTypeDirectory:
-            {
-                // make the new directory and get in there
-                FileSpec dst_dir = rc_baton->dst;
-                if (!dst_dir.GetFilename())
-                    dst_dir.GetFilename() = src.GetLastPathComponent();
-                Error error = rc_baton->platform_ptr->MakeDirectory(dst_dir, lldb::eFilePermissionsDirectoryDefault);
-                if (error.Fail())
-                {
-                    rc_baton->error.SetErrorStringWithFormat("unable to setup directory %s on remote end",
-                            dst_dir.GetCString());
-                    return FileSpec::eEnumerateDirectoryResultQuit; // got an error, bail out
-                }
-                
-                // now recurse
-                std::string src_dir_path (src.GetPath());
-                
-                // Make a filespec that only fills in the directory of a FileSpec so
-                // when we enumerate we can quickly fill in the filename for dst copies
-                FileSpec recurse_dst;
-                recurse_dst.GetDirectory().SetCString(dst_dir.GetPath().c_str());
-                RecurseCopyBaton rc_baton2 = { recurse_dst, rc_baton->platform_ptr, Error() };
-                FileSpec::EnumerateDirectory(src_dir_path.c_str(), true, true, true, RecurseCopy_Callback, &rc_baton2);
-                if (rc_baton2.error.Fail())
-                {
-                    rc_baton->error.SetErrorString(rc_baton2.error.AsCString());
-                    return FileSpec::eEnumerateDirectoryResultQuit; // got an error, bail out
-                }
-                return FileSpec::eEnumerateDirectoryResultNext;
-            }
-            break;
-            
-        case FileSpec::eFileTypeSymbolicLink:
-            {
-                // copy the file and keep going
-                FileSpec dst_file = rc_baton->dst;
-                if (!dst_file.GetFilename())
-                    dst_file.GetFilename() = src.GetFilename();
-
-                FileSpec src_resolved;
-
-                rc_baton->error = FileSystem::Readlink(src, src_resolved);
-
-                if (rc_baton->error.Fail())
-                    return FileSpec::eEnumerateDirectoryResultQuit; // got an error, bail out
-
-                rc_baton->error = rc_baton->platform_ptr->CreateSymlink(dst_file, src_resolved);
-
-                if (rc_baton->error.Fail())
-                    return FileSpec::eEnumerateDirectoryResultQuit; // got an error, bail out
-
-                return FileSpec::eEnumerateDirectoryResultNext;
-            }
-            break;
-
-        case FileSpec::eFileTypeRegular:
-            {
-                // copy the file and keep going
-                FileSpec dst_file = rc_baton->dst;
-                if (!dst_file.GetFilename())
-                    dst_file.GetFilename() = src.GetFilename();
-                Error err = rc_baton->platform_ptr->PutFile(src, dst_file);
-                if (err.Fail())
-                {
-                    rc_baton->error.SetErrorString(err.AsCString());
-                    return FileSpec::eEnumerateDirectoryResultQuit; // got an error, bail out
-                }
-                return FileSpec::eEnumerateDirectoryResultNext;
-            }
-            break;
-            
-        case FileSpec::eFileTypeInvalid:
-        case FileSpec::eFileTypeOther:
-        case FileSpec::eFileTypeUnknown:
-            rc_baton->error.SetErrorStringWithFormat("invalid file detected during copy: %s", src.GetPath().c_str());
-            return FileSpec::eEnumerateDirectoryResultQuit; // got an error, bail out
-            break;
+RecurseCopy_Callback(void *baton, FileSpec::FileType file_type,
+                     const FileSpec &src) {
+  RecurseCopyBaton *rc_baton = (RecurseCopyBaton *)baton;
+  switch (file_type) {
+  case FileSpec::eFileTypePipe:
+  case FileSpec::eFileTypeSocket:
+    // we have no way to copy pipes and sockets - ignore them and continue
+    return FileSpec::eEnumerateDirectoryResultNext;
+    break;
+
+  case FileSpec::eFileTypeDirectory: {
+    // make the new directory and get in there
+    FileSpec dst_dir = rc_baton->dst;
+    if (!dst_dir.GetFilename())
+      dst_dir.GetFilename() = src.GetLastPathComponent();
+    Error error = rc_baton->platform_ptr->MakeDirectory(
+        dst_dir, lldb::eFilePermissionsDirectoryDefault);
+    if (error.Fail()) {
+      rc_baton->error.SetErrorStringWithFormat(
+          "unable to setup directory %s on remote end", dst_dir.GetCString());
+      return FileSpec::eEnumerateDirectoryResultQuit; // got an error, bail out
+    }
+
+    // now recurse
+    std::string src_dir_path(src.GetPath());
+
+    // Make a filespec that only fills in the directory of a FileSpec so
+    // when we enumerate we can quickly fill in the filename for dst copies
+    FileSpec recurse_dst;
+    recurse_dst.GetDirectory().SetCString(dst_dir.GetPath().c_str());
+    RecurseCopyBaton rc_baton2 = {recurse_dst, rc_baton->platform_ptr, Error()};
+    FileSpec::EnumerateDirectory(src_dir_path.c_str(), true, true, true,
+                                 RecurseCopy_Callback, &rc_baton2);
+    if (rc_baton2.error.Fail()) {
+      rc_baton->error.SetErrorString(rc_baton2.error.AsCString());
+      return FileSpec::eEnumerateDirectoryResultQuit; // got an error, bail out
+    }
+    return FileSpec::eEnumerateDirectoryResultNext;
+  } break;
+
+  case FileSpec::eFileTypeSymbolicLink: {
+    // copy the file and keep going
+    FileSpec dst_file = rc_baton->dst;
+    if (!dst_file.GetFilename())
+      dst_file.GetFilename() = src.GetFilename();
+
+    FileSpec src_resolved;
+
+    rc_baton->error = FileSystem::Readlink(src, src_resolved);
+
+    if (rc_baton->error.Fail())
+      return FileSpec::eEnumerateDirectoryResultQuit; // got an error, bail out
+
+    rc_baton->error =
+        rc_baton->platform_ptr->CreateSymlink(dst_file, src_resolved);
+
+    if (rc_baton->error.Fail())
+      return FileSpec::eEnumerateDirectoryResultQuit; // got an error, bail out
+
+    return FileSpec::eEnumerateDirectoryResultNext;
+  } break;
+
+  case FileSpec::eFileTypeRegular: {
+    // copy the file and keep going
+    FileSpec dst_file = rc_baton->dst;
+    if (!dst_file.GetFilename())
+      dst_file.GetFilename() = src.GetFilename();
+    Error err = rc_baton->platform_ptr->PutFile(src, dst_file);
+    if (err.Fail()) {
+      rc_baton->error.SetErrorString(err.AsCString());
+      return FileSpec::eEnumerateDirectoryResultQuit; // got an error, bail out
+    }
+    return FileSpec::eEnumerateDirectoryResultNext;
+  } break;
+
+  case FileSpec::eFileTypeInvalid:
+  case FileSpec::eFileTypeOther:
+  case FileSpec::eFileTypeUnknown:
+    rc_baton->error.SetErrorStringWithFormat(
+        "invalid file detected during copy: %s", src.GetPath().c_str());
+    return FileSpec::eEnumerateDirectoryResultQuit; // got an error, bail out
+    break;
+  }
+  llvm_unreachable("Unhandled FileSpec::FileType!");
+}
+
+Error Platform::Install(const FileSpec &src, const FileSpec &dst) {
+  Error error;
+
+  Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM);
+  if (log)
+    log->Printf("Platform::Install (src='%s', dst='%s')", src.GetPath().c_str(),
+                dst.GetPath().c_str());
+  FileSpec fixed_dst(dst);
+
+  if (!fixed_dst.GetFilename())
+    fixed_dst.GetFilename() = src.GetFilename();
+
+  FileSpec working_dir = GetWorkingDirectory();
+
+  if (dst) {
+    if (dst.GetDirectory()) {
+      const char first_dst_dir_char = dst.GetDirectory().GetCString()[0];
+      if (first_dst_dir_char == '/' || first_dst_dir_char == '\\') {
+        fixed_dst.GetDirectory() = dst.GetDirectory();
+      }
+      // If the fixed destination file doesn't have a directory yet,
+      // then we must have a relative path. We will resolve this relative
+      // path against the platform's working directory
+      if (!fixed_dst.GetDirectory()) {
+        FileSpec relative_spec;
+        std::string path;
+        if (working_dir) {
+          relative_spec = working_dir;
+          relative_spec.AppendPathComponent(dst.GetPath());
+          fixed_dst.GetDirectory() = relative_spec.GetDirectory();
+        } else {
+          error.SetErrorStringWithFormat(
+              "platform working directory must be valid for relative path '%s'",
+              dst.GetPath().c_str());
+          return error;
+        }
+      }
+    } else {
+      if (working_dir) {
+        fixed_dst.GetDirectory().SetCString(working_dir.GetCString());
+      } else {
+        error.SetErrorStringWithFormat(
+            "platform working directory must be valid for relative path '%s'",
+            dst.GetPath().c_str());
+        return error;
+      }
     }
-    llvm_unreachable("Unhandled FileSpec::FileType!");
+  } else {
+    if (working_dir) {
+      fixed_dst.GetDirectory().SetCString(working_dir.GetCString());
+    } else {
+      error.SetErrorStringWithFormat("platform working directory must be valid "
+                                     "when destination directory is empty");
+      return error;
+    }
+  }
+
+  if (log)
+    log->Printf("Platform::Install (src='%s', dst='%s') fixed_dst='%s'",
+                src.GetPath().c_str(), dst.GetPath().c_str(),
+                fixed_dst.GetPath().c_str());
+
+  if (GetSupportsRSync()) {
+    error = PutFile(src, dst);
+  } else {
+    switch (src.GetFileType()) {
+    case FileSpec::eFileTypeDirectory: {
+      if (GetFileExists(fixed_dst))
+        Unlink(fixed_dst);
+      uint32_t permissions = src.GetPermissions();
+      if (permissions == 0)
+        permissions = eFilePermissionsDirectoryDefault;
+      error = MakeDirectory(fixed_dst, permissions);
+      if (error.Success()) {
+        // Make a filespec that only fills in the directory of a FileSpec so
+        // when we enumerate we can quickly fill in the filename for dst copies
+        FileSpec recurse_dst;
+        recurse_dst.GetDirectory().SetCString(fixed_dst.GetCString());
+        std::string src_dir_path(src.GetPath());
+        RecurseCopyBaton baton = {recurse_dst, this, Error()};
+        FileSpec::EnumerateDirectory(src_dir_path.c_str(), true, true, true,
+                                     RecurseCopy_Callback, &baton);
+        return baton.error;
+      }
+    } break;
+
+    case FileSpec::eFileTypeRegular:
+      if (GetFileExists(fixed_dst))
+        Unlink(fixed_dst);
+      error = PutFile(src, fixed_dst);
+      break;
+
+    case FileSpec::eFileTypeSymbolicLink: {
+      if (GetFileExists(fixed_dst))
+        Unlink(fixed_dst);
+      FileSpec src_resolved;
+      error = FileSystem::Readlink(src, src_resolved);
+      if (error.Success())
+        error = CreateSymlink(dst, src_resolved);
+    } break;
+    case FileSpec::eFileTypePipe:
+      error.SetErrorString("platform install doesn't handle pipes");
+      break;
+    case FileSpec::eFileTypeSocket:
+      error.SetErrorString("platform install doesn't handle sockets");
+      break;
+    case FileSpec::eFileTypeInvalid:
+    case FileSpec::eFileTypeUnknown:
+    case FileSpec::eFileTypeOther:
+      error.SetErrorString(
+          "platform install doesn't handle non file or directory items");
+      break;
+    }
+  }
+  return error;
 }
 
-Error
-Platform::Install (const FileSpec& src, const FileSpec& dst)
-{
-    Error error;
-    
+bool Platform::SetWorkingDirectory(const FileSpec &file_spec) {
+  if (IsHost()) {
     Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM);
     if (log)
-        log->Printf ("Platform::Install (src='%s', dst='%s')", src.GetPath().c_str(), dst.GetPath().c_str());
-    FileSpec fixed_dst(dst);
-    
-    if (!fixed_dst.GetFilename())
-        fixed_dst.GetFilename() = src.GetFilename();
-
-    FileSpec working_dir = GetWorkingDirectory();
-
-    if (dst)
-    {
-        if (dst.GetDirectory())
-        {
-            const char first_dst_dir_char = dst.GetDirectory().GetCString()[0];
-            if (first_dst_dir_char == '/' || first_dst_dir_char  == '\\')
-            {
-                fixed_dst.GetDirectory() = dst.GetDirectory();
-            }
-            // If the fixed destination file doesn't have a directory yet,
-            // then we must have a relative path. We will resolve this relative
-            // path against the platform's working directory
-            if (!fixed_dst.GetDirectory())
-            {
-                FileSpec relative_spec;
-                std::string path;
-                if (working_dir)
-                {
-                    relative_spec = working_dir;
-                    relative_spec.AppendPathComponent(dst.GetPath());
-                    fixed_dst.GetDirectory() = relative_spec.GetDirectory();
-                }
-                else
-                {
-                    error.SetErrorStringWithFormat("platform working directory must be valid for relative path '%s'", dst.GetPath().c_str());
-                    return error;
-                }
-            }
-        }
-        else
-        {
-            if (working_dir)
-            {
-                fixed_dst.GetDirectory().SetCString(working_dir.GetCString());
-            }
-            else
-            {
-                error.SetErrorStringWithFormat("platform working directory must be valid for relative path '%s'", dst.GetPath().c_str());
-                return error;
-            }
-        }
-    }
-    else
-    {
-        if (working_dir)
-        {
-            fixed_dst.GetDirectory().SetCString(working_dir.GetCString());
-        }
-        else
-        {
-            error.SetErrorStringWithFormat("platform working directory must be valid when destination directory is empty");
-            return error;
-        }
-    }
-    
-    if (log)
-        log->Printf ("Platform::Install (src='%s', dst='%s') fixed_dst='%s'", src.GetPath().c_str(), dst.GetPath().c_str(), fixed_dst.GetPath().c_str());
-
-    if (GetSupportsRSync())
-    {
-        error = PutFile(src, dst);
-    }
-    else
-    {
-        switch (src.GetFileType())
-        {
-            case FileSpec::eFileTypeDirectory:
-                {
-                    if (GetFileExists (fixed_dst))
-                        Unlink(fixed_dst);
-                    uint32_t permissions = src.GetPermissions();
-                    if (permissions == 0)
-                        permissions = eFilePermissionsDirectoryDefault;
-                    error = MakeDirectory(fixed_dst, permissions);
-                    if (error.Success())
-                    {
-                        // Make a filespec that only fills in the directory of a FileSpec so
-                        // when we enumerate we can quickly fill in the filename for dst copies
-                        FileSpec recurse_dst;
-                        recurse_dst.GetDirectory().SetCString(fixed_dst.GetCString());
-                        std::string src_dir_path (src.GetPath());
-                        RecurseCopyBaton baton = { recurse_dst, this, Error() };
-                        FileSpec::EnumerateDirectory(src_dir_path.c_str(), true, true, true, RecurseCopy_Callback, &baton);
-                        return baton.error;
-                    }
-                }
-                break;
-
-            case FileSpec::eFileTypeRegular:
-                if (GetFileExists (fixed_dst))
-                    Unlink(fixed_dst);
-                error = PutFile(src, fixed_dst);
-                break;
-
-            case FileSpec::eFileTypeSymbolicLink:
-                {
-                    if (GetFileExists (fixed_dst))
-                        Unlink(fixed_dst);
-                    FileSpec src_resolved;
-                    error = FileSystem::Readlink(src, src_resolved);
-                    if (error.Success())
-                        error = CreateSymlink(dst, src_resolved);
-                }
-                break;
-            case FileSpec::eFileTypePipe:
-                error.SetErrorString("platform install doesn't handle pipes");
-                break;
-            case FileSpec::eFileTypeSocket:
-                error.SetErrorString("platform install doesn't handle sockets");
-                break;
-            case FileSpec::eFileTypeInvalid:
-            case FileSpec::eFileTypeUnknown:
-            case FileSpec::eFileTypeOther:
-                error.SetErrorString("platform install doesn't handle non file or directory items");
-                break;
-        }
-    }
-    return error;
-}
-
-bool
-Platform::SetWorkingDirectory(const FileSpec &file_spec)
-{
-    if (IsHost())
-    {
-        Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM);
-        if (log)
-            log->Printf("Platform::SetWorkingDirectory('%s')",
-                    file_spec.GetCString());
-        if (file_spec)
-        {
-            if (::chdir(file_spec.GetCString()) == 0)
-                return true;
-        }
-        return false;
-    }
-    else
-    {
-        m_working_dir.Clear();
-        return SetRemoteWorkingDirectory(file_spec);
+      log->Printf("Platform::SetWorkingDirectory('%s')",
+                  file_spec.GetCString());
+    if (file_spec) {
+      if (::chdir(file_spec.GetCString()) == 0)
+        return true;
     }
+    return false;
+  } else {
+    m_working_dir.Clear();
+    return SetRemoteWorkingDirectory(file_spec);
+  }
 }
 
-Error
-Platform::MakeDirectory(const FileSpec &file_spec, uint32_t permissions)
-{
-    if (IsHost())
-        return FileSystem::MakeDirectory(file_spec, permissions);
-    else
-    {
-        Error error;
-        error.SetErrorStringWithFormat("remote platform %s doesn't support %s", GetPluginName().GetCString(), LLVM_PRETTY_FUNCTION);
-        return error;
-    }
+Error Platform::MakeDirectory(const FileSpec &file_spec, uint32_t permissions) {
+  if (IsHost())
+    return FileSystem::MakeDirectory(file_spec, permissions);
+  else {
+    Error error;
+    error.SetErrorStringWithFormat("remote platform %s doesn't support %s",
+                                   GetPluginName().GetCString(),
+                                   LLVM_PRETTY_FUNCTION);
+    return error;
+  }
 }
 
-Error
-Platform::GetFilePermissions(const FileSpec &file_spec, uint32_t &file_permissions)
-{
-    if (IsHost())
-        return FileSystem::GetFilePermissions(file_spec, file_permissions);
-    else
-    {
-        Error error;
-        error.SetErrorStringWithFormat("remote platform %s doesn't support %s", GetPluginName().GetCString(), LLVM_PRETTY_FUNCTION);
-        return error;
-    }
+Error Platform::GetFilePermissions(const FileSpec &file_spec,
+                                   uint32_t &file_permissions) {
+  if (IsHost())
+    return FileSystem::GetFilePermissions(file_spec, file_permissions);
+  else {
+    Error error;
+    error.SetErrorStringWithFormat("remote platform %s doesn't support %s",
+                                   GetPluginName().GetCString(),
+                                   LLVM_PRETTY_FUNCTION);
+    return error;
+  }
 }
 
-Error
-Platform::SetFilePermissions(const FileSpec &file_spec, uint32_t file_permissions)
-{
-    if (IsHost())
-        return FileSystem::SetFilePermissions(file_spec, file_permissions);
-    else
-    {
-        Error error;
-        error.SetErrorStringWithFormat("remote platform %s doesn't support %s", GetPluginName().GetCString(), LLVM_PRETTY_FUNCTION);
-        return error;
-    }
+Error Platform::SetFilePermissions(const FileSpec &file_spec,
+                                   uint32_t file_permissions) {
+  if (IsHost())
+    return FileSystem::SetFilePermissions(file_spec, file_permissions);
+  else {
+    Error error;
+    error.SetErrorStringWithFormat("remote platform %s doesn't support %s",
+                                   GetPluginName().GetCString(),
+                                   LLVM_PRETTY_FUNCTION);
+    return error;
+  }
 }
 
-ConstString
-Platform::GetName ()
-{
-    return GetPluginName();
-}
+ConstString Platform::GetName() { return GetPluginName(); }
 
-const char *
-Platform::GetHostname ()
-{
-    if (IsHost())
-        return "127.0.0.1";
+const char *Platform::GetHostname() {
+  if (IsHost())
+    return "127.0.0.1";
 
-    if (m_name.empty())        
-        return nullptr;
-    return m_name.c_str();
+  if (m_name.empty())
+    return nullptr;
+  return m_name.c_str();
 }
 
-ConstString
-Platform::GetFullNameForDylib (ConstString basename)
-{
-    return basename;
+ConstString Platform::GetFullNameForDylib(ConstString basename) {
+  return basename;
 }
 
-bool
-Platform::SetRemoteWorkingDirectory(const FileSpec &working_dir)
-{
-    Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM);
-    if (log)
-        log->Printf("Platform::SetRemoteWorkingDirectory('%s')",
+bool Platform::SetRemoteWorkingDirectory(const FileSpec &working_dir) {
+  Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM);
+  if (log)
+    log->Printf("Platform::SetRemoteWorkingDirectory('%s')",
                 working_dir.GetCString());
-    m_working_dir = working_dir;
-    return true;
+  m_working_dir = working_dir;
+  return true;
 }
 
-const char *
-Platform::GetUserName (uint32_t uid)
-{
+const char *Platform::GetUserName(uint32_t uid) {
 #if !defined(LLDB_DISABLE_POSIX)
-    const char *user_name = GetCachedUserName(uid);
-    if (user_name)
-        return user_name;
-    if (IsHost())
-    {
-        std::string name;
-        if (HostInfo::LookupUserName(uid, name))
-            return SetCachedUserName (uid, name.c_str(), name.size());
-    }
+  const char *user_name = GetCachedUserName(uid);
+  if (user_name)
+    return user_name;
+  if (IsHost()) {
+    std::string name;
+    if (HostInfo::LookupUserName(uid, name))
+      return SetCachedUserName(uid, name.c_str(), name.size());
+  }
 #endif
-    return nullptr;
+  return nullptr;
 }
 
-const char *
-Platform::GetGroupName (uint32_t gid)
-{
+const char *Platform::GetGroupName(uint32_t gid) {
 #if !defined(LLDB_DISABLE_POSIX)
-    const char *group_name = GetCachedGroupName(gid);
-    if (group_name)
-        return group_name;
-    if (IsHost())
-    {
-        std::string name;
-        if (HostInfo::LookupGroupName(gid, name))
-            return SetCachedGroupName (gid, name.c_str(), name.size());
-    }
+  const char *group_name = GetCachedGroupName(gid);
+  if (group_name)
+    return group_name;
+  if (IsHost()) {
+    std::string name;
+    if (HostInfo::LookupGroupName(gid, name))
+      return SetCachedGroupName(gid, name.c_str(), name.size());
+  }
 #endif
-    return nullptr;
-}
-
-bool
-Platform::SetOSVersion (uint32_t major, 
-                        uint32_t minor, 
-                        uint32_t update)
-{
-    if (IsHost())
-    {
-        // We don't need anyone setting the OS version for the host platform,
-        // we should be able to figure it out by calling HostInfo::GetOSVersion(...).
-        return false; 
-    }
-    else
-    {
-        // We have a remote platform, allow setting the target OS version if
-        // we aren't connected, since if we are connected, we should be able to
-        // request the remote OS version from the connected platform.
-        if (IsConnected())
-            return false;
-        else
-        {
-            // We aren't connected and we might want to set the OS version
-            // ahead of time before we connect so we can peruse files and
-            // use a local SDK or PDK cache of support files to disassemble
-            // or do other things.
-            m_major_os_version = major;
-            m_minor_os_version = minor;
-            m_update_os_version = update;
-            return true;
-        }
-    }
-    return false;
-}
-
-Error
-Platform::ResolveExecutable (const ModuleSpec &module_spec,
-                             lldb::ModuleSP &exe_module_sp,
-                             const FileSpecList *module_search_paths_ptr)
-{
-    Error error;
-    if (module_spec.GetFileSpec().Exists())
-    {
-        if (module_spec.GetArchitecture().IsValid())
-        {
-            error = ModuleList::GetSharedModule(module_spec, 
-                                                exe_module_sp, 
-                                                module_search_paths_ptr,
-                                                nullptr, 
-                                                nullptr);
-        }
-        else
-        {
-            // No valid architecture was specified, ask the platform for
-            // the architectures that we should be using (in the correct order)
-            // and see if we can find a match that way
-            ModuleSpec arch_module_spec(module_spec);
-            for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, arch_module_spec.GetArchitecture()); ++idx)
-            {
-                error = ModuleList::GetSharedModule(arch_module_spec,
-                                                    exe_module_sp, 
-                                                    module_search_paths_ptr,
-                                                    nullptr, 
-                                                    nullptr);
-                // Did we find an executable using one of the 
-                if (error.Success() && exe_module_sp)
-                    break;
-            }
-        }
-    }
-    else
-    {
-        error.SetErrorStringWithFormat ("'%s' does not exist",
-                                        module_spec.GetFileSpec().GetPath().c_str());
-    }
-    return error;
-}
-
-Error
-Platform::ResolveSymbolFile (Target &target,
-                             const ModuleSpec &sym_spec,
-                             FileSpec &sym_file)
-{
-    Error error;
-    if (sym_spec.GetSymbolFileSpec().Exists())
-        sym_file = sym_spec.GetSymbolFileSpec();
-    else
-        error.SetErrorString("unable to resolve symbol file");
-    return error;
-}   
-
-bool
-Platform::ResolveRemotePath (const FileSpec &platform_path,
-                             FileSpec &resolved_platform_path)
-{
-    resolved_platform_path = platform_path;
-    return resolved_platform_path.ResolvePath();
-}
-
-const ArchSpec &
-Platform::GetSystemArchitecture()
-{
-    if (IsHost())
-    {
-        if (!m_system_arch.IsValid())
-        {
-            // We have a local host platform
-            m_system_arch = HostInfo::GetArchitecture();
-            m_system_arch_set_while_connected = m_system_arch.IsValid();
-        }
-    }
-    else 
-    {
-        // We have a remote platform. We can only fetch the remote
-        // system architecture if we are connected, and we don't want to do it
-        // more than once.
-        
-        const bool is_connected = IsConnected();
-
-        bool fetch = false;
-        if (m_system_arch.IsValid())
-        {
-            // We have valid OS version info, check to make sure it wasn't
-            // manually set prior to connecting. If it was manually set prior
-            // to connecting, then lets fetch the actual OS version info
-            // if we are now connected.
-            if (is_connected && !m_system_arch_set_while_connected)
-                fetch = true;
-        }
-        else
-        {
-            // We don't have valid OS version info, fetch it if we are connected
-            fetch = is_connected;
-        }
-
-        if (fetch)
-        {
-            m_system_arch = GetRemoteSystemArchitecture ();
-            m_system_arch_set_while_connected = m_system_arch.IsValid();
-        }
-    }
-    return m_system_arch;
+  return nullptr;
 }
 
-Error
-Platform::ConnectRemote (Args& args)
-{
-    Error error;
-    if (IsHost())
-        error.SetErrorStringWithFormat ("The currently selected platform (%s) is the host platform and is always connected.", GetPluginName().GetCString());
-    else
-        error.SetErrorStringWithFormat ("Platform::ConnectRemote() is not supported by %s", GetPluginName().GetCString());
-    return error;
-}
-
-Error
-Platform::DisconnectRemote ()
-{
-    Error error;
-    if (IsHost())
-        error.SetErrorStringWithFormat ("The currently selected platform (%s) is the host platform and is always connected.", GetPluginName().GetCString());
-    else
-        error.SetErrorStringWithFormat ("Platform::DisconnectRemote() is not supported by %s", GetPluginName().GetCString());
-    return error;
-}
-
-bool
-Platform::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info)
-{
-    // Take care of the host case so that each subclass can just 
-    // call this function to get the host functionality.
-    if (IsHost())
-        return Host::GetProcessInfo (pid, process_info);
+bool Platform::SetOSVersion(uint32_t major, uint32_t minor, uint32_t update) {
+  if (IsHost()) {
+    // We don't need anyone setting the OS version for the host platform,
+    // we should be able to figure it out by calling
+    // HostInfo::GetOSVersion(...).
     return false;
-}
-
-uint32_t
-Platform::FindProcesses (const ProcessInstanceInfoMatch &match_info,
-                         ProcessInstanceInfoList &process_infos)
-{
-    // Take care of the host case so that each subclass can just 
-    // call this function to get the host functionality.
-    uint32_t match_count = 0;
-    if (IsHost())
-        match_count = Host::FindProcesses (match_info, process_infos);
-    return match_count;    
-}
-
-Error
-Platform::LaunchProcess (ProcessLaunchInfo &launch_info)
-{
-    Error error;
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PLATFORM));
-    if (log)
-        log->Printf ("Platform::%s()", __FUNCTION__);
-
-    // Take care of the host case so that each subclass can just
-    // call this function to get the host functionality.
-    if (IsHost())
-    {
-        if (::getenv ("LLDB_LAUNCH_FLAG_LAUNCH_IN_TTY"))
-            launch_info.GetFlags().Set (eLaunchFlagLaunchInTTY);
-        
-        if (launch_info.GetFlags().Test (eLaunchFlagLaunchInShell))
-        {
-            const bool is_localhost = true;
-            const bool will_debug = launch_info.GetFlags().Test(eLaunchFlagDebug);
-            const bool first_arg_is_full_shell_command = false;
-            uint32_t num_resumes = GetResumeCountForLaunchInfo (launch_info);
-            if (log)
-            {
-                const FileSpec &shell = launch_info.GetShell();
-                const char *shell_str = (shell) ? shell.GetPath().c_str() : "<null>";
-                log->Printf ("Platform::%s GetResumeCountForLaunchInfo() returned %" PRIu32 ", shell is '%s'",
-                             __FUNCTION__,
-                             num_resumes,
-                             shell_str);
-            }
-
-            if (!launch_info.ConvertArgumentsForLaunchingInShell (error,
-                                                                  is_localhost,
-                                                                  will_debug,
-                                                                  first_arg_is_full_shell_command,
-                                                                  num_resumes))
-                return error;
-        }
-        else if (launch_info.GetFlags().Test(eLaunchFlagShellExpandArguments))
-        {
-            error = ShellExpandArguments(launch_info);
-            if (error.Fail())
-            {
-                error.SetErrorStringWithFormat("shell expansion failed (reason: %s). consider launching with 'process launch'.",
-                                               error.AsCString("unknown"));
-                return error;
-            }
-        }
-
-        if (log)
-            log->Printf ("Platform::%s final launch_info resume count: %" PRIu32, __FUNCTION__, launch_info.GetResumeCount ());
-
-        error = Host::LaunchProcess (launch_info);
+  } else {
+    // We have a remote platform, allow setting the target OS version if
+    // we aren't connected, since if we are connected, we should be able to
+    // request the remote OS version from the connected platform.
+    if (IsConnected())
+      return false;
+    else {
+      // We aren't connected and we might want to set the OS version
+      // ahead of time before we connect so we can peruse files and
+      // use a local SDK or PDK cache of support files to disassemble
+      // or do other things.
+      m_major_os_version = major;
+      m_minor_os_version = minor;
+      m_update_os_version = update;
+      return true;
+    }
+  }
+  return false;
+}
+
+Error Platform::ResolveExecutable(const ModuleSpec &module_spec,
+                                  lldb::ModuleSP &exe_module_sp,
+                                  const FileSpecList *module_search_paths_ptr) {
+  Error error;
+  if (module_spec.GetFileSpec().Exists()) {
+    if (module_spec.GetArchitecture().IsValid()) {
+      error = ModuleList::GetSharedModule(module_spec, exe_module_sp,
+                                          module_search_paths_ptr, nullptr,
+                                          nullptr);
+    } else {
+      // No valid architecture was specified, ask the platform for
+      // the architectures that we should be using (in the correct order)
+      // and see if we can find a match that way
+      ModuleSpec arch_module_spec(module_spec);
+      for (uint32_t idx = 0; GetSupportedArchitectureAtIndex(
+               idx, arch_module_spec.GetArchitecture());
+           ++idx) {
+        error = ModuleList::GetSharedModule(arch_module_spec, exe_module_sp,
+                                            module_search_paths_ptr, nullptr,
+                                            nullptr);
+        // Did we find an executable using one of the
+        if (error.Success() && exe_module_sp)
+          break;
+      }
+    }
+  } else {
+    error.SetErrorStringWithFormat("'%s' does not exist",
+                                   module_spec.GetFileSpec().GetPath().c_str());
+  }
+  return error;
+}
+
+Error Platform::ResolveSymbolFile(Target &target, const ModuleSpec &sym_spec,
+                                  FileSpec &sym_file) {
+  Error error;
+  if (sym_spec.GetSymbolFileSpec().Exists())
+    sym_file = sym_spec.GetSymbolFileSpec();
+  else
+    error.SetErrorString("unable to resolve symbol file");
+  return error;
+}
+
+bool Platform::ResolveRemotePath(const FileSpec &platform_path,
+                                 FileSpec &resolved_platform_path) {
+  resolved_platform_path = platform_path;
+  return resolved_platform_path.ResolvePath();
+}
+
+const ArchSpec &Platform::GetSystemArchitecture() {
+  if (IsHost()) {
+    if (!m_system_arch.IsValid()) {
+      // We have a local host platform
+      m_system_arch = HostInfo::GetArchitecture();
+      m_system_arch_set_while_connected = m_system_arch.IsValid();
+    }
+  } else {
+    // We have a remote platform. We can only fetch the remote
+    // system architecture if we are connected, and we don't want to do it
+    // more than once.
+
+    const bool is_connected = IsConnected();
+
+    bool fetch = false;
+    if (m_system_arch.IsValid()) {
+      // We have valid OS version info, check to make sure it wasn't
+      // manually set prior to connecting. If it was manually set prior
+      // to connecting, then lets fetch the actual OS version info
+      // if we are now connected.
+      if (is_connected && !m_system_arch_set_while_connected)
+        fetch = true;
+    } else {
+      // We don't have valid OS version info, fetch it if we are connected
+      fetch = is_connected;
+    }
+
+    if (fetch) {
+      m_system_arch = GetRemoteSystemArchitecture();
+      m_system_arch_set_while_connected = m_system_arch.IsValid();
+    }
+  }
+  return m_system_arch;
+}
+
+Error Platform::ConnectRemote(Args &args) {
+  Error error;
+  if (IsHost())
+    error.SetErrorStringWithFormat("The currently selected platform (%s) is "
+                                   "the host platform and is always connected.",
+                                   GetPluginName().GetCString());
+  else
+    error.SetErrorStringWithFormat(
+        "Platform::ConnectRemote() is not supported by %s",
+        GetPluginName().GetCString());
+  return error;
+}
+
+Error Platform::DisconnectRemote() {
+  Error error;
+  if (IsHost())
+    error.SetErrorStringWithFormat("The currently selected platform (%s) is "
+                                   "the host platform and is always connected.",
+                                   GetPluginName().GetCString());
+  else
+    error.SetErrorStringWithFormat(
+        "Platform::DisconnectRemote() is not supported by %s",
+        GetPluginName().GetCString());
+  return error;
+}
+
+bool Platform::GetProcessInfo(lldb::pid_t pid,
+                              ProcessInstanceInfo &process_info) {
+  // Take care of the host case so that each subclass can just
+  // call this function to get the host functionality.
+  if (IsHost())
+    return Host::GetProcessInfo(pid, process_info);
+  return false;
+}
+
+uint32_t Platform::FindProcesses(const ProcessInstanceInfoMatch &match_info,
+                                 ProcessInstanceInfoList &process_infos) {
+  // Take care of the host case so that each subclass can just
+  // call this function to get the host functionality.
+  uint32_t match_count = 0;
+  if (IsHost())
+    match_count = Host::FindProcesses(match_info, process_infos);
+  return match_count;
+}
+
+Error Platform::LaunchProcess(ProcessLaunchInfo &launch_info) {
+  Error error;
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
+  if (log)
+    log->Printf("Platform::%s()", __FUNCTION__);
+
+  // Take care of the host case so that each subclass can just
+  // call this function to get the host functionality.
+  if (IsHost()) {
+    if (::getenv("LLDB_LAUNCH_FLAG_LAUNCH_IN_TTY"))
+      launch_info.GetFlags().Set(eLaunchFlagLaunchInTTY);
+
+    if (launch_info.GetFlags().Test(eLaunchFlagLaunchInShell)) {
+      const bool is_localhost = true;
+      const bool will_debug = launch_info.GetFlags().Test(eLaunchFlagDebug);
+      const bool first_arg_is_full_shell_command = false;
+      uint32_t num_resumes = GetResumeCountForLaunchInfo(launch_info);
+      if (log) {
+        const FileSpec &shell = launch_info.GetShell();
+        const char *shell_str = (shell) ? shell.GetPath().c_str() : "<null>";
+        log->Printf(
+            "Platform::%s GetResumeCountForLaunchInfo() returned %" PRIu32
+            ", shell is '%s'",
+            __FUNCTION__, num_resumes, shell_str);
+      }
+
+      if (!launch_info.ConvertArgumentsForLaunchingInShell(
+              error, is_localhost, will_debug, first_arg_is_full_shell_command,
+              num_resumes))
+        return error;
+    } else if (launch_info.GetFlags().Test(eLaunchFlagShellExpandArguments)) {
+      error = ShellExpandArguments(launch_info);
+      if (error.Fail()) {
+        error.SetErrorStringWithFormat("shell expansion failed (reason: %s). "
+                                       "consider launching with 'process "
+                                       "launch'.",
+                                       error.AsCString("unknown"));
+        return error;
+      }
     }
-    else
-        error.SetErrorString ("base lldb_private::Platform class can't launch remote processes");
-    return error;
-}
 
-Error
-Platform::ShellExpandArguments (ProcessLaunchInfo &launch_info)
-{
-    if (IsHost())
-        return Host::ShellExpandArguments(launch_info);
-    return Error("base lldb_private::Platform class can't expand arguments");
-}
-
-Error
-Platform::KillProcess (const lldb::pid_t pid)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PLATFORM));
     if (log)
-        log->Printf ("Platform::%s, pid %" PRIu64, __FUNCTION__, pid);
-
-    // Try to find a process plugin to handle this Kill request.  If we can't, fall back to
-    // the default OS implementation.
-    size_t num_debuggers = Debugger::GetNumDebuggers();
-    for (size_t didx = 0; didx < num_debuggers; ++didx)
-    {
-        DebuggerSP debugger = Debugger::GetDebuggerAtIndex(didx);
-        lldb_private::TargetList &targets = debugger->GetTargetList();
-        for (int tidx = 0; tidx < targets.GetNumTargets(); ++tidx)
-        {
-            ProcessSP process = targets.GetTargetAtIndex(tidx)->GetProcessSP();
-            if (process->GetID() == pid)
-                return process->Destroy(true);
-        }
-    }
+      log->Printf("Platform::%s final launch_info resume count: %" PRIu32,
+                  __FUNCTION__, launch_info.GetResumeCount());
 
-    if (!IsHost())
-    {
-        return Error("base lldb_private::Platform class can't kill remote processes unless "
-                     "they are controlled by a process plugin");
-    }
-    Host::Kill(pid, SIGTERM);
-    return Error();
+    error = Host::LaunchProcess(launch_info);
+  } else
+    error.SetErrorString(
+        "base lldb_private::Platform class can't launch remote processes");
+  return error;
+}
+
+Error Platform::ShellExpandArguments(ProcessLaunchInfo &launch_info) {
+  if (IsHost())
+    return Host::ShellExpandArguments(launch_info);
+  return Error("base lldb_private::Platform class can't expand arguments");
+}
+
+Error Platform::KillProcess(const lldb::pid_t pid) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
+  if (log)
+    log->Printf("Platform::%s, pid %" PRIu64, __FUNCTION__, pid);
+
+  // Try to find a process plugin to handle this Kill request.  If we can't,
+  // fall back to
+  // the default OS implementation.
+  size_t num_debuggers = Debugger::GetNumDebuggers();
+  for (size_t didx = 0; didx < num_debuggers; ++didx) {
+    DebuggerSP debugger = Debugger::GetDebuggerAtIndex(didx);
+    lldb_private::TargetList &targets = debugger->GetTargetList();
+    for (int tidx = 0; tidx < targets.GetNumTargets(); ++tidx) {
+      ProcessSP process = targets.GetTargetAtIndex(tidx)->GetProcessSP();
+      if (process->GetID() == pid)
+        return process->Destroy(true);
+    }
+  }
+
+  if (!IsHost()) {
+    return Error(
+        "base lldb_private::Platform class can't kill remote processes unless "
+        "they are controlled by a process plugin");
+  }
+  Host::Kill(pid, SIGTERM);
+  return Error();
 }
 
 lldb::ProcessSP
-Platform::DebugProcess (ProcessLaunchInfo &launch_info, 
-                        Debugger &debugger,
-                        Target *target,       // Can be nullptr, if nullptr create a new target, else use existing one
-                        Error &error)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PLATFORM));
-    if (log)
-        log->Printf ("Platform::%s entered (target %p)", __FUNCTION__, static_cast<void*>(target));
-
-    ProcessSP process_sp;
-    // Make sure we stop at the entry point
-    launch_info.GetFlags ().Set (eLaunchFlagDebug);
-    // We always launch the process we are going to debug in a separate process
-    // group, since then we can handle ^C interrupts ourselves w/o having to worry
-    // about the target getting them as well.
-    launch_info.SetLaunchInSeparateProcessGroup(true);
-
-    // Allow any StructuredData process-bound plugins to adjust the launch info
-    // if needed
-    size_t i = 0;
-    bool iteration_complete = false;
-    // Note iteration can't simply go until a nullptr callback is returned, as
-    // it is valid for a plugin to not supply a filter.
-    auto get_filter_func =
-        PluginManager::GetStructuredDataFilterCallbackAtIndex;
-    for (auto filter_callback = get_filter_func(i, iteration_complete);
-         !iteration_complete;
-         filter_callback = get_filter_func(++i, iteration_complete))
-    {
-        if (filter_callback)
-        {
-            // Give this ProcessLaunchInfo filter a chance to adjust the launch
-            // info.
-            error = (*filter_callback)(launch_info, target);
-            if (!error.Success())
-            {
-                if (log)
-                    log->Printf("Platform::%s() StructuredDataPlugin launch "
-                                "filter failed.", __FUNCTION__);
-                return process_sp;
-            }
-        }
+Platform::DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger,
+                       Target *target, // Can be nullptr, if nullptr create a
+                                       // new target, else use existing one
+                       Error &error) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
+  if (log)
+    log->Printf("Platform::%s entered (target %p)", __FUNCTION__,
+                static_cast<void *>(target));
+
+  ProcessSP process_sp;
+  // Make sure we stop at the entry point
+  launch_info.GetFlags().Set(eLaunchFlagDebug);
+  // We always launch the process we are going to debug in a separate process
+  // group, since then we can handle ^C interrupts ourselves w/o having to worry
+  // about the target getting them as well.
+  launch_info.SetLaunchInSeparateProcessGroup(true);
+
+  // Allow any StructuredData process-bound plugins to adjust the launch info
+  // if needed
+  size_t i = 0;
+  bool iteration_complete = false;
+  // Note iteration can't simply go until a nullptr callback is returned, as
+  // it is valid for a plugin to not supply a filter.
+  auto get_filter_func = PluginManager::GetStructuredDataFilterCallbackAtIndex;
+  for (auto filter_callback = get_filter_func(i, iteration_complete);
+       !iteration_complete;
+       filter_callback = get_filter_func(++i, iteration_complete)) {
+    if (filter_callback) {
+      // Give this ProcessLaunchInfo filter a chance to adjust the launch
+      // info.
+      error = (*filter_callback)(launch_info, target);
+      if (!error.Success()) {
+        if (log)
+          log->Printf("Platform::%s() StructuredDataPlugin launch "
+                      "filter failed.",
+                      __FUNCTION__);
+        return process_sp;
+      }
     }
+  }
 
-    error = LaunchProcess (launch_info);
-    if (error.Success())
-    {
+  error = LaunchProcess(launch_info);
+  if (error.Success()) {
+    if (log)
+      log->Printf("Platform::%s LaunchProcess() call succeeded (pid=%" PRIu64
+                  ")",
+                  __FUNCTION__, launch_info.GetProcessID());
+    if (launch_info.GetProcessID() != LLDB_INVALID_PROCESS_ID) {
+      ProcessAttachInfo attach_info(launch_info);
+      process_sp = Attach(attach_info, debugger, target, error);
+      if (process_sp) {
         if (log)
-            log->Printf ("Platform::%s LaunchProcess() call succeeded (pid=%" PRIu64 ")", __FUNCTION__, launch_info.GetProcessID ());
-        if (launch_info.GetProcessID() != LLDB_INVALID_PROCESS_ID)
-        {
-            ProcessAttachInfo attach_info (launch_info);
-            process_sp = Attach (attach_info, debugger, target, error);
-            if (process_sp)
-            {
-                if (log)
-                    log->Printf ("Platform::%s Attach() succeeded, Process plugin: %s", __FUNCTION__, process_sp->GetPluginName ().AsCString ());
-                launch_info.SetHijackListener(attach_info.GetHijackListener());
-                
-                // Since we attached to the process, it will think it needs to detach
-                // if the process object just goes away without an explicit call to
-                // Process::Kill() or Process::Detach(), so let it know to kill the 
-                // process if this happens.
-                process_sp->SetShouldDetach (false);
-                
-                // If we didn't have any file actions, the pseudo terminal might
-                // have been used where the slave side was given as the file to
-                // open for stdin/out/err after we have already opened the master
-                // so we can read/write stdin/out/err.
-                int pty_fd = launch_info.GetPTY().ReleaseMasterFileDescriptor();
-                if (pty_fd != lldb_utility::PseudoTerminal::invalid_fd)
-                {
-                    process_sp->SetSTDIOFileDescriptor(pty_fd);
-                }
-            }
-            else
-            {
-                if (log)
-                    log->Printf ("Platform::%s Attach() failed: %s", __FUNCTION__, error.AsCString ());
-            }
+          log->Printf("Platform::%s Attach() succeeded, Process plugin: %s",
+                      __FUNCTION__, process_sp->GetPluginName().AsCString());
+        launch_info.SetHijackListener(attach_info.GetHijackListener());
+
+        // Since we attached to the process, it will think it needs to detach
+        // if the process object just goes away without an explicit call to
+        // Process::Kill() or Process::Detach(), so let it know to kill the
+        // process if this happens.
+        process_sp->SetShouldDetach(false);
+
+        // If we didn't have any file actions, the pseudo terminal might
+        // have been used where the slave side was given as the file to
+        // open for stdin/out/err after we have already opened the master
+        // so we can read/write stdin/out/err.
+        int pty_fd = launch_info.GetPTY().ReleaseMasterFileDescriptor();
+        if (pty_fd != lldb_utility::PseudoTerminal::invalid_fd) {
+          process_sp->SetSTDIOFileDescriptor(pty_fd);
         }
-        else
-        {
-            if (log)
-                log->Printf ("Platform::%s LaunchProcess() returned launch_info with invalid process id", __FUNCTION__);
-        }
-    }
-    else
-    {
+      } else {
         if (log)
-            log->Printf ("Platform::%s LaunchProcess() failed: %s", __FUNCTION__, error.AsCString ());
+          log->Printf("Platform::%s Attach() failed: %s", __FUNCTION__,
+                      error.AsCString());
+      }
+    } else {
+      if (log)
+        log->Printf("Platform::%s LaunchProcess() returned launch_info with "
+                    "invalid process id",
+                    __FUNCTION__);
     }
+  } else {
+    if (log)
+      log->Printf("Platform::%s LaunchProcess() failed: %s", __FUNCTION__,
+                  error.AsCString());
+  }
 
-    return process_sp;
+  return process_sp;
 }
 
 lldb::PlatformSP
-Platform::GetPlatformForArchitecture (const ArchSpec &arch, ArchSpec *platform_arch_ptr)
-{
-    lldb::PlatformSP platform_sp;
-    Error error;
-    if (arch.IsValid())
-        platform_sp = Platform::Create (arch, platform_arch_ptr, error);
-    return platform_sp;
+Platform::GetPlatformForArchitecture(const ArchSpec &arch,
+                                     ArchSpec *platform_arch_ptr) {
+  lldb::PlatformSP platform_sp;
+  Error error;
+  if (arch.IsValid())
+    platform_sp = Platform::Create(arch, platform_arch_ptr, error);
+  return platform_sp;
 }
 
 //------------------------------------------------------------------
 /// Lets a platform answer if it is compatible with a given
 /// architecture and the target triple contained within.
 //------------------------------------------------------------------
-bool
-Platform::IsCompatibleArchitecture (const ArchSpec &arch, bool exact_arch_match, ArchSpec *compatible_arch_ptr)
-{
-    // If the architecture is invalid, we must answer true...
-    if (arch.IsValid())
-    {
-        ArchSpec platform_arch;
-        // Try for an exact architecture match first.
-        if (exact_arch_match)
-        {
-            for (uint32_t arch_idx=0; GetSupportedArchitectureAtIndex (arch_idx, platform_arch); ++arch_idx)
-            {
-                if (arch.IsExactMatch(platform_arch))
-                {
-                    if (compatible_arch_ptr)
-                        *compatible_arch_ptr = platform_arch;
-                    return true;
-                }
-            }
-        }
-        else
-        {
-            for (uint32_t arch_idx=0; GetSupportedArchitectureAtIndex (arch_idx, platform_arch); ++arch_idx)
-            {
-                if (arch.IsCompatibleMatch(platform_arch))
-                {
-                    if (compatible_arch_ptr)
-                        *compatible_arch_ptr = platform_arch;
-                    return true;
-                }
-            }
-        }
-    }
-    if (compatible_arch_ptr)
-        compatible_arch_ptr->Clear();
-    return false;
-}
-
-Error
-Platform::PutFile (const FileSpec& source,
-                   const FileSpec& destination,
-                   uint32_t uid,
-                   uint32_t gid)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PLATFORM));
-    if (log)
-        log->Printf("[PutFile] Using block by block transfer....\n");
-
-    uint32_t source_open_options = File::eOpenOptionRead | File::eOpenOptionCloseOnExec;
-    if (source.GetFileType() == FileSpec::eFileTypeSymbolicLink)
-        source_open_options |= File::eOpenOptionDontFollowSymlinks;
+bool Platform::IsCompatibleArchitecture(const ArchSpec &arch,
+                                        bool exact_arch_match,
+                                        ArchSpec *compatible_arch_ptr) {
+  // If the architecture is invalid, we must answer true...
+  if (arch.IsValid()) {
+    ArchSpec platform_arch;
+    // Try for an exact architecture match first.
+    if (exact_arch_match) {
+      for (uint32_t arch_idx = 0;
+           GetSupportedArchitectureAtIndex(arch_idx, platform_arch);
+           ++arch_idx) {
+        if (arch.IsExactMatch(platform_arch)) {
+          if (compatible_arch_ptr)
+            *compatible_arch_ptr = platform_arch;
+          return true;
+        }
+      }
+    } else {
+      for (uint32_t arch_idx = 0;
+           GetSupportedArchitectureAtIndex(arch_idx, platform_arch);
+           ++arch_idx) {
+        if (arch.IsCompatibleMatch(platform_arch)) {
+          if (compatible_arch_ptr)
+            *compatible_arch_ptr = platform_arch;
+          return true;
+        }
+      }
+    }
+  }
+  if (compatible_arch_ptr)
+    compatible_arch_ptr->Clear();
+  return false;
+}
+
+Error Platform::PutFile(const FileSpec &source, const FileSpec &destination,
+                        uint32_t uid, uint32_t gid) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
+  if (log)
+    log->Printf("[PutFile] Using block by block transfer....\n");
+
+  uint32_t source_open_options =
+      File::eOpenOptionRead | File::eOpenOptionCloseOnExec;
+  if (source.GetFileType() == FileSpec::eFileTypeSymbolicLink)
+    source_open_options |= File::eOpenOptionDontFollowSymlinks;
+
+  File source_file(source, source_open_options, lldb::eFilePermissionsUserRW);
+  Error error;
+  uint32_t permissions = source_file.GetPermissions(error);
+  if (permissions == 0)
+    permissions = lldb::eFilePermissionsFileDefault;
+
+  if (!source_file.IsValid())
+    return Error("PutFile: unable to open source file");
+  lldb::user_id_t dest_file = OpenFile(
+      destination, File::eOpenOptionCanCreate | File::eOpenOptionWrite |
+                       File::eOpenOptionTruncate | File::eOpenOptionCloseOnExec,
+      permissions, error);
+  if (log)
+    log->Printf("dest_file = %" PRIu64 "\n", dest_file);
 
-    File source_file(source, source_open_options, lldb::eFilePermissionsUserRW);
-    Error error;
-    uint32_t permissions = source_file.GetPermissions(error);
-    if (permissions == 0)
-        permissions = lldb::eFilePermissionsFileDefault;
-
-    if (!source_file.IsValid())
-        return Error("PutFile: unable to open source file");
-    lldb::user_id_t dest_file = OpenFile (destination,
-                                          File::eOpenOptionCanCreate |
-                                          File::eOpenOptionWrite |
-                                          File::eOpenOptionTruncate |
-                                          File::eOpenOptionCloseOnExec,
-                                          permissions,
-                                          error);
-    if (log)
-        log->Printf ("dest_file = %" PRIu64 "\n", dest_file);
+  if (error.Fail())
+    return error;
+  if (dest_file == UINT64_MAX)
+    return Error("unable to open target file");
+  lldb::DataBufferSP buffer_sp(new DataBufferHeap(1024, 0));
+  uint64_t offset = 0;
+  for (;;) {
+    size_t bytes_read = buffer_sp->GetByteSize();
+    error = source_file.Read(buffer_sp->GetBytes(), bytes_read);
+    if (error.Fail() || bytes_read == 0)
+      break;
 
+    const uint64_t bytes_written =
+        WriteFile(dest_file, offset, buffer_sp->GetBytes(), bytes_read, error);
     if (error.Fail())
-        return error;
-    if (dest_file == UINT64_MAX)
-        return Error("unable to open target file");
-    lldb::DataBufferSP buffer_sp(new DataBufferHeap(1024, 0));
-    uint64_t offset = 0;
-    for (;;)
-    {
-        size_t bytes_read = buffer_sp->GetByteSize();
-        error = source_file.Read(buffer_sp->GetBytes(), bytes_read);
-        if (error.Fail() || bytes_read == 0)
-            break;
-
-        const uint64_t bytes_written = WriteFile(dest_file, offset,
-            buffer_sp->GetBytes(), bytes_read, error);
-        if (error.Fail())
-            break;
-
-        offset += bytes_written;
-        if (bytes_written != bytes_read)
-        {
-            // We didn't write the correct number of bytes, so adjust
-            // the file position in the source file we are reading from...
-            source_file.SeekFromStart(offset);
-        }
+      break;
+
+    offset += bytes_written;
+    if (bytes_written != bytes_read) {
+      // We didn't write the correct number of bytes, so adjust
+      // the file position in the source file we are reading from...
+      source_file.SeekFromStart(offset);
     }
-    CloseFile(dest_file, error);
+  }
+  CloseFile(dest_file, error);
 
-    if (uid == UINT32_MAX && gid == UINT32_MAX)
-        return error;
+  if (uid == UINT32_MAX && gid == UINT32_MAX)
+    return error;
 
-    // TODO: ChownFile?
+  // TODO: ChownFile?
 
-    return error;
+  return error;
 }
 
-Error
-Platform::GetFile(const FileSpec &source,
-                  const FileSpec &destination)
-{
-    Error error("unimplemented");
-    return error;
+Error Platform::GetFile(const FileSpec &source, const FileSpec &destination) {
+  Error error("unimplemented");
+  return error;
 }
 
-Error
-Platform::CreateSymlink(const FileSpec &src, // The name of the link is in src
-                        const FileSpec &dst) // The symlink points to dst
+Error Platform::CreateSymlink(
+    const FileSpec &src, // The name of the link is in src
+    const FileSpec &dst) // The symlink points to dst
 {
-    Error error("unimplemented");
-    return error;
+  Error error("unimplemented");
+  return error;
 }
 
-bool
-Platform::GetFileExists(const lldb_private::FileSpec &file_spec)
-{
-    return false;
+bool Platform::GetFileExists(const lldb_private::FileSpec &file_spec) {
+  return false;
 }
 
-Error
-Platform::Unlink(const FileSpec &path)
-{
-    Error error("unimplemented");
-    return error;
+Error Platform::Unlink(const FileSpec &path) {
+  Error error("unimplemented");
+  return error;
 }
 
-uint64_t
-Platform::ConvertMmapFlagsToPlatform(const ArchSpec &arch, unsigned flags)
-{
-    uint64_t flags_platform = 0;
-    if (flags & eMmapFlagsPrivate)
-        flags_platform |= MAP_PRIVATE;
-    if (flags & eMmapFlagsAnon)
-        flags_platform |= MAP_ANON;
-    return flags_platform;
+uint64_t Platform::ConvertMmapFlagsToPlatform(const ArchSpec &arch,
+                                              unsigned flags) {
+  uint64_t flags_platform = 0;
+  if (flags & eMmapFlagsPrivate)
+    flags_platform |= MAP_PRIVATE;
+  if (flags & eMmapFlagsAnon)
+    flags_platform |= MAP_ANON;
+  return flags_platform;
 }
 
-lldb_private::Error
-Platform::RunShellCommand(const char *command,           // Shouldn't be nullptr
-                          const FileSpec &working_dir,   // Pass empty FileSpec to use the current working directory
-                          int *status_ptr,               // Pass nullptr if you don't want the process exit status
-                          int *signo_ptr,                // Pass nullptr if you don't want the signal that caused the process to exit
-                          std::string *command_output,   // Pass nullptr if you don't want the command output
-                          uint32_t timeout_sec)          // Timeout in seconds to wait for shell program to finish
+lldb_private::Error Platform::RunShellCommand(
+    const char *command, // Shouldn't be nullptr
+    const FileSpec &
+        working_dir, // Pass empty FileSpec to use the current working directory
+    int *status_ptr, // Pass nullptr if you don't want the process exit status
+    int *signo_ptr, // Pass nullptr if you don't want the signal that caused the
+                    // process to exit
+    std::string
+        *command_output, // Pass nullptr if you don't want the command output
+    uint32_t
+        timeout_sec) // Timeout in seconds to wait for shell program to finish
 {
-    if (IsHost())
-        return Host::RunShellCommand (command, working_dir, status_ptr, signo_ptr, command_output, timeout_sec);
-    else
-        return Error("unimplemented");
+  if (IsHost())
+    return Host::RunShellCommand(command, working_dir, status_ptr, signo_ptr,
+                                 command_output, timeout_sec);
+  else
+    return Error("unimplemented");
 }
 
-bool
-Platform::CalculateMD5 (const FileSpec& file_spec,
-                        uint64_t &low,
-                        uint64_t &high)
-{
-    if (IsHost())
-        return FileSystem::CalculateMD5(file_spec, low, high);
-    else
-        return false;
+bool Platform::CalculateMD5(const FileSpec &file_spec, uint64_t &low,
+                            uint64_t &high) {
+  if (IsHost())
+    return FileSystem::CalculateMD5(file_spec, low, high);
+  else
+    return false;
 }
 
-void
-Platform::SetLocalCacheDirectory (const char* local)
-{
-    m_local_cache_directory.assign(local);
+void Platform::SetLocalCacheDirectory(const char *local) {
+  m_local_cache_directory.assign(local);
 }
 
-const char*
-Platform::GetLocalCacheDirectory ()
-{
-    return m_local_cache_directory.c_str();
+const char *Platform::GetLocalCacheDirectory() {
+  return m_local_cache_directory.c_str();
 }
 
-static OptionDefinition
-g_rsync_option_table[] =
-{
-    {   LLDB_OPT_SET_ALL, false, "rsync"                  , 'r', OptionParser::eNoArgument,       nullptr, nullptr, 0, eArgTypeNone         , "Enable rsync." },
-    {   LLDB_OPT_SET_ALL, false, "rsync-opts"             , 'R', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeCommandName  , "Platform-specific options required for rsync to work." },
-    {   LLDB_OPT_SET_ALL, false, "rsync-prefix"           , 'P', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeCommandName  , "Platform-specific rsync prefix put before the remote path." },
-    {   LLDB_OPT_SET_ALL, false, "ignore-remote-hostname" , 'i', OptionParser::eNoArgument,       nullptr, nullptr, 0, eArgTypeNone         , "Do not automatically fill in the remote hostname when composing the rsync command." },
+static OptionDefinition g_rsync_option_table[] = {
+    {LLDB_OPT_SET_ALL, false, "rsync", 'r', OptionParser::eNoArgument, nullptr,
+     nullptr, 0, eArgTypeNone, "Enable rsync."},
+    {LLDB_OPT_SET_ALL, false, "rsync-opts", 'R',
+     OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeCommandName,
+     "Platform-specific options required for rsync to work."},
+    {LLDB_OPT_SET_ALL, false, "rsync-prefix", 'P',
+     OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeCommandName,
+     "Platform-specific rsync prefix put before the remote path."},
+    {LLDB_OPT_SET_ALL, false, "ignore-remote-hostname", 'i',
+     OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone,
+     "Do not automatically fill in the remote hostname when composing the "
+     "rsync command."},
 };
 
-static OptionDefinition
-g_ssh_option_table[] =
-{
-    {   LLDB_OPT_SET_ALL, false, "ssh"                    , 's', OptionParser::eNoArgument,       nullptr, nullptr, 0, eArgTypeNone         , "Enable SSH." },
-    {   LLDB_OPT_SET_ALL, false, "ssh-opts"               , 'S', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeCommandName  , "Platform-specific options required for SSH to work." },
+static OptionDefinition g_ssh_option_table[] = {
+    {LLDB_OPT_SET_ALL, false, "ssh", 's', OptionParser::eNoArgument, nullptr,
+     nullptr, 0, eArgTypeNone, "Enable SSH."},
+    {LLDB_OPT_SET_ALL, false, "ssh-opts", 'S', OptionParser::eRequiredArgument,
+     nullptr, nullptr, 0, eArgTypeCommandName,
+     "Platform-specific options required for SSH to work."},
 };
 
-static OptionDefinition
-g_caching_option_table[] =
-{
-    {   LLDB_OPT_SET_ALL, false, "local-cache-dir"        , 'c', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypePath         , "Path in which to store local copies of files." },
+static OptionDefinition g_caching_option_table[] = {
+    {LLDB_OPT_SET_ALL, false, "local-cache-dir", 'c',
+     OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypePath,
+     "Path in which to store local copies of files."},
 };
 
-const lldb_private::OptionDefinition*
-OptionGroupPlatformRSync::GetDefinitions ()
-{
-    return g_rsync_option_table;
+const lldb_private::OptionDefinition *
+OptionGroupPlatformRSync::GetDefinitions() {
+  return g_rsync_option_table;
 }
 
-void
-OptionGroupPlatformRSync::OptionParsingStarting(ExecutionContext *execution_context)
-{
-    m_rsync = false;
-    m_rsync_opts.clear();
-    m_rsync_prefix.clear();
-    m_ignores_remote_hostname = false;
+void OptionGroupPlatformRSync::OptionParsingStarting(
+    ExecutionContext *execution_context) {
+  m_rsync = false;
+  m_rsync_opts.clear();
+  m_rsync_prefix.clear();
+  m_ignores_remote_hostname = false;
 }
 
 lldb_private::Error
 OptionGroupPlatformRSync::SetOptionValue(uint32_t option_idx,
                                          const char *option_arg,
-                                         ExecutionContext *execution_context)
-{
-    Error error;
-    char short_option = (char) GetDefinitions()[option_idx].short_option;
-    switch (short_option)
-    {
-        case 'r':
-            m_rsync = true;
-            break;
-            
-        case 'R':
-            m_rsync_opts.assign(option_arg);
-            break;
-            
-        case 'P':
-            m_rsync_prefix.assign(option_arg);
-            break;
-            
-        case 'i':
-            m_ignores_remote_hostname = true;
-            break;
-            
-        default:
-            error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
-            break;
-    }
-    
-    return error;
+                                         ExecutionContext *execution_context) {
+  Error error;
+  char short_option = (char)GetDefinitions()[option_idx].short_option;
+  switch (short_option) {
+  case 'r':
+    m_rsync = true;
+    break;
+
+  case 'R':
+    m_rsync_opts.assign(option_arg);
+    break;
+
+  case 'P':
+    m_rsync_prefix.assign(option_arg);
+    break;
+
+  case 'i':
+    m_ignores_remote_hostname = true;
+    break;
+
+  default:
+    error.SetErrorStringWithFormat("unrecognized option '%c'", short_option);
+    break;
+  }
+
+  return error;
 }
 
-uint32_t
-OptionGroupPlatformRSync::GetNumDefinitions ()
-{
-    return llvm::array_lengthof(g_rsync_option_table);
+uint32_t OptionGroupPlatformRSync::GetNumDefinitions() {
+  return llvm::array_lengthof(g_rsync_option_table);
 }
 
 lldb::BreakpointSP
-Platform::SetThreadCreationBreakpoint (lldb_private::Target &target)
-{
-    return lldb::BreakpointSP();
+Platform::SetThreadCreationBreakpoint(lldb_private::Target &target) {
+  return lldb::BreakpointSP();
 }
 
-const lldb_private::OptionDefinition*
-OptionGroupPlatformSSH::GetDefinitions ()
-{
-    return g_ssh_option_table;
+const lldb_private::OptionDefinition *OptionGroupPlatformSSH::GetDefinitions() {
+  return g_ssh_option_table;
 }
 
-void
-OptionGroupPlatformSSH::OptionParsingStarting(ExecutionContext
-                                              *execution_context)
-{
-    m_ssh = false;
-    m_ssh_opts.clear();
+void OptionGroupPlatformSSH::OptionParsingStarting(
+    ExecutionContext *execution_context) {
+  m_ssh = false;
+  m_ssh_opts.clear();
 }
 
 lldb_private::Error
 OptionGroupPlatformSSH::SetOptionValue(uint32_t option_idx,
                                        const char *option_arg,
-                                       ExecutionContext *execution_context)
-{
-    Error error;
-    char short_option = (char) GetDefinitions()[option_idx].short_option;
-    switch (short_option)
-    {
-        case 's':
-            m_ssh = true;
-            break;
-            
-        case 'S':
-            m_ssh_opts.assign(option_arg);
-            break;
-            
-        default:
-            error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
-            break;
-    }
-    
-    return error;
-}
+                                       ExecutionContext *execution_context) {
+  Error error;
+  char short_option = (char)GetDefinitions()[option_idx].short_option;
+  switch (short_option) {
+  case 's':
+    m_ssh = true;
+    break;
 
-uint32_t
-OptionGroupPlatformSSH::GetNumDefinitions ()
-{
-    return llvm::array_lengthof(g_ssh_option_table);
-}
+  case 'S':
+    m_ssh_opts.assign(option_arg);
+    break;
 
-const lldb_private::OptionDefinition*
-OptionGroupPlatformCaching::GetDefinitions ()
-{
-    return g_caching_option_table;
-}
+  default:
+    error.SetErrorStringWithFormat("unrecognized option '%c'", short_option);
+    break;
+  }
 
-void
-OptionGroupPlatformCaching::OptionParsingStarting(ExecutionContext
-                                                  *execution_context)
-{
-    m_cache_dir.clear();
+  return error;
 }
 
-lldb_private::Error
-OptionGroupPlatformCaching::SetOptionValue(uint32_t option_idx,
-                                           const char *option_arg,
-                                           ExecutionContext *execution_context)
-{
-    Error error;
-    char short_option = (char) GetDefinitions()[option_idx].short_option;
-    switch (short_option)
-    {
-        case 'c':
-            m_cache_dir.assign(option_arg);
-            break;
-            
-        default:
-            error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
-            break;
-    }
-    
-    return error;
+uint32_t OptionGroupPlatformSSH::GetNumDefinitions() {
+  return llvm::array_lengthof(g_ssh_option_table);
 }
 
-uint32_t
-OptionGroupPlatformCaching::GetNumDefinitions ()
-{
-    return llvm::array_lengthof(g_caching_option_table);
+const lldb_private::OptionDefinition *
+OptionGroupPlatformCaching::GetDefinitions() {
+  return g_caching_option_table;
 }
 
-size_t
-Platform::GetEnvironment (StringList &environment)
-{
-    environment.Clear();
-    return false;
+void OptionGroupPlatformCaching::OptionParsingStarting(
+    ExecutionContext *execution_context) {
+  m_cache_dir.clear();
 }
 
-const std::vector<ConstString> &
-Platform::GetTrapHandlerSymbolNames ()
-{
-    if (!m_calculated_trap_handlers)
-    {
-        std::lock_guard<std::mutex> guard(m_mutex);
-        if (!m_calculated_trap_handlers)
-        {
-            CalculateTrapHandlerSymbolNames();
-            m_calculated_trap_handlers = true;
-        }
-    }
-    return m_trap_handlers;
-}
+lldb_private::Error OptionGroupPlatformCaching::SetOptionValue(
+    uint32_t option_idx, const char *option_arg,
+    ExecutionContext *execution_context) {
+  Error error;
+  char short_option = (char)GetDefinitions()[option_idx].short_option;
+  switch (short_option) {
+  case 'c':
+    m_cache_dir.assign(option_arg);
+    break;
 
-Error
-Platform::GetCachedExecutable (ModuleSpec &module_spec,
-                               lldb::ModuleSP &module_sp,
-                               const FileSpecList *module_search_paths_ptr,
-                               Platform &remote_platform)
-{
-    const auto platform_spec = module_spec.GetFileSpec ();
-    const auto error = LoadCachedExecutable (module_spec,
-                                             module_sp,
-                                             module_search_paths_ptr,
-                                             remote_platform);
-    if (error.Success ())
-    {
-        module_spec.GetFileSpec () = module_sp->GetFileSpec ();
-        module_spec.GetPlatformFileSpec () = platform_spec;
-    }
+  default:
+    error.SetErrorStringWithFormat("unrecognized option '%c'", short_option);
+    break;
+  }
 
-    return error;
+  return error;
 }
 
-Error
-Platform::LoadCachedExecutable (const ModuleSpec &module_spec,
-                                lldb::ModuleSP &module_sp,
-                                const FileSpecList *module_search_paths_ptr,
-                                Platform &remote_platform)
-{
-    return GetRemoteSharedModule (module_spec,
-                                  nullptr,
-                                  module_sp,
-                                  [&](const ModuleSpec &spec)
-                                  {
-                                      return remote_platform.ResolveExecutable (
-                                          spec, module_sp, module_search_paths_ptr);
-                                  },
-                                  nullptr);
-}
-
-Error
-Platform::GetRemoteSharedModule (const ModuleSpec &module_spec,
-                                 Process* process,
-                                 lldb::ModuleSP &module_sp,
-                                 const ModuleResolver &module_resolver,
-                                 bool *did_create_ptr)
-{
-    // Get module information from a target.
-    ModuleSpec resolved_module_spec;
-    bool got_module_spec = false;
-    if (process)
-    {
-        // Try to get module information from the process
-        if (process->GetModuleSpec (module_spec.GetFileSpec (), module_spec.GetArchitecture (), resolved_module_spec))
-        {
-            if (module_spec.GetUUID().IsValid() == false || module_spec.GetUUID() == resolved_module_spec.GetUUID())
-            {
-                got_module_spec = true;
-            }
-        }
-    }
+uint32_t OptionGroupPlatformCaching::GetNumDefinitions() {
+  return llvm::array_lengthof(g_caching_option_table);
+}
 
-    if (!got_module_spec)
-    {
-        // Get module information from a target.
-        if (!GetModuleSpec (module_spec.GetFileSpec (), module_spec.GetArchitecture (), resolved_module_spec))
-        {
-            if (module_spec.GetUUID().IsValid() == false || module_spec.GetUUID() == resolved_module_spec.GetUUID())
-            {
-                return module_resolver (module_spec);
-            }
-        }
-    }
+size_t Platform::GetEnvironment(StringList &environment) {
+  environment.Clear();
+  return false;
+}
 
-    // If we are looking for a specific UUID, make sure resolved_module_spec has the same one before we search.
-    if (module_spec.GetUUID().IsValid())
-    {
-        resolved_module_spec.GetUUID() = module_spec.GetUUID();
+const std::vector<ConstString> &Platform::GetTrapHandlerSymbolNames() {
+  if (!m_calculated_trap_handlers) {
+    std::lock_guard<std::mutex> guard(m_mutex);
+    if (!m_calculated_trap_handlers) {
+      CalculateTrapHandlerSymbolNames();
+      m_calculated_trap_handlers = true;
+    }
+  }
+  return m_trap_handlers;
+}
+
+Error Platform::GetCachedExecutable(ModuleSpec &module_spec,
+                                    lldb::ModuleSP &module_sp,
+                                    const FileSpecList *module_search_paths_ptr,
+                                    Platform &remote_platform) {
+  const auto platform_spec = module_spec.GetFileSpec();
+  const auto error = LoadCachedExecutable(
+      module_spec, module_sp, module_search_paths_ptr, remote_platform);
+  if (error.Success()) {
+    module_spec.GetFileSpec() = module_sp->GetFileSpec();
+    module_spec.GetPlatformFileSpec() = platform_spec;
+  }
+
+  return error;
+}
+
+Error Platform::LoadCachedExecutable(
+    const ModuleSpec &module_spec, lldb::ModuleSP &module_sp,
+    const FileSpecList *module_search_paths_ptr, Platform &remote_platform) {
+  return GetRemoteSharedModule(module_spec, nullptr, module_sp,
+                               [&](const ModuleSpec &spec) {
+                                 return remote_platform.ResolveExecutable(
+                                     spec, module_sp, module_search_paths_ptr);
+                               },
+                               nullptr);
+}
+
+Error Platform::GetRemoteSharedModule(const ModuleSpec &module_spec,
+                                      Process *process,
+                                      lldb::ModuleSP &module_sp,
+                                      const ModuleResolver &module_resolver,
+                                      bool *did_create_ptr) {
+  // Get module information from a target.
+  ModuleSpec resolved_module_spec;
+  bool got_module_spec = false;
+  if (process) {
+    // Try to get module information from the process
+    if (process->GetModuleSpec(module_spec.GetFileSpec(),
+                               module_spec.GetArchitecture(),
+                               resolved_module_spec)) {
+      if (module_spec.GetUUID().IsValid() == false ||
+          module_spec.GetUUID() == resolved_module_spec.GetUUID()) {
+        got_module_spec = true;
+      }
     }
+  }
 
-    // Trying to find a module by UUID on local file system.
-    const auto error = module_resolver (resolved_module_spec);
-    if (error.Fail ())
-     {
-          if (GetCachedSharedModule (resolved_module_spec, module_sp, did_create_ptr))
-              return Error ();
-     }
+  if (!got_module_spec) {
+    // Get module information from a target.
+    if (!GetModuleSpec(module_spec.GetFileSpec(), module_spec.GetArchitecture(),
+                       resolved_module_spec)) {
+      if (module_spec.GetUUID().IsValid() == false ||
+          module_spec.GetUUID() == resolved_module_spec.GetUUID()) {
+        return module_resolver(module_spec);
+      }
+    }
+  }
+
+  // If we are looking for a specific UUID, make sure resolved_module_spec has
+  // the same one before we search.
+  if (module_spec.GetUUID().IsValid()) {
+    resolved_module_spec.GetUUID() = module_spec.GetUUID();
+  }
+
+  // Trying to find a module by UUID on local file system.
+  const auto error = module_resolver(resolved_module_spec);
+  if (error.Fail()) {
+    if (GetCachedSharedModule(resolved_module_spec, module_sp, did_create_ptr))
+      return Error();
+  }
+
+  return error;
+}
+
+bool Platform::GetCachedSharedModule(const ModuleSpec &module_spec,
+                                     lldb::ModuleSP &module_sp,
+                                     bool *did_create_ptr) {
+  if (IsHost() || !GetGlobalPlatformProperties()->GetUseModuleCache() ||
+      !GetGlobalPlatformProperties()->GetModuleCacheDirectory())
+    return false;
 
-    return error;
-}
+  Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM);
 
-bool
-Platform::GetCachedSharedModule (const ModuleSpec &module_spec,
-                                 lldb::ModuleSP &module_sp,
-                                 bool *did_create_ptr)
-{
-    if (IsHost() ||
-        !GetGlobalPlatformProperties ()->GetUseModuleCache () ||
-        !GetGlobalPlatformProperties ()->GetModuleCacheDirectory ())
-        return false;
-
-    Log *log = GetLogIfAnyCategoriesSet (LIBLLDB_LOG_PLATFORM);
-
-    // Check local cache for a module.
-    auto error = m_module_cache->GetAndPut (
-        GetModuleCacheRoot (),
-        GetCacheHostname (),
-        module_spec,
-        [this](const ModuleSpec &module_spec, const FileSpec &tmp_download_file_spec)
-        {
-            return DownloadModuleSlice (module_spec.GetFileSpec (),
-                                        module_spec.GetObjectOffset (),
-                                        module_spec.GetObjectSize (),
-                                        tmp_download_file_spec);
-
-        },
-        [this](const ModuleSP& module_sp, const FileSpec& tmp_download_file_spec)
-        {
-            return DownloadSymbolFile (module_sp, tmp_download_file_spec);
-        },
-        module_sp,
-        did_create_ptr);
-    if (error.Success ())
-        return true;
+  // Check local cache for a module.
+  auto error = m_module_cache->GetAndPut(
+      GetModuleCacheRoot(), GetCacheHostname(), module_spec,
+      [this](const ModuleSpec &module_spec,
+             const FileSpec &tmp_download_file_spec) {
+        return DownloadModuleSlice(
+            module_spec.GetFileSpec(), module_spec.GetObjectOffset(),
+            module_spec.GetObjectSize(), tmp_download_file_spec);
+
+      },
+      [this](const ModuleSP &module_sp,
+             const FileSpec &tmp_download_file_spec) {
+        return DownloadSymbolFile(module_sp, tmp_download_file_spec);
+      },
+      module_sp, did_create_ptr);
+  if (error.Success())
+    return true;
 
-    if (log)
-        log->Printf("Platform::%s - module %s not found in local cache: %s",
-                    __FUNCTION__, module_spec.GetUUID ().GetAsString ().c_str (), error.AsCString ());
-    return false;
-}
+  if (log)
+    log->Printf("Platform::%s - module %s not found in local cache: %s",
+                __FUNCTION__, module_spec.GetUUID().GetAsString().c_str(),
+                error.AsCString());
+  return false;
+}
+
+Error Platform::DownloadModuleSlice(const FileSpec &src_file_spec,
+                                    const uint64_t src_offset,
+                                    const uint64_t src_size,
+                                    const FileSpec &dst_file_spec) {
+  Error error;
+
+  std::ofstream dst(dst_file_spec.GetPath(), std::ios::out | std::ios::binary);
+  if (!dst.is_open()) {
+    error.SetErrorStringWithFormat("unable to open destination file: %s",
+                                   dst_file_spec.GetPath().c_str());
+    return error;
+  }
 
-Error
-Platform::DownloadModuleSlice (const FileSpec& src_file_spec,
-                               const uint64_t src_offset,
-                               const uint64_t src_size,
-                               const FileSpec& dst_file_spec)
-{
-    Error error;
+  auto src_fd = OpenFile(src_file_spec, File::eOpenOptionRead,
+                         lldb::eFilePermissionsFileDefault, error);
 
-    std::ofstream dst (dst_file_spec.GetPath(), std::ios::out | std::ios::binary);
-    if (!dst.is_open())
-    {
-        error.SetErrorStringWithFormat ("unable to open destination file: %s", dst_file_spec.GetPath ().c_str ());
-        return error;
-    }
+  if (error.Fail()) {
+    error.SetErrorStringWithFormat("unable to open source file: %s",
+                                   error.AsCString());
+    return error;
+  }
 
-    auto src_fd = OpenFile (src_file_spec,
-                            File::eOpenOptionRead,
-                            lldb::eFilePermissionsFileDefault,
-                            error);
-
-   if (error.Fail ())
-   {
-       error.SetErrorStringWithFormat ("unable to open source file: %s", error.AsCString ());
-       return error;
-   }
-
-    std::vector<char> buffer (1024);
-    auto offset = src_offset;
-    uint64_t total_bytes_read = 0;
-    while (total_bytes_read < src_size)
-    {
-        const auto to_read = std::min (static_cast<uint64_t>(buffer.size ()), src_size - total_bytes_read);
-        const uint64_t n_read = ReadFile (src_fd, offset, &buffer[0], to_read, error);
-        if (error.Fail ())
-            break;
-        if (n_read == 0)
-        {
-            error.SetErrorString ("read 0 bytes");
-            break;
-        }
-        offset += n_read;
-        total_bytes_read += n_read;
-        dst.write (&buffer[0], n_read);
+  std::vector<char> buffer(1024);
+  auto offset = src_offset;
+  uint64_t total_bytes_read = 0;
+  while (total_bytes_read < src_size) {
+    const auto to_read = std::min(static_cast<uint64_t>(buffer.size()),
+                                  src_size - total_bytes_read);
+    const uint64_t n_read =
+        ReadFile(src_fd, offset, &buffer[0], to_read, error);
+    if (error.Fail())
+      break;
+    if (n_read == 0) {
+      error.SetErrorString("read 0 bytes");
+      break;
     }
+    offset += n_read;
+    total_bytes_read += n_read;
+    dst.write(&buffer[0], n_read);
+  }
 
-    Error close_error;
-    CloseFile (src_fd, close_error);  // Ignoring close error.
+  Error close_error;
+  CloseFile(src_fd, close_error); // Ignoring close error.
 
-    return error;
+  return error;
 }
 
-Error
-Platform::DownloadSymbolFile (const lldb::ModuleSP& module_sp, const FileSpec& dst_file_spec)
-{
-    return Error ("Symbol file downloading not supported by the default platform.");
+Error Platform::DownloadSymbolFile(const lldb::ModuleSP &module_sp,
+                                   const FileSpec &dst_file_spec) {
+  return Error(
+      "Symbol file downloading not supported by the default platform.");
 }
 
-FileSpec
-Platform::GetModuleCacheRoot ()
-{
-    auto dir_spec = GetGlobalPlatformProperties ()->GetModuleCacheDirectory ();
-    dir_spec.AppendPathComponent (GetName ().AsCString ());
-    return dir_spec;
+FileSpec Platform::GetModuleCacheRoot() {
+  auto dir_spec = GetGlobalPlatformProperties()->GetModuleCacheDirectory();
+  dir_spec.AppendPathComponent(GetName().AsCString());
+  return dir_spec;
 }
 
-const char *
-Platform::GetCacheHostname ()
-{
-    return GetHostname ();
-}
+const char *Platform::GetCacheHostname() { return GetHostname(); }
 
-const UnixSignalsSP &
-Platform::GetRemoteUnixSignals()
-{
-    static const auto s_default_unix_signals_sp = std::make_shared<UnixSignals>();
-    return s_default_unix_signals_sp;
+const UnixSignalsSP &Platform::GetRemoteUnixSignals() {
+  static const auto s_default_unix_signals_sp = std::make_shared<UnixSignals>();
+  return s_default_unix_signals_sp;
 }
 
-const UnixSignalsSP &
-Platform::GetUnixSignals()
-{
-    if (IsHost())
-        return Host::GetUnixSignals();
-    return GetRemoteUnixSignals();
+const UnixSignalsSP &Platform::GetUnixSignals() {
+  if (IsHost())
+    return Host::GetUnixSignals();
+  return GetRemoteUnixSignals();
 }
 
-uint32_t
-Platform::LoadImage(lldb_private::Process* process,
-                    const lldb_private::FileSpec& local_file,
-                    const lldb_private::FileSpec& remote_file,
-                    lldb_private::Error& error)
-{
-    if (local_file && remote_file)
-    {
-        // Both local and remote file was specified. Install the local file to the given location.
-        if (IsRemote() || local_file != remote_file)
-        {
-            error = Install(local_file, remote_file);
-            if (error.Fail())
-                return LLDB_INVALID_IMAGE_TOKEN;
-        }
-        return DoLoadImage(process, remote_file, error);
+uint32_t Platform::LoadImage(lldb_private::Process *process,
+                             const lldb_private::FileSpec &local_file,
+                             const lldb_private::FileSpec &remote_file,
+                             lldb_private::Error &error) {
+  if (local_file && remote_file) {
+    // Both local and remote file was specified. Install the local file to the
+    // given location.
+    if (IsRemote() || local_file != remote_file) {
+      error = Install(local_file, remote_file);
+      if (error.Fail())
+        return LLDB_INVALID_IMAGE_TOKEN;
     }
+    return DoLoadImage(process, remote_file, error);
+  }
 
-    if (local_file)
-    {
-        // Only local file was specified. Install it to the current working directory.
-        FileSpec target_file = GetWorkingDirectory();
-        target_file.AppendPathComponent(local_file.GetFilename().AsCString());
-        if (IsRemote() || local_file != target_file)
-        {
-            error = Install(local_file, target_file);
-            if (error.Fail())
-                return LLDB_INVALID_IMAGE_TOKEN;
-        }
-        return DoLoadImage(process, target_file, error);
+  if (local_file) {
+    // Only local file was specified. Install it to the current working
+    // directory.
+    FileSpec target_file = GetWorkingDirectory();
+    target_file.AppendPathComponent(local_file.GetFilename().AsCString());
+    if (IsRemote() || local_file != target_file) {
+      error = Install(local_file, target_file);
+      if (error.Fail())
+        return LLDB_INVALID_IMAGE_TOKEN;
     }
+    return DoLoadImage(process, target_file, error);
+  }
 
-    if (remote_file)
-    {
-        // Only remote file was specified so we don't have to do any copying
-        return DoLoadImage(process, remote_file, error);
-    }
+  if (remote_file) {
+    // Only remote file was specified so we don't have to do any copying
+    return DoLoadImage(process, remote_file, error);
+  }
 
-    error.SetErrorString("Neither local nor remote file was specified");
-    return LLDB_INVALID_IMAGE_TOKEN;
+  error.SetErrorString("Neither local nor remote file was specified");
+  return LLDB_INVALID_IMAGE_TOKEN;
 }
 
-uint32_t
-Platform::DoLoadImage (lldb_private::Process* process,
-                       const lldb_private::FileSpec& remote_file,
-                       lldb_private::Error& error)
-{
-    error.SetErrorString("LoadImage is not supported on the current platform");
-    return LLDB_INVALID_IMAGE_TOKEN;
+uint32_t Platform::DoLoadImage(lldb_private::Process *process,
+                               const lldb_private::FileSpec &remote_file,
+                               lldb_private::Error &error) {
+  error.SetErrorString("LoadImage is not supported on the current platform");
+  return LLDB_INVALID_IMAGE_TOKEN;
 }
 
-Error
-Platform::UnloadImage(lldb_private::Process* process, uint32_t image_token)
-{
-    return Error("UnloadImage is not supported on the current platform");
+Error Platform::UnloadImage(lldb_private::Process *process,
+                            uint32_t image_token) {
+  return Error("UnloadImage is not supported on the current platform");
 }
 
-lldb::ProcessSP
-Platform::ConnectProcess(const char* connect_url,
-                         const char* plugin_name,
-                         lldb_private::Debugger &debugger,
-                         lldb_private::Target *target,
-                         lldb_private::Error &error)
-{
-    error.Clear();
+lldb::ProcessSP Platform::ConnectProcess(const char *connect_url,
+                                         const char *plugin_name,
+                                         lldb_private::Debugger &debugger,
+                                         lldb_private::Target *target,
+                                         lldb_private::Error &error) {
+  error.Clear();
 
-    if (!target)
-    {
-        TargetSP new_target_sp;
-        error = debugger.GetTargetList().CreateTarget(debugger,
-                                                      nullptr,
-                                                      nullptr,
-                                                      false,
-                                                      nullptr,
-                                                      new_target_sp);
-        target = new_target_sp.get();
-    }
-
-    if (!target || error.Fail())
-        return nullptr;
-
-    debugger.GetTargetList().SetSelectedTarget(target);
-
-    lldb::ProcessSP process_sp = target->CreateProcess(debugger.GetListener(),
-                                                       plugin_name,
-                                                       nullptr);
-    if (!process_sp)
-        return nullptr;
-
-    error = process_sp->ConnectRemote(debugger.GetOutputFile().get(), connect_url);
-    if (error.Fail())
-        return nullptr;
-
-    return process_sp;
-}
-
-size_t
-Platform::ConnectToWaitingProcesses(lldb_private::Debugger& debugger, lldb_private::Error& error)
-{
-    error.Clear();
-    return 0;
-}
-
-size_t
-Platform::GetSoftwareBreakpointTrapOpcode(Target &target, BreakpointSite *bp_site)
-{
-    ArchSpec arch = target.GetArchitecture();
-    const uint8_t *trap_opcode = nullptr;
-    size_t trap_opcode_size = 0;
-
-    switch (arch.GetMachine())
-    {
-    case llvm::Triple::aarch64:
-        {
-            static const uint8_t g_aarch64_opcode[] = {0x00, 0x00, 0x20, 0xd4};
-            trap_opcode = g_aarch64_opcode;
-            trap_opcode_size = sizeof(g_aarch64_opcode);
-        }
-        break;
-
-    // TODO: support big-endian arm and thumb trap codes.
-    case llvm::Triple::arm:
-        {
-            // The ARM reference recommends the use of 0xe7fddefe and 0xdefe
-            // but the linux kernel does otherwise.
-            static const uint8_t g_arm_breakpoint_opcode[] = {0xf0, 0x01, 0xf0, 0xe7};
-            static const uint8_t g_thumb_breakpoint_opcode[] = {0x01, 0xde};
-
-            lldb::BreakpointLocationSP bp_loc_sp(bp_site->GetOwnerAtIndex(0));
-            AddressClass addr_class = eAddressClassUnknown;
-
-            if (bp_loc_sp)
-            {
-                addr_class = bp_loc_sp->GetAddress().GetAddressClass();
-                if (addr_class == eAddressClassUnknown && (bp_loc_sp->GetAddress().GetFileAddress() & 1))
-                    addr_class = eAddressClassCodeAlternateISA;
-            }
-
-            if (addr_class == eAddressClassCodeAlternateISA)
-            {
-                trap_opcode = g_thumb_breakpoint_opcode;
-                trap_opcode_size = sizeof(g_thumb_breakpoint_opcode);
-            }
-            else
-            {
-                trap_opcode = g_arm_breakpoint_opcode;
-                trap_opcode_size = sizeof(g_arm_breakpoint_opcode);
-            }
-        }
-        break;
-
-    case llvm::Triple::mips:
-    case llvm::Triple::mips64:
-        {
-            static const uint8_t g_hex_opcode[] = {0x00, 0x00, 0x00, 0x0d};
-            trap_opcode = g_hex_opcode;
-            trap_opcode_size = sizeof(g_hex_opcode);
-        }
-        break;
+  if (!target) {
+    TargetSP new_target_sp;
+    error = debugger.GetTargetList().CreateTarget(
+        debugger, nullptr, nullptr, false, nullptr, new_target_sp);
+    target = new_target_sp.get();
+  }
 
-    case llvm::Triple::mipsel:
-    case llvm::Triple::mips64el:
-        {
-            static const uint8_t g_hex_opcode[] = {0x0d, 0x00, 0x00, 0x00};
-            trap_opcode = g_hex_opcode;
-            trap_opcode_size = sizeof(g_hex_opcode);
-        }
-        break;
-
-    case llvm::Triple::systemz:
-        {
-            static const uint8_t g_hex_opcode[] = {0x00, 0x01};
-            trap_opcode = g_hex_opcode;
-            trap_opcode_size = sizeof(g_hex_opcode);
-        }
-        break;
+  if (!target || error.Fail())
+    return nullptr;
 
-    case llvm::Triple::hexagon:
-        {
-            static const uint8_t g_hex_opcode[] = {0x0c, 0xdb, 0x00, 0x54};
-            trap_opcode = g_hex_opcode;
-            trap_opcode_size = sizeof(g_hex_opcode);
-        }
-        break;
+  debugger.GetTargetList().SetSelectedTarget(target);
 
-    case llvm::Triple::ppc:
-    case llvm::Triple::ppc64:
-        {
-            static const uint8_t g_ppc_opcode[] = {0x7f, 0xe0, 0x00, 0x08};
-            trap_opcode = g_ppc_opcode;
-            trap_opcode_size = sizeof(g_ppc_opcode);
-        }
-        break;
+  lldb::ProcessSP process_sp =
+      target->CreateProcess(debugger.GetListener(), plugin_name, nullptr);
+  if (!process_sp)
+    return nullptr;
 
-    case llvm::Triple::x86:
-    case llvm::Triple::x86_64:
-        {
-            static const uint8_t g_i386_opcode[] = {0xCC};
-            trap_opcode = g_i386_opcode;
-            trap_opcode_size = sizeof(g_i386_opcode);
-        }
-        break;
+  error =
+      process_sp->ConnectRemote(debugger.GetOutputFile().get(), connect_url);
+  if (error.Fail())
+    return nullptr;
 
-    default:
-        assert(!"Unhandled architecture in Platform::GetSoftwareBreakpointTrapOpcode");
-        break;
-    }
+  return process_sp;
+}
 
-    assert(bp_site);
-    if (bp_site->SetTrapOpcode(trap_opcode, trap_opcode_size))
-        return trap_opcode_size;
+size_t Platform::ConnectToWaitingProcesses(lldb_private::Debugger &debugger,
+                                           lldb_private::Error &error) {
+  error.Clear();
+  return 0;
+}
+
+size_t Platform::GetSoftwareBreakpointTrapOpcode(Target &target,
+                                                 BreakpointSite *bp_site) {
+  ArchSpec arch = target.GetArchitecture();
+  const uint8_t *trap_opcode = nullptr;
+  size_t trap_opcode_size = 0;
+
+  switch (arch.GetMachine()) {
+  case llvm::Triple::aarch64: {
+    static const uint8_t g_aarch64_opcode[] = {0x00, 0x00, 0x20, 0xd4};
+    trap_opcode = g_aarch64_opcode;
+    trap_opcode_size = sizeof(g_aarch64_opcode);
+  } break;
+
+  // TODO: support big-endian arm and thumb trap codes.
+  case llvm::Triple::arm: {
+    // The ARM reference recommends the use of 0xe7fddefe and 0xdefe
+    // but the linux kernel does otherwise.
+    static const uint8_t g_arm_breakpoint_opcode[] = {0xf0, 0x01, 0xf0, 0xe7};
+    static const uint8_t g_thumb_breakpoint_opcode[] = {0x01, 0xde};
+
+    lldb::BreakpointLocationSP bp_loc_sp(bp_site->GetOwnerAtIndex(0));
+    AddressClass addr_class = eAddressClassUnknown;
+
+    if (bp_loc_sp) {
+      addr_class = bp_loc_sp->GetAddress().GetAddressClass();
+      if (addr_class == eAddressClassUnknown &&
+          (bp_loc_sp->GetAddress().GetFileAddress() & 1))
+        addr_class = eAddressClassCodeAlternateISA;
+    }
+
+    if (addr_class == eAddressClassCodeAlternateISA) {
+      trap_opcode = g_thumb_breakpoint_opcode;
+      trap_opcode_size = sizeof(g_thumb_breakpoint_opcode);
+    } else {
+      trap_opcode = g_arm_breakpoint_opcode;
+      trap_opcode_size = sizeof(g_arm_breakpoint_opcode);
+    }
+  } break;
+
+  case llvm::Triple::mips:
+  case llvm::Triple::mips64: {
+    static const uint8_t g_hex_opcode[] = {0x00, 0x00, 0x00, 0x0d};
+    trap_opcode = g_hex_opcode;
+    trap_opcode_size = sizeof(g_hex_opcode);
+  } break;
+
+  case llvm::Triple::mipsel:
+  case llvm::Triple::mips64el: {
+    static const uint8_t g_hex_opcode[] = {0x0d, 0x00, 0x00, 0x00};
+    trap_opcode = g_hex_opcode;
+    trap_opcode_size = sizeof(g_hex_opcode);
+  } break;
+
+  case llvm::Triple::systemz: {
+    static const uint8_t g_hex_opcode[] = {0x00, 0x01};
+    trap_opcode = g_hex_opcode;
+    trap_opcode_size = sizeof(g_hex_opcode);
+  } break;
+
+  case llvm::Triple::hexagon: {
+    static const uint8_t g_hex_opcode[] = {0x0c, 0xdb, 0x00, 0x54};
+    trap_opcode = g_hex_opcode;
+    trap_opcode_size = sizeof(g_hex_opcode);
+  } break;
+
+  case llvm::Triple::ppc:
+  case llvm::Triple::ppc64: {
+    static const uint8_t g_ppc_opcode[] = {0x7f, 0xe0, 0x00, 0x08};
+    trap_opcode = g_ppc_opcode;
+    trap_opcode_size = sizeof(g_ppc_opcode);
+  } break;
+
+  case llvm::Triple::x86:
+  case llvm::Triple::x86_64: {
+    static const uint8_t g_i386_opcode[] = {0xCC};
+    trap_opcode = g_i386_opcode;
+    trap_opcode_size = sizeof(g_i386_opcode);
+  } break;
+
+  default:
+    assert(
+        !"Unhandled architecture in Platform::GetSoftwareBreakpointTrapOpcode");
+    break;
+  }
+
+  assert(bp_site);
+  if (bp_site->SetTrapOpcode(trap_opcode, trap_opcode_size))
+    return trap_opcode_size;
 
-    return 0;
+  return 0;
 }




More information about the lldb-commits mailing list