[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/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp Tue Sep  6 15:57:50 2016
@@ -7,7 +7,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#if defined (__arm64__) || defined (__aarch64__)
+#if defined(__arm64__) || defined(__aarch64__)
 
 #include "NativeRegisterContextLinux_arm.h"
 #include "NativeRegisterContextLinux_arm64.h"
@@ -27,7 +27,8 @@
 #include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
 #include "Plugins/Process/Utility/RegisterContextLinux_arm64.h"
 
-// System includes - They have to be included after framework includes because they define some
+// System includes - They have to be included after framework includes because
+// they define some
 // macros which collide with variable names in other modules
 #include <sys/socket.h>
 // NT_PRSTATUS and NT_FPREGSET definition
@@ -42,1051 +43,930 @@ using namespace lldb_private;
 using namespace lldb_private::process_linux;
 
 // ARM64 general purpose registers.
-static const uint32_t g_gpr_regnums_arm64[] =
-{
-    gpr_x0_arm64,
-    gpr_x1_arm64,
-    gpr_x2_arm64,
-    gpr_x3_arm64,
-    gpr_x4_arm64,
-    gpr_x5_arm64,
-    gpr_x6_arm64,
-    gpr_x7_arm64,
-    gpr_x8_arm64,
-    gpr_x9_arm64,
-    gpr_x10_arm64,
-    gpr_x11_arm64,
-    gpr_x12_arm64,
-    gpr_x13_arm64,
-    gpr_x14_arm64,
-    gpr_x15_arm64,
-    gpr_x16_arm64,
-    gpr_x17_arm64,
-    gpr_x18_arm64,
-    gpr_x19_arm64,
-    gpr_x20_arm64,
-    gpr_x21_arm64,
-    gpr_x22_arm64,
-    gpr_x23_arm64,
-    gpr_x24_arm64,
-    gpr_x25_arm64,
-    gpr_x26_arm64,
-    gpr_x27_arm64,
-    gpr_x28_arm64,
-    gpr_fp_arm64,
-    gpr_lr_arm64,
-    gpr_sp_arm64,
-    gpr_pc_arm64,
-    gpr_cpsr_arm64,
+static const uint32_t g_gpr_regnums_arm64[] = {
+    gpr_x0_arm64,       gpr_x1_arm64,   gpr_x2_arm64,  gpr_x3_arm64,
+    gpr_x4_arm64,       gpr_x5_arm64,   gpr_x6_arm64,  gpr_x7_arm64,
+    gpr_x8_arm64,       gpr_x9_arm64,   gpr_x10_arm64, gpr_x11_arm64,
+    gpr_x12_arm64,      gpr_x13_arm64,  gpr_x14_arm64, gpr_x15_arm64,
+    gpr_x16_arm64,      gpr_x17_arm64,  gpr_x18_arm64, gpr_x19_arm64,
+    gpr_x20_arm64,      gpr_x21_arm64,  gpr_x22_arm64, gpr_x23_arm64,
+    gpr_x24_arm64,      gpr_x25_arm64,  gpr_x26_arm64, gpr_x27_arm64,
+    gpr_x28_arm64,      gpr_fp_arm64,   gpr_lr_arm64,  gpr_sp_arm64,
+    gpr_pc_arm64,       gpr_cpsr_arm64,
     LLDB_INVALID_REGNUM // register sets need to end with this flag
 };
-static_assert(((sizeof g_gpr_regnums_arm64 / sizeof g_gpr_regnums_arm64[0]) - 1) == k_num_gpr_registers_arm64, \
+static_assert(((sizeof g_gpr_regnums_arm64 / sizeof g_gpr_regnums_arm64[0]) -
+               1) == k_num_gpr_registers_arm64,
               "g_gpr_regnums_arm64 has wrong number of register infos");
 
 // ARM64 floating point registers.
-static const uint32_t g_fpu_regnums_arm64[] =
-{
-    fpu_v0_arm64,
-    fpu_v1_arm64,
-    fpu_v2_arm64,
-    fpu_v3_arm64,
-    fpu_v4_arm64,
-    fpu_v5_arm64,
-    fpu_v6_arm64,
-    fpu_v7_arm64,
-    fpu_v8_arm64,
-    fpu_v9_arm64,
-    fpu_v10_arm64,
-    fpu_v11_arm64,
-    fpu_v12_arm64,
-    fpu_v13_arm64,
-    fpu_v14_arm64,
-    fpu_v15_arm64,
-    fpu_v16_arm64,
-    fpu_v17_arm64,
-    fpu_v18_arm64,
-    fpu_v19_arm64,
-    fpu_v20_arm64,
-    fpu_v21_arm64,
-    fpu_v22_arm64,
-    fpu_v23_arm64,
-    fpu_v24_arm64,
-    fpu_v25_arm64,
-    fpu_v26_arm64,
-    fpu_v27_arm64,
-    fpu_v28_arm64,
-    fpu_v29_arm64,
-    fpu_v30_arm64,
-    fpu_v31_arm64,
-    fpu_fpsr_arm64,
-    fpu_fpcr_arm64,
+static const uint32_t g_fpu_regnums_arm64[] = {
+    fpu_v0_arm64,       fpu_v1_arm64,   fpu_v2_arm64,  fpu_v3_arm64,
+    fpu_v4_arm64,       fpu_v5_arm64,   fpu_v6_arm64,  fpu_v7_arm64,
+    fpu_v8_arm64,       fpu_v9_arm64,   fpu_v10_arm64, fpu_v11_arm64,
+    fpu_v12_arm64,      fpu_v13_arm64,  fpu_v14_arm64, fpu_v15_arm64,
+    fpu_v16_arm64,      fpu_v17_arm64,  fpu_v18_arm64, fpu_v19_arm64,
+    fpu_v20_arm64,      fpu_v21_arm64,  fpu_v22_arm64, fpu_v23_arm64,
+    fpu_v24_arm64,      fpu_v25_arm64,  fpu_v26_arm64, fpu_v27_arm64,
+    fpu_v28_arm64,      fpu_v29_arm64,  fpu_v30_arm64, fpu_v31_arm64,
+    fpu_fpsr_arm64,     fpu_fpcr_arm64,
     LLDB_INVALID_REGNUM // register sets need to end with this flag
 };
-static_assert(((sizeof g_fpu_regnums_arm64 / sizeof g_fpu_regnums_arm64[0]) - 1) == k_num_fpr_registers_arm64, \
+static_assert(((sizeof g_fpu_regnums_arm64 / sizeof g_fpu_regnums_arm64[0]) -
+               1) == k_num_fpr_registers_arm64,
               "g_fpu_regnums_arm64 has wrong number of register infos");
 
 namespace {
-    // Number of register sets provided by this context.
-    enum
-    {
-        k_num_register_sets = 2
-    };
+// Number of register sets provided by this context.
+enum { k_num_register_sets = 2 };
 }
 
 // Register sets for ARM64.
-static const RegisterSet
-g_reg_sets_arm64[k_num_register_sets] =
-{
-    { "General Purpose Registers",  "gpr", k_num_gpr_registers_arm64, g_gpr_regnums_arm64 },
-    { "Floating Point Registers",   "fpu", k_num_fpr_registers_arm64, g_fpu_regnums_arm64 }
-};
-
-NativeRegisterContextLinux*
-NativeRegisterContextLinux::CreateHostNativeRegisterContextLinux(const ArchSpec& target_arch,
-                                                                 NativeThreadProtocol &native_thread,
-                                                                 uint32_t concrete_frame_idx)
-{
-    Log *log  = ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_REGISTERS);
-    switch (target_arch.GetMachine())
-    {
-        case llvm::Triple::arm:
-            return new NativeRegisterContextLinux_arm(target_arch, native_thread, concrete_frame_idx);
-        case llvm::Triple::aarch64:
-            return new NativeRegisterContextLinux_arm64(target_arch, native_thread, concrete_frame_idx);
-        default:
-            if (log)
-                log->Printf("NativeRegisterContextLinux::%s() have no register context for architecture: %s\n", __FUNCTION__,
-                            target_arch.GetTriple().getArchName().str().c_str());
-            return nullptr;
-    }
+static const RegisterSet g_reg_sets_arm64[k_num_register_sets] = {
+    {"General Purpose Registers", "gpr", k_num_gpr_registers_arm64,
+     g_gpr_regnums_arm64},
+    {"Floating Point Registers", "fpu", k_num_fpr_registers_arm64,
+     g_fpu_regnums_arm64}};
+
+NativeRegisterContextLinux *
+NativeRegisterContextLinux::CreateHostNativeRegisterContextLinux(
+    const ArchSpec &target_arch, NativeThreadProtocol &native_thread,
+    uint32_t concrete_frame_idx) {
+  Log *log = ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_REGISTERS);
+  switch (target_arch.GetMachine()) {
+  case llvm::Triple::arm:
+    return new NativeRegisterContextLinux_arm(target_arch, native_thread,
+                                              concrete_frame_idx);
+  case llvm::Triple::aarch64:
+    return new NativeRegisterContextLinux_arm64(target_arch, native_thread,
+                                                concrete_frame_idx);
+  default:
+    if (log)
+      log->Printf("NativeRegisterContextLinux::%s() have no register context "
+                  "for architecture: %s\n",
+                  __FUNCTION__,
+                  target_arch.GetTriple().getArchName().str().c_str());
+    return nullptr;
+  }
 }
 
-NativeRegisterContextLinux_arm64::NativeRegisterContextLinux_arm64 (const ArchSpec& target_arch,
-                                                                    NativeThreadProtocol &native_thread,
-                                                                    uint32_t concrete_frame_idx) :
-    NativeRegisterContextLinux (native_thread, concrete_frame_idx, new RegisterContextLinux_arm64(target_arch))
-{
-    switch (target_arch.GetMachine())
-    {
-        case llvm::Triple::aarch64:
-            m_reg_info.num_registers     = k_num_registers_arm64;
-            m_reg_info.num_gpr_registers = k_num_gpr_registers_arm64;
-            m_reg_info.num_fpr_registers = k_num_fpr_registers_arm64;
-            m_reg_info.last_gpr          = k_last_gpr_arm64;
-            m_reg_info.first_fpr         = k_first_fpr_arm64;
-            m_reg_info.last_fpr          = k_last_fpr_arm64;
-            m_reg_info.first_fpr_v       = fpu_v0_arm64;
-            m_reg_info.last_fpr_v        = fpu_v31_arm64;
-            m_reg_info.gpr_flags         = gpr_cpsr_arm64;
-            break;
-        default:
-            assert(false && "Unhandled target architecture.");
-            break;
-    }
-
-    ::memset(&m_fpr, 0, sizeof (m_fpr));
-    ::memset(&m_gpr_arm64, 0, sizeof (m_gpr_arm64));
-    ::memset(&m_hwp_regs, 0, sizeof (m_hwp_regs));
-
-    // 16 is just a maximum value, query hardware for actual watchpoint count
-    m_max_hwp_supported = 16;
-    m_max_hbp_supported = 16;
-    m_refresh_hwdebug_info = true;
+NativeRegisterContextLinux_arm64::NativeRegisterContextLinux_arm64(
+    const ArchSpec &target_arch, NativeThreadProtocol &native_thread,
+    uint32_t concrete_frame_idx)
+    : NativeRegisterContextLinux(native_thread, concrete_frame_idx,
+                                 new RegisterContextLinux_arm64(target_arch)) {
+  switch (target_arch.GetMachine()) {
+  case llvm::Triple::aarch64:
+    m_reg_info.num_registers = k_num_registers_arm64;
+    m_reg_info.num_gpr_registers = k_num_gpr_registers_arm64;
+    m_reg_info.num_fpr_registers = k_num_fpr_registers_arm64;
+    m_reg_info.last_gpr = k_last_gpr_arm64;
+    m_reg_info.first_fpr = k_first_fpr_arm64;
+    m_reg_info.last_fpr = k_last_fpr_arm64;
+    m_reg_info.first_fpr_v = fpu_v0_arm64;
+    m_reg_info.last_fpr_v = fpu_v31_arm64;
+    m_reg_info.gpr_flags = gpr_cpsr_arm64;
+    break;
+  default:
+    assert(false && "Unhandled target architecture.");
+    break;
+  }
+
+  ::memset(&m_fpr, 0, sizeof(m_fpr));
+  ::memset(&m_gpr_arm64, 0, sizeof(m_gpr_arm64));
+  ::memset(&m_hwp_regs, 0, sizeof(m_hwp_regs));
+
+  // 16 is just a maximum value, query hardware for actual watchpoint count
+  m_max_hwp_supported = 16;
+  m_max_hbp_supported = 16;
+  m_refresh_hwdebug_info = true;
 }
 
-uint32_t
-NativeRegisterContextLinux_arm64::GetRegisterSetCount () const
-{
-    return k_num_register_sets;
+uint32_t NativeRegisterContextLinux_arm64::GetRegisterSetCount() const {
+  return k_num_register_sets;
 }
 
 const RegisterSet *
-NativeRegisterContextLinux_arm64::GetRegisterSet (uint32_t set_index) const
-{
-    if (set_index < k_num_register_sets)
-        return &g_reg_sets_arm64[set_index];
+NativeRegisterContextLinux_arm64::GetRegisterSet(uint32_t set_index) const {
+  if (set_index < k_num_register_sets)
+    return &g_reg_sets_arm64[set_index];
 
-    return nullptr;
+  return nullptr;
 }
 
-uint32_t
-NativeRegisterContextLinux_arm64::GetUserRegisterCount() const
-{
-    uint32_t count = 0;
-    for (uint32_t set_index = 0; set_index < k_num_register_sets; ++set_index)
-        count += g_reg_sets_arm64[set_index].num_registers;
-    return count;
-}
-
-Error
-NativeRegisterContextLinux_arm64::ReadRegister (const RegisterInfo *reg_info, RegisterValue &reg_value)
-{
-    Error error;
-
-    if (!reg_info)
-    {
-        error.SetErrorString ("reg_info NULL");
-        return error;
-    }
+uint32_t NativeRegisterContextLinux_arm64::GetUserRegisterCount() const {
+  uint32_t count = 0;
+  for (uint32_t set_index = 0; set_index < k_num_register_sets; ++set_index)
+    count += g_reg_sets_arm64[set_index].num_registers;
+  return count;
+}
 
-    const uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];
+Error NativeRegisterContextLinux_arm64::ReadRegister(
+    const RegisterInfo *reg_info, RegisterValue &reg_value) {
+  Error error;
 
-    if (IsFPR(reg))
-    {
-        error = ReadFPR();
-        if (error.Fail())
-            return error;
-    }
-    else
-    {
-        uint32_t full_reg = reg;
-        bool is_subreg = reg_info->invalidate_regs && (reg_info->invalidate_regs[0] != LLDB_INVALID_REGNUM);
-
-        if (is_subreg)
-        {
-            // Read the full aligned 64-bit register.
-            full_reg = reg_info->invalidate_regs[0];
-        }
-
-        error = ReadRegisterRaw(full_reg, reg_value);
-
-        if (error.Success ())
-        {
-            // If our read was not aligned (for ah,bh,ch,dh), shift our returned value one byte to the right.
-            if (is_subreg && (reg_info->byte_offset & 0x1))
-                reg_value.SetUInt64(reg_value.GetAsUInt64() >> 8);
-
-            // If our return byte size was greater than the return value reg size, then
-            // use the type specified by reg_info rather than the uint64_t default
-            if (reg_value.GetByteSize() > reg_info->byte_size)
-                reg_value.SetType(reg_info);
-        }
-        return error;
-    }
+  if (!reg_info) {
+    error.SetErrorString("reg_info NULL");
+    return error;
+  }
 
-    // Get pointer to m_fpr variable and set the data from it.
-    uint32_t fpr_offset = CalculateFprOffset(reg_info);
-    assert (fpr_offset < sizeof m_fpr);
-    uint8_t *src = (uint8_t *)&m_fpr + fpr_offset;
-    reg_value.SetFromMemoryData(reg_info, src, reg_info->byte_size, eByteOrderLittle, error);
+  const uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];
 
+  if (IsFPR(reg)) {
+    error = ReadFPR();
+    if (error.Fail())
+      return error;
+  } else {
+    uint32_t full_reg = reg;
+    bool is_subreg = reg_info->invalidate_regs &&
+                     (reg_info->invalidate_regs[0] != LLDB_INVALID_REGNUM);
+
+    if (is_subreg) {
+      // Read the full aligned 64-bit register.
+      full_reg = reg_info->invalidate_regs[0];
+    }
+
+    error = ReadRegisterRaw(full_reg, reg_value);
+
+    if (error.Success()) {
+      // If our read was not aligned (for ah,bh,ch,dh), shift our returned value
+      // one byte to the right.
+      if (is_subreg && (reg_info->byte_offset & 0x1))
+        reg_value.SetUInt64(reg_value.GetAsUInt64() >> 8);
+
+      // If our return byte size was greater than the return value reg size,
+      // then
+      // use the type specified by reg_info rather than the uint64_t default
+      if (reg_value.GetByteSize() > reg_info->byte_size)
+        reg_value.SetType(reg_info);
+    }
     return error;
-}
+  }
+
+  // Get pointer to m_fpr variable and set the data from it.
+  uint32_t fpr_offset = CalculateFprOffset(reg_info);
+  assert(fpr_offset < sizeof m_fpr);
+  uint8_t *src = (uint8_t *)&m_fpr + fpr_offset;
+  reg_value.SetFromMemoryData(reg_info, src, reg_info->byte_size,
+                              eByteOrderLittle, error);
+
+  return error;
+}
+
+Error NativeRegisterContextLinux_arm64::WriteRegister(
+    const RegisterInfo *reg_info, const RegisterValue &reg_value) {
+  if (!reg_info)
+    return Error("reg_info NULL");
+
+  const uint32_t reg_index = reg_info->kinds[lldb::eRegisterKindLLDB];
+  if (reg_index == LLDB_INVALID_REGNUM)
+    return Error("no lldb regnum for %s", reg_info && reg_info->name
+                                              ? reg_info->name
+                                              : "<unknown register>");
 
-Error
-NativeRegisterContextLinux_arm64::WriteRegister (const RegisterInfo *reg_info, const RegisterValue &reg_value)
-{
-    if (!reg_info)
-        return Error ("reg_info NULL");
-
-    const uint32_t reg_index = reg_info->kinds[lldb::eRegisterKindLLDB];
-    if (reg_index == LLDB_INVALID_REGNUM)
-        return Error ("no lldb regnum for %s", reg_info && reg_info->name ? reg_info->name : "<unknown register>");
-
-    if (IsGPR(reg_index))
-        return WriteRegisterRaw(reg_index, reg_value);
-
-    if (IsFPR(reg_index))
-    {
-        // Get pointer to m_fpr variable and set the data to it.
-        uint32_t fpr_offset = CalculateFprOffset(reg_info);
-        assert (fpr_offset < sizeof m_fpr);
-        uint8_t *dst = (uint8_t *)&m_fpr + fpr_offset;
-        switch (reg_info->byte_size)
-        {
-            case 2:
-                *(uint16_t *)dst = reg_value.GetAsUInt16();
-                break;
-            case 4:
-                *(uint32_t *)dst = reg_value.GetAsUInt32();
-                break;
-            case 8:
-                *(uint64_t *)dst = reg_value.GetAsUInt64();
-                break;
-            default:
-                assert(false && "Unhandled data size.");
-                return Error ("unhandled register data size %" PRIu32, reg_info->byte_size);
-        }
-
-        Error error = WriteFPR();
-        if (error.Fail())
-            return error;
+  if (IsGPR(reg_index))
+    return WriteRegisterRaw(reg_index, reg_value);
 
-        return Error ();
+  if (IsFPR(reg_index)) {
+    // Get pointer to m_fpr variable and set the data to it.
+    uint32_t fpr_offset = CalculateFprOffset(reg_info);
+    assert(fpr_offset < sizeof m_fpr);
+    uint8_t *dst = (uint8_t *)&m_fpr + fpr_offset;
+    switch (reg_info->byte_size) {
+    case 2:
+      *(uint16_t *)dst = reg_value.GetAsUInt16();
+      break;
+    case 4:
+      *(uint32_t *)dst = reg_value.GetAsUInt32();
+      break;
+    case 8:
+      *(uint64_t *)dst = reg_value.GetAsUInt64();
+      break;
+    default:
+      assert(false && "Unhandled data size.");
+      return Error("unhandled register data size %" PRIu32,
+                   reg_info->byte_size);
     }
 
-    return Error ("failed - register wasn't recognized to be a GPR or an FPR, write strategy unknown");
-}
+    Error error = WriteFPR();
+    if (error.Fail())
+      return error;
 
-Error
-NativeRegisterContextLinux_arm64::ReadAllRegisterValues (lldb::DataBufferSP &data_sp)
-{
-    Error error;
+    return Error();
+  }
 
-    data_sp.reset (new DataBufferHeap (REG_CONTEXT_SIZE, 0));
-    if (!data_sp)
-        return Error ("failed to allocate DataBufferHeap instance of size %" PRIu64, REG_CONTEXT_SIZE);
+  return Error("failed - register wasn't recognized to be a GPR or an FPR, "
+               "write strategy unknown");
+}
 
-    error = ReadGPR();
-    if (error.Fail())
-        return error;
+Error NativeRegisterContextLinux_arm64::ReadAllRegisterValues(
+    lldb::DataBufferSP &data_sp) {
+  Error error;
 
-    error = ReadFPR();
-    if (error.Fail())
-        return error;
+  data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0));
+  if (!data_sp)
+    return Error("failed to allocate DataBufferHeap instance of size %" PRIu64,
+                 REG_CONTEXT_SIZE);
 
-    uint8_t *dst = data_sp->GetBytes ();
-    if (dst == nullptr)
-    {
-        error.SetErrorStringWithFormat ("DataBufferHeap instance of size %" PRIu64 " returned a null pointer", REG_CONTEXT_SIZE);
-        return error;
-    }
+  error = ReadGPR();
+  if (error.Fail())
+    return error;
 
-    ::memcpy (dst, &m_gpr_arm64, GetGPRSize());
-    dst += GetGPRSize();
-    ::memcpy (dst, &m_fpr, sizeof(m_fpr));
+  error = ReadFPR();
+  if (error.Fail())
+    return error;
 
+  uint8_t *dst = data_sp->GetBytes();
+  if (dst == nullptr) {
+    error.SetErrorStringWithFormat("DataBufferHeap instance of size %" PRIu64
+                                   " returned a null pointer",
+                                   REG_CONTEXT_SIZE);
     return error;
-}
+  }
 
-Error
-NativeRegisterContextLinux_arm64::WriteAllRegisterValues (const lldb::DataBufferSP &data_sp)
-{
-    Error error;
-
-    if (!data_sp)
-    {
-        error.SetErrorStringWithFormat ("NativeRegisterContextLinux_x86_64::%s invalid data_sp provided", __FUNCTION__);
-        return error;
-    }
+  ::memcpy(dst, &m_gpr_arm64, GetGPRSize());
+  dst += GetGPRSize();
+  ::memcpy(dst, &m_fpr, sizeof(m_fpr));
 
-    if (data_sp->GetByteSize () != REG_CONTEXT_SIZE)
-    {
-        error.SetErrorStringWithFormat ("NativeRegisterContextLinux_x86_64::%s data_sp contained mismatched data size, expected %" PRIu64 ", actual %" PRIu64, __FUNCTION__, REG_CONTEXT_SIZE, data_sp->GetByteSize ());
-        return error;
-    }
+  return error;
+}
 
+Error NativeRegisterContextLinux_arm64::WriteAllRegisterValues(
+    const lldb::DataBufferSP &data_sp) {
+  Error error;
 
-    uint8_t *src = data_sp->GetBytes ();
-    if (src == nullptr)
-    {
-        error.SetErrorStringWithFormat ("NativeRegisterContextLinux_x86_64::%s DataBuffer::GetBytes() returned a null pointer", __FUNCTION__);
-        return error;
-    }
-    ::memcpy (&m_gpr_arm64, src, GetRegisterInfoInterface ().GetGPRSize ());
+  if (!data_sp) {
+    error.SetErrorStringWithFormat(
+        "NativeRegisterContextLinux_x86_64::%s invalid data_sp provided",
+        __FUNCTION__);
+    return error;
+  }
 
-    error = WriteGPR();
-    if (error.Fail())
-        return error;
+  if (data_sp->GetByteSize() != REG_CONTEXT_SIZE) {
+    error.SetErrorStringWithFormat(
+        "NativeRegisterContextLinux_x86_64::%s data_sp contained mismatched "
+        "data size, expected %" PRIu64 ", actual %" PRIu64,
+        __FUNCTION__, REG_CONTEXT_SIZE, data_sp->GetByteSize());
+    return error;
+  }
 
-    src += GetRegisterInfoInterface ().GetGPRSize ();
-    ::memcpy (&m_fpr, src, sizeof(m_fpr));
+  uint8_t *src = data_sp->GetBytes();
+  if (src == nullptr) {
+    error.SetErrorStringWithFormat("NativeRegisterContextLinux_x86_64::%s "
+                                   "DataBuffer::GetBytes() returned a null "
+                                   "pointer",
+                                   __FUNCTION__);
+    return error;
+  }
+  ::memcpy(&m_gpr_arm64, src, GetRegisterInfoInterface().GetGPRSize());
 
-    error = WriteFPR();
-    if (error.Fail())
-        return error;
+  error = WriteGPR();
+  if (error.Fail())
+    return error;
+
+  src += GetRegisterInfoInterface().GetGPRSize();
+  ::memcpy(&m_fpr, src, sizeof(m_fpr));
 
+  error = WriteFPR();
+  if (error.Fail())
     return error;
+
+  return error;
 }
 
-bool
-NativeRegisterContextLinux_arm64::IsGPR(unsigned reg) const
-{
-    return reg <= m_reg_info.last_gpr;   // GPR's come first.
+bool NativeRegisterContextLinux_arm64::IsGPR(unsigned reg) const {
+  return reg <= m_reg_info.last_gpr; // GPR's come first.
 }
 
-bool
-NativeRegisterContextLinux_arm64::IsFPR(unsigned reg) const
-{
-    return (m_reg_info.first_fpr <= reg && reg <= m_reg_info.last_fpr);
+bool NativeRegisterContextLinux_arm64::IsFPR(unsigned reg) const {
+  return (m_reg_info.first_fpr <= reg && reg <= m_reg_info.last_fpr);
 }
 
 uint32_t
-NativeRegisterContextLinux_arm64::SetHardwareBreakpoint (lldb::addr_t addr, size_t size)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS));
+NativeRegisterContextLinux_arm64::SetHardwareBreakpoint(lldb::addr_t addr,
+                                                        size_t size) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
 
-    if (log)
-        log->Printf ("NativeRegisterContextLinux_arm64::%s()", __FUNCTION__);
+  if (log)
+    log->Printf("NativeRegisterContextLinux_arm64::%s()", __FUNCTION__);
 
-    Error error;
+  Error error;
 
-    // Read hardware breakpoint and watchpoint information.
-    error = ReadHardwareDebugInfo ();
+  // Read hardware breakpoint and watchpoint information.
+  error = ReadHardwareDebugInfo();
 
-    if (error.Fail())
-        return LLDB_INVALID_INDEX32;
+  if (error.Fail())
+    return LLDB_INVALID_INDEX32;
 
-    uint32_t control_value = 0, bp_index = 0;
+  uint32_t control_value = 0, bp_index = 0;
 
-    // Check if size has a valid hardware breakpoint length.
-    if (size != 4)
-        return LLDB_INVALID_INDEX32;  // Invalid size for a AArch64 hardware breakpoint
-
-    // Check 4-byte alignment for hardware breakpoint target address.
-    if (addr & 0x03)
-        return LLDB_INVALID_INDEX32; // Invalid address, should be 4-byte aligned.
-
-    // Setup control value
-    control_value = 0;
-    control_value |= ((1 << size) - 1) << 5;
-    control_value |= (2 << 1) | 1;
-
-    // Iterate over stored hardware breakpoints
-    // Find a free bp_index or update reference count if duplicate.
-    bp_index = LLDB_INVALID_INDEX32;
-    for (uint32_t i = 0; i < m_max_hbp_supported; i++)
-    {
-        if ((m_hbr_regs[i].control & 1) == 0)
-        {
-            bp_index = i;  // Mark last free slot
-        }
-        else if (m_hbr_regs[i].address == addr && m_hbr_regs[i].control == control_value)
-        {
-            bp_index = i;  // Mark duplicate index
-            break;  // Stop searching here
-        }
+  // Check if size has a valid hardware breakpoint length.
+  if (size != 4)
+    return LLDB_INVALID_INDEX32; // Invalid size for a AArch64 hardware
+                                 // breakpoint
+
+  // Check 4-byte alignment for hardware breakpoint target address.
+  if (addr & 0x03)
+    return LLDB_INVALID_INDEX32; // Invalid address, should be 4-byte aligned.
+
+  // Setup control value
+  control_value = 0;
+  control_value |= ((1 << size) - 1) << 5;
+  control_value |= (2 << 1) | 1;
+
+  // Iterate over stored hardware breakpoints
+  // Find a free bp_index or update reference count if duplicate.
+  bp_index = LLDB_INVALID_INDEX32;
+  for (uint32_t i = 0; i < m_max_hbp_supported; i++) {
+    if ((m_hbr_regs[i].control & 1) == 0) {
+      bp_index = i; // Mark last free slot
+    } else if (m_hbr_regs[i].address == addr &&
+               m_hbr_regs[i].control == control_value) {
+      bp_index = i; // Mark duplicate index
+      break;        // Stop searching here
     }
+  }
+
+  if (bp_index == LLDB_INVALID_INDEX32)
+    return LLDB_INVALID_INDEX32;
+
+  // Add new or update existing breakpoint
+  if ((m_hbr_regs[bp_index].control & 1) == 0) {
+    m_hbr_regs[bp_index].address = addr;
+    m_hbr_regs[bp_index].control = control_value;
+    m_hbr_regs[bp_index].refcount = 1;
 
-     if (bp_index == LLDB_INVALID_INDEX32)
-        return LLDB_INVALID_INDEX32;
+    // PTRACE call to set corresponding hardware breakpoint register.
+    error = WriteHardwareDebugRegs(eDREGTypeBREAK);
 
-    // Add new or update existing breakpoint
-    if ((m_hbr_regs[bp_index].control & 1) == 0)
-    {
-        m_hbr_regs[bp_index].address = addr;
-        m_hbr_regs[bp_index].control = control_value;
-        m_hbr_regs[bp_index].refcount = 1;
-
-        // PTRACE call to set corresponding hardware breakpoint register.
-        error = WriteHardwareDebugRegs(eDREGTypeBREAK);
-
-        if (error.Fail())
-        {
-            m_hbr_regs[bp_index].address = 0;
-            m_hbr_regs[bp_index].control &= ~1;
-            m_hbr_regs[bp_index].refcount = 0;
+    if (error.Fail()) {
+      m_hbr_regs[bp_index].address = 0;
+      m_hbr_regs[bp_index].control &= ~1;
+      m_hbr_regs[bp_index].refcount = 0;
 
-            return LLDB_INVALID_INDEX32;
-        }
+      return LLDB_INVALID_INDEX32;
     }
-    else
-        m_hbr_regs[bp_index].refcount++;
+  } else
+    m_hbr_regs[bp_index].refcount++;
 
-    return bp_index;
+  return bp_index;
 }
 
-bool
-NativeRegisterContextLinux_arm64::ClearHardwareBreakpoint (uint32_t hw_idx)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS));
+bool NativeRegisterContextLinux_arm64::ClearHardwareBreakpoint(
+    uint32_t hw_idx) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
 
-    if (log)
-        log->Printf ("NativeRegisterContextLinux_arm64::%s()", __FUNCTION__);
+  if (log)
+    log->Printf("NativeRegisterContextLinux_arm64::%s()", __FUNCTION__);
 
-    Error error;
+  Error error;
 
-    // Read hardware breakpoint and watchpoint information.
-    error = ReadHardwareDebugInfo ();
+  // Read hardware breakpoint and watchpoint information.
+  error = ReadHardwareDebugInfo();
 
-    if (error.Fail())
-        return false;
+  if (error.Fail())
+    return false;
+
+  if (hw_idx >= m_max_hbp_supported)
+    return false;
 
-    if (hw_idx >= m_max_hbp_supported)
-        return false;
+  // Update reference count if multiple references.
+  if (m_hbr_regs[hw_idx].refcount > 1) {
+    m_hbr_regs[hw_idx].refcount--;
+    return true;
+  } else if (m_hbr_regs[hw_idx].refcount == 1) {
+    // Create a backup we can revert to in case of failure.
+    lldb::addr_t tempAddr = m_hbr_regs[hw_idx].address;
+    uint32_t tempControl = m_hbr_regs[hw_idx].control;
+    uint32_t tempRefCount = m_hbr_regs[hw_idx].refcount;
 
-    // Update reference count if multiple references.
-    if (m_hbr_regs[hw_idx].refcount > 1)
-    {
-        m_hbr_regs[hw_idx].refcount--;
-        return true;
-    }
-    else if (m_hbr_regs[hw_idx].refcount == 1)
-    {
-        // Create a backup we can revert to in case of failure.
-        lldb::addr_t tempAddr = m_hbr_regs[hw_idx].address;
-        uint32_t tempControl = m_hbr_regs[hw_idx].control;
-        uint32_t tempRefCount = m_hbr_regs[hw_idx].refcount;
-
-        m_hbr_regs[hw_idx].control &= ~1;
-        m_hbr_regs[hw_idx].address = 0;
-        m_hbr_regs[hw_idx].refcount = 0;
-
-        // PTRACE call to clear corresponding hardware breakpoint register.
-        WriteHardwareDebugRegs(eDREGTypeBREAK);
-
-        if (error.Fail())
-        {
-            m_hbr_regs[hw_idx].control = tempControl;
-            m_hbr_regs[hw_idx].address = tempAddr;
-            m_hbr_regs[hw_idx].refcount = tempRefCount;
+    m_hbr_regs[hw_idx].control &= ~1;
+    m_hbr_regs[hw_idx].address = 0;
+    m_hbr_regs[hw_idx].refcount = 0;
+
+    // PTRACE call to clear corresponding hardware breakpoint register.
+    WriteHardwareDebugRegs(eDREGTypeBREAK);
 
-            return false;
-        }
+    if (error.Fail()) {
+      m_hbr_regs[hw_idx].control = tempControl;
+      m_hbr_regs[hw_idx].address = tempAddr;
+      m_hbr_regs[hw_idx].refcount = tempRefCount;
 
-        return true;
+      return false;
     }
 
-    return false;
+    return true;
+  }
+
+  return false;
 }
 
-uint32_t
-NativeRegisterContextLinux_arm64::NumSupportedHardwareWatchpoints ()
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS));
+uint32_t NativeRegisterContextLinux_arm64::NumSupportedHardwareWatchpoints() {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
 
-    if (log)
-        log->Printf ("NativeRegisterContextLinux_arm64::%s()", __FUNCTION__);
+  if (log)
+    log->Printf("NativeRegisterContextLinux_arm64::%s()", __FUNCTION__);
 
-    Error error;
+  Error error;
 
-    // Read hardware breakpoint and watchpoint information.
-    error = ReadHardwareDebugInfo ();
+  // Read hardware breakpoint and watchpoint information.
+  error = ReadHardwareDebugInfo();
 
-    if (error.Fail())
-        return 0;
+  if (error.Fail())
+    return 0;
 
-    return m_max_hwp_supported;
+  return m_max_hwp_supported;
 }
 
-uint32_t
-NativeRegisterContextLinux_arm64::SetHardwareWatchpoint (lldb::addr_t addr, size_t size, uint32_t watch_flags)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS));
+uint32_t NativeRegisterContextLinux_arm64::SetHardwareWatchpoint(
+    lldb::addr_t addr, size_t size, uint32_t watch_flags) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
 
-    if (log)
-        log->Printf ("NativeRegisterContextLinux_arm64::%s()", __FUNCTION__);
-    
-    Error error;
+  if (log)
+    log->Printf("NativeRegisterContextLinux_arm64::%s()", __FUNCTION__);
 
-    // Read hardware breakpoint and watchpoint information.
-    error = ReadHardwareDebugInfo ();
+  Error error;
 
-    if (error.Fail())
-        return LLDB_INVALID_INDEX32;
-		
-    uint32_t control_value = 0, wp_index = 0;
-    lldb::addr_t real_addr = addr;
-
-    // Check if we are setting watchpoint other than read/write/access
-    // Also update watchpoint flag to match AArch64 write-read bit configuration.
-    switch (watch_flags)
-    {
-        case 1:
-            watch_flags = 2;
-            break;
-        case 2:
-            watch_flags = 1;
-            break;
-        case 3:
-            break;
-        default:
-            return LLDB_INVALID_INDEX32;
-    }
+  // Read hardware breakpoint and watchpoint information.
+  error = ReadHardwareDebugInfo();
 
-    // Check if size has a valid hardware watchpoint length.
-    if (size != 1 && size != 2 && size != 4 && size != 8)
-        return LLDB_INVALID_INDEX32;
-
-    // Check 8-byte alignment for hardware watchpoint target address.
-    // Below is a hack to recalculate address and size in order to
-    // make sure we can watch non 8-byte alligned addresses as well.
-    if (addr & 0x07)
-    {
-        uint8_t watch_mask = (addr & 0x07) + size;
-
-        if (watch_mask > 0x08)
-            return LLDB_INVALID_INDEX32;
-        else if (watch_mask <= 0x02)
-            size = 2;
-        else if (watch_mask <= 0x04)
-            size = 4;
-        else
-            size = 8;
+  if (error.Fail())
+    return LLDB_INVALID_INDEX32;
 
-        addr = addr & (~0x07);
-    }
+  uint32_t control_value = 0, wp_index = 0;
+  lldb::addr_t real_addr = addr;
+
+  // Check if we are setting watchpoint other than read/write/access
+  // Also update watchpoint flag to match AArch64 write-read bit configuration.
+  switch (watch_flags) {
+  case 1:
+    watch_flags = 2;
+    break;
+  case 2:
+    watch_flags = 1;
+    break;
+  case 3:
+    break;
+  default:
+    return LLDB_INVALID_INDEX32;
+  }
+
+  // Check if size has a valid hardware watchpoint length.
+  if (size != 1 && size != 2 && size != 4 && size != 8)
+    return LLDB_INVALID_INDEX32;
 
-    // Setup control value
-    control_value = watch_flags << 3;
-    control_value |= ((1 << size) - 1) << 5;
-    control_value |= (2 << 1) | 1;
-
-    // Iterate over stored watchpoints
-    // Find a free wp_index or update reference count if duplicate.
-    wp_index = LLDB_INVALID_INDEX32;
-    for (uint32_t i = 0; i < m_max_hwp_supported; i++)
-    {
-        if ((m_hwp_regs[i].control & 1) == 0)
-        {
-            wp_index = i; // Mark last free slot
-        }
-        else if (m_hwp_regs[i].address == addr && m_hwp_regs[i].control == control_value)
-        {
-            wp_index = i; // Mark duplicate index
-            break; // Stop searching here
-        }
+  // Check 8-byte alignment for hardware watchpoint target address.
+  // Below is a hack to recalculate address and size in order to
+  // make sure we can watch non 8-byte alligned addresses as well.
+  if (addr & 0x07) {
+    uint8_t watch_mask = (addr & 0x07) + size;
+
+    if (watch_mask > 0x08)
+      return LLDB_INVALID_INDEX32;
+    else if (watch_mask <= 0x02)
+      size = 2;
+    else if (watch_mask <= 0x04)
+      size = 4;
+    else
+      size = 8;
+
+    addr = addr & (~0x07);
+  }
+
+  // Setup control value
+  control_value = watch_flags << 3;
+  control_value |= ((1 << size) - 1) << 5;
+  control_value |= (2 << 1) | 1;
+
+  // Iterate over stored watchpoints
+  // Find a free wp_index or update reference count if duplicate.
+  wp_index = LLDB_INVALID_INDEX32;
+  for (uint32_t i = 0; i < m_max_hwp_supported; i++) {
+    if ((m_hwp_regs[i].control & 1) == 0) {
+      wp_index = i; // Mark last free slot
+    } else if (m_hwp_regs[i].address == addr &&
+               m_hwp_regs[i].control == control_value) {
+      wp_index = i; // Mark duplicate index
+      break;        // Stop searching here
     }
+  }
+
+  if (wp_index == LLDB_INVALID_INDEX32)
+    return LLDB_INVALID_INDEX32;
 
-     if (wp_index == LLDB_INVALID_INDEX32)
-        return LLDB_INVALID_INDEX32;
+  // Add new or update existing watchpoint
+  if ((m_hwp_regs[wp_index].control & 1) == 0) {
+    // Update watchpoint in local cache
+    m_hwp_regs[wp_index].real_addr = real_addr;
+    m_hwp_regs[wp_index].address = addr;
+    m_hwp_regs[wp_index].control = control_value;
+    m_hwp_regs[wp_index].refcount = 1;
 
-    // Add new or update existing watchpoint
-    if ((m_hwp_regs[wp_index].control & 1) == 0)
-    {
-        // Update watchpoint in local cache
-        m_hwp_regs[wp_index].real_addr = real_addr;
-        m_hwp_regs[wp_index].address = addr;
-        m_hwp_regs[wp_index].control = control_value;
-        m_hwp_regs[wp_index].refcount = 1;
-
-        // PTRACE call to set corresponding watchpoint register.
-        error = WriteHardwareDebugRegs(eDREGTypeWATCH);
-
-        if (error.Fail())
-        {
-            m_hwp_regs[wp_index].address = 0;
-            m_hwp_regs[wp_index].control &= ~1;
-            m_hwp_regs[wp_index].refcount = 0;
+    // PTRACE call to set corresponding watchpoint register.
+    error = WriteHardwareDebugRegs(eDREGTypeWATCH);
 
-            return LLDB_INVALID_INDEX32;
-        }
+    if (error.Fail()) {
+      m_hwp_regs[wp_index].address = 0;
+      m_hwp_regs[wp_index].control &= ~1;
+      m_hwp_regs[wp_index].refcount = 0;
+
+      return LLDB_INVALID_INDEX32;
     }
-    else
-        m_hwp_regs[wp_index].refcount++;
+  } else
+    m_hwp_regs[wp_index].refcount++;
 
-    return wp_index;
+  return wp_index;
 }
 
-bool
-NativeRegisterContextLinux_arm64::ClearHardwareWatchpoint (uint32_t wp_index)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS));
+bool NativeRegisterContextLinux_arm64::ClearHardwareWatchpoint(
+    uint32_t wp_index) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
 
-    if (log)
-        log->Printf ("NativeRegisterContextLinux_arm64::%s()", __FUNCTION__);
+  if (log)
+    log->Printf("NativeRegisterContextLinux_arm64::%s()", __FUNCTION__);
 
-    Error error;
+  Error error;
 
-    // Read hardware breakpoint and watchpoint information.
-    error = ReadHardwareDebugInfo ();
+  // Read hardware breakpoint and watchpoint information.
+  error = ReadHardwareDebugInfo();
 
-    if (error.Fail())
-        return false;
+  if (error.Fail())
+    return false;
 
-    if (wp_index >= m_max_hwp_supported)
-        return false;
+  if (wp_index >= m_max_hwp_supported)
+    return false;
 
-    // Update reference count if multiple references.
-    if (m_hwp_regs[wp_index].refcount > 1)
-    {
-        m_hwp_regs[wp_index].refcount--;
-        return true;
-    }
-    else if (m_hwp_regs[wp_index].refcount == 1)
-    {
-        // Create a backup we can revert to in case of failure.
-        lldb::addr_t tempAddr = m_hwp_regs[wp_index].address;
-        uint32_t tempControl = m_hwp_regs[wp_index].control;
-        uint32_t tempRefCount = m_hwp_regs[wp_index].refcount;
-
-        // Update watchpoint in local cache
-        m_hwp_regs[wp_index].control &= ~1;
-        m_hwp_regs[wp_index].address = 0;
-        m_hwp_regs[wp_index].refcount = 0;
-
-        // Ptrace call to update hardware debug registers
-        error = WriteHardwareDebugRegs(eDREGTypeWATCH);
-
-        if (error.Fail())
-        {
-            m_hwp_regs[wp_index].control = tempControl;
-            m_hwp_regs[wp_index].address = tempAddr;
-            m_hwp_regs[wp_index].refcount = tempRefCount;
+  // Update reference count if multiple references.
+  if (m_hwp_regs[wp_index].refcount > 1) {
+    m_hwp_regs[wp_index].refcount--;
+    return true;
+  } else if (m_hwp_regs[wp_index].refcount == 1) {
+    // Create a backup we can revert to in case of failure.
+    lldb::addr_t tempAddr = m_hwp_regs[wp_index].address;
+    uint32_t tempControl = m_hwp_regs[wp_index].control;
+    uint32_t tempRefCount = m_hwp_regs[wp_index].refcount;
+
+    // Update watchpoint in local cache
+    m_hwp_regs[wp_index].control &= ~1;
+    m_hwp_regs[wp_index].address = 0;
+    m_hwp_regs[wp_index].refcount = 0;
 
-            return false;
-        }
+    // Ptrace call to update hardware debug registers
+    error = WriteHardwareDebugRegs(eDREGTypeWATCH);
 
-        return true;
+    if (error.Fail()) {
+      m_hwp_regs[wp_index].control = tempControl;
+      m_hwp_regs[wp_index].address = tempAddr;
+      m_hwp_regs[wp_index].refcount = tempRefCount;
+
+      return false;
     }
 
-    return false;
+    return true;
+  }
+
+  return false;
 }
 
-Error
-NativeRegisterContextLinux_arm64::ClearAllHardwareWatchpoints ()
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS));
+Error NativeRegisterContextLinux_arm64::ClearAllHardwareWatchpoints() {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
 
-    if (log)
-        log->Printf ("NativeRegisterContextLinux_arm64::%s()", __FUNCTION__);
+  if (log)
+    log->Printf("NativeRegisterContextLinux_arm64::%s()", __FUNCTION__);
 
-    Error error;
+  Error error;
 
-    // Read hardware breakpoint and watchpoint information.
-    error = ReadHardwareDebugInfo ();
+  // Read hardware breakpoint and watchpoint information.
+  error = ReadHardwareDebugInfo();
 
-    if (error.Fail())
-        return error;
+  if (error.Fail())
+    return error;
 
-    lldb::addr_t tempAddr = 0;
-    uint32_t tempControl = 0, tempRefCount = 0;
+  lldb::addr_t tempAddr = 0;
+  uint32_t tempControl = 0, tempRefCount = 0;
 
-    for (uint32_t i = 0; i < m_max_hwp_supported; i++)
-    {
-        if (m_hwp_regs[i].control & 0x01)
-        {
-            // Create a backup we can revert to in case of failure.
-            tempAddr = m_hwp_regs[i].address;
-            tempControl = m_hwp_regs[i].control;
-            tempRefCount = m_hwp_regs[i].refcount;
-
-            // Clear watchpoints in local cache
-            m_hwp_regs[i].control &= ~1;
-            m_hwp_regs[i].address = 0;
-            m_hwp_regs[i].refcount = 0;
-
-            // Ptrace call to update hardware debug registers
-            error = WriteHardwareDebugRegs(eDREGTypeWATCH);
-
-            if (error.Fail())
-            {
-                m_hwp_regs[i].control = tempControl;
-                m_hwp_regs[i].address = tempAddr;
-                m_hwp_regs[i].refcount = tempRefCount;
-
-                return error;
-            }
-        }
-    }
+  for (uint32_t i = 0; i < m_max_hwp_supported; i++) {
+    if (m_hwp_regs[i].control & 0x01) {
+      // Create a backup we can revert to in case of failure.
+      tempAddr = m_hwp_regs[i].address;
+      tempControl = m_hwp_regs[i].control;
+      tempRefCount = m_hwp_regs[i].refcount;
 
-    return Error();
-}
+      // Clear watchpoints in local cache
+      m_hwp_regs[i].control &= ~1;
+      m_hwp_regs[i].address = 0;
+      m_hwp_regs[i].refcount = 0;
 
-uint32_t
-NativeRegisterContextLinux_arm64::GetWatchpointSize(uint32_t wp_index)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS));
+      // Ptrace call to update hardware debug registers
+      error = WriteHardwareDebugRegs(eDREGTypeWATCH);
 
-    if (log)
-        log->Printf ("NativeRegisterContextLinux_arm64::%s()", __FUNCTION__);
-    switch ((m_hwp_regs[wp_index].control >> 5) & 0xff)
-    {
-        case 0x01:
-            return 1;
-        case 0x03:
-            return 2;
-        case 0x0f:
-            return 4;
-        case 0xff:
-            return 8;
-        default:
-            return 0;
+      if (error.Fail()) {
+        m_hwp_regs[i].control = tempControl;
+        m_hwp_regs[i].address = tempAddr;
+        m_hwp_regs[i].refcount = tempRefCount;
+
+        return error;
+      }
     }
+  }
+
+  return Error();
 }
-bool
-NativeRegisterContextLinux_arm64::WatchpointIsEnabled(uint32_t wp_index)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS));
 
-    if (log)
-        log->Printf ("NativeRegisterContextLinux_arm64::%s()", __FUNCTION__);
+uint32_t
+NativeRegisterContextLinux_arm64::GetWatchpointSize(uint32_t wp_index) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
 
-    if ((m_hwp_regs[wp_index].control & 0x1) == 0x1)
-        return true;
-    else
-        return false;
+  if (log)
+    log->Printf("NativeRegisterContextLinux_arm64::%s()", __FUNCTION__);
+  switch ((m_hwp_regs[wp_index].control >> 5) & 0xff) {
+  case 0x01:
+    return 1;
+  case 0x03:
+    return 2;
+  case 0x0f:
+    return 4;
+  case 0xff:
+    return 8;
+  default:
+    return 0;
+  }
+}
+bool NativeRegisterContextLinux_arm64::WatchpointIsEnabled(uint32_t wp_index) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
+
+  if (log)
+    log->Printf("NativeRegisterContextLinux_arm64::%s()", __FUNCTION__);
+
+  if ((m_hwp_regs[wp_index].control & 0x1) == 0x1)
+    return true;
+  else
+    return false;
 }
 
-Error
-NativeRegisterContextLinux_arm64::GetWatchpointHitIndex(uint32_t &wp_index, lldb::addr_t trap_addr)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS));
+Error NativeRegisterContextLinux_arm64::GetWatchpointHitIndex(
+    uint32_t &wp_index, lldb::addr_t trap_addr) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
 
-    if (log)
-        log->Printf ("NativeRegisterContextLinux_arm64::%s()", __FUNCTION__);
+  if (log)
+    log->Printf("NativeRegisterContextLinux_arm64::%s()", __FUNCTION__);
 
-    uint32_t watch_size;
-    lldb::addr_t watch_addr;
+  uint32_t watch_size;
+  lldb::addr_t watch_addr;
 
-    for (wp_index = 0; wp_index < m_max_hwp_supported; ++wp_index)
-    {
-        watch_size = GetWatchpointSize (wp_index);
-        watch_addr = m_hwp_regs[wp_index].address;
-
-        if (m_hwp_regs[wp_index].refcount >= 1 && WatchpointIsEnabled(wp_index)
-            && trap_addr >= watch_addr && trap_addr < watch_addr + watch_size)
-        {
-            m_hwp_regs[wp_index].hit_addr = trap_addr;
-            return Error();
-        }
+  for (wp_index = 0; wp_index < m_max_hwp_supported; ++wp_index) {
+    watch_size = GetWatchpointSize(wp_index);
+    watch_addr = m_hwp_regs[wp_index].address;
+
+    if (m_hwp_regs[wp_index].refcount >= 1 && WatchpointIsEnabled(wp_index) &&
+        trap_addr >= watch_addr && trap_addr < watch_addr + watch_size) {
+      m_hwp_regs[wp_index].hit_addr = trap_addr;
+      return Error();
     }
+  }
 
-    wp_index = LLDB_INVALID_INDEX32;
-    return Error();
+  wp_index = LLDB_INVALID_INDEX32;
+  return Error();
 }
 
 lldb::addr_t
-NativeRegisterContextLinux_arm64::GetWatchpointAddress (uint32_t wp_index)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS));
+NativeRegisterContextLinux_arm64::GetWatchpointAddress(uint32_t wp_index) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
 
-    if (log)
-        log->Printf ("NativeRegisterContextLinux_arm64::%s()", __FUNCTION__);
+  if (log)
+    log->Printf("NativeRegisterContextLinux_arm64::%s()", __FUNCTION__);
 
-    if (wp_index >= m_max_hwp_supported)
-        return LLDB_INVALID_ADDRESS;
+  if (wp_index >= m_max_hwp_supported)
+    return LLDB_INVALID_ADDRESS;
 
-    if (WatchpointIsEnabled(wp_index))
-        return m_hwp_regs[wp_index].real_addr;
-    else
-        return LLDB_INVALID_ADDRESS;
+  if (WatchpointIsEnabled(wp_index))
+    return m_hwp_regs[wp_index].real_addr;
+  else
+    return LLDB_INVALID_ADDRESS;
 }
 
 lldb::addr_t
-NativeRegisterContextLinux_arm64::GetWatchpointHitAddress (uint32_t wp_index)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS));
+NativeRegisterContextLinux_arm64::GetWatchpointHitAddress(uint32_t wp_index) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
 
-    if (log)
-        log->Printf ("NativeRegisterContextLinux_arm64::%s()", __FUNCTION__);
+  if (log)
+    log->Printf("NativeRegisterContextLinux_arm64::%s()", __FUNCTION__);
 
-    if (wp_index >= m_max_hwp_supported)
-        return LLDB_INVALID_ADDRESS;
+  if (wp_index >= m_max_hwp_supported)
+    return LLDB_INVALID_ADDRESS;
 
-    if (WatchpointIsEnabled(wp_index))
-        return m_hwp_regs[wp_index].hit_addr;
-    else
-        return LLDB_INVALID_ADDRESS;
+  if (WatchpointIsEnabled(wp_index))
+    return m_hwp_regs[wp_index].hit_addr;
+  else
+    return LLDB_INVALID_ADDRESS;
 }
 
-Error
-NativeRegisterContextLinux_arm64::ReadHardwareDebugInfo()
-{
-    if (!m_refresh_hwdebug_info)
-    {
-        return Error();
-    }
-
-    ::pid_t tid = m_thread.GetID();
+Error NativeRegisterContextLinux_arm64::ReadHardwareDebugInfo() {
+  if (!m_refresh_hwdebug_info) {
+    return Error();
+  }
 
-    int regset = NT_ARM_HW_WATCH;
-    struct iovec ioVec;
-    struct user_hwdebug_state dreg_state;
-    Error error;
+  ::pid_t tid = m_thread.GetID();
 
-    ioVec.iov_base = &dreg_state;
-    ioVec.iov_len = sizeof (dreg_state);
-    error = NativeProcessLinux::PtraceWrapper(PTRACE_GETREGSET, tid, &regset, &ioVec, ioVec.iov_len);
+  int regset = NT_ARM_HW_WATCH;
+  struct iovec ioVec;
+  struct user_hwdebug_state dreg_state;
+  Error error;
 
-    if (error.Fail())
-        return error;
+  ioVec.iov_base = &dreg_state;
+  ioVec.iov_len = sizeof(dreg_state);
+  error = NativeProcessLinux::PtraceWrapper(PTRACE_GETREGSET, tid, &regset,
+                                            &ioVec, ioVec.iov_len);
 
-    m_max_hwp_supported = dreg_state.dbg_info & 0xff;
+  if (error.Fail())
+    return error;
 
-    regset = NT_ARM_HW_BREAK;
-    error = NativeProcessLinux::PtraceWrapper(PTRACE_GETREGSET, tid, &regset, &ioVec, ioVec.iov_len);
+  m_max_hwp_supported = dreg_state.dbg_info & 0xff;
 
-    if (error.Fail())
-        return error;
-	
-    m_max_hbp_supported = dreg_state.dbg_info & 0xff;
-    m_refresh_hwdebug_info = false;
+  regset = NT_ARM_HW_BREAK;
+  error = NativeProcessLinux::PtraceWrapper(PTRACE_GETREGSET, tid, &regset,
+                                            &ioVec, ioVec.iov_len);
 
+  if (error.Fail())
     return error;
-}
 
-Error
-NativeRegisterContextLinux_arm64::WriteHardwareDebugRegs(int hwbType)
-{
-    struct iovec ioVec;
-    struct user_hwdebug_state dreg_state;
-    Error error;
+  m_max_hbp_supported = dreg_state.dbg_info & 0xff;
+  m_refresh_hwdebug_info = false;
 
-    memset (&dreg_state, 0, sizeof (dreg_state));
-    ioVec.iov_base = &dreg_state;
+  return error;
+}
 
-    if (hwbType == eDREGTypeWATCH)
-    {
-        hwbType = NT_ARM_HW_WATCH;
-        ioVec.iov_len = sizeof (dreg_state.dbg_info) + sizeof (dreg_state.pad)
-                + (sizeof (dreg_state.dbg_regs [0]) * m_max_hwp_supported);
-
-        for (uint32_t i = 0; i < m_max_hwp_supported; i++)
-        {
-            dreg_state.dbg_regs[i].addr = m_hwp_regs[i].address;
-            dreg_state.dbg_regs[i].ctrl = m_hwp_regs[i].control;
-        }
-    }
-    else
-    {
-        hwbType = NT_ARM_HW_BREAK;
-        ioVec.iov_len = sizeof (dreg_state.dbg_info) + sizeof (dreg_state.pad)
-                + (sizeof (dreg_state.dbg_regs [0]) * m_max_hbp_supported);
-
-        for (uint32_t i = 0; i < m_max_hbp_supported; i++)
-        {
-            dreg_state.dbg_regs[i].addr = m_hbr_regs[i].address;
-            dreg_state.dbg_regs[i].ctrl = m_hbr_regs[i].control;
-        }
-    }
+Error NativeRegisterContextLinux_arm64::WriteHardwareDebugRegs(int hwbType) {
+  struct iovec ioVec;
+  struct user_hwdebug_state dreg_state;
+  Error error;
 
-    return NativeProcessLinux::PtraceWrapper(PTRACE_SETREGSET, m_thread.GetID(), &hwbType, &ioVec, ioVec.iov_len);
-}
+  memset(&dreg_state, 0, sizeof(dreg_state));
+  ioVec.iov_base = &dreg_state;
 
-Error
-NativeRegisterContextLinux_arm64::DoReadRegisterValue(uint32_t offset,
-                                                      const char* reg_name,
-                                                      uint32_t size,
-                                                      RegisterValue &value)
-{
-    Error error;
-    if (offset > sizeof(struct user_pt_regs))
-    {
-        uintptr_t offset = offset - sizeof(struct user_pt_regs);
-        if (offset > sizeof(struct user_fpsimd_state))
-        {
-            error.SetErrorString("invalid offset value");
-            return error;
-        }
-        elf_fpregset_t regs;
-        int regset = NT_FPREGSET;
-        struct iovec ioVec;
-
-        ioVec.iov_base = ®s;
-        ioVec.iov_len = sizeof regs;
-        error = NativeProcessLinux::PtraceWrapper(
-                PTRACE_GETREGSET, m_thread.GetID(), &regset, &ioVec, sizeof regs);
-        if (error.Success())
-        {
-            ArchSpec arch;
-            if (m_thread.GetProcess()->GetArchitecture(arch))
-                value.SetBytes((void *)(((unsigned char *)(&regs)) + offset), 16, arch.GetByteOrder());
-            else
-                error.SetErrorString("failed to get architecture");
-        }
-    }
-    else
-    {
-        elf_gregset_t regs;
-        int regset = NT_PRSTATUS;
-        struct iovec ioVec;
-
-        ioVec.iov_base = ®s;
-        ioVec.iov_len = sizeof regs;
-        error = NativeProcessLinux::PtraceWrapper(
-                PTRACE_GETREGSET, m_thread.GetID(), &regset, &ioVec, sizeof regs);
-        if (error.Success())
-        {
-            ArchSpec arch;
-            if (m_thread.GetProcess()->GetArchitecture(arch))
-                value.SetBytes((void *)(((unsigned char *)(regs)) + offset), 8, arch.GetByteOrder());
-            else
-                error.SetErrorString("failed to get architecture");
-        }
-    }
-    return error;
-}
+  if (hwbType == eDREGTypeWATCH) {
+    hwbType = NT_ARM_HW_WATCH;
+    ioVec.iov_len = sizeof(dreg_state.dbg_info) + sizeof(dreg_state.pad) +
+                    (sizeof(dreg_state.dbg_regs[0]) * m_max_hwp_supported);
 
-Error
-NativeRegisterContextLinux_arm64::DoWriteRegisterValue(uint32_t offset,
-                                                       const char* reg_name,
-                                                       const RegisterValue &value)
-{
-    Error error;
-    ::pid_t tid = m_thread.GetID();
-    if (offset > sizeof(struct user_pt_regs))
-    {
-        uintptr_t offset = offset - sizeof(struct user_pt_regs);
-        if (offset > sizeof(struct user_fpsimd_state))
-        {
-            error.SetErrorString("invalid offset value");
-            return error;
-        }
-        elf_fpregset_t regs;
-        int regset = NT_FPREGSET;
-        struct iovec ioVec;
-
-        ioVec.iov_base = ®s;
-        ioVec.iov_len = sizeof regs;
-        error = NativeProcessLinux::PtraceWrapper( PTRACE_GETREGSET, tid, &regset, &ioVec, sizeof regs);
-
-        if (error.Success())
-        {
-            ::memcpy((void *)(((unsigned char *)(&regs)) + offset), value.GetBytes(), 16);
-            error = NativeProcessLinux::PtraceWrapper(PTRACE_SETREGSET, tid, &regset, &ioVec, sizeof regs);
-        }
+    for (uint32_t i = 0; i < m_max_hwp_supported; i++) {
+      dreg_state.dbg_regs[i].addr = m_hwp_regs[i].address;
+      dreg_state.dbg_regs[i].ctrl = m_hwp_regs[i].control;
     }
-    else
-    {
-        elf_gregset_t regs;
-        int regset = NT_PRSTATUS;
-        struct iovec ioVec;
-
-        ioVec.iov_base = ®s;
-        ioVec.iov_len = sizeof regs;
-        error = NativeProcessLinux::PtraceWrapper(PTRACE_GETREGSET, tid, &regset, &ioVec, sizeof regs);
-        if (error.Success())
-        {
-            ::memcpy((void *)(((unsigned char *)(&regs)) + offset), value.GetBytes(), 8);
-            error = NativeProcessLinux::PtraceWrapper(PTRACE_SETREGSET, tid, &regset, &ioVec, sizeof regs);
-        }
+  } else {
+    hwbType = NT_ARM_HW_BREAK;
+    ioVec.iov_len = sizeof(dreg_state.dbg_info) + sizeof(dreg_state.pad) +
+                    (sizeof(dreg_state.dbg_regs[0]) * m_max_hbp_supported);
+
+    for (uint32_t i = 0; i < m_max_hbp_supported; i++) {
+      dreg_state.dbg_regs[i].addr = m_hbr_regs[i].address;
+      dreg_state.dbg_regs[i].ctrl = m_hbr_regs[i].control;
     }
-    return error;
+  }
+
+  return NativeProcessLinux::PtraceWrapper(PTRACE_SETREGSET, m_thread.GetID(),
+                                           &hwbType, &ioVec, ioVec.iov_len);
 }
 
-Error
-NativeRegisterContextLinux_arm64::DoReadGPR(void *buf, size_t buf_size)
-{
-    int regset = NT_PRSTATUS;
+Error NativeRegisterContextLinux_arm64::DoReadRegisterValue(
+    uint32_t offset, const char *reg_name, uint32_t size,
+    RegisterValue &value) {
+  Error error;
+  if (offset > sizeof(struct user_pt_regs)) {
+    uintptr_t offset = offset - sizeof(struct user_pt_regs);
+    if (offset > sizeof(struct user_fpsimd_state)) {
+      error.SetErrorString("invalid offset value");
+      return error;
+    }
+    elf_fpregset_t regs;
+    int regset = NT_FPREGSET;
     struct iovec ioVec;
-    Error error;
-
-    ioVec.iov_base = buf;
-    ioVec.iov_len = buf_size;
-    return NativeProcessLinux::PtraceWrapper(PTRACE_GETREGSET, m_thread.GetID(), &regset, &ioVec, buf_size);
-}
 
-Error
-NativeRegisterContextLinux_arm64::DoWriteGPR(void *buf, size_t buf_size)
-{
+    ioVec.iov_base = ®s;
+    ioVec.iov_len = sizeof regs;
+    error = NativeProcessLinux::PtraceWrapper(
+        PTRACE_GETREGSET, m_thread.GetID(), &regset, &ioVec, sizeof regs);
+    if (error.Success()) {
+      ArchSpec arch;
+      if (m_thread.GetProcess()->GetArchitecture(arch))
+        value.SetBytes((void *)(((unsigned char *)(&regs)) + offset), 16,
+                       arch.GetByteOrder());
+      else
+        error.SetErrorString("failed to get architecture");
+    }
+  } else {
+    elf_gregset_t regs;
     int regset = NT_PRSTATUS;
     struct iovec ioVec;
-    Error error;
-
-    ioVec.iov_base = buf;
-    ioVec.iov_len = buf_size;
-    return NativeProcessLinux::PtraceWrapper(PTRACE_SETREGSET, m_thread.GetID(), &regset, &ioVec, buf_size);
-}
 
-Error
-NativeRegisterContextLinux_arm64::DoReadFPR(void *buf, size_t buf_size)
-{
+    ioVec.iov_base = ®s;
+    ioVec.iov_len = sizeof regs;
+    error = NativeProcessLinux::PtraceWrapper(
+        PTRACE_GETREGSET, m_thread.GetID(), &regset, &ioVec, sizeof regs);
+    if (error.Success()) {
+      ArchSpec arch;
+      if (m_thread.GetProcess()->GetArchitecture(arch))
+        value.SetBytes((void *)(((unsigned char *)(regs)) + offset), 8,
+                       arch.GetByteOrder());
+      else
+        error.SetErrorString("failed to get architecture");
+    }
+  }
+  return error;
+}
+
+Error NativeRegisterContextLinux_arm64::DoWriteRegisterValue(
+    uint32_t offset, const char *reg_name, const RegisterValue &value) {
+  Error error;
+  ::pid_t tid = m_thread.GetID();
+  if (offset > sizeof(struct user_pt_regs)) {
+    uintptr_t offset = offset - sizeof(struct user_pt_regs);
+    if (offset > sizeof(struct user_fpsimd_state)) {
+      error.SetErrorString("invalid offset value");
+      return error;
+    }
+    elf_fpregset_t regs;
     int regset = NT_FPREGSET;
     struct iovec ioVec;
-    Error error;
 
-    ioVec.iov_base = buf;
-    ioVec.iov_len = buf_size;
-    return NativeProcessLinux::PtraceWrapper(PTRACE_GETREGSET, m_thread.GetID(), &regset, &ioVec, buf_size);
-}
-
-Error
-NativeRegisterContextLinux_arm64::DoWriteFPR(void *buf, size_t buf_size)
-{
-    int regset = NT_FPREGSET;
+    ioVec.iov_base = ®s;
+    ioVec.iov_len = sizeof regs;
+    error = NativeProcessLinux::PtraceWrapper(PTRACE_GETREGSET, tid, &regset,
+                                              &ioVec, sizeof regs);
+
+    if (error.Success()) {
+      ::memcpy((void *)(((unsigned char *)(&regs)) + offset), value.GetBytes(),
+               16);
+      error = NativeProcessLinux::PtraceWrapper(PTRACE_SETREGSET, tid, &regset,
+                                                &ioVec, sizeof regs);
+    }
+  } else {
+    elf_gregset_t regs;
+    int regset = NT_PRSTATUS;
     struct iovec ioVec;
-    Error error;
 
-    ioVec.iov_base = buf;
-    ioVec.iov_len = buf_size;
-    return NativeProcessLinux::PtraceWrapper(PTRACE_SETREGSET, m_thread.GetID(), &regset, &ioVec, buf_size);
-}
-
-uint32_t
-NativeRegisterContextLinux_arm64::CalculateFprOffset(const RegisterInfo* reg_info) const
-{
-    return reg_info->byte_offset - GetRegisterInfoAtIndex(m_reg_info.first_fpr)->byte_offset;
+    ioVec.iov_base = ®s;
+    ioVec.iov_len = sizeof regs;
+    error = NativeProcessLinux::PtraceWrapper(PTRACE_GETREGSET, tid, &regset,
+                                              &ioVec, sizeof regs);
+    if (error.Success()) {
+      ::memcpy((void *)(((unsigned char *)(&regs)) + offset), value.GetBytes(),
+               8);
+      error = NativeProcessLinux::PtraceWrapper(PTRACE_SETREGSET, tid, &regset,
+                                                &ioVec, sizeof regs);
+    }
+  }
+  return error;
+}
+
+Error NativeRegisterContextLinux_arm64::DoReadGPR(void *buf, size_t buf_size) {
+  int regset = NT_PRSTATUS;
+  struct iovec ioVec;
+  Error error;
+
+  ioVec.iov_base = buf;
+  ioVec.iov_len = buf_size;
+  return NativeProcessLinux::PtraceWrapper(PTRACE_GETREGSET, m_thread.GetID(),
+                                           &regset, &ioVec, buf_size);
+}
+
+Error NativeRegisterContextLinux_arm64::DoWriteGPR(void *buf, size_t buf_size) {
+  int regset = NT_PRSTATUS;
+  struct iovec ioVec;
+  Error error;
+
+  ioVec.iov_base = buf;
+  ioVec.iov_len = buf_size;
+  return NativeProcessLinux::PtraceWrapper(PTRACE_SETREGSET, m_thread.GetID(),
+                                           &regset, &ioVec, buf_size);
+}
+
+Error NativeRegisterContextLinux_arm64::DoReadFPR(void *buf, size_t buf_size) {
+  int regset = NT_FPREGSET;
+  struct iovec ioVec;
+  Error error;
+
+  ioVec.iov_base = buf;
+  ioVec.iov_len = buf_size;
+  return NativeProcessLinux::PtraceWrapper(PTRACE_GETREGSET, m_thread.GetID(),
+                                           &regset, &ioVec, buf_size);
+}
+
+Error NativeRegisterContextLinux_arm64::DoWriteFPR(void *buf, size_t buf_size) {
+  int regset = NT_FPREGSET;
+  struct iovec ioVec;
+  Error error;
+
+  ioVec.iov_base = buf;
+  ioVec.iov_len = buf_size;
+  return NativeProcessLinux::PtraceWrapper(PTRACE_SETREGSET, m_thread.GetID(),
+                                           &regset, &ioVec, buf_size);
+}
+
+uint32_t NativeRegisterContextLinux_arm64::CalculateFprOffset(
+    const RegisterInfo *reg_info) const {
+  return reg_info->byte_offset -
+         GetRegisterInfoAtIndex(m_reg_info.first_fpr)->byte_offset;
 }
 
 #endif // defined (__arm64__) || defined (__aarch64__)

Modified: lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h (original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h Tue Sep  6 15:57:50 2016
@@ -7,7 +7,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#if defined (__arm64__) || defined (__aarch64__)
+#if defined(__arm64__) || defined(__aarch64__)
 
 #ifndef lldb_NativeRegisterContextLinux_arm64_h
 #define lldb_NativeRegisterContextLinux_arm64_h
@@ -18,180 +18,142 @@
 namespace lldb_private {
 namespace process_linux {
 
-    class NativeProcessLinux;
+class NativeProcessLinux;
 
-    class NativeRegisterContextLinux_arm64 : public NativeRegisterContextLinux
-    {
-    public:
-        NativeRegisterContextLinux_arm64 (const ArchSpec& target_arch,
-                                          NativeThreadProtocol &native_thread,
-                                          uint32_t concrete_frame_idx);
+class NativeRegisterContextLinux_arm64 : public NativeRegisterContextLinux {
+public:
+  NativeRegisterContextLinux_arm64(const ArchSpec &target_arch,
+                                   NativeThreadProtocol &native_thread,
+                                   uint32_t concrete_frame_idx);
 
-        uint32_t
-        GetRegisterSetCount () const override;
+  uint32_t GetRegisterSetCount() const override;
 
-        uint32_t
-        GetUserRegisterCount() const override;
+  uint32_t GetUserRegisterCount() const override;
 
-        const RegisterSet *
-        GetRegisterSet (uint32_t set_index) const override;
+  const RegisterSet *GetRegisterSet(uint32_t set_index) const override;
 
-        Error
-        ReadRegister (const RegisterInfo *reg_info, RegisterValue &reg_value) override;
+  Error ReadRegister(const RegisterInfo *reg_info,
+                     RegisterValue &reg_value) override;
 
-        Error
-        WriteRegister (const RegisterInfo *reg_info, const RegisterValue &reg_value) override;
+  Error WriteRegister(const RegisterInfo *reg_info,
+                      const RegisterValue &reg_value) override;
 
-        Error
-        ReadAllRegisterValues (lldb::DataBufferSP &data_sp) override;
+  Error ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
 
-        Error
-        WriteAllRegisterValues (const lldb::DataBufferSP &data_sp) override;
+  Error WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
 
-        //------------------------------------------------------------------
-        // Hardware breakpoints/watchpoint mangement functions
-        //------------------------------------------------------------------
+  //------------------------------------------------------------------
+  // Hardware breakpoints/watchpoint mangement functions
+  //------------------------------------------------------------------
 
-        uint32_t
-        SetHardwareBreakpoint (lldb::addr_t addr, size_t size) override;
+  uint32_t SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override;
 
-        bool
-        ClearHardwareBreakpoint (uint32_t hw_idx) override;
+  bool ClearHardwareBreakpoint(uint32_t hw_idx) override;
 
-        uint32_t
-        NumSupportedHardwareWatchpoints () override;
+  uint32_t NumSupportedHardwareWatchpoints() override;
 
-        uint32_t
-        SetHardwareWatchpoint (lldb::addr_t addr, size_t size, uint32_t watch_flags) override;
+  uint32_t SetHardwareWatchpoint(lldb::addr_t addr, size_t size,
+                                 uint32_t watch_flags) override;
 
-        bool
-        ClearHardwareWatchpoint (uint32_t hw_index) override;
+  bool ClearHardwareWatchpoint(uint32_t hw_index) override;
 
-        Error
-        ClearAllHardwareWatchpoints () override;
+  Error ClearAllHardwareWatchpoints() override;
 
-        Error
-        GetWatchpointHitIndex(uint32_t &wp_index, lldb::addr_t trap_addr) override;
+  Error GetWatchpointHitIndex(uint32_t &wp_index,
+                              lldb::addr_t trap_addr) override;
 
-        lldb::addr_t
-        GetWatchpointHitAddress (uint32_t wp_index) override;
+  lldb::addr_t GetWatchpointHitAddress(uint32_t wp_index) override;
 
-        lldb::addr_t
-        GetWatchpointAddress (uint32_t wp_index) override;
+  lldb::addr_t GetWatchpointAddress(uint32_t wp_index) override;
 
-        uint32_t
-        GetWatchpointSize(uint32_t wp_index);
+  uint32_t GetWatchpointSize(uint32_t wp_index);
 
-        bool
-        WatchpointIsEnabled(uint32_t wp_index);
+  bool WatchpointIsEnabled(uint32_t wp_index);
 
-        // Debug register type select
-        enum DREGType
-        {
-            eDREGTypeWATCH = 0,
-            eDREGTypeBREAK
-        };
+  // Debug register type select
+  enum DREGType { eDREGTypeWATCH = 0, eDREGTypeBREAK };
 
-    protected:
-        Error
-        DoReadRegisterValue(uint32_t offset,
-                            const char* reg_name,
-                            uint32_t size,
-                            RegisterValue &value) override;
+protected:
+  Error DoReadRegisterValue(uint32_t offset, const char *reg_name,
+                            uint32_t size, RegisterValue &value) override;
 
-        Error
-        DoWriteRegisterValue(uint32_t offset,
-                             const char* reg_name,
+  Error DoWriteRegisterValue(uint32_t offset, const char *reg_name,
                              const RegisterValue &value) override;
 
-        Error
-        DoReadGPR(void *buf, size_t buf_size) override;
+  Error DoReadGPR(void *buf, size_t buf_size) override;
 
-        Error
-        DoWriteGPR(void *buf, size_t buf_size) override;
+  Error DoWriteGPR(void *buf, size_t buf_size) override;
 
-        Error
-        DoReadFPR(void *buf, size_t buf_size) override;
+  Error DoReadFPR(void *buf, size_t buf_size) override;
 
-        Error
-        DoWriteFPR(void *buf, size_t buf_size) override;
-
-        void*
-        GetGPRBuffer() override { return &m_gpr_arm64; }
-
-        void*
-        GetFPRBuffer() override { return &m_fpr; }
-
-        size_t
-        GetFPRSize() override { return sizeof(m_fpr); }
-
-    private:
-        struct RegInfo
-        {
-            uint32_t num_registers;
-            uint32_t num_gpr_registers;
-            uint32_t num_fpr_registers;
-
-            uint32_t last_gpr;
-            uint32_t first_fpr;
-            uint32_t last_fpr;
-
-            uint32_t first_fpr_v;
-            uint32_t last_fpr_v;
-
-            uint32_t gpr_flags;
-        };
-
-        // based on RegisterContextDarwin_arm64.h
-        struct VReg
-        {
-            uint8_t bytes[16];
-        };
-
-        // based on RegisterContextDarwin_arm64.h
-        struct FPU
-        {
-            VReg        v[32];
-            uint32_t    fpsr;
-            uint32_t    fpcr;
-        };
-
-        uint64_t m_gpr_arm64[k_num_gpr_registers_arm64]; // 64-bit general purpose registers.
-        RegInfo  m_reg_info;
-        FPU m_fpr; // floating-point registers including extended register sets.
-
-        // Debug register info for hardware breakpoints and watchpoints management.
-        struct DREG
-        {
-            lldb::addr_t address;  // Breakpoint/watchpoint address value.
-            lldb::addr_t hit_addr; // Address at which last watchpoint trigger exception occurred.
-            lldb::addr_t real_addr;  // Address value that should cause target to stop.
-            uint32_t control;  // Breakpoint/watchpoint control value.
-            uint32_t refcount;  // Serves as enable/disable and refernce counter.
-        };
-
-        struct DREG m_hbr_regs[16];  // Arm native linux hardware breakpoints
-        struct DREG m_hwp_regs[16];  // Arm native linux hardware watchpoints
-
-        uint32_t m_max_hwp_supported;
-        uint32_t m_max_hbp_supported;
-        bool m_refresh_hwdebug_info;
-
-        bool
-        IsGPR(unsigned reg) const;
-
-        bool
-        IsFPR(unsigned reg) const;
-
-        Error
-        ReadHardwareDebugInfo();
-
-        Error
-        WriteHardwareDebugRegs(int hwbType);
-
-        uint32_t
-        CalculateFprOffset(const RegisterInfo* reg_info) const;
-    };
+  Error DoWriteFPR(void *buf, size_t buf_size) override;
+
+  void *GetGPRBuffer() override { return &m_gpr_arm64; }
+
+  void *GetFPRBuffer() override { return &m_fpr; }
+
+  size_t GetFPRSize() override { return sizeof(m_fpr); }
+
+private:
+  struct RegInfo {
+    uint32_t num_registers;
+    uint32_t num_gpr_registers;
+    uint32_t num_fpr_registers;
+
+    uint32_t last_gpr;
+    uint32_t first_fpr;
+    uint32_t last_fpr;
+
+    uint32_t first_fpr_v;
+    uint32_t last_fpr_v;
+
+    uint32_t gpr_flags;
+  };
+
+  // based on RegisterContextDarwin_arm64.h
+  struct VReg {
+    uint8_t bytes[16];
+  };
+
+  // based on RegisterContextDarwin_arm64.h
+  struct FPU {
+    VReg v[32];
+    uint32_t fpsr;
+    uint32_t fpcr;
+  };
+
+  uint64_t m_gpr_arm64[k_num_gpr_registers_arm64]; // 64-bit general purpose
+                                                   // registers.
+  RegInfo m_reg_info;
+  FPU m_fpr; // floating-point registers including extended register sets.
+
+  // Debug register info for hardware breakpoints and watchpoints management.
+  struct DREG {
+    lldb::addr_t address;  // Breakpoint/watchpoint address value.
+    lldb::addr_t hit_addr; // Address at which last watchpoint trigger exception
+                           // occurred.
+    lldb::addr_t real_addr; // Address value that should cause target to stop.
+    uint32_t control;       // Breakpoint/watchpoint control value.
+    uint32_t refcount;      // Serves as enable/disable and refernce counter.
+  };
+
+  struct DREG m_hbr_regs[16]; // Arm native linux hardware breakpoints
+  struct DREG m_hwp_regs[16]; // Arm native linux hardware watchpoints
+
+  uint32_t m_max_hwp_supported;
+  uint32_t m_max_hbp_supported;
+  bool m_refresh_hwdebug_info;
+
+  bool IsGPR(unsigned reg) const;
+
+  bool IsFPR(unsigned reg) const;
+
+  Error ReadHardwareDebugInfo();
+
+  Error WriteHardwareDebugRegs(int hwbType);
+
+  uint32_t CalculateFprOffset(const RegisterInfo *reg_info) const;
+};
 
 } // namespace process_linux
 } // namespace lldb_private

Modified: lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp Tue Sep  6 15:57:50 2016
@@ -7,7 +7,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#if defined (__mips__)
+#if defined(__mips__)
 
 #include "NativeRegisterContextLinux_mips64.h"
 
@@ -15,57 +15,49 @@
 // C++ Includes
 
 // Other libraries and framework includes
+#include "Plugins/Process/Linux/NativeProcessLinux.h"
+#include "Plugins/Process/Linux/Procfs.h"
+#include "Plugins/Process/Utility/RegisterContextLinux_mips.h"
+#include "Plugins/Process/Utility/RegisterContextLinux_mips64.h"
+#include "lldb/Core/DataBufferHeap.h"
+#include "lldb/Core/EmulateInstruction.h"
 #include "lldb/Core/Error.h"
-#include "lldb/Core/RegisterValue.h"
 #include "lldb/Core/Log.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Host/HostInfo.h"
+#include "lldb/Core/RegisterValue.h"
 #include "lldb/Host/Host.h"
-#include "lldb/Core/EmulateInstruction.h"
+#include "lldb/Host/HostInfo.h"
 #include "lldb/lldb-enumerations.h"
 #include "lldb/lldb-private-enumerations.h"
-#include "Plugins/Process/Linux/NativeProcessLinux.h"
-#include "Plugins/Process/Linux/Procfs.h"
-#include "Plugins/Process/Utility/RegisterContextLinux_mips64.h"
-#include "Plugins/Process/Utility/RegisterContextLinux_mips.h"
 #define NT_MIPS_MSA 0x600
 #define CONFIG5_FRE (1 << 8)
 #define SR_FR (1 << 26)
 #define NUM_REGISTERS 32
 
-#include <sys/ptrace.h>
 #include <asm/ptrace.h>
+#include <sys/ptrace.h>
 
 #ifndef PTRACE_GET_WATCH_REGS
-enum pt_watch_style
-{
-    pt_watch_style_mips32,
-    pt_watch_style_mips64
-};
-struct mips32_watch_regs
-{
-    uint32_t watchlo[8];
-    uint16_t watchhi[8];
-    uint16_t watch_masks[8];
-    uint32_t num_valid;
+enum pt_watch_style { pt_watch_style_mips32, pt_watch_style_mips64 };
+struct mips32_watch_regs {
+  uint32_t watchlo[8];
+  uint16_t watchhi[8];
+  uint16_t watch_masks[8];
+  uint32_t num_valid;
 } __attribute__((aligned(8)));
 
-struct mips64_watch_regs
-{
-    uint64_t watchlo[8];
-    uint16_t watchhi[8];
-    uint16_t watch_masks[8];
-    uint32_t num_valid;
+struct mips64_watch_regs {
+  uint64_t watchlo[8];
+  uint16_t watchhi[8];
+  uint16_t watch_masks[8];
+  uint32_t num_valid;
 } __attribute__((aligned(8)));
 
-struct pt_watch_regs
-{
-    enum pt_watch_style style;
-    union
-    {
-        struct mips32_watch_regs mips32;
-        struct mips64_watch_regs mips64;
-    };
+struct pt_watch_regs {
+  enum pt_watch_style style;
+  union {
+    struct mips32_watch_regs mips32;
+    struct mips64_watch_regs mips64;
+  };
 };
 
 #define PTRACE_GET_WATCH_REGS 0xd0
@@ -76,7 +68,7 @@ struct pt_watch_regs
 #define R (1 << 1)
 #define I (1 << 2)
 
-#define IRW  (I | R | W)
+#define IRW (I | R | W)
 
 struct pt_watch_regs default_watch_regs;
 
@@ -87,1227 +79,993 @@ using namespace lldb_private::process_li
 // Private namespace.
 // ----------------------------------------------------------------------------
 
-namespace
-{
-    // mips general purpose registers.
-    const uint32_t
-    g_gp_regnums_mips[] =
-    {
-        gpr_zero_mips,
-        gpr_r1_mips,
-        gpr_r2_mips,
-        gpr_r3_mips,
-        gpr_r4_mips,
-        gpr_r5_mips,
-        gpr_r6_mips,
-        gpr_r7_mips,
-        gpr_r8_mips,
-        gpr_r9_mips,
-        gpr_r10_mips,
-        gpr_r11_mips,
-        gpr_r12_mips,
-        gpr_r13_mips,
-        gpr_r14_mips,
-        gpr_r15_mips,
-        gpr_r16_mips,
-        gpr_r17_mips,
-        gpr_r18_mips,
-        gpr_r19_mips,
-        gpr_r20_mips,
-        gpr_r21_mips,
-        gpr_r22_mips,
-        gpr_r23_mips,
-        gpr_r24_mips,
-        gpr_r25_mips,
-        gpr_r26_mips,
-        gpr_r27_mips,
-        gpr_gp_mips,
-        gpr_sp_mips,
-        gpr_r30_mips,
-        gpr_ra_mips,
-        gpr_sr_mips,
-        gpr_mullo_mips,
-        gpr_mulhi_mips,
-        gpr_badvaddr_mips,
-        gpr_cause_mips,
-        gpr_pc_mips,
-        gpr_config5_mips,
-        LLDB_INVALID_REGNUM     // register sets need to end with this flag
-    };
-
-    static_assert((sizeof(g_gp_regnums_mips) / sizeof(g_gp_regnums_mips[0])) - 1 == k_num_gpr_registers_mips,
-                  "g_gp_regnums_mips has wrong number of register infos");
-
-    // mips floating point registers.
-    const uint32_t
-    g_fp_regnums_mips[] =
-    {
-        fpr_f0_mips,
-        fpr_f1_mips,
-        fpr_f2_mips,
-        fpr_f3_mips,
-        fpr_f4_mips,
-        fpr_f5_mips,
-        fpr_f6_mips,
-        fpr_f7_mips,
-        fpr_f8_mips,
-        fpr_f9_mips,
-        fpr_f10_mips,
-        fpr_f11_mips,
-        fpr_f12_mips,
-        fpr_f13_mips,
-        fpr_f14_mips,
-        fpr_f15_mips,
-        fpr_f16_mips,
-        fpr_f17_mips,
-        fpr_f18_mips,
-        fpr_f19_mips,
-        fpr_f20_mips,
-        fpr_f21_mips,
-        fpr_f22_mips,
-        fpr_f23_mips,
-        fpr_f24_mips,
-        fpr_f25_mips,
-        fpr_f26_mips,
-        fpr_f27_mips,
-        fpr_f28_mips,
-        fpr_f29_mips,
-        fpr_f30_mips,
-        fpr_f31_mips,
-        fpr_fcsr_mips,
-        fpr_fir_mips,
-        fpr_config5_mips,
-        LLDB_INVALID_REGNUM     // register sets need to end with this flag
-    };
-
-    static_assert((sizeof(g_fp_regnums_mips) / sizeof(g_fp_regnums_mips[0])) - 1 == k_num_fpr_registers_mips,
-                  "g_fp_regnums_mips has wrong number of register infos");
-
-    // mips MSA registers.
-    const uint32_t
-    g_msa_regnums_mips[] =
-    {
-        msa_w0_mips,
-        msa_w1_mips,
-        msa_w2_mips,
-        msa_w3_mips,
-        msa_w4_mips,
-        msa_w5_mips,
-        msa_w6_mips,
-        msa_w7_mips,
-        msa_w8_mips,
-        msa_w9_mips,
-        msa_w10_mips,
-        msa_w11_mips,
-        msa_w12_mips,
-        msa_w13_mips,
-        msa_w14_mips,
-        msa_w15_mips,
-        msa_w16_mips,
-        msa_w17_mips,
-        msa_w18_mips,
-        msa_w19_mips,
-        msa_w20_mips,
-        msa_w21_mips,
-        msa_w22_mips,
-        msa_w23_mips,
-        msa_w24_mips,
-        msa_w25_mips,
-        msa_w26_mips,
-        msa_w27_mips,
-        msa_w28_mips,
-        msa_w29_mips,
-        msa_w30_mips,
-        msa_w31_mips,
-        msa_fcsr_mips,
-        msa_fir_mips,
-        msa_mcsr_mips,
-        msa_mir_mips,
-        msa_config5_mips,
-        LLDB_INVALID_REGNUM     // register sets need to end with this flag
-    };
-
-    static_assert((sizeof(g_msa_regnums_mips) / sizeof(g_msa_regnums_mips[0])) - 1 == k_num_msa_registers_mips,
-                  "g_msa_regnums_mips has wrong number of register infos");
-
-    // mips64 general purpose registers.
-    const uint32_t
-    g_gp_regnums_mips64[] =
-    {
-        gpr_zero_mips64,
-        gpr_r1_mips64,
-        gpr_r2_mips64,
-        gpr_r3_mips64,
-        gpr_r4_mips64,
-        gpr_r5_mips64,
-        gpr_r6_mips64,
-        gpr_r7_mips64,
-        gpr_r8_mips64,
-        gpr_r9_mips64,
-        gpr_r10_mips64,
-        gpr_r11_mips64,
-        gpr_r12_mips64,
-        gpr_r13_mips64,
-        gpr_r14_mips64,
-        gpr_r15_mips64,
-        gpr_r16_mips64,
-        gpr_r17_mips64,
-        gpr_r18_mips64,
-        gpr_r19_mips64,
-        gpr_r20_mips64,
-        gpr_r21_mips64,
-        gpr_r22_mips64,
-        gpr_r23_mips64,
-        gpr_r24_mips64,
-        gpr_r25_mips64,
-        gpr_r26_mips64,
-        gpr_r27_mips64,
-        gpr_gp_mips64,
-        gpr_sp_mips64,
-        gpr_r30_mips64,
-        gpr_ra_mips64,
-        gpr_sr_mips64,
-        gpr_mullo_mips64,
-        gpr_mulhi_mips64,
-        gpr_badvaddr_mips64,
-        gpr_cause_mips64,
-        gpr_pc_mips64,
-        gpr_config5_mips64,
-        LLDB_INVALID_REGNUM     // register sets need to end with this flag
-    };
-
-    static_assert((sizeof(g_gp_regnums_mips64) / sizeof(g_gp_regnums_mips64[0])) - 1 == k_num_gpr_registers_mips64,
-                  "g_gp_regnums_mips64 has wrong number of register infos");
-
-    // mips64 floating point registers.
-    const uint32_t
-    g_fp_regnums_mips64[] =
-    {
-        fpr_f0_mips64,
-        fpr_f1_mips64,
-        fpr_f2_mips64,
-        fpr_f3_mips64,
-        fpr_f4_mips64,
-        fpr_f5_mips64,
-        fpr_f6_mips64,
-        fpr_f7_mips64,
-        fpr_f8_mips64,
-        fpr_f9_mips64,
-        fpr_f10_mips64,
-        fpr_f11_mips64,
-        fpr_f12_mips64,
-        fpr_f13_mips64,
-        fpr_f14_mips64,
-        fpr_f15_mips64,
-        fpr_f16_mips64,
-        fpr_f17_mips64,
-        fpr_f18_mips64,
-        fpr_f19_mips64,
-        fpr_f20_mips64,
-        fpr_f21_mips64,
-        fpr_f22_mips64,
-        fpr_f23_mips64,
-        fpr_f24_mips64,
-        fpr_f25_mips64,
-        fpr_f26_mips64,
-        fpr_f27_mips64,
-        fpr_f28_mips64,
-        fpr_f29_mips64,
-        fpr_f30_mips64,
-        fpr_f31_mips64,
-        fpr_fcsr_mips64,
-        fpr_fir_mips64,
-        fpr_config5_mips64,
-        LLDB_INVALID_REGNUM     // register sets need to end with this flag
-    };
-
-    static_assert((sizeof(g_fp_regnums_mips64) / sizeof(g_fp_regnums_mips64[0])) - 1 == k_num_fpr_registers_mips64,
-                  "g_fp_regnums_mips64 has wrong number of register infos");
-
-    // mips64 MSA registers.
-    const uint32_t
-    g_msa_regnums_mips64[] =
-    {
-        msa_w0_mips64,
-        msa_w1_mips64,
-        msa_w2_mips64,
-        msa_w3_mips64,
-        msa_w4_mips64,
-        msa_w5_mips64,
-        msa_w6_mips64,
-        msa_w7_mips64,
-        msa_w8_mips64,
-        msa_w9_mips64,
-        msa_w10_mips64,
-        msa_w11_mips64,
-        msa_w12_mips64,
-        msa_w13_mips64,
-        msa_w14_mips64,
-        msa_w15_mips64,
-        msa_w16_mips64,
-        msa_w17_mips64,
-        msa_w18_mips64,
-        msa_w19_mips64,
-        msa_w20_mips64,
-        msa_w21_mips64,
-        msa_w22_mips64,
-        msa_w23_mips64,
-        msa_w24_mips64,
-        msa_w25_mips64,
-        msa_w26_mips64,
-        msa_w27_mips64,
-        msa_w28_mips64,
-        msa_w29_mips64,
-        msa_w30_mips64,
-        msa_w31_mips64,
-        msa_fcsr_mips64,
-        msa_fir_mips64,
-        msa_mcsr_mips64,
-        msa_mir_mips64,
-        msa_config5_mips64,
-        LLDB_INVALID_REGNUM     // register sets need to end with this flag
-    };
-
-    static_assert((sizeof(g_msa_regnums_mips64) / sizeof(g_msa_regnums_mips64[0])) - 1 == k_num_msa_registers_mips64,
-                  "g_msa_regnums_mips64 has wrong number of register infos");
-
-    // Number of register sets provided by this context.
-    enum
-    {
-        k_num_register_sets = 3
-    };
-
-    // Register sets for mips.
-    static const RegisterSet
-    g_reg_sets_mips[k_num_register_sets] =
-    {
-        { "General Purpose Registers",  "gpr", k_num_gpr_registers_mips, g_gp_regnums_mips },
-        { "Floating Point Registers",   "fpu", k_num_fpr_registers_mips, g_fp_regnums_mips },
-        { "MSA Registers",              "msa", k_num_msa_registers_mips, g_msa_regnums_mips }
-    };
-
-    // Register sets for mips64.
-    static const RegisterSet
-    g_reg_sets_mips64[k_num_register_sets] =
-    {
-        { "General Purpose Registers",  "gpr", k_num_gpr_registers_mips64, g_gp_regnums_mips64 },
-        { "Floating Point Registers",   "fpu", k_num_fpr_registers_mips64, g_fp_regnums_mips64 },
-        { "MSA Registers",              "msa", k_num_msa_registers_mips64, g_msa_regnums_mips64 },
-    };
+namespace {
+// mips general purpose registers.
+const uint32_t g_gp_regnums_mips[] = {
+    gpr_zero_mips,      gpr_r1_mips,    gpr_r2_mips,      gpr_r3_mips,
+    gpr_r4_mips,        gpr_r5_mips,    gpr_r6_mips,      gpr_r7_mips,
+    gpr_r8_mips,        gpr_r9_mips,    gpr_r10_mips,     gpr_r11_mips,
+    gpr_r12_mips,       gpr_r13_mips,   gpr_r14_mips,     gpr_r15_mips,
+    gpr_r16_mips,       gpr_r17_mips,   gpr_r18_mips,     gpr_r19_mips,
+    gpr_r20_mips,       gpr_r21_mips,   gpr_r22_mips,     gpr_r23_mips,
+    gpr_r24_mips,       gpr_r25_mips,   gpr_r26_mips,     gpr_r27_mips,
+    gpr_gp_mips,        gpr_sp_mips,    gpr_r30_mips,     gpr_ra_mips,
+    gpr_sr_mips,        gpr_mullo_mips, gpr_mulhi_mips,   gpr_badvaddr_mips,
+    gpr_cause_mips,     gpr_pc_mips,    gpr_config5_mips,
+    LLDB_INVALID_REGNUM // register sets need to end with this flag
+};
+
+static_assert((sizeof(g_gp_regnums_mips) / sizeof(g_gp_regnums_mips[0])) - 1 ==
+                  k_num_gpr_registers_mips,
+              "g_gp_regnums_mips has wrong number of register infos");
+
+// mips floating point registers.
+const uint32_t g_fp_regnums_mips[] = {
+    fpr_f0_mips,        fpr_f1_mips,  fpr_f2_mips,      fpr_f3_mips,
+    fpr_f4_mips,        fpr_f5_mips,  fpr_f6_mips,      fpr_f7_mips,
+    fpr_f8_mips,        fpr_f9_mips,  fpr_f10_mips,     fpr_f11_mips,
+    fpr_f12_mips,       fpr_f13_mips, fpr_f14_mips,     fpr_f15_mips,
+    fpr_f16_mips,       fpr_f17_mips, fpr_f18_mips,     fpr_f19_mips,
+    fpr_f20_mips,       fpr_f21_mips, fpr_f22_mips,     fpr_f23_mips,
+    fpr_f24_mips,       fpr_f25_mips, fpr_f26_mips,     fpr_f27_mips,
+    fpr_f28_mips,       fpr_f29_mips, fpr_f30_mips,     fpr_f31_mips,
+    fpr_fcsr_mips,      fpr_fir_mips, fpr_config5_mips,
+    LLDB_INVALID_REGNUM // register sets need to end with this flag
+};
+
+static_assert((sizeof(g_fp_regnums_mips) / sizeof(g_fp_regnums_mips[0])) - 1 ==
+                  k_num_fpr_registers_mips,
+              "g_fp_regnums_mips has wrong number of register infos");
+
+// mips MSA registers.
+const uint32_t g_msa_regnums_mips[] = {
+    msa_w0_mips,        msa_w1_mips,  msa_w2_mips,   msa_w3_mips,
+    msa_w4_mips,        msa_w5_mips,  msa_w6_mips,   msa_w7_mips,
+    msa_w8_mips,        msa_w9_mips,  msa_w10_mips,  msa_w11_mips,
+    msa_w12_mips,       msa_w13_mips, msa_w14_mips,  msa_w15_mips,
+    msa_w16_mips,       msa_w17_mips, msa_w18_mips,  msa_w19_mips,
+    msa_w20_mips,       msa_w21_mips, msa_w22_mips,  msa_w23_mips,
+    msa_w24_mips,       msa_w25_mips, msa_w26_mips,  msa_w27_mips,
+    msa_w28_mips,       msa_w29_mips, msa_w30_mips,  msa_w31_mips,
+    msa_fcsr_mips,      msa_fir_mips, msa_mcsr_mips, msa_mir_mips,
+    msa_config5_mips,
+    LLDB_INVALID_REGNUM // register sets need to end with this flag
+};
+
+static_assert((sizeof(g_msa_regnums_mips) / sizeof(g_msa_regnums_mips[0])) -
+                      1 ==
+                  k_num_msa_registers_mips,
+              "g_msa_regnums_mips has wrong number of register infos");
+
+// mips64 general purpose registers.
+const uint32_t g_gp_regnums_mips64[] = {
+    gpr_zero_mips64,    gpr_r1_mips64,    gpr_r2_mips64,
+    gpr_r3_mips64,      gpr_r4_mips64,    gpr_r5_mips64,
+    gpr_r6_mips64,      gpr_r7_mips64,    gpr_r8_mips64,
+    gpr_r9_mips64,      gpr_r10_mips64,   gpr_r11_mips64,
+    gpr_r12_mips64,     gpr_r13_mips64,   gpr_r14_mips64,
+    gpr_r15_mips64,     gpr_r16_mips64,   gpr_r17_mips64,
+    gpr_r18_mips64,     gpr_r19_mips64,   gpr_r20_mips64,
+    gpr_r21_mips64,     gpr_r22_mips64,   gpr_r23_mips64,
+    gpr_r24_mips64,     gpr_r25_mips64,   gpr_r26_mips64,
+    gpr_r27_mips64,     gpr_gp_mips64,    gpr_sp_mips64,
+    gpr_r30_mips64,     gpr_ra_mips64,    gpr_sr_mips64,
+    gpr_mullo_mips64,   gpr_mulhi_mips64, gpr_badvaddr_mips64,
+    gpr_cause_mips64,   gpr_pc_mips64,    gpr_config5_mips64,
+    LLDB_INVALID_REGNUM // register sets need to end with this flag
+};
+
+static_assert((sizeof(g_gp_regnums_mips64) / sizeof(g_gp_regnums_mips64[0])) -
+                      1 ==
+                  k_num_gpr_registers_mips64,
+              "g_gp_regnums_mips64 has wrong number of register infos");
+
+// mips64 floating point registers.
+const uint32_t g_fp_regnums_mips64[] = {
+    fpr_f0_mips64,      fpr_f1_mips64,  fpr_f2_mips64,      fpr_f3_mips64,
+    fpr_f4_mips64,      fpr_f5_mips64,  fpr_f6_mips64,      fpr_f7_mips64,
+    fpr_f8_mips64,      fpr_f9_mips64,  fpr_f10_mips64,     fpr_f11_mips64,
+    fpr_f12_mips64,     fpr_f13_mips64, fpr_f14_mips64,     fpr_f15_mips64,
+    fpr_f16_mips64,     fpr_f17_mips64, fpr_f18_mips64,     fpr_f19_mips64,
+    fpr_f20_mips64,     fpr_f21_mips64, fpr_f22_mips64,     fpr_f23_mips64,
+    fpr_f24_mips64,     fpr_f25_mips64, fpr_f26_mips64,     fpr_f27_mips64,
+    fpr_f28_mips64,     fpr_f29_mips64, fpr_f30_mips64,     fpr_f31_mips64,
+    fpr_fcsr_mips64,    fpr_fir_mips64, fpr_config5_mips64,
+    LLDB_INVALID_REGNUM // register sets need to end with this flag
+};
+
+static_assert((sizeof(g_fp_regnums_mips64) / sizeof(g_fp_regnums_mips64[0])) -
+                      1 ==
+                  k_num_fpr_registers_mips64,
+              "g_fp_regnums_mips64 has wrong number of register infos");
+
+// mips64 MSA registers.
+const uint32_t g_msa_regnums_mips64[] = {
+    msa_w0_mips64,      msa_w1_mips64,  msa_w2_mips64,   msa_w3_mips64,
+    msa_w4_mips64,      msa_w5_mips64,  msa_w6_mips64,   msa_w7_mips64,
+    msa_w8_mips64,      msa_w9_mips64,  msa_w10_mips64,  msa_w11_mips64,
+    msa_w12_mips64,     msa_w13_mips64, msa_w14_mips64,  msa_w15_mips64,
+    msa_w16_mips64,     msa_w17_mips64, msa_w18_mips64,  msa_w19_mips64,
+    msa_w20_mips64,     msa_w21_mips64, msa_w22_mips64,  msa_w23_mips64,
+    msa_w24_mips64,     msa_w25_mips64, msa_w26_mips64,  msa_w27_mips64,
+    msa_w28_mips64,     msa_w29_mips64, msa_w30_mips64,  msa_w31_mips64,
+    msa_fcsr_mips64,    msa_fir_mips64, msa_mcsr_mips64, msa_mir_mips64,
+    msa_config5_mips64,
+    LLDB_INVALID_REGNUM // register sets need to end with this flag
+};
+
+static_assert((sizeof(g_msa_regnums_mips64) / sizeof(g_msa_regnums_mips64[0])) -
+                      1 ==
+                  k_num_msa_registers_mips64,
+              "g_msa_regnums_mips64 has wrong number of register infos");
+
+// Number of register sets provided by this context.
+enum { k_num_register_sets = 3 };
+
+// Register sets for mips.
+static const RegisterSet g_reg_sets_mips[k_num_register_sets] = {
+    {"General Purpose Registers", "gpr", k_num_gpr_registers_mips,
+     g_gp_regnums_mips},
+    {"Floating Point Registers", "fpu", k_num_fpr_registers_mips,
+     g_fp_regnums_mips},
+    {"MSA Registers", "msa", k_num_msa_registers_mips, g_msa_regnums_mips}};
+
+// Register sets for mips64.
+static const RegisterSet g_reg_sets_mips64[k_num_register_sets] = {
+    {"General Purpose Registers", "gpr", k_num_gpr_registers_mips64,
+     g_gp_regnums_mips64},
+    {"Floating Point Registers", "fpu", k_num_fpr_registers_mips64,
+     g_fp_regnums_mips64},
+    {"MSA Registers", "msa", k_num_msa_registers_mips64, g_msa_regnums_mips64},
+};
 
 } // end of anonymous namespace
 
-NativeRegisterContextLinux*
-NativeRegisterContextLinux::CreateHostNativeRegisterContextLinux(const ArchSpec& target_arch,
-                                                                 NativeThreadProtocol &native_thread,
-                                                                 uint32_t concrete_frame_idx)
-{
-    return new NativeRegisterContextLinux_mips64(target_arch, native_thread, concrete_frame_idx);
+NativeRegisterContextLinux *
+NativeRegisterContextLinux::CreateHostNativeRegisterContextLinux(
+    const ArchSpec &target_arch, NativeThreadProtocol &native_thread,
+    uint32_t concrete_frame_idx) {
+  return new NativeRegisterContextLinux_mips64(target_arch, native_thread,
+                                               concrete_frame_idx);
 }
 
-#define REG_CONTEXT_SIZE (GetRegisterInfoInterface ().GetGPRSize () + sizeof(FPR_linux_mips) + sizeof(MSA_linux_mips))
+#define REG_CONTEXT_SIZE                                                       \
+  (GetRegisterInfoInterface().GetGPRSize() + sizeof(FPR_linux_mips) +          \
+   sizeof(MSA_linux_mips))
 
 // ----------------------------------------------------------------------------
 // NativeRegisterContextLinux_mips64 members.
 // ----------------------------------------------------------------------------
 
-static RegisterInfoInterface*
-CreateRegisterInfoInterface(const ArchSpec& target_arch)
-{
-    if (HostInfo::GetArchitecture().GetAddressByteSize() == 4)
-    {
-        // 32-bit hosts run with a RegisterContextLinux_mips context.
-        return new RegisterContextLinux_mips(target_arch, NativeRegisterContextLinux_mips64::IsMSAAvailable());
-    }
-    else
-    {
-        assert((HostInfo::GetArchitecture().GetAddressByteSize() == 8) &&
-               "Register setting path assumes this is a 64-bit host");
-        // mips64 hosts know how to work with 64-bit and 32-bit EXEs using the mips64 register context.
-        return new RegisterContextLinux_mips64 (target_arch, NativeRegisterContextLinux_mips64::IsMSAAvailable());
-    }
-}
+static RegisterInfoInterface *
+CreateRegisterInfoInterface(const ArchSpec &target_arch) {
+  if (HostInfo::GetArchitecture().GetAddressByteSize() == 4) {
+    // 32-bit hosts run with a RegisterContextLinux_mips context.
+    return new RegisterContextLinux_mips(
+        target_arch, NativeRegisterContextLinux_mips64::IsMSAAvailable());
+  } else {
+    assert((HostInfo::GetArchitecture().GetAddressByteSize() == 8) &&
+           "Register setting path assumes this is a 64-bit host");
+    // mips64 hosts know how to work with 64-bit and 32-bit EXEs using the
+    // mips64 register context.
+    return new RegisterContextLinux_mips64(
+        target_arch, NativeRegisterContextLinux_mips64::IsMSAAvailable());
+  }
+}
+
+NativeRegisterContextLinux_mips64::NativeRegisterContextLinux_mips64(
+    const ArchSpec &target_arch, NativeThreadProtocol &native_thread,
+    uint32_t concrete_frame_idx)
+    : NativeRegisterContextLinux(native_thread, concrete_frame_idx,
+                                 CreateRegisterInfoInterface(target_arch)) {
+  switch (target_arch.GetMachine()) {
+  case llvm::Triple::mips:
+  case llvm::Triple::mipsel:
+    m_reg_info.num_registers = k_num_registers_mips;
+    m_reg_info.num_gpr_registers = k_num_gpr_registers_mips;
+    m_reg_info.num_fpr_registers = k_num_fpr_registers_mips;
+    m_reg_info.last_gpr = k_last_gpr_mips;
+    m_reg_info.first_fpr = k_first_fpr_mips;
+    m_reg_info.last_fpr = k_last_fpr_mips;
+    m_reg_info.first_msa = k_first_msa_mips;
+    m_reg_info.last_msa = k_last_msa_mips;
+    break;
+  case llvm::Triple::mips64:
+  case llvm::Triple::mips64el:
+    m_reg_info.num_registers = k_num_registers_mips64;
+    m_reg_info.num_gpr_registers = k_num_gpr_registers_mips64;
+    m_reg_info.num_fpr_registers = k_num_fpr_registers_mips64;
+    m_reg_info.last_gpr = k_last_gpr_mips64;
+    m_reg_info.first_fpr = k_first_fpr_mips64;
+    m_reg_info.last_fpr = k_last_fpr_mips64;
+    m_reg_info.first_msa = k_first_msa_mips64;
+    m_reg_info.last_msa = k_last_msa_mips64;
+    break;
+  default:
+    assert(false && "Unhandled target architecture.");
+    break;
+  }
+
+  // Initialize m_iovec to point to the buffer and buffer size
+  // using the conventions of Berkeley style UIO structures, as required
+  // by PTRACE extensions.
+  m_iovec.iov_base = &m_msa;
+  m_iovec.iov_len = sizeof(MSA_linux_mips);
+
+  // init h/w watchpoint addr map
+  for (int index = 0; index <= MAX_NUM_WP; index++)
+    hw_addr_map[index] = LLDB_INVALID_ADDRESS;
+
+  ::memset(&m_gpr, 0, sizeof(GPR_linux_mips));
+  ::memset(&m_fpr, 0, sizeof(FPR_linux_mips));
+  ::memset(&m_msa, 0, sizeof(MSA_linux_mips));
+}
+
+uint32_t NativeRegisterContextLinux_mips64::GetRegisterSetCount() const {
+  return k_num_register_sets;
+}
+
+lldb::addr_t NativeRegisterContextLinux_mips64::GetPCfromBreakpointLocation(
+    lldb::addr_t fail_value) {
+  Error error;
+  RegisterValue pc_value;
+  lldb::addr_t pc = fail_value;
+  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
+
+  if (log)
+    log->Printf("NativeRegisterContextLinux_mips64::%s Reading PC from "
+                "breakpoint location",
+                __FUNCTION__);
+
+  // PC register is at index 34 of the register array
+  const RegisterInfo *const pc_info_p = GetRegisterInfoAtIndex(gpr_pc_mips64);
+
+  error = ReadRegister(pc_info_p, pc_value);
+  if (error.Success()) {
+    pc = pc_value.GetAsUInt64();
+
+    // CAUSE register is at index 37 of the register array
+    const RegisterInfo *const cause_info_p =
+        GetRegisterInfoAtIndex(gpr_cause_mips64);
+    RegisterValue cause_value;
 
-NativeRegisterContextLinux_mips64::NativeRegisterContextLinux_mips64 (const ArchSpec& target_arch,
-                                                                      NativeThreadProtocol &native_thread, 
-                                                                      uint32_t concrete_frame_idx) :
-    NativeRegisterContextLinux (native_thread, concrete_frame_idx, CreateRegisterInfoInterface(target_arch))
-{
-    switch (target_arch.GetMachine ())
-    {
-        case llvm::Triple::mips:
-        case llvm::Triple::mipsel:
-            m_reg_info.num_registers        = k_num_registers_mips;
-            m_reg_info.num_gpr_registers    = k_num_gpr_registers_mips;
-            m_reg_info.num_fpr_registers    = k_num_fpr_registers_mips;
-            m_reg_info.last_gpr             = k_last_gpr_mips;
-            m_reg_info.first_fpr            = k_first_fpr_mips;
-            m_reg_info.last_fpr             = k_last_fpr_mips;
-            m_reg_info.first_msa            = k_first_msa_mips;
-            m_reg_info.last_msa             = k_last_msa_mips;
-            break;
-        case llvm::Triple::mips64:
-        case llvm::Triple::mips64el:
-            m_reg_info.num_registers        = k_num_registers_mips64;
-            m_reg_info.num_gpr_registers    = k_num_gpr_registers_mips64;
-            m_reg_info.num_fpr_registers    = k_num_fpr_registers_mips64;
-            m_reg_info.last_gpr             = k_last_gpr_mips64;
-            m_reg_info.first_fpr            = k_first_fpr_mips64;
-            m_reg_info.last_fpr             = k_last_fpr_mips64;
-            m_reg_info.first_msa            = k_first_msa_mips64;
-            m_reg_info.last_msa             = k_last_msa_mips64;
-            break;
-        default:
-            assert(false && "Unhandled target architecture.");
-            break;
-    }
+    ReadRegister(cause_info_p, cause_value);
 
-    // Initialize m_iovec to point to the buffer and buffer size
-    // using the conventions of Berkeley style UIO structures, as required
-    // by PTRACE extensions.
-    m_iovec.iov_base = &m_msa;
-    m_iovec.iov_len = sizeof(MSA_linux_mips);
-
-    // init h/w watchpoint addr map
-    for (int index = 0;index <= MAX_NUM_WP; index++)
-        hw_addr_map[index] = LLDB_INVALID_ADDRESS;
-
-    ::memset(&m_gpr, 0, sizeof(GPR_linux_mips));
-    ::memset(&m_fpr, 0, sizeof(FPR_linux_mips));
-    ::memset(&m_msa, 0, sizeof(MSA_linux_mips));
-}
-
-uint32_t
-NativeRegisterContextLinux_mips64::GetRegisterSetCount () const
-{
-    return k_num_register_sets;
-}
+    uint64_t cause = cause_value.GetAsUInt64();
 
-lldb::addr_t
-NativeRegisterContextLinux_mips64::GetPCfromBreakpointLocation (lldb::addr_t fail_value)
-{
-    Error error;
-    RegisterValue pc_value;
-    lldb::addr_t pc = fail_value;
-    Log *log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
-    
     if (log)
-        log->Printf ("NativeRegisterContextLinux_mips64::%s Reading PC from breakpoint location", __FUNCTION__);
-
-    // PC register is at index 34 of the register array
-    const RegisterInfo *const pc_info_p = GetRegisterInfoAtIndex (gpr_pc_mips64);
-        
-    error = ReadRegister (pc_info_p, pc_value);
-    if (error.Success ())
-    {
-        pc = pc_value.GetAsUInt64 ();
-        
-        // CAUSE register is at index 37 of the register array
-        const RegisterInfo *const cause_info_p = GetRegisterInfoAtIndex (gpr_cause_mips64);
-        RegisterValue cause_value;
-
-        ReadRegister (cause_info_p, cause_value);
-
-        uint64_t cause = cause_value.GetAsUInt64 ();
-        
-        if (log)
-            log->Printf ("NativeRegisterContextLinux_mips64::%s PC 0x%" PRIx64 " Cause 0x%" PRIx64, __FUNCTION__, pc, cause);
-
-        /*
-         * The breakpoint might be in a delay slot. In this case PC points
-         * to the delayed branch instruction rather then the instruction
-         * in the delay slot. If the CAUSE.BD flag is set then adjust the 
-         * PC based on the size of the branch instruction.
-        */
-        if ((cause & (1 << 31)) != 0)
-        {
-            lldb::addr_t branch_delay = 0;
-            branch_delay = 4;   // FIXME - Adjust according to size of branch instruction at PC
-            pc = pc + branch_delay;
-            pc_value.SetUInt64 (pc);
-            WriteRegister (pc_info_p, pc_value);
-            
-            if (log)
-                log->Printf ("NativeRegisterContextLinux_mips64::%s New PC 0x%" PRIx64, __FUNCTION__, pc);
-        }
+      log->Printf("NativeRegisterContextLinux_mips64::%s PC 0x%" PRIx64
+                  " Cause 0x%" PRIx64,
+                  __FUNCTION__, pc, cause);
+
+    /*
+     * The breakpoint might be in a delay slot. In this case PC points
+     * to the delayed branch instruction rather then the instruction
+     * in the delay slot. If the CAUSE.BD flag is set then adjust the
+     * PC based on the size of the branch instruction.
+    */
+    if ((cause & (1 << 31)) != 0) {
+      lldb::addr_t branch_delay = 0;
+      branch_delay =
+          4; // FIXME - Adjust according to size of branch instruction at PC
+      pc = pc + branch_delay;
+      pc_value.SetUInt64(pc);
+      WriteRegister(pc_info_p, pc_value);
+
+      if (log)
+        log->Printf("NativeRegisterContextLinux_mips64::%s New PC 0x%" PRIx64,
+                    __FUNCTION__, pc);
     }
+  }
 
-    return pc;
+  return pc;
 }
 
 const RegisterSet *
-NativeRegisterContextLinux_mips64::GetRegisterSet (uint32_t set_index) const
-{
-    if (set_index >= k_num_register_sets)
-        return nullptr;
-
-    switch (GetRegisterInfoInterface ().GetTargetArchitecture ().GetMachine ())
-    {
-        case llvm::Triple::mips64:
-        case llvm::Triple::mips64el:
-            return &g_reg_sets_mips64[set_index];
-        case llvm::Triple::mips:
-        case llvm::Triple::mipsel:
-            return &g_reg_sets_mips[set_index];
-        default:
-            assert (false && "Unhandled target architecture.");
-            return nullptr;
-    }
+NativeRegisterContextLinux_mips64::GetRegisterSet(uint32_t set_index) const {
+  if (set_index >= k_num_register_sets)
+    return nullptr;
 
+  switch (GetRegisterInfoInterface().GetTargetArchitecture().GetMachine()) {
+  case llvm::Triple::mips64:
+  case llvm::Triple::mips64el:
+    return &g_reg_sets_mips64[set_index];
+  case llvm::Triple::mips:
+  case llvm::Triple::mipsel:
+    return &g_reg_sets_mips[set_index];
+  default:
+    assert(false && "Unhandled target architecture.");
     return nullptr;
+  }
+
+  return nullptr;
 }
 
 lldb_private::Error
-NativeRegisterContextLinux_mips64::ReadRegister (const RegisterInfo *reg_info, RegisterValue &reg_value)
-{
-    Error error;
-
-    if (!reg_info)
-    {
-        error.SetErrorString ("reg_info NULL");
-        return error;
-    }
-
-    const uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];
-    if (reg == LLDB_INVALID_REGNUM)
-    {
-        // This is likely an internal register for lldb use only and should not be directly queried.
-        error.SetErrorStringWithFormat ("register \"%s\" is an internal-only lldb register, cannot read directly", reg_info->name);
-        return error;
-    }
-
-    if (IsMSA(reg) && !IsMSAAvailable())
-    {
-        error.SetErrorString ("MSA not available on this processor");
-        return error;
-    }
-
-    if (IsMSA(reg) || IsFPR(reg))
-    {
-        uint8_t *src;
-
-        error = ReadCP1();
-
-        if (!error.Success())
-        {
-            error.SetErrorString ("failed to read co-processor 1 register");
-            return error;
-        }
-
-        if (IsFPR(reg))
-        {
-            assert (reg_info->byte_offset < sizeof(UserArea));
-            src = (uint8_t *)&m_fpr + reg_info->byte_offset - (sizeof(m_gpr));
-        }
-        else
-        {
-            assert (reg_info->byte_offset < sizeof(UserArea));
-            src = (uint8_t *)&m_msa + reg_info->byte_offset - (sizeof(m_gpr) + sizeof(m_fpr));
-        }
-        switch (reg_info->byte_size)
-        {
-            case 4:
-                reg_value.SetUInt32(*(uint32_t *)src);
-                break;
-            case 8:
-                reg_value.SetUInt64(*(uint64_t *)src);
-                break;
-            case 16:
-                reg_value.SetBytes((const void *)src, 16, GetByteOrder());
-                break;
-            default:
-                assert(false && "Unhandled data size.");
-                error.SetErrorStringWithFormat ("unhandled byte size: %" PRIu32, reg_info->byte_size);
-                break;
-        }
-    }
-    else
-    {
-        error = ReadRegisterRaw(reg, reg_value);
-    }
+NativeRegisterContextLinux_mips64::ReadRegister(const RegisterInfo *reg_info,
+                                                RegisterValue &reg_value) {
+  Error error;
 
+  if (!reg_info) {
+    error.SetErrorString("reg_info NULL");
     return error;
-}
+  }
 
-lldb_private::Error
-NativeRegisterContextLinux_mips64::WriteRegister (const RegisterInfo *reg_info, const RegisterValue &reg_value)
-{
-    Error error;
+  const uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];
+  if (reg == LLDB_INVALID_REGNUM) {
+    // This is likely an internal register for lldb use only and should not be
+    // directly queried.
+    error.SetErrorStringWithFormat("register \"%s\" is an internal-only lldb "
+                                   "register, cannot read directly",
+                                   reg_info->name);
+    return error;
+  }
 
-    assert (reg_info && "reg_info is null");
+  if (IsMSA(reg) && !IsMSAAvailable()) {
+    error.SetErrorString("MSA not available on this processor");
+    return error;
+  }
 
-    const uint32_t reg_index = reg_info->kinds[lldb::eRegisterKindLLDB];
+  if (IsMSA(reg) || IsFPR(reg)) {
+    uint8_t *src;
 
-    if (reg_index == LLDB_INVALID_REGNUM)
-        return Error ("no lldb regnum for %s", reg_info && reg_info->name ? reg_info->name : "<unknown register>");
+    error = ReadCP1();
 
-    if (IsMSA(reg_index) && !IsMSAAvailable())
-    {
-        error.SetErrorString ("MSA not available on this processor");
-        return error;
-    }
-
-    if (IsFPR(reg_index) || IsMSA(reg_index))
-    {
-        uint8_t *dst;
-        uint64_t *src;
-
-        // Initialise the FP and MSA buffers by reading all co-processor 1 registers
-        ReadCP1();
-
-        if (IsFPR(reg_index))
-        {
-            assert (reg_info->byte_offset < sizeof(UserArea));
-            dst = (uint8_t *)&m_fpr + reg_info->byte_offset - (sizeof(m_gpr));
-        }
-        else
-        {
-            assert (reg_info->byte_offset < sizeof(UserArea));
-            dst = (uint8_t *)&m_msa + reg_info->byte_offset - (sizeof(m_gpr) + sizeof(m_fpr));
-        }
-        switch (reg_info->byte_size)
-        {
-            case 4:
-                *(uint32_t *)dst = reg_value.GetAsUInt32();
-                break;
-            case 8:
-                *(uint64_t *)dst = reg_value.GetAsUInt64();
-                break;
-            case 16:
-                src = (uint64_t *)reg_value.GetBytes();
-                *(uint64_t *)dst = *src;
-                *(uint64_t *)(dst + 8) = *(src + 1);
-                break;
-            default:
-                assert(false && "Unhandled data size.");
-                error.SetErrorStringWithFormat ("unhandled byte size: %" PRIu32, reg_info->byte_size);
-                break;
-        }
-        error = WriteCP1();
-        if (!error.Success())
-        {
-            error.SetErrorString ("failed to write co-processor 1 register");
-            return error;
-        }
-    }
-    else
-    {
-        error = WriteRegisterRaw(reg_index, reg_value);
-    }
+    if (!error.Success()) {
+      error.SetErrorString("failed to read co-processor 1 register");
+      return error;
+    }
+
+    if (IsFPR(reg)) {
+      assert(reg_info->byte_offset < sizeof(UserArea));
+      src = (uint8_t *)&m_fpr + reg_info->byte_offset - (sizeof(m_gpr));
+    } else {
+      assert(reg_info->byte_offset < sizeof(UserArea));
+      src = (uint8_t *)&m_msa + reg_info->byte_offset -
+            (sizeof(m_gpr) + sizeof(m_fpr));
+    }
+    switch (reg_info->byte_size) {
+    case 4:
+      reg_value.SetUInt32(*(uint32_t *)src);
+      break;
+    case 8:
+      reg_value.SetUInt64(*(uint64_t *)src);
+      break;
+    case 16:
+      reg_value.SetBytes((const void *)src, 16, GetByteOrder());
+      break;
+    default:
+      assert(false && "Unhandled data size.");
+      error.SetErrorStringWithFormat("unhandled byte size: %" PRIu32,
+                                     reg_info->byte_size);
+      break;
+    }
+  } else {
+    error = ReadRegisterRaw(reg, reg_value);
+  }
+
+  return error;
+}
+
+lldb_private::Error NativeRegisterContextLinux_mips64::WriteRegister(
+    const RegisterInfo *reg_info, const RegisterValue &reg_value) {
+  Error error;
+
+  assert(reg_info && "reg_info is null");
+
+  const uint32_t reg_index = reg_info->kinds[lldb::eRegisterKindLLDB];
+
+  if (reg_index == LLDB_INVALID_REGNUM)
+    return Error("no lldb regnum for %s", reg_info && reg_info->name
+                                              ? reg_info->name
+                                              : "<unknown register>");
 
+  if (IsMSA(reg_index) && !IsMSAAvailable()) {
+    error.SetErrorString("MSA not available on this processor");
     return error;
-}
+  }
 
-Error
-NativeRegisterContextLinux_mips64::ReadAllRegisterValues (lldb::DataBufferSP &data_sp)
-{
-    Error error;
-
-    data_sp.reset (new DataBufferHeap (REG_CONTEXT_SIZE, 0));
-    if (!data_sp)
-    {
-        error.SetErrorStringWithFormat ("failed to allocate DataBufferHeap instance of size %" PRIu64, REG_CONTEXT_SIZE);
-        return error;
+  if (IsFPR(reg_index) || IsMSA(reg_index)) {
+    uint8_t *dst;
+    uint64_t *src;
+
+    // Initialise the FP and MSA buffers by reading all co-processor 1 registers
+    ReadCP1();
+
+    if (IsFPR(reg_index)) {
+      assert(reg_info->byte_offset < sizeof(UserArea));
+      dst = (uint8_t *)&m_fpr + reg_info->byte_offset - (sizeof(m_gpr));
+    } else {
+      assert(reg_info->byte_offset < sizeof(UserArea));
+      dst = (uint8_t *)&m_msa + reg_info->byte_offset -
+            (sizeof(m_gpr) + sizeof(m_fpr));
+    }
+    switch (reg_info->byte_size) {
+    case 4:
+      *(uint32_t *)dst = reg_value.GetAsUInt32();
+      break;
+    case 8:
+      *(uint64_t *)dst = reg_value.GetAsUInt64();
+      break;
+    case 16:
+      src = (uint64_t *)reg_value.GetBytes();
+      *(uint64_t *)dst = *src;
+      *(uint64_t *)(dst + 8) = *(src + 1);
+      break;
+    default:
+      assert(false && "Unhandled data size.");
+      error.SetErrorStringWithFormat("unhandled byte size: %" PRIu32,
+                                     reg_info->byte_size);
+      break;
     }
+    error = WriteCP1();
+    if (!error.Success()) {
+      error.SetErrorString("failed to write co-processor 1 register");
+      return error;
+    }
+  } else {
+    error = WriteRegisterRaw(reg_index, reg_value);
+  }
+
+  return error;
+}
+
+Error NativeRegisterContextLinux_mips64::ReadAllRegisterValues(
+    lldb::DataBufferSP &data_sp) {
+  Error error;
+
+  data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0));
+  if (!data_sp) {
+    error.SetErrorStringWithFormat(
+        "failed to allocate DataBufferHeap instance of size %" PRIu64,
+        REG_CONTEXT_SIZE);
+    return error;
+  }
 
-    error = ReadGPR();
-    if (!error.Success())
-    {
-        error.SetErrorString ("ReadGPR() failed");
-        return error;
-    }
+  error = ReadGPR();
+  if (!error.Success()) {
+    error.SetErrorString("ReadGPR() failed");
+    return error;
+  }
 
-    error = ReadCP1();
-    if (!error.Success())
-    {
-        error.SetErrorString ("ReadCP1() failed");
-        return error;
-    }
+  error = ReadCP1();
+  if (!error.Success()) {
+    error.SetErrorString("ReadCP1() failed");
+    return error;
+  }
 
-    uint8_t *dst = data_sp->GetBytes ();
-    if (dst == nullptr)
-    {
-        error.SetErrorStringWithFormat ("DataBufferHeap instance of size %" PRIu64 " returned a null pointer", REG_CONTEXT_SIZE);
-        return error;
-    }
+  uint8_t *dst = data_sp->GetBytes();
+  if (dst == nullptr) {
+    error.SetErrorStringWithFormat("DataBufferHeap instance of size %" PRIu64
+                                   " returned a null pointer",
+                                   REG_CONTEXT_SIZE);
+    return error;
+  }
 
-    ::memcpy (dst, &m_gpr, GetRegisterInfoInterface ().GetGPRSize ());
-    dst += GetRegisterInfoInterface ().GetGPRSize ();
+  ::memcpy(dst, &m_gpr, GetRegisterInfoInterface().GetGPRSize());
+  dst += GetRegisterInfoInterface().GetGPRSize();
 
-    ::memcpy (dst, &m_fpr, GetFPRSize ());
-    dst += GetFPRSize ();
+  ::memcpy(dst, &m_fpr, GetFPRSize());
+  dst += GetFPRSize();
 
-    ::memcpy (dst, &m_msa, sizeof(MSA_linux_mips));
+  ::memcpy(dst, &m_msa, sizeof(MSA_linux_mips));
 
-    return error;
+  return error;
 }
 
-Error
-NativeRegisterContextLinux_mips64::WriteAllRegisterValues (const lldb::DataBufferSP &data_sp)
-{
-    Error error;
-
-    if (!data_sp)
-    {
-        error.SetErrorStringWithFormat ("NativeRegisterContextLinux_mips64::%s invalid data_sp provided", __FUNCTION__);
-        return error;
-    }
-
-    if (data_sp->GetByteSize () != REG_CONTEXT_SIZE)
-    {
-        error.SetErrorStringWithFormat ("NativeRegisterContextLinux_mips64::%s data_sp contained mismatched data size, expected %" PRIu64 ", actual %" PRIu64, __FUNCTION__, REG_CONTEXT_SIZE, data_sp->GetByteSize ());
-        return error;
-    }
+Error NativeRegisterContextLinux_mips64::WriteAllRegisterValues(
+    const lldb::DataBufferSP &data_sp) {
+  Error error;
 
+  if (!data_sp) {
+    error.SetErrorStringWithFormat(
+        "NativeRegisterContextLinux_mips64::%s invalid data_sp provided",
+        __FUNCTION__);
+    return error;
+  }
 
-    uint8_t *src = data_sp->GetBytes ();
-    if (src == nullptr)
-    {
-        error.SetErrorStringWithFormat ("NativeRegisterContextLinux_mips64::%s DataBuffer::GetBytes() returned a null pointer", __FUNCTION__);
-        return error;
-    }
+  if (data_sp->GetByteSize() != REG_CONTEXT_SIZE) {
+    error.SetErrorStringWithFormat(
+        "NativeRegisterContextLinux_mips64::%s data_sp contained mismatched "
+        "data size, expected %" PRIu64 ", actual %" PRIu64,
+        __FUNCTION__, REG_CONTEXT_SIZE, data_sp->GetByteSize());
+    return error;
+  }
 
-    ::memcpy (&m_gpr, src, GetRegisterInfoInterface ().GetGPRSize ());
-    src += GetRegisterInfoInterface ().GetGPRSize ();
+  uint8_t *src = data_sp->GetBytes();
+  if (src == nullptr) {
+    error.SetErrorStringWithFormat("NativeRegisterContextLinux_mips64::%s "
+                                   "DataBuffer::GetBytes() returned a null "
+                                   "pointer",
+                                   __FUNCTION__);
+    return error;
+  }
 
-    ::memcpy (&m_fpr, src, GetFPRSize ());
-    src += GetFPRSize ();
+  ::memcpy(&m_gpr, src, GetRegisterInfoInterface().GetGPRSize());
+  src += GetRegisterInfoInterface().GetGPRSize();
 
-    ::memcpy (&m_msa, src, sizeof(MSA_linux_mips));
+  ::memcpy(&m_fpr, src, GetFPRSize());
+  src += GetFPRSize();
 
-    error = WriteGPR();
-    if (!error.Success())
-    {
-        error.SetErrorStringWithFormat ("NativeRegisterContextLinux_mips64::%s WriteGPR() failed", __FUNCTION__);
-        return error;
-    }
-
-    error = WriteCP1();
-    if (!error.Success())
-    {
-        error.SetErrorStringWithFormat ("NativeRegisterContextLinux_mips64::%s WriteCP1() failed", __FUNCTION__);
-        return error;
-    }
+  ::memcpy(&m_msa, src, sizeof(MSA_linux_mips));
 
+  error = WriteGPR();
+  if (!error.Success()) {
+    error.SetErrorStringWithFormat(
+        "NativeRegisterContextLinux_mips64::%s WriteGPR() failed",
+        __FUNCTION__);
     return error;
-}
-
-Error
-NativeRegisterContextLinux_mips64::ReadCP1()
-{
-    Error error;
-
-    uint8_t *src, *dst;
-
-    lldb::ByteOrder byte_order = GetByteOrder();
-
-    uint32_t IsBigEndian = (byte_order == lldb::eByteOrderBig);
-
-    if (IsMSAAvailable())
-    {
-        error = NativeRegisterContextLinux::ReadRegisterSet(&m_iovec, sizeof(MSA_linux_mips), NT_MIPS_MSA);
-        src = (uint8_t *)&m_msa + (IsBigEndian * 8);
-        dst = (uint8_t *)&m_fpr;
-        for ( int i = 0; i < NUM_REGISTERS; i++)
-        {
-            // Copy fp values from msa buffer fetched via ptrace
-            *(uint64_t *) dst = *(uint64_t *) src;
-            src = src + 16;
-            dst = dst + 8;
-        }
-        m_fpr.fir = m_msa.fir;
-        m_fpr.fcsr = m_msa.fcsr;
-        m_fpr.config5 = m_msa.config5;
-    }
-    else
-    {
-        error = NativeRegisterContextLinux::ReadFPR();
-    }
-
-    // TODO: Add support for FRE
-    if (IsFR0())
-    {
-         src = (uint8_t *)&m_fpr + 4 + (IsBigEndian * 4);
-         dst = (uint8_t *)&m_fpr + 8 + (IsBigEndian * 4);
-         for (int i = 0; i < (NUM_REGISTERS / 2); i++)
-         {
-              // copy odd single from top of neighbouring even double
-              *(uint32_t *) dst = *(uint32_t *) src;
-              src = src + 16;
-              dst = dst + 16;
-         }
-    }
+  }
 
+  error = WriteCP1();
+  if (!error.Success()) {
+    error.SetErrorStringWithFormat(
+        "NativeRegisterContextLinux_mips64::%s WriteCP1() failed",
+        __FUNCTION__);
     return error;
+  }
+
+  return error;
 }
 
-Error
-NativeRegisterContextLinux_mips64::WriteCP1()
-{
-    Error error;
-
-    uint8_t *src, *dst;
-
-    lldb::ByteOrder byte_order = GetByteOrder();
-
-    uint32_t IsBigEndian = (byte_order == lldb::eByteOrderBig);
-
-    // TODO: Add support for FRE
-    if (IsFR0())
-    {
-        src = (uint8_t *)&m_fpr + 8 + (IsBigEndian * 4);
-        dst = (uint8_t *)&m_fpr + 4 + (IsBigEndian * 4);
-        for (int i = 0; i < (NUM_REGISTERS / 2); i++)
-        {
-             // copy odd single to top of neighbouring even double
-             *(uint32_t *) dst = *(uint32_t *) src;
-             src = src + 16;
-             dst = dst + 16;
+Error NativeRegisterContextLinux_mips64::ReadCP1() {
+  Error error;
+
+  uint8_t *src, *dst;
+
+  lldb::ByteOrder byte_order = GetByteOrder();
+
+  uint32_t IsBigEndian = (byte_order == lldb::eByteOrderBig);
+
+  if (IsMSAAvailable()) {
+    error = NativeRegisterContextLinux::ReadRegisterSet(
+        &m_iovec, sizeof(MSA_linux_mips), NT_MIPS_MSA);
+    src = (uint8_t *)&m_msa + (IsBigEndian * 8);
+    dst = (uint8_t *)&m_fpr;
+    for (int i = 0; i < NUM_REGISTERS; i++) {
+      // Copy fp values from msa buffer fetched via ptrace
+      *(uint64_t *)dst = *(uint64_t *)src;
+      src = src + 16;
+      dst = dst + 8;
+    }
+    m_fpr.fir = m_msa.fir;
+    m_fpr.fcsr = m_msa.fcsr;
+    m_fpr.config5 = m_msa.config5;
+  } else {
+    error = NativeRegisterContextLinux::ReadFPR();
+  }
+
+  // TODO: Add support for FRE
+  if (IsFR0()) {
+    src = (uint8_t *)&m_fpr + 4 + (IsBigEndian * 4);
+    dst = (uint8_t *)&m_fpr + 8 + (IsBigEndian * 4);
+    for (int i = 0; i < (NUM_REGISTERS / 2); i++) {
+      // copy odd single from top of neighbouring even double
+      *(uint32_t *)dst = *(uint32_t *)src;
+      src = src + 16;
+      dst = dst + 16;
+    }
+  }
+
+  return error;
+}
+
+Error NativeRegisterContextLinux_mips64::WriteCP1() {
+  Error error;
+
+  uint8_t *src, *dst;
+
+  lldb::ByteOrder byte_order = GetByteOrder();
+
+  uint32_t IsBigEndian = (byte_order == lldb::eByteOrderBig);
+
+  // TODO: Add support for FRE
+  if (IsFR0()) {
+    src = (uint8_t *)&m_fpr + 8 + (IsBigEndian * 4);
+    dst = (uint8_t *)&m_fpr + 4 + (IsBigEndian * 4);
+    for (int i = 0; i < (NUM_REGISTERS / 2); i++) {
+      // copy odd single to top of neighbouring even double
+      *(uint32_t *)dst = *(uint32_t *)src;
+      src = src + 16;
+      dst = dst + 16;
+    }
+  }
+
+  if (IsMSAAvailable()) {
+    dst = (uint8_t *)&m_msa + (IsBigEndian * 8);
+    src = (uint8_t *)&m_fpr;
+    for (int i = 0; i < NUM_REGISTERS; i++) {
+      // Copy fp values to msa buffer for ptrace
+      *(uint64_t *)dst = *(uint64_t *)src;
+      dst = dst + 16;
+      src = src + 8;
+    }
+    m_msa.fir = m_fpr.fir;
+    m_msa.fcsr = m_fpr.fcsr;
+    m_msa.config5 = m_fpr.config5;
+    error = NativeRegisterContextLinux::WriteRegisterSet(
+        &m_iovec, sizeof(MSA_linux_mips), NT_MIPS_MSA);
+  } else {
+    error = NativeRegisterContextLinux::WriteFPR();
+  }
+
+  return error;
+}
+
+bool NativeRegisterContextLinux_mips64::IsFR0() {
+  const RegisterInfo *const reg_info_p = GetRegisterInfoAtIndex(gpr_sr_mips64);
+
+  RegisterValue reg_value;
+  ReadRegister(reg_info_p, reg_value);
+
+  uint64_t value = reg_value.GetAsUInt64();
+
+  return (!(value & SR_FR));
+}
+
+bool NativeRegisterContextLinux_mips64::IsFRE() {
+  const RegisterInfo *const reg_info_p =
+      GetRegisterInfoAtIndex(gpr_config5_mips64);
+
+  RegisterValue reg_value;
+  ReadRegister(reg_info_p, reg_value);
+
+  uint64_t config5 = reg_value.GetAsUInt64();
+
+  return (config5 & CONFIG5_FRE);
+}
+
+bool NativeRegisterContextLinux_mips64::IsFPR(uint32_t reg_index) const {
+  return (m_reg_info.first_fpr <= reg_index &&
+          reg_index <= m_reg_info.last_fpr);
+}
+
+static uint32_t GetWatchHi(struct pt_watch_regs *regs, uint32_t index) {
+  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
+  if (regs->style == pt_watch_style_mips32)
+    return regs->mips32.watchhi[index];
+  else if (regs->style == pt_watch_style_mips64)
+    return regs->mips64.watchhi[index];
+  if (log)
+    log->Printf("Invalid watch register style");
+  return 0;
+}
+
+static void SetWatchHi(struct pt_watch_regs *regs, uint32_t index,
+                       uint16_t value) {
+  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
+  if (regs->style == pt_watch_style_mips32)
+    regs->mips32.watchhi[index] = value;
+  else if (regs->style == pt_watch_style_mips64)
+    regs->mips64.watchhi[index] = value;
+  if (log)
+    log->Printf("Invalid watch register style");
+  return;
+}
+
+static lldb::addr_t GetWatchLo(struct pt_watch_regs *regs, uint32_t index) {
+  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
+  if (regs->style == pt_watch_style_mips32)
+    return regs->mips32.watchlo[index];
+  else if (regs->style == pt_watch_style_mips64)
+    return regs->mips64.watchlo[index];
+  if (log)
+    log->Printf("Invalid watch register style");
+  return LLDB_INVALID_ADDRESS;
+}
+
+static void SetWatchLo(struct pt_watch_regs *regs, uint32_t index,
+                       uint64_t value) {
+  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
+  if (regs->style == pt_watch_style_mips32)
+    regs->mips32.watchlo[index] = (uint32_t)value;
+  else if (regs->style == pt_watch_style_mips64)
+    regs->mips64.watchlo[index] = value;
+  if (log)
+    log->Printf("Invalid watch register style");
+  return;
+}
+
+static uint32_t GetIRWMask(struct pt_watch_regs *regs, uint32_t index) {
+  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
+  if (regs->style == pt_watch_style_mips32)
+    return regs->mips32.watch_masks[index] & IRW;
+  else if (regs->style == pt_watch_style_mips64)
+    return regs->mips64.watch_masks[index] & IRW;
+  if (log)
+    log->Printf("Invalid watch register style");
+  return 0;
+}
+
+static uint32_t GetRegMask(struct pt_watch_regs *regs, uint32_t index) {
+  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
+  if (regs->style == pt_watch_style_mips32)
+    return regs->mips32.watch_masks[index] & ~IRW;
+  else if (regs->style == pt_watch_style_mips64)
+    return regs->mips64.watch_masks[index] & ~IRW;
+  if (log)
+    log->Printf("Invalid watch register style");
+  return 0;
+}
+
+static lldb::addr_t GetRangeMask(lldb::addr_t mask) {
+  lldb::addr_t mask_bit = 1;
+  while (mask_bit < mask) {
+    mask = mask | mask_bit;
+    mask_bit <<= 1;
+  }
+  return mask;
+}
+
+static int GetVacantWatchIndex(struct pt_watch_regs *regs, lldb::addr_t addr,
+                               uint32_t size, uint32_t irw,
+                               uint32_t num_valid) {
+  lldb::addr_t last_byte = addr + size - 1;
+  lldb::addr_t mask = GetRangeMask(addr ^ last_byte) | IRW;
+  lldb::addr_t base_addr = addr & ~mask;
+
+  // Check if this address is already watched by previous watch points.
+  lldb::addr_t lo;
+  uint16_t hi;
+  uint32_t vacant_watches = 0;
+  for (uint32_t index = 0; index < num_valid; index++) {
+    lo = GetWatchLo(regs, index);
+    if (lo != 0 && irw == ((uint32_t)lo & irw)) {
+      hi = GetWatchHi(regs, index) | IRW;
+      lo &= ~(lldb::addr_t)hi;
+      if (addr >= lo && last_byte <= (lo + hi))
+        return index;
+    } else
+      vacant_watches++;
+  }
+
+  // Now try to find a vacant index
+  if (vacant_watches > 0) {
+    vacant_watches = 0;
+    for (uint32_t index = 0; index < num_valid; index++) {
+      lo = GetWatchLo(regs, index);
+      if (lo == 0 && irw == (GetIRWMask(regs, index) & irw)) {
+        if (mask <= (GetRegMask(regs, index) | IRW)) {
+          // It fits, we can use it.
+          SetWatchLo(regs, index, base_addr | irw);
+          SetWatchHi(regs, index, mask & ~IRW);
+          return index;
+        } else {
+          // It doesn't fit, but has the proper IRW capabilities
+          vacant_watches++;
         }
+      }
     }
 
-    if (IsMSAAvailable())
-    {
-        dst = (uint8_t *)&m_msa + (IsBigEndian * 8);
-        src = (uint8_t *)&m_fpr;
-        for (int i = 0; i < NUM_REGISTERS; i++)
-        {
-            // Copy fp values to msa buffer for ptrace
-            *(uint64_t *) dst = *(uint64_t *) src;
-            dst = dst + 16;
-            src = src + 8;
+    if (vacant_watches > 1) {
+      // Split this watchpoint accross several registers
+      struct pt_watch_regs regs_copy;
+      regs_copy = *regs;
+      lldb::addr_t break_addr;
+      uint32_t segment_size;
+      for (uint32_t index = 0; index < num_valid; index++) {
+        lo = GetWatchLo(&regs_copy, index);
+        hi = GetRegMask(&regs_copy, index) | IRW;
+        if (lo == 0 && irw == (hi & irw)) {
+          lo = addr & ~(lldb::addr_t)hi;
+          break_addr = lo + hi + 1;
+          if (break_addr >= addr + size)
+            segment_size = size;
+          else
+            segment_size = break_addr - addr;
+          mask = GetRangeMask(addr ^ (addr + segment_size - 1));
+          SetWatchLo(&regs_copy, index, (addr & ~mask) | irw);
+          SetWatchHi(&regs_copy, index, mask & ~IRW);
+          if (break_addr >= addr + size) {
+            *regs = regs_copy;
+            return index;
+          }
+          size = addr + size - break_addr;
+          addr = break_addr;
         }
-        m_msa.fir = m_fpr.fir;
-        m_msa.fcsr = m_fpr.fcsr;
-        m_msa.config5 = m_fpr.config5;
-        error = NativeRegisterContextLinux::WriteRegisterSet(&m_iovec, sizeof(MSA_linux_mips), NT_MIPS_MSA);
-    }
-    else
-    {
-        error = NativeRegisterContextLinux::WriteFPR();
+      }
     }
-
-    return error;
+  }
+  return LLDB_INVALID_INDEX32;
 }
 
-bool
-NativeRegisterContextLinux_mips64::IsFR0()
-{
-    const RegisterInfo *const reg_info_p = GetRegisterInfoAtIndex (gpr_sr_mips64);
-
-    RegisterValue reg_value;
-    ReadRegister (reg_info_p, reg_value);
-
-    uint64_t value = reg_value.GetAsUInt64();
-
-    return (!(value & SR_FR));
+bool NativeRegisterContextLinux_mips64::IsMSA(uint32_t reg_index) const {
+  return (m_reg_info.first_msa <= reg_index &&
+          reg_index <= m_reg_info.last_msa);
 }
 
-bool
-NativeRegisterContextLinux_mips64::IsFRE()
-{
-    const RegisterInfo *const reg_info_p = GetRegisterInfoAtIndex (gpr_config5_mips64);
+bool NativeRegisterContextLinux_mips64::IsMSAAvailable() {
+  MSA_linux_mips msa_buf;
+  unsigned int regset = NT_MIPS_MSA;
 
-    RegisterValue reg_value;
-    ReadRegister (reg_info_p, reg_value);
+  Error error = NativeProcessLinux::PtraceWrapper(
+      PTRACE_GETREGSET, Host::GetCurrentProcessID(),
+      static_cast<void *>(&regset), &msa_buf, sizeof(MSA_linux_mips));
 
-    uint64_t config5 = reg_value.GetAsUInt64();
+  if (error.Success() && msa_buf.mir) {
+    return true;
+  }
 
-    return (config5 & CONFIG5_FRE);
+  return false;
 }
 
-bool
-NativeRegisterContextLinux_mips64::IsFPR(uint32_t reg_index) const
-{
-    return (m_reg_info.first_fpr <= reg_index && reg_index <= m_reg_info.last_fpr);
-}
+Error NativeRegisterContextLinux_mips64::IsWatchpointHit(uint32_t wp_index,
+                                                         bool &is_hit) {
+  if (wp_index >= NumSupportedHardwareWatchpoints())
+    return Error("Watchpoint index out of range");
 
-static uint32_t
-GetWatchHi (struct pt_watch_regs *regs, uint32_t index)
-{
-    Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
-    if (regs->style == pt_watch_style_mips32)
-        return regs->mips32.watchhi[index];
-    else if (regs->style == pt_watch_style_mips64)
-        return regs->mips64.watchhi[index];
-    if(log)
-        log->Printf("Invalid watch register style");
-    return 0;
-}
+  // reading the current state of watch regs
+  struct pt_watch_regs watch_readback;
+  Error error = DoReadWatchPointRegisterValue(
+      m_thread.GetID(), static_cast<void *>(&watch_readback));
 
-static void
-SetWatchHi (struct pt_watch_regs *regs, uint32_t index, uint16_t value)
-{
-    Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
-    if (regs->style == pt_watch_style_mips32)
-        regs->mips32.watchhi[index] = value;
-    else if (regs->style == pt_watch_style_mips64)
-        regs->mips64.watchhi[index] = value;
-    if(log)
-        log->Printf("Invalid watch register style");
-    return;
-}
-
-static lldb::addr_t
-GetWatchLo (struct pt_watch_regs *regs, uint32_t index)
-{
-    Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
-    if (regs->style == pt_watch_style_mips32)
-        return regs->mips32.watchlo[index];
-    else if (regs->style == pt_watch_style_mips64)
-        return regs->mips64.watchlo[index];
-    if(log)
-        log->Printf("Invalid watch register style");
-    return LLDB_INVALID_ADDRESS;
-}
+  if (GetWatchHi(&watch_readback, wp_index) & (IRW)) {
+    // clear hit flag in watchhi
+    SetWatchHi(&watch_readback, wp_index,
+               (GetWatchHi(&watch_readback, wp_index) & ~(IRW)));
+    DoWriteWatchPointRegisterValue(m_thread.GetID(),
+                                   static_cast<void *>(&watch_readback));
 
-static void
-SetWatchLo (struct pt_watch_regs *regs, uint32_t index, uint64_t value)
-{
-    Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
-    if (regs->style == pt_watch_style_mips32)
-        regs->mips32.watchlo[index] = (uint32_t) value;
-    else if (regs->style == pt_watch_style_mips64)
-        regs->mips64.watchlo[index] = value;
-    if(log)
-        log->Printf("Invalid watch register style");
-    return;
-}
-
-static uint32_t
-GetIRWMask (struct pt_watch_regs *regs, uint32_t index)
-{
-    Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
-    if (regs->style == pt_watch_style_mips32)
-        return regs->mips32.watch_masks[index] & IRW;
-    else if (regs->style == pt_watch_style_mips64)
-        return regs->mips64.watch_masks[index] & IRW;
-    if(log)
-        log->Printf("Invalid watch register style");
-    return 0;
-}
+    is_hit = true;
+    return error;
+  }
+  is_hit = false;
+  return error;
+}
+
+Error NativeRegisterContextLinux_mips64::GetWatchpointHitIndex(
+    uint32_t &wp_index, lldb::addr_t trap_addr) {
+  uint32_t num_hw_wps = NumSupportedHardwareWatchpoints();
+  for (wp_index = 0; wp_index < num_hw_wps; ++wp_index) {
+    bool is_hit;
+    Error error = IsWatchpointHit(wp_index, is_hit);
+    if (error.Fail()) {
+      wp_index = LLDB_INVALID_INDEX32;
+    } else if (is_hit) {
+      return error;
+    }
+  }
+  wp_index = LLDB_INVALID_INDEX32;
+  return Error();
+}
+
+Error NativeRegisterContextLinux_mips64::IsWatchpointVacant(uint32_t wp_index,
+                                                            bool &is_vacant) {
+  is_vacant = false;
+  return Error("MIPS TODO: "
+               "NativeRegisterContextLinux_mips64::IsWatchpointVacant not "
+               "implemented");
+}
+
+bool NativeRegisterContextLinux_mips64::ClearHardwareWatchpoint(
+    uint32_t wp_index) {
+  if (wp_index >= NumSupportedHardwareWatchpoints())
+    return false;
 
-static uint32_t
-GetRegMask (struct pt_watch_regs *regs, uint32_t index)
-{
-    Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
-    if (regs->style == pt_watch_style_mips32)
-        return regs->mips32.watch_masks[index] & ~IRW;
-    else if (regs->style == pt_watch_style_mips64)
-        return regs->mips64.watch_masks[index] & ~IRW;
-    if(log)
-        log->Printf("Invalid watch register style");
-    return 0;
+  struct pt_watch_regs regs;
+  // First reading the current state of watch regs
+  DoReadWatchPointRegisterValue(m_thread.GetID(), static_cast<void *>(&regs));
+
+  if (regs.style == pt_watch_style_mips32) {
+    regs.mips32.watchlo[wp_index] = default_watch_regs.mips32.watchlo[wp_index];
+    regs.mips32.watchhi[wp_index] = default_watch_regs.mips32.watchhi[wp_index];
+    regs.mips32.watch_masks[wp_index] =
+        default_watch_regs.mips32.watch_masks[wp_index];
+  } else // pt_watch_style_mips64
+  {
+    regs.mips64.watchlo[wp_index] = default_watch_regs.mips64.watchlo[wp_index];
+    regs.mips64.watchhi[wp_index] = default_watch_regs.mips64.watchhi[wp_index];
+    regs.mips64.watch_masks[wp_index] =
+        default_watch_regs.mips64.watch_masks[wp_index];
+  }
+
+  Error error = DoWriteWatchPointRegisterValue(m_thread.GetID(),
+                                               static_cast<void *>(&regs));
+  if (!error.Fail()) {
+    hw_addr_map[wp_index] = LLDB_INVALID_ADDRESS;
+    return true;
+  }
+  return false;
 }
 
-static lldb::addr_t
-GetRangeMask (lldb::addr_t mask)
-{
-    lldb::addr_t mask_bit = 1;
-    while (mask_bit < mask)
-    {
-        mask = mask | mask_bit;
-        mask_bit <<= 1;
-    }
-    return mask;
+Error NativeRegisterContextLinux_mips64::ClearAllHardwareWatchpoints() {
+  return DoWriteWatchPointRegisterValue(
+      m_thread.GetID(), static_cast<void *>(&default_watch_regs));
 }
 
-static int
-GetVacantWatchIndex (struct pt_watch_regs *regs, lldb::addr_t addr, uint32_t size, uint32_t irw, uint32_t num_valid)
-{
-    lldb::addr_t last_byte = addr + size - 1;
-    lldb::addr_t mask = GetRangeMask (addr ^ last_byte) | IRW;
-    lldb::addr_t base_addr = addr & ~mask;
-
-    // Check if this address is already watched by previous watch points.
-    lldb::addr_t lo;
-    uint16_t hi;
-    uint32_t vacant_watches = 0;
-    for (uint32_t index = 0; index < num_valid; index++)
-    {
-        lo = GetWatchLo (regs, index);
-        if (lo != 0 && irw == ((uint32_t) lo & irw))
-        {
-            hi = GetWatchHi (regs, index) | IRW;
-            lo &= ~(lldb::addr_t) hi;
-            if (addr >= lo && last_byte <= (lo + hi))
-                return index;
-        }
-        else
-            vacant_watches++;
-    }
-
-    // Now try to find a vacant index
-    if(vacant_watches > 0)
-    {
-        vacant_watches = 0;
-        for (uint32_t index = 0; index < num_valid; index++)
-        {
-            lo = GetWatchLo (regs, index);
-            if (lo == 0
-              && irw == (GetIRWMask (regs, index) & irw))
-            {
-                if (mask <= (GetRegMask (regs, index) | IRW))
-                {
-                    // It fits, we can use it. 
-                    SetWatchLo (regs, index, base_addr | irw);
-                    SetWatchHi (regs, index, mask & ~IRW);
-                    return index;
-                }
-                else
-                {
-                    // It doesn't fit, but has the proper IRW capabilities
-                    vacant_watches++;
-                }
-            }
-        }
-
-        if (vacant_watches > 1)
-        {
-            // Split this watchpoint accross several registers
-            struct pt_watch_regs regs_copy;
-            regs_copy = *regs;
-            lldb::addr_t break_addr;
-            uint32_t segment_size;
-            for (uint32_t index = 0; index < num_valid; index++)
-            {
-                lo = GetWatchLo (&regs_copy, index);
-                hi = GetRegMask (&regs_copy, index) | IRW;
-                if (lo == 0 && irw == (hi & irw))
-                {
-                    lo = addr & ~(lldb::addr_t) hi;
-                    break_addr = lo + hi + 1;
-                    if (break_addr >= addr + size)
-                        segment_size = size;
-                    else
-                        segment_size = break_addr - addr;
-                    mask = GetRangeMask (addr ^ (addr + segment_size - 1));
-                    SetWatchLo (&regs_copy, index, (addr & ~mask) | irw);
-                    SetWatchHi (&regs_copy, index, mask & ~IRW);
-                    if (break_addr >= addr + size)
-                    {
-                        *regs = regs_copy;
-                        return index;
-                    }
-                    size = addr + size - break_addr;
-                    addr = break_addr;
-                }
-            }
-        }
-    }
-    return LLDB_INVALID_INDEX32;
+Error NativeRegisterContextLinux_mips64::SetHardwareWatchpointWithIndex(
+    lldb::addr_t addr, size_t size, uint32_t watch_flags, uint32_t wp_index) {
+  Error error;
+  error.SetErrorString("MIPS TODO: "
+                       "NativeRegisterContextLinux_mips64::"
+                       "SetHardwareWatchpointWithIndex not implemented");
+  return error;
 }
 
-bool
-NativeRegisterContextLinux_mips64::IsMSA(uint32_t reg_index) const
-{
-    return (m_reg_info.first_msa <= reg_index && reg_index <= m_reg_info.last_msa);
-}
-
-bool
-NativeRegisterContextLinux_mips64::IsMSAAvailable()
-{
-    MSA_linux_mips msa_buf;
-    unsigned int regset = NT_MIPS_MSA;
-
-    Error error = NativeProcessLinux::PtraceWrapper(PTRACE_GETREGSET, Host::GetCurrentProcessID(), static_cast<void *>(&regset), &msa_buf, sizeof(MSA_linux_mips));
-
-    if (error.Success() && msa_buf.mir)
-    {
-        return true;
-    }
+uint32_t NativeRegisterContextLinux_mips64::SetHardwareWatchpoint(
+    lldb::addr_t addr, size_t size, uint32_t watch_flags) {
+  struct pt_watch_regs regs;
 
-    return false;
-}
+  // First reading the current state of watch regs
+  DoReadWatchPointRegisterValue(m_thread.GetID(), static_cast<void *>(&regs));
 
-Error
-NativeRegisterContextLinux_mips64::IsWatchpointHit (uint32_t wp_index, bool &is_hit)
-{
-    if (wp_index >= NumSupportedHardwareWatchpoints())
-        return Error("Watchpoint index out of range");
-
-    // reading the current state of watch regs
-    struct pt_watch_regs watch_readback;
-    Error error =  DoReadWatchPointRegisterValue(m_thread.GetID(), static_cast<void *>(&watch_readback));
-
-    if (GetWatchHi (&watch_readback, wp_index) & (IRW))
-    {
-        // clear hit flag in watchhi 
-        SetWatchHi (&watch_readback, wp_index, (GetWatchHi (&watch_readback, wp_index) & ~(IRW)));
-        DoWriteWatchPointRegisterValue(m_thread.GetID(), static_cast<void *>(&watch_readback));
-     
-        is_hit = true;
-        return error;
-    }
-    is_hit = false;
-    return error;
-}
+  // Try if a new watch point fits in this state
+  int index = GetVacantWatchIndex(&regs, addr, size, watch_flags,
+                                  NumSupportedHardwareWatchpoints());
 
-Error
-NativeRegisterContextLinux_mips64::GetWatchpointHitIndex(uint32_t &wp_index, lldb::addr_t trap_addr) {
-    uint32_t num_hw_wps = NumSupportedHardwareWatchpoints();
-    for (wp_index = 0; wp_index < num_hw_wps; ++wp_index)
-    {
-        bool is_hit;
-        Error error = IsWatchpointHit(wp_index, is_hit);
-        if (error.Fail()) {
-            wp_index = LLDB_INVALID_INDEX32;
-        } else if (is_hit) {
-            return error;
-        }
-    }
-    wp_index = LLDB_INVALID_INDEX32;
-    return Error();
-}
+  // New watchpoint doesn't fit
+  if (index == LLDB_INVALID_INDEX32)
+    return LLDB_INVALID_INDEX32;
 
-Error
-NativeRegisterContextLinux_mips64::IsWatchpointVacant (uint32_t wp_index, bool &is_vacant)
-{
-    is_vacant = false;
-    return Error("MIPS TODO: NativeRegisterContextLinux_mips64::IsWatchpointVacant not implemented");
-}
-
-bool
-NativeRegisterContextLinux_mips64::ClearHardwareWatchpoint(uint32_t wp_index)
-{
-    if (wp_index >= NumSupportedHardwareWatchpoints())
-        return false;
-
-    struct pt_watch_regs regs;
-    // First reading the current state of watch regs
-    DoReadWatchPointRegisterValue(m_thread.GetID(), static_cast<void*>(&regs));
-
-    if (regs.style == pt_watch_style_mips32)
-    {
-        regs.mips32.watchlo[wp_index] = default_watch_regs.mips32.watchlo[wp_index];
-        regs.mips32.watchhi[wp_index] = default_watch_regs.mips32.watchhi[wp_index];
-        regs.mips32.watch_masks[wp_index] = default_watch_regs.mips32.watch_masks[wp_index];
-    }
-    else // pt_watch_style_mips64
-    {
-        regs.mips64.watchlo[wp_index] = default_watch_regs.mips64.watchlo[wp_index];
-        regs.mips64.watchhi[wp_index] = default_watch_regs.mips64.watchhi[wp_index];
-        regs.mips64.watch_masks[wp_index] = default_watch_regs.mips64.watch_masks[wp_index];
-    }
+  // It fits, so we go ahead with updating the state of watch regs
+  DoWriteWatchPointRegisterValue(m_thread.GetID(), static_cast<void *>(&regs));
 
-    Error error = DoWriteWatchPointRegisterValue(m_thread.GetID(), static_cast<void *>(&regs));
-    if(!error.Fail())
-    {
-        hw_addr_map[wp_index] = LLDB_INVALID_ADDRESS;
-        return true;
-    }
-    return false;
+  // Storing exact address
+  hw_addr_map[index] = addr;
+  return index;
 }
 
-Error
-NativeRegisterContextLinux_mips64::ClearAllHardwareWatchpoints()
-{
-    return DoWriteWatchPointRegisterValue(m_thread.GetID(), static_cast<void *>(&default_watch_regs));
-}
+lldb::addr_t
+NativeRegisterContextLinux_mips64::GetWatchpointAddress(uint32_t wp_index) {
+  if (wp_index >= NumSupportedHardwareWatchpoints())
+    return LLDB_INVALID_ADDRESS;
 
-Error
-NativeRegisterContextLinux_mips64::SetHardwareWatchpointWithIndex (
-        lldb::addr_t addr, size_t size, uint32_t watch_flags, uint32_t wp_index) 
-{
-    Error error;
-    error.SetErrorString ("MIPS TODO: NativeRegisterContextLinux_mips64::SetHardwareWatchpointWithIndex not implemented");
-    return error;
+  return hw_addr_map[wp_index];
 }
 
-uint32_t
-NativeRegisterContextLinux_mips64::SetHardwareWatchpoint (
-        lldb::addr_t addr, size_t size, uint32_t watch_flags)
-{
-    struct pt_watch_regs regs;
-
-    // First reading the current state of watch regs
-    DoReadWatchPointRegisterValue(m_thread.GetID(), static_cast<void *>(&regs));
-
-    // Try if a new watch point fits in this state
-    int index = GetVacantWatchIndex (&regs, addr, size, watch_flags, NumSupportedHardwareWatchpoints());
-
-    // New watchpoint doesn't fit
-    if (index == LLDB_INVALID_INDEX32)
-    return LLDB_INVALID_INDEX32;
-
-
-    // It fits, so we go ahead with updating the state of watch regs 
-    DoWriteWatchPointRegisterValue(m_thread.GetID(), static_cast<void *>(&regs));
+struct EmulatorBaton {
+  lldb::addr_t m_watch_hit_addr;
+  NativeProcessLinux *m_process;
+  NativeRegisterContext *m_reg_context;
 
-    // Storing exact address  
-    hw_addr_map[index] = addr; 
-    return index;
-}
-
-lldb::addr_t
-NativeRegisterContextLinux_mips64::GetWatchpointAddress (uint32_t wp_index)
-{
-    if (wp_index >= NumSupportedHardwareWatchpoints())
-        return LLDB_INVALID_ADDRESS;
-
-    return hw_addr_map[wp_index];
-}
-
-struct EmulatorBaton
-{
-    lldb::addr_t m_watch_hit_addr;
-    NativeProcessLinux* m_process;
-    NativeRegisterContext* m_reg_context;
-
-    EmulatorBaton(NativeProcessLinux* process, NativeRegisterContext* reg_context) :
-            m_watch_hit_addr(LLDB_INVALID_ADDRESS), 
-            m_process(process),
-            m_reg_context(reg_context) 
-            {}
+  EmulatorBaton(NativeProcessLinux *process, NativeRegisterContext *reg_context)
+      : m_watch_hit_addr(LLDB_INVALID_ADDRESS), m_process(process),
+        m_reg_context(reg_context) {}
 };
 
-static size_t
-ReadMemoryCallback (EmulateInstruction *instruction, void *baton,
-                    const EmulateInstruction::Context &context, lldb::addr_t addr, 
-                    void *dst, size_t length)
-{
-    size_t bytes_read;
-    EmulatorBaton* emulator_baton = static_cast<EmulatorBaton*>(baton);
-    emulator_baton->m_process->ReadMemory(addr, dst, length, bytes_read);
-    return bytes_read;
-}
-
-static size_t
-WriteMemoryCallback (EmulateInstruction *instruction, void *baton,
-                     const EmulateInstruction::Context &context, 
-                     lldb::addr_t addr, const void *dst, size_t length)
-{
-    return length;
-}
-
-static bool
-ReadRegisterCallback (EmulateInstruction *instruction, void *baton,
-                      const RegisterInfo *reg_info, RegisterValue &reg_value)
-{
-    EmulatorBaton* emulator_baton = static_cast<EmulatorBaton*>(baton);
-
-    const RegisterInfo* full_reg_info = emulator_baton->m_reg_context->GetRegisterInfo(
-            lldb::eRegisterKindDWARF, reg_info->kinds[lldb::eRegisterKindDWARF]);
-
-    Error error = emulator_baton->m_reg_context->ReadRegister(full_reg_info, reg_value);
-    if (error.Success())
-        return true;
+static size_t ReadMemoryCallback(EmulateInstruction *instruction, void *baton,
+                                 const EmulateInstruction::Context &context,
+                                 lldb::addr_t addr, void *dst, size_t length) {
+  size_t bytes_read;
+  EmulatorBaton *emulator_baton = static_cast<EmulatorBaton *>(baton);
+  emulator_baton->m_process->ReadMemory(addr, dst, length, bytes_read);
+  return bytes_read;
+}
+
+static size_t WriteMemoryCallback(EmulateInstruction *instruction, void *baton,
+                                  const EmulateInstruction::Context &context,
+                                  lldb::addr_t addr, const void *dst,
+                                  size_t length) {
+  return length;
+}
+
+static bool ReadRegisterCallback(EmulateInstruction *instruction, void *baton,
+                                 const RegisterInfo *reg_info,
+                                 RegisterValue &reg_value) {
+  EmulatorBaton *emulator_baton = static_cast<EmulatorBaton *>(baton);
+
+  const RegisterInfo *full_reg_info =
+      emulator_baton->m_reg_context->GetRegisterInfo(
+          lldb::eRegisterKindDWARF, reg_info->kinds[lldb::eRegisterKindDWARF]);
+
+  Error error =
+      emulator_baton->m_reg_context->ReadRegister(full_reg_info, reg_value);
+  if (error.Success())
+    return true;
 
-    return false;
+  return false;
 }
 
-static bool
-WriteRegisterCallback (EmulateInstruction *instruction, void *baton,
-                       const EmulateInstruction::Context &context,
-                       const RegisterInfo *reg_info, const RegisterValue &reg_value)
-{
-    if (reg_info->kinds[lldb::eRegisterKindDWARF] == dwarf_bad_mips64)
-    {
-        EmulatorBaton* emulator_baton = static_cast<EmulatorBaton*>(baton);
-        emulator_baton->m_watch_hit_addr = reg_value.GetAsUInt64 ();
-    }
+static bool WriteRegisterCallback(EmulateInstruction *instruction, void *baton,
+                                  const EmulateInstruction::Context &context,
+                                  const RegisterInfo *reg_info,
+                                  const RegisterValue &reg_value) {
+  if (reg_info->kinds[lldb::eRegisterKindDWARF] == dwarf_bad_mips64) {
+    EmulatorBaton *emulator_baton = static_cast<EmulatorBaton *>(baton);
+    emulator_baton->m_watch_hit_addr = reg_value.GetAsUInt64();
+  }
 
-    return true;
+  return true;
 }
 
 /*
@@ -1319,123 +1077,121 @@ WriteRegisterCallback (EmulateInstructio
  * it can decide to stop or continue the thread.
 */
 lldb::addr_t
-NativeRegisterContextLinux_mips64::GetWatchpointHitAddress (uint32_t wp_index)
-{
-    if (wp_index >= NumSupportedHardwareWatchpoints())
-        return LLDB_INVALID_ADDRESS;
+NativeRegisterContextLinux_mips64::GetWatchpointHitAddress(uint32_t wp_index) {
+  if (wp_index >= NumSupportedHardwareWatchpoints())
+    return LLDB_INVALID_ADDRESS;
 
-    lldb_private::ArchSpec arch;
-    arch = GetRegisterInfoInterface().GetTargetArchitecture();
-    std::unique_ptr<EmulateInstruction> emulator_ap(
-        EmulateInstruction::FindPlugin(arch, lldb_private::eInstructionTypeAny, nullptr));
-
-    if (emulator_ap == nullptr)
-        return LLDB_INVALID_ADDRESS;
-    
-    EmulatorBaton baton(static_cast<NativeProcessLinux*>(m_thread.GetProcess().get()), this);
-    emulator_ap->SetBaton (&baton);
-    emulator_ap->SetReadMemCallback (&ReadMemoryCallback);
-    emulator_ap->SetReadRegCallback (&ReadRegisterCallback);
-    emulator_ap->SetWriteMemCallback (&WriteMemoryCallback);
-    emulator_ap->SetWriteRegCallback (&WriteRegisterCallback);
+  lldb_private::ArchSpec arch;
+  arch = GetRegisterInfoInterface().GetTargetArchitecture();
+  std::unique_ptr<EmulateInstruction> emulator_ap(
+      EmulateInstruction::FindPlugin(arch, lldb_private::eInstructionTypeAny,
+                                     nullptr));
 
-    if (!emulator_ap->ReadInstruction())
-        return LLDB_INVALID_ADDRESS;
+  if (emulator_ap == nullptr)
+    return LLDB_INVALID_ADDRESS;
 
-    if (emulator_ap->EvaluateInstruction(lldb::eEmulateInstructionOptionNone))
-        return baton.m_watch_hit_addr;
+  EmulatorBaton baton(
+      static_cast<NativeProcessLinux *>(m_thread.GetProcess().get()), this);
+  emulator_ap->SetBaton(&baton);
+  emulator_ap->SetReadMemCallback(&ReadMemoryCallback);
+  emulator_ap->SetReadRegCallback(&ReadRegisterCallback);
+  emulator_ap->SetWriteMemCallback(&WriteMemoryCallback);
+  emulator_ap->SetWriteRegCallback(&WriteRegisterCallback);
 
+  if (!emulator_ap->ReadInstruction())
     return LLDB_INVALID_ADDRESS;
-}
 
-uint32_t
-NativeRegisterContextLinux_mips64::NumSupportedHardwareWatchpoints ()
-{
-    Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
-    struct pt_watch_regs regs;
-    static int num_valid = 0;
-    if (!num_valid)
-    {
-        DoReadWatchPointRegisterValue(m_thread.GetID(), static_cast<void *>(&regs));
-        default_watch_regs = regs; // Keeping default watch regs values for future use
-        switch (regs.style)
-        {
-            case pt_watch_style_mips32:
-                num_valid = regs.mips32.num_valid; // Using num_valid as cache
-                return num_valid;
-            case pt_watch_style_mips64:
-                num_valid = regs.mips64.num_valid;
-                return num_valid;
-            default:
-                if(log)
-                    log->Printf("NativeRegisterContextLinux_mips64::%s Error: Unrecognized watch register style", __FUNCTION__);
-        }
-        return 0;
-    }
-    return num_valid;
-}
-Error
-NativeRegisterContextLinux_mips64::DoReadRegisterValue(uint32_t offset,
-                                                       const char* reg_name,
-                                                       uint32_t size,
-                                                       RegisterValue &value)
-{
-    GPR_linux_mips regs;
-    ::memset(&regs, 0, sizeof(GPR_linux_mips));
-
-    // Clear all bits in RegisterValue before writing actual value read from ptrace to avoid garbage value in 32-bit MSB 
-    value.SetBytes((void *)(((unsigned char *)&regs) + offset), 8, GetByteOrder());
-    Error error = NativeProcessLinux::PtraceWrapper(PTRACE_GETREGS, m_thread.GetID(), NULL, &regs, sizeof regs);
-    if (error.Success())
-    {
-        lldb_private::ArchSpec arch;
-        if (m_thread.GetProcess()->GetArchitecture(arch))
-        {
-            void* target_address = ((uint8_t*)&regs) + offset + 4 * (arch.GetMachine() == llvm::Triple::mips);
-            uint32_t target_size;
-            if ((::strcmp(reg_name, "sr") == 0) || (::strcmp(reg_name, "cause") == 0) || (::strcmp(reg_name, "config5") == 0))
-                target_size = 4;
-            else
-                target_size = arch.GetFlags() & lldb_private::ArchSpec::eMIPSABI_O32 ? 4 : 8;
-            value.SetBytes(target_address, target_size, arch.GetByteOrder());
-        }
-        else
-            error.SetErrorString("failed to get architecture");
-    }
-    return error;
-}
+  if (emulator_ap->EvaluateInstruction(lldb::eEmulateInstructionOptionNone))
+    return baton.m_watch_hit_addr;
 
-Error
-NativeRegisterContextLinux_mips64::DoWriteRegisterValue(uint32_t offset,
-                                                        const char* reg_name,
-                                                        const RegisterValue &value)
-{
-    GPR_linux_mips regs;
-    Error error = NativeProcessLinux::PtraceWrapper(PTRACE_GETREGS, m_thread.GetID(), NULL, &regs, sizeof regs);
-    if (error.Success())
-    {
-        lldb_private::ArchSpec arch;
-        if (m_thread.GetProcess()->GetArchitecture(arch))
-        {
-            ::memcpy((void *)(((unsigned char *)(&regs)) + offset), value.GetBytes(), arch.GetFlags() & lldb_private::ArchSpec::eMIPSABI_O32 ? 4 : 8);
-            error = NativeProcessLinux::PtraceWrapper(PTRACE_SETREGS, m_thread.GetID(), NULL, &regs, sizeof regs);
-        }
-        else
-            error.SetErrorString("failed to get architecture");
-    }
-    return error;
+  return LLDB_INVALID_ADDRESS;
 }
 
-Error
-NativeRegisterContextLinux_mips64::DoReadWatchPointRegisterValue(lldb::tid_t tid, void* watch_readback)
-{
-    return NativeProcessLinux::PtraceWrapper( PTRACE_GET_WATCH_REGS, m_thread.GetID(), watch_readback);
+uint32_t NativeRegisterContextLinux_mips64::NumSupportedHardwareWatchpoints() {
+  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
+  struct pt_watch_regs regs;
+  static int num_valid = 0;
+  if (!num_valid) {
+    DoReadWatchPointRegisterValue(m_thread.GetID(), static_cast<void *>(&regs));
+    default_watch_regs =
+        regs; // Keeping default watch regs values for future use
+    switch (regs.style) {
+    case pt_watch_style_mips32:
+      num_valid = regs.mips32.num_valid; // Using num_valid as cache
+      return num_valid;
+    case pt_watch_style_mips64:
+      num_valid = regs.mips64.num_valid;
+      return num_valid;
+    default:
+      if (log)
+        log->Printf("NativeRegisterContextLinux_mips64::%s Error: Unrecognized "
+                    "watch register style",
+                    __FUNCTION__);
+    }
+    return 0;
+  }
+  return num_valid;
 }
-
-Error
-NativeRegisterContextLinux_mips64::DoWriteWatchPointRegisterValue(lldb::tid_t tid, void* watch_reg_value)
-{
-    return NativeProcessLinux::PtraceWrapper(PTRACE_SET_WATCH_REGS, m_thread.GetID(), watch_reg_value);
+Error NativeRegisterContextLinux_mips64::DoReadRegisterValue(
+    uint32_t offset, const char *reg_name, uint32_t size,
+    RegisterValue &value) {
+  GPR_linux_mips regs;
+  ::memset(&regs, 0, sizeof(GPR_linux_mips));
+
+  // Clear all bits in RegisterValue before writing actual value read from
+  // ptrace to avoid garbage value in 32-bit MSB
+  value.SetBytes((void *)(((unsigned char *)&regs) + offset), 8,
+                 GetByteOrder());
+  Error error = NativeProcessLinux::PtraceWrapper(
+      PTRACE_GETREGS, m_thread.GetID(), NULL, &regs, sizeof regs);
+  if (error.Success()) {
+    lldb_private::ArchSpec arch;
+    if (m_thread.GetProcess()->GetArchitecture(arch)) {
+      void *target_address = ((uint8_t *)&regs) + offset +
+                             4 * (arch.GetMachine() == llvm::Triple::mips);
+      uint32_t target_size;
+      if ((::strcmp(reg_name, "sr") == 0) ||
+          (::strcmp(reg_name, "cause") == 0) ||
+          (::strcmp(reg_name, "config5") == 0))
+        target_size = 4;
+      else
+        target_size =
+            arch.GetFlags() & lldb_private::ArchSpec::eMIPSABI_O32 ? 4 : 8;
+      value.SetBytes(target_address, target_size, arch.GetByteOrder());
+    } else
+      error.SetErrorString("failed to get architecture");
+  }
+  return error;
+}
+
+Error NativeRegisterContextLinux_mips64::DoWriteRegisterValue(
+    uint32_t offset, const char *reg_name, const RegisterValue &value) {
+  GPR_linux_mips regs;
+  Error error = NativeProcessLinux::PtraceWrapper(
+      PTRACE_GETREGS, m_thread.GetID(), NULL, &regs, sizeof regs);
+  if (error.Success()) {
+    lldb_private::ArchSpec arch;
+    if (m_thread.GetProcess()->GetArchitecture(arch)) {
+      ::memcpy((void *)(((unsigned char *)(&regs)) + offset), value.GetBytes(),
+               arch.GetFlags() & lldb_private::ArchSpec::eMIPSABI_O32 ? 4 : 8);
+      error = NativeProcessLinux::PtraceWrapper(
+          PTRACE_SETREGS, m_thread.GetID(), NULL, &regs, sizeof regs);
+    } else
+      error.SetErrorString("failed to get architecture");
+  }
+  return error;
+}
+
+Error NativeRegisterContextLinux_mips64::DoReadWatchPointRegisterValue(
+    lldb::tid_t tid, void *watch_readback) {
+  return NativeProcessLinux::PtraceWrapper(PTRACE_GET_WATCH_REGS,
+                                           m_thread.GetID(), watch_readback);
+}
+
+Error NativeRegisterContextLinux_mips64::DoWriteWatchPointRegisterValue(
+    lldb::tid_t tid, void *watch_reg_value) {
+  return NativeProcessLinux::PtraceWrapper(PTRACE_SET_WATCH_REGS,
+                                           m_thread.GetID(), watch_reg_value);
 }
 
 #endif // defined (__mips__)

Modified: lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.h (original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.h Tue Sep  6 15:57:50 2016
@@ -7,7 +7,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#if defined (__mips__)
+#if defined(__mips__)
 
 #ifndef lldb_NativeRegisterContextLinux_mips64_h
 #define lldb_NativeRegisterContextLinux_mips64_h
@@ -21,143 +21,111 @@
 namespace lldb_private {
 namespace process_linux {
 
-    class NativeProcessLinux;
+class NativeProcessLinux;
 
-    class NativeRegisterContextLinux_mips64 : public NativeRegisterContextLinux
-    {
-    public:
-        NativeRegisterContextLinux_mips64 (const ArchSpec& target_arch,
-                                           NativeThreadProtocol &native_thread, 
-                                           uint32_t concrete_frame_idx);
+class NativeRegisterContextLinux_mips64 : public NativeRegisterContextLinux {
+public:
+  NativeRegisterContextLinux_mips64(const ArchSpec &target_arch,
+                                    NativeThreadProtocol &native_thread,
+                                    uint32_t concrete_frame_idx);
 
-        uint32_t
-        GetRegisterSetCount () const override;
+  uint32_t GetRegisterSetCount() const override;
 
-        lldb::addr_t
-        GetPCfromBreakpointLocation (lldb::addr_t fail_value = LLDB_INVALID_ADDRESS) override;
+  lldb::addr_t GetPCfromBreakpointLocation(
+      lldb::addr_t fail_value = LLDB_INVALID_ADDRESS) override;
 
-        lldb::addr_t
-        GetWatchpointHitAddress (uint32_t wp_index) override;
+  lldb::addr_t GetWatchpointHitAddress(uint32_t wp_index) override;
 
-        const RegisterSet *
-        GetRegisterSet (uint32_t set_index) const override;
+  const RegisterSet *GetRegisterSet(uint32_t set_index) const override;
 
-        Error
-        ReadRegister (const RegisterInfo *reg_info, RegisterValue &reg_value) override;
+  Error ReadRegister(const RegisterInfo *reg_info,
+                     RegisterValue &reg_value) override;
 
-        Error
-        WriteRegister (const RegisterInfo *reg_info, const RegisterValue &reg_value) override;
+  Error WriteRegister(const RegisterInfo *reg_info,
+                      const RegisterValue &reg_value) override;
 
-        Error
-        ReadAllRegisterValues (lldb::DataBufferSP &data_sp) override;
+  Error ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
 
-        Error
-        WriteAllRegisterValues (const lldb::DataBufferSP &data_sp) override;
+  Error WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
 
-        Error
-        ReadCP1();
+  Error ReadCP1();
 
-        Error
-        WriteCP1();
+  Error WriteCP1();
 
-        Error
-        IsWatchpointHit (uint32_t wp_index, bool &is_hit) override;
+  Error IsWatchpointHit(uint32_t wp_index, bool &is_hit) override;
 
-        Error
-        GetWatchpointHitIndex(uint32_t &wp_index, lldb::addr_t trap_addr) override;
+  Error GetWatchpointHitIndex(uint32_t &wp_index,
+                              lldb::addr_t trap_addr) override;
 
-        Error
-        IsWatchpointVacant (uint32_t wp_index, bool &is_vacant) override;
+  Error IsWatchpointVacant(uint32_t wp_index, bool &is_vacant) override;
 
-        bool
-        ClearHardwareWatchpoint (uint32_t wp_index) override;
+  bool ClearHardwareWatchpoint(uint32_t wp_index) override;
 
-        Error
-        ClearAllHardwareWatchpoints () override;
+  Error ClearAllHardwareWatchpoints() override;
 
-        Error
-        SetHardwareWatchpointWithIndex (lldb::addr_t addr, size_t size,
-                uint32_t watch_flags, uint32_t wp_index);
+  Error SetHardwareWatchpointWithIndex(lldb::addr_t addr, size_t size,
+                                       uint32_t watch_flags, uint32_t wp_index);
 
-        uint32_t
-        SetHardwareWatchpoint (lldb::addr_t addr, size_t size,
-                uint32_t watch_flags) override;
+  uint32_t SetHardwareWatchpoint(lldb::addr_t addr, size_t size,
+                                 uint32_t watch_flags) override;
 
-        lldb::addr_t
-        GetWatchpointAddress (uint32_t wp_index) override;
+  lldb::addr_t GetWatchpointAddress(uint32_t wp_index) override;
 
-        uint32_t
-        NumSupportedHardwareWatchpoints () override;
+  uint32_t NumSupportedHardwareWatchpoints() override;
 
-        static bool
-        IsMSAAvailable();
+  static bool IsMSAAvailable();
 
-    protected:
-        Error
-        DoReadRegisterValue(uint32_t offset,
-                            const char* reg_name,
-                            uint32_t size,
-                            RegisterValue &value) override;
+protected:
+  Error DoReadRegisterValue(uint32_t offset, const char *reg_name,
+                            uint32_t size, RegisterValue &value) override;
 
-        Error
-        DoWriteRegisterValue(uint32_t offset,
-                             const char* reg_name,
+  Error DoWriteRegisterValue(uint32_t offset, const char *reg_name,
                              const RegisterValue &value) override;
 
-        Error
-        DoReadWatchPointRegisterValue(lldb::tid_t tid, void* watch_readback);
+  Error DoReadWatchPointRegisterValue(lldb::tid_t tid, void *watch_readback);
 
-        Error
-        DoWriteWatchPointRegisterValue(lldb::tid_t tid, void* watch_readback);
+  Error DoWriteWatchPointRegisterValue(lldb::tid_t tid, void *watch_readback);
 
-        bool
-        IsFR0();
+  bool IsFR0();
 
-        bool
-        IsFRE();
+  bool IsFRE();
 
-        bool
-        IsFPR(uint32_t reg_index) const;
+  bool IsFPR(uint32_t reg_index) const;
 
-        bool
-        IsMSA(uint32_t reg_index) const;
+  bool IsMSA(uint32_t reg_index) const;
 
-        void*
-        GetGPRBuffer() override { return &m_gpr; }
+  void *GetGPRBuffer() override { return &m_gpr; }
 
-        void*
-        GetFPRBuffer() override { return &m_fpr; }
+  void *GetFPRBuffer() override { return &m_fpr; }
 
-        size_t
-        GetFPRSize() override { return sizeof(FPR_linux_mips); }
+  size_t GetFPRSize() override { return sizeof(FPR_linux_mips); }
 
-    private:
-        // Info about register ranges.
-        struct RegInfo
-        {
-            uint32_t num_registers;
-            uint32_t num_gpr_registers;
-            uint32_t num_fpr_registers;
+private:
+  // Info about register ranges.
+  struct RegInfo {
+    uint32_t num_registers;
+    uint32_t num_gpr_registers;
+    uint32_t num_fpr_registers;
 
-            uint32_t last_gpr;
-            uint32_t first_fpr;
-            uint32_t last_fpr;
-            uint32_t first_msa;
-            uint32_t last_msa;
-        };
+    uint32_t last_gpr;
+    uint32_t first_fpr;
+    uint32_t last_fpr;
+    uint32_t first_msa;
+    uint32_t last_msa;
+  };
 
-        RegInfo m_reg_info;
+  RegInfo m_reg_info;
 
-        GPR_linux_mips m_gpr;
+  GPR_linux_mips m_gpr;
 
-        FPR_linux_mips m_fpr;
+  FPR_linux_mips m_fpr;
 
-        MSA_linux_mips m_msa;
+  MSA_linux_mips m_msa;
 
-        lldb::addr_t hw_addr_map[MAX_NUM_WP];
+  lldb::addr_t hw_addr_map[MAX_NUM_WP];
 
-        IOVEC_mips m_iovec;
-    };
+  IOVEC_mips m_iovec;
+};
 
 } // namespace process_linux
 } // namespace lldb_private

Modified: lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp Tue Sep  6 15:57:50 2016
@@ -30,99 +30,62 @@ using namespace lldb_private::process_li
 // Private namespace.
 // ----------------------------------------------------------------------------
 
-namespace
-{
-    // s390x 64-bit general purpose registers.
-    static const uint32_t g_gpr_regnums_s390x[] =
-    {
-        lldb_r0_s390x,
-        lldb_r1_s390x,
-        lldb_r2_s390x,
-        lldb_r3_s390x,
-        lldb_r4_s390x,
-        lldb_r5_s390x,
-        lldb_r6_s390x,
-        lldb_r7_s390x,
-        lldb_r8_s390x,
-        lldb_r9_s390x,
-        lldb_r10_s390x,
-        lldb_r11_s390x,
-        lldb_r12_s390x,
-        lldb_r13_s390x,
-        lldb_r14_s390x,
-        lldb_r15_s390x,
-        lldb_acr0_s390x,
-        lldb_acr1_s390x,
-        lldb_acr2_s390x,
-        lldb_acr3_s390x,
-        lldb_acr4_s390x,
-        lldb_acr5_s390x,
-        lldb_acr6_s390x,
-        lldb_acr7_s390x,
-        lldb_acr8_s390x,
-        lldb_acr9_s390x,
-        lldb_acr10_s390x,
-        lldb_acr11_s390x,
-        lldb_acr12_s390x,
-        lldb_acr13_s390x,
-        lldb_acr14_s390x,
-        lldb_acr15_s390x,
-        lldb_pswm_s390x,
-        lldb_pswa_s390x,
-        LLDB_INVALID_REGNUM // register sets need to end with this flag
-    };
-    static_assert((sizeof(g_gpr_regnums_s390x) / sizeof(g_gpr_regnums_s390x[0])) - 1 == k_num_gpr_registers_s390x,
-                  "g_gpr_regnums_s390x has wrong number of register infos");
-
-    // s390x 64-bit floating point registers.
-    static const uint32_t g_fpu_regnums_s390x[] =
-    {
-        lldb_f0_s390x,
-        lldb_f1_s390x,
-        lldb_f2_s390x,
-        lldb_f3_s390x,
-        lldb_f4_s390x,
-        lldb_f5_s390x,
-        lldb_f6_s390x,
-        lldb_f7_s390x,
-        lldb_f8_s390x,
-        lldb_f9_s390x,
-        lldb_f10_s390x,
-        lldb_f11_s390x,
-        lldb_f12_s390x,
-        lldb_f13_s390x,
-        lldb_f14_s390x,
-        lldb_f15_s390x,
-        lldb_fpc_s390x,
-        LLDB_INVALID_REGNUM // register sets need to end with this flag
-    };
-    static_assert((sizeof(g_fpu_regnums_s390x) / sizeof(g_fpu_regnums_s390x[0])) - 1 == k_num_fpr_registers_s390x,
-                  "g_fpu_regnums_s390x has wrong number of register infos");
-
-    // s390x Linux operating-system information.
-    static const uint32_t g_linux_regnums_s390x[] =
-    {
-        lldb_orig_r2_s390x,
-        lldb_last_break_s390x,
-        lldb_system_call_s390x,
-        LLDB_INVALID_REGNUM // register sets need to end with this flag
-    };
-    static_assert((sizeof(g_linux_regnums_s390x) / sizeof(g_linux_regnums_s390x[0])) - 1 == k_num_linux_registers_s390x,
-                  "g_linux_regnums_s390x has wrong number of register infos");
-
-    // Number of register sets provided by this context.
-    enum
-    {
-        k_num_register_sets = 3
-    };
-
-    // Register sets for s390x 64-bit.
-    static const RegisterSet g_reg_sets_s390x[k_num_register_sets] =
-    {
-        { "General Purpose Registers", "gpr", k_num_gpr_registers_s390x, g_gpr_regnums_s390x },
-        { "Floating Point Registers", "fpr", k_num_fpr_registers_s390x, g_fpu_regnums_s390x },
-        { "Linux Operating System Data", "linux", k_num_linux_registers_s390x, g_linux_regnums_s390x },
-    };
+namespace {
+// s390x 64-bit general purpose registers.
+static const uint32_t g_gpr_regnums_s390x[] = {
+    lldb_r0_s390x,      lldb_r1_s390x,    lldb_r2_s390x,    lldb_r3_s390x,
+    lldb_r4_s390x,      lldb_r5_s390x,    lldb_r6_s390x,    lldb_r7_s390x,
+    lldb_r8_s390x,      lldb_r9_s390x,    lldb_r10_s390x,   lldb_r11_s390x,
+    lldb_r12_s390x,     lldb_r13_s390x,   lldb_r14_s390x,   lldb_r15_s390x,
+    lldb_acr0_s390x,    lldb_acr1_s390x,  lldb_acr2_s390x,  lldb_acr3_s390x,
+    lldb_acr4_s390x,    lldb_acr5_s390x,  lldb_acr6_s390x,  lldb_acr7_s390x,
+    lldb_acr8_s390x,    lldb_acr9_s390x,  lldb_acr10_s390x, lldb_acr11_s390x,
+    lldb_acr12_s390x,   lldb_acr13_s390x, lldb_acr14_s390x, lldb_acr15_s390x,
+    lldb_pswm_s390x,    lldb_pswa_s390x,
+    LLDB_INVALID_REGNUM // register sets need to end with this flag
+};
+static_assert((sizeof(g_gpr_regnums_s390x) / sizeof(g_gpr_regnums_s390x[0])) -
+                      1 ==
+                  k_num_gpr_registers_s390x,
+              "g_gpr_regnums_s390x has wrong number of register infos");
+
+// s390x 64-bit floating point registers.
+static const uint32_t g_fpu_regnums_s390x[] = {
+    lldb_f0_s390x,      lldb_f1_s390x,  lldb_f2_s390x,  lldb_f3_s390x,
+    lldb_f4_s390x,      lldb_f5_s390x,  lldb_f6_s390x,  lldb_f7_s390x,
+    lldb_f8_s390x,      lldb_f9_s390x,  lldb_f10_s390x, lldb_f11_s390x,
+    lldb_f12_s390x,     lldb_f13_s390x, lldb_f14_s390x, lldb_f15_s390x,
+    lldb_fpc_s390x,
+    LLDB_INVALID_REGNUM // register sets need to end with this flag
+};
+static_assert((sizeof(g_fpu_regnums_s390x) / sizeof(g_fpu_regnums_s390x[0])) -
+                      1 ==
+                  k_num_fpr_registers_s390x,
+              "g_fpu_regnums_s390x has wrong number of register infos");
+
+// s390x Linux operating-system information.
+static const uint32_t g_linux_regnums_s390x[] = {
+    lldb_orig_r2_s390x, lldb_last_break_s390x, lldb_system_call_s390x,
+    LLDB_INVALID_REGNUM // register sets need to end with this flag
+};
+static_assert((sizeof(g_linux_regnums_s390x) /
+               sizeof(g_linux_regnums_s390x[0])) -
+                      1 ==
+                  k_num_linux_registers_s390x,
+              "g_linux_regnums_s390x has wrong number of register infos");
+
+// Number of register sets provided by this context.
+enum { k_num_register_sets = 3 };
+
+// Register sets for s390x 64-bit.
+static const RegisterSet g_reg_sets_s390x[k_num_register_sets] = {
+    {"General Purpose Registers", "gpr", k_num_gpr_registers_s390x,
+     g_gpr_regnums_s390x},
+    {"Floating Point Registers", "fpr", k_num_fpr_registers_s390x,
+     g_fpu_regnums_s390x},
+    {"Linux Operating System Data", "linux", k_num_linux_registers_s390x,
+     g_linux_regnums_s390x},
+};
 }
 
 #define REG_CONTEXT_SIZE (sizeof(s390_regs) + sizeof(s390_fp_regs) + 4)
@@ -131,15 +94,15 @@ namespace
 // Required ptrace defines.
 // ----------------------------------------------------------------------------
 
-#define NT_S390_LAST_BREAK  0x306 /* s390 breaking event address */
+#define NT_S390_LAST_BREAK 0x306  /* s390 breaking event address */
 #define NT_S390_SYSTEM_CALL 0x307 /* s390 system call restart data */
 
 NativeRegisterContextLinux *
-NativeRegisterContextLinux::CreateHostNativeRegisterContextLinux(const ArchSpec &target_arch,
-                                                                 NativeThreadProtocol &native_thread,
-                                                                 uint32_t concrete_frame_idx)
-{
-    return new NativeRegisterContextLinux_s390x(target_arch, native_thread, concrete_frame_idx);
+NativeRegisterContextLinux::CreateHostNativeRegisterContextLinux(
+    const ArchSpec &target_arch, NativeThreadProtocol &native_thread,
+    uint32_t concrete_frame_idx) {
+  return new NativeRegisterContextLinux_s390x(target_arch, native_thread,
+                                              concrete_frame_idx);
 }
 
 // ----------------------------------------------------------------------------
@@ -147,570 +110,527 @@ NativeRegisterContextLinux::CreateHostNa
 // ----------------------------------------------------------------------------
 
 static RegisterInfoInterface *
-CreateRegisterInfoInterface(const ArchSpec &target_arch)
-{
-    assert((HostInfo::GetArchitecture().GetAddressByteSize() == 8) &&
-           "Register setting path assumes this is a 64-bit host");
-    return new RegisterContextLinux_s390x(target_arch);
-}
-
-NativeRegisterContextLinux_s390x::NativeRegisterContextLinux_s390x(const ArchSpec &target_arch,
-                                                                   NativeThreadProtocol &native_thread,
-                                                                   uint32_t concrete_frame_idx)
-    : NativeRegisterContextLinux(native_thread, concrete_frame_idx, CreateRegisterInfoInterface(target_arch))
-{
-    // Set up data about ranges of valid registers.
-    switch (target_arch.GetMachine())
-    {
-        case llvm::Triple::systemz:
-            m_reg_info.num_registers = k_num_registers_s390x;
-            m_reg_info.num_gpr_registers = k_num_gpr_registers_s390x;
-            m_reg_info.num_fpr_registers = k_num_fpr_registers_s390x;
-            m_reg_info.last_gpr = k_last_gpr_s390x;
-            m_reg_info.first_fpr = k_first_fpr_s390x;
-            m_reg_info.last_fpr = k_last_fpr_s390x;
-            break;
-        default:
-            assert(false && "Unhandled target architecture.");
-            break;
-    }
-
-    // Clear out the watchpoint state.
-    m_watchpoint_addr = LLDB_INVALID_ADDRESS;
+CreateRegisterInfoInterface(const ArchSpec &target_arch) {
+  assert((HostInfo::GetArchitecture().GetAddressByteSize() == 8) &&
+         "Register setting path assumes this is a 64-bit host");
+  return new RegisterContextLinux_s390x(target_arch);
+}
+
+NativeRegisterContextLinux_s390x::NativeRegisterContextLinux_s390x(
+    const ArchSpec &target_arch, NativeThreadProtocol &native_thread,
+    uint32_t concrete_frame_idx)
+    : NativeRegisterContextLinux(native_thread, concrete_frame_idx,
+                                 CreateRegisterInfoInterface(target_arch)) {
+  // Set up data about ranges of valid registers.
+  switch (target_arch.GetMachine()) {
+  case llvm::Triple::systemz:
+    m_reg_info.num_registers = k_num_registers_s390x;
+    m_reg_info.num_gpr_registers = k_num_gpr_registers_s390x;
+    m_reg_info.num_fpr_registers = k_num_fpr_registers_s390x;
+    m_reg_info.last_gpr = k_last_gpr_s390x;
+    m_reg_info.first_fpr = k_first_fpr_s390x;
+    m_reg_info.last_fpr = k_last_fpr_s390x;
+    break;
+  default:
+    assert(false && "Unhandled target architecture.");
+    break;
+  }
+
+  // Clear out the watchpoint state.
+  m_watchpoint_addr = LLDB_INVALID_ADDRESS;
+}
+
+uint32_t NativeRegisterContextLinux_s390x::GetRegisterSetCount() const {
+  uint32_t sets = 0;
+  for (uint32_t set_index = 0; set_index < k_num_register_sets; ++set_index) {
+    if (IsRegisterSetAvailable(set_index))
+      ++sets;
+  }
+
+  return sets;
+}
+
+uint32_t NativeRegisterContextLinux_s390x::GetUserRegisterCount() const {
+  uint32_t count = 0;
+  for (uint32_t set_index = 0; set_index < k_num_register_sets; ++set_index) {
+    const RegisterSet *set = GetRegisterSet(set_index);
+    if (set)
+      count += set->num_registers;
+  }
+  return count;
 }
 
-uint32_t
-NativeRegisterContextLinux_s390x::GetRegisterSetCount() const
-{
-    uint32_t sets = 0;
-    for (uint32_t set_index = 0; set_index < k_num_register_sets; ++set_index)
-    {
-        if (IsRegisterSetAvailable(set_index))
-            ++sets;
-    }
+const RegisterSet *
+NativeRegisterContextLinux_s390x::GetRegisterSet(uint32_t set_index) const {
+  if (!IsRegisterSetAvailable(set_index))
+    return nullptr;
+
+  switch (GetRegisterInfoInterface().GetTargetArchitecture().GetMachine()) {
+  case llvm::Triple::systemz:
+    return &g_reg_sets_s390x[set_index];
+  default:
+    assert(false && "Unhandled target architecture.");
+    return nullptr;
+  }
 
-    return sets;
+  return nullptr;
 }
 
-uint32_t
-NativeRegisterContextLinux_s390x::GetUserRegisterCount() const
-{
-    uint32_t count = 0;
-    for (uint32_t set_index = 0; set_index < k_num_register_sets; ++set_index)
-    {
-        const RegisterSet *set = GetRegisterSet(set_index);
-        if (set)
-            count += set->num_registers;
-    }
-    return count;
+bool NativeRegisterContextLinux_s390x::IsRegisterSetAvailable(
+    uint32_t set_index) const {
+  return set_index < k_num_register_sets;
 }
 
-const RegisterSet *
-NativeRegisterContextLinux_s390x::GetRegisterSet(uint32_t set_index) const
-{
-    if (!IsRegisterSetAvailable(set_index))
-        return nullptr;
-
-    switch (GetRegisterInfoInterface().GetTargetArchitecture().GetMachine())
-    {
-        case llvm::Triple::systemz:
-            return &g_reg_sets_s390x[set_index];
-        default:
-            assert(false && "Unhandled target architecture.");
-            return nullptr;
-    }
+bool NativeRegisterContextLinux_s390x::IsGPR(uint32_t reg_index) const {
+  // GPRs come first.  "orig_r2" counts as GPR since it is part of the GPR
+  // register area.
+  return reg_index <= m_reg_info.last_gpr || reg_index == lldb_orig_r2_s390x;
+}
 
-    return nullptr;
+bool NativeRegisterContextLinux_s390x::IsFPR(uint32_t reg_index) const {
+  return (m_reg_info.first_fpr <= reg_index &&
+          reg_index <= m_reg_info.last_fpr);
 }
 
-bool
-NativeRegisterContextLinux_s390x::IsRegisterSetAvailable(uint32_t set_index) const
-{
-    return set_index < k_num_register_sets;
-}
-
-bool
-NativeRegisterContextLinux_s390x::IsGPR(uint32_t reg_index) const
-{
-    // GPRs come first.  "orig_r2" counts as GPR since it is part of the GPR register area.
-    return reg_index <= m_reg_info.last_gpr || reg_index == lldb_orig_r2_s390x;
-}
-
-bool
-NativeRegisterContextLinux_s390x::IsFPR(uint32_t reg_index) const
-{
-    return (m_reg_info.first_fpr <= reg_index && reg_index <= m_reg_info.last_fpr);
-}
-
-Error
-NativeRegisterContextLinux_s390x::ReadRegister(const RegisterInfo *reg_info, RegisterValue &reg_value)
-{
-    if (!reg_info)
-        return Error("reg_info NULL");
-
-    const uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];
-    if (reg == LLDB_INVALID_REGNUM)
-        return Error("register \"%s\" is an internal-only lldb register, cannot read directly", reg_info->name);
-
-    if (IsGPR(reg))
-    {
-        s390_regs regs;
-        Error error = DoReadGPR(&regs, sizeof(regs));
-        if (error.Fail())
-            return error;
-
-        uint8_t *src = (uint8_t *)&regs + reg_info->byte_offset;
-        assert(reg_info->byte_offset + reg_info->byte_size <= sizeof(regs));
-        switch (reg_info->byte_size)
-        {
-            case 4:
-                reg_value.SetUInt32(*(uint32_t *)src);
-                break;
-            case 8:
-                reg_value.SetUInt64(*(uint64_t *)src);
-                break;
-            default:
-                assert(false && "Unhandled data size.");
-                return Error("unhandled byte size: %" PRIu32, reg_info->byte_size);
-        }
-        return Error();
-    }
+Error NativeRegisterContextLinux_s390x::ReadRegister(
+    const RegisterInfo *reg_info, RegisterValue &reg_value) {
+  if (!reg_info)
+    return Error("reg_info NULL");
 
-    if (IsFPR(reg))
-    {
-        s390_fp_regs fp_regs;
-        Error error = DoReadFPR(&fp_regs, sizeof(fp_regs));
-        if (error.Fail())
-            return error;
-
-        // byte_offset is just the offset within FPR, not the whole user area.
-        uint8_t *src = (uint8_t *)&fp_regs + reg_info->byte_offset;
-        assert(reg_info->byte_offset + reg_info->byte_size <= sizeof(fp_regs));
-        switch (reg_info->byte_size)
-        {
-            case 4:
-                reg_value.SetUInt32(*(uint32_t *)src);
-                break;
-            case 8:
-                reg_value.SetUInt64(*(uint64_t *)src);
-                break;
-            default:
-                assert(false && "Unhandled data size.");
-                return Error("unhandled byte size: %" PRIu32, reg_info->byte_size);
-        }
-        return Error();
-    }
+  const uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];
+  if (reg == LLDB_INVALID_REGNUM)
+    return Error("register \"%s\" is an internal-only lldb register, cannot "
+                 "read directly",
+                 reg_info->name);
 
-    if (reg == lldb_last_break_s390x)
-    {
-        uint64_t last_break;
-        Error error = DoReadRegisterSet(NT_S390_LAST_BREAK, &last_break, 8);
-        if (error.Fail())
-            return error;
+  if (IsGPR(reg)) {
+    s390_regs regs;
+    Error error = DoReadGPR(&regs, sizeof(regs));
+    if (error.Fail())
+      return error;
 
-        reg_value.SetUInt64(last_break);
-        return Error();
+    uint8_t *src = (uint8_t *)&regs + reg_info->byte_offset;
+    assert(reg_info->byte_offset + reg_info->byte_size <= sizeof(regs));
+    switch (reg_info->byte_size) {
+    case 4:
+      reg_value.SetUInt32(*(uint32_t *)src);
+      break;
+    case 8:
+      reg_value.SetUInt64(*(uint64_t *)src);
+      break;
+    default:
+      assert(false && "Unhandled data size.");
+      return Error("unhandled byte size: %" PRIu32, reg_info->byte_size);
     }
+    return Error();
+  }
 
-    if (reg == lldb_system_call_s390x)
-    {
-        uint32_t system_call;
-        Error error = DoReadRegisterSet(NT_S390_SYSTEM_CALL, &system_call, 4);
-        if (error.Fail())
-            return error;
+  if (IsFPR(reg)) {
+    s390_fp_regs fp_regs;
+    Error error = DoReadFPR(&fp_regs, sizeof(fp_regs));
+    if (error.Fail())
+      return error;
 
-        reg_value.SetUInt32(system_call);
-        return Error();
+    // byte_offset is just the offset within FPR, not the whole user area.
+    uint8_t *src = (uint8_t *)&fp_regs + reg_info->byte_offset;
+    assert(reg_info->byte_offset + reg_info->byte_size <= sizeof(fp_regs));
+    switch (reg_info->byte_size) {
+    case 4:
+      reg_value.SetUInt32(*(uint32_t *)src);
+      break;
+    case 8:
+      reg_value.SetUInt64(*(uint64_t *)src);
+      break;
+    default:
+      assert(false && "Unhandled data size.");
+      return Error("unhandled byte size: %" PRIu32, reg_info->byte_size);
     }
+    return Error();
+  }
 
-    return Error("failed - register wasn't recognized");
-}
-
-Error
-NativeRegisterContextLinux_s390x::WriteRegister(const RegisterInfo *reg_info, const RegisterValue &reg_value)
-{
-    if (!reg_info)
-        return Error("reg_info NULL");
-
-    const uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];
-    if (reg == LLDB_INVALID_REGNUM)
-        return Error("register \"%s\" is an internal-only lldb register, cannot write directly", reg_info->name);
-
-    if (IsGPR(reg))
-    {
-        s390_regs regs;
-        Error error = DoReadGPR(&regs, sizeof(regs));
-        if (error.Fail())
-            return error;
-
-        uint8_t *dst = (uint8_t *)&regs + reg_info->byte_offset;
-        assert(reg_info->byte_offset + reg_info->byte_size <= sizeof(regs));
-        switch (reg_info->byte_size)
-        {
-            case 4:
-                *(uint32_t *)dst = reg_value.GetAsUInt32();
-                break;
-            case 8:
-                *(uint64_t *)dst = reg_value.GetAsUInt64();
-                break;
-            default:
-                assert(false && "Unhandled data size.");
-                return Error("unhandled byte size: %" PRIu32, reg_info->byte_size);
-        }
-        return DoWriteGPR(&regs, sizeof(regs));
-    }
+  if (reg == lldb_last_break_s390x) {
+    uint64_t last_break;
+    Error error = DoReadRegisterSet(NT_S390_LAST_BREAK, &last_break, 8);
+    if (error.Fail())
+      return error;
 
-    if (IsFPR(reg))
-    {
-        s390_fp_regs fp_regs;
-        Error error = DoReadFPR(&fp_regs, sizeof(fp_regs));
-        if (error.Fail())
-            return error;
-
-        // byte_offset is just the offset within fp_regs, not the whole user area.
-        uint8_t *dst = (uint8_t *)&fp_regs + reg_info->byte_offset;
-        assert(reg_info->byte_offset + reg_info->byte_size <= sizeof(fp_regs));
-        switch (reg_info->byte_size)
-        {
-            case 4:
-                *(uint32_t *)dst = reg_value.GetAsUInt32();
-                break;
-            case 8:
-                *(uint64_t *)dst = reg_value.GetAsUInt64();
-                break;
-            default:
-                assert(false && "Unhandled data size.");
-                return Error("unhandled byte size: %" PRIu32, reg_info->byte_size);
-        }
-        return DoWriteFPR(&fp_regs, sizeof(fp_regs));
-    }
+    reg_value.SetUInt64(last_break);
+    return Error();
+  }
 
-    if (reg == lldb_last_break_s390x)
-    {
-        return Error("The last break address is read-only");
-    }
+  if (reg == lldb_system_call_s390x) {
+    uint32_t system_call;
+    Error error = DoReadRegisterSet(NT_S390_SYSTEM_CALL, &system_call, 4);
+    if (error.Fail())
+      return error;
 
-    if (reg == lldb_system_call_s390x)
-    {
-        uint32_t system_call = reg_value.GetAsUInt32();
-        return DoWriteRegisterSet(NT_S390_SYSTEM_CALL, &system_call, 4);
-    }
+    reg_value.SetUInt32(system_call);
+    return Error();
+  }
 
-    return Error("failed - register wasn't recognized");
+  return Error("failed - register wasn't recognized");
 }
 
-Error
-NativeRegisterContextLinux_s390x::ReadAllRegisterValues(lldb::DataBufferSP &data_sp)
-{
-    Error error;
-
-    data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0));
-    if (!data_sp)
-    {
-        error.SetErrorStringWithFormat("failed to allocate DataBufferHeap instance of size %" PRIu64, REG_CONTEXT_SIZE);
-        return error;
-    }
+Error NativeRegisterContextLinux_s390x::WriteRegister(
+    const RegisterInfo *reg_info, const RegisterValue &reg_value) {
+  if (!reg_info)
+    return Error("reg_info NULL");
 
-    uint8_t *dst = data_sp->GetBytes();
-    if (dst == nullptr)
-    {
-        error.SetErrorStringWithFormat("DataBufferHeap instance of size %" PRIu64 " returned a null pointer",
-                                       REG_CONTEXT_SIZE);
-        return error;
-    }
+  const uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];
+  if (reg == LLDB_INVALID_REGNUM)
+    return Error("register \"%s\" is an internal-only lldb register, cannot "
+                 "write directly",
+                 reg_info->name);
 
-    error = DoReadGPR(dst, sizeof(s390_regs));
-    dst += sizeof(s390_regs);
+  if (IsGPR(reg)) {
+    s390_regs regs;
+    Error error = DoReadGPR(&regs, sizeof(regs));
     if (error.Fail())
-        return error;
+      return error;
 
-    error = DoReadFPR(dst, sizeof(s390_fp_regs));
-    dst += sizeof(s390_fp_regs);
+    uint8_t *dst = (uint8_t *)&regs + reg_info->byte_offset;
+    assert(reg_info->byte_offset + reg_info->byte_size <= sizeof(regs));
+    switch (reg_info->byte_size) {
+    case 4:
+      *(uint32_t *)dst = reg_value.GetAsUInt32();
+      break;
+    case 8:
+      *(uint64_t *)dst = reg_value.GetAsUInt64();
+      break;
+    default:
+      assert(false && "Unhandled data size.");
+      return Error("unhandled byte size: %" PRIu32, reg_info->byte_size);
+    }
+    return DoWriteGPR(&regs, sizeof(regs));
+  }
+
+  if (IsFPR(reg)) {
+    s390_fp_regs fp_regs;
+    Error error = DoReadFPR(&fp_regs, sizeof(fp_regs));
     if (error.Fail())
-        return error;
+      return error;
 
-    // Ignore errors if the regset is unsupported (happens on older kernels).
-    DoReadRegisterSet(NT_S390_SYSTEM_CALL, dst, 4);
-    dst += 4;
-
-    // To enable inferior function calls while the process is stopped in
-    // an interrupted system call, we need to clear the system call flag.
-    // It will be restored to its original value by WriteAllRegisterValues.
-    // Again we ignore error if the regset is unsupported.
-    uint32_t system_call = 0;
-    DoWriteRegisterSet(NT_S390_SYSTEM_CALL, &system_call, 4);
+    // byte_offset is just the offset within fp_regs, not the whole user area.
+    uint8_t *dst = (uint8_t *)&fp_regs + reg_info->byte_offset;
+    assert(reg_info->byte_offset + reg_info->byte_size <= sizeof(fp_regs));
+    switch (reg_info->byte_size) {
+    case 4:
+      *(uint32_t *)dst = reg_value.GetAsUInt32();
+      break;
+    case 8:
+      *(uint64_t *)dst = reg_value.GetAsUInt64();
+      break;
+    default:
+      assert(false && "Unhandled data size.");
+      return Error("unhandled byte size: %" PRIu32, reg_info->byte_size);
+    }
+    return DoWriteFPR(&fp_regs, sizeof(fp_regs));
+  }
+
+  if (reg == lldb_last_break_s390x) {
+    return Error("The last break address is read-only");
+  }
+
+  if (reg == lldb_system_call_s390x) {
+    uint32_t system_call = reg_value.GetAsUInt32();
+    return DoWriteRegisterSet(NT_S390_SYSTEM_CALL, &system_call, 4);
+  }
+
+  return Error("failed - register wasn't recognized");
+}
+
+Error NativeRegisterContextLinux_s390x::ReadAllRegisterValues(
+    lldb::DataBufferSP &data_sp) {
+  Error error;
+
+  data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0));
+  if (!data_sp) {
+    error.SetErrorStringWithFormat(
+        "failed to allocate DataBufferHeap instance of size %" PRIu64,
+        REG_CONTEXT_SIZE);
+    return error;
+  }
 
+  uint8_t *dst = data_sp->GetBytes();
+  if (dst == nullptr) {
+    error.SetErrorStringWithFormat("DataBufferHeap instance of size %" PRIu64
+                                   " returned a null pointer",
+                                   REG_CONTEXT_SIZE);
     return error;
-}
+  }
 
-Error
-NativeRegisterContextLinux_s390x::WriteAllRegisterValues(const lldb::DataBufferSP &data_sp)
-{
-    Error error;
-
-    if (!data_sp)
-    {
-        error.SetErrorStringWithFormat("NativeRegisterContextLinux_s390x::%s invalid data_sp provided", __FUNCTION__);
-        return error;
-    }
+  error = DoReadGPR(dst, sizeof(s390_regs));
+  dst += sizeof(s390_regs);
+  if (error.Fail())
+    return error;
 
-    if (data_sp->GetByteSize() != REG_CONTEXT_SIZE)
-    {
-        error.SetErrorStringWithFormat(
-            "NativeRegisterContextLinux_s390x::%s data_sp contained mismatched data size, expected %" PRIu64
-            ", actual %" PRIu64,
-            __FUNCTION__, REG_CONTEXT_SIZE, data_sp->GetByteSize());
-        return error;
-    }
+  error = DoReadFPR(dst, sizeof(s390_fp_regs));
+  dst += sizeof(s390_fp_regs);
+  if (error.Fail())
+    return error;
 
-    uint8_t *src = data_sp->GetBytes();
-    if (src == nullptr)
-    {
-        error.SetErrorStringWithFormat(
-            "NativeRegisterContextLinux_s390x::%s DataBuffer::GetBytes() returned a null pointer", __FUNCTION__);
-        return error;
-    }
+  // Ignore errors if the regset is unsupported (happens on older kernels).
+  DoReadRegisterSet(NT_S390_SYSTEM_CALL, dst, 4);
+  dst += 4;
+
+  // To enable inferior function calls while the process is stopped in
+  // an interrupted system call, we need to clear the system call flag.
+  // It will be restored to its original value by WriteAllRegisterValues.
+  // Again we ignore error if the regset is unsupported.
+  uint32_t system_call = 0;
+  DoWriteRegisterSet(NT_S390_SYSTEM_CALL, &system_call, 4);
+
+  return error;
+}
+
+Error NativeRegisterContextLinux_s390x::WriteAllRegisterValues(
+    const lldb::DataBufferSP &data_sp) {
+  Error error;
+
+  if (!data_sp) {
+    error.SetErrorStringWithFormat(
+        "NativeRegisterContextLinux_s390x::%s invalid data_sp provided",
+        __FUNCTION__);
+    return error;
+  }
 
-    error = DoWriteGPR(src, sizeof(s390_regs));
-    src += sizeof(s390_regs);
-    if (error.Fail())
-        return error;
+  if (data_sp->GetByteSize() != REG_CONTEXT_SIZE) {
+    error.SetErrorStringWithFormat(
+        "NativeRegisterContextLinux_s390x::%s data_sp contained mismatched "
+        "data size, expected %" PRIu64 ", actual %" PRIu64,
+        __FUNCTION__, REG_CONTEXT_SIZE, data_sp->GetByteSize());
+    return error;
+  }
 
-    error = DoWriteFPR(src, sizeof(s390_fp_regs));
-    src += sizeof(s390_fp_regs);
-    if (error.Fail())
-        return error;
+  uint8_t *src = data_sp->GetBytes();
+  if (src == nullptr) {
+    error.SetErrorStringWithFormat("NativeRegisterContextLinux_s390x::%s "
+                                   "DataBuffer::GetBytes() returned a null "
+                                   "pointer",
+                                   __FUNCTION__);
+    return error;
+  }
 
-    // Ignore errors if the regset is unsupported (happens on older kernels).
-    DoWriteRegisterSet(NT_S390_SYSTEM_CALL, src, 4);
-    src += 4;
+  error = DoWriteGPR(src, sizeof(s390_regs));
+  src += sizeof(s390_regs);
+  if (error.Fail())
+    return error;
 
+  error = DoWriteFPR(src, sizeof(s390_fp_regs));
+  src += sizeof(s390_fp_regs);
+  if (error.Fail())
     return error;
+
+  // Ignore errors if the regset is unsupported (happens on older kernels).
+  DoWriteRegisterSet(NT_S390_SYSTEM_CALL, src, 4);
+  src += 4;
+
+  return error;
 }
 
-Error
-NativeRegisterContextLinux_s390x::DoReadRegisterValue(uint32_t offset, const char *reg_name, uint32_t size,
-                                                      RegisterValue &value)
-{
-    return Error("DoReadRegisterValue unsupported");
+Error NativeRegisterContextLinux_s390x::DoReadRegisterValue(
+    uint32_t offset, const char *reg_name, uint32_t size,
+    RegisterValue &value) {
+  return Error("DoReadRegisterValue unsupported");
 }
 
-Error
-NativeRegisterContextLinux_s390x::DoWriteRegisterValue(uint32_t offset, const char *reg_name,
-                                                       const RegisterValue &value)
-{
-    return Error("DoWriteRegisterValue unsupported");
+Error NativeRegisterContextLinux_s390x::DoWriteRegisterValue(
+    uint32_t offset, const char *reg_name, const RegisterValue &value) {
+  return Error("DoWriteRegisterValue unsupported");
 }
 
-Error
-NativeRegisterContextLinux_s390x::PeekUserArea(uint32_t offset, void *buf, size_t buf_size)
-{
-    ptrace_area parea;
-    parea.len = buf_size;
-    parea.process_addr = (addr_t)buf;
-    parea.kernel_addr = offset;
+Error NativeRegisterContextLinux_s390x::PeekUserArea(uint32_t offset, void *buf,
+                                                     size_t buf_size) {
+  ptrace_area parea;
+  parea.len = buf_size;
+  parea.process_addr = (addr_t)buf;
+  parea.kernel_addr = offset;
 
-    return NativeProcessLinux::PtraceWrapper(PTRACE_PEEKUSR_AREA, m_thread.GetID(), &parea);
+  return NativeProcessLinux::PtraceWrapper(PTRACE_PEEKUSR_AREA,
+                                           m_thread.GetID(), &parea);
 }
 
-Error
-NativeRegisterContextLinux_s390x::PokeUserArea(uint32_t offset, const void *buf, size_t buf_size)
-{
-    ptrace_area parea;
-    parea.len = buf_size;
-    parea.process_addr = (addr_t)buf;
-    parea.kernel_addr = offset;
+Error NativeRegisterContextLinux_s390x::PokeUserArea(uint32_t offset,
+                                                     const void *buf,
+                                                     size_t buf_size) {
+  ptrace_area parea;
+  parea.len = buf_size;
+  parea.process_addr = (addr_t)buf;
+  parea.kernel_addr = offset;
 
-    return NativeProcessLinux::PtraceWrapper(PTRACE_POKEUSR_AREA, m_thread.GetID(), &parea);
+  return NativeProcessLinux::PtraceWrapper(PTRACE_POKEUSR_AREA,
+                                           m_thread.GetID(), &parea);
 }
 
-Error
-NativeRegisterContextLinux_s390x::DoReadGPR(void *buf, size_t buf_size)
-{
-    assert(buf_size == sizeof(s390_regs));
-    return PeekUserArea(offsetof(user_regs_struct, psw), buf, buf_size);
+Error NativeRegisterContextLinux_s390x::DoReadGPR(void *buf, size_t buf_size) {
+  assert(buf_size == sizeof(s390_regs));
+  return PeekUserArea(offsetof(user_regs_struct, psw), buf, buf_size);
 }
 
-Error
-NativeRegisterContextLinux_s390x::DoWriteGPR(void *buf, size_t buf_size)
-{
-    assert(buf_size == sizeof(s390_regs));
-    return PokeUserArea(offsetof(user_regs_struct, psw), buf, buf_size);
+Error NativeRegisterContextLinux_s390x::DoWriteGPR(void *buf, size_t buf_size) {
+  assert(buf_size == sizeof(s390_regs));
+  return PokeUserArea(offsetof(user_regs_struct, psw), buf, buf_size);
 }
 
-Error
-NativeRegisterContextLinux_s390x::DoReadFPR(void *buf, size_t buf_size)
-{
-    assert(buf_size == sizeof(s390_fp_regs));
-    return PeekUserArea(offsetof(user_regs_struct, fp_regs), buf, buf_size);
+Error NativeRegisterContextLinux_s390x::DoReadFPR(void *buf, size_t buf_size) {
+  assert(buf_size == sizeof(s390_fp_regs));
+  return PeekUserArea(offsetof(user_regs_struct, fp_regs), buf, buf_size);
 }
 
-Error
-NativeRegisterContextLinux_s390x::DoWriteFPR(void *buf, size_t buf_size)
-{
-    assert(buf_size == sizeof(s390_fp_regs));
-    return PokeUserArea(offsetof(user_regs_struct, fp_regs), buf, buf_size);
+Error NativeRegisterContextLinux_s390x::DoWriteFPR(void *buf, size_t buf_size) {
+  assert(buf_size == sizeof(s390_fp_regs));
+  return PokeUserArea(offsetof(user_regs_struct, fp_regs), buf, buf_size);
 }
 
-Error
-NativeRegisterContextLinux_s390x::DoReadRegisterSet(uint32_t regset, void *buf, size_t buf_size)
-{
-    struct iovec iov;
-    iov.iov_base = buf;
-    iov.iov_len = buf_size;
+Error NativeRegisterContextLinux_s390x::DoReadRegisterSet(uint32_t regset,
+                                                          void *buf,
+                                                          size_t buf_size) {
+  struct iovec iov;
+  iov.iov_base = buf;
+  iov.iov_len = buf_size;
 
-    return ReadRegisterSet(&iov, buf_size, regset);
+  return ReadRegisterSet(&iov, buf_size, regset);
 }
 
-Error
-NativeRegisterContextLinux_s390x::DoWriteRegisterSet(uint32_t regset, const void *buf, size_t buf_size)
-{
-    struct iovec iov;
-    iov.iov_base = const_cast<void *>(buf);
-    iov.iov_len = buf_size;
+Error NativeRegisterContextLinux_s390x::DoWriteRegisterSet(uint32_t regset,
+                                                           const void *buf,
+                                                           size_t buf_size) {
+  struct iovec iov;
+  iov.iov_base = const_cast<void *>(buf);
+  iov.iov_len = buf_size;
 
-    return WriteRegisterSet(&iov, buf_size, regset);
+  return WriteRegisterSet(&iov, buf_size, regset);
 }
 
-Error
-NativeRegisterContextLinux_s390x::IsWatchpointHit(uint32_t wp_index, bool &is_hit)
-{
-    per_lowcore_bits per_lowcore;
+Error NativeRegisterContextLinux_s390x::IsWatchpointHit(uint32_t wp_index,
+                                                        bool &is_hit) {
+  per_lowcore_bits per_lowcore;
 
-    if (wp_index >= NumSupportedHardwareWatchpoints())
-        return Error("Watchpoint index out of range");
+  if (wp_index >= NumSupportedHardwareWatchpoints())
+    return Error("Watchpoint index out of range");
 
-    if (m_watchpoint_addr == LLDB_INVALID_ADDRESS)
-    {
-        is_hit = false;
-        return Error();
-    }
+  if (m_watchpoint_addr == LLDB_INVALID_ADDRESS) {
+    is_hit = false;
+    return Error();
+  }
 
-    Error error = PeekUserArea(offsetof(user_regs_struct, per_info.lowcore), &per_lowcore, sizeof(per_lowcore));
-    if (error.Fail())
-    {
-        is_hit = false;
-        return error;
-    }
+  Error error = PeekUserArea(offsetof(user_regs_struct, per_info.lowcore),
+                             &per_lowcore, sizeof(per_lowcore));
+  if (error.Fail()) {
+    is_hit = false;
+    return error;
+  }
 
-    is_hit = (per_lowcore.perc_storage_alteration == 1 && per_lowcore.perc_store_real_address == 0);
+  is_hit = (per_lowcore.perc_storage_alteration == 1 &&
+            per_lowcore.perc_store_real_address == 0);
 
-    if (is_hit)
-    {
-        // Do not report this watchpoint again.
-        memset(&per_lowcore, 0, sizeof(per_lowcore));
-        PokeUserArea(offsetof(user_regs_struct, per_info.lowcore), &per_lowcore, sizeof(per_lowcore));
-    }
+  if (is_hit) {
+    // Do not report this watchpoint again.
+    memset(&per_lowcore, 0, sizeof(per_lowcore));
+    PokeUserArea(offsetof(user_regs_struct, per_info.lowcore), &per_lowcore,
+                 sizeof(per_lowcore));
+  }
 
-    return Error();
+  return Error();
 }
 
-Error
-NativeRegisterContextLinux_s390x::GetWatchpointHitIndex(uint32_t &wp_index, lldb::addr_t trap_addr)
-{
-    uint32_t num_hw_wps = NumSupportedHardwareWatchpoints();
-    for (wp_index = 0; wp_index < num_hw_wps; ++wp_index)
-    {
-        bool is_hit;
-        Error error = IsWatchpointHit(wp_index, is_hit);
-        if (error.Fail())
-        {
-            wp_index = LLDB_INVALID_INDEX32;
-            return error;
-        }
-        else if (is_hit)
-        {
-            return error;
-        }
+Error NativeRegisterContextLinux_s390x::GetWatchpointHitIndex(
+    uint32_t &wp_index, lldb::addr_t trap_addr) {
+  uint32_t num_hw_wps = NumSupportedHardwareWatchpoints();
+  for (wp_index = 0; wp_index < num_hw_wps; ++wp_index) {
+    bool is_hit;
+    Error error = IsWatchpointHit(wp_index, is_hit);
+    if (error.Fail()) {
+      wp_index = LLDB_INVALID_INDEX32;
+      return error;
+    } else if (is_hit) {
+      return error;
     }
-    wp_index = LLDB_INVALID_INDEX32;
-    return Error();
+  }
+  wp_index = LLDB_INVALID_INDEX32;
+  return Error();
 }
 
-Error
-NativeRegisterContextLinux_s390x::IsWatchpointVacant(uint32_t wp_index, bool &is_vacant)
-{
-    if (wp_index >= NumSupportedHardwareWatchpoints())
-        return Error("Watchpoint index out of range");
+Error NativeRegisterContextLinux_s390x::IsWatchpointVacant(uint32_t wp_index,
+                                                           bool &is_vacant) {
+  if (wp_index >= NumSupportedHardwareWatchpoints())
+    return Error("Watchpoint index out of range");
 
-    is_vacant = m_watchpoint_addr == LLDB_INVALID_ADDRESS;
+  is_vacant = m_watchpoint_addr == LLDB_INVALID_ADDRESS;
 
-    return Error();
+  return Error();
 }
 
-bool
-NativeRegisterContextLinux_s390x::ClearHardwareWatchpoint(uint32_t wp_index)
-{
-    per_struct per_info;
+bool NativeRegisterContextLinux_s390x::ClearHardwareWatchpoint(
+    uint32_t wp_index) {
+  per_struct per_info;
 
-    if (wp_index >= NumSupportedHardwareWatchpoints())
-        return false;
+  if (wp_index >= NumSupportedHardwareWatchpoints())
+    return false;
 
-    Error error = PeekUserArea(offsetof(user_regs_struct, per_info), &per_info, sizeof(per_info));
-    if (error.Fail())
-        return false;
+  Error error = PeekUserArea(offsetof(user_regs_struct, per_info), &per_info,
+                             sizeof(per_info));
+  if (error.Fail())
+    return false;
 
-    per_info.control_regs.bits.em_storage_alteration = 0;
-    per_info.control_regs.bits.storage_alt_space_ctl = 0;
-    per_info.starting_addr = 0;
-    per_info.ending_addr = 0;
+  per_info.control_regs.bits.em_storage_alteration = 0;
+  per_info.control_regs.bits.storage_alt_space_ctl = 0;
+  per_info.starting_addr = 0;
+  per_info.ending_addr = 0;
 
-    error = PokeUserArea(offsetof(user_regs_struct, per_info), &per_info, sizeof(per_info));
-    if (error.Fail())
-        return false;
+  error = PokeUserArea(offsetof(user_regs_struct, per_info), &per_info,
+                       sizeof(per_info));
+  if (error.Fail())
+    return false;
 
-    m_watchpoint_addr = LLDB_INVALID_ADDRESS;
-    return true;
+  m_watchpoint_addr = LLDB_INVALID_ADDRESS;
+  return true;
 }
 
-Error
-NativeRegisterContextLinux_s390x::ClearAllHardwareWatchpoints()
-{
-    if (ClearHardwareWatchpoint(0))
-        return Error();
-    return Error("Clearing all hardware watchpoints failed.");
+Error NativeRegisterContextLinux_s390x::ClearAllHardwareWatchpoints() {
+  if (ClearHardwareWatchpoint(0))
+    return Error();
+  return Error("Clearing all hardware watchpoints failed.");
 }
 
-uint32_t
-NativeRegisterContextLinux_s390x::SetHardwareWatchpoint(lldb::addr_t addr, size_t size, uint32_t watch_flags)
-{
-    per_struct per_info;
+uint32_t NativeRegisterContextLinux_s390x::SetHardwareWatchpoint(
+    lldb::addr_t addr, size_t size, uint32_t watch_flags) {
+  per_struct per_info;
 
-    if (watch_flags != 0x1)
-        return LLDB_INVALID_INDEX32;
+  if (watch_flags != 0x1)
+    return LLDB_INVALID_INDEX32;
 
-    if (m_watchpoint_addr != LLDB_INVALID_ADDRESS)
-        return LLDB_INVALID_INDEX32;
+  if (m_watchpoint_addr != LLDB_INVALID_ADDRESS)
+    return LLDB_INVALID_INDEX32;
 
-    Error error = PeekUserArea(offsetof(user_regs_struct, per_info), &per_info, sizeof(per_info));
-    if (error.Fail())
-        return LLDB_INVALID_INDEX32;
+  Error error = PeekUserArea(offsetof(user_regs_struct, per_info), &per_info,
+                             sizeof(per_info));
+  if (error.Fail())
+    return LLDB_INVALID_INDEX32;
 
-    per_info.control_regs.bits.em_storage_alteration = 1;
-    per_info.control_regs.bits.storage_alt_space_ctl = 1;
-    per_info.starting_addr = addr;
-    per_info.ending_addr = addr + size - 1;
+  per_info.control_regs.bits.em_storage_alteration = 1;
+  per_info.control_regs.bits.storage_alt_space_ctl = 1;
+  per_info.starting_addr = addr;
+  per_info.ending_addr = addr + size - 1;
 
-    error = PokeUserArea(offsetof(user_regs_struct, per_info), &per_info, sizeof(per_info));
-    if (error.Fail())
-        return LLDB_INVALID_INDEX32;
+  error = PokeUserArea(offsetof(user_regs_struct, per_info), &per_info,
+                       sizeof(per_info));
+  if (error.Fail())
+    return LLDB_INVALID_INDEX32;
 
-    m_watchpoint_addr = addr;
-    return 0;
+  m_watchpoint_addr = addr;
+  return 0;
 }
 
 lldb::addr_t
-NativeRegisterContextLinux_s390x::GetWatchpointAddress(uint32_t wp_index)
-{
-    if (wp_index >= NumSupportedHardwareWatchpoints())
-        return LLDB_INVALID_ADDRESS;
-    return m_watchpoint_addr;
+NativeRegisterContextLinux_s390x::GetWatchpointAddress(uint32_t wp_index) {
+  if (wp_index >= NumSupportedHardwareWatchpoints())
+    return LLDB_INVALID_ADDRESS;
+  return m_watchpoint_addr;
 }
 
-uint32_t
-NativeRegisterContextLinux_s390x::NumSupportedHardwareWatchpoints()
-{
-    return 1;
+uint32_t NativeRegisterContextLinux_s390x::NumSupportedHardwareWatchpoints() {
+  return 1;
 }
 
 #endif // defined(__s390x__) && defined(__linux__)

Modified: lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.h (original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.h Tue Sep  6 15:57:50 2016
@@ -16,121 +16,96 @@
 #include "Plugins/Process/Utility/RegisterContext_s390x.h"
 #include "Plugins/Process/Utility/lldb-s390x-register-enums.h"
 
-namespace lldb_private
-{
-namespace process_linux
-{
+namespace lldb_private {
+namespace process_linux {
 
 class NativeProcessLinux;
 
-class NativeRegisterContextLinux_s390x : public NativeRegisterContextLinux
-{
+class NativeRegisterContextLinux_s390x : public NativeRegisterContextLinux {
 public:
-    NativeRegisterContextLinux_s390x(const ArchSpec &target_arch, NativeThreadProtocol &native_thread,
-                                     uint32_t concrete_frame_idx);
+  NativeRegisterContextLinux_s390x(const ArchSpec &target_arch,
+                                   NativeThreadProtocol &native_thread,
+                                   uint32_t concrete_frame_idx);
 
-    uint32_t
-    GetRegisterSetCount() const override;
+  uint32_t GetRegisterSetCount() const override;
 
-    const RegisterSet *
-    GetRegisterSet(uint32_t set_index) const override;
+  const RegisterSet *GetRegisterSet(uint32_t set_index) const override;
 
-    uint32_t
-    GetUserRegisterCount() const override;
+  uint32_t GetUserRegisterCount() const override;
 
-    Error
-    ReadRegister(const RegisterInfo *reg_info, RegisterValue &reg_value) override;
+  Error ReadRegister(const RegisterInfo *reg_info,
+                     RegisterValue &reg_value) override;
 
-    Error
-    WriteRegister(const RegisterInfo *reg_info, const RegisterValue &reg_value) override;
+  Error WriteRegister(const RegisterInfo *reg_info,
+                      const RegisterValue &reg_value) override;
 
-    Error
-    ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
+  Error ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
 
-    Error
-    WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
+  Error WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
 
-    Error
-    IsWatchpointHit(uint32_t wp_index, bool &is_hit) override;
+  Error IsWatchpointHit(uint32_t wp_index, bool &is_hit) override;
 
-    Error
-    GetWatchpointHitIndex(uint32_t &wp_index, lldb::addr_t trap_addr) override;
+  Error GetWatchpointHitIndex(uint32_t &wp_index,
+                              lldb::addr_t trap_addr) override;
 
-    Error
-    IsWatchpointVacant(uint32_t wp_index, bool &is_vacant) override;
+  Error IsWatchpointVacant(uint32_t wp_index, bool &is_vacant) override;
 
-    bool
-    ClearHardwareWatchpoint(uint32_t wp_index) override;
+  bool ClearHardwareWatchpoint(uint32_t wp_index) override;
 
-    Error
-    ClearAllHardwareWatchpoints() override;
+  Error ClearAllHardwareWatchpoints() override;
 
-    uint32_t
-    SetHardwareWatchpoint(lldb::addr_t addr, size_t size, uint32_t watch_flags) override;
+  uint32_t SetHardwareWatchpoint(lldb::addr_t addr, size_t size,
+                                 uint32_t watch_flags) override;
 
-    lldb::addr_t
-    GetWatchpointAddress(uint32_t wp_index) override;
+  lldb::addr_t GetWatchpointAddress(uint32_t wp_index) override;
 
-    uint32_t
-    NumSupportedHardwareWatchpoints() override;
+  uint32_t NumSupportedHardwareWatchpoints() override;
 
 protected:
-    Error
-    DoReadRegisterValue(uint32_t offset, const char *reg_name, uint32_t size, RegisterValue &value) override;
+  Error DoReadRegisterValue(uint32_t offset, const char *reg_name,
+                            uint32_t size, RegisterValue &value) override;
 
-    Error
-    DoWriteRegisterValue(uint32_t offset, const char *reg_name, const RegisterValue &value) override;
+  Error DoWriteRegisterValue(uint32_t offset, const char *reg_name,
+                             const RegisterValue &value) override;
 
-    Error
-    DoReadGPR(void *buf, size_t buf_size) override;
+  Error DoReadGPR(void *buf, size_t buf_size) override;
 
-    Error
-    DoWriteGPR(void *buf, size_t buf_size) override;
+  Error DoWriteGPR(void *buf, size_t buf_size) override;
 
-    Error
-    DoReadFPR(void *buf, size_t buf_size) override;
+  Error DoReadFPR(void *buf, size_t buf_size) override;
 
-    Error
-    DoWriteFPR(void *buf, size_t buf_size) override;
+  Error DoWriteFPR(void *buf, size_t buf_size) override;
 
 private:
-    // Info about register ranges.
-    struct RegInfo
-    {
-        uint32_t num_registers;
-        uint32_t num_gpr_registers;
-        uint32_t num_fpr_registers;
-
-        uint32_t last_gpr;
-        uint32_t first_fpr;
-        uint32_t last_fpr;
-    };
-
-    // Private member variables.
-    RegInfo m_reg_info;
-    lldb::addr_t m_watchpoint_addr;
-
-    // Private member methods.
-    bool
-    IsRegisterSetAvailable(uint32_t set_index) const;
-
-    bool
-    IsGPR(uint32_t reg_index) const;
-
-    bool
-    IsFPR(uint32_t reg_index) const;
-
-    Error
-    PeekUserArea(uint32_t offset, void *buf, size_t buf_size);
+  // Info about register ranges.
+  struct RegInfo {
+    uint32_t num_registers;
+    uint32_t num_gpr_registers;
+    uint32_t num_fpr_registers;
 
-    Error
-    PokeUserArea(uint32_t offset, const void *buf, size_t buf_size);
+    uint32_t last_gpr;
+    uint32_t first_fpr;
+    uint32_t last_fpr;
+  };
 
-    Error
-    DoReadRegisterSet(uint32_t regset, void *buf, size_t buf_size);
+  // Private member variables.
+  RegInfo m_reg_info;
+  lldb::addr_t m_watchpoint_addr;
 
-    Error
-    DoWriteRegisterSet(uint32_t regset, const void *buf, size_t buf_size);
+  // Private member methods.
+  bool IsRegisterSetAvailable(uint32_t set_index) const;
+
+  bool IsGPR(uint32_t reg_index) const;
+
+  bool IsFPR(uint32_t reg_index) const;
+
+  Error PeekUserArea(uint32_t offset, void *buf, size_t buf_size);
+
+  Error PokeUserArea(uint32_t offset, const void *buf, size_t buf_size);
+
+  Error DoReadRegisterSet(uint32_t regset, void *buf, size_t buf_size);
+
+  Error DoWriteRegisterSet(uint32_t regset, const void *buf, size_t buf_size);
 };
 
 } // namespace process_linux

Modified: lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp Tue Sep  6 15:57:50 2016
@@ -11,9 +11,9 @@
 
 #include "NativeRegisterContextLinux_x86_64.h"
 
-#include "lldb/Core/Log.h"
 #include "lldb/Core/DataBufferHeap.h"
 #include "lldb/Core/Error.h"
+#include "lldb/Core/Log.h"
 #include "lldb/Core/RegisterValue.h"
 #include "lldb/Host/HostInfo.h"
 
@@ -27,297 +27,158 @@ using namespace lldb_private::process_li
 // Private namespace.
 // ----------------------------------------------------------------------------
 
-namespace
-{
-    // x86 32-bit general purpose registers.
-    const uint32_t
-    g_gpr_regnums_i386[] =
-    {
-        lldb_eax_i386,
-        lldb_ebx_i386,
-        lldb_ecx_i386,
-        lldb_edx_i386,
-        lldb_edi_i386,
-        lldb_esi_i386,
-        lldb_ebp_i386,
-        lldb_esp_i386,
-        lldb_eip_i386,
-        lldb_eflags_i386,
-        lldb_cs_i386,
-        lldb_fs_i386,
-        lldb_gs_i386,
-        lldb_ss_i386,
-        lldb_ds_i386,
-        lldb_es_i386,
-        lldb_ax_i386,
-        lldb_bx_i386,
-        lldb_cx_i386,
-        lldb_dx_i386,
-        lldb_di_i386,
-        lldb_si_i386,
-        lldb_bp_i386,
-        lldb_sp_i386,
-        lldb_ah_i386,
-        lldb_bh_i386,
-        lldb_ch_i386,
-        lldb_dh_i386,
-        lldb_al_i386,
-        lldb_bl_i386,
-        lldb_cl_i386,
-        lldb_dl_i386,
-        LLDB_INVALID_REGNUM // register sets need to end with this flag
-    };
-    static_assert((sizeof(g_gpr_regnums_i386) / sizeof(g_gpr_regnums_i386[0])) - 1 == k_num_gpr_registers_i386,
-                  "g_gpr_regnums_i386 has wrong number of register infos");
-
-    // x86 32-bit floating point registers.
-    const uint32_t
-    g_fpu_regnums_i386[] =
-    {
-        lldb_fctrl_i386,
-        lldb_fstat_i386,
-        lldb_ftag_i386,
-        lldb_fop_i386,
-        lldb_fiseg_i386,
-        lldb_fioff_i386,
-        lldb_foseg_i386,
-        lldb_fooff_i386,
-        lldb_mxcsr_i386,
-        lldb_mxcsrmask_i386,
-        lldb_st0_i386,
-        lldb_st1_i386,
-        lldb_st2_i386,
-        lldb_st3_i386,
-        lldb_st4_i386,
-        lldb_st5_i386,
-        lldb_st6_i386,
-        lldb_st7_i386,
-        lldb_mm0_i386,
-        lldb_mm1_i386,
-        lldb_mm2_i386,
-        lldb_mm3_i386,
-        lldb_mm4_i386,
-        lldb_mm5_i386,
-        lldb_mm6_i386,
-        lldb_mm7_i386,
-        lldb_xmm0_i386,
-        lldb_xmm1_i386,
-        lldb_xmm2_i386,
-        lldb_xmm3_i386,
-        lldb_xmm4_i386,
-        lldb_xmm5_i386,
-        lldb_xmm6_i386,
-        lldb_xmm7_i386,
-        LLDB_INVALID_REGNUM // register sets need to end with this flag
-    };
-    static_assert((sizeof(g_fpu_regnums_i386) / sizeof(g_fpu_regnums_i386[0])) - 1 == k_num_fpr_registers_i386,
-                  "g_fpu_regnums_i386 has wrong number of register infos");
-
-    // x86 32-bit AVX registers.
-    const uint32_t
-    g_avx_regnums_i386[] =
-    {
-        lldb_ymm0_i386,
-        lldb_ymm1_i386,
-        lldb_ymm2_i386,
-        lldb_ymm3_i386,
-        lldb_ymm4_i386,
-        lldb_ymm5_i386,
-        lldb_ymm6_i386,
-        lldb_ymm7_i386,
-        LLDB_INVALID_REGNUM // register sets need to end with this flag
-    };
-    static_assert((sizeof(g_avx_regnums_i386) / sizeof(g_avx_regnums_i386[0])) - 1 == k_num_avx_registers_i386,
-                  " g_avx_regnums_i386 has wrong number of register infos");
-
-    // x86 64-bit general purpose registers.
-    static const
-    uint32_t g_gpr_regnums_x86_64[] =
-    {
-        lldb_rax_x86_64,
-        lldb_rbx_x86_64,
-        lldb_rcx_x86_64,
-        lldb_rdx_x86_64,
-        lldb_rdi_x86_64,
-        lldb_rsi_x86_64,
-        lldb_rbp_x86_64,
-        lldb_rsp_x86_64,
-        lldb_r8_x86_64,
-        lldb_r9_x86_64,
-        lldb_r10_x86_64,
-        lldb_r11_x86_64,
-        lldb_r12_x86_64,
-        lldb_r13_x86_64,
-        lldb_r14_x86_64,
-        lldb_r15_x86_64,
-        lldb_rip_x86_64,
-        lldb_rflags_x86_64,
-        lldb_cs_x86_64,
-        lldb_fs_x86_64,
-        lldb_gs_x86_64,
-        lldb_ss_x86_64,
-        lldb_ds_x86_64,
-        lldb_es_x86_64,
-        lldb_eax_x86_64,
-        lldb_ebx_x86_64,
-        lldb_ecx_x86_64,
-        lldb_edx_x86_64,
-        lldb_edi_x86_64,
-        lldb_esi_x86_64,
-        lldb_ebp_x86_64,
-        lldb_esp_x86_64,
-        lldb_r8d_x86_64,    // Low 32 bits or r8
-        lldb_r9d_x86_64,    // Low 32 bits or r9
-        lldb_r10d_x86_64,   // Low 32 bits or r10
-        lldb_r11d_x86_64,   // Low 32 bits or r11
-        lldb_r12d_x86_64,   // Low 32 bits or r12
-        lldb_r13d_x86_64,   // Low 32 bits or r13
-        lldb_r14d_x86_64,   // Low 32 bits or r14
-        lldb_r15d_x86_64,   // Low 32 bits or r15
-        lldb_ax_x86_64,
-        lldb_bx_x86_64,
-        lldb_cx_x86_64,
-        lldb_dx_x86_64,
-        lldb_di_x86_64,
-        lldb_si_x86_64,
-        lldb_bp_x86_64,
-        lldb_sp_x86_64,
-        lldb_r8w_x86_64,    // Low 16 bits or r8
-        lldb_r9w_x86_64,    // Low 16 bits or r9
-        lldb_r10w_x86_64,   // Low 16 bits or r10
-        lldb_r11w_x86_64,   // Low 16 bits or r11
-        lldb_r12w_x86_64,   // Low 16 bits or r12
-        lldb_r13w_x86_64,   // Low 16 bits or r13
-        lldb_r14w_x86_64,   // Low 16 bits or r14
-        lldb_r15w_x86_64,   // Low 16 bits or r15
-        lldb_ah_x86_64,
-        lldb_bh_x86_64,
-        lldb_ch_x86_64,
-        lldb_dh_x86_64,
-        lldb_al_x86_64,
-        lldb_bl_x86_64,
-        lldb_cl_x86_64,
-        lldb_dl_x86_64,
-        lldb_dil_x86_64,
-        lldb_sil_x86_64,
-        lldb_bpl_x86_64,
-        lldb_spl_x86_64,
-        lldb_r8l_x86_64,    // Low 8 bits or r8
-        lldb_r9l_x86_64,    // Low 8 bits or r9
-        lldb_r10l_x86_64,   // Low 8 bits or r10
-        lldb_r11l_x86_64,   // Low 8 bits or r11
-        lldb_r12l_x86_64,   // Low 8 bits or r12
-        lldb_r13l_x86_64,   // Low 8 bits or r13
-        lldb_r14l_x86_64,   // Low 8 bits or r14
-        lldb_r15l_x86_64,   // Low 8 bits or r15
-        LLDB_INVALID_REGNUM // register sets need to end with this flag
-    };
-    static_assert((sizeof(g_gpr_regnums_x86_64) / sizeof(g_gpr_regnums_x86_64[0])) - 1 == k_num_gpr_registers_x86_64,
-                  "g_gpr_regnums_x86_64 has wrong number of register infos");
-
-    // x86 64-bit floating point registers.
-    static const uint32_t
-    g_fpu_regnums_x86_64[] =
-    {
-        lldb_fctrl_x86_64,
-        lldb_fstat_x86_64,
-        lldb_ftag_x86_64,
-        lldb_fop_x86_64,
-        lldb_fiseg_x86_64,
-        lldb_fioff_x86_64,
-        lldb_foseg_x86_64,
-        lldb_fooff_x86_64,
-        lldb_mxcsr_x86_64,
-        lldb_mxcsrmask_x86_64,
-        lldb_st0_x86_64,
-        lldb_st1_x86_64,
-        lldb_st2_x86_64,
-        lldb_st3_x86_64,
-        lldb_st4_x86_64,
-        lldb_st5_x86_64,
-        lldb_st6_x86_64,
-        lldb_st7_x86_64,
-        lldb_mm0_x86_64,
-        lldb_mm1_x86_64,
-        lldb_mm2_x86_64,
-        lldb_mm3_x86_64,
-        lldb_mm4_x86_64,
-        lldb_mm5_x86_64,
-        lldb_mm6_x86_64,
-        lldb_mm7_x86_64,
-        lldb_xmm0_x86_64,
-        lldb_xmm1_x86_64,
-        lldb_xmm2_x86_64,
-        lldb_xmm3_x86_64,
-        lldb_xmm4_x86_64,
-        lldb_xmm5_x86_64,
-        lldb_xmm6_x86_64,
-        lldb_xmm7_x86_64,
-        lldb_xmm8_x86_64,
-        lldb_xmm9_x86_64,
-        lldb_xmm10_x86_64,
-        lldb_xmm11_x86_64,
-        lldb_xmm12_x86_64,
-        lldb_xmm13_x86_64,
-        lldb_xmm14_x86_64,
-        lldb_xmm15_x86_64,
-        LLDB_INVALID_REGNUM // register sets need to end with this flag
-    };
-    static_assert((sizeof(g_fpu_regnums_x86_64) / sizeof(g_fpu_regnums_x86_64[0])) - 1 == k_num_fpr_registers_x86_64,
-                  "g_fpu_regnums_x86_64 has wrong number of register infos");
-
-    // x86 64-bit AVX registers.
-    static const uint32_t
-    g_avx_regnums_x86_64[] =
-    {
-        lldb_ymm0_x86_64,
-        lldb_ymm1_x86_64,
-        lldb_ymm2_x86_64,
-        lldb_ymm3_x86_64,
-        lldb_ymm4_x86_64,
-        lldb_ymm5_x86_64,
-        lldb_ymm6_x86_64,
-        lldb_ymm7_x86_64,
-        lldb_ymm8_x86_64,
-        lldb_ymm9_x86_64,
-        lldb_ymm10_x86_64,
-        lldb_ymm11_x86_64,
-        lldb_ymm12_x86_64,
-        lldb_ymm13_x86_64,
-        lldb_ymm14_x86_64,
-        lldb_ymm15_x86_64,
-        LLDB_INVALID_REGNUM // register sets need to end with this flag
-    };
-    static_assert((sizeof(g_avx_regnums_x86_64) / sizeof(g_avx_regnums_x86_64[0])) - 1 == k_num_avx_registers_x86_64,
-                  "g_avx_regnums_x86_64 has wrong number of register infos");
-
-    // Number of register sets provided by this context.
-    enum
-    {
-        k_num_extended_register_sets = 1,
-        k_num_register_sets = 3
-    };
-
-    // Register sets for x86 32-bit.
-    static const RegisterSet
-    g_reg_sets_i386[k_num_register_sets] =
-    {
-        { "General Purpose Registers",  "gpr", k_num_gpr_registers_i386, g_gpr_regnums_i386 },
-        { "Floating Point Registers",   "fpu", k_num_fpr_registers_i386, g_fpu_regnums_i386 },
-        { "Advanced Vector Extensions", "avx", k_num_avx_registers_i386, g_avx_regnums_i386 }
-    };
-
-    // Register sets for x86 64-bit.
-    static const RegisterSet
-    g_reg_sets_x86_64[k_num_register_sets] =
-    {
-        { "General Purpose Registers",  "gpr", k_num_gpr_registers_x86_64, g_gpr_regnums_x86_64 },
-        { "Floating Point Registers",   "fpu", k_num_fpr_registers_x86_64, g_fpu_regnums_x86_64 },
-        { "Advanced Vector Extensions", "avx", k_num_avx_registers_x86_64, g_avx_regnums_x86_64 }
-    };
+namespace {
+// x86 32-bit general purpose registers.
+const uint32_t g_gpr_regnums_i386[] = {
+    lldb_eax_i386,      lldb_ebx_i386,    lldb_ecx_i386, lldb_edx_i386,
+    lldb_edi_i386,      lldb_esi_i386,    lldb_ebp_i386, lldb_esp_i386,
+    lldb_eip_i386,      lldb_eflags_i386, lldb_cs_i386,  lldb_fs_i386,
+    lldb_gs_i386,       lldb_ss_i386,     lldb_ds_i386,  lldb_es_i386,
+    lldb_ax_i386,       lldb_bx_i386,     lldb_cx_i386,  lldb_dx_i386,
+    lldb_di_i386,       lldb_si_i386,     lldb_bp_i386,  lldb_sp_i386,
+    lldb_ah_i386,       lldb_bh_i386,     lldb_ch_i386,  lldb_dh_i386,
+    lldb_al_i386,       lldb_bl_i386,     lldb_cl_i386,  lldb_dl_i386,
+    LLDB_INVALID_REGNUM // register sets need to end with this flag
+};
+static_assert((sizeof(g_gpr_regnums_i386) / sizeof(g_gpr_regnums_i386[0])) -
+                      1 ==
+                  k_num_gpr_registers_i386,
+              "g_gpr_regnums_i386 has wrong number of register infos");
+
+// x86 32-bit floating point registers.
+const uint32_t g_fpu_regnums_i386[] = {
+    lldb_fctrl_i386,    lldb_fstat_i386,     lldb_ftag_i386,  lldb_fop_i386,
+    lldb_fiseg_i386,    lldb_fioff_i386,     lldb_foseg_i386, lldb_fooff_i386,
+    lldb_mxcsr_i386,    lldb_mxcsrmask_i386, lldb_st0_i386,   lldb_st1_i386,
+    lldb_st2_i386,      lldb_st3_i386,       lldb_st4_i386,   lldb_st5_i386,
+    lldb_st6_i386,      lldb_st7_i386,       lldb_mm0_i386,   lldb_mm1_i386,
+    lldb_mm2_i386,      lldb_mm3_i386,       lldb_mm4_i386,   lldb_mm5_i386,
+    lldb_mm6_i386,      lldb_mm7_i386,       lldb_xmm0_i386,  lldb_xmm1_i386,
+    lldb_xmm2_i386,     lldb_xmm3_i386,      lldb_xmm4_i386,  lldb_xmm5_i386,
+    lldb_xmm6_i386,     lldb_xmm7_i386,
+    LLDB_INVALID_REGNUM // register sets need to end with this flag
+};
+static_assert((sizeof(g_fpu_regnums_i386) / sizeof(g_fpu_regnums_i386[0])) -
+                      1 ==
+                  k_num_fpr_registers_i386,
+              "g_fpu_regnums_i386 has wrong number of register infos");
+
+// x86 32-bit AVX registers.
+const uint32_t g_avx_regnums_i386[] = {
+    lldb_ymm0_i386,     lldb_ymm1_i386, lldb_ymm2_i386, lldb_ymm3_i386,
+    lldb_ymm4_i386,     lldb_ymm5_i386, lldb_ymm6_i386, lldb_ymm7_i386,
+    LLDB_INVALID_REGNUM // register sets need to end with this flag
+};
+static_assert((sizeof(g_avx_regnums_i386) / sizeof(g_avx_regnums_i386[0])) -
+                      1 ==
+                  k_num_avx_registers_i386,
+              " g_avx_regnums_i386 has wrong number of register infos");
+
+// x86 64-bit general purpose registers.
+static const uint32_t g_gpr_regnums_x86_64[] = {
+    lldb_rax_x86_64,    lldb_rbx_x86_64,    lldb_rcx_x86_64, lldb_rdx_x86_64,
+    lldb_rdi_x86_64,    lldb_rsi_x86_64,    lldb_rbp_x86_64, lldb_rsp_x86_64,
+    lldb_r8_x86_64,     lldb_r9_x86_64,     lldb_r10_x86_64, lldb_r11_x86_64,
+    lldb_r12_x86_64,    lldb_r13_x86_64,    lldb_r14_x86_64, lldb_r15_x86_64,
+    lldb_rip_x86_64,    lldb_rflags_x86_64, lldb_cs_x86_64,  lldb_fs_x86_64,
+    lldb_gs_x86_64,     lldb_ss_x86_64,     lldb_ds_x86_64,  lldb_es_x86_64,
+    lldb_eax_x86_64,    lldb_ebx_x86_64,    lldb_ecx_x86_64, lldb_edx_x86_64,
+    lldb_edi_x86_64,    lldb_esi_x86_64,    lldb_ebp_x86_64, lldb_esp_x86_64,
+    lldb_r8d_x86_64,  // Low 32 bits or r8
+    lldb_r9d_x86_64,  // Low 32 bits or r9
+    lldb_r10d_x86_64, // Low 32 bits or r10
+    lldb_r11d_x86_64, // Low 32 bits or r11
+    lldb_r12d_x86_64, // Low 32 bits or r12
+    lldb_r13d_x86_64, // Low 32 bits or r13
+    lldb_r14d_x86_64, // Low 32 bits or r14
+    lldb_r15d_x86_64, // Low 32 bits or r15
+    lldb_ax_x86_64,     lldb_bx_x86_64,     lldb_cx_x86_64,  lldb_dx_x86_64,
+    lldb_di_x86_64,     lldb_si_x86_64,     lldb_bp_x86_64,  lldb_sp_x86_64,
+    lldb_r8w_x86_64,  // Low 16 bits or r8
+    lldb_r9w_x86_64,  // Low 16 bits or r9
+    lldb_r10w_x86_64, // Low 16 bits or r10
+    lldb_r11w_x86_64, // Low 16 bits or r11
+    lldb_r12w_x86_64, // Low 16 bits or r12
+    lldb_r13w_x86_64, // Low 16 bits or r13
+    lldb_r14w_x86_64, // Low 16 bits or r14
+    lldb_r15w_x86_64, // Low 16 bits or r15
+    lldb_ah_x86_64,     lldb_bh_x86_64,     lldb_ch_x86_64,  lldb_dh_x86_64,
+    lldb_al_x86_64,     lldb_bl_x86_64,     lldb_cl_x86_64,  lldb_dl_x86_64,
+    lldb_dil_x86_64,    lldb_sil_x86_64,    lldb_bpl_x86_64, lldb_spl_x86_64,
+    lldb_r8l_x86_64,    // Low 8 bits or r8
+    lldb_r9l_x86_64,    // Low 8 bits or r9
+    lldb_r10l_x86_64,   // Low 8 bits or r10
+    lldb_r11l_x86_64,   // Low 8 bits or r11
+    lldb_r12l_x86_64,   // Low 8 bits or r12
+    lldb_r13l_x86_64,   // Low 8 bits or r13
+    lldb_r14l_x86_64,   // Low 8 bits or r14
+    lldb_r15l_x86_64,   // Low 8 bits or r15
+    LLDB_INVALID_REGNUM // register sets need to end with this flag
+};
+static_assert((sizeof(g_gpr_regnums_x86_64) / sizeof(g_gpr_regnums_x86_64[0])) -
+                      1 ==
+                  k_num_gpr_registers_x86_64,
+              "g_gpr_regnums_x86_64 has wrong number of register infos");
+
+// x86 64-bit floating point registers.
+static const uint32_t g_fpu_regnums_x86_64[] = {
+    lldb_fctrl_x86_64,     lldb_fstat_x86_64, lldb_ftag_x86_64,
+    lldb_fop_x86_64,       lldb_fiseg_x86_64, lldb_fioff_x86_64,
+    lldb_foseg_x86_64,     lldb_fooff_x86_64, lldb_mxcsr_x86_64,
+    lldb_mxcsrmask_x86_64, lldb_st0_x86_64,   lldb_st1_x86_64,
+    lldb_st2_x86_64,       lldb_st3_x86_64,   lldb_st4_x86_64,
+    lldb_st5_x86_64,       lldb_st6_x86_64,   lldb_st7_x86_64,
+    lldb_mm0_x86_64,       lldb_mm1_x86_64,   lldb_mm2_x86_64,
+    lldb_mm3_x86_64,       lldb_mm4_x86_64,   lldb_mm5_x86_64,
+    lldb_mm6_x86_64,       lldb_mm7_x86_64,   lldb_xmm0_x86_64,
+    lldb_xmm1_x86_64,      lldb_xmm2_x86_64,  lldb_xmm3_x86_64,
+    lldb_xmm4_x86_64,      lldb_xmm5_x86_64,  lldb_xmm6_x86_64,
+    lldb_xmm7_x86_64,      lldb_xmm8_x86_64,  lldb_xmm9_x86_64,
+    lldb_xmm10_x86_64,     lldb_xmm11_x86_64, lldb_xmm12_x86_64,
+    lldb_xmm13_x86_64,     lldb_xmm14_x86_64, lldb_xmm15_x86_64,
+    LLDB_INVALID_REGNUM // register sets need to end with this flag
+};
+static_assert((sizeof(g_fpu_regnums_x86_64) / sizeof(g_fpu_regnums_x86_64[0])) -
+                      1 ==
+                  k_num_fpr_registers_x86_64,
+              "g_fpu_regnums_x86_64 has wrong number of register infos");
+
+// x86 64-bit AVX registers.
+static const uint32_t g_avx_regnums_x86_64[] = {
+    lldb_ymm0_x86_64,   lldb_ymm1_x86_64,  lldb_ymm2_x86_64,  lldb_ymm3_x86_64,
+    lldb_ymm4_x86_64,   lldb_ymm5_x86_64,  lldb_ymm6_x86_64,  lldb_ymm7_x86_64,
+    lldb_ymm8_x86_64,   lldb_ymm9_x86_64,  lldb_ymm10_x86_64, lldb_ymm11_x86_64,
+    lldb_ymm12_x86_64,  lldb_ymm13_x86_64, lldb_ymm14_x86_64, lldb_ymm15_x86_64,
+    LLDB_INVALID_REGNUM // register sets need to end with this flag
+};
+static_assert((sizeof(g_avx_regnums_x86_64) / sizeof(g_avx_regnums_x86_64[0])) -
+                      1 ==
+                  k_num_avx_registers_x86_64,
+              "g_avx_regnums_x86_64 has wrong number of register infos");
+
+// Number of register sets provided by this context.
+enum { k_num_extended_register_sets = 1, k_num_register_sets = 3 };
+
+// Register sets for x86 32-bit.
+static const RegisterSet g_reg_sets_i386[k_num_register_sets] = {
+    {"General Purpose Registers", "gpr", k_num_gpr_registers_i386,
+     g_gpr_regnums_i386},
+    {"Floating Point Registers", "fpu", k_num_fpr_registers_i386,
+     g_fpu_regnums_i386},
+    {"Advanced Vector Extensions", "avx", k_num_avx_registers_i386,
+     g_avx_regnums_i386}};
+
+// Register sets for x86 64-bit.
+static const RegisterSet g_reg_sets_x86_64[k_num_register_sets] = {
+    {"General Purpose Registers", "gpr", k_num_gpr_registers_x86_64,
+     g_gpr_regnums_x86_64},
+    {"Floating Point Registers", "fpu", k_num_fpr_registers_x86_64,
+     g_fpu_regnums_x86_64},
+    {"Advanced Vector Extensions", "avx", k_num_avx_registers_x86_64,
+     g_avx_regnums_x86_64}};
 }
 
-#define REG_CONTEXT_SIZE (GetRegisterInfoInterface ().GetGPRSize () + sizeof(FPR))
+#define REG_CONTEXT_SIZE (GetRegisterInfoInterface().GetGPRSize() + sizeof(FPR))
 
 // ----------------------------------------------------------------------------
 // Required ptrace defines.
@@ -331,909 +192,890 @@ namespace
 #define NT_PRXFPREG 0x46e62b7f
 #endif
 
-NativeRegisterContextLinux*
-NativeRegisterContextLinux::CreateHostNativeRegisterContextLinux(const ArchSpec& target_arch,
-                                                                 NativeThreadProtocol &native_thread,
-                                                                 uint32_t concrete_frame_idx)
-{
-    return new NativeRegisterContextLinux_x86_64(target_arch, native_thread, concrete_frame_idx);
+NativeRegisterContextLinux *
+NativeRegisterContextLinux::CreateHostNativeRegisterContextLinux(
+    const ArchSpec &target_arch, NativeThreadProtocol &native_thread,
+    uint32_t concrete_frame_idx) {
+  return new NativeRegisterContextLinux_x86_64(target_arch, native_thread,
+                                               concrete_frame_idx);
 }
 
 // ----------------------------------------------------------------------------
 // NativeRegisterContextLinux_x86_64 members.
 // ----------------------------------------------------------------------------
 
-static RegisterInfoInterface*
-CreateRegisterInfoInterface(const ArchSpec& target_arch)
-{
-    if (HostInfo::GetArchitecture().GetAddressByteSize() == 4)
-    {
-        // 32-bit hosts run with a RegisterContextLinux_i386 context.
-        return new RegisterContextLinux_i386(target_arch);
-    }
-    else
-    {
-        assert((HostInfo::GetArchitecture().GetAddressByteSize() == 8) &&
-               "Register setting path assumes this is a 64-bit host");
-        // X86_64 hosts know how to work with 64-bit and 32-bit EXEs using the x86_64 register context.
-        return new RegisterContextLinux_x86_64 (target_arch);
-    }
-}
-
-NativeRegisterContextLinux_x86_64::NativeRegisterContextLinux_x86_64 (const ArchSpec& target_arch,
-                                                                      NativeThreadProtocol &native_thread,
-                                                                      uint32_t concrete_frame_idx) :
-    NativeRegisterContextLinux (native_thread, concrete_frame_idx, CreateRegisterInfoInterface(target_arch)),
-    m_fpr_type (eFPRTypeNotValid),
-    m_fpr (),
-    m_iovec (),
-    m_ymm_set (),
-    m_reg_info (),
-    m_gpr_x86_64 ()
-{
-    // Set up data about ranges of valid registers.
-    switch (target_arch.GetMachine ())
-    {
-        case llvm::Triple::x86:
-            m_reg_info.num_registers        = k_num_registers_i386;
-            m_reg_info.num_gpr_registers    = k_num_gpr_registers_i386;
-            m_reg_info.num_fpr_registers    = k_num_fpr_registers_i386;
-            m_reg_info.num_avx_registers    = k_num_avx_registers_i386;
-            m_reg_info.last_gpr             = k_last_gpr_i386;
-            m_reg_info.first_fpr            = k_first_fpr_i386;
-            m_reg_info.last_fpr             = k_last_fpr_i386;
-            m_reg_info.first_st             = lldb_st0_i386;
-            m_reg_info.last_st              = lldb_st7_i386;
-            m_reg_info.first_mm             = lldb_mm0_i386;
-            m_reg_info.last_mm              = lldb_mm7_i386;
-            m_reg_info.first_xmm            = lldb_xmm0_i386;
-            m_reg_info.last_xmm             = lldb_xmm7_i386;
-            m_reg_info.first_ymm            = lldb_ymm0_i386;
-            m_reg_info.last_ymm             = lldb_ymm7_i386;
-            m_reg_info.first_dr             = lldb_dr0_i386;
-            m_reg_info.gpr_flags            = lldb_eflags_i386;
-            break;
-        case llvm::Triple::x86_64:
-            m_reg_info.num_registers        = k_num_registers_x86_64;
-            m_reg_info.num_gpr_registers    = k_num_gpr_registers_x86_64;
-            m_reg_info.num_fpr_registers    = k_num_fpr_registers_x86_64;
-            m_reg_info.num_avx_registers    = k_num_avx_registers_x86_64;
-            m_reg_info.last_gpr             = k_last_gpr_x86_64;
-            m_reg_info.first_fpr            = k_first_fpr_x86_64;
-            m_reg_info.last_fpr             = k_last_fpr_x86_64;
-            m_reg_info.first_st             = lldb_st0_x86_64;
-            m_reg_info.last_st              = lldb_st7_x86_64;
-            m_reg_info.first_mm             = lldb_mm0_x86_64;
-            m_reg_info.last_mm              = lldb_mm7_x86_64;
-            m_reg_info.first_xmm            = lldb_xmm0_x86_64;
-            m_reg_info.last_xmm             = lldb_xmm15_x86_64;
-            m_reg_info.first_ymm            = lldb_ymm0_x86_64;
-            m_reg_info.last_ymm             = lldb_ymm15_x86_64;
-            m_reg_info.first_dr             = lldb_dr0_x86_64;
-            m_reg_info.gpr_flags            = lldb_rflags_x86_64;
-            break;
-        default:
-            assert(false && "Unhandled target architecture.");
-            break;
-    }
-
-    // Initialize m_iovec to point to the buffer and buffer size
-    // using the conventions of Berkeley style UIO structures, as required
-    // by PTRACE extensions.
-    m_iovec.iov_base = &m_fpr.xstate.xsave;
-    m_iovec.iov_len = sizeof(m_fpr.xstate.xsave);
-
-    // Clear out the FPR state.
-    ::memset(&m_fpr, 0, sizeof(FPR));
-
-    // Store byte offset of fctrl (i.e. first register of FPR)
-    const RegisterInfo *reg_info_fctrl = GetRegisterInfoByName("fctrl");
-    m_fctrl_offset_in_userarea = reg_info_fctrl->byte_offset;
+static RegisterInfoInterface *
+CreateRegisterInfoInterface(const ArchSpec &target_arch) {
+  if (HostInfo::GetArchitecture().GetAddressByteSize() == 4) {
+    // 32-bit hosts run with a RegisterContextLinux_i386 context.
+    return new RegisterContextLinux_i386(target_arch);
+  } else {
+    assert((HostInfo::GetArchitecture().GetAddressByteSize() == 8) &&
+           "Register setting path assumes this is a 64-bit host");
+    // X86_64 hosts know how to work with 64-bit and 32-bit EXEs using the
+    // x86_64 register context.
+    return new RegisterContextLinux_x86_64(target_arch);
+  }
+}
+
+NativeRegisterContextLinux_x86_64::NativeRegisterContextLinux_x86_64(
+    const ArchSpec &target_arch, NativeThreadProtocol &native_thread,
+    uint32_t concrete_frame_idx)
+    : NativeRegisterContextLinux(native_thread, concrete_frame_idx,
+                                 CreateRegisterInfoInterface(target_arch)),
+      m_fpr_type(eFPRTypeNotValid), m_fpr(), m_iovec(), m_ymm_set(),
+      m_reg_info(), m_gpr_x86_64() {
+  // Set up data about ranges of valid registers.
+  switch (target_arch.GetMachine()) {
+  case llvm::Triple::x86:
+    m_reg_info.num_registers = k_num_registers_i386;
+    m_reg_info.num_gpr_registers = k_num_gpr_registers_i386;
+    m_reg_info.num_fpr_registers = k_num_fpr_registers_i386;
+    m_reg_info.num_avx_registers = k_num_avx_registers_i386;
+    m_reg_info.last_gpr = k_last_gpr_i386;
+    m_reg_info.first_fpr = k_first_fpr_i386;
+    m_reg_info.last_fpr = k_last_fpr_i386;
+    m_reg_info.first_st = lldb_st0_i386;
+    m_reg_info.last_st = lldb_st7_i386;
+    m_reg_info.first_mm = lldb_mm0_i386;
+    m_reg_info.last_mm = lldb_mm7_i386;
+    m_reg_info.first_xmm = lldb_xmm0_i386;
+    m_reg_info.last_xmm = lldb_xmm7_i386;
+    m_reg_info.first_ymm = lldb_ymm0_i386;
+    m_reg_info.last_ymm = lldb_ymm7_i386;
+    m_reg_info.first_dr = lldb_dr0_i386;
+    m_reg_info.gpr_flags = lldb_eflags_i386;
+    break;
+  case llvm::Triple::x86_64:
+    m_reg_info.num_registers = k_num_registers_x86_64;
+    m_reg_info.num_gpr_registers = k_num_gpr_registers_x86_64;
+    m_reg_info.num_fpr_registers = k_num_fpr_registers_x86_64;
+    m_reg_info.num_avx_registers = k_num_avx_registers_x86_64;
+    m_reg_info.last_gpr = k_last_gpr_x86_64;
+    m_reg_info.first_fpr = k_first_fpr_x86_64;
+    m_reg_info.last_fpr = k_last_fpr_x86_64;
+    m_reg_info.first_st = lldb_st0_x86_64;
+    m_reg_info.last_st = lldb_st7_x86_64;
+    m_reg_info.first_mm = lldb_mm0_x86_64;
+    m_reg_info.last_mm = lldb_mm7_x86_64;
+    m_reg_info.first_xmm = lldb_xmm0_x86_64;
+    m_reg_info.last_xmm = lldb_xmm15_x86_64;
+    m_reg_info.first_ymm = lldb_ymm0_x86_64;
+    m_reg_info.last_ymm = lldb_ymm15_x86_64;
+    m_reg_info.first_dr = lldb_dr0_x86_64;
+    m_reg_info.gpr_flags = lldb_rflags_x86_64;
+    break;
+  default:
+    assert(false && "Unhandled target architecture.");
+    break;
+  }
+
+  // Initialize m_iovec to point to the buffer and buffer size
+  // using the conventions of Berkeley style UIO structures, as required
+  // by PTRACE extensions.
+  m_iovec.iov_base = &m_fpr.xstate.xsave;
+  m_iovec.iov_len = sizeof(m_fpr.xstate.xsave);
+
+  // Clear out the FPR state.
+  ::memset(&m_fpr, 0, sizeof(FPR));
+
+  // Store byte offset of fctrl (i.e. first register of FPR)
+  const RegisterInfo *reg_info_fctrl = GetRegisterInfoByName("fctrl");
+  m_fctrl_offset_in_userarea = reg_info_fctrl->byte_offset;
 }
 
 // CONSIDER after local and llgs debugging are merged, register set support can
 // be moved into a base x86-64 class with IsRegisterSetAvailable made virtual.
-uint32_t
-NativeRegisterContextLinux_x86_64::GetRegisterSetCount () const
-{
-    uint32_t sets = 0;
-    for (uint32_t set_index = 0; set_index < k_num_register_sets; ++set_index)
-    {
-        if (IsRegisterSetAvailable (set_index))
-            ++sets;
-    }
-
-    return sets;
-}
-
-uint32_t
-NativeRegisterContextLinux_x86_64::GetUserRegisterCount() const
-{
-    uint32_t count = 0;
-    for (uint32_t set_index = 0; set_index < k_num_register_sets; ++set_index)
-    {
-        const RegisterSet* set = GetRegisterSet(set_index);
-        if (set)
-            count += set->num_registers;
-    }
-    return count;
+uint32_t NativeRegisterContextLinux_x86_64::GetRegisterSetCount() const {
+  uint32_t sets = 0;
+  for (uint32_t set_index = 0; set_index < k_num_register_sets; ++set_index) {
+    if (IsRegisterSetAvailable(set_index))
+      ++sets;
+  }
+
+  return sets;
+}
+
+uint32_t NativeRegisterContextLinux_x86_64::GetUserRegisterCount() const {
+  uint32_t count = 0;
+  for (uint32_t set_index = 0; set_index < k_num_register_sets; ++set_index) {
+    const RegisterSet *set = GetRegisterSet(set_index);
+    if (set)
+      count += set->num_registers;
+  }
+  return count;
 }
 
 const RegisterSet *
-NativeRegisterContextLinux_x86_64::GetRegisterSet (uint32_t set_index) const
-{
-    if (!IsRegisterSetAvailable (set_index))
-        return nullptr;
-
-    switch (GetRegisterInfoInterface ().GetTargetArchitecture ().GetMachine ())
-    {
-        case llvm::Triple::x86:
-            return &g_reg_sets_i386[set_index];
-        case llvm::Triple::x86_64:
-            return &g_reg_sets_x86_64[set_index];
-        default:
-            assert (false && "Unhandled target architecture.");
-            return nullptr;
-    }
+NativeRegisterContextLinux_x86_64::GetRegisterSet(uint32_t set_index) const {
+  if (!IsRegisterSetAvailable(set_index))
+    return nullptr;
 
+  switch (GetRegisterInfoInterface().GetTargetArchitecture().GetMachine()) {
+  case llvm::Triple::x86:
+    return &g_reg_sets_i386[set_index];
+  case llvm::Triple::x86_64:
+    return &g_reg_sets_x86_64[set_index];
+  default:
+    assert(false && "Unhandled target architecture.");
     return nullptr;
-}
+  }
 
-Error
-NativeRegisterContextLinux_x86_64::ReadRegister (const RegisterInfo *reg_info, RegisterValue &reg_value)
-{
-    Error error;
-
-    if (!reg_info)
-    {
-        error.SetErrorString ("reg_info NULL");
-        return error;
-    }
+  return nullptr;
+}
 
-    const uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];
-    if (reg == LLDB_INVALID_REGNUM)
-    {
-        // This is likely an internal register for lldb use only and should not be directly queried.
-        error.SetErrorStringWithFormat ("register \"%s\" is an internal-only lldb register, cannot read directly", reg_info->name);
-        return error;
-    }
+Error NativeRegisterContextLinux_x86_64::ReadRegister(
+    const RegisterInfo *reg_info, RegisterValue &reg_value) {
+  Error error;
 
-    if (IsFPR(reg, GetFPRType()))
-    {
-        error = ReadFPR();
-        if (error.Fail())
-            return error;
-    }
-    else
-    {
-        uint32_t full_reg = reg;
-        bool is_subreg = reg_info->invalidate_regs && (reg_info->invalidate_regs[0] != LLDB_INVALID_REGNUM);
-
-        if (is_subreg)
-        {
-            // Read the full aligned 64-bit register.
-            full_reg = reg_info->invalidate_regs[0];
-        }
+  if (!reg_info) {
+    error.SetErrorString("reg_info NULL");
+    return error;
+  }
 
-        error = ReadRegisterRaw(full_reg, reg_value);
+  const uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];
+  if (reg == LLDB_INVALID_REGNUM) {
+    // This is likely an internal register for lldb use only and should not be
+    // directly queried.
+    error.SetErrorStringWithFormat("register \"%s\" is an internal-only lldb "
+                                   "register, cannot read directly",
+                                   reg_info->name);
+    return error;
+  }
 
-        if (error.Success ())
-        {
-            // If our read was not aligned (for ah,bh,ch,dh), shift our returned value one byte to the right.
-            if (is_subreg && (reg_info->byte_offset & 0x1))
-                reg_value.SetUInt64(reg_value.GetAsUInt64() >> 8);
-
-            // If our return byte size was greater than the return value reg size, then
-            // use the type specified by reg_info rather than the uint64_t default
-            if (reg_value.GetByteSize() > reg_info->byte_size)
-                reg_value.SetType(reg_info);
-        }
-        return error;
+  if (IsFPR(reg, GetFPRType())) {
+    error = ReadFPR();
+    if (error.Fail())
+      return error;
+  } else {
+    uint32_t full_reg = reg;
+    bool is_subreg = reg_info->invalidate_regs &&
+                     (reg_info->invalidate_regs[0] != LLDB_INVALID_REGNUM);
+
+    if (is_subreg) {
+      // Read the full aligned 64-bit register.
+      full_reg = reg_info->invalidate_regs[0];
+    }
+
+    error = ReadRegisterRaw(full_reg, reg_value);
+
+    if (error.Success()) {
+      // If our read was not aligned (for ah,bh,ch,dh), shift our returned value
+      // one byte to the right.
+      if (is_subreg && (reg_info->byte_offset & 0x1))
+        reg_value.SetUInt64(reg_value.GetAsUInt64() >> 8);
+
+      // If our return byte size was greater than the return value reg size,
+      // then
+      // use the type specified by reg_info rather than the uint64_t default
+      if (reg_value.GetByteSize() > reg_info->byte_size)
+        reg_value.SetType(reg_info);
     }
+    return error;
+  }
 
-    if (reg_info->encoding == lldb::eEncodingVector)
-    {
-        lldb::ByteOrder byte_order = GetByteOrder();
-
-        if (byte_order != lldb::eByteOrderInvalid)
-        {
-            if (reg >= m_reg_info.first_st && reg <= m_reg_info.last_st)
-                reg_value.SetBytes(m_fpr.xstate.fxsave.stmm[reg - m_reg_info.first_st].bytes, reg_info->byte_size, byte_order);
-            if (reg >= m_reg_info.first_mm && reg <= m_reg_info.last_mm)
-                reg_value.SetBytes(m_fpr.xstate.fxsave.stmm[reg - m_reg_info.first_mm].bytes, reg_info->byte_size, byte_order);
-            if (reg >= m_reg_info.first_xmm && reg <= m_reg_info.last_xmm)
-                reg_value.SetBytes(m_fpr.xstate.fxsave.xmm[reg - m_reg_info.first_xmm].bytes, reg_info->byte_size, byte_order);
-            if (reg >= m_reg_info.first_ymm && reg <= m_reg_info.last_ymm)
-            {
-                // Concatenate ymm using the register halves in xmm.bytes and ymmh.bytes
-                if (GetFPRType() == eFPRTypeXSAVE && CopyXSTATEtoYMM(reg, byte_order))
-                    reg_value.SetBytes(m_ymm_set.ymm[reg - m_reg_info.first_ymm].bytes, reg_info->byte_size, byte_order);
-                else
-                {
-                    error.SetErrorString ("failed to copy ymm register value");
-                    return error;
-                }
-            }
-
-            if (reg_value.GetType() != RegisterValue::eTypeBytes)
-                error.SetErrorString ("write failed - type was expected to be RegisterValue::eTypeBytes");
+  if (reg_info->encoding == lldb::eEncodingVector) {
+    lldb::ByteOrder byte_order = GetByteOrder();
 
-            return error;
+    if (byte_order != lldb::eByteOrderInvalid) {
+      if (reg >= m_reg_info.first_st && reg <= m_reg_info.last_st)
+        reg_value.SetBytes(
+            m_fpr.xstate.fxsave.stmm[reg - m_reg_info.first_st].bytes,
+            reg_info->byte_size, byte_order);
+      if (reg >= m_reg_info.first_mm && reg <= m_reg_info.last_mm)
+        reg_value.SetBytes(
+            m_fpr.xstate.fxsave.stmm[reg - m_reg_info.first_mm].bytes,
+            reg_info->byte_size, byte_order);
+      if (reg >= m_reg_info.first_xmm && reg <= m_reg_info.last_xmm)
+        reg_value.SetBytes(
+            m_fpr.xstate.fxsave.xmm[reg - m_reg_info.first_xmm].bytes,
+            reg_info->byte_size, byte_order);
+      if (reg >= m_reg_info.first_ymm && reg <= m_reg_info.last_ymm) {
+        // Concatenate ymm using the register halves in xmm.bytes and ymmh.bytes
+        if (GetFPRType() == eFPRTypeXSAVE && CopyXSTATEtoYMM(reg, byte_order))
+          reg_value.SetBytes(m_ymm_set.ymm[reg - m_reg_info.first_ymm].bytes,
+                             reg_info->byte_size, byte_order);
+        else {
+          error.SetErrorString("failed to copy ymm register value");
+          return error;
         }
+      }
 
-        error.SetErrorString ("byte order is invalid");
-        return error;
-    }
-
-    // Get pointer to m_fpr.xstate.fxsave variable and set the data from it.
+      if (reg_value.GetType() != RegisterValue::eTypeBytes)
+        error.SetErrorString(
+            "write failed - type was expected to be RegisterValue::eTypeBytes");
 
-    // Byte offsets of all registers are calculated wrt 'UserArea' structure.
-    // However, ReadFPR() reads fpu registers {using ptrace(PTRACE_GETFPREGS,..)}
-    // and stores them in 'm_fpr' (of type FPR structure). To extract values of fpu
-    // registers, m_fpr should be read at byte offsets calculated wrt to FPR structure.
-
-    // Since, FPR structure is also one of the member of UserArea structure.
-    // byte_offset(fpu wrt FPR) = byte_offset(fpu wrt UserArea) - byte_offset(fctrl wrt UserArea)
-    assert ( (reg_info->byte_offset - m_fctrl_offset_in_userarea) < sizeof(m_fpr));
-    uint8_t *src = (uint8_t *)&m_fpr + reg_info->byte_offset - m_fctrl_offset_in_userarea;
-    switch (reg_info->byte_size)
-    {
-        case 1:
-            reg_value.SetUInt8(*(uint8_t *)src);
-            break;
-        case 2:
-            reg_value.SetUInt16(*(uint16_t *)src);
-            break;
-        case 4:
-            reg_value.SetUInt32(*(uint32_t *)src);
-            break;
-        case 8:
-            reg_value.SetUInt64(*(uint64_t *)src);
-            break;
-        default:
-            assert(false && "Unhandled data size.");
-            error.SetErrorStringWithFormat ("unhandled byte size: %" PRIu32, reg_info->byte_size);
-            break;
+      return error;
     }
 
+    error.SetErrorString("byte order is invalid");
     return error;
-}
+  }
 
-Error
-NativeRegisterContextLinux_x86_64::WriteRegister (const RegisterInfo *reg_info, const RegisterValue &reg_value)
-{
-    assert (reg_info && "reg_info is null");
-
-    const uint32_t reg_index = reg_info->kinds[lldb::eRegisterKindLLDB];
-    if (reg_index == LLDB_INVALID_REGNUM)
-        return Error ("no lldb regnum for %s", reg_info && reg_info->name ? reg_info->name : "<unknown register>");
-
-    if (IsGPR(reg_index))
-        return WriteRegisterRaw(reg_index, reg_value);
-
-    if (IsFPR(reg_index, GetFPRType()))
-    {
-        if (reg_info->encoding == lldb::eEncodingVector)
-        {
-            if (reg_index >= m_reg_info.first_st && reg_index <= m_reg_info.last_st)
-                ::memcpy (m_fpr.xstate.fxsave.stmm[reg_index - m_reg_info.first_st].bytes, reg_value.GetBytes(), reg_value.GetByteSize());
-
-            if (reg_index >= m_reg_info.first_mm && reg_index <= m_reg_info.last_mm)
-                ::memcpy (m_fpr.xstate.fxsave.stmm[reg_index - m_reg_info.first_mm].bytes, reg_value.GetBytes(), reg_value.GetByteSize());
-
-            if (reg_index >= m_reg_info.first_xmm && reg_index <= m_reg_info.last_xmm)
-                ::memcpy (m_fpr.xstate.fxsave.xmm[reg_index - m_reg_info.first_xmm].bytes, reg_value.GetBytes(), reg_value.GetByteSize());
-
-            if (reg_index >= m_reg_info.first_ymm && reg_index <= m_reg_info.last_ymm)
-            {
-                if (GetFPRType() != eFPRTypeXSAVE)
-                    return Error ("target processor does not support AVX");
-
-                // Store ymm register content, and split into the register halves in xmm.bytes and ymmh.bytes
-                ::memcpy (m_ymm_set.ymm[reg_index - m_reg_info.first_ymm].bytes, reg_value.GetBytes(), reg_value.GetByteSize());
-                if (!CopyYMMtoXSTATE(reg_index, GetByteOrder()))
-                    return Error ("CopyYMMtoXSTATE() failed");
-            }
-        }
-        else
-        {
-            // Get pointer to m_fpr.xstate.fxsave variable and set the data to it.
-
-            // Byte offsets of all registers are calculated wrt 'UserArea' structure.
-            // However, WriteFPR() takes m_fpr (of type FPR structure) and writes only fpu
-            // registers using ptrace(PTRACE_SETFPREGS,..) API. Hence fpu registers should
-            // be written in m_fpr at byte offsets calculated wrt FPR structure.
-
-            // Since, FPR structure is also one of the member of UserArea structure.
-            // byte_offset(fpu wrt FPR) = byte_offset(fpu wrt UserArea) - byte_offset(fctrl wrt UserArea)
-            assert ( (reg_info->byte_offset - m_fctrl_offset_in_userarea) < sizeof(m_fpr));
-            uint8_t *dst = (uint8_t *)&m_fpr + reg_info->byte_offset - m_fctrl_offset_in_userarea;
-            switch (reg_info->byte_size)
-            {
-                case 1:
-                    *(uint8_t *)dst = reg_value.GetAsUInt8();
-                    break;
-                case 2:
-                    *(uint16_t *)dst = reg_value.GetAsUInt16();
-                    break;
-                case 4:
-                    *(uint32_t *)dst = reg_value.GetAsUInt32();
-                    break;
-                case 8:
-                    *(uint64_t *)dst = reg_value.GetAsUInt64();
-                    break;
-                default:
-                    assert(false && "Unhandled data size.");
-                    return Error ("unhandled register data size %" PRIu32, reg_info->byte_size);
-            }
-        }
+  // Get pointer to m_fpr.xstate.fxsave variable and set the data from it.
 
-        Error error = WriteFPR();
-        if (error.Fail())
-            return error;
-
-        if (IsAVX(reg_index))
-        {
-            if (!CopyYMMtoXSTATE(reg_index, GetByteOrder()))
-                return Error ("CopyYMMtoXSTATE() failed");
-        }
-        return Error ();
-    }
-    return Error ("failed - register wasn't recognized to be a GPR or an FPR, write strategy unknown");
-}
+  // Byte offsets of all registers are calculated wrt 'UserArea' structure.
+  // However, ReadFPR() reads fpu registers {using ptrace(PTRACE_GETFPREGS,..)}
+  // and stores them in 'm_fpr' (of type FPR structure). To extract values of
+  // fpu
+  // registers, m_fpr should be read at byte offsets calculated wrt to FPR
+  // structure.
+
+  // Since, FPR structure is also one of the member of UserArea structure.
+  // byte_offset(fpu wrt FPR) = byte_offset(fpu wrt UserArea) -
+  // byte_offset(fctrl wrt UserArea)
+  assert((reg_info->byte_offset - m_fctrl_offset_in_userarea) < sizeof(m_fpr));
+  uint8_t *src =
+      (uint8_t *)&m_fpr + reg_info->byte_offset - m_fctrl_offset_in_userarea;
+  switch (reg_info->byte_size) {
+  case 1:
+    reg_value.SetUInt8(*(uint8_t *)src);
+    break;
+  case 2:
+    reg_value.SetUInt16(*(uint16_t *)src);
+    break;
+  case 4:
+    reg_value.SetUInt32(*(uint32_t *)src);
+    break;
+  case 8:
+    reg_value.SetUInt64(*(uint64_t *)src);
+    break;
+  default:
+    assert(false && "Unhandled data size.");
+    error.SetErrorStringWithFormat("unhandled byte size: %" PRIu32,
+                                   reg_info->byte_size);
+    break;
+  }
+
+  return error;
+}
+
+Error NativeRegisterContextLinux_x86_64::WriteRegister(
+    const RegisterInfo *reg_info, const RegisterValue &reg_value) {
+  assert(reg_info && "reg_info is null");
+
+  const uint32_t reg_index = reg_info->kinds[lldb::eRegisterKindLLDB];
+  if (reg_index == LLDB_INVALID_REGNUM)
+    return Error("no lldb regnum for %s", reg_info && reg_info->name
+                                              ? reg_info->name
+                                              : "<unknown register>");
+
+  if (IsGPR(reg_index))
+    return WriteRegisterRaw(reg_index, reg_value);
+
+  if (IsFPR(reg_index, GetFPRType())) {
+    if (reg_info->encoding == lldb::eEncodingVector) {
+      if (reg_index >= m_reg_info.first_st && reg_index <= m_reg_info.last_st)
+        ::memcpy(
+            m_fpr.xstate.fxsave.stmm[reg_index - m_reg_info.first_st].bytes,
+            reg_value.GetBytes(), reg_value.GetByteSize());
+
+      if (reg_index >= m_reg_info.first_mm && reg_index <= m_reg_info.last_mm)
+        ::memcpy(
+            m_fpr.xstate.fxsave.stmm[reg_index - m_reg_info.first_mm].bytes,
+            reg_value.GetBytes(), reg_value.GetByteSize());
+
+      if (reg_index >= m_reg_info.first_xmm && reg_index <= m_reg_info.last_xmm)
+        ::memcpy(
+            m_fpr.xstate.fxsave.xmm[reg_index - m_reg_info.first_xmm].bytes,
+            reg_value.GetBytes(), reg_value.GetByteSize());
+
+      if (reg_index >= m_reg_info.first_ymm &&
+          reg_index <= m_reg_info.last_ymm) {
+        if (GetFPRType() != eFPRTypeXSAVE)
+          return Error("target processor does not support AVX");
 
-Error
-NativeRegisterContextLinux_x86_64::ReadAllRegisterValues (lldb::DataBufferSP &data_sp)
-{
-    Error error;
-
-    data_sp.reset (new DataBufferHeap (REG_CONTEXT_SIZE, 0));
-    if (!data_sp)
-    {
-        error.SetErrorStringWithFormat ("failed to allocate DataBufferHeap instance of size %" PRIu64, REG_CONTEXT_SIZE);
-        return error;
+        // Store ymm register content, and split into the register halves in
+        // xmm.bytes and ymmh.bytes
+        ::memcpy(m_ymm_set.ymm[reg_index - m_reg_info.first_ymm].bytes,
+                 reg_value.GetBytes(), reg_value.GetByteSize());
+        if (!CopyYMMtoXSTATE(reg_index, GetByteOrder()))
+          return Error("CopyYMMtoXSTATE() failed");
+      }
+    } else {
+      // Get pointer to m_fpr.xstate.fxsave variable and set the data to it.
+
+      // Byte offsets of all registers are calculated wrt 'UserArea' structure.
+      // However, WriteFPR() takes m_fpr (of type FPR structure) and writes only
+      // fpu
+      // registers using ptrace(PTRACE_SETFPREGS,..) API. Hence fpu registers
+      // should
+      // be written in m_fpr at byte offsets calculated wrt FPR structure.
+
+      // Since, FPR structure is also one of the member of UserArea structure.
+      // byte_offset(fpu wrt FPR) = byte_offset(fpu wrt UserArea) -
+      // byte_offset(fctrl wrt UserArea)
+      assert((reg_info->byte_offset - m_fctrl_offset_in_userarea) <
+             sizeof(m_fpr));
+      uint8_t *dst = (uint8_t *)&m_fpr + reg_info->byte_offset -
+                     m_fctrl_offset_in_userarea;
+      switch (reg_info->byte_size) {
+      case 1:
+        *(uint8_t *)dst = reg_value.GetAsUInt8();
+        break;
+      case 2:
+        *(uint16_t *)dst = reg_value.GetAsUInt16();
+        break;
+      case 4:
+        *(uint32_t *)dst = reg_value.GetAsUInt32();
+        break;
+      case 8:
+        *(uint64_t *)dst = reg_value.GetAsUInt64();
+        break;
+      default:
+        assert(false && "Unhandled data size.");
+        return Error("unhandled register data size %" PRIu32,
+                     reg_info->byte_size);
+      }
     }
 
-    error = ReadGPR();
-    if (error.Fail())
-        return error;
-
-    error = ReadFPR();
+    Error error = WriteFPR();
     if (error.Fail())
-        return error;
+      return error;
 
-    uint8_t *dst = data_sp->GetBytes ();
-    if (dst == nullptr)
-    {
-        error.SetErrorStringWithFormat ("DataBufferHeap instance of size %" PRIu64 " returned a null pointer", REG_CONTEXT_SIZE);
-        return error;
+    if (IsAVX(reg_index)) {
+      if (!CopyYMMtoXSTATE(reg_index, GetByteOrder()))
+        return Error("CopyYMMtoXSTATE() failed");
     }
+    return Error();
+  }
+  return Error("failed - register wasn't recognized to be a GPR or an FPR, "
+               "write strategy unknown");
+}
 
-    ::memcpy (dst, &m_gpr_x86_64, GetRegisterInfoInterface ().GetGPRSize ());
-    dst += GetRegisterInfoInterface ().GetGPRSize ();
-    if (GetFPRType () == eFPRTypeFXSAVE)
-        ::memcpy (dst, &m_fpr.xstate.fxsave, sizeof(m_fpr.xstate.fxsave));
-    else if (GetFPRType () == eFPRTypeXSAVE)
-    {
-        lldb::ByteOrder byte_order = GetByteOrder ();
-
-        // Assemble the YMM register content from the register halves.
-        for (uint32_t reg = m_reg_info.first_ymm; reg <= m_reg_info.last_ymm; ++reg)
-        {
-            if (!CopyXSTATEtoYMM (reg, byte_order))
-            {
-                error.SetErrorStringWithFormat ("NativeRegisterContextLinux_x86_64::%s CopyXSTATEtoYMM() failed for reg num %" PRIu32, __FUNCTION__, reg);
-                return error;
-            }
-        }
-
-        // Copy the extended register state including the assembled ymm registers.
-        ::memcpy (dst, &m_fpr, sizeof (m_fpr));
-    }
-    else
-    {
-        assert (false && "how do we save the floating point registers?");
-        error.SetErrorString ("unsure how to save the floating point registers");
-    }
-    /** The following code is specific to Linux x86 based architectures,
-     *  where the register orig_eax (32 bit)/orig_rax (64 bit) is set to
-     *  -1 to solve the bug 23659, such a setting prevents the automatic
-     *  decrement of the instruction pointer which was causing the SIGILL
-     *  exception.
-     * **/
-
-    RegisterValue value((uint64_t) -1);
-    const RegisterInfo *reg_info = GetRegisterInfoInterface().GetDynamicRegisterInfo("orig_eax");
-    if (reg_info == nullptr)
-        reg_info = GetRegisterInfoInterface().GetDynamicRegisterInfo("orig_rax");
+Error NativeRegisterContextLinux_x86_64::ReadAllRegisterValues(
+    lldb::DataBufferSP &data_sp) {
+  Error error;
+
+  data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0));
+  if (!data_sp) {
+    error.SetErrorStringWithFormat(
+        "failed to allocate DataBufferHeap instance of size %" PRIu64,
+        REG_CONTEXT_SIZE);
+    return error;
+  }
 
-    if (reg_info != nullptr)
-        return DoWriteRegisterValue(reg_info->byte_offset,reg_info->name,value);
+  error = ReadGPR();
+  if (error.Fail())
+    return error;
 
+  error = ReadFPR();
+  if (error.Fail())
     return error;
-}
 
-Error
-NativeRegisterContextLinux_x86_64::WriteAllRegisterValues (const lldb::DataBufferSP &data_sp)
-{
-    Error error;
+  uint8_t *dst = data_sp->GetBytes();
+  if (dst == nullptr) {
+    error.SetErrorStringWithFormat("DataBufferHeap instance of size %" PRIu64
+                                   " returned a null pointer",
+                                   REG_CONTEXT_SIZE);
+    return error;
+  }
 
-    if (!data_sp)
-    {
-        error.SetErrorStringWithFormat ("NativeRegisterContextLinux_x86_64::%s invalid data_sp provided", __FUNCTION__);
+  ::memcpy(dst, &m_gpr_x86_64, GetRegisterInfoInterface().GetGPRSize());
+  dst += GetRegisterInfoInterface().GetGPRSize();
+  if (GetFPRType() == eFPRTypeFXSAVE)
+    ::memcpy(dst, &m_fpr.xstate.fxsave, sizeof(m_fpr.xstate.fxsave));
+  else if (GetFPRType() == eFPRTypeXSAVE) {
+    lldb::ByteOrder byte_order = GetByteOrder();
+
+    // Assemble the YMM register content from the register halves.
+    for (uint32_t reg = m_reg_info.first_ymm; reg <= m_reg_info.last_ymm;
+         ++reg) {
+      if (!CopyXSTATEtoYMM(reg, byte_order)) {
+        error.SetErrorStringWithFormat("NativeRegisterContextLinux_x86_64::%s "
+                                       "CopyXSTATEtoYMM() failed for reg num "
+                                       "%" PRIu32,
+                                       __FUNCTION__, reg);
         return error;
+      }
     }
 
-    if (data_sp->GetByteSize () != REG_CONTEXT_SIZE)
-    {
-        error.SetErrorStringWithFormat ("NativeRegisterContextLinux_x86_64::%s data_sp contained mismatched data size, expected %" PRIu64 ", actual %" PRIu64, __FUNCTION__, REG_CONTEXT_SIZE, data_sp->GetByteSize ());
-        return error;
-    }
+    // Copy the extended register state including the assembled ymm registers.
+    ::memcpy(dst, &m_fpr, sizeof(m_fpr));
+  } else {
+    assert(false && "how do we save the floating point registers?");
+    error.SetErrorString("unsure how to save the floating point registers");
+  }
+  /** The following code is specific to Linux x86 based architectures,
+   *  where the register orig_eax (32 bit)/orig_rax (64 bit) is set to
+   *  -1 to solve the bug 23659, such a setting prevents the automatic
+   *  decrement of the instruction pointer which was causing the SIGILL
+   *  exception.
+   * **/
+
+  RegisterValue value((uint64_t)-1);
+  const RegisterInfo *reg_info =
+      GetRegisterInfoInterface().GetDynamicRegisterInfo("orig_eax");
+  if (reg_info == nullptr)
+    reg_info = GetRegisterInfoInterface().GetDynamicRegisterInfo("orig_rax");
+
+  if (reg_info != nullptr)
+    return DoWriteRegisterValue(reg_info->byte_offset, reg_info->name, value);
+
+  return error;
+}
+
+Error NativeRegisterContextLinux_x86_64::WriteAllRegisterValues(
+    const lldb::DataBufferSP &data_sp) {
+  Error error;
+
+  if (!data_sp) {
+    error.SetErrorStringWithFormat(
+        "NativeRegisterContextLinux_x86_64::%s invalid data_sp provided",
+        __FUNCTION__);
+    return error;
+  }
+
+  if (data_sp->GetByteSize() != REG_CONTEXT_SIZE) {
+    error.SetErrorStringWithFormat(
+        "NativeRegisterContextLinux_x86_64::%s data_sp contained mismatched "
+        "data size, expected %" PRIu64 ", actual %" PRIu64,
+        __FUNCTION__, REG_CONTEXT_SIZE, data_sp->GetByteSize());
+    return error;
+  }
 
+  uint8_t *src = data_sp->GetBytes();
+  if (src == nullptr) {
+    error.SetErrorStringWithFormat("NativeRegisterContextLinux_x86_64::%s "
+                                   "DataBuffer::GetBytes() returned a null "
+                                   "pointer",
+                                   __FUNCTION__);
+    return error;
+  }
+  ::memcpy(&m_gpr_x86_64, src, GetRegisterInfoInterface().GetGPRSize());
 
-    uint8_t *src = data_sp->GetBytes ();
-    if (src == nullptr)
-    {
-        error.SetErrorStringWithFormat ("NativeRegisterContextLinux_x86_64::%s DataBuffer::GetBytes() returned a null pointer", __FUNCTION__);
-        return error;
-    }
-    ::memcpy (&m_gpr_x86_64, src, GetRegisterInfoInterface ().GetGPRSize ());
+  error = WriteGPR();
+  if (error.Fail())
+    return error;
 
-    error = WriteGPR();
-    if (error.Fail())
-        return error;
+  src += GetRegisterInfoInterface().GetGPRSize();
+  if (GetFPRType() == eFPRTypeFXSAVE)
+    ::memcpy(&m_fpr.xstate.fxsave, src, sizeof(m_fpr.xstate.fxsave));
+  else if (GetFPRType() == eFPRTypeXSAVE)
+    ::memcpy(&m_fpr.xstate.xsave, src, sizeof(m_fpr.xstate.xsave));
+
+  error = WriteFPR();
+  if (error.Fail())
+    return error;
 
-    src += GetRegisterInfoInterface ().GetGPRSize ();
-    if (GetFPRType () == eFPRTypeFXSAVE)
-        ::memcpy (&m_fpr.xstate.fxsave, src, sizeof(m_fpr.xstate.fxsave));
-    else if (GetFPRType () == eFPRTypeXSAVE)
-        ::memcpy (&m_fpr.xstate.xsave, src, sizeof(m_fpr.xstate.xsave));
+  if (GetFPRType() == eFPRTypeXSAVE) {
+    lldb::ByteOrder byte_order = GetByteOrder();
 
-    error = WriteFPR();
-    if (error.Fail())
+    // Parse the YMM register content from the register halves.
+    for (uint32_t reg = m_reg_info.first_ymm; reg <= m_reg_info.last_ymm;
+         ++reg) {
+      if (!CopyYMMtoXSTATE(reg, byte_order)) {
+        error.SetErrorStringWithFormat("NativeRegisterContextLinux_x86_64::%s "
+                                       "CopyYMMtoXSTATE() failed for reg num "
+                                       "%" PRIu32,
+                                       __FUNCTION__, reg);
         return error;
-
-    if (GetFPRType() == eFPRTypeXSAVE)
-    {
-        lldb::ByteOrder byte_order = GetByteOrder();
-
-        // Parse the YMM register content from the register halves.
-        for (uint32_t reg = m_reg_info.first_ymm; reg <= m_reg_info.last_ymm; ++reg)
-        {
-            if (!CopyYMMtoXSTATE (reg, byte_order))
-            {
-                error.SetErrorStringWithFormat ("NativeRegisterContextLinux_x86_64::%s CopyYMMtoXSTATE() failed for reg num %" PRIu32, __FUNCTION__, reg);
-                return error;
-            }
-        }
+      }
     }
+  }
 
-    return error;
+  return error;
 }
 
-bool
-NativeRegisterContextLinux_x86_64::IsRegisterSetAvailable (uint32_t set_index) const
-{
-    // Note: Extended register sets are assumed to be at the end of g_reg_sets.
-    uint32_t num_sets = k_num_register_sets - k_num_extended_register_sets;
-
-    if (GetFPRType () == eFPRTypeXSAVE)
-    {
-        // AVX is the first extended register set.
-        ++num_sets;
-    }
-    return (set_index < num_sets);
+bool NativeRegisterContextLinux_x86_64::IsRegisterSetAvailable(
+    uint32_t set_index) const {
+  // Note: Extended register sets are assumed to be at the end of g_reg_sets.
+  uint32_t num_sets = k_num_register_sets - k_num_extended_register_sets;
+
+  if (GetFPRType() == eFPRTypeXSAVE) {
+    // AVX is the first extended register set.
+    ++num_sets;
+  }
+  return (set_index < num_sets);
 }
 
-bool
-NativeRegisterContextLinux_x86_64::IsGPR(uint32_t reg_index) const
-{
-    // GPRs come first.
-    return reg_index <= m_reg_info.last_gpr;
+bool NativeRegisterContextLinux_x86_64::IsGPR(uint32_t reg_index) const {
+  // GPRs come first.
+  return reg_index <= m_reg_info.last_gpr;
 }
 
 NativeRegisterContextLinux_x86_64::FPRType
-NativeRegisterContextLinux_x86_64::GetFPRType () const
-{
-    Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
-    if (m_fpr_type == eFPRTypeNotValid)
-    {
-        // TODO: Use assembly to call cpuid on the inferior and query ebx or ecx.
-
-        // Try and see if AVX register retrieval works.
-        m_fpr_type = eFPRTypeXSAVE;
-        if (const_cast<NativeRegisterContextLinux_x86_64*>(this)->ReadFPR().Fail())
-        {
-            // Fall back to general floating point with no AVX support.
-            m_fpr_type = eFPRTypeFXSAVE;
-
-            // Check if FXSAVE area can be read.
-            if (const_cast<NativeRegisterContextLinux_x86_64*>(this)->ReadFPR().Fail())
-            {
-                if (log)
-                    log->Printf("NativeRegisterContextLinux_x86_64::%s ptrace APIs failed to read XSAVE/FXSAVE area", __FUNCTION__);
-            }
-        }
+NativeRegisterContextLinux_x86_64::GetFPRType() const {
+  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+  if (m_fpr_type == eFPRTypeNotValid) {
+    // TODO: Use assembly to call cpuid on the inferior and query ebx or ecx.
+
+    // Try and see if AVX register retrieval works.
+    m_fpr_type = eFPRTypeXSAVE;
+    if (const_cast<NativeRegisterContextLinux_x86_64 *>(this)
+            ->ReadFPR()
+            .Fail()) {
+      // Fall back to general floating point with no AVX support.
+      m_fpr_type = eFPRTypeFXSAVE;
+
+      // Check if FXSAVE area can be read.
+      if (const_cast<NativeRegisterContextLinux_x86_64 *>(this)
+              ->ReadFPR()
+              .Fail()) {
+        if (log)
+          log->Printf("NativeRegisterContextLinux_x86_64::%s ptrace APIs "
+                      "failed to read XSAVE/FXSAVE area",
+                      __FUNCTION__);
+      }
+    }
+  }
+  return m_fpr_type;
+}
+
+bool NativeRegisterContextLinux_x86_64::IsFPR(uint32_t reg_index) const {
+  return (m_reg_info.first_fpr <= reg_index &&
+          reg_index <= m_reg_info.last_fpr);
+}
+
+bool NativeRegisterContextLinux_x86_64::IsFPR(uint32_t reg_index,
+                                              FPRType fpr_type) const {
+  bool generic_fpr = IsFPR(reg_index);
+
+  if (fpr_type == eFPRTypeXSAVE)
+    return generic_fpr || IsAVX(reg_index);
+  return generic_fpr;
+}
+
+Error NativeRegisterContextLinux_x86_64::WriteFPR() {
+  const FPRType fpr_type = GetFPRType();
+  const lldb_private::ArchSpec &target_arch =
+      GetRegisterInfoInterface().GetTargetArchitecture();
+  switch (fpr_type) {
+  case FPRType::eFPRTypeFXSAVE:
+    // For 32-bit inferiors on x86_32/x86_64 architectures,
+    // FXSAVE area can be written using PTRACE_SETREGSET ptrace api
+    // For 64-bit inferiors on x86_64 architectures,
+    // FXSAVE area can be written using PTRACE_SETFPREGS ptrace api
+    switch (target_arch.GetMachine()) {
+    case llvm::Triple::x86:
+      return WriteRegisterSet(&m_iovec, sizeof(m_fpr.xstate.xsave),
+                              NT_PRXFPREG);
+    case llvm::Triple::x86_64:
+      return NativeRegisterContextLinux::WriteFPR();
+    default:
+      assert(false && "Unhandled target architecture.");
+      break;
     }
-    return m_fpr_type;
+  case FPRType::eFPRTypeXSAVE:
+    return WriteRegisterSet(&m_iovec, sizeof(m_fpr.xstate.xsave),
+                            NT_X86_XSTATE);
+  default:
+    return Error("Unrecognized FPR type");
+  }
+}
+
+bool NativeRegisterContextLinux_x86_64::IsAVX(uint32_t reg_index) const {
+  return (m_reg_info.first_ymm <= reg_index &&
+          reg_index <= m_reg_info.last_ymm);
+}
+
+bool NativeRegisterContextLinux_x86_64::CopyXSTATEtoYMM(
+    uint32_t reg_index, lldb::ByteOrder byte_order) {
+  if (!IsAVX(reg_index))
+    return false;
+
+  if (byte_order == lldb::eByteOrderLittle) {
+    ::memcpy(m_ymm_set.ymm[reg_index - m_reg_info.first_ymm].bytes,
+             m_fpr.xstate.fxsave.xmm[reg_index - m_reg_info.first_ymm].bytes,
+             sizeof(XMMReg));
+    ::memcpy(m_ymm_set.ymm[reg_index - m_reg_info.first_ymm].bytes +
+                 sizeof(XMMReg),
+             m_fpr.xstate.xsave.ymmh[reg_index - m_reg_info.first_ymm].bytes,
+             sizeof(YMMHReg));
+    return true;
+  }
+
+  if (byte_order == lldb::eByteOrderBig) {
+    ::memcpy(m_ymm_set.ymm[reg_index - m_reg_info.first_ymm].bytes +
+                 sizeof(XMMReg),
+             m_fpr.xstate.fxsave.xmm[reg_index - m_reg_info.first_ymm].bytes,
+             sizeof(XMMReg));
+    ::memcpy(m_ymm_set.ymm[reg_index - m_reg_info.first_ymm].bytes,
+             m_fpr.xstate.xsave.ymmh[reg_index - m_reg_info.first_ymm].bytes,
+             sizeof(YMMHReg));
+    return true;
+  }
+  return false; // unsupported or invalid byte order
+}
+
+bool NativeRegisterContextLinux_x86_64::CopyYMMtoXSTATE(
+    uint32_t reg, lldb::ByteOrder byte_order) {
+  if (!IsAVX(reg))
+    return false;
+
+  if (byte_order == lldb::eByteOrderLittle) {
+    ::memcpy(m_fpr.xstate.fxsave.xmm[reg - m_reg_info.first_ymm].bytes,
+             m_ymm_set.ymm[reg - m_reg_info.first_ymm].bytes, sizeof(XMMReg));
+    ::memcpy(m_fpr.xstate.xsave.ymmh[reg - m_reg_info.first_ymm].bytes,
+             m_ymm_set.ymm[reg - m_reg_info.first_ymm].bytes + sizeof(XMMReg),
+             sizeof(YMMHReg));
+    return true;
+  }
+
+  if (byte_order == lldb::eByteOrderBig) {
+    ::memcpy(m_fpr.xstate.fxsave.xmm[reg - m_reg_info.first_ymm].bytes,
+             m_ymm_set.ymm[reg - m_reg_info.first_ymm].bytes + sizeof(XMMReg),
+             sizeof(XMMReg));
+    ::memcpy(m_fpr.xstate.xsave.ymmh[reg - m_reg_info.first_ymm].bytes,
+             m_ymm_set.ymm[reg - m_reg_info.first_ymm].bytes, sizeof(YMMHReg));
+    return true;
+  }
+  return false; // unsupported or invalid byte order
+}
+
+void *NativeRegisterContextLinux_x86_64::GetFPRBuffer() {
+  const FPRType fpr_type = GetFPRType();
+  switch (fpr_type) {
+  case FPRType::eFPRTypeFXSAVE:
+    return &m_fpr.xstate.fxsave;
+  case FPRType::eFPRTypeXSAVE:
+    return &m_iovec;
+  default:
+    return nullptr;
+  }
 }
 
-bool
-NativeRegisterContextLinux_x86_64::IsFPR(uint32_t reg_index) const
-{
-    return (m_reg_info.first_fpr <= reg_index && reg_index <= m_reg_info.last_fpr);
-}
-
-bool
-NativeRegisterContextLinux_x86_64::IsFPR(uint32_t reg_index, FPRType fpr_type) const
-{
-    bool generic_fpr = IsFPR(reg_index);
-
-    if (fpr_type == eFPRTypeXSAVE)
-        return generic_fpr || IsAVX(reg_index);
-    return generic_fpr;
-}
-
-Error
-NativeRegisterContextLinux_x86_64::WriteFPR()
-{
-    const FPRType fpr_type = GetFPRType ();
-    const lldb_private::ArchSpec& target_arch = GetRegisterInfoInterface().GetTargetArchitecture();
-    switch (fpr_type)
-    {
-    case FPRType::eFPRTypeFXSAVE:
-        // For 32-bit inferiors on x86_32/x86_64 architectures,
-        // FXSAVE area can be written using PTRACE_SETREGSET ptrace api
-        // For 64-bit inferiors on x86_64 architectures,
-        // FXSAVE area can be written using PTRACE_SETFPREGS ptrace api
-        switch (target_arch.GetMachine ())
-        {
-            case llvm::Triple::x86:
-                return WriteRegisterSet(&m_iovec, sizeof(m_fpr.xstate.xsave), NT_PRXFPREG);
-            case llvm::Triple::x86_64:
-                return NativeRegisterContextLinux::WriteFPR();
-            default:
-                assert(false && "Unhandled target architecture.");
-                break;
-        }
-    case FPRType::eFPRTypeXSAVE:
-        return WriteRegisterSet(&m_iovec, sizeof(m_fpr.xstate.xsave), NT_X86_XSTATE);
+size_t NativeRegisterContextLinux_x86_64::GetFPRSize() {
+  const FPRType fpr_type = GetFPRType();
+  switch (fpr_type) {
+  case FPRType::eFPRTypeFXSAVE:
+    return sizeof(m_fpr.xstate.fxsave);
+  case FPRType::eFPRTypeXSAVE:
+    return sizeof(m_iovec);
+  default:
+    return 0;
+  }
+}
+
+Error NativeRegisterContextLinux_x86_64::ReadFPR() {
+  const FPRType fpr_type = GetFPRType();
+  const lldb_private::ArchSpec &target_arch =
+      GetRegisterInfoInterface().GetTargetArchitecture();
+  switch (fpr_type) {
+  case FPRType::eFPRTypeFXSAVE:
+    // For 32-bit inferiors on x86_32/x86_64 architectures,
+    // FXSAVE area can be read using PTRACE_GETREGSET ptrace api
+    // For 64-bit inferiors on x86_64 architectures,
+    // FXSAVE area can be read using PTRACE_GETFPREGS ptrace api
+    switch (target_arch.GetMachine()) {
+    case llvm::Triple::x86:
+      return ReadRegisterSet(&m_iovec, sizeof(m_fpr.xstate.xsave), NT_PRXFPREG);
+    case llvm::Triple::x86_64:
+      return NativeRegisterContextLinux::ReadFPR();
     default:
-        return Error("Unrecognized FPR type");
+      assert(false && "Unhandled target architecture.");
+      break;
     }
-}
+  case FPRType::eFPRTypeXSAVE:
+    return ReadRegisterSet(&m_iovec, sizeof(m_fpr.xstate.xsave), NT_X86_XSTATE);
+  default:
+    return Error("Unrecognized FPR type");
+  }
+}
+
+Error NativeRegisterContextLinux_x86_64::IsWatchpointHit(uint32_t wp_index,
+                                                         bool &is_hit) {
+  if (wp_index >= NumSupportedHardwareWatchpoints())
+    return Error("Watchpoint index out of range");
+
+  RegisterValue reg_value;
+  Error error = ReadRegisterRaw(m_reg_info.first_dr + 6, reg_value);
+  if (error.Fail()) {
+    is_hit = false;
+    return error;
+  }
 
-bool
-NativeRegisterContextLinux_x86_64::IsAVX(uint32_t reg_index) const
-{
-    return (m_reg_info.first_ymm <= reg_index && reg_index <= m_reg_info.last_ymm);
-}
-
-bool
-NativeRegisterContextLinux_x86_64::CopyXSTATEtoYMM (uint32_t reg_index, lldb::ByteOrder byte_order)
-{
-    if (!IsAVX (reg_index))
-        return false;
-
-    if (byte_order == lldb::eByteOrderLittle)
-    {
-        ::memcpy (m_ymm_set.ymm[reg_index - m_reg_info.first_ymm].bytes,
-                 m_fpr.xstate.fxsave.xmm[reg_index - m_reg_info.first_ymm].bytes,
-                 sizeof (XMMReg));
-        ::memcpy (m_ymm_set.ymm[reg_index - m_reg_info.first_ymm].bytes + sizeof (XMMReg),
-                 m_fpr.xstate.xsave.ymmh[reg_index - m_reg_info.first_ymm].bytes,
-                 sizeof (YMMHReg));
-        return true;
-    }
+  uint64_t status_bits = reg_value.GetAsUInt64();
 
-    if (byte_order == lldb::eByteOrderBig)
-    {
-        ::memcpy(m_ymm_set.ymm[reg_index - m_reg_info.first_ymm].bytes + sizeof (XMMReg),
-                 m_fpr.xstate.fxsave.xmm[reg_index - m_reg_info.first_ymm].bytes,
-                 sizeof (XMMReg));
-        ::memcpy(m_ymm_set.ymm[reg_index - m_reg_info.first_ymm].bytes,
-                 m_fpr.xstate.xsave.ymmh[reg_index - m_reg_info.first_ymm].bytes,
-                 sizeof (YMMHReg));
-        return true;
-    }
-    return false; // unsupported or invalid byte order
+  is_hit = status_bits & (1 << wp_index);
 
+  return error;
 }
 
-bool
-NativeRegisterContextLinux_x86_64::CopyYMMtoXSTATE(uint32_t reg, lldb::ByteOrder byte_order)
-{
-    if (!IsAVX(reg))
-        return false;
-
-    if (byte_order == lldb::eByteOrderLittle)
-    {
-        ::memcpy(m_fpr.xstate.fxsave.xmm[reg - m_reg_info.first_ymm].bytes,
-                 m_ymm_set.ymm[reg - m_reg_info.first_ymm].bytes,
-                 sizeof(XMMReg));
-        ::memcpy(m_fpr.xstate.xsave.ymmh[reg - m_reg_info.first_ymm].bytes,
-                 m_ymm_set.ymm[reg - m_reg_info.first_ymm].bytes + sizeof(XMMReg),
-                 sizeof(YMMHReg));
-        return true;
+Error NativeRegisterContextLinux_x86_64::GetWatchpointHitIndex(
+    uint32_t &wp_index, lldb::addr_t trap_addr) {
+  uint32_t num_hw_wps = NumSupportedHardwareWatchpoints();
+  for (wp_index = 0; wp_index < num_hw_wps; ++wp_index) {
+    bool is_hit;
+    Error error = IsWatchpointHit(wp_index, is_hit);
+    if (error.Fail()) {
+      wp_index = LLDB_INVALID_INDEX32;
+      return error;
+    } else if (is_hit) {
+      return error;
     }
-
-    if (byte_order == lldb::eByteOrderBig)
-    {
-        ::memcpy(m_fpr.xstate.fxsave.xmm[reg - m_reg_info.first_ymm].bytes,
-                 m_ymm_set.ymm[reg - m_reg_info.first_ymm].bytes + sizeof(XMMReg),
-                 sizeof(XMMReg));
-        ::memcpy(m_fpr.xstate.xsave.ymmh[reg - m_reg_info.first_ymm].bytes,
-                 m_ymm_set.ymm[reg - m_reg_info.first_ymm].bytes,
-                 sizeof(YMMHReg));
-        return true;
-    }
-    return false; // unsupported or invalid byte order
+  }
+  wp_index = LLDB_INVALID_INDEX32;
+  return Error();
 }
 
-void*
-NativeRegisterContextLinux_x86_64::GetFPRBuffer()
-{
-    const FPRType fpr_type = GetFPRType ();
-    switch (fpr_type)
-    {
-    case FPRType::eFPRTypeFXSAVE:
-        return &m_fpr.xstate.fxsave;
-    case FPRType::eFPRTypeXSAVE:
-        return &m_iovec;
-    default:
-        return nullptr;
-    }
-}
+Error NativeRegisterContextLinux_x86_64::IsWatchpointVacant(uint32_t wp_index,
+                                                            bool &is_vacant) {
+  if (wp_index >= NumSupportedHardwareWatchpoints())
+    return Error("Watchpoint index out of range");
 
-size_t
-NativeRegisterContextLinux_x86_64::GetFPRSize()
-{
-    const FPRType fpr_type = GetFPRType ();
-    switch (fpr_type)
-    {
-    case FPRType::eFPRTypeFXSAVE:
-        return sizeof(m_fpr.xstate.fxsave);
-    case FPRType::eFPRTypeXSAVE:
-        return sizeof(m_iovec);
-    default:
-        return 0;
-    }
-}
+  RegisterValue reg_value;
+  Error error = ReadRegisterRaw(m_reg_info.first_dr + 7, reg_value);
+  if (error.Fail()) {
+    is_vacant = false;
+    return error;
+  }
 
-Error
-NativeRegisterContextLinux_x86_64::ReadFPR ()
-{
-    const FPRType fpr_type = GetFPRType ();
-    const lldb_private::ArchSpec& target_arch = GetRegisterInfoInterface().GetTargetArchitecture();
-    switch (fpr_type)
-    {
-    case FPRType::eFPRTypeFXSAVE:
-        // For 32-bit inferiors on x86_32/x86_64 architectures,
-        // FXSAVE area can be read using PTRACE_GETREGSET ptrace api
-        // For 64-bit inferiors on x86_64 architectures,
-        // FXSAVE area can be read using PTRACE_GETFPREGS ptrace api
-        switch (target_arch.GetMachine ())
-        {
-            case llvm::Triple::x86:
-                return ReadRegisterSet(&m_iovec, sizeof(m_fpr.xstate.xsave), NT_PRXFPREG);
-            case llvm::Triple::x86_64:
-                return NativeRegisterContextLinux::ReadFPR();
-            default:
-                assert(false && "Unhandled target architecture.");
-                break;
-        }
-    case FPRType::eFPRTypeXSAVE:
-        return ReadRegisterSet(&m_iovec, sizeof(m_fpr.xstate.xsave), NT_X86_XSTATE);
-    default:
-        return Error("Unrecognized FPR type");
-    }
+  uint64_t control_bits = reg_value.GetAsUInt64();
+
+  is_vacant = !(control_bits & (1 << (2 * wp_index)));
+
+  return error;
 }
 
-Error
-NativeRegisterContextLinux_x86_64::IsWatchpointHit(uint32_t wp_index, bool &is_hit)
-{
-    if (wp_index >= NumSupportedHardwareWatchpoints())
-        return Error("Watchpoint index out of range");
+Error NativeRegisterContextLinux_x86_64::SetHardwareWatchpointWithIndex(
+    lldb::addr_t addr, size_t size, uint32_t watch_flags, uint32_t wp_index) {
 
-    RegisterValue reg_value;
-    Error error = ReadRegisterRaw(m_reg_info.first_dr + 6, reg_value);
-    if (error.Fail())
-    {
-        is_hit = false;
-        return error;
-    }
+  if (wp_index >= NumSupportedHardwareWatchpoints())
+    return Error("Watchpoint index out of range");
+
+  // Read only watchpoints aren't supported on x86_64. Fall back to read/write
+  // waitchpoints instead.
+  // TODO: Add logic to detect when a write happens and ignore that watchpoint
+  // hit.
+  if (watch_flags == 0x2)
+    watch_flags = 0x3;
 
-    uint64_t status_bits = reg_value.GetAsUInt64();
+  if (watch_flags != 0x1 && watch_flags != 0x3)
+    return Error("Invalid read/write bits for watchpoint");
 
-    is_hit = status_bits & (1 << wp_index);
+  if (size != 1 && size != 2 && size != 4 && size != 8)
+    return Error("Invalid size for watchpoint");
 
+  bool is_vacant;
+  Error error = IsWatchpointVacant(wp_index, is_vacant);
+  if (error.Fail())
     return error;
-}
+  if (!is_vacant)
+    return Error("Watchpoint index not vacant");
 
-Error
-NativeRegisterContextLinux_x86_64::GetWatchpointHitIndex(uint32_t &wp_index, lldb::addr_t trap_addr) {
-    uint32_t num_hw_wps = NumSupportedHardwareWatchpoints();
-    for (wp_index = 0; wp_index < num_hw_wps; ++wp_index)
-    {
-        bool is_hit;
-        Error error = IsWatchpointHit(wp_index, is_hit);
-        if (error.Fail()) {
-            wp_index = LLDB_INVALID_INDEX32;
-            return error;
-        } else if (is_hit) {
-            return error;
-        }
-    }
-    wp_index = LLDB_INVALID_INDEX32;
-    return Error();
-}
+  RegisterValue reg_value;
+  error = ReadRegisterRaw(m_reg_info.first_dr + 7, reg_value);
+  if (error.Fail())
+    return error;
 
-Error
-NativeRegisterContextLinux_x86_64::IsWatchpointVacant(uint32_t wp_index, bool &is_vacant)
-{
-    if (wp_index >= NumSupportedHardwareWatchpoints())
-        return Error ("Watchpoint index out of range");
+  // for watchpoints 0, 1, 2, or 3, respectively,
+  // set bits 1, 3, 5, or 7
+  uint64_t enable_bit = 1 << (2 * wp_index);
 
-    RegisterValue reg_value;
-    Error error = ReadRegisterRaw(m_reg_info.first_dr + 7, reg_value);
-    if (error.Fail())
-    {
-        is_vacant = false;
-        return error;
-    }
+  // set bits 16-17, 20-21, 24-25, or 28-29
+  // with 0b01 for write, and 0b11 for read/write
+  uint64_t rw_bits = watch_flags << (16 + 4 * wp_index);
 
-    uint64_t control_bits = reg_value.GetAsUInt64();
+  // set bits 18-19, 22-23, 26-27, or 30-31
+  // with 0b00, 0b01, 0b10, or 0b11
+  // for 1, 2, 8 (if supported), or 4 bytes, respectively
+  uint64_t size_bits = (size == 8 ? 0x2 : size - 1) << (18 + 4 * wp_index);
 
-    is_vacant = !(control_bits & (1 << (2 * wp_index)));
+  uint64_t bit_mask = (0x3 << (2 * wp_index)) | (0xF << (16 + 4 * wp_index));
 
-    return error;
-}
+  uint64_t control_bits = reg_value.GetAsUInt64() & ~bit_mask;
 
-Error
-NativeRegisterContextLinux_x86_64::SetHardwareWatchpointWithIndex(
-        lldb::addr_t addr, size_t size, uint32_t watch_flags, uint32_t wp_index) {
+  control_bits |= enable_bit | rw_bits | size_bits;
 
-    if (wp_index >= NumSupportedHardwareWatchpoints())
-        return Error ("Watchpoint index out of range");
+  error = WriteRegisterRaw(m_reg_info.first_dr + wp_index, RegisterValue(addr));
+  if (error.Fail())
+    return error;
 
-    // Read only watchpoints aren't supported on x86_64. Fall back to read/write waitchpoints instead.
-    // TODO: Add logic to detect when a write happens and ignore that watchpoint hit.
-    if (watch_flags == 0x2)
-        watch_flags = 0x3;
+  error =
+      WriteRegisterRaw(m_reg_info.first_dr + 7, RegisterValue(control_bits));
+  if (error.Fail())
+    return error;
 
-    if (watch_flags != 0x1 && watch_flags != 0x3)
-        return Error ("Invalid read/write bits for watchpoint");
+  error.Clear();
+  return error;
+}
 
-    if (size != 1 && size != 2 && size != 4 && size != 8)
-        return Error ("Invalid size for watchpoint");
+bool NativeRegisterContextLinux_x86_64::ClearHardwareWatchpoint(
+    uint32_t wp_index) {
+  if (wp_index >= NumSupportedHardwareWatchpoints())
+    return false;
+
+  RegisterValue reg_value;
+
+  // for watchpoints 0, 1, 2, or 3, respectively,
+  // clear bits 0, 1, 2, or 3 of the debug status register (DR6)
+  Error error = ReadRegisterRaw(m_reg_info.first_dr + 6, reg_value);
+  if (error.Fail())
+    return false;
+  uint64_t bit_mask = 1 << wp_index;
+  uint64_t status_bits = reg_value.GetAsUInt64() & ~bit_mask;
+  error = WriteRegisterRaw(m_reg_info.first_dr + 6, RegisterValue(status_bits));
+  if (error.Fail())
+    return false;
+
+  // for watchpoints 0, 1, 2, or 3, respectively,
+  // clear bits {0-1,16-19}, {2-3,20-23}, {4-5,24-27}, or {6-7,28-31}
+  // of the debug control register (DR7)
+  error = ReadRegisterRaw(m_reg_info.first_dr + 7, reg_value);
+  if (error.Fail())
+    return false;
+  bit_mask = (0x3 << (2 * wp_index)) | (0xF << (16 + 4 * wp_index));
+  uint64_t control_bits = reg_value.GetAsUInt64() & ~bit_mask;
+  return WriteRegisterRaw(m_reg_info.first_dr + 7, RegisterValue(control_bits))
+      .Success();
+}
+
+Error NativeRegisterContextLinux_x86_64::ClearAllHardwareWatchpoints() {
+  RegisterValue reg_value;
+
+  // clear bits {0-4} of the debug status register (DR6)
+  Error error = ReadRegisterRaw(m_reg_info.first_dr + 6, reg_value);
+  if (error.Fail())
+    return error;
+  uint64_t bit_mask = 0xF;
+  uint64_t status_bits = reg_value.GetAsUInt64() & ~bit_mask;
+  error = WriteRegisterRaw(m_reg_info.first_dr + 6, RegisterValue(status_bits));
+  if (error.Fail())
+    return error;
 
+  // clear bits {0-7,16-31} of the debug control register (DR7)
+  error = ReadRegisterRaw(m_reg_info.first_dr + 7, reg_value);
+  if (error.Fail())
+    return error;
+  bit_mask = 0xFF | (0xFFFF << 16);
+  uint64_t control_bits = reg_value.GetAsUInt64() & ~bit_mask;
+  return WriteRegisterRaw(m_reg_info.first_dr + 7, RegisterValue(control_bits));
+}
+
+uint32_t NativeRegisterContextLinux_x86_64::SetHardwareWatchpoint(
+    lldb::addr_t addr, size_t size, uint32_t watch_flags) {
+  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
+  const uint32_t num_hw_watchpoints = NumSupportedHardwareWatchpoints();
+  for (uint32_t wp_index = 0; wp_index < num_hw_watchpoints; ++wp_index) {
     bool is_vacant;
-    Error error = IsWatchpointVacant (wp_index, is_vacant);
-    if (error.Fail()) return error;
-    if (!is_vacant) return Error("Watchpoint index not vacant");
-
-    RegisterValue reg_value;
-    error = ReadRegisterRaw(m_reg_info.first_dr + 7, reg_value);
-    if (error.Fail()) return error;
-
-    // for watchpoints 0, 1, 2, or 3, respectively,
-    // set bits 1, 3, 5, or 7
-    uint64_t enable_bit = 1 << (2 * wp_index);
-
-    // set bits 16-17, 20-21, 24-25, or 28-29
-    // with 0b01 for write, and 0b11 for read/write
-    uint64_t rw_bits = watch_flags << (16 + 4 * wp_index);
-
-    // set bits 18-19, 22-23, 26-27, or 30-31
-    // with 0b00, 0b01, 0b10, or 0b11
-    // for 1, 2, 8 (if supported), or 4 bytes, respectively
-    uint64_t size_bits = (size == 8 ? 0x2 : size - 1) << (18 + 4 * wp_index);
-
-    uint64_t bit_mask = (0x3 << (2 * wp_index)) | (0xF << (16 + 4 * wp_index));
-
-    uint64_t control_bits = reg_value.GetAsUInt64() & ~bit_mask;
-
-    control_bits |= enable_bit | rw_bits | size_bits;
-
-    error = WriteRegisterRaw(m_reg_info.first_dr + wp_index, RegisterValue(addr));
-    if (error.Fail()) return error;
-
-    error = WriteRegisterRaw(m_reg_info.first_dr + 7, RegisterValue(control_bits));
-    if (error.Fail()) return error;
-
-    error.Clear();
-    return error;
-}
-
-bool
-NativeRegisterContextLinux_x86_64::ClearHardwareWatchpoint(uint32_t wp_index)
-{
-    if (wp_index >= NumSupportedHardwareWatchpoints())
-        return false;
-
-    RegisterValue reg_value;
-
-    // for watchpoints 0, 1, 2, or 3, respectively,
-    // clear bits 0, 1, 2, or 3 of the debug status register (DR6)
-    Error error = ReadRegisterRaw(m_reg_info.first_dr + 6, reg_value);
-    if (error.Fail()) return false;
-    uint64_t bit_mask = 1 << wp_index;
-    uint64_t status_bits = reg_value.GetAsUInt64() & ~bit_mask;
-    error = WriteRegisterRaw(m_reg_info.first_dr + 6, RegisterValue(status_bits));
-    if (error.Fail()) return false;
-
-    // for watchpoints 0, 1, 2, or 3, respectively,
-    // clear bits {0-1,16-19}, {2-3,20-23}, {4-5,24-27}, or {6-7,28-31}
-    // of the debug control register (DR7)
-    error = ReadRegisterRaw(m_reg_info.first_dr + 7, reg_value);
-    if (error.Fail()) return false;
-    bit_mask = (0x3 << (2 * wp_index)) | (0xF << (16 + 4 * wp_index));
-    uint64_t control_bits = reg_value.GetAsUInt64() & ~bit_mask;
-    return WriteRegisterRaw(m_reg_info.first_dr + 7, RegisterValue(control_bits)).Success();
-}
-
-Error
-NativeRegisterContextLinux_x86_64::ClearAllHardwareWatchpoints()
-{
-    RegisterValue reg_value;
-
-    // clear bits {0-4} of the debug status register (DR6)
-    Error error = ReadRegisterRaw(m_reg_info.first_dr + 6, reg_value);
-    if (error.Fail()) return error;
-    uint64_t bit_mask = 0xF;
-    uint64_t status_bits = reg_value.GetAsUInt64() & ~bit_mask;
-    error = WriteRegisterRaw(m_reg_info.first_dr + 6, RegisterValue(status_bits));
-    if (error.Fail()) return error;
-
-    // clear bits {0-7,16-31} of the debug control register (DR7)
-    error = ReadRegisterRaw(m_reg_info.first_dr + 7, reg_value);
-    if (error.Fail()) return error;
-    bit_mask = 0xFF | (0xFFFF << 16);
-    uint64_t control_bits = reg_value.GetAsUInt64() & ~bit_mask;
-    return WriteRegisterRaw(m_reg_info.first_dr + 7, RegisterValue(control_bits));
-}
-
-uint32_t
-NativeRegisterContextLinux_x86_64::SetHardwareWatchpoint(
-        lldb::addr_t addr, size_t size, uint32_t watch_flags)
-{
-    Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
-    const uint32_t num_hw_watchpoints = NumSupportedHardwareWatchpoints();
-    for (uint32_t wp_index = 0; wp_index < num_hw_watchpoints; ++wp_index)
-    {
-        bool is_vacant;
-        Error error = IsWatchpointVacant(wp_index, is_vacant);
-        if (is_vacant)
-        {
-            error = SetHardwareWatchpointWithIndex(addr, size, watch_flags, wp_index);
-            if (error.Success())
-                return wp_index;
-        }
-        if (error.Fail() && log)
-        {
-            log->Printf("NativeRegisterContextLinux_x86_64::%s Error: %s",
-                    __FUNCTION__, error.AsCString());
-        }
+    Error error = IsWatchpointVacant(wp_index, is_vacant);
+    if (is_vacant) {
+      error = SetHardwareWatchpointWithIndex(addr, size, watch_flags, wp_index);
+      if (error.Success())
+        return wp_index;
+    }
+    if (error.Fail() && log) {
+      log->Printf("NativeRegisterContextLinux_x86_64::%s Error: %s",
+                  __FUNCTION__, error.AsCString());
     }
-    return LLDB_INVALID_INDEX32;
+  }
+  return LLDB_INVALID_INDEX32;
 }
 
 lldb::addr_t
-NativeRegisterContextLinux_x86_64::GetWatchpointAddress(uint32_t wp_index)
-{
-    if (wp_index >= NumSupportedHardwareWatchpoints())
-        return LLDB_INVALID_ADDRESS;
-    RegisterValue reg_value;
-    if (ReadRegisterRaw(m_reg_info.first_dr + wp_index, reg_value).Fail())
-        return LLDB_INVALID_ADDRESS;
-    return reg_value.GetAsUInt64();
+NativeRegisterContextLinux_x86_64::GetWatchpointAddress(uint32_t wp_index) {
+  if (wp_index >= NumSupportedHardwareWatchpoints())
+    return LLDB_INVALID_ADDRESS;
+  RegisterValue reg_value;
+  if (ReadRegisterRaw(m_reg_info.first_dr + wp_index, reg_value).Fail())
+    return LLDB_INVALID_ADDRESS;
+  return reg_value.GetAsUInt64();
 }
 
-uint32_t
-NativeRegisterContextLinux_x86_64::NumSupportedHardwareWatchpoints ()
-{
-    // Available debug address registers: dr0, dr1, dr2, dr3
-    return 4;
+uint32_t NativeRegisterContextLinux_x86_64::NumSupportedHardwareWatchpoints() {
+  // Available debug address registers: dr0, dr1, dr2, dr3
+  return 4;
 }
 
 #endif // defined(__i386__) || defined(__x86_64__)

Modified: lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h (original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h Tue Sep  6 15:57:50 2016
@@ -19,149 +19,116 @@
 namespace lldb_private {
 namespace process_linux {
 
-    class NativeProcessLinux;
+class NativeProcessLinux;
 
-    class NativeRegisterContextLinux_x86_64 : public NativeRegisterContextLinux
-    {
-    public:
-        NativeRegisterContextLinux_x86_64 (const ArchSpec& target_arch,
-                                           NativeThreadProtocol &native_thread,
-                                           uint32_t concrete_frame_idx);
+class NativeRegisterContextLinux_x86_64 : public NativeRegisterContextLinux {
+public:
+  NativeRegisterContextLinux_x86_64(const ArchSpec &target_arch,
+                                    NativeThreadProtocol &native_thread,
+                                    uint32_t concrete_frame_idx);
 
-        uint32_t
-        GetRegisterSetCount () const override;
+  uint32_t GetRegisterSetCount() const override;
 
-        const RegisterSet *
-        GetRegisterSet (uint32_t set_index) const override;
+  const RegisterSet *GetRegisterSet(uint32_t set_index) const override;
 
-        uint32_t
-        GetUserRegisterCount() const override;
+  uint32_t GetUserRegisterCount() const override;
 
-        Error
-        ReadRegister (const RegisterInfo *reg_info, RegisterValue &reg_value) override;
+  Error ReadRegister(const RegisterInfo *reg_info,
+                     RegisterValue &reg_value) override;
 
-        Error
-        WriteRegister (const RegisterInfo *reg_info, const RegisterValue &reg_value) override;
+  Error WriteRegister(const RegisterInfo *reg_info,
+                      const RegisterValue &reg_value) override;
 
-        Error
-        ReadAllRegisterValues (lldb::DataBufferSP &data_sp) override;
+  Error ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
 
-        Error
-        WriteAllRegisterValues (const lldb::DataBufferSP &data_sp) override;
+  Error WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
 
-        Error
-        IsWatchpointHit(uint32_t wp_index, bool &is_hit) override;
+  Error IsWatchpointHit(uint32_t wp_index, bool &is_hit) override;
 
-        Error
-        GetWatchpointHitIndex(uint32_t &wp_index, lldb::addr_t trap_addr) override;
+  Error GetWatchpointHitIndex(uint32_t &wp_index,
+                              lldb::addr_t trap_addr) override;
 
-        Error
-        IsWatchpointVacant(uint32_t wp_index, bool &is_vacant) override;
+  Error IsWatchpointVacant(uint32_t wp_index, bool &is_vacant) override;
 
-        bool
-        ClearHardwareWatchpoint(uint32_t wp_index) override;
+  bool ClearHardwareWatchpoint(uint32_t wp_index) override;
 
-        Error
-        ClearAllHardwareWatchpoints () override;
+  Error ClearAllHardwareWatchpoints() override;
 
-        Error
-        SetHardwareWatchpointWithIndex(lldb::addr_t addr, size_t size,
-                uint32_t watch_flags, uint32_t wp_index);
+  Error SetHardwareWatchpointWithIndex(lldb::addr_t addr, size_t size,
+                                       uint32_t watch_flags, uint32_t wp_index);
 
-        uint32_t
-        SetHardwareWatchpoint(lldb::addr_t addr, size_t size,
-                uint32_t watch_flags) override;
+  uint32_t SetHardwareWatchpoint(lldb::addr_t addr, size_t size,
+                                 uint32_t watch_flags) override;
 
-        lldb::addr_t
-        GetWatchpointAddress(uint32_t wp_index) override;
+  lldb::addr_t GetWatchpointAddress(uint32_t wp_index) override;
 
-        uint32_t
-        NumSupportedHardwareWatchpoints() override;
+  uint32_t NumSupportedHardwareWatchpoints() override;
 
-    protected:
-        void*
-        GetGPRBuffer() override { return &m_gpr_x86_64; }
+protected:
+  void *GetGPRBuffer() override { return &m_gpr_x86_64; }
 
-        void*
-        GetFPRBuffer() override;
+  void *GetFPRBuffer() override;
 
-        size_t
-        GetFPRSize() override;
+  size_t GetFPRSize() override;
 
-        Error
-        ReadFPR() override;
+  Error ReadFPR() override;
 
-        Error
-        WriteFPR() override;
+  Error WriteFPR() override;
 
-    private:
+private:
+  // Private member types.
+  enum FPRType { eFPRTypeNotValid = 0, eFPRTypeFXSAVE, eFPRTypeXSAVE };
 
-        // Private member types.
-        enum FPRType
-        {
-            eFPRTypeNotValid = 0,
-            eFPRTypeFXSAVE,
-            eFPRTypeXSAVE
-        };
+  // Info about register ranges.
+  struct RegInfo {
+    uint32_t num_registers;
+    uint32_t num_gpr_registers;
+    uint32_t num_fpr_registers;
+    uint32_t num_avx_registers;
 
-        // Info about register ranges.
-        struct RegInfo
-        {
-            uint32_t num_registers;
-            uint32_t num_gpr_registers;
-            uint32_t num_fpr_registers;
-            uint32_t num_avx_registers;
+    uint32_t last_gpr;
+    uint32_t first_fpr;
+    uint32_t last_fpr;
 
-            uint32_t last_gpr;
-            uint32_t first_fpr;
-            uint32_t last_fpr;
+    uint32_t first_st;
+    uint32_t last_st;
+    uint32_t first_mm;
+    uint32_t last_mm;
+    uint32_t first_xmm;
+    uint32_t last_xmm;
+    uint32_t first_ymm;
+    uint32_t last_ymm;
 
-            uint32_t first_st;
-            uint32_t last_st;
-            uint32_t first_mm;
-            uint32_t last_mm;
-            uint32_t first_xmm;
-            uint32_t last_xmm;
-            uint32_t first_ymm;
-            uint32_t last_ymm;
+    uint32_t first_dr;
+    uint32_t gpr_flags;
+  };
 
-            uint32_t first_dr;
-            uint32_t gpr_flags;
-        };
+  // Private member variables.
+  mutable FPRType m_fpr_type;
+  FPR m_fpr;
+  IOVEC m_iovec;
+  YMM m_ymm_set;
+  RegInfo m_reg_info;
+  uint64_t m_gpr_x86_64[k_num_gpr_registers_x86_64];
+  uint32_t m_fctrl_offset_in_userarea;
 
-        // Private member variables.
-        mutable FPRType m_fpr_type;
-        FPR m_fpr;
-        IOVEC m_iovec;
-        YMM m_ymm_set;
-        RegInfo m_reg_info;
-        uint64_t m_gpr_x86_64[k_num_gpr_registers_x86_64];
-        uint32_t m_fctrl_offset_in_userarea;
+  // Private member methods.
+  bool IsRegisterSetAvailable(uint32_t set_index) const;
 
-        // Private member methods.
-        bool IsRegisterSetAvailable (uint32_t set_index) const;
+  bool IsGPR(uint32_t reg_index) const;
 
-        bool
-        IsGPR(uint32_t reg_index) const;
+  FPRType GetFPRType() const;
 
-        FPRType
-        GetFPRType () const;
+  bool IsFPR(uint32_t reg_index) const;
 
-        bool
-        IsFPR(uint32_t reg_index) const;
+  bool IsFPR(uint32_t reg_index, FPRType fpr_type) const;
 
-        bool
-        IsFPR(uint32_t reg_index, FPRType fpr_type) const;
+  bool CopyXSTATEtoYMM(uint32_t reg_index, lldb::ByteOrder byte_order);
 
-        bool
-        CopyXSTATEtoYMM (uint32_t reg_index, lldb::ByteOrder byte_order);
+  bool CopyYMMtoXSTATE(uint32_t reg, lldb::ByteOrder byte_order);
 
-        bool
-        CopyYMMtoXSTATE(uint32_t reg, lldb::ByteOrder byte_order);
-
-        bool
-        IsAVX (uint32_t reg_index) const;
-    };
+  bool IsAVX(uint32_t reg_index) const;
+};
 
 } // namespace process_linux
 } // namespace lldb_private

Modified: lldb/trunk/source/Plugins/Process/Linux/NativeThreadLinux.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeThreadLinux.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/NativeThreadLinux.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeThreadLinux.cpp Tue Sep  6 15:57:50 2016
@@ -29,481 +29,454 @@
 
 #include <sys/syscall.h>
 // Try to define a macro to encapsulate the tgkill syscall
-#define tgkill(pid, tid, sig) \
-    syscall(__NR_tgkill, static_cast< ::pid_t>(pid), static_cast< ::pid_t>(tid), sig)
+#define tgkill(pid, tid, sig)                                                  \
+  syscall(__NR_tgkill, static_cast<::pid_t>(pid), static_cast<::pid_t>(tid),   \
+          sig)
 
 using namespace lldb;
 using namespace lldb_private;
 using namespace lldb_private::process_linux;
 
-namespace
-{
-    void LogThreadStopInfo (Log &log, const ThreadStopInfo &stop_info, const char *const header)
-    {
-        switch (stop_info.reason)
-        {
-            case eStopReasonNone:
-                log.Printf ("%s: %s no stop reason", __FUNCTION__, header);
-                return;
-            case eStopReasonTrace:
-                log.Printf ("%s: %s trace, stopping signal 0x%" PRIx32, __FUNCTION__, header, stop_info.details.signal.signo);
-                return;
-            case eStopReasonBreakpoint:
-                log.Printf ("%s: %s breakpoint, stopping signal 0x%" PRIx32, __FUNCTION__, header, stop_info.details.signal.signo);
-                return;
-            case eStopReasonWatchpoint:
-                log.Printf ("%s: %s watchpoint, stopping signal 0x%" PRIx32, __FUNCTION__, header, stop_info.details.signal.signo);
-                return;
-            case eStopReasonSignal:
-                log.Printf ("%s: %s signal 0x%02" PRIx32, __FUNCTION__, header, stop_info.details.signal.signo);
-                return;
-            case eStopReasonException:
-                log.Printf ("%s: %s exception type 0x%02" PRIx64, __FUNCTION__, header, stop_info.details.exception.type);
-                return;
-            case eStopReasonExec:
-                log.Printf ("%s: %s exec, stopping signal 0x%" PRIx32, __FUNCTION__, header, stop_info.details.signal.signo);
-                return;
-            case eStopReasonPlanComplete:
-                log.Printf ("%s: %s plan complete", __FUNCTION__, header);
-                return;
-            case eStopReasonThreadExiting:
-                log.Printf ("%s: %s thread exiting", __FUNCTION__, header);
-                return;
-            case eStopReasonInstrumentation:
-                log.Printf ("%s: %s instrumentation", __FUNCTION__, header);
-                return;
-            default:
-                log.Printf ("%s: %s invalid stop reason %" PRIu32, __FUNCTION__, header, static_cast<uint32_t> (stop_info.reason));
-        }
-    }
-}
+namespace {
+void LogThreadStopInfo(Log &log, const ThreadStopInfo &stop_info,
+                       const char *const header) {
+  switch (stop_info.reason) {
+  case eStopReasonNone:
+    log.Printf("%s: %s no stop reason", __FUNCTION__, header);
+    return;
+  case eStopReasonTrace:
+    log.Printf("%s: %s trace, stopping signal 0x%" PRIx32, __FUNCTION__, header,
+               stop_info.details.signal.signo);
+    return;
+  case eStopReasonBreakpoint:
+    log.Printf("%s: %s breakpoint, stopping signal 0x%" PRIx32, __FUNCTION__,
+               header, stop_info.details.signal.signo);
+    return;
+  case eStopReasonWatchpoint:
+    log.Printf("%s: %s watchpoint, stopping signal 0x%" PRIx32, __FUNCTION__,
+               header, stop_info.details.signal.signo);
+    return;
+  case eStopReasonSignal:
+    log.Printf("%s: %s signal 0x%02" PRIx32, __FUNCTION__, header,
+               stop_info.details.signal.signo);
+    return;
+  case eStopReasonException:
+    log.Printf("%s: %s exception type 0x%02" PRIx64, __FUNCTION__, header,
+               stop_info.details.exception.type);
+    return;
+  case eStopReasonExec:
+    log.Printf("%s: %s exec, stopping signal 0x%" PRIx32, __FUNCTION__, header,
+               stop_info.details.signal.signo);
+    return;
+  case eStopReasonPlanComplete:
+    log.Printf("%s: %s plan complete", __FUNCTION__, header);
+    return;
+  case eStopReasonThreadExiting:
+    log.Printf("%s: %s thread exiting", __FUNCTION__, header);
+    return;
+  case eStopReasonInstrumentation:
+    log.Printf("%s: %s instrumentation", __FUNCTION__, header);
+    return;
+  default:
+    log.Printf("%s: %s invalid stop reason %" PRIu32, __FUNCTION__, header,
+               static_cast<uint32_t>(stop_info.reason));
+  }
+}
+}
+
+NativeThreadLinux::NativeThreadLinux(NativeProcessLinux *process,
+                                     lldb::tid_t tid)
+    : NativeThreadProtocol(process, tid), m_state(StateType::eStateInvalid),
+      m_stop_info(), m_reg_context_sp(), m_stop_description() {}
+
+std::string NativeThreadLinux::GetName() {
+  NativeProcessProtocolSP process_sp = m_process_wp.lock();
+  if (!process_sp)
+    return "<unknown: no process>";
+
+  // const NativeProcessLinux *const process =
+  // reinterpret_cast<NativeProcessLinux*> (process_sp->get ());
+  llvm::SmallString<32> thread_name;
+  HostNativeThread::GetName(GetID(), thread_name);
+  return thread_name.c_str();
+}
+
+lldb::StateType NativeThreadLinux::GetState() { return m_state; }
+
+bool NativeThreadLinux::GetStopReason(ThreadStopInfo &stop_info,
+                                      std::string &description) {
+  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
+
+  description.clear();
+
+  switch (m_state) {
+  case eStateStopped:
+  case eStateCrashed:
+  case eStateExited:
+  case eStateSuspended:
+  case eStateUnloaded:
+    if (log)
+      LogThreadStopInfo(*log, m_stop_info, "m_stop_info in thread:");
+    stop_info = m_stop_info;
+    description = m_stop_description;
+    if (log)
+      LogThreadStopInfo(*log, stop_info, "returned stop_info:");
 
-NativeThreadLinux::NativeThreadLinux (NativeProcessLinux *process, lldb::tid_t tid) :
-    NativeThreadProtocol (process, tid),
-    m_state (StateType::eStateInvalid),
-    m_stop_info (),
-    m_reg_context_sp (),
-    m_stop_description ()
-{
-}
-
-std::string
-NativeThreadLinux::GetName()
-{
-    NativeProcessProtocolSP process_sp = m_process_wp.lock ();
-    if (!process_sp)
-        return "<unknown: no process>";
-
-    // const NativeProcessLinux *const process = reinterpret_cast<NativeProcessLinux*> (process_sp->get ());
-    llvm::SmallString<32> thread_name;
-    HostNativeThread::GetName(GetID(), thread_name);
-    return thread_name.c_str();
-}
-
-lldb::StateType
-NativeThreadLinux::GetState ()
-{
-    return m_state;
-}
-
-
-bool
-NativeThreadLinux::GetStopReason (ThreadStopInfo &stop_info, std::string& description)
-{
-    Log *log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));
-
-    description.clear();
-
-    switch (m_state)
-    {
-    case eStateStopped:
-    case eStateCrashed:
-    case eStateExited:
-    case eStateSuspended:
-    case eStateUnloaded:
-        if (log)
-            LogThreadStopInfo (*log, m_stop_info, "m_stop_info in thread:");
-        stop_info = m_stop_info;
-        description = m_stop_description;
-        if (log)
-            LogThreadStopInfo (*log, stop_info, "returned stop_info:");
-
-        return true;
-
-    case eStateInvalid:
-    case eStateConnected:
-    case eStateAttaching:
-    case eStateLaunching:
-    case eStateRunning:
-    case eStateStepping:
-    case eStateDetached:
-        if (log)
-        {
-            log->Printf ("NativeThreadLinux::%s tid %" PRIu64 " in state %s cannot answer stop reason",
-                    __FUNCTION__, GetID (), StateAsCString (m_state));
-        }
-        return false;
+    return true;
+
+  case eStateInvalid:
+  case eStateConnected:
+  case eStateAttaching:
+  case eStateLaunching:
+  case eStateRunning:
+  case eStateStepping:
+  case eStateDetached:
+    if (log) {
+      log->Printf("NativeThreadLinux::%s tid %" PRIu64
+                  " in state %s cannot answer stop reason",
+                  __FUNCTION__, GetID(), StateAsCString(m_state));
     }
-    llvm_unreachable("unhandled StateType!");
+    return false;
+  }
+  llvm_unreachable("unhandled StateType!");
 }
 
-NativeRegisterContextSP
-NativeThreadLinux::GetRegisterContext ()
-{
-    // Return the register context if we already created it.
-    if (m_reg_context_sp)
-        return m_reg_context_sp;
-
-    NativeProcessProtocolSP m_process_sp = m_process_wp.lock ();
-    if (!m_process_sp)
-        return NativeRegisterContextSP ();
-
-    ArchSpec target_arch;
-    if (!m_process_sp->GetArchitecture (target_arch))
-        return NativeRegisterContextSP ();
-
-    const uint32_t concrete_frame_idx = 0;
-    m_reg_context_sp.reset (NativeRegisterContextLinux::CreateHostNativeRegisterContextLinux(target_arch,
-                                                                                             *this,
-                                                                                             concrete_frame_idx));
-
+NativeRegisterContextSP NativeThreadLinux::GetRegisterContext() {
+  // Return the register context if we already created it.
+  if (m_reg_context_sp)
     return m_reg_context_sp;
-}
 
-Error
-NativeThreadLinux::SetWatchpoint (lldb::addr_t addr, size_t size, uint32_t watch_flags, bool hardware)
-{
-    if (!hardware)
-        return Error ("not implemented");
-    if (m_state == eStateLaunching)
-        return Error ();
-    Error error = RemoveWatchpoint(addr);
-    if (error.Fail()) return error;
-    NativeRegisterContextSP reg_ctx = GetRegisterContext ();
-    uint32_t wp_index =
-        reg_ctx->SetHardwareWatchpoint (addr, size, watch_flags);
-    if (wp_index == LLDB_INVALID_INDEX32)
-        return Error ("Setting hardware watchpoint failed.");
-    m_watchpoint_index_map.insert({addr, wp_index});
-    return Error ();
-}
-
-Error
-NativeThreadLinux::RemoveWatchpoint (lldb::addr_t addr)
-{
-    auto wp = m_watchpoint_index_map.find(addr);
-    if (wp == m_watchpoint_index_map.end())
-        return Error ();
-    uint32_t wp_index = wp->second;
-    m_watchpoint_index_map.erase(wp);
-    if (GetRegisterContext()->ClearHardwareWatchpoint(wp_index))
-        return Error ();
-    return Error ("Clearing hardware watchpoint failed.");
-}
-
-Error
-NativeThreadLinux::Resume(uint32_t signo)
-{
-    const StateType new_state = StateType::eStateRunning;
-    MaybeLogStateChange (new_state);
-    m_state = new_state;
-
-    m_stop_info.reason = StopReason::eStopReasonNone;
-    m_stop_description.clear();
-
-    // If watchpoints have been set, but none on this thread,
-    // then this is a new thread. So set all existing watchpoints.
-    if (m_watchpoint_index_map.empty())
-    {
-        NativeProcessLinux &process = GetProcess();
-
-        const auto &watchpoint_map = process.GetWatchpointMap();
-        GetRegisterContext()->ClearAllHardwareWatchpoints();
-        for (const auto &pair : watchpoint_map)
-        {
-            const auto &wp = pair.second;
-            SetWatchpoint(wp.m_addr, wp.m_size, wp.m_watch_flags, wp.m_hardware);
-        }
+  NativeProcessProtocolSP m_process_sp = m_process_wp.lock();
+  if (!m_process_sp)
+    return NativeRegisterContextSP();
+
+  ArchSpec target_arch;
+  if (!m_process_sp->GetArchitecture(target_arch))
+    return NativeRegisterContextSP();
+
+  const uint32_t concrete_frame_idx = 0;
+  m_reg_context_sp.reset(
+      NativeRegisterContextLinux::CreateHostNativeRegisterContextLinux(
+          target_arch, *this, concrete_frame_idx));
+
+  return m_reg_context_sp;
+}
+
+Error NativeThreadLinux::SetWatchpoint(lldb::addr_t addr, size_t size,
+                                       uint32_t watch_flags, bool hardware) {
+  if (!hardware)
+    return Error("not implemented");
+  if (m_state == eStateLaunching)
+    return Error();
+  Error error = RemoveWatchpoint(addr);
+  if (error.Fail())
+    return error;
+  NativeRegisterContextSP reg_ctx = GetRegisterContext();
+  uint32_t wp_index = reg_ctx->SetHardwareWatchpoint(addr, size, watch_flags);
+  if (wp_index == LLDB_INVALID_INDEX32)
+    return Error("Setting hardware watchpoint failed.");
+  m_watchpoint_index_map.insert({addr, wp_index});
+  return Error();
+}
+
+Error NativeThreadLinux::RemoveWatchpoint(lldb::addr_t addr) {
+  auto wp = m_watchpoint_index_map.find(addr);
+  if (wp == m_watchpoint_index_map.end())
+    return Error();
+  uint32_t wp_index = wp->second;
+  m_watchpoint_index_map.erase(wp);
+  if (GetRegisterContext()->ClearHardwareWatchpoint(wp_index))
+    return Error();
+  return Error("Clearing hardware watchpoint failed.");
+}
+
+Error NativeThreadLinux::Resume(uint32_t signo) {
+  const StateType new_state = StateType::eStateRunning;
+  MaybeLogStateChange(new_state);
+  m_state = new_state;
+
+  m_stop_info.reason = StopReason::eStopReasonNone;
+  m_stop_description.clear();
+
+  // If watchpoints have been set, but none on this thread,
+  // then this is a new thread. So set all existing watchpoints.
+  if (m_watchpoint_index_map.empty()) {
+    NativeProcessLinux &process = GetProcess();
+
+    const auto &watchpoint_map = process.GetWatchpointMap();
+    GetRegisterContext()->ClearAllHardwareWatchpoints();
+    for (const auto &pair : watchpoint_map) {
+      const auto &wp = pair.second;
+      SetWatchpoint(wp.m_addr, wp.m_size, wp.m_watch_flags, wp.m_hardware);
     }
+  }
 
-    intptr_t data = 0;
+  intptr_t data = 0;
 
-    if (signo != LLDB_INVALID_SIGNAL_NUMBER)
-        data = signo;
+  if (signo != LLDB_INVALID_SIGNAL_NUMBER)
+    data = signo;
 
-    return NativeProcessLinux::PtraceWrapper(PTRACE_CONT, GetID(), nullptr, reinterpret_cast<void *>(data));
+  return NativeProcessLinux::PtraceWrapper(PTRACE_CONT, GetID(), nullptr,
+                                           reinterpret_cast<void *>(data));
 }
 
-void
-NativeThreadLinux::MaybePrepareSingleStepWorkaround()
-{
-    if (!SingleStepWorkaroundNeeded())
-        return;
+void NativeThreadLinux::MaybePrepareSingleStepWorkaround() {
+  if (!SingleStepWorkaroundNeeded())
+    return;
 
-    Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
+  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
 
-    if (sched_getaffinity(static_cast<::pid_t>(m_tid), sizeof m_original_cpu_set, &m_original_cpu_set) != 0)
-    {
-        // This should really not fail. But, just in case...
-        if (log)
-        {
-            Error error(errno, eErrorTypePOSIX);
-            log->Printf("NativeThreadLinux::%s Unable to get cpu affinity for thread %" PRIx64 ": %s", __FUNCTION__,
-                        m_tid, error.AsCString());
-        }
-        return;
+  if (sched_getaffinity(static_cast<::pid_t>(m_tid), sizeof m_original_cpu_set,
+                        &m_original_cpu_set) != 0) {
+    // This should really not fail. But, just in case...
+    if (log) {
+      Error error(errno, eErrorTypePOSIX);
+      log->Printf(
+          "NativeThreadLinux::%s Unable to get cpu affinity for thread %" PRIx64
+          ": %s",
+          __FUNCTION__, m_tid, error.AsCString());
     }
+    return;
+  }
 
-    cpu_set_t set;
-    CPU_ZERO(&set);
-    CPU_SET(0, &set);
-    if (sched_setaffinity(static_cast<::pid_t>(m_tid), sizeof set, &set) != 0 && log)
-    {
-        // This may fail in very locked down systems, if the thread is not allowed to run on
-        // cpu 0. If that happens, only thing we can do is it log it and continue...
-        Error error(errno, eErrorTypePOSIX);
-        log->Printf("NativeThreadLinux::%s Unable to set cpu affinity for thread %" PRIx64 ": %s", __FUNCTION__, m_tid,
-                    error.AsCString());
-    }
-}
-
-void
-NativeThreadLinux::MaybeCleanupSingleStepWorkaround()
-{
-    if (!SingleStepWorkaroundNeeded())
-        return;
-
-    if (sched_setaffinity(static_cast<::pid_t>(m_tid), sizeof m_original_cpu_set, &m_original_cpu_set) != 0)
-    {
-        Error error(errno, eErrorTypePOSIX);
-        Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
-        log->Printf("NativeThreadLinux::%s Unable to reset cpu affinity for thread %" PRIx64 ": %s", __FUNCTION__,
-                    m_tid, error.AsCString());
+  cpu_set_t set;
+  CPU_ZERO(&set);
+  CPU_SET(0, &set);
+  if (sched_setaffinity(static_cast<::pid_t>(m_tid), sizeof set, &set) != 0 &&
+      log) {
+    // This may fail in very locked down systems, if the thread is not allowed
+    // to run on
+    // cpu 0. If that happens, only thing we can do is it log it and continue...
+    Error error(errno, eErrorTypePOSIX);
+    log->Printf(
+        "NativeThreadLinux::%s Unable to set cpu affinity for thread %" PRIx64
+        ": %s",
+        __FUNCTION__, m_tid, error.AsCString());
+  }
+}
+
+void NativeThreadLinux::MaybeCleanupSingleStepWorkaround() {
+  if (!SingleStepWorkaroundNeeded())
+    return;
+
+  if (sched_setaffinity(static_cast<::pid_t>(m_tid), sizeof m_original_cpu_set,
+                        &m_original_cpu_set) != 0) {
+    Error error(errno, eErrorTypePOSIX);
+    Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
+    log->Printf(
+        "NativeThreadLinux::%s Unable to reset cpu affinity for thread %" PRIx64
+        ": %s",
+        __FUNCTION__, m_tid, error.AsCString());
+  }
+}
+
+Error NativeThreadLinux::SingleStep(uint32_t signo) {
+  const StateType new_state = StateType::eStateStepping;
+  MaybeLogStateChange(new_state);
+  m_state = new_state;
+  m_stop_info.reason = StopReason::eStopReasonNone;
+
+  MaybePrepareSingleStepWorkaround();
+
+  intptr_t data = 0;
+  if (signo != LLDB_INVALID_SIGNAL_NUMBER)
+    data = signo;
+
+  // If hardware single-stepping is not supported, we just do a continue. The
+  // breakpoint on the
+  // next instruction has been setup in NativeProcessLinux::Resume.
+  return NativeProcessLinux::PtraceWrapper(
+      GetProcess().SupportHardwareSingleStepping() ? PTRACE_SINGLESTEP
+                                                   : PTRACE_CONT,
+      m_tid, nullptr, reinterpret_cast<void *>(data));
+}
+
+void NativeThreadLinux::SetStoppedBySignal(uint32_t signo,
+                                           const siginfo_t *info) {
+  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
+  if (log)
+    log->Printf("NativeThreadLinux::%s called with signal 0x%02" PRIx32,
+                __FUNCTION__, signo);
+
+  SetStopped();
+
+  m_stop_info.reason = StopReason::eStopReasonSignal;
+  m_stop_info.details.signal.signo = signo;
+
+  m_stop_description.clear();
+  if (info) {
+    switch (signo) {
+    case SIGSEGV:
+    case SIGBUS:
+    case SIGFPE:
+    case SIGILL:
+      // In case of MIPS64 target, SI_KERNEL is generated for invalid 64bit
+      // address.
+      const auto reason =
+          (info->si_signo == SIGBUS && info->si_code == SI_KERNEL)
+              ? CrashReason::eInvalidAddress
+              : GetCrashReason(*info);
+      m_stop_description = GetCrashReasonString(
+          reason, reinterpret_cast<uintptr_t>(info->si_addr));
+      break;
     }
+  }
 }
 
-Error
-NativeThreadLinux::SingleStep(uint32_t signo)
-{
-    const StateType new_state = StateType::eStateStepping;
-    MaybeLogStateChange (new_state);
-    m_state = new_state;
-    m_stop_info.reason = StopReason::eStopReasonNone;
-
-    MaybePrepareSingleStepWorkaround();
-
-    intptr_t data = 0;
-    if (signo != LLDB_INVALID_SIGNAL_NUMBER)
-        data = signo;
-
-    // If hardware single-stepping is not supported, we just do a continue. The breakpoint on the
-    // next instruction has been setup in NativeProcessLinux::Resume.
-    return NativeProcessLinux::PtraceWrapper(GetProcess().SupportHardwareSingleStepping() ? PTRACE_SINGLESTEP
-                                                                                          : PTRACE_CONT,
-                                             m_tid, nullptr, reinterpret_cast<void *>(data));
-}
-
-void
-NativeThreadLinux::SetStoppedBySignal(uint32_t signo, const siginfo_t *info)
-{
-    Log *log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));
-    if (log)
-        log->Printf ("NativeThreadLinux::%s called with signal 0x%02" PRIx32, __FUNCTION__, signo);
-
-    SetStopped();
+bool NativeThreadLinux::IsStopped(int *signo) {
+  if (!StateIsStoppedState(m_state, false))
+    return false;
 
-    m_stop_info.reason = StopReason::eStopReasonSignal;
-    m_stop_info.details.signal.signo = signo;
+  // If we are stopped by a signal, return the signo.
+  if (signo && m_state == StateType::eStateStopped &&
+      m_stop_info.reason == StopReason::eStopReasonSignal) {
+    *signo = m_stop_info.details.signal.signo;
+  }
 
-    m_stop_description.clear();
-    if (info)
-    {
-        switch (signo)
-        {
-        case SIGSEGV:
-        case SIGBUS:
-        case SIGFPE:
-        case SIGILL:
-             //In case of MIPS64 target, SI_KERNEL is generated for invalid 64bit address.
-             const auto reason = (info->si_signo == SIGBUS && info->si_code == SI_KERNEL) ? 
-                                  CrashReason::eInvalidAddress : GetCrashReason(*info);
-             m_stop_description = GetCrashReasonString(reason, reinterpret_cast<uintptr_t>(info->si_addr));
-             break;
-        }
-    }
+  // Regardless, we are stopped.
+  return true;
 }
 
-bool
-NativeThreadLinux::IsStopped (int *signo)
-{
-    if (!StateIsStoppedState (m_state, false))
-        return false;
-
-    // If we are stopped by a signal, return the signo.
-    if (signo &&
-        m_state == StateType::eStateStopped &&
-        m_stop_info.reason == StopReason::eStopReasonSignal)
-    {
-        *signo = m_stop_info.details.signal.signo;
-    }
+void NativeThreadLinux::SetStopped() {
+  if (m_state == StateType::eStateStepping)
+    MaybeCleanupSingleStepWorkaround();
 
-    // Regardless, we are stopped.
-    return true;
+  const StateType new_state = StateType::eStateStopped;
+  MaybeLogStateChange(new_state);
+  m_state = new_state;
+  m_stop_description.clear();
 }
 
-void
-NativeThreadLinux::SetStopped()
-{
-    if (m_state == StateType::eStateStepping)
-        MaybeCleanupSingleStepWorkaround();
-
-    const StateType new_state = StateType::eStateStopped;
-    MaybeLogStateChange(new_state);
-    m_state = new_state;
-    m_stop_description.clear();
-}
-
-void
-NativeThreadLinux::SetStoppedByExec ()
-{
-    Log *log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));
-    if (log)
-        log->Printf ("NativeThreadLinux::%s()", __FUNCTION__);
+void NativeThreadLinux::SetStoppedByExec() {
+  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
+  if (log)
+    log->Printf("NativeThreadLinux::%s()", __FUNCTION__);
 
-    SetStopped();
+  SetStopped();
 
-    m_stop_info.reason = StopReason::eStopReasonExec;
-    m_stop_info.details.signal.signo = SIGSTOP;
+  m_stop_info.reason = StopReason::eStopReasonExec;
+  m_stop_info.details.signal.signo = SIGSTOP;
 }
 
-void
-NativeThreadLinux::SetStoppedByBreakpoint ()
-{
-    SetStopped();
+void NativeThreadLinux::SetStoppedByBreakpoint() {
+  SetStopped();
 
-    m_stop_info.reason = StopReason::eStopReasonBreakpoint;
-    m_stop_info.details.signal.signo = SIGTRAP;
-    m_stop_description.clear();
+  m_stop_info.reason = StopReason::eStopReasonBreakpoint;
+  m_stop_info.details.signal.signo = SIGTRAP;
+  m_stop_description.clear();
 }
 
-void
-NativeThreadLinux::SetStoppedByWatchpoint (uint32_t wp_index)
-{
-    SetStopped();
+void NativeThreadLinux::SetStoppedByWatchpoint(uint32_t wp_index) {
+  SetStopped();
 
-    lldbassert(wp_index != LLDB_INVALID_INDEX32 &&
-               "wp_index cannot be invalid");
+  lldbassert(wp_index != LLDB_INVALID_INDEX32 && "wp_index cannot be invalid");
 
-    std::ostringstream ostr;
-    ostr << GetRegisterContext()->GetWatchpointAddress(wp_index) << " ";
-    ostr << wp_index;
+  std::ostringstream ostr;
+  ostr << GetRegisterContext()->GetWatchpointAddress(wp_index) << " ";
+  ostr << wp_index;
 
-    /*
-     * MIPS: Last 3bits of the watchpoint address are masked by the kernel. For example:
-     * 'n' is at 0x120010d00 and 'm' is 0x120010d04. When a watchpoint is set at 'm', then
-     * watch exception is generated even when 'n' is read/written. To handle this case,
-     * find the base address of the load/store instruction and append it in the stop-info 
-     * packet.
-    */
-    ostr << " " << GetRegisterContext()->GetWatchpointHitAddress(wp_index);
+  /*
+   * MIPS: Last 3bits of the watchpoint address are masked by the kernel. For
+   * example:
+   * 'n' is at 0x120010d00 and 'm' is 0x120010d04. When a watchpoint is set at
+   * 'm', then
+   * watch exception is generated even when 'n' is read/written. To handle this
+   * case,
+   * find the base address of the load/store instruction and append it in the
+   * stop-info
+   * packet.
+  */
+  ostr << " " << GetRegisterContext()->GetWatchpointHitAddress(wp_index);
 
-    m_stop_description = ostr.str();
+  m_stop_description = ostr.str();
 
-    m_stop_info.reason = StopReason::eStopReasonWatchpoint;
-    m_stop_info.details.signal.signo = SIGTRAP;
+  m_stop_info.reason = StopReason::eStopReasonWatchpoint;
+  m_stop_info.details.signal.signo = SIGTRAP;
 }
 
-bool
-NativeThreadLinux::IsStoppedAtBreakpoint ()
-{
-    return GetState () == StateType::eStateStopped &&
-        m_stop_info.reason == StopReason::eStopReasonBreakpoint;
+bool NativeThreadLinux::IsStoppedAtBreakpoint() {
+  return GetState() == StateType::eStateStopped &&
+         m_stop_info.reason == StopReason::eStopReasonBreakpoint;
 }
 
-bool
-NativeThreadLinux::IsStoppedAtWatchpoint ()
-{
-    return GetState () == StateType::eStateStopped &&
-        m_stop_info.reason == StopReason::eStopReasonWatchpoint;
+bool NativeThreadLinux::IsStoppedAtWatchpoint() {
+  return GetState() == StateType::eStateStopped &&
+         m_stop_info.reason == StopReason::eStopReasonWatchpoint;
 }
 
-void
-NativeThreadLinux::SetStoppedByTrace ()
-{
-    SetStopped();
+void NativeThreadLinux::SetStoppedByTrace() {
+  SetStopped();
 
-    m_stop_info.reason = StopReason::eStopReasonTrace;
-    m_stop_info.details.signal.signo = SIGTRAP;
+  m_stop_info.reason = StopReason::eStopReasonTrace;
+  m_stop_info.details.signal.signo = SIGTRAP;
 }
 
-void
-NativeThreadLinux::SetStoppedWithNoReason ()
-{
-    SetStopped();
+void NativeThreadLinux::SetStoppedWithNoReason() {
+  SetStopped();
 
-    m_stop_info.reason = StopReason::eStopReasonNone;
-    m_stop_info.details.signal.signo = 0;
+  m_stop_info.reason = StopReason::eStopReasonNone;
+  m_stop_info.details.signal.signo = 0;
 }
 
-void
-NativeThreadLinux::SetExited ()
-{
-    const StateType new_state = StateType::eStateExited;
-    MaybeLogStateChange (new_state);
-    m_state = new_state;
+void NativeThreadLinux::SetExited() {
+  const StateType new_state = StateType::eStateExited;
+  MaybeLogStateChange(new_state);
+  m_state = new_state;
 
-    m_stop_info.reason = StopReason::eStopReasonThreadExiting;
+  m_stop_info.reason = StopReason::eStopReasonThreadExiting;
 }
 
-Error
-NativeThreadLinux::RequestStop ()
-{
-    Log* log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));
+Error NativeThreadLinux::RequestStop() {
+  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
 
-    NativeProcessLinux &process = GetProcess();
-
-    lldb::pid_t pid = process.GetID();
-    lldb::tid_t tid = GetID();
+  NativeProcessLinux &process = GetProcess();
 
-    if (log)
-        log->Printf ("NativeThreadLinux::%s requesting thread stop(pid: %" PRIu64 ", tid: %" PRIu64 ")", __FUNCTION__, pid, tid);
+  lldb::pid_t pid = process.GetID();
+  lldb::tid_t tid = GetID();
 
-    Error err;
-    errno = 0;
-    if (::tgkill (pid, tid, SIGSTOP) != 0)
-    {
-        err.SetErrorToErrno ();
-        if (log)
-            log->Printf ("NativeThreadLinux::%s tgkill(%" PRIu64 ", %" PRIu64 ", SIGSTOP) failed: %s", __FUNCTION__, pid, tid, err.AsCString ());
-    }
+  if (log)
+    log->Printf("NativeThreadLinux::%s requesting thread stop(pid: %" PRIu64
+                ", tid: %" PRIu64 ")",
+                __FUNCTION__, pid, tid);
 
-    return err;
-}
-
-void
-NativeThreadLinux::MaybeLogStateChange (lldb::StateType new_state)
-{
-    Log *log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));
-    // If we're not logging, we're done.
-    if (!log)
-        return;
-
-    // If this is a state change to the same state, we're done.
-    lldb::StateType old_state = m_state;
-    if (new_state == old_state)
-        return;
-
-    NativeProcessProtocolSP m_process_sp = m_process_wp.lock ();
-    lldb::pid_t pid = m_process_sp ? m_process_sp->GetID () : LLDB_INVALID_PROCESS_ID;
-
-    // Log it.
-    log->Printf ("NativeThreadLinux: thread (pid=%" PRIu64 ", tid=%" PRIu64 ") changing from state %s to %s", pid, GetID (), StateAsCString (old_state), StateAsCString (new_state));
-}
-
-NativeProcessLinux &
-NativeThreadLinux::GetProcess()
-{
-    auto process_sp = std::static_pointer_cast<NativeProcessLinux>(NativeThreadProtocol::GetProcess());
-    assert(process_sp);
-    return *process_sp;
+  Error err;
+  errno = 0;
+  if (::tgkill(pid, tid, SIGSTOP) != 0) {
+    err.SetErrorToErrno();
+    if (log)
+      log->Printf("NativeThreadLinux::%s tgkill(%" PRIu64 ", %" PRIu64
+                  ", SIGSTOP) failed: %s",
+                  __FUNCTION__, pid, tid, err.AsCString());
+  }
+
+  return err;
+}
+
+void NativeThreadLinux::MaybeLogStateChange(lldb::StateType new_state) {
+  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
+  // If we're not logging, we're done.
+  if (!log)
+    return;
+
+  // If this is a state change to the same state, we're done.
+  lldb::StateType old_state = m_state;
+  if (new_state == old_state)
+    return;
+
+  NativeProcessProtocolSP m_process_sp = m_process_wp.lock();
+  lldb::pid_t pid =
+      m_process_sp ? m_process_sp->GetID() : LLDB_INVALID_PROCESS_ID;
+
+  // Log it.
+  log->Printf("NativeThreadLinux: thread (pid=%" PRIu64 ", tid=%" PRIu64
+              ") changing from state %s to %s",
+              pid, GetID(), StateAsCString(old_state),
+              StateAsCString(new_state));
+}
+
+NativeProcessLinux &NativeThreadLinux::GetProcess() {
+  auto process_sp = std::static_pointer_cast<NativeProcessLinux>(
+      NativeThreadProtocol::GetProcess());
+  assert(process_sp);
+  return *process_sp;
 }

Modified: lldb/trunk/source/Plugins/Process/Linux/NativeThreadLinux.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeThreadLinux.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/NativeThreadLinux.h (original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeThreadLinux.h Tue Sep  6 15:57:50 2016
@@ -10,8 +10,8 @@
 #ifndef liblldb_NativeThreadLinux_H_
 #define liblldb_NativeThreadLinux_H_
 
-#include "lldb/lldb-private-forward.h"
 #include "lldb/Host/common/NativeThreadProtocol.h"
+#include "lldb/lldb-private-forward.h"
 
 #include <sched.h>
 
@@ -22,118 +22,95 @@
 namespace lldb_private {
 namespace process_linux {
 
-    class NativeProcessLinux;
+class NativeProcessLinux;
 
-    class NativeThreadLinux : public NativeThreadProtocol
-    {
-        friend class NativeProcessLinux;
+class NativeThreadLinux : public NativeThreadProtocol {
+  friend class NativeProcessLinux;
 
-    public:
-        NativeThreadLinux (NativeProcessLinux *process, lldb::tid_t tid);
+public:
+  NativeThreadLinux(NativeProcessLinux *process, lldb::tid_t tid);
 
-        // ---------------------------------------------------------------------
-        // NativeThreadProtocol Interface
-        // ---------------------------------------------------------------------
-        std::string
-        GetName() override;
+  // ---------------------------------------------------------------------
+  // NativeThreadProtocol Interface
+  // ---------------------------------------------------------------------
+  std::string GetName() override;
 
-        lldb::StateType
-        GetState () override;
+  lldb::StateType GetState() override;
 
-        bool
-        GetStopReason (ThreadStopInfo &stop_info, std::string& description) override;
+  bool GetStopReason(ThreadStopInfo &stop_info,
+                     std::string &description) override;
 
-        NativeRegisterContextSP
-        GetRegisterContext () override;
+  NativeRegisterContextSP GetRegisterContext() override;
 
-        Error
-        SetWatchpoint (lldb::addr_t addr, size_t size, uint32_t watch_flags, bool hardware) override;
+  Error SetWatchpoint(lldb::addr_t addr, size_t size, uint32_t watch_flags,
+                      bool hardware) override;
 
-        Error
-        RemoveWatchpoint (lldb::addr_t addr) override;
+  Error RemoveWatchpoint(lldb::addr_t addr) override;
 
-    private:
-        // ---------------------------------------------------------------------
-        // Interface for friend classes
-        // ---------------------------------------------------------------------
+private:
+  // ---------------------------------------------------------------------
+  // Interface for friend classes
+  // ---------------------------------------------------------------------
 
-        /// Resumes the thread.  If @p signo is anything but
-        /// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the thread.
-        Error
-        Resume(uint32_t signo);
+  /// Resumes the thread.  If @p signo is anything but
+  /// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the thread.
+  Error Resume(uint32_t signo);
 
-        /// Single steps the thread.  If @p signo is anything but
-        /// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the thread.
-        Error
-        SingleStep(uint32_t signo);
+  /// Single steps the thread.  If @p signo is anything but
+  /// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the thread.
+  Error SingleStep(uint32_t signo);
 
-        void
-        SetStoppedBySignal(uint32_t signo, const siginfo_t *info = nullptr);
+  void SetStoppedBySignal(uint32_t signo, const siginfo_t *info = nullptr);
 
-        /// Return true if the thread is stopped.
-        /// If stopped by a signal, indicate the signo in the signo argument.
-        /// Otherwise, return LLDB_INVALID_SIGNAL_NUMBER.
-        bool
-        IsStopped (int *signo);
+  /// Return true if the thread is stopped.
+  /// If stopped by a signal, indicate the signo in the signo argument.
+  /// Otherwise, return LLDB_INVALID_SIGNAL_NUMBER.
+  bool IsStopped(int *signo);
 
-        void
-        SetStoppedByExec ();
+  void SetStoppedByExec();
 
-        void
-        SetStoppedByBreakpoint ();
+  void SetStoppedByBreakpoint();
 
-        void
-        SetStoppedByWatchpoint (uint32_t wp_index);
+  void SetStoppedByWatchpoint(uint32_t wp_index);
 
-        bool
-        IsStoppedAtBreakpoint ();
+  bool IsStoppedAtBreakpoint();
 
-        bool
-        IsStoppedAtWatchpoint ();
+  bool IsStoppedAtWatchpoint();
 
-        void
-        SetStoppedByTrace ();
+  void SetStoppedByTrace();
 
-        void
-        SetStoppedWithNoReason ();
+  void SetStoppedWithNoReason();
 
-        void
-        SetExited ();
+  void SetExited();
 
-        Error
-        RequestStop ();
+  Error RequestStop();
 
-        // ---------------------------------------------------------------------
-        // Private interface
-        // ---------------------------------------------------------------------
-        void
-        MaybeLogStateChange (lldb::StateType new_state);
+  // ---------------------------------------------------------------------
+  // Private interface
+  // ---------------------------------------------------------------------
+  void MaybeLogStateChange(lldb::StateType new_state);
 
-        NativeProcessLinux &
-        GetProcess();
+  NativeProcessLinux &GetProcess();
 
-        void
-        SetStopped();
+  void SetStopped();
 
-        inline void
-        MaybePrepareSingleStepWorkaround();
+  inline void MaybePrepareSingleStepWorkaround();
 
-        inline void
-        MaybeCleanupSingleStepWorkaround();
+  inline void MaybeCleanupSingleStepWorkaround();
 
-        // ---------------------------------------------------------------------
-        // Member Variables
-        // ---------------------------------------------------------------------
-        lldb::StateType m_state;
-        ThreadStopInfo m_stop_info;
-        NativeRegisterContextSP m_reg_context_sp;
-        std::string m_stop_description;
-        using WatchpointIndexMap = std::map<lldb::addr_t, uint32_t>;
-        WatchpointIndexMap m_watchpoint_index_map;
-        cpu_set_t m_original_cpu_set; // For single-step workaround.
-    };
+  // ---------------------------------------------------------------------
+  // Member Variables
+  // ---------------------------------------------------------------------
+  lldb::StateType m_state;
+  ThreadStopInfo m_stop_info;
+  NativeRegisterContextSP m_reg_context_sp;
+  std::string m_stop_description;
+  using WatchpointIndexMap = std::map<lldb::addr_t, uint32_t>;
+  WatchpointIndexMap m_watchpoint_index_map;
+  cpu_set_t m_original_cpu_set; // For single-step workaround.
+};
 
-    typedef std::shared_ptr<NativeThreadLinux> NativeThreadLinuxSP;
+typedef std::shared_ptr<NativeThreadLinux> NativeThreadLinuxSP;
 } // namespace process_linux
 } // namespace lldb_private
 

Modified: lldb/trunk/source/Plugins/Process/Linux/ProcFileReader.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcFileReader.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/ProcFileReader.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/ProcFileReader.cpp Tue Sep  6 15:57:50 2016
@@ -26,83 +26,78 @@
 using namespace lldb_private;
 using namespace lldb_private::process_linux;
 
-lldb::DataBufferSP
-ProcFileReader::ReadIntoDataBuffer (lldb::pid_t pid, const char *name)
-{
-    int fd;
-    char path[PATH_MAX];
-
-    // Make sure we've got a nil terminated buffer for all the folks calling
-    // GetBytes() directly off our returned DataBufferSP if we hit an error.
-    lldb::DataBufferSP buf_sp (new DataBufferHeap(1, 0));
-
-    // Ideally, we would simply create a FileSpec and call ReadFileContents.
-    // However, files in procfs have zero size (since they are, in general,
-    // dynamically generated by the kernel) which is incompatible with the
-    // current ReadFileContents implementation. Therefore we simply stream the
-    // data into a DataBuffer ourselves.
-    if (snprintf (path, PATH_MAX, "/proc/%" PRIu64 "/%s", pid, name) > 0)
-    {
-        if ((fd = open (path, O_RDONLY, 0)) >= 0)
-        {
-            size_t bytes_read = 0;
-            std::unique_ptr<DataBufferHeap> buf_ap(new DataBufferHeap(1024, 0));
-
-            for (;;)
-            {
-                size_t avail = buf_ap->GetByteSize() - bytes_read;
-                ssize_t status = read (fd, buf_ap->GetBytes() + bytes_read, avail);
-
-                if (status < 0)
-                    break;
-
-                if (status == 0)
-                {
-                    buf_ap->SetByteSize (bytes_read);
-                    buf_sp.reset (buf_ap.release());
-                    break;
-                }
-
-                bytes_read += status;
-
-                if (avail - status == 0)
-                    buf_ap->SetByteSize (2 * buf_ap->GetByteSize());
-            }
-            
-            close (fd);
+lldb::DataBufferSP ProcFileReader::ReadIntoDataBuffer(lldb::pid_t pid,
+                                                      const char *name) {
+  int fd;
+  char path[PATH_MAX];
+
+  // Make sure we've got a nil terminated buffer for all the folks calling
+  // GetBytes() directly off our returned DataBufferSP if we hit an error.
+  lldb::DataBufferSP buf_sp(new DataBufferHeap(1, 0));
+
+  // Ideally, we would simply create a FileSpec and call ReadFileContents.
+  // However, files in procfs have zero size (since they are, in general,
+  // dynamically generated by the kernel) which is incompatible with the
+  // current ReadFileContents implementation. Therefore we simply stream the
+  // data into a DataBuffer ourselves.
+  if (snprintf(path, PATH_MAX, "/proc/%" PRIu64 "/%s", pid, name) > 0) {
+    if ((fd = open(path, O_RDONLY, 0)) >= 0) {
+      size_t bytes_read = 0;
+      std::unique_ptr<DataBufferHeap> buf_ap(new DataBufferHeap(1024, 0));
+
+      for (;;) {
+        size_t avail = buf_ap->GetByteSize() - bytes_read;
+        ssize_t status = read(fd, buf_ap->GetBytes() + bytes_read, avail);
+
+        if (status < 0)
+          break;
+
+        if (status == 0) {
+          buf_ap->SetByteSize(bytes_read);
+          buf_sp.reset(buf_ap.release());
+          break;
         }
-    }
-    
-    return buf_sp;
-}
 
-Error
-ProcFileReader::ProcessLineByLine (lldb::pid_t pid, const char *name, std::function<bool (const std::string &line)> line_parser)
-{
-    Error error;
-
-    // Try to open the /proc/{pid}/maps entry.
-    char filename [PATH_MAX];
-    snprintf (filename, sizeof(filename), "/proc/%" PRIu64 "/%s", pid, name);
-    filename[sizeof (filename) - 1] = '\0';
-
-    std::ifstream proc_file (filename);
-    if (proc_file.fail ())
-    {
-        error.SetErrorStringWithFormat ("failed to open file '%s'", filename);
-        return error;
-    }
+        bytes_read += status;
+
+        if (avail - status == 0)
+          buf_ap->SetByteSize(2 * buf_ap->GetByteSize());
+      }
 
-    // Read the file line by line, processing until either end of file or when the line_parser returns false.
-    std::string line;
-    bool should_continue = true;
-
-    while (should_continue && std::getline (proc_file, line))
-    {
-        // Pass the line over to the line_parser for processing.  If the line_parser returns false, we
-        // stop processing.
-        should_continue = line_parser (line);
+      close(fd);
     }
+  }
 
+  return buf_sp;
+}
+
+Error ProcFileReader::ProcessLineByLine(
+    lldb::pid_t pid, const char *name,
+    std::function<bool(const std::string &line)> line_parser) {
+  Error error;
+
+  // Try to open the /proc/{pid}/maps entry.
+  char filename[PATH_MAX];
+  snprintf(filename, sizeof(filename), "/proc/%" PRIu64 "/%s", pid, name);
+  filename[sizeof(filename) - 1] = '\0';
+
+  std::ifstream proc_file(filename);
+  if (proc_file.fail()) {
+    error.SetErrorStringWithFormat("failed to open file '%s'", filename);
     return error;
+  }
+
+  // Read the file line by line, processing until either end of file or when the
+  // line_parser returns false.
+  std::string line;
+  bool should_continue = true;
+
+  while (should_continue && std::getline(proc_file, line)) {
+    // Pass the line over to the line_parser for processing.  If the line_parser
+    // returns false, we
+    // stop processing.
+    should_continue = line_parser(line);
+  }
+
+  return error;
 }

Modified: lldb/trunk/source/Plugins/Process/Linux/ProcFileReader.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcFileReader.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/ProcFileReader.h (original)
+++ lldb/trunk/source/Plugins/Process/Linux/ProcFileReader.h Tue Sep  6 15:57:50 2016
@@ -18,18 +18,18 @@
 namespace lldb_private {
 namespace process_linux {
 
-    class ProcFileReader
-    {
-    public:
+class ProcFileReader {
+public:
+  static lldb::DataBufferSP ReadIntoDataBuffer(lldb::pid_t pid,
+                                               const char *name);
 
-        static lldb::DataBufferSP
-        ReadIntoDataBuffer (lldb::pid_t pid, const char *name);
-
-        /// Parse the /proc/{@a pid}/{@a name} file line by line, passing each line to line_parser, until
-        /// either end of file or until line_parser returns false.
-        static Error
-        ProcessLineByLine (lldb::pid_t pid, const char *name, std::function<bool (const std::string &line)> line_parser);
-    };
+  /// Parse the /proc/{@a pid}/{@a name} file line by line, passing each line to
+  /// line_parser, until
+  /// either end of file or until line_parser returns false.
+  static Error
+  ProcessLineByLine(lldb::pid_t pid, const char *name,
+                    std::function<bool(const std::string &line)> line_parser);
+};
 
 } // namespace process_linux
 } // namespace lldb_private

Modified: lldb/trunk/source/Plugins/Process/Linux/Procfs.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/Procfs.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/Procfs.h (original)
+++ lldb/trunk/source/Plugins/Process/Linux/Procfs.h Tue Sep  6 15:57:50 2016
@@ -13,19 +13,19 @@
 #include <sys/ptrace.h>
 
 #ifdef __ANDROID__
-#if defined (__arm64__) || defined (__aarch64__)
+#if defined(__arm64__) || defined(__aarch64__)
 typedef unsigned long elf_greg_t;
-typedef elf_greg_t elf_gregset_t[(sizeof (struct user_pt_regs) / sizeof(elf_greg_t))];
+typedef elf_greg_t
+    elf_gregset_t[(sizeof(struct user_pt_regs) / sizeof(elf_greg_t))];
 typedef struct user_fpsimd_state elf_fpregset_t;
 #ifndef NT_FPREGSET
-    #define NT_FPREGSET NT_PRFPREG
+#define NT_FPREGSET NT_PRFPREG
 #endif // NT_FPREGSET
-#elif defined (__mips__)
+#elif defined(__mips__)
 #ifndef NT_FPREGSET
-    #define NT_FPREGSET NT_PRFPREG
+#define NT_FPREGSET NT_PRFPREG
 #endif // NT_FPREGSET
 #endif
-#else  // __ANDROID__
+#else // __ANDROID__
 #include <sys/procfs.h>
 #endif // __ANDROID__
-

Modified: lldb/trunk/source/Plugins/Process/Linux/SingleStepCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/SingleStepCheck.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/SingleStepCheck.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/SingleStepCheck.cpp Tue Sep  6 15:57:50 2016
@@ -25,153 +25,142 @@
 using namespace lldb_private::process_linux;
 
 #if defined(__arm64__) || defined(__aarch64__)
-namespace
-{
+namespace {
 
-void LLVM_ATTRIBUTE_NORETURN
-Child()
-{
-    if (ptrace(PTRACE_TRACEME, 0, nullptr, nullptr) == -1)
-        _exit(1);
-
-    // We just do an endless loop SIGSTOPPING ourselves until killed. The tracer will fiddle with our cpu
-    // affinities and monitor the behaviour.
-    for (;;)
-    {
-        raise(SIGSTOP);
-
-        // Generate a bunch of instructions here, so that a single-step does not land in the
-        // raise() accidentally. If single-stepping works, we will be spinning in this loop. If
-        // it doesn't, we'll land in the raise() call above.
-        for (volatile unsigned i = 0; i < CPU_SETSIZE; ++i)
-            ;
-    }
+void LLVM_ATTRIBUTE_NORETURN Child() {
+  if (ptrace(PTRACE_TRACEME, 0, nullptr, nullptr) == -1)
+    _exit(1);
+
+  // We just do an endless loop SIGSTOPPING ourselves until killed. The tracer
+  // will fiddle with our cpu
+  // affinities and monitor the behaviour.
+  for (;;) {
+    raise(SIGSTOP);
+
+    // Generate a bunch of instructions here, so that a single-step does not
+    // land in the
+    // raise() accidentally. If single-stepping works, we will be spinning in
+    // this loop. If
+    // it doesn't, we'll land in the raise() call above.
+    for (volatile unsigned i = 0; i < CPU_SETSIZE; ++i)
+      ;
+  }
 }
 
-struct ChildDeleter
-{
-    ::pid_t pid;
-
-    ~ChildDeleter()
-    {
-        int status;
-        kill(pid, SIGKILL);            // Kill the child.
-        waitpid(pid, &status, __WALL); // Pick up the remains.
-    }
+struct ChildDeleter {
+  ::pid_t pid;
+
+  ~ChildDeleter() {
+    int status;
+    kill(pid, SIGKILL);            // Kill the child.
+    waitpid(pid, &status, __WALL); // Pick up the remains.
+  }
 };
 
 } // end anonymous namespace
 
-bool
-impl::SingleStepWorkaroundNeeded()
-{
-    // We shall spawn a child, and use it to verify the debug capabilities of the cpu. We shall
-    // iterate through the cpus, bind the child to each one in turn, and verify that
-    // single-stepping works on that cpu. A workaround is needed if we find at least one broken
-    // cpu.
-
-    Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
-    Error error;
-    ::pid_t child_pid = fork();
-    if (child_pid == -1)
-    {
-        if (log)
-        {
-            error.SetErrorToErrno();
-            log->Printf("%s failed to fork(): %s", __FUNCTION__, error.AsCString());
-        }
-        return false;
-    }
-    if (child_pid == 0)
-        Child();
-
-    ChildDeleter child_deleter{child_pid};
-    cpu_set_t available_cpus;
-    if (sched_getaffinity(child_pid, sizeof available_cpus, &available_cpus) == -1)
-    {
-        if (log)
-        {
-            error.SetErrorToErrno();
-            log->Printf("%s failed to get available cpus: %s", __FUNCTION__, error.AsCString());
-        }
-        return false;
+bool impl::SingleStepWorkaroundNeeded() {
+  // We shall spawn a child, and use it to verify the debug capabilities of the
+  // cpu. We shall
+  // iterate through the cpus, bind the child to each one in turn, and verify
+  // that
+  // single-stepping works on that cpu. A workaround is needed if we find at
+  // least one broken
+  // cpu.
+
+  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
+  Error error;
+  ::pid_t child_pid = fork();
+  if (child_pid == -1) {
+    if (log) {
+      error.SetErrorToErrno();
+      log->Printf("%s failed to fork(): %s", __FUNCTION__, error.AsCString());
     }
+    return false;
+  }
+  if (child_pid == 0)
+    Child();
+
+  ChildDeleter child_deleter{child_pid};
+  cpu_set_t available_cpus;
+  if (sched_getaffinity(child_pid, sizeof available_cpus, &available_cpus) ==
+      -1) {
+    if (log) {
+      error.SetErrorToErrno();
+      log->Printf("%s failed to get available cpus: %s", __FUNCTION__,
+                  error.AsCString());
+    }
+    return false;
+  }
 
-    int status;
-    ::pid_t wpid = waitpid(child_pid, &status, __WALL);
-    if (wpid != child_pid || !WIFSTOPPED(status))
-    {
-        if (log)
-        {
-            error.SetErrorToErrno();
-            log->Printf("%s waitpid() failed (status = %x): %s", __FUNCTION__, status, error.AsCString());
-        }
-        return false;
-    }
-
-    unsigned cpu;
-    for (cpu = 0; cpu < CPU_SETSIZE; ++cpu)
-    {
-        if (!CPU_ISSET(cpu, &available_cpus))
-            continue;
-
-        cpu_set_t cpus;
-        CPU_ZERO(&cpus);
-        CPU_SET(cpu, &cpus);
-        if (sched_setaffinity(child_pid, sizeof cpus, &cpus) == -1)
-        {
-            if (log)
-            {
-                error.SetErrorToErrno();
-                log->Printf("%s failed to switch to cpu %u: %s", __FUNCTION__, cpu, error.AsCString());
-            }
-            continue;
-        }
-
-        int status;
-        error = NativeProcessLinux::PtraceWrapper(PTRACE_SINGLESTEP, child_pid);
-        if (error.Fail())
-        {
-            if (log)
-                log->Printf("%s single step failed: %s", __FUNCTION__, error.AsCString());
-            break;
-        }
-
-        wpid = waitpid(child_pid, &status, __WALL);
-        if (wpid != child_pid || !WIFSTOPPED(status))
-        {
-            if (log)
-            {
-                error.SetErrorToErrno();
-                log->Printf("%s waitpid() failed (status = %x): %s", __FUNCTION__, status, error.AsCString());
-            }
-            break;
-        }
-        if (WSTOPSIG(status) != SIGTRAP)
-        {
-            if (log)
-                log->Printf("%s single stepping on cpu %d failed with status %x", __FUNCTION__, cpu, status);
-            break;
-        }
-    }
-
-    // cpu is either the index of the first broken cpu, or CPU_SETSIZE.
-    if (cpu == 0)
-    {
-        if (log)
-            log->Printf("%s SINGLE STEPPING ON FIRST CPU IS NOT WORKING. DEBUGGING LIKELY TO BE UNRELIABLE.",
-                        __FUNCTION__);
-        // No point in trying to fiddle with the affinities, just give it our best shot and see how it goes.
-        return false;
+  int status;
+  ::pid_t wpid = waitpid(child_pid, &status, __WALL);
+  if (wpid != child_pid || !WIFSTOPPED(status)) {
+    if (log) {
+      error.SetErrorToErrno();
+      log->Printf("%s waitpid() failed (status = %x): %s", __FUNCTION__, status,
+                  error.AsCString());
     }
+    return false;
+  }
 
-    return cpu != CPU_SETSIZE;
-}
+  unsigned cpu;
+  for (cpu = 0; cpu < CPU_SETSIZE; ++cpu) {
+    if (!CPU_ISSET(cpu, &available_cpus))
+      continue;
+
+    cpu_set_t cpus;
+    CPU_ZERO(&cpus);
+    CPU_SET(cpu, &cpus);
+    if (sched_setaffinity(child_pid, sizeof cpus, &cpus) == -1) {
+      if (log) {
+        error.SetErrorToErrno();
+        log->Printf("%s failed to switch to cpu %u: %s", __FUNCTION__, cpu,
+                    error.AsCString());
+      }
+      continue;
+    }
 
-#else // !arm64
-bool
-impl::SingleStepWorkaroundNeeded()
-{
+    int status;
+    error = NativeProcessLinux::PtraceWrapper(PTRACE_SINGLESTEP, child_pid);
+    if (error.Fail()) {
+      if (log)
+        log->Printf("%s single step failed: %s", __FUNCTION__,
+                    error.AsCString());
+      break;
+    }
+
+    wpid = waitpid(child_pid, &status, __WALL);
+    if (wpid != child_pid || !WIFSTOPPED(status)) {
+      if (log) {
+        error.SetErrorToErrno();
+        log->Printf("%s waitpid() failed (status = %x): %s", __FUNCTION__,
+                    status, error.AsCString());
+      }
+      break;
+    }
+    if (WSTOPSIG(status) != SIGTRAP) {
+      if (log)
+        log->Printf("%s single stepping on cpu %d failed with status %x",
+                    __FUNCTION__, cpu, status);
+      break;
+    }
+  }
+
+  // cpu is either the index of the first broken cpu, or CPU_SETSIZE.
+  if (cpu == 0) {
+    if (log)
+      log->Printf("%s SINGLE STEPPING ON FIRST CPU IS NOT WORKING. DEBUGGING "
+                  "LIKELY TO BE UNRELIABLE.",
+                  __FUNCTION__);
+    // No point in trying to fiddle with the affinities, just give it our best
+    // shot and see how it goes.
     return false;
+  }
+
+  return cpu != CPU_SETSIZE;
 }
+
+#else // !arm64
+bool impl::SingleStepWorkaroundNeeded() { return false; }
 #endif

Modified: lldb/trunk/source/Plugins/Process/Linux/SingleStepCheck.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/SingleStepCheck.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/SingleStepCheck.h (original)
+++ lldb/trunk/source/Plugins/Process/Linux/SingleStepCheck.h Tue Sep  6 15:57:50 2016
@@ -10,30 +10,29 @@
 #ifndef liblldb_SingleStepCheck_H_
 #define liblldb_SingleStepCheck_H_
 
-namespace lldb_private
-{
-namespace process_linux
-{
+namespace lldb_private {
+namespace process_linux {
 
-namespace impl
-{
-extern bool
-SingleStepWorkaroundNeeded();
+namespace impl {
+extern bool SingleStepWorkaroundNeeded();
 }
 
-// arm64 linux had a bug which prevented single-stepping and watchpoints from working on non-boot
-// cpus, due to them being incorrectly initialized after coming out of suspend.  This issue is
-// particularly affecting android M, which uses suspend ("doze mode") quite aggressively. This
-// code detects that situation and makes single-stepping work by doing all the step operations on
+// arm64 linux had a bug which prevented single-stepping and watchpoints from
+// working on non-boot
+// cpus, due to them being incorrectly initialized after coming out of suspend.
+// This issue is
+// particularly affecting android M, which uses suspend ("doze mode") quite
+// aggressively. This
+// code detects that situation and makes single-stepping work by doing all the
+// step operations on
 // the boot cpu.
 //
-// The underlying issue has been fixed in android N and linux 4.4. This code can be removed once
+// The underlying issue has been fixed in android N and linux 4.4. This code can
+// be removed once
 // these systems become obsolete.
-inline bool
-SingleStepWorkaroundNeeded()
-{
-    static bool value = impl::SingleStepWorkaroundNeeded();
-    return value;
+inline bool SingleStepWorkaroundNeeded() {
+  static bool value = impl::SingleStepWorkaroundNeeded();
+  return value;
 }
 } // end namespace process_linux
 } // end namespace lldb_private

Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp Tue Sep  6 15:57:50 2016
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-
 #include "CommunicationKDP.h"
 
 // C Includes
@@ -38,39 +37,26 @@ using namespace lldb_private;
 // CommunicationKDP constructor
 //----------------------------------------------------------------------
 CommunicationKDP::CommunicationKDP(const char *comm_name)
-    : Communication(comm_name),
-      m_addr_byte_size(4),
-      m_byte_order(eByteOrderLittle),
-      m_packet_timeout(5),
-      m_sequence_mutex(),
-      m_is_running(false),
-      m_session_key(0u),
-      m_request_sequence_id(0u),
-      m_exception_sequence_id(0u),
-      m_kdp_version_version(0u),
-      m_kdp_version_feature(0u),
-      m_kdp_hostinfo_cpu_mask(0u),
-      m_kdp_hostinfo_cpu_type(0u),
-      m_kdp_hostinfo_cpu_subtype(0u)
-{
-}
+    : Communication(comm_name), m_addr_byte_size(4),
+      m_byte_order(eByteOrderLittle), m_packet_timeout(5), m_sequence_mutex(),
+      m_is_running(false), m_session_key(0u), m_request_sequence_id(0u),
+      m_exception_sequence_id(0u), m_kdp_version_version(0u),
+      m_kdp_version_feature(0u), m_kdp_hostinfo_cpu_mask(0u),
+      m_kdp_hostinfo_cpu_type(0u), m_kdp_hostinfo_cpu_subtype(0u) {}
 
 //----------------------------------------------------------------------
 // Destructor
 //----------------------------------------------------------------------
-CommunicationKDP::~CommunicationKDP()
-{
-    if (IsConnected())
-    {
-        Disconnect();
-    }
+CommunicationKDP::~CommunicationKDP() {
+  if (IsConnected()) {
+    Disconnect();
+  }
 }
 
-bool
-CommunicationKDP::SendRequestPacket (const PacketStreamType &request_packet)
-{
-    std::lock_guard<std::recursive_mutex> guard(m_sequence_mutex);
-    return SendRequestPacketNoLock (request_packet);
+bool CommunicationKDP::SendRequestPacket(
+    const PacketStreamType &request_packet) {
+  std::lock_guard<std::recursive_mutex> guard(m_sequence_mutex);
+  return SendRequestPacketNoLock(request_packet);
 }
 
 #if 0
@@ -82,408 +68,370 @@ typedef struct {
 } kdp_hdr_t;
 #endif
 
-void
-CommunicationKDP::MakeRequestPacketHeader (CommandType request_type,
-                                           PacketStreamType &request_packet,
-                                           uint16_t request_length)
-{
-    request_packet.Clear();
-    request_packet.PutHex8 (request_type | ePacketTypeRequest); // Set the request type
-    request_packet.PutHex8 (m_request_sequence_id++);           // Sequence number
-    request_packet.PutHex16 (request_length);                   // Length of the packet including this header
-    request_packet.PutHex32 (m_session_key);                    // Session key
-}
-
-bool
-CommunicationKDP::SendRequestAndGetReply (const CommandType command,
-                                          const PacketStreamType &request_packet,
-                                          DataExtractor &reply_packet)
-{
-    if (IsRunning())
-    {
-        Log *log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PACKETS));
-        if (log)
-        {
-            PacketStreamType log_strm;
-            DumpPacket (log_strm, request_packet.GetData(), request_packet.GetSize());
-            log->Printf("error: kdp running, not sending packet: %.*s", (uint32_t)log_strm.GetSize(), log_strm.GetData());
-        }
-        return false;
+void CommunicationKDP::MakeRequestPacketHeader(CommandType request_type,
+                                               PacketStreamType &request_packet,
+                                               uint16_t request_length) {
+  request_packet.Clear();
+  request_packet.PutHex8(request_type |
+                         ePacketTypeRequest);      // Set the request type
+  request_packet.PutHex8(m_request_sequence_id++); // Sequence number
+  request_packet.PutHex16(
+      request_length); // Length of the packet including this header
+  request_packet.PutHex32(m_session_key); // Session key
+}
+
+bool CommunicationKDP::SendRequestAndGetReply(
+    const CommandType command, const PacketStreamType &request_packet,
+    DataExtractor &reply_packet) {
+  if (IsRunning()) {
+    Log *log(ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PACKETS));
+    if (log) {
+      PacketStreamType log_strm;
+      DumpPacket(log_strm, request_packet.GetData(), request_packet.GetSize());
+      log->Printf("error: kdp running, not sending packet: %.*s",
+                  (uint32_t)log_strm.GetSize(), log_strm.GetData());
     }
+    return false;
+  }
 
-    std::lock_guard<std::recursive_mutex> guard(m_sequence_mutex);
+  std::lock_guard<std::recursive_mutex> guard(m_sequence_mutex);
 #ifdef LLDB_CONFIGURATION_DEBUG
-    // NOTE: this only works for packets that are in native endian byte order
-    assert (request_packet.GetSize() == *((uint16_t *)(request_packet.GetData() + 2)));
+  // NOTE: this only works for packets that are in native endian byte order
+  assert(request_packet.GetSize() ==
+         *((uint16_t *)(request_packet.GetData() + 2)));
 #endif
-    lldb::offset_t offset = 1;
-    const uint32_t num_retries = 3;
-    for (uint32_t i=0; i<num_retries; ++i)
-    {
-        if (SendRequestPacketNoLock(request_packet))
-        {
-            const uint8_t request_sequence_id = (uint8_t)request_packet.GetData()[1];
-            while (1)
-            {
-                if (WaitForPacketWithTimeoutMicroSecondsNoLock (reply_packet, GetPacketTimeoutInMicroSeconds ()))
-                {
-                    offset = 0;
-                    const uint8_t reply_command = reply_packet.GetU8 (&offset);
-                    const uint8_t reply_sequence_id = reply_packet.GetU8 (&offset);
-                    if (request_sequence_id == reply_sequence_id)
-                    {
-                        // The sequent ID was correct, now verify we got the response we were looking for
-                        if ((reply_command & eCommandTypeMask) == command)
-                        {
-                            // Success
-                            if (command == KDP_RESUMECPUS)
-                                m_is_running.SetValue(true, eBroadcastAlways);
-                            return true;
-                        }
-                        else
-                        {
-                            // Failed to get the correct response, bail
-                            reply_packet.Clear();
-                            return false;
-                        }
-                    }
-                    else if (reply_sequence_id > request_sequence_id)
-                    {
-                        // Sequence ID was greater than the sequence ID of the packet we sent, something
-                        // is really wrong...
-                        reply_packet.Clear();
-                        return false;
-                    }
-                    else
-                    {
-                        // The reply sequence ID was less than our current packet's sequence ID
-                        // so we should keep trying to get a response because this was a response
-                        // for a previous packet that we must have retried.
-                    }
-                }
-                else
-                {
-                    // Break and retry sending the packet as we didn't get a response due to timeout
-                    break;
-                }
+  lldb::offset_t offset = 1;
+  const uint32_t num_retries = 3;
+  for (uint32_t i = 0; i < num_retries; ++i) {
+    if (SendRequestPacketNoLock(request_packet)) {
+      const uint8_t request_sequence_id = (uint8_t)request_packet.GetData()[1];
+      while (1) {
+        if (WaitForPacketWithTimeoutMicroSecondsNoLock(
+                reply_packet, GetPacketTimeoutInMicroSeconds())) {
+          offset = 0;
+          const uint8_t reply_command = reply_packet.GetU8(&offset);
+          const uint8_t reply_sequence_id = reply_packet.GetU8(&offset);
+          if (request_sequence_id == reply_sequence_id) {
+            // The sequent ID was correct, now verify we got the response we
+            // were looking for
+            if ((reply_command & eCommandTypeMask) == command) {
+              // Success
+              if (command == KDP_RESUMECPUS)
+                m_is_running.SetValue(true, eBroadcastAlways);
+              return true;
+            } else {
+              // Failed to get the correct response, bail
+              reply_packet.Clear();
+              return false;
             }
+          } else if (reply_sequence_id > request_sequence_id) {
+            // Sequence ID was greater than the sequence ID of the packet we
+            // sent, something
+            // is really wrong...
+            reply_packet.Clear();
+            return false;
+          } else {
+            // The reply sequence ID was less than our current packet's sequence
+            // ID
+            // so we should keep trying to get a response because this was a
+            // response
+            // for a previous packet that we must have retried.
+          }
+        } else {
+          // Break and retry sending the packet as we didn't get a response due
+          // to timeout
+          break;
         }
+      }
     }
-    reply_packet.Clear();
-    return false;
+  }
+  reply_packet.Clear();
+  return false;
 }
 
-bool
-CommunicationKDP::SendRequestPacketNoLock (const PacketStreamType &request_packet)
-{
-    if (IsConnected())
-    {
-        const char *packet_data = request_packet.GetData();
-        const size_t packet_size = request_packet.GetSize();
+bool CommunicationKDP::SendRequestPacketNoLock(
+    const PacketStreamType &request_packet) {
+  if (IsConnected()) {
+    const char *packet_data = request_packet.GetData();
+    const size_t packet_size = request_packet.GetSize();
 
-        Log *log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PACKETS));
-        if (log)
-        {
-            PacketStreamType log_strm;            
-            DumpPacket (log_strm, packet_data, packet_size);
-            log->Printf("%.*s", (uint32_t)log_strm.GetSize(), log_strm.GetData());
-        }
-        ConnectionStatus status = eConnectionStatusSuccess;
-
-        size_t bytes_written = Write (packet_data, 
-                                      packet_size, 
-                                      status, 
-                                      NULL);
-
-        if (bytes_written == packet_size)
-            return true;
-        
-        if (log)
-            log->Printf ("error: failed to send packet entire packet %" PRIu64 " of %" PRIu64 " bytes sent", (uint64_t)bytes_written, (uint64_t)packet_size);
+    Log *log(ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PACKETS));
+    if (log) {
+      PacketStreamType log_strm;
+      DumpPacket(log_strm, packet_data, packet_size);
+      log->Printf("%.*s", (uint32_t)log_strm.GetSize(), log_strm.GetData());
     }
-    return false;
-}
+    ConnectionStatus status = eConnectionStatusSuccess;
 
-bool
-CommunicationKDP::GetSequenceMutex(std::unique_lock<std::recursive_mutex> &lock)
-{
-    return (lock = std::unique_lock<std::recursive_mutex>(m_sequence_mutex, std::try_to_lock)).owns_lock();
+    size_t bytes_written = Write(packet_data, packet_size, status, NULL);
+
+    if (bytes_written == packet_size)
+      return true;
+
+    if (log)
+      log->Printf("error: failed to send packet entire packet %" PRIu64
+                  " of %" PRIu64 " bytes sent",
+                  (uint64_t)bytes_written, (uint64_t)packet_size);
+  }
+  return false;
 }
 
-bool
-CommunicationKDP::WaitForNotRunningPrivate(const std::chrono::microseconds &timeout)
-{
-    return m_is_running.WaitForValueEqualTo(false, timeout, NULL);
+bool CommunicationKDP::GetSequenceMutex(
+    std::unique_lock<std::recursive_mutex> &lock) {
+  return (lock = std::unique_lock<std::recursive_mutex>(m_sequence_mutex,
+                                                        std::try_to_lock))
+      .owns_lock();
 }
 
-size_t
-CommunicationKDP::WaitForPacketWithTimeoutMicroSeconds (DataExtractor &packet, uint32_t timeout_usec)
-{
-    std::lock_guard<std::recursive_mutex> guard(m_sequence_mutex);
-    return WaitForPacketWithTimeoutMicroSecondsNoLock (packet, timeout_usec);
+bool CommunicationKDP::WaitForNotRunningPrivate(
+    const std::chrono::microseconds &timeout) {
+  return m_is_running.WaitForValueEqualTo(false, timeout, NULL);
 }
 
 size_t
-CommunicationKDP::WaitForPacketWithTimeoutMicroSecondsNoLock (DataExtractor &packet, uint32_t timeout_usec)
-{
-    uint8_t buffer[8192];
-    Error error;
+CommunicationKDP::WaitForPacketWithTimeoutMicroSeconds(DataExtractor &packet,
+                                                       uint32_t timeout_usec) {
+  std::lock_guard<std::recursive_mutex> guard(m_sequence_mutex);
+  return WaitForPacketWithTimeoutMicroSecondsNoLock(packet, timeout_usec);
+}
+
+size_t CommunicationKDP::WaitForPacketWithTimeoutMicroSecondsNoLock(
+    DataExtractor &packet, uint32_t timeout_usec) {
+  uint8_t buffer[8192];
+  Error error;
+
+  Log *log(ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PACKETS |
+                                                   KDP_LOG_VERBOSE));
+
+  // Check for a packet from our cache first without trying any reading...
+  if (CheckForPacket(NULL, 0, packet))
+    return packet.GetByteSize();
+
+  bool timed_out = false;
+  while (IsConnected() && !timed_out) {
+    lldb::ConnectionStatus status = eConnectionStatusNoConnection;
+    size_t bytes_read =
+        Read(buffer, sizeof(buffer), timeout_usec, status, &error);
+
+    if (log)
+      log->Printf("%s: Read (buffer, (sizeof(buffer), timeout_usec = 0x%x, "
+                  "status = %s, error = %s) => bytes_read = %" PRIu64,
+                  LLVM_PRETTY_FUNCTION, timeout_usec,
+                  Communication::ConnectionStatusAsCString(status),
+                  error.AsCString(), (uint64_t)bytes_read);
 
-    Log *log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PACKETS | KDP_LOG_VERBOSE));
-
-    // Check for a packet from our cache first without trying any reading...
-    if (CheckForPacket (NULL, 0, packet))
+    if (bytes_read > 0) {
+      if (CheckForPacket(buffer, bytes_read, packet))
         return packet.GetByteSize();
-
-    bool timed_out = false;
-    while (IsConnected() && !timed_out)
-    {
-        lldb::ConnectionStatus status = eConnectionStatusNoConnection;
-        size_t bytes_read = Read (buffer, sizeof(buffer), timeout_usec, status, &error);
-        
-        if (log)
-            log->Printf ("%s: Read (buffer, (sizeof(buffer), timeout_usec = 0x%x, status = %s, error = %s) => bytes_read = %" PRIu64,
-                         LLVM_PRETTY_FUNCTION,
-                         timeout_usec, 
-                         Communication::ConnectionStatusAsCString (status),
-                         error.AsCString(), 
-                         (uint64_t)bytes_read);
-
-        if (bytes_read > 0)
-        {
-            if (CheckForPacket (buffer, bytes_read, packet))
-                return packet.GetByteSize();
-        }
-        else
-        {
-            switch (status)
-            {
-            case eConnectionStatusInterrupted:
-            case eConnectionStatusTimedOut:
-                timed_out = true;
-                break;
-            case eConnectionStatusSuccess:
-                //printf ("status = success but error = %s\n", error.AsCString("<invalid>"));
-                break;
-                
-            case eConnectionStatusEndOfFile:
-            case eConnectionStatusNoConnection:
-            case eConnectionStatusLostConnection:
-            case eConnectionStatusError:
-                Disconnect();
-                break;
-            }
-        }
+    } else {
+      switch (status) {
+      case eConnectionStatusInterrupted:
+      case eConnectionStatusTimedOut:
+        timed_out = true;
+        break;
+      case eConnectionStatusSuccess:
+        // printf ("status = success but error = %s\n",
+        // error.AsCString("<invalid>"));
+        break;
+
+      case eConnectionStatusEndOfFile:
+      case eConnectionStatusNoConnection:
+      case eConnectionStatusLostConnection:
+      case eConnectionStatusError:
+        Disconnect();
+        break;
+      }
     }
-    packet.Clear ();    
-    return 0;
-}
-
-bool
-CommunicationKDP::CheckForPacket (const uint8_t *src, size_t src_len, DataExtractor &packet)
-{
-    // Put the packet data into the buffer in a thread safe fashion
-    std::lock_guard<std::recursive_mutex> guard(m_bytes_mutex);
-
-    Log *log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PACKETS));
+  }
+  packet.Clear();
+  return 0;
+}
+
+bool CommunicationKDP::CheckForPacket(const uint8_t *src, size_t src_len,
+                                      DataExtractor &packet) {
+  // Put the packet data into the buffer in a thread safe fashion
+  std::lock_guard<std::recursive_mutex> guard(m_bytes_mutex);
+
+  Log *log(ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PACKETS));
+
+  if (src && src_len > 0) {
+    if (log && log->GetVerbose()) {
+      PacketStreamType log_strm;
+      DataExtractor::DumpHexBytes(&log_strm, src, src_len, UINT32_MAX,
+                                  LLDB_INVALID_ADDRESS);
+      log->Printf("CommunicationKDP::%s adding %u bytes: %s", __FUNCTION__,
+                  (uint32_t)src_len, log_strm.GetData());
+    }
+    m_bytes.append((const char *)src, src_len);
+  }
+
+  // Make sure we at least have enough bytes for a packet header
+  const size_t bytes_available = m_bytes.size();
+  if (bytes_available >= 8) {
+    packet.SetData(&m_bytes[0], bytes_available, m_byte_order);
+    lldb::offset_t offset = 0;
+    uint8_t reply_command = packet.GetU8(&offset);
+    switch (reply_command) {
+    case ePacketTypeRequest | KDP_EXCEPTION:
+    case ePacketTypeRequest | KDP_TERMINATION:
+      // We got an exception request, so be sure to send an ACK
+      {
+        PacketStreamType request_ack_packet(Stream::eBinary, m_addr_byte_size,
+                                            m_byte_order);
+        // Set the reply but and make the ACK packet
+        request_ack_packet.PutHex8(reply_command | ePacketTypeReply);
+        request_ack_packet.PutHex8(packet.GetU8(&offset));
+        request_ack_packet.PutHex16(packet.GetU16(&offset));
+        request_ack_packet.PutHex32(packet.GetU32(&offset));
+        m_is_running.SetValue(false, eBroadcastAlways);
+        // Ack to the exception or termination
+        SendRequestPacketNoLock(request_ack_packet);
+      }
+      // Fall through to case below to get packet contents
+      LLVM_FALLTHROUGH;
+    case ePacketTypeReply | KDP_CONNECT:
+    case ePacketTypeReply | KDP_DISCONNECT:
+    case ePacketTypeReply | KDP_HOSTINFO:
+    case ePacketTypeReply | KDP_VERSION:
+    case ePacketTypeReply | KDP_MAXBYTES:
+    case ePacketTypeReply | KDP_READMEM:
+    case ePacketTypeReply | KDP_WRITEMEM:
+    case ePacketTypeReply | KDP_READREGS:
+    case ePacketTypeReply | KDP_WRITEREGS:
+    case ePacketTypeReply | KDP_LOAD:
+    case ePacketTypeReply | KDP_IMAGEPATH:
+    case ePacketTypeReply | KDP_SUSPEND:
+    case ePacketTypeReply | KDP_RESUMECPUS:
+    case ePacketTypeReply | KDP_BREAKPOINT_SET:
+    case ePacketTypeReply | KDP_BREAKPOINT_REMOVE:
+    case ePacketTypeReply | KDP_REGIONS:
+    case ePacketTypeReply | KDP_REATTACH:
+    case ePacketTypeReply | KDP_HOSTREBOOT:
+    case ePacketTypeReply | KDP_READMEM64:
+    case ePacketTypeReply | KDP_WRITEMEM64:
+    case ePacketTypeReply | KDP_BREAKPOINT_SET64:
+    case ePacketTypeReply | KDP_BREAKPOINT_REMOVE64:
+    case ePacketTypeReply | KDP_KERNELVERSION:
+    case ePacketTypeReply | KDP_READPHYSMEM64:
+    case ePacketTypeReply | KDP_WRITEPHYSMEM64:
+    case ePacketTypeReply | KDP_READIOPORT:
+    case ePacketTypeReply | KDP_WRITEIOPORT:
+    case ePacketTypeReply | KDP_READMSR64:
+    case ePacketTypeReply | KDP_WRITEMSR64:
+    case ePacketTypeReply | KDP_DUMPINFO: {
+      offset = 2;
+      const uint16_t length = packet.GetU16(&offset);
+      if (length <= bytes_available) {
+        // We have an entire packet ready, we need to copy the data
+        // bytes into a buffer that will be owned by the packet and
+        // erase the bytes from our communcation buffer "m_bytes"
+        packet.SetData(DataBufferSP(new DataBufferHeap(&m_bytes[0], length)));
+        m_bytes.erase(0, length);
+
+        if (log) {
+          PacketStreamType log_strm;
+          DumpPacket(log_strm, packet);
 
-    if (src && src_len > 0)
-    {
-        if (log && log->GetVerbose())
-        {
-            PacketStreamType log_strm;
-            DataExtractor::DumpHexBytes (&log_strm, src, src_len, UINT32_MAX, LLDB_INVALID_ADDRESS);
-            log->Printf ("CommunicationKDP::%s adding %u bytes: %s",
-                         __FUNCTION__, 
-                         (uint32_t)src_len, 
-                         log_strm.GetData());
+          log->Printf("%.*s", (uint32_t)log_strm.GetSize(), log_strm.GetData());
         }
-        m_bytes.append ((const char *)src, src_len);
-    }
-
-    // Make sure we at least have enough bytes for a packet header
-    const size_t bytes_available = m_bytes.size();
-    if (bytes_available >= 8)
-    {
-        packet.SetData (&m_bytes[0], bytes_available, m_byte_order);
-        lldb::offset_t offset = 0;
-        uint8_t reply_command = packet.GetU8(&offset);
-        switch (reply_command)
-        {
-        case ePacketTypeRequest | KDP_EXCEPTION:
-        case ePacketTypeRequest | KDP_TERMINATION:
-            // We got an exception request, so be sure to send an ACK
-            {
-                PacketStreamType request_ack_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
-                // Set the reply but and make the ACK packet
-                request_ack_packet.PutHex8 (reply_command | ePacketTypeReply);
-                request_ack_packet.PutHex8 (packet.GetU8(&offset));
-                request_ack_packet.PutHex16 (packet.GetU16(&offset));
-                request_ack_packet.PutHex32 (packet.GetU32(&offset));
-                m_is_running.SetValue(false, eBroadcastAlways);
-                // Ack to the exception or termination
-                SendRequestPacketNoLock (request_ack_packet);
-            }
-            // Fall through to case below to get packet contents
-            LLVM_FALLTHROUGH;
-        case ePacketTypeReply | KDP_CONNECT:
-        case ePacketTypeReply | KDP_DISCONNECT:
-        case ePacketTypeReply | KDP_HOSTINFO:
-        case ePacketTypeReply | KDP_VERSION:
-        case ePacketTypeReply | KDP_MAXBYTES:
-        case ePacketTypeReply | KDP_READMEM:
-        case ePacketTypeReply | KDP_WRITEMEM:
-        case ePacketTypeReply | KDP_READREGS:
-        case ePacketTypeReply | KDP_WRITEREGS:
-        case ePacketTypeReply | KDP_LOAD:
-        case ePacketTypeReply | KDP_IMAGEPATH:
-        case ePacketTypeReply | KDP_SUSPEND:
-        case ePacketTypeReply | KDP_RESUMECPUS:
-        case ePacketTypeReply | KDP_BREAKPOINT_SET:
-        case ePacketTypeReply | KDP_BREAKPOINT_REMOVE:
-        case ePacketTypeReply | KDP_REGIONS:
-        case ePacketTypeReply | KDP_REATTACH:
-        case ePacketTypeReply | KDP_HOSTREBOOT:
-        case ePacketTypeReply | KDP_READMEM64:
-        case ePacketTypeReply | KDP_WRITEMEM64:
-        case ePacketTypeReply | KDP_BREAKPOINT_SET64:
-        case ePacketTypeReply | KDP_BREAKPOINT_REMOVE64:
-        case ePacketTypeReply | KDP_KERNELVERSION:
-        case ePacketTypeReply | KDP_READPHYSMEM64:
-        case ePacketTypeReply | KDP_WRITEPHYSMEM64:
-        case ePacketTypeReply | KDP_READIOPORT:
-        case ePacketTypeReply | KDP_WRITEIOPORT:
-        case ePacketTypeReply | KDP_READMSR64:
-        case ePacketTypeReply | KDP_WRITEMSR64:
-        case ePacketTypeReply | KDP_DUMPINFO:
-            {
-                offset = 2;
-                const uint16_t length = packet.GetU16 (&offset);
-                if (length <= bytes_available)
-                {
-                    // We have an entire packet ready, we need to copy the data
-                    // bytes into a buffer that will be owned by the packet and
-                    // erase the bytes from our communcation buffer "m_bytes"
-                    packet.SetData (DataBufferSP (new DataBufferHeap (&m_bytes[0], length)));
-                    m_bytes.erase (0, length);
-                    
-                    if (log)
-                    {
-                        PacketStreamType log_strm;
-                        DumpPacket (log_strm, packet);
-                        
-                        log->Printf("%.*s", (uint32_t)log_strm.GetSize(), log_strm.GetData());
-                    }
-                    return true;
-                }
-            }
-            break;
-
-        default:
-            // Unrecognized reply command byte, erase this byte and try to get back on track
-            if (log)
-                log->Printf ("CommunicationKDP::%s: tossing junk byte: 0x%2.2x", 
-                             __FUNCTION__, 
-                             (uint8_t)m_bytes[0]);
-            m_bytes.erase(0, 1);
-            break;
-        }
-    }
-    packet.Clear();
-    return false;
-}
-
-
-bool
-CommunicationKDP::SendRequestConnect (uint16_t reply_port, 
-                                      uint16_t exc_port, 
-                                      const char *greeting)
-{
-    PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
-    if (greeting == NULL)
-        greeting = "";
-
-    const CommandType command = KDP_CONNECT;
-    // Length is 82 uint16_t and the length of the greeting C string with the terminating NULL
-    const uint32_t command_length = 8 + 2 + 2 + ::strlen(greeting) + 1;
-    MakeRequestPacketHeader (command, request_packet, command_length);
-    // Always send connect ports as little endian
-    request_packet.SetByteOrder (eByteOrderLittle);
-    request_packet.PutHex16 (htons(reply_port));
-    request_packet.PutHex16 (htons(exc_port));
-    request_packet.SetByteOrder (m_byte_order);
-    request_packet.PutCString (greeting);
-    DataExtractor reply_packet;
-    return SendRequestAndGetReply (command, request_packet, reply_packet);
-}
-
-void
-CommunicationKDP::ClearKDPSettings ()
-{
-    m_request_sequence_id = 0;
-    m_kdp_version_version = 0;
-    m_kdp_version_feature = 0;
-    m_kdp_hostinfo_cpu_mask = 0;
-    m_kdp_hostinfo_cpu_type = 0;
-    m_kdp_hostinfo_cpu_subtype = 0;
-}
-
-bool
-CommunicationKDP::SendRequestReattach (uint16_t reply_port)
-{
-    PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
-    const CommandType command = KDP_REATTACH;
-    // Length is 8 bytes for the header plus 2 bytes for the reply UDP port
-    const uint32_t command_length = 8 + 2;
-    MakeRequestPacketHeader (command, request_packet, command_length);
-    // Always send connect ports as little endian
-    request_packet.SetByteOrder (eByteOrderLittle);
-    request_packet.PutHex16(htons(reply_port));
-    request_packet.SetByteOrder (m_byte_order);
-    DataExtractor reply_packet;
-    if (SendRequestAndGetReply (command, request_packet, reply_packet))
-    {
-        // Reset the sequence ID to zero for reattach
-        ClearKDPSettings ();
-        lldb::offset_t offset = 4;
-        m_session_key = reply_packet.GetU32 (&offset);
         return true;
-    }
-    return false;
-}
+      }
+    } break;
 
-uint32_t
-CommunicationKDP::GetVersion ()
-{
-    if (!VersionIsValid())
-        SendRequestVersion();
-    return m_kdp_version_version;
-}
-
-uint32_t
-CommunicationKDP::GetFeatureFlags ()
-{
-    if (!VersionIsValid())
-        SendRequestVersion();
-    return m_kdp_version_feature;
+    default:
+      // Unrecognized reply command byte, erase this byte and try to get back on
+      // track
+      if (log)
+        log->Printf("CommunicationKDP::%s: tossing junk byte: 0x%2.2x",
+                    __FUNCTION__, (uint8_t)m_bytes[0]);
+      m_bytes.erase(0, 1);
+      break;
+    }
+  }
+  packet.Clear();
+  return false;
+}
+
+bool CommunicationKDP::SendRequestConnect(uint16_t reply_port,
+                                          uint16_t exc_port,
+                                          const char *greeting) {
+  PacketStreamType request_packet(Stream::eBinary, m_addr_byte_size,
+                                  m_byte_order);
+  if (greeting == NULL)
+    greeting = "";
+
+  const CommandType command = KDP_CONNECT;
+  // Length is 82 uint16_t and the length of the greeting C string with the
+  // terminating NULL
+  const uint32_t command_length = 8 + 2 + 2 + ::strlen(greeting) + 1;
+  MakeRequestPacketHeader(command, request_packet, command_length);
+  // Always send connect ports as little endian
+  request_packet.SetByteOrder(eByteOrderLittle);
+  request_packet.PutHex16(htons(reply_port));
+  request_packet.PutHex16(htons(exc_port));
+  request_packet.SetByteOrder(m_byte_order);
+  request_packet.PutCString(greeting);
+  DataExtractor reply_packet;
+  return SendRequestAndGetReply(command, request_packet, reply_packet);
+}
+
+void CommunicationKDP::ClearKDPSettings() {
+  m_request_sequence_id = 0;
+  m_kdp_version_version = 0;
+  m_kdp_version_feature = 0;
+  m_kdp_hostinfo_cpu_mask = 0;
+  m_kdp_hostinfo_cpu_type = 0;
+  m_kdp_hostinfo_cpu_subtype = 0;
+}
+
+bool CommunicationKDP::SendRequestReattach(uint16_t reply_port) {
+  PacketStreamType request_packet(Stream::eBinary, m_addr_byte_size,
+                                  m_byte_order);
+  const CommandType command = KDP_REATTACH;
+  // Length is 8 bytes for the header plus 2 bytes for the reply UDP port
+  const uint32_t command_length = 8 + 2;
+  MakeRequestPacketHeader(command, request_packet, command_length);
+  // Always send connect ports as little endian
+  request_packet.SetByteOrder(eByteOrderLittle);
+  request_packet.PutHex16(htons(reply_port));
+  request_packet.SetByteOrder(m_byte_order);
+  DataExtractor reply_packet;
+  if (SendRequestAndGetReply(command, request_packet, reply_packet)) {
+    // Reset the sequence ID to zero for reattach
+    ClearKDPSettings();
+    lldb::offset_t offset = 4;
+    m_session_key = reply_packet.GetU32(&offset);
+    return true;
+  }
+  return false;
 }
 
-bool
-CommunicationKDP::SendRequestVersion ()
-{
-    PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
-    const CommandType command = KDP_VERSION;
-    const uint32_t command_length = 8;
-    MakeRequestPacketHeader (command, request_packet, command_length);
-    DataExtractor reply_packet;
-    if (SendRequestAndGetReply (command, request_packet, reply_packet))
-    {
-        lldb::offset_t offset = 8;
-        m_kdp_version_version = reply_packet.GetU32 (&offset);
-        m_kdp_version_feature = reply_packet.GetU32 (&offset);
-        return true;
-    }
-    return false;
+uint32_t CommunicationKDP::GetVersion() {
+  if (!VersionIsValid())
+    SendRequestVersion();
+  return m_kdp_version_version;
+}
+
+uint32_t CommunicationKDP::GetFeatureFlags() {
+  if (!VersionIsValid())
+    SendRequestVersion();
+  return m_kdp_version_feature;
+}
+
+bool CommunicationKDP::SendRequestVersion() {
+  PacketStreamType request_packet(Stream::eBinary, m_addr_byte_size,
+                                  m_byte_order);
+  const CommandType command = KDP_VERSION;
+  const uint32_t command_length = 8;
+  MakeRequestPacketHeader(command, request_packet, command_length);
+  DataExtractor reply_packet;
+  if (SendRequestAndGetReply(command, request_packet, reply_packet)) {
+    lldb::offset_t offset = 8;
+    m_kdp_version_version = reply_packet.GetU32(&offset);
+    m_kdp_version_feature = reply_packet.GetU32(&offset);
+    return true;
+  }
+  return false;
 }
 
 #if 0 // Disable KDP_IMAGEPATH for now, it seems to hang the KDP connection...
@@ -514,932 +462,863 @@ CommunicationKDP::SendRequestImagePath (
 }
 #endif
 
-uint32_t
-CommunicationKDP::GetCPUMask ()
-{
-    if (!HostInfoIsValid())
-        SendRequestHostInfo();
-    return m_kdp_hostinfo_cpu_mask;
+uint32_t CommunicationKDP::GetCPUMask() {
+  if (!HostInfoIsValid())
+    SendRequestHostInfo();
+  return m_kdp_hostinfo_cpu_mask;
 }
 
-uint32_t
-CommunicationKDP::GetCPUType ()
-{
-    if (!HostInfoIsValid())
-        SendRequestHostInfo();
-    return m_kdp_hostinfo_cpu_type;
+uint32_t CommunicationKDP::GetCPUType() {
+  if (!HostInfoIsValid())
+    SendRequestHostInfo();
+  return m_kdp_hostinfo_cpu_type;
 }
 
-uint32_t
-CommunicationKDP::GetCPUSubtype ()
-{
-    if (!HostInfoIsValid())
-        SendRequestHostInfo();
-    return m_kdp_hostinfo_cpu_subtype;
+uint32_t CommunicationKDP::GetCPUSubtype() {
+  if (!HostInfoIsValid())
+    SendRequestHostInfo();
+  return m_kdp_hostinfo_cpu_subtype;
 }
 
-lldb_private::UUID
-CommunicationKDP::GetUUID ()
-{
-    UUID uuid;
-    if (GetKernelVersion() == NULL)
-        return uuid;
-
-    if (m_kernel_version.find("UUID=") == std::string::npos)
-        return uuid;
-
-    size_t p = m_kernel_version.find("UUID=") + strlen ("UUID=");
-    std::string uuid_str = m_kernel_version.substr(p, 36);
-    if (uuid_str.size() < 32)
-        return uuid;
+lldb_private::UUID CommunicationKDP::GetUUID() {
+  UUID uuid;
+  if (GetKernelVersion() == NULL)
+    return uuid;
 
-    if (uuid.SetFromCString (uuid_str.c_str()) == 0)
-    {
-        UUID invalid_uuid;
-        return invalid_uuid;
-    }
+  if (m_kernel_version.find("UUID=") == std::string::npos)
+    return uuid;
 
+  size_t p = m_kernel_version.find("UUID=") + strlen("UUID=");
+  std::string uuid_str = m_kernel_version.substr(p, 36);
+  if (uuid_str.size() < 32)
     return uuid;
-}
 
-bool
-CommunicationKDP::RemoteIsEFI ()
-{
-    if (GetKernelVersion() == NULL)
-        return false;
-    if (strncmp (m_kernel_version.c_str(), "EFI", 3) == 0)
-        return true;
-    else
-        return false;
-}
+  if (uuid.SetFromCString(uuid_str.c_str()) == 0) {
+    UUID invalid_uuid;
+    return invalid_uuid;
+  }
 
-bool
-CommunicationKDP::RemoteIsDarwinKernel ()
-{
-    if (GetKernelVersion() == NULL)
-        return false;
-    if (m_kernel_version.find("Darwin Kernel") != std::string::npos)
-        return true;
-    else
-        return false;
+  return uuid;
 }
 
-lldb::addr_t
-CommunicationKDP::GetLoadAddress ()
-{
-    if (GetKernelVersion() == NULL)
-        return LLDB_INVALID_ADDRESS;
-
-    if (m_kernel_version.find("stext=") == std::string::npos)
-        return LLDB_INVALID_ADDRESS;
-    size_t p = m_kernel_version.find("stext=") + strlen ("stext=");
-    if (m_kernel_version[p] != '0' || m_kernel_version[p + 1] != 'x')
-        return LLDB_INVALID_ADDRESS;
-
-    addr_t kernel_load_address;
-    errno = 0;
-    kernel_load_address = ::strtoul (m_kernel_version.c_str() + p, NULL, 16);
-    if (errno != 0 || kernel_load_address == 0)
-        return LLDB_INVALID_ADDRESS;
-
-    return kernel_load_address;
+bool CommunicationKDP::RemoteIsEFI() {
+  if (GetKernelVersion() == NULL)
+    return false;
+  if (strncmp(m_kernel_version.c_str(), "EFI", 3) == 0)
+    return true;
+  else
+    return false;
 }
 
-bool
-CommunicationKDP::SendRequestHostInfo ()
-{
-    PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
-    const CommandType command = KDP_HOSTINFO;
-    const uint32_t command_length = 8;
-    MakeRequestPacketHeader (command, request_packet, command_length);
-    DataExtractor reply_packet;
-    if (SendRequestAndGetReply (command, request_packet, reply_packet))
-    {
-        lldb::offset_t offset = 8;
-        m_kdp_hostinfo_cpu_mask     = reply_packet.GetU32 (&offset);
-        m_kdp_hostinfo_cpu_type     = reply_packet.GetU32 (&offset);
-        m_kdp_hostinfo_cpu_subtype  = reply_packet.GetU32 (&offset);
-        
-        ArchSpec kernel_arch;
-        kernel_arch.SetArchitecture (eArchTypeMachO, 
-                                     m_kdp_hostinfo_cpu_type, 
-                                     m_kdp_hostinfo_cpu_subtype);
-    
-        m_addr_byte_size = kernel_arch.GetAddressByteSize();
-        m_byte_order = kernel_arch.GetByteOrder();
-        return true;
-    }
+bool CommunicationKDP::RemoteIsDarwinKernel() {
+  if (GetKernelVersion() == NULL)
+    return false;
+  if (m_kernel_version.find("Darwin Kernel") != std::string::npos)
+    return true;
+  else
     return false;
 }
 
-const char *
-CommunicationKDP::GetKernelVersion ()
-{
-    if (m_kernel_version.empty())
-        SendRequestKernelVersion ();
-    return m_kernel_version.c_str();
-}
+lldb::addr_t CommunicationKDP::GetLoadAddress() {
+  if (GetKernelVersion() == NULL)
+    return LLDB_INVALID_ADDRESS;
+
+  if (m_kernel_version.find("stext=") == std::string::npos)
+    return LLDB_INVALID_ADDRESS;
+  size_t p = m_kernel_version.find("stext=") + strlen("stext=");
+  if (m_kernel_version[p] != '0' || m_kernel_version[p + 1] != 'x')
+    return LLDB_INVALID_ADDRESS;
+
+  addr_t kernel_load_address;
+  errno = 0;
+  kernel_load_address = ::strtoul(m_kernel_version.c_str() + p, NULL, 16);
+  if (errno != 0 || kernel_load_address == 0)
+    return LLDB_INVALID_ADDRESS;
+
+  return kernel_load_address;
+}
+
+bool CommunicationKDP::SendRequestHostInfo() {
+  PacketStreamType request_packet(Stream::eBinary, m_addr_byte_size,
+                                  m_byte_order);
+  const CommandType command = KDP_HOSTINFO;
+  const uint32_t command_length = 8;
+  MakeRequestPacketHeader(command, request_packet, command_length);
+  DataExtractor reply_packet;
+  if (SendRequestAndGetReply(command, request_packet, reply_packet)) {
+    lldb::offset_t offset = 8;
+    m_kdp_hostinfo_cpu_mask = reply_packet.GetU32(&offset);
+    m_kdp_hostinfo_cpu_type = reply_packet.GetU32(&offset);
+    m_kdp_hostinfo_cpu_subtype = reply_packet.GetU32(&offset);
+
+    ArchSpec kernel_arch;
+    kernel_arch.SetArchitecture(eArchTypeMachO, m_kdp_hostinfo_cpu_type,
+                                m_kdp_hostinfo_cpu_subtype);
 
-bool
-CommunicationKDP::SendRequestKernelVersion ()
-{
-    PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
-    const CommandType command = KDP_KERNELVERSION;
-    const uint32_t command_length = 8;
-    MakeRequestPacketHeader (command, request_packet, command_length);
-    DataExtractor reply_packet;
-    if (SendRequestAndGetReply (command, request_packet, reply_packet))
-    {
-        const char *kernel_version_cstr = reply_packet.PeekCStr(8);
-        if (kernel_version_cstr && kernel_version_cstr[0])
-            m_kernel_version.assign (kernel_version_cstr);
-        return true;
-    }
-    return false;
+    m_addr_byte_size = kernel_arch.GetAddressByteSize();
+    m_byte_order = kernel_arch.GetByteOrder();
+    return true;
+  }
+  return false;
 }
 
-bool
-CommunicationKDP::SendRequestDisconnect ()
-{
-    PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
-    const CommandType command = KDP_DISCONNECT;
-    const uint32_t command_length = 8;
-    MakeRequestPacketHeader (command, request_packet, command_length);
-    DataExtractor reply_packet;
-    if (SendRequestAndGetReply (command, request_packet, reply_packet))
-    {
-        // Are we supposed to get a reply for disconnect?
-    }
-    ClearKDPSettings ();
+const char *CommunicationKDP::GetKernelVersion() {
+  if (m_kernel_version.empty())
+    SendRequestKernelVersion();
+  return m_kernel_version.c_str();
+}
+
+bool CommunicationKDP::SendRequestKernelVersion() {
+  PacketStreamType request_packet(Stream::eBinary, m_addr_byte_size,
+                                  m_byte_order);
+  const CommandType command = KDP_KERNELVERSION;
+  const uint32_t command_length = 8;
+  MakeRequestPacketHeader(command, request_packet, command_length);
+  DataExtractor reply_packet;
+  if (SendRequestAndGetReply(command, request_packet, reply_packet)) {
+    const char *kernel_version_cstr = reply_packet.PeekCStr(8);
+    if (kernel_version_cstr && kernel_version_cstr[0])
+      m_kernel_version.assign(kernel_version_cstr);
     return true;
+  }
+  return false;
 }
 
-uint32_t
-CommunicationKDP::SendRequestReadMemory (lldb::addr_t addr, 
-                                         void *dst, 
-                                         uint32_t dst_len,
-                                         Error &error)
-{
-    PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
-    bool use_64 = (GetVersion() >= 11);
-    uint32_t command_addr_byte_size = use_64 ? 8 : 4;
-    const CommandType command = use_64 ? KDP_READMEM64 : KDP_READMEM;
-    // Size is header + address size + uint32_t length
-    const uint32_t command_length = 8 + command_addr_byte_size + 4;
-    MakeRequestPacketHeader (command, request_packet, command_length);
-    request_packet.PutMaxHex64 (addr, command_addr_byte_size);
-    request_packet.PutHex32 (dst_len);
-    DataExtractor reply_packet;
-    if (SendRequestAndGetReply (command, request_packet, reply_packet))
-    {
-        lldb::offset_t offset = 8;
-        uint32_t kdp_error = reply_packet.GetU32 (&offset);
-        uint32_t src_len = reply_packet.GetByteSize() - 12;
-        
-        if (src_len > 0)
-        {
-            const void *src = reply_packet.GetData(&offset, src_len);
-            if (src)
-            {
-                ::memcpy (dst, src, src_len);
-                error.Clear();
-                return src_len;
-            }
-        }
-        if (kdp_error)
-            error.SetErrorStringWithFormat ("kdp read memory failed (error %u)", kdp_error);
-        else
-            error.SetErrorString ("kdp read memory failed");
-    }
+bool CommunicationKDP::SendRequestDisconnect() {
+  PacketStreamType request_packet(Stream::eBinary, m_addr_byte_size,
+                                  m_byte_order);
+  const CommandType command = KDP_DISCONNECT;
+  const uint32_t command_length = 8;
+  MakeRequestPacketHeader(command, request_packet, command_length);
+  DataExtractor reply_packet;
+  if (SendRequestAndGetReply(command, request_packet, reply_packet)) {
+    // Are we supposed to get a reply for disconnect?
+  }
+  ClearKDPSettings();
+  return true;
+}
+
+uint32_t CommunicationKDP::SendRequestReadMemory(lldb::addr_t addr, void *dst,
+                                                 uint32_t dst_len,
+                                                 Error &error) {
+  PacketStreamType request_packet(Stream::eBinary, m_addr_byte_size,
+                                  m_byte_order);
+  bool use_64 = (GetVersion() >= 11);
+  uint32_t command_addr_byte_size = use_64 ? 8 : 4;
+  const CommandType command = use_64 ? KDP_READMEM64 : KDP_READMEM;
+  // Size is header + address size + uint32_t length
+  const uint32_t command_length = 8 + command_addr_byte_size + 4;
+  MakeRequestPacketHeader(command, request_packet, command_length);
+  request_packet.PutMaxHex64(addr, command_addr_byte_size);
+  request_packet.PutHex32(dst_len);
+  DataExtractor reply_packet;
+  if (SendRequestAndGetReply(command, request_packet, reply_packet)) {
+    lldb::offset_t offset = 8;
+    uint32_t kdp_error = reply_packet.GetU32(&offset);
+    uint32_t src_len = reply_packet.GetByteSize() - 12;
+
+    if (src_len > 0) {
+      const void *src = reply_packet.GetData(&offset, src_len);
+      if (src) {
+        ::memcpy(dst, src, src_len);
+        error.Clear();
+        return src_len;
+      }
+    }
+    if (kdp_error)
+      error.SetErrorStringWithFormat("kdp read memory failed (error %u)",
+                                     kdp_error);
     else
-    {
-        error.SetErrorString ("failed to send packet");
-    }
-    return 0;
-}
-
-
-uint32_t
-CommunicationKDP::SendRequestWriteMemory (lldb::addr_t addr, 
-                                          const void *src, 
-                                          uint32_t src_len,
-                                          Error &error)
-{
-    PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
-    bool use_64 = (GetVersion() >= 11);
-    uint32_t command_addr_byte_size = use_64 ? 8 : 4;
-    const CommandType command = use_64 ? KDP_WRITEMEM64 : KDP_WRITEMEM;
-    // Size is header + address size + uint32_t length
-    const uint32_t command_length = 8 + command_addr_byte_size + 4 + src_len;
-    MakeRequestPacketHeader (command, request_packet, command_length);
-    request_packet.PutMaxHex64 (addr, command_addr_byte_size);
-    request_packet.PutHex32 (src_len);
-    request_packet.PutRawBytes(src, src_len);
+      error.SetErrorString("kdp read memory failed");
+  } else {
+    error.SetErrorString("failed to send packet");
+  }
+  return 0;
+}
+
+uint32_t CommunicationKDP::SendRequestWriteMemory(lldb::addr_t addr,
+                                                  const void *src,
+                                                  uint32_t src_len,
+                                                  Error &error) {
+  PacketStreamType request_packet(Stream::eBinary, m_addr_byte_size,
+                                  m_byte_order);
+  bool use_64 = (GetVersion() >= 11);
+  uint32_t command_addr_byte_size = use_64 ? 8 : 4;
+  const CommandType command = use_64 ? KDP_WRITEMEM64 : KDP_WRITEMEM;
+  // Size is header + address size + uint32_t length
+  const uint32_t command_length = 8 + command_addr_byte_size + 4 + src_len;
+  MakeRequestPacketHeader(command, request_packet, command_length);
+  request_packet.PutMaxHex64(addr, command_addr_byte_size);
+  request_packet.PutHex32(src_len);
+  request_packet.PutRawBytes(src, src_len);
+
+  DataExtractor reply_packet;
+  if (SendRequestAndGetReply(command, request_packet, reply_packet)) {
+    lldb::offset_t offset = 8;
+    uint32_t kdp_error = reply_packet.GetU32(&offset);
+    if (kdp_error)
+      error.SetErrorStringWithFormat("kdp write memory failed (error %u)",
+                                     kdp_error);
+    else {
+      error.Clear();
+      return src_len;
+    }
+  } else {
+    error.SetErrorString("failed to send packet");
+  }
+  return 0;
+}
+
+bool CommunicationKDP::SendRawRequest(
+    uint8_t command_byte,
+    const void *src,  // Raw packet payload bytes
+    uint32_t src_len, // Raw packet payload length
+    DataExtractor &reply_packet, Error &error) {
+  PacketStreamType request_packet(Stream::eBinary, m_addr_byte_size,
+                                  m_byte_order);
+  // Size is header + address size + uint32_t length
+  const uint32_t command_length = 8 + src_len;
+  const CommandType command = (CommandType)command_byte;
+  MakeRequestPacketHeader(command, request_packet, command_length);
+  request_packet.PutRawBytes(src, src_len);
+
+  if (SendRequestAndGetReply(command, request_packet, reply_packet)) {
+    lldb::offset_t offset = 8;
+    uint32_t kdp_error = reply_packet.GetU32(&offset);
+    if (kdp_error && (command_byte != KDP_DUMPINFO))
+      error.SetErrorStringWithFormat("request packet 0x%8.8x failed (error %u)",
+                                     command_byte, kdp_error);
+    else {
+      error.Clear();
+      return true;
+    }
+  } else {
+    error.SetErrorString("failed to send packet");
+  }
+  return false;
+}
+
+const char *CommunicationKDP::GetCommandAsCString(uint8_t command) {
+  switch (command) {
+  case KDP_CONNECT:
+    return "KDP_CONNECT";
+  case KDP_DISCONNECT:
+    return "KDP_DISCONNECT";
+  case KDP_HOSTINFO:
+    return "KDP_HOSTINFO";
+  case KDP_VERSION:
+    return "KDP_VERSION";
+  case KDP_MAXBYTES:
+    return "KDP_MAXBYTES";
+  case KDP_READMEM:
+    return "KDP_READMEM";
+  case KDP_WRITEMEM:
+    return "KDP_WRITEMEM";
+  case KDP_READREGS:
+    return "KDP_READREGS";
+  case KDP_WRITEREGS:
+    return "KDP_WRITEREGS";
+  case KDP_LOAD:
+    return "KDP_LOAD";
+  case KDP_IMAGEPATH:
+    return "KDP_IMAGEPATH";
+  case KDP_SUSPEND:
+    return "KDP_SUSPEND";
+  case KDP_RESUMECPUS:
+    return "KDP_RESUMECPUS";
+  case KDP_EXCEPTION:
+    return "KDP_EXCEPTION";
+  case KDP_TERMINATION:
+    return "KDP_TERMINATION";
+  case KDP_BREAKPOINT_SET:
+    return "KDP_BREAKPOINT_SET";
+  case KDP_BREAKPOINT_REMOVE:
+    return "KDP_BREAKPOINT_REMOVE";
+  case KDP_REGIONS:
+    return "KDP_REGIONS";
+  case KDP_REATTACH:
+    return "KDP_REATTACH";
+  case KDP_HOSTREBOOT:
+    return "KDP_HOSTREBOOT";
+  case KDP_READMEM64:
+    return "KDP_READMEM64";
+  case KDP_WRITEMEM64:
+    return "KDP_WRITEMEM64";
+  case KDP_BREAKPOINT_SET64:
+    return "KDP_BREAKPOINT64_SET";
+  case KDP_BREAKPOINT_REMOVE64:
+    return "KDP_BREAKPOINT64_REMOVE";
+  case KDP_KERNELVERSION:
+    return "KDP_KERNELVERSION";
+  case KDP_READPHYSMEM64:
+    return "KDP_READPHYSMEM64";
+  case KDP_WRITEPHYSMEM64:
+    return "KDP_WRITEPHYSMEM64";
+  case KDP_READIOPORT:
+    return "KDP_READIOPORT";
+  case KDP_WRITEIOPORT:
+    return "KDP_WRITEIOPORT";
+  case KDP_READMSR64:
+    return "KDP_READMSR64";
+  case KDP_WRITEMSR64:
+    return "KDP_WRITEMSR64";
+  case KDP_DUMPINFO:
+    return "KDP_DUMPINFO";
+  }
+  return NULL;
+}
+
+void CommunicationKDP::DumpPacket(Stream &s, const void *data,
+                                  uint32_t data_len) {
+  DataExtractor extractor(data, data_len, m_byte_order, m_addr_byte_size);
+  DumpPacket(s, extractor);
+}
+
+void CommunicationKDP::DumpPacket(Stream &s, const DataExtractor &packet) {
+  const char *error_desc = NULL;
+  if (packet.GetByteSize() < 8) {
+    error_desc = "error: invalid packet (too short): ";
+  } else {
+    lldb::offset_t offset = 0;
+    const uint8_t first_packet_byte = packet.GetU8(&offset);
+    const uint8_t sequence_id = packet.GetU8(&offset);
+    const uint16_t length = packet.GetU16(&offset);
+    const uint32_t key = packet.GetU32(&offset);
+    const CommandType command = ExtractCommand(first_packet_byte);
+    const char *command_name = GetCommandAsCString(command);
+    if (command_name) {
+      const bool is_reply = ExtractIsReply(first_packet_byte);
+      s.Printf("(running=%i) %s %24s: 0x%2.2x 0x%2.2x 0x%4.4x 0x%8.8x ",
+               IsRunning(), is_reply ? "<--" : "-->", command_name,
+               first_packet_byte, sequence_id, length, key);
+
+      if (is_reply) {
+        // Dump request reply packets
+        switch (command) {
+        // Commands that return a single 32 bit error
+        case KDP_CONNECT:
+        case KDP_WRITEMEM:
+        case KDP_WRITEMEM64:
+        case KDP_BREAKPOINT_SET:
+        case KDP_BREAKPOINT_REMOVE:
+        case KDP_BREAKPOINT_SET64:
+        case KDP_BREAKPOINT_REMOVE64:
+        case KDP_WRITEREGS:
+        case KDP_LOAD:
+        case KDP_WRITEIOPORT:
+        case KDP_WRITEMSR64: {
+          const uint32_t error = packet.GetU32(&offset);
+          s.Printf(" (error=0x%8.8x)", error);
+        } break;
+
+        case KDP_DISCONNECT:
+        case KDP_REATTACH:
+        case KDP_HOSTREBOOT:
+        case KDP_SUSPEND:
+        case KDP_RESUMECPUS:
+        case KDP_EXCEPTION:
+        case KDP_TERMINATION:
+          // No return value for the reply, just the header to ack
+          s.PutCString(" ()");
+          break;
+
+        case KDP_HOSTINFO: {
+          const uint32_t cpu_mask = packet.GetU32(&offset);
+          const uint32_t cpu_type = packet.GetU32(&offset);
+          const uint32_t cpu_subtype = packet.GetU32(&offset);
+          s.Printf(" (cpu_mask=0x%8.8x, cpu_type=0x%8.8x, cpu_subtype=0x%8.8x)",
+                   cpu_mask, cpu_type, cpu_subtype);
+        } break;
+
+        case KDP_VERSION: {
+          const uint32_t version = packet.GetU32(&offset);
+          const uint32_t feature = packet.GetU32(&offset);
+          s.Printf(" (version=0x%8.8x, feature=0x%8.8x)", version, feature);
+        } break;
+
+        case KDP_REGIONS: {
+          const uint32_t region_count = packet.GetU32(&offset);
+          s.Printf(" (count = %u", region_count);
+          for (uint32_t i = 0; i < region_count; ++i) {
+            const addr_t region_addr = packet.GetPointer(&offset);
+            const uint32_t region_size = packet.GetU32(&offset);
+            const uint32_t region_prot = packet.GetU32(&offset);
+            s.Printf("\n\tregion[%" PRIu64 "] = { range = [0x%16.16" PRIx64
+                     " - 0x%16.16" PRIx64 "), size = 0x%8.8x, prot = %s }",
+                     region_addr, region_addr, region_addr + region_size,
+                     region_size, GetPermissionsAsCString(region_prot));
+          }
+        } break;
+
+        case KDP_READMEM:
+        case KDP_READMEM64:
+        case KDP_READPHYSMEM64: {
+          const uint32_t error = packet.GetU32(&offset);
+          const uint32_t count = packet.GetByteSize() - offset;
+          s.Printf(" (error = 0x%8.8x:\n", error);
+          if (count > 0)
+            packet.Dump(&s,                      // Stream to dump to
+                        offset,                  // Offset within "packet"
+                        eFormatBytesWithASCII,   // Format to use
+                        1,                       // Size of each item in bytes
+                        count,                   // Number of items
+                        16,                      // Number per line
+                        m_last_read_memory_addr, // Don't show addresses before
+                                                 // each line
+                        0, 0);                   // No bitfields
+        } break;
+
+        case KDP_READREGS: {
+          const uint32_t error = packet.GetU32(&offset);
+          const uint32_t count = packet.GetByteSize() - offset;
+          s.Printf(" (error = 0x%8.8x regs:\n", error);
+          if (count > 0)
+            packet.Dump(
+                &s,                       // Stream to dump to
+                offset,                   // Offset within "packet"
+                eFormatHex,               // Format to use
+                m_addr_byte_size,         // Size of each item in bytes
+                count / m_addr_byte_size, // Number of items
+                16 / m_addr_byte_size,    // Number per line
+                LLDB_INVALID_ADDRESS, // Don't show addresses before each line
+                0, 0);                // No bitfields
+        } break;
+
+        case KDP_KERNELVERSION: {
+          const char *kernel_version = packet.PeekCStr(8);
+          s.Printf(" (version = \"%s\")", kernel_version);
+        } break;
+
+        case KDP_MAXBYTES: {
+          const uint32_t max_bytes = packet.GetU32(&offset);
+          s.Printf(" (max_bytes = 0x%8.8x (%u))", max_bytes, max_bytes);
+        } break;
+        case KDP_IMAGEPATH: {
+          const char *path = packet.GetCStr(&offset);
+          s.Printf(" (path = \"%s\")", path);
+        } break;
+
+        case KDP_READIOPORT:
+        case KDP_READMSR64: {
+          const uint32_t error = packet.GetU32(&offset);
+          const uint32_t count = packet.GetByteSize() - offset;
+          s.Printf(" (error = 0x%8.8x io:\n", error);
+          if (count > 0)
+            packet.Dump(
+                &s,                   // Stream to dump to
+                offset,               // Offset within "packet"
+                eFormatHex,           // Format to use
+                1,                    // Size of each item in bytes
+                count,                // Number of items
+                16,                   // Number per line
+                LLDB_INVALID_ADDRESS, // Don't show addresses before each line
+                0, 0);                // No bitfields
+        } break;
+        case KDP_DUMPINFO: {
+          const uint32_t count = packet.GetByteSize() - offset;
+          s.Printf(" (count = %u, bytes = \n", count);
+          if (count > 0)
+            packet.Dump(
+                &s,                   // Stream to dump to
+                offset,               // Offset within "packet"
+                eFormatHex,           // Format to use
+                1,                    // Size of each item in bytes
+                count,                // Number of items
+                16,                   // Number per line
+                LLDB_INVALID_ADDRESS, // Don't show addresses before each line
+                0, 0);                // No bitfields
 
-    DataExtractor reply_packet;
-    if (SendRequestAndGetReply (command, request_packet, reply_packet))
-    {
-        lldb::offset_t offset = 8;
-        uint32_t kdp_error = reply_packet.GetU32 (&offset);
-        if (kdp_error)
-            error.SetErrorStringWithFormat ("kdp write memory failed (error %u)", kdp_error);
-        else
-        {
-            error.Clear();
-            return src_len;
-        }
-    }
-    else
-    {
-        error.SetErrorString ("failed to send packet");
-    }
-    return 0;
-}
+        } break;
 
-bool
-CommunicationKDP::SendRawRequest (uint8_t command_byte,
-                                  const void *src,  // Raw packet payload bytes
-                                  uint32_t src_len, // Raw packet payload length
-                                  DataExtractor &reply_packet,
-                                  Error &error)
-{
-    PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
-    // Size is header + address size + uint32_t length
-    const uint32_t command_length = 8 + src_len;
-    const CommandType command = (CommandType)command_byte;
-    MakeRequestPacketHeader (command, request_packet, command_length);
-    request_packet.PutRawBytes(src, src_len);
-    
-    if (SendRequestAndGetReply (command, request_packet, reply_packet))
-    {
-        lldb::offset_t offset = 8;
-        uint32_t kdp_error = reply_packet.GetU32 (&offset);
-        if (kdp_error  && (command_byte != KDP_DUMPINFO))
-            error.SetErrorStringWithFormat ("request packet 0x%8.8x failed (error %u)", command_byte, kdp_error);
-        else
-        {
-            error.Clear();
-            return true;
+        default:
+          s.Printf(" (add support for dumping this packet reply!!!");
+          break;
         }
-    }
-    else
-    {
-        error.SetErrorString ("failed to send packet");
-    }
-    return false;
-}
-
-
-const char *
-CommunicationKDP::GetCommandAsCString (uint8_t command)
-{
-    switch (command)
-    {
-    case KDP_CONNECT:               return "KDP_CONNECT";
-    case KDP_DISCONNECT:            return "KDP_DISCONNECT";
-    case KDP_HOSTINFO:              return "KDP_HOSTINFO";
-    case KDP_VERSION:               return "KDP_VERSION";
-    case KDP_MAXBYTES:              return "KDP_MAXBYTES";
-    case KDP_READMEM:               return "KDP_READMEM";
-    case KDP_WRITEMEM:              return "KDP_WRITEMEM";
-    case KDP_READREGS:              return "KDP_READREGS";
-    case KDP_WRITEREGS:             return "KDP_WRITEREGS";
-    case KDP_LOAD:                  return "KDP_LOAD";
-    case KDP_IMAGEPATH:             return "KDP_IMAGEPATH";
-    case KDP_SUSPEND:               return "KDP_SUSPEND";
-    case KDP_RESUMECPUS:            return "KDP_RESUMECPUS";
-    case KDP_EXCEPTION:             return "KDP_EXCEPTION";
-    case KDP_TERMINATION:           return "KDP_TERMINATION";
-    case KDP_BREAKPOINT_SET:        return "KDP_BREAKPOINT_SET";
-    case KDP_BREAKPOINT_REMOVE:     return "KDP_BREAKPOINT_REMOVE";
-    case KDP_REGIONS:               return "KDP_REGIONS";
-    case KDP_REATTACH:              return "KDP_REATTACH";
-    case KDP_HOSTREBOOT:            return "KDP_HOSTREBOOT";
-    case KDP_READMEM64:             return "KDP_READMEM64";
-    case KDP_WRITEMEM64:            return "KDP_WRITEMEM64";
-    case KDP_BREAKPOINT_SET64:      return "KDP_BREAKPOINT64_SET";
-    case KDP_BREAKPOINT_REMOVE64:   return "KDP_BREAKPOINT64_REMOVE";
-    case KDP_KERNELVERSION:         return "KDP_KERNELVERSION";
-    case KDP_READPHYSMEM64:         return "KDP_READPHYSMEM64";
-    case KDP_WRITEPHYSMEM64:        return "KDP_WRITEPHYSMEM64";
-    case KDP_READIOPORT:            return "KDP_READIOPORT";
-    case KDP_WRITEIOPORT:           return "KDP_WRITEIOPORT";
-    case KDP_READMSR64:             return "KDP_READMSR64";
-    case KDP_WRITEMSR64:            return "KDP_WRITEMSR64";
-    case KDP_DUMPINFO:              return "KDP_DUMPINFO";
-    }
-    return NULL;
-}
-
-void
-CommunicationKDP::DumpPacket (Stream &s, const void *data, uint32_t data_len)
-{
-    DataExtractor extractor (data, data_len, m_byte_order, m_addr_byte_size);
-    DumpPacket (s, extractor);
-}
-
-void
-CommunicationKDP::DumpPacket (Stream &s, const DataExtractor& packet)
-{
-    const char *error_desc = NULL;
-    if (packet.GetByteSize() < 8)
-    {
-        error_desc = "error: invalid packet (too short): ";
-    }
-    else
-    {
-        lldb::offset_t offset = 0;
-        const uint8_t first_packet_byte = packet.GetU8 (&offset);
-        const uint8_t sequence_id = packet.GetU8 (&offset);
-        const uint16_t length = packet.GetU16 (&offset);
-        const uint32_t key = packet.GetU32 (&offset);
-        const CommandType command = ExtractCommand (first_packet_byte);
-        const char *command_name = GetCommandAsCString (command);
-        if (command_name)
-        {
-            const bool is_reply = ExtractIsReply(first_packet_byte);
-            s.Printf ("(running=%i) %s %24s: 0x%2.2x 0x%2.2x 0x%4.4x 0x%8.8x ",
-                      IsRunning(),
-                      is_reply ? "<--" : "-->",
-                      command_name,
-                      first_packet_byte,
-                      sequence_id,
-                      length,
-                      key);
-            
-            if (is_reply)
-            {
-                // Dump request reply packets
-                switch (command)
-                {
-                    // Commands that return a single 32 bit error
-                    case KDP_CONNECT:
-                    case KDP_WRITEMEM:
-                    case KDP_WRITEMEM64:
-                    case KDP_BREAKPOINT_SET:
-                    case KDP_BREAKPOINT_REMOVE:
-                    case KDP_BREAKPOINT_SET64:
-                    case KDP_BREAKPOINT_REMOVE64:
-                    case KDP_WRITEREGS:
-                    case KDP_LOAD:
-                    case KDP_WRITEIOPORT:
-                    case KDP_WRITEMSR64:
-                        {
-                            const uint32_t error = packet.GetU32 (&offset);
-                            s.Printf(" (error=0x%8.8x)", error);
-                        }
-                        break;
-                    
-                    case KDP_DISCONNECT:
-                    case KDP_REATTACH:
-                    case KDP_HOSTREBOOT:
-                    case KDP_SUSPEND:
-                    case KDP_RESUMECPUS:
-                    case KDP_EXCEPTION:
-                    case KDP_TERMINATION:
-                        // No return value for the reply, just the header to ack
-                        s.PutCString(" ()");
-                        break;
-
-                    case KDP_HOSTINFO:
-                        {
-                            const uint32_t cpu_mask = packet.GetU32 (&offset);
-                            const uint32_t cpu_type = packet.GetU32 (&offset);
-                            const uint32_t cpu_subtype = packet.GetU32 (&offset);
-                            s.Printf(" (cpu_mask=0x%8.8x, cpu_type=0x%8.8x, cpu_subtype=0x%8.8x)", cpu_mask, cpu_type, cpu_subtype);
-                        }
-                        break;
-                        
-                    case KDP_VERSION:
-                        {
-                            const uint32_t version = packet.GetU32 (&offset);
-                            const uint32_t feature = packet.GetU32 (&offset);
-                            s.Printf(" (version=0x%8.8x, feature=0x%8.8x)", version, feature);
-                        }
-                        break;
-                        
-                    case KDP_REGIONS:
-                        {
-                            const uint32_t region_count = packet.GetU32 (&offset);
-                            s.Printf(" (count = %u", region_count); 
-                            for (uint32_t i=0; i<region_count; ++i)
-                            {
-                                const addr_t region_addr = packet.GetPointer (&offset);
-                                const uint32_t region_size = packet.GetU32 (&offset);
-                                const uint32_t region_prot = packet.GetU32 (&offset);
-                                s.Printf("\n\tregion[%" PRIu64 "] = { range = [0x%16.16" PRIx64 " - 0x%16.16" PRIx64 "), size = 0x%8.8x, prot = %s }", region_addr, region_addr, region_addr + region_size, region_size, GetPermissionsAsCString (region_prot));
-                            }
-                        }
-                        break;
-
-                    case KDP_READMEM:
-                    case KDP_READMEM64:
-                    case KDP_READPHYSMEM64:
-                        {
-                            const uint32_t error = packet.GetU32 (&offset);
-                            const uint32_t count = packet.GetByteSize() - offset;
-                            s.Printf(" (error = 0x%8.8x:\n", error); 
-                            if (count > 0)
-                                packet.Dump (&s,                        // Stream to dump to
-                                             offset,                    // Offset within "packet"
-                                             eFormatBytesWithASCII,     // Format to use
-                                             1,                         // Size of each item in bytes
-                                             count,                     // Number of items
-                                             16,                        // Number per line
-                                             m_last_read_memory_addr,   // Don't show addresses before each line
-                                             0, 0);                     // No bitfields
-                        }
-                        break;
-
-                    case KDP_READREGS:
-                        {
-                            const uint32_t error = packet.GetU32 (&offset);
-                            const uint32_t count = packet.GetByteSize() - offset;
-                            s.Printf(" (error = 0x%8.8x regs:\n", error); 
-                            if (count > 0)
-                                packet.Dump (&s,                        // Stream to dump to
-                                             offset,                    // Offset within "packet"
-                                             eFormatHex,                // Format to use
-                                             m_addr_byte_size,          // Size of each item in bytes
-                                             count / m_addr_byte_size,  // Number of items
-                                             16 / m_addr_byte_size,     // Number per line
-                                             LLDB_INVALID_ADDRESS,      // Don't show addresses before each line
-                                             0, 0);                     // No bitfields
-                        }
-                        break;
-
-                    case KDP_KERNELVERSION:
-                        {
-                            const char *kernel_version = packet.PeekCStr(8);
-                            s.Printf(" (version = \"%s\")", kernel_version);
-                        }
-                        break;
-                        
-                    case KDP_MAXBYTES:
-                        {
-                            const uint32_t max_bytes = packet.GetU32 (&offset);
-                            s.Printf(" (max_bytes = 0x%8.8x (%u))", max_bytes, max_bytes);
-                        }
-                        break;
-                    case KDP_IMAGEPATH:
-                        {
-                            const char *path = packet.GetCStr(&offset);
-                            s.Printf(" (path = \"%s\")", path);
-                        }
-                        break;
-
-                    case KDP_READIOPORT:
-                    case KDP_READMSR64:
-                        {
-                            const uint32_t error = packet.GetU32 (&offset);
-                            const uint32_t count = packet.GetByteSize() - offset;
-                            s.Printf(" (error = 0x%8.8x io:\n", error); 
-                            if (count > 0)
-                                packet.Dump (&s,                        // Stream to dump to
-                                             offset,                    // Offset within "packet"
-                                             eFormatHex,                // Format to use
-                                             1,                         // Size of each item in bytes
-                                             count,                     // Number of items
-                                             16,                        // Number per line
-                                             LLDB_INVALID_ADDRESS,      // Don't show addresses before each line
-                                             0, 0);                     // No bitfields
-                        }
-                        break;
-                    case KDP_DUMPINFO:
-                        {
-                            const uint32_t count = packet.GetByteSize() - offset;
-                            s.Printf(" (count = %u, bytes = \n", count);
-                            if (count > 0)
-                                packet.Dump (&s,                        // Stream to dump to
-                                             offset,                    // Offset within "packet"
-                                             eFormatHex,                // Format to use
-                                             1,                         // Size of each item in bytes
-                                             count,                     // Number of items
-                                             16,                        // Number per line
-                                             LLDB_INVALID_ADDRESS,      // Don't show addresses before each line
-                                             0, 0);                     // No bitfields
-                            
-                        }
-                        break;
-                        
-                    default:
-                        s.Printf(" (add support for dumping this packet reply!!!"); 
-                        break;
-                    
-                } 
-            }
-            else
-            {
-                // Dump request packets
-                switch (command)
-                {
-                    case KDP_CONNECT:               
-                        {
-                            const uint16_t reply_port = ntohs(packet.GetU16 (&offset));
-                            const uint16_t exc_port = ntohs(packet.GetU16 (&offset));
-                            s.Printf(" (reply_port = %u, exc_port = %u, greeting = \"%s\")", reply_port, exc_port, packet.GetCStr(&offset));
-                        }
-                        break;
-                                 
-                    case KDP_DISCONNECT:
-                    case KDP_HOSTREBOOT:
-                    case KDP_HOSTINFO:
-                    case KDP_VERSION:
-                    case KDP_REGIONS:
-                    case KDP_KERNELVERSION:
-                    case KDP_MAXBYTES:
-                    case KDP_IMAGEPATH:
-                    case KDP_SUSPEND:
-                        // No args, just the header in the request...
-                        s.PutCString(" ()");
-                        break;
-
-                    case KDP_RESUMECPUS:
-                        {
-                            const uint32_t cpu_mask = packet.GetU32 (&offset);
-                            s.Printf(" (cpu_mask = 0x%8.8x)", cpu_mask);
-                        }
-                        break;
-
-                    case KDP_READMEM:
-                        {
-                            const uint32_t addr = packet.GetU32 (&offset);
-                            const uint32_t size = packet.GetU32 (&offset);
-                            s.Printf(" (addr = 0x%8.8x, size = %u)", addr, size);
-                            m_last_read_memory_addr = addr;
-                        }
-                        break;
-
-                    case KDP_WRITEMEM:
-                        {
-                            const uint32_t addr = packet.GetU32 (&offset);
-                            const uint32_t size = packet.GetU32 (&offset);
-                            s.Printf(" (addr = 0x%8.8x, size = %u, bytes = \n", addr, size);
-                            if (size > 0)
-                                DataExtractor::DumpHexBytes(&s, packet.GetData(&offset, size), size, 32, addr);
-                        }
-                        break;
-
-                    case KDP_READMEM64:
-                        {
-                            const uint64_t addr = packet.GetU64 (&offset);
-                            const uint32_t size = packet.GetU32 (&offset);
-                            s.Printf(" (addr = 0x%16.16" PRIx64 ", size = %u)", addr, size);
-                            m_last_read_memory_addr = addr;
-                        }
-                        break;
-
-                    case KDP_READPHYSMEM64:
-                        {
-                            const uint64_t addr = packet.GetU64 (&offset);
-                            const uint32_t size = packet.GetU32 (&offset);
-                            const uint32_t lcpu = packet.GetU16 (&offset);
-                            s.Printf(" (addr = 0x%16.16llx, size = %u, lcpu = %u)", addr, size, lcpu);
-                            m_last_read_memory_addr = addr;
-                        }
-                        break;
-
-                    case KDP_WRITEMEM64:
-                        {
-                            const uint64_t addr = packet.GetU64 (&offset);
-                            const uint32_t size = packet.GetU32 (&offset);
-                            s.Printf(" (addr = 0x%16.16" PRIx64 ", size = %u, bytes = \n", addr, size);
-                            if (size > 0)
-                                DataExtractor::DumpHexBytes(&s, packet.GetData(&offset, size), size, 32, addr);
-                        }
-                        break;
-
-                    case KDP_WRITEPHYSMEM64:
-                        {
-                            const uint64_t addr = packet.GetU64 (&offset);
-                            const uint32_t size = packet.GetU32 (&offset);
-                            const uint32_t lcpu = packet.GetU16 (&offset);
-                            s.Printf(" (addr = 0x%16.16llx, size = %u, lcpu = %u, bytes = \n", addr, size, lcpu);
-                            if (size > 0)
-                                DataExtractor::DumpHexBytes(&s, packet.GetData(&offset, size), size, 32, addr);
-                        }
-                        break;
-
-                    case KDP_READREGS:
-                        {
-                            const uint32_t cpu = packet.GetU32 (&offset);
-                            const uint32_t flavor = packet.GetU32 (&offset);
-                            s.Printf(" (cpu = %u, flavor = %u)", cpu, flavor);
-                        }
-                        break;
-
-                    case KDP_WRITEREGS:
-                        {
-                            const uint32_t cpu = packet.GetU32 (&offset);
-                            const uint32_t flavor = packet.GetU32 (&offset);
-                            const uint32_t nbytes = packet.GetByteSize() - offset;
-                            s.Printf(" (cpu = %u, flavor = %u, regs = \n", cpu, flavor);
-                            if (nbytes > 0)
-                                packet.Dump (&s,                        // Stream to dump to
-                                             offset,                    // Offset within "packet"
-                                             eFormatHex,                // Format to use
-                                             m_addr_byte_size,          // Size of each item in bytes
-                                             nbytes / m_addr_byte_size, // Number of items
-                                             16 / m_addr_byte_size,     // Number per line
-                                             LLDB_INVALID_ADDRESS,      // Don't show addresses before each line
-                                             0, 0);                     // No bitfields
-                        }
-                        break;
-
-
-                    case KDP_BREAKPOINT_SET:
-                    case KDP_BREAKPOINT_REMOVE:
-                        {
-                            const uint32_t addr = packet.GetU32 (&offset);
-                            s.Printf(" (addr = 0x%8.8x)", addr);
-                        }
-                        break;
-
-                    case KDP_BREAKPOINT_SET64:
-                    case KDP_BREAKPOINT_REMOVE64:
-                        {
-                            const uint64_t addr = packet.GetU64 (&offset);
-                            s.Printf(" (addr = 0x%16.16" PRIx64 ")", addr);
-                        }
-                        break;
-
-
-                    case KDP_LOAD:
-                        {
-                            const char *path = packet.GetCStr(&offset);
-                            s.Printf(" (path = \"%s\")", path);
-                        }
-                        break;
-
-                    case KDP_EXCEPTION:
-                        {
-                            const uint32_t count = packet.GetU32 (&offset);
-                            
-                            for (uint32_t i=0; i<count; ++i)
-                            {
-                                const uint32_t cpu = packet.GetU32 (&offset);
-                                const uint32_t exc = packet.GetU32 (&offset);
-                                const uint32_t code = packet.GetU32 (&offset);
-                                const uint32_t subcode = packet.GetU32 (&offset);
-                                const char *exc_cstr = NULL;
-                                switch (exc)
-                                {
-                                    case 1:  exc_cstr = "EXC_BAD_ACCESS"; break;
-                                    case 2:  exc_cstr = "EXC_BAD_INSTRUCTION"; break;
-                                    case 3:  exc_cstr = "EXC_ARITHMETIC"; break;
-                                    case 4:  exc_cstr = "EXC_EMULATION"; break;
-                                    case 5:  exc_cstr = "EXC_SOFTWARE"; break;
-                                    case 6:  exc_cstr = "EXC_BREAKPOINT"; break;
-                                    case 7:  exc_cstr = "EXC_SYSCALL"; break;
-                                    case 8:  exc_cstr = "EXC_MACH_SYSCALL"; break;
-                                    case 9:  exc_cstr = "EXC_RPC_ALERT"; break;
-                                    case 10: exc_cstr = "EXC_CRASH"; break;
-                                    default:
-                                        break;
-                                }
-
-                                s.Printf ("{ cpu = 0x%8.8x, exc = %s (%u), code = %u (0x%8.8x), subcode = %u (0x%8.8x)} ", 
-                                          cpu, exc_cstr, exc, code, code, subcode, subcode);
-                            }
-                        }
-                        break;
-
-                    case KDP_TERMINATION:
-                        {
-                            const uint32_t term_code = packet.GetU32 (&offset);
-                            const uint32_t exit_code = packet.GetU32 (&offset);
-                            s.Printf(" (term_code = 0x%8.8x (%u), exit_code = 0x%8.8x (%u))", term_code, term_code, exit_code, exit_code);
-                        }
-                        break;
-
-                    case KDP_REATTACH:
-                        {
-                            const uint16_t reply_port = ntohs(packet.GetU16 (&offset));
-                            s.Printf(" (reply_port = %u)", reply_port);
-                        }
-                        break;
-
-                    case KDP_READMSR64:
-                        {
-                            const uint32_t address = packet.GetU32 (&offset);
-                            const uint16_t lcpu = packet.GetU16 (&offset);
-                            s.Printf(" (address=0x%8.8x, lcpu=0x%4.4x)", address, lcpu);
-                        }
-                        break;
-
-                    case KDP_WRITEMSR64:
-                        {
-                            const uint32_t address = packet.GetU32 (&offset);
-                            const uint16_t lcpu = packet.GetU16 (&offset);
-                            const uint32_t nbytes = packet.GetByteSize() - offset;
-                            s.Printf(" (address=0x%8.8x, lcpu=0x%4.4x, nbytes=0x%8.8x)", lcpu, address, nbytes);
-                            if (nbytes > 0)
-                                packet.Dump (&s,                        // Stream to dump to
-                                             offset,                    // Offset within "packet"
-                                             eFormatHex,                // Format to use
-                                             1,                         // Size of each item in bytes
-                                             nbytes,                    // Number of items
-                                             16,                        // Number per line
-                                             LLDB_INVALID_ADDRESS,      // Don't show addresses before each line
-                                             0, 0);                     // No bitfields
-                        }
-                        break;
-
-                    case KDP_READIOPORT:
-                        {
-                            const uint16_t lcpu = packet.GetU16 (&offset);
-                            const uint16_t address = packet.GetU16 (&offset);
-                            const uint16_t nbytes = packet.GetU16 (&offset);
-                            s.Printf(" (lcpu=0x%4.4x, address=0x%4.4x, nbytes=%u)", lcpu, address, nbytes);
-                        }
-                        break;
-
-                    case KDP_WRITEIOPORT:
-                         {
-                            const uint16_t lcpu = packet.GetU16 (&offset);
-                            const uint16_t address = packet.GetU16 (&offset);
-                            const uint16_t nbytes = packet.GetU16 (&offset);
-                            s.Printf(" (lcpu = %u, addr = 0x%4.4x, nbytes = %u, bytes = \n", lcpu, address, nbytes);
-                            if (nbytes > 0)
-                                packet.Dump (&s,                        // Stream to dump to
-                                             offset,                    // Offset within "packet"
-                                             eFormatHex,                // Format to use
-                                             1,                         // Size of each item in bytes
-                                             nbytes,                    // Number of items
-                                             16,                        // Number per line
-                                             LLDB_INVALID_ADDRESS,      // Don't show addresses before each line
-                                             0, 0);                     // No bitfields
-                        }
-                        break;
-                        
-                    case KDP_DUMPINFO:
-                        {
-                            const uint32_t count = packet.GetByteSize() - offset;
-                            s.Printf(" (count = %u, bytes = \n", count);
-                            if (count > 0)
-                                packet.Dump (&s,                        // Stream to dump to
-                                             offset,                    // Offset within "packet"
-                                             eFormatHex,                // Format to use
-                                             1,                         // Size of each item in bytes
-                                             count,                     // Number of items
-                                             16,                        // Number per line
-                                             LLDB_INVALID_ADDRESS,      // Don't show addresses before each line
-                                             0, 0);                     // No bitfields
-                            
-                        }
-                        break;
-                        
-               }
+      } else {
+        // Dump request packets
+        switch (command) {
+        case KDP_CONNECT: {
+          const uint16_t reply_port = ntohs(packet.GetU16(&offset));
+          const uint16_t exc_port = ntohs(packet.GetU16(&offset));
+          s.Printf(" (reply_port = %u, exc_port = %u, greeting = \"%s\")",
+                   reply_port, exc_port, packet.GetCStr(&offset));
+        } break;
+
+        case KDP_DISCONNECT:
+        case KDP_HOSTREBOOT:
+        case KDP_HOSTINFO:
+        case KDP_VERSION:
+        case KDP_REGIONS:
+        case KDP_KERNELVERSION:
+        case KDP_MAXBYTES:
+        case KDP_IMAGEPATH:
+        case KDP_SUSPEND:
+          // No args, just the header in the request...
+          s.PutCString(" ()");
+          break;
+
+        case KDP_RESUMECPUS: {
+          const uint32_t cpu_mask = packet.GetU32(&offset);
+          s.Printf(" (cpu_mask = 0x%8.8x)", cpu_mask);
+        } break;
+
+        case KDP_READMEM: {
+          const uint32_t addr = packet.GetU32(&offset);
+          const uint32_t size = packet.GetU32(&offset);
+          s.Printf(" (addr = 0x%8.8x, size = %u)", addr, size);
+          m_last_read_memory_addr = addr;
+        } break;
+
+        case KDP_WRITEMEM: {
+          const uint32_t addr = packet.GetU32(&offset);
+          const uint32_t size = packet.GetU32(&offset);
+          s.Printf(" (addr = 0x%8.8x, size = %u, bytes = \n", addr, size);
+          if (size > 0)
+            DataExtractor::DumpHexBytes(&s, packet.GetData(&offset, size), size,
+                                        32, addr);
+        } break;
+
+        case KDP_READMEM64: {
+          const uint64_t addr = packet.GetU64(&offset);
+          const uint32_t size = packet.GetU32(&offset);
+          s.Printf(" (addr = 0x%16.16" PRIx64 ", size = %u)", addr, size);
+          m_last_read_memory_addr = addr;
+        } break;
+
+        case KDP_READPHYSMEM64: {
+          const uint64_t addr = packet.GetU64(&offset);
+          const uint32_t size = packet.GetU32(&offset);
+          const uint32_t lcpu = packet.GetU16(&offset);
+          s.Printf(" (addr = 0x%16.16llx, size = %u, lcpu = %u)", addr, size,
+                   lcpu);
+          m_last_read_memory_addr = addr;
+        } break;
+
+        case KDP_WRITEMEM64: {
+          const uint64_t addr = packet.GetU64(&offset);
+          const uint32_t size = packet.GetU32(&offset);
+          s.Printf(" (addr = 0x%16.16" PRIx64 ", size = %u, bytes = \n", addr,
+                   size);
+          if (size > 0)
+            DataExtractor::DumpHexBytes(&s, packet.GetData(&offset, size), size,
+                                        32, addr);
+        } break;
+
+        case KDP_WRITEPHYSMEM64: {
+          const uint64_t addr = packet.GetU64(&offset);
+          const uint32_t size = packet.GetU32(&offset);
+          const uint32_t lcpu = packet.GetU16(&offset);
+          s.Printf(" (addr = 0x%16.16llx, size = %u, lcpu = %u, bytes = \n",
+                   addr, size, lcpu);
+          if (size > 0)
+            DataExtractor::DumpHexBytes(&s, packet.GetData(&offset, size), size,
+                                        32, addr);
+        } break;
+
+        case KDP_READREGS: {
+          const uint32_t cpu = packet.GetU32(&offset);
+          const uint32_t flavor = packet.GetU32(&offset);
+          s.Printf(" (cpu = %u, flavor = %u)", cpu, flavor);
+        } break;
+
+        case KDP_WRITEREGS: {
+          const uint32_t cpu = packet.GetU32(&offset);
+          const uint32_t flavor = packet.GetU32(&offset);
+          const uint32_t nbytes = packet.GetByteSize() - offset;
+          s.Printf(" (cpu = %u, flavor = %u, regs = \n", cpu, flavor);
+          if (nbytes > 0)
+            packet.Dump(
+                &s,                        // Stream to dump to
+                offset,                    // Offset within "packet"
+                eFormatHex,                // Format to use
+                m_addr_byte_size,          // Size of each item in bytes
+                nbytes / m_addr_byte_size, // Number of items
+                16 / m_addr_byte_size,     // Number per line
+                LLDB_INVALID_ADDRESS, // Don't show addresses before each line
+                0, 0);                // No bitfields
+        } break;
+
+        case KDP_BREAKPOINT_SET:
+        case KDP_BREAKPOINT_REMOVE: {
+          const uint32_t addr = packet.GetU32(&offset);
+          s.Printf(" (addr = 0x%8.8x)", addr);
+        } break;
+
+        case KDP_BREAKPOINT_SET64:
+        case KDP_BREAKPOINT_REMOVE64: {
+          const uint64_t addr = packet.GetU64(&offset);
+          s.Printf(" (addr = 0x%16.16" PRIx64 ")", addr);
+        } break;
+
+        case KDP_LOAD: {
+          const char *path = packet.GetCStr(&offset);
+          s.Printf(" (path = \"%s\")", path);
+        } break;
+
+        case KDP_EXCEPTION: {
+          const uint32_t count = packet.GetU32(&offset);
+
+          for (uint32_t i = 0; i < count; ++i) {
+            const uint32_t cpu = packet.GetU32(&offset);
+            const uint32_t exc = packet.GetU32(&offset);
+            const uint32_t code = packet.GetU32(&offset);
+            const uint32_t subcode = packet.GetU32(&offset);
+            const char *exc_cstr = NULL;
+            switch (exc) {
+            case 1:
+              exc_cstr = "EXC_BAD_ACCESS";
+              break;
+            case 2:
+              exc_cstr = "EXC_BAD_INSTRUCTION";
+              break;
+            case 3:
+              exc_cstr = "EXC_ARITHMETIC";
+              break;
+            case 4:
+              exc_cstr = "EXC_EMULATION";
+              break;
+            case 5:
+              exc_cstr = "EXC_SOFTWARE";
+              break;
+            case 6:
+              exc_cstr = "EXC_BREAKPOINT";
+              break;
+            case 7:
+              exc_cstr = "EXC_SYSCALL";
+              break;
+            case 8:
+              exc_cstr = "EXC_MACH_SYSCALL";
+              break;
+            case 9:
+              exc_cstr = "EXC_RPC_ALERT";
+              break;
+            case 10:
+              exc_cstr = "EXC_CRASH";
+              break;
+            default:
+              break;
             }
-        }
-        else
-        {
-            error_desc = "error: invalid packet command: ";
-        }
-    }
-
-    if (error_desc)
-    {
-        s.PutCString (error_desc);
 
-        packet.Dump (&s,                    // Stream to dump to
-                     0,                     // Offset into "packet"
-                     eFormatBytes,          // Dump as hex bytes
-                     1,                     // Size of each item is 1 for single bytes
-                     packet.GetByteSize(),  // Number of bytes
-                     UINT32_MAX,            // Num bytes per line
-                     LLDB_INVALID_ADDRESS,  // Base address
-                     0, 0);                 // Bitfield info set to not do anything bitfield related
-    }
-}
+            s.Printf("{ cpu = 0x%8.8x, exc = %s (%u), code = %u (0x%8.8x), "
+                     "subcode = %u (0x%8.8x)} ",
+                     cpu, exc_cstr, exc, code, code, subcode, subcode);
+          }
+        } break;
+
+        case KDP_TERMINATION: {
+          const uint32_t term_code = packet.GetU32(&offset);
+          const uint32_t exit_code = packet.GetU32(&offset);
+          s.Printf(" (term_code = 0x%8.8x (%u), exit_code = 0x%8.8x (%u))",
+                   term_code, term_code, exit_code, exit_code);
+        } break;
+
+        case KDP_REATTACH: {
+          const uint16_t reply_port = ntohs(packet.GetU16(&offset));
+          s.Printf(" (reply_port = %u)", reply_port);
+        } break;
+
+        case KDP_READMSR64: {
+          const uint32_t address = packet.GetU32(&offset);
+          const uint16_t lcpu = packet.GetU16(&offset);
+          s.Printf(" (address=0x%8.8x, lcpu=0x%4.4x)", address, lcpu);
+        } break;
+
+        case KDP_WRITEMSR64: {
+          const uint32_t address = packet.GetU32(&offset);
+          const uint16_t lcpu = packet.GetU16(&offset);
+          const uint32_t nbytes = packet.GetByteSize() - offset;
+          s.Printf(" (address=0x%8.8x, lcpu=0x%4.4x, nbytes=0x%8.8x)", lcpu,
+                   address, nbytes);
+          if (nbytes > 0)
+            packet.Dump(
+                &s,                   // Stream to dump to
+                offset,               // Offset within "packet"
+                eFormatHex,           // Format to use
+                1,                    // Size of each item in bytes
+                nbytes,               // Number of items
+                16,                   // Number per line
+                LLDB_INVALID_ADDRESS, // Don't show addresses before each line
+                0, 0);                // No bitfields
+        } break;
+
+        case KDP_READIOPORT: {
+          const uint16_t lcpu = packet.GetU16(&offset);
+          const uint16_t address = packet.GetU16(&offset);
+          const uint16_t nbytes = packet.GetU16(&offset);
+          s.Printf(" (lcpu=0x%4.4x, address=0x%4.4x, nbytes=%u)", lcpu, address,
+                   nbytes);
+        } break;
+
+        case KDP_WRITEIOPORT: {
+          const uint16_t lcpu = packet.GetU16(&offset);
+          const uint16_t address = packet.GetU16(&offset);
+          const uint16_t nbytes = packet.GetU16(&offset);
+          s.Printf(" (lcpu = %u, addr = 0x%4.4x, nbytes = %u, bytes = \n", lcpu,
+                   address, nbytes);
+          if (nbytes > 0)
+            packet.Dump(
+                &s,                   // Stream to dump to
+                offset,               // Offset within "packet"
+                eFormatHex,           // Format to use
+                1,                    // Size of each item in bytes
+                nbytes,               // Number of items
+                16,                   // Number per line
+                LLDB_INVALID_ADDRESS, // Don't show addresses before each line
+                0, 0);                // No bitfields
+        } break;
+
+        case KDP_DUMPINFO: {
+          const uint32_t count = packet.GetByteSize() - offset;
+          s.Printf(" (count = %u, bytes = \n", count);
+          if (count > 0)
+            packet.Dump(
+                &s,                   // Stream to dump to
+                offset,               // Offset within "packet"
+                eFormatHex,           // Format to use
+                1,                    // Size of each item in bytes
+                count,                // Number of items
+                16,                   // Number per line
+                LLDB_INVALID_ADDRESS, // Don't show addresses before each line
+                0, 0);                // No bitfields
 
-uint32_t
-CommunicationKDP::SendRequestReadRegisters (uint32_t cpu,
-                                            uint32_t flavor,
-                                            void *dst,
-                                            uint32_t dst_len,
-                                            Error &error)
-{
-    PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
-    const CommandType command = KDP_READREGS;
-    // Size is header + 4 byte cpu and 4 byte flavor
-    const uint32_t command_length = 8 + 4 + 4;
-    MakeRequestPacketHeader (command, request_packet, command_length);
-    request_packet.PutHex32 (cpu);
-    request_packet.PutHex32 (flavor);
-    DataExtractor reply_packet;
-    if (SendRequestAndGetReply (command, request_packet, reply_packet))
-    {
-        lldb::offset_t offset = 8;
-        uint32_t kdp_error = reply_packet.GetU32 (&offset);
-        uint32_t src_len = reply_packet.GetByteSize() - 12;
-        
-        if (src_len > 0)
-        {
-            const uint32_t bytes_to_copy = std::min<uint32_t>(src_len, dst_len);
-            const void *src = reply_packet.GetData(&offset, bytes_to_copy);
-            if (src)
-            {
-                ::memcpy (dst, src, bytes_to_copy);
-                error.Clear();
-                // Return the number of bytes we could have returned regardless if
-                // we copied them or not, just so we know when things don't match up
-                return src_len;
-            }
+        } break;
         }
-        if (kdp_error)
-            error.SetErrorStringWithFormat("failed to read kdp registers for cpu %u flavor %u (error %u)", cpu, flavor, kdp_error);
-        else
-            error.SetErrorStringWithFormat("failed to read kdp registers for cpu %u flavor %u", cpu, flavor);
-    }
+      }
+    } else {
+      error_desc = "error: invalid packet command: ";
+    }
+  }
+
+  if (error_desc) {
+    s.PutCString(error_desc);
+
+    packet.Dump(&s,                   // Stream to dump to
+                0,                    // Offset into "packet"
+                eFormatBytes,         // Dump as hex bytes
+                1,                    // Size of each item is 1 for single bytes
+                packet.GetByteSize(), // Number of bytes
+                UINT32_MAX,           // Num bytes per line
+                LLDB_INVALID_ADDRESS, // Base address
+                0, 0); // Bitfield info set to not do anything bitfield related
+  }
+}
+
+uint32_t CommunicationKDP::SendRequestReadRegisters(uint32_t cpu,
+                                                    uint32_t flavor, void *dst,
+                                                    uint32_t dst_len,
+                                                    Error &error) {
+  PacketStreamType request_packet(Stream::eBinary, m_addr_byte_size,
+                                  m_byte_order);
+  const CommandType command = KDP_READREGS;
+  // Size is header + 4 byte cpu and 4 byte flavor
+  const uint32_t command_length = 8 + 4 + 4;
+  MakeRequestPacketHeader(command, request_packet, command_length);
+  request_packet.PutHex32(cpu);
+  request_packet.PutHex32(flavor);
+  DataExtractor reply_packet;
+  if (SendRequestAndGetReply(command, request_packet, reply_packet)) {
+    lldb::offset_t offset = 8;
+    uint32_t kdp_error = reply_packet.GetU32(&offset);
+    uint32_t src_len = reply_packet.GetByteSize() - 12;
+
+    if (src_len > 0) {
+      const uint32_t bytes_to_copy = std::min<uint32_t>(src_len, dst_len);
+      const void *src = reply_packet.GetData(&offset, bytes_to_copy);
+      if (src) {
+        ::memcpy(dst, src, bytes_to_copy);
+        error.Clear();
+        // Return the number of bytes we could have returned regardless if
+        // we copied them or not, just so we know when things don't match up
+        return src_len;
+      }
+    }
+    if (kdp_error)
+      error.SetErrorStringWithFormat(
+          "failed to read kdp registers for cpu %u flavor %u (error %u)", cpu,
+          flavor, kdp_error);
     else
-    {
-        error.SetErrorString ("failed to send packet");
-    }
-    return 0;
-}
-
-uint32_t
-CommunicationKDP::SendRequestWriteRegisters (uint32_t cpu,
-                                             uint32_t flavor,
-                                             const void *src,
-                                             uint32_t src_len,
-                                             Error &error)
-{
-    PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
-    const CommandType command = KDP_WRITEREGS;
-    // Size is header + 4 byte cpu and 4 byte flavor
-    const uint32_t command_length = 8 + 4 + 4 + src_len;
-    MakeRequestPacketHeader (command, request_packet, command_length);
-    request_packet.PutHex32 (cpu);
-    request_packet.PutHex32 (flavor);
-    request_packet.Write(src, src_len);
-    DataExtractor reply_packet;
-    if (SendRequestAndGetReply (command, request_packet, reply_packet))
-    {
-        lldb::offset_t offset = 8;
-        uint32_t kdp_error = reply_packet.GetU32 (&offset);
-        if (kdp_error == 0)
-            return src_len;
-        error.SetErrorStringWithFormat("failed to read kdp registers for cpu %u flavor %u (error %u)", cpu, flavor, kdp_error);
-    }
-    else
-    {
-        error.SetErrorString ("failed to send packet");
-    }
-    return 0;
-}
+      error.SetErrorStringWithFormat(
+          "failed to read kdp registers for cpu %u flavor %u", cpu, flavor);
+  } else {
+    error.SetErrorString("failed to send packet");
+  }
+  return 0;
+}
+
+uint32_t CommunicationKDP::SendRequestWriteRegisters(uint32_t cpu,
+                                                     uint32_t flavor,
+                                                     const void *src,
+                                                     uint32_t src_len,
+                                                     Error &error) {
+  PacketStreamType request_packet(Stream::eBinary, m_addr_byte_size,
+                                  m_byte_order);
+  const CommandType command = KDP_WRITEREGS;
+  // Size is header + 4 byte cpu and 4 byte flavor
+  const uint32_t command_length = 8 + 4 + 4 + src_len;
+  MakeRequestPacketHeader(command, request_packet, command_length);
+  request_packet.PutHex32(cpu);
+  request_packet.PutHex32(flavor);
+  request_packet.Write(src, src_len);
+  DataExtractor reply_packet;
+  if (SendRequestAndGetReply(command, request_packet, reply_packet)) {
+    lldb::offset_t offset = 8;
+    uint32_t kdp_error = reply_packet.GetU32(&offset);
+    if (kdp_error == 0)
+      return src_len;
+    error.SetErrorStringWithFormat(
+        "failed to read kdp registers for cpu %u flavor %u (error %u)", cpu,
+        flavor, kdp_error);
+  } else {
+    error.SetErrorString("failed to send packet");
+  }
+  return 0;
+}
+
+bool CommunicationKDP::SendRequestResume() {
+  PacketStreamType request_packet(Stream::eBinary, m_addr_byte_size,
+                                  m_byte_order);
+  const CommandType command = KDP_RESUMECPUS;
+  const uint32_t command_length = 12;
+  MakeRequestPacketHeader(command, request_packet, command_length);
+  request_packet.PutHex32(GetCPUMask());
 
-
-bool
-CommunicationKDP::SendRequestResume ()
-{
-    PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
-    const CommandType command = KDP_RESUMECPUS;
-    const uint32_t command_length = 12;
-    MakeRequestPacketHeader (command, request_packet, command_length);
-    request_packet.PutHex32(GetCPUMask());
-
-    DataExtractor reply_packet;
-    if (SendRequestAndGetReply (command, request_packet, reply_packet))
-        return true;
-    return false;
-}
-
-bool
-CommunicationKDP::SendRequestBreakpoint (bool set, addr_t addr)
-{
-    PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
-    bool use_64 = (GetVersion() >= 11);
-    uint32_t command_addr_byte_size = use_64 ? 8 : 4;
-    const CommandType command = set ? (use_64 ? KDP_BREAKPOINT_SET64    : KDP_BREAKPOINT_SET   ):
-                                      (use_64 ? KDP_BREAKPOINT_REMOVE64 : KDP_BREAKPOINT_REMOVE);
-
-    const uint32_t command_length = 8 + command_addr_byte_size;
-    MakeRequestPacketHeader (command, request_packet, command_length);
-    request_packet.PutMaxHex64 (addr, command_addr_byte_size);
-    
-    DataExtractor reply_packet;
-    if (SendRequestAndGetReply (command, request_packet, reply_packet))
-    {
-        lldb::offset_t offset = 8;
-        uint32_t kdp_error = reply_packet.GetU32 (&offset);        
-        if (kdp_error == 0)
-            return true;
-    }
-    return false;
+  DataExtractor reply_packet;
+  if (SendRequestAndGetReply(command, request_packet, reply_packet))
+    return true;
+  return false;
 }
 
-bool
-CommunicationKDP::SendRequestSuspend ()
-{
-    PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
-    const CommandType command = KDP_SUSPEND;
-    const uint32_t command_length = 8;
-    MakeRequestPacketHeader (command, request_packet, command_length);
-    DataExtractor reply_packet;
-    if (SendRequestAndGetReply (command, request_packet, reply_packet))
-        return true;
-    return false;
+bool CommunicationKDP::SendRequestBreakpoint(bool set, addr_t addr) {
+  PacketStreamType request_packet(Stream::eBinary, m_addr_byte_size,
+                                  m_byte_order);
+  bool use_64 = (GetVersion() >= 11);
+  uint32_t command_addr_byte_size = use_64 ? 8 : 4;
+  const CommandType command =
+      set ? (use_64 ? KDP_BREAKPOINT_SET64 : KDP_BREAKPOINT_SET)
+          : (use_64 ? KDP_BREAKPOINT_REMOVE64 : KDP_BREAKPOINT_REMOVE);
+
+  const uint32_t command_length = 8 + command_addr_byte_size;
+  MakeRequestPacketHeader(command, request_packet, command_length);
+  request_packet.PutMaxHex64(addr, command_addr_byte_size);
+
+  DataExtractor reply_packet;
+  if (SendRequestAndGetReply(command, request_packet, reply_packet)) {
+    lldb::offset_t offset = 8;
+    uint32_t kdp_error = reply_packet.GetU32(&offset);
+    if (kdp_error == 0)
+      return true;
+  }
+  return false;
+}
+
+bool CommunicationKDP::SendRequestSuspend() {
+  PacketStreamType request_packet(Stream::eBinary, m_addr_byte_size,
+                                  m_byte_order);
+  const CommandType command = KDP_SUSPEND;
+  const uint32_t command_length = 8;
+  MakeRequestPacketHeader(command, request_packet, command_length);
+  DataExtractor reply_packet;
+  if (SendRequestAndGetReply(command, request_packet, reply_packet))
+    return true;
+  return false;
 }
-

Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h Tue Sep  6 15:57:50 2016
@@ -18,330 +18,248 @@
 
 // Other libraries and framework includes
 // Project includes
-#include "lldb/lldb-private.h"
 #include "lldb/Core/Communication.h"
 #include "lldb/Core/Listener.h"
 #include "lldb/Core/StreamBuffer.h"
 #include "lldb/Host/Predicate.h"
 #include "lldb/Host/TimeValue.h"
+#include "lldb/lldb-private.h"
 
-class CommunicationKDP : public lldb_private::Communication
-{
+class CommunicationKDP : public lldb_private::Communication {
 public:
-    enum
-    {
-        eBroadcastBitRunPacketSent = kLoUserBroadcastBit
-    };
-    
-    const static uint32_t kMaxPacketSize = 1200;
-    const static uint32_t kMaxDataSize = 1024;
-    typedef lldb_private::StreamBuffer<1024> PacketStreamType;
-    typedef enum 
-    {
-        KDP_CONNECT = 0u,               
-        KDP_DISCONNECT,
-        KDP_HOSTINFO,
-        KDP_VERSION,
-        KDP_MAXBYTES,
-        KDP_READMEM,
-        KDP_WRITEMEM,
-        KDP_READREGS,
-        KDP_WRITEREGS,
-        KDP_LOAD,
-        KDP_IMAGEPATH,
-        KDP_SUSPEND,
-        KDP_RESUMECPUS,
-        KDP_EXCEPTION,
-        KDP_TERMINATION,
-        KDP_BREAKPOINT_SET,
-        KDP_BREAKPOINT_REMOVE,
-        KDP_REGIONS,
-        KDP_REATTACH,
-        KDP_HOSTREBOOT,
-        KDP_READMEM64,
-        KDP_WRITEMEM64,
-        KDP_BREAKPOINT_SET64,
-        KDP_BREAKPOINT_REMOVE64,
-        KDP_KERNELVERSION,
-        KDP_READPHYSMEM64,
-        KDP_WRITEPHYSMEM64,
-        KDP_READIOPORT,
-        KDP_WRITEIOPORT,
-        KDP_READMSR64,
-        KDP_WRITEMSR64,
-        KDP_DUMPINFO
-    } CommandType;
-
-    enum 
-    {
-        KDP_FEATURE_BP = (1u << 0)
-    };
-
-    typedef enum
-    {
-        KDP_PROTERR_SUCCESS = 0,
-        KDP_PROTERR_ALREADY_CONNECTED,
-        KDP_PROTERR_BAD_NBYTES,
-        KDP_PROTERR_BADFLAVOR
-    } KDPError;
-    
-    typedef enum
-    {
-        ePacketTypeRequest  = 0x00u,
-        ePacketTypeReply    = 0x80u,
-        ePacketTypeMask     = 0x80u,
-        eCommandTypeMask    = 0x7fu
-    } PacketType;
-    //------------------------------------------------------------------
-    // Constructors and Destructors
-    //------------------------------------------------------------------
-    CommunicationKDP (const char *comm_name);
-
-    virtual
-    ~CommunicationKDP();
-
-    bool
-    SendRequestPacket (const PacketStreamType &request_packet);
-
-    // Wait for a packet within 'nsec' seconds
-    size_t
-    WaitForPacketWithTimeoutMicroSeconds (lldb_private::DataExtractor &response,
-                                          uint32_t usec);
-
-    bool
-    GetSequenceMutex(std::unique_lock<std::recursive_mutex> &lock);
-
-    bool
-    CheckForPacket (const uint8_t *src, 
-                    size_t src_len, 
-                    lldb_private::DataExtractor &packet);
-    bool
-    IsRunning() const
-    {
-        return m_is_running.GetValue();
-    }
-
-    //------------------------------------------------------------------
-    // Set the global packet timeout.
-    //
-    // For clients, this is the timeout that gets used when sending
-    // packets and waiting for responses. For servers, this might not
-    // get used, and if it doesn't this should be moved to the
-    // CommunicationKDPClient.
-    //------------------------------------------------------------------
-    uint32_t 
-    SetPacketTimeout (uint32_t packet_timeout)
-    {
-        const uint32_t old_packet_timeout = m_packet_timeout;
-        m_packet_timeout = packet_timeout;
-        return old_packet_timeout;
-    }
-
-    uint32_t
-    GetPacketTimeoutInMicroSeconds () const
-    {
-        return m_packet_timeout * lldb_private::TimeValue::MicroSecPerSec;
-    }
-    
-    //------------------------------------------------------------------
-    // Public Request Packets
-    //------------------------------------------------------------------
-    bool
-    SendRequestConnect (uint16_t reply_port, 
-                        uint16_t exc_port, 
-                        const char *greeting);
-
-    bool
-    SendRequestReattach (uint16_t reply_port);
-
-    bool
-    SendRequestDisconnect ();
-    
-    uint32_t
-    SendRequestReadMemory (lldb::addr_t addr, 
-                           void *dst, 
-                           uint32_t dst_size,
-                           lldb_private::Error &error);
-
-    uint32_t
-    SendRequestWriteMemory (lldb::addr_t addr, 
-                            const void *src, 
-                            uint32_t src_len,
-                            lldb_private::Error &error);
-
-    bool
-    SendRawRequest (uint8_t command_byte,
-                    const void *src,
-                    uint32_t src_len,
-                    lldb_private::DataExtractor &reply,
-                    lldb_private::Error &error);
-
-    uint32_t
-    SendRequestReadRegisters (uint32_t cpu,
-                              uint32_t flavor,
-                              void *dst, 
-                              uint32_t dst_size,
-                              lldb_private::Error &error);
-
-    uint32_t
-    SendRequestWriteRegisters (uint32_t cpu,
-                               uint32_t flavor,
-                               const void *src,
-                               uint32_t src_size,
-                               lldb_private::Error &error);
-
-    const char *
-    GetKernelVersion ();
-    
-    // Disable KDP_IMAGEPATH for now, it seems to hang the KDP connection...
-    // const char *
-    // GetImagePath ();
-
-    uint32_t
-    GetVersion ();
-
-    uint32_t
-    GetFeatureFlags ();
-
-    bool
-    LocalBreakpointsAreSupported ()
-    {
-        return (GetFeatureFlags() & KDP_FEATURE_BP) != 0;
-    }
-
-    uint32_t
-    GetCPUMask ();
-    
-    uint32_t
-    GetCPUType ();
-    
-    uint32_t
-    GetCPUSubtype ();
-
-    lldb_private::UUID 
-    GetUUID ();
-
-    bool
-    RemoteIsEFI ();
-
-    bool
-    RemoteIsDarwinKernel ();
-
-    lldb::addr_t
-    GetLoadAddress ();
+  enum { eBroadcastBitRunPacketSent = kLoUserBroadcastBit };
+
+  const static uint32_t kMaxPacketSize = 1200;
+  const static uint32_t kMaxDataSize = 1024;
+  typedef lldb_private::StreamBuffer<1024> PacketStreamType;
+  typedef enum {
+    KDP_CONNECT = 0u,
+    KDP_DISCONNECT,
+    KDP_HOSTINFO,
+    KDP_VERSION,
+    KDP_MAXBYTES,
+    KDP_READMEM,
+    KDP_WRITEMEM,
+    KDP_READREGS,
+    KDP_WRITEREGS,
+    KDP_LOAD,
+    KDP_IMAGEPATH,
+    KDP_SUSPEND,
+    KDP_RESUMECPUS,
+    KDP_EXCEPTION,
+    KDP_TERMINATION,
+    KDP_BREAKPOINT_SET,
+    KDP_BREAKPOINT_REMOVE,
+    KDP_REGIONS,
+    KDP_REATTACH,
+    KDP_HOSTREBOOT,
+    KDP_READMEM64,
+    KDP_WRITEMEM64,
+    KDP_BREAKPOINT_SET64,
+    KDP_BREAKPOINT_REMOVE64,
+    KDP_KERNELVERSION,
+    KDP_READPHYSMEM64,
+    KDP_WRITEPHYSMEM64,
+    KDP_READIOPORT,
+    KDP_WRITEIOPORT,
+    KDP_READMSR64,
+    KDP_WRITEMSR64,
+    KDP_DUMPINFO
+  } CommandType;
+
+  enum { KDP_FEATURE_BP = (1u << 0) };
+
+  typedef enum {
+    KDP_PROTERR_SUCCESS = 0,
+    KDP_PROTERR_ALREADY_CONNECTED,
+    KDP_PROTERR_BAD_NBYTES,
+    KDP_PROTERR_BADFLAVOR
+  } KDPError;
+
+  typedef enum {
+    ePacketTypeRequest = 0x00u,
+    ePacketTypeReply = 0x80u,
+    ePacketTypeMask = 0x80u,
+    eCommandTypeMask = 0x7fu
+  } PacketType;
+  //------------------------------------------------------------------
+  // Constructors and Destructors
+  //------------------------------------------------------------------
+  CommunicationKDP(const char *comm_name);
+
+  virtual ~CommunicationKDP();
+
+  bool SendRequestPacket(const PacketStreamType &request_packet);
+
+  // Wait for a packet within 'nsec' seconds
+  size_t
+  WaitForPacketWithTimeoutMicroSeconds(lldb_private::DataExtractor &response,
+                                       uint32_t usec);
+
+  bool GetSequenceMutex(std::unique_lock<std::recursive_mutex> &lock);
+
+  bool CheckForPacket(const uint8_t *src, size_t src_len,
+                      lldb_private::DataExtractor &packet);
+  bool IsRunning() const { return m_is_running.GetValue(); }
+
+  //------------------------------------------------------------------
+  // Set the global packet timeout.
+  //
+  // For clients, this is the timeout that gets used when sending
+  // packets and waiting for responses. For servers, this might not
+  // get used, and if it doesn't this should be moved to the
+  // CommunicationKDPClient.
+  //------------------------------------------------------------------
+  uint32_t SetPacketTimeout(uint32_t packet_timeout) {
+    const uint32_t old_packet_timeout = m_packet_timeout;
+    m_packet_timeout = packet_timeout;
+    return old_packet_timeout;
+  }
+
+  uint32_t GetPacketTimeoutInMicroSeconds() const {
+    return m_packet_timeout * lldb_private::TimeValue::MicroSecPerSec;
+  }
+
+  //------------------------------------------------------------------
+  // Public Request Packets
+  //------------------------------------------------------------------
+  bool SendRequestConnect(uint16_t reply_port, uint16_t exc_port,
+                          const char *greeting);
+
+  bool SendRequestReattach(uint16_t reply_port);
+
+  bool SendRequestDisconnect();
+
+  uint32_t SendRequestReadMemory(lldb::addr_t addr, void *dst,
+                                 uint32_t dst_size, lldb_private::Error &error);
+
+  uint32_t SendRequestWriteMemory(lldb::addr_t addr, const void *src,
+                                  uint32_t src_len, lldb_private::Error &error);
+
+  bool SendRawRequest(uint8_t command_byte, const void *src, uint32_t src_len,
+                      lldb_private::DataExtractor &reply,
+                      lldb_private::Error &error);
+
+  uint32_t SendRequestReadRegisters(uint32_t cpu, uint32_t flavor, void *dst,
+                                    uint32_t dst_size,
+                                    lldb_private::Error &error);
+
+  uint32_t SendRequestWriteRegisters(uint32_t cpu, uint32_t flavor,
+                                     const void *src, uint32_t src_size,
+                                     lldb_private::Error &error);
+
+  const char *GetKernelVersion();
+
+  // Disable KDP_IMAGEPATH for now, it seems to hang the KDP connection...
+  // const char *
+  // GetImagePath ();
+
+  uint32_t GetVersion();
+
+  uint32_t GetFeatureFlags();
+
+  bool LocalBreakpointsAreSupported() {
+    return (GetFeatureFlags() & KDP_FEATURE_BP) != 0;
+  }
+
+  uint32_t GetCPUMask();
+
+  uint32_t GetCPUType();
+
+  uint32_t GetCPUSubtype();
+
+  lldb_private::UUID GetUUID();
+
+  bool RemoteIsEFI();
+
+  bool RemoteIsDarwinKernel();
 
-    bool
-    SendRequestResume ();
+  lldb::addr_t GetLoadAddress();
 
-    bool
-    SendRequestSuspend ();
+  bool SendRequestResume();
 
-    bool
-    SendRequestBreakpoint (bool set, lldb::addr_t addr);
+  bool SendRequestSuspend();
+
+  bool SendRequestBreakpoint(bool set, lldb::addr_t addr);
 
 protected:
+  bool SendRequestPacketNoLock(const PacketStreamType &request_packet);
+
+  size_t WaitForPacketWithTimeoutMicroSecondsNoLock(
+      lldb_private::DataExtractor &response, uint32_t timeout_usec);
 
-    bool
-    SendRequestPacketNoLock (const PacketStreamType &request_packet);
+  bool WaitForNotRunningPrivate(const std::chrono::microseconds &timeout);
 
-    size_t
-    WaitForPacketWithTimeoutMicroSecondsNoLock (lldb_private::DataExtractor &response, 
-                                                uint32_t timeout_usec);
-
-    bool
-    WaitForNotRunningPrivate(const std::chrono::microseconds &timeout);
-
-    void
-    MakeRequestPacketHeader (CommandType request_type, 
-                             PacketStreamType &request_packet,
-                             uint16_t request_length);
-
-    //------------------------------------------------------------------
-    // Protected Request Packets (use public accessors which will cache
-    // results.
-    //------------------------------------------------------------------
-    bool
-    SendRequestVersion ();
-    
-    bool
-    SendRequestHostInfo ();
-
-    bool
-    SendRequestKernelVersion ();
-    
-    // Disable KDP_IMAGEPATH for now, it seems to hang the KDP connection...
-    //bool
-    //SendRequestImagePath ();
-
-    void
-    DumpPacket (lldb_private::Stream &s, 
-                const void *data, 
-                uint32_t data_len);
-
-    void
-    DumpPacket (lldb_private::Stream &s, 
-                const lldb_private::DataExtractor& extractor);
-
-    bool
-    VersionIsValid() const
-    {
-        return m_kdp_version_version != 0;
-    }
-
-    bool
-    HostInfoIsValid() const
-    {
-        return m_kdp_hostinfo_cpu_type != 0;
-    }
-
-    bool
-    ExtractIsReply (uint8_t first_packet_byte) const
-    {
-        // TODO: handle big endian...
-        return (first_packet_byte & ePacketTypeMask) != 0;
-    }
-
-    CommandType
-    ExtractCommand (uint8_t first_packet_byte) const
-    {
-        // TODO: handle big endian...
-        return (CommandType)(first_packet_byte & eCommandTypeMask);
-    }
-    
-    static const char *
-    GetCommandAsCString (uint8_t command);
-
-    void
-    ClearKDPSettings ();
-    
-    bool
-    SendRequestAndGetReply (const CommandType command,
-                            const PacketStreamType &request_packet, 
-                            lldb_private::DataExtractor &reply_packet);
-    //------------------------------------------------------------------
-    // Classes that inherit from CommunicationKDP can see and modify these
-    //------------------------------------------------------------------
-    uint32_t m_addr_byte_size;
-    lldb::ByteOrder m_byte_order;
-    uint32_t m_packet_timeout;
-    std::recursive_mutex m_sequence_mutex; // Restrict access to sending/receiving packets to a single thread at a time
-    lldb_private::Predicate<bool> m_is_running;
-    uint32_t m_session_key;
-    uint8_t m_request_sequence_id;
-    uint8_t m_exception_sequence_id;
-    uint32_t m_kdp_version_version;
-    uint32_t m_kdp_version_feature;
-    uint32_t m_kdp_hostinfo_cpu_mask;
-    uint32_t m_kdp_hostinfo_cpu_type;
-    uint32_t m_kdp_hostinfo_cpu_subtype;
-    std::string m_kernel_version;
-    //std::string m_image_path; // Disable KDP_IMAGEPATH for now, it seems to hang the KDP connection...
-    lldb::addr_t m_last_read_memory_addr; // Last memory read address for logging
+  void MakeRequestPacketHeader(CommandType request_type,
+                               PacketStreamType &request_packet,
+                               uint16_t request_length);
+
+  //------------------------------------------------------------------
+  // Protected Request Packets (use public accessors which will cache
+  // results.
+  //------------------------------------------------------------------
+  bool SendRequestVersion();
+
+  bool SendRequestHostInfo();
+
+  bool SendRequestKernelVersion();
+
+  // Disable KDP_IMAGEPATH for now, it seems to hang the KDP connection...
+  // bool
+  // SendRequestImagePath ();
+
+  void DumpPacket(lldb_private::Stream &s, const void *data, uint32_t data_len);
+
+  void DumpPacket(lldb_private::Stream &s,
+                  const lldb_private::DataExtractor &extractor);
+
+  bool VersionIsValid() const { return m_kdp_version_version != 0; }
+
+  bool HostInfoIsValid() const { return m_kdp_hostinfo_cpu_type != 0; }
+
+  bool ExtractIsReply(uint8_t first_packet_byte) const {
+    // TODO: handle big endian...
+    return (first_packet_byte & ePacketTypeMask) != 0;
+  }
+
+  CommandType ExtractCommand(uint8_t first_packet_byte) const {
+    // TODO: handle big endian...
+    return (CommandType)(first_packet_byte & eCommandTypeMask);
+  }
+
+  static const char *GetCommandAsCString(uint8_t command);
+
+  void ClearKDPSettings();
+
+  bool SendRequestAndGetReply(const CommandType command,
+                              const PacketStreamType &request_packet,
+                              lldb_private::DataExtractor &reply_packet);
+  //------------------------------------------------------------------
+  // Classes that inherit from CommunicationKDP can see and modify these
+  //------------------------------------------------------------------
+  uint32_t m_addr_byte_size;
+  lldb::ByteOrder m_byte_order;
+  uint32_t m_packet_timeout;
+  std::recursive_mutex m_sequence_mutex; // Restrict access to sending/receiving
+                                         // packets to a single thread at a time
+  lldb_private::Predicate<bool> m_is_running;
+  uint32_t m_session_key;
+  uint8_t m_request_sequence_id;
+  uint8_t m_exception_sequence_id;
+  uint32_t m_kdp_version_version;
+  uint32_t m_kdp_version_feature;
+  uint32_t m_kdp_hostinfo_cpu_mask;
+  uint32_t m_kdp_hostinfo_cpu_type;
+  uint32_t m_kdp_hostinfo_cpu_subtype;
+  std::string m_kernel_version;
+  // std::string m_image_path; // Disable KDP_IMAGEPATH for now, it seems to
+  // hang the KDP connection...
+  lldb::addr_t m_last_read_memory_addr; // Last memory read address for logging
 private:
-    //------------------------------------------------------------------
-    // For CommunicationKDP only
-    //------------------------------------------------------------------
-    DISALLOW_COPY_AND_ASSIGN (CommunicationKDP);
+  //------------------------------------------------------------------
+  // For CommunicationKDP only
+  //------------------------------------------------------------------
+  DISALLOW_COPY_AND_ASSIGN(CommunicationKDP);
 };
 
-#endif  // liblldb_CommunicationKDP_h_
+#endif // liblldb_CommunicationKDP_h_

Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp Tue Sep  6 15:57:50 2016
@@ -16,9 +16,9 @@
 
 // Other libraries and framework includes
 #include "lldb/Core/Debugger.h"
-#include "lldb/Core/PluginManager.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleSpec.h"
+#include "lldb/Core/PluginManager.h"
 #include "lldb/Core/State.h"
 #include "lldb/Core/UUID.h"
 #include "lldb/Host/ConnectionFileDescriptor.h"
@@ -42,1168 +42,1000 @@
 #define USEC_PER_SEC 1000000
 
 // Project includes
+#include "Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h"
+#include "Plugins/DynamicLoader/Static/DynamicLoaderStatic.h"
 #include "ProcessKDP.h"
 #include "ProcessKDPLog.h"
 #include "ThreadKDP.h"
-#include "Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h"
-#include "Plugins/DynamicLoader/Static/DynamicLoaderStatic.h"
 
 using namespace lldb;
 using namespace lldb_private;
 
 namespace {
 
-    static PropertyDefinition
-    g_properties[] =
-    {
-        { "packet-timeout" , OptionValue::eTypeUInt64 , true , 5, NULL, NULL, "Specify the default packet timeout in seconds." },
-        {  NULL            , OptionValue::eTypeInvalid, false, 0, NULL, NULL, NULL  }
-    };
-    
-    enum
-    {
-        ePropertyPacketTimeout
-    };
-
-    class PluginProperties : public Properties
-    {
-    public:
-        
-        static ConstString
-        GetSettingName ()
-        {
-            return ProcessKDP::GetPluginNameStatic();
-        }
-
-        PluginProperties() :
-            Properties ()
-        {
-            m_collection_sp.reset (new OptionValueProperties(GetSettingName()));
-            m_collection_sp->Initialize(g_properties);
-        }
-        
-        virtual
-        ~PluginProperties()
-        {
-        }
-        
-        uint64_t
-        GetPacketTimeout()
-        {
-            const uint32_t idx = ePropertyPacketTimeout;
-            return m_collection_sp->GetPropertyAtIndexAsUInt64(NULL, idx, g_properties[idx].default_uint_value);
-        }
-    };
+static PropertyDefinition g_properties[] = {
+    {"packet-timeout", OptionValue::eTypeUInt64, true, 5, NULL, NULL,
+     "Specify the default packet timeout in seconds."},
+    {NULL, OptionValue::eTypeInvalid, false, 0, NULL, NULL, NULL}};
 
-    typedef std::shared_ptr<PluginProperties> ProcessKDPPropertiesSP;
+enum { ePropertyPacketTimeout };
 
-    static const ProcessKDPPropertiesSP &
-    GetGlobalPluginProperties()
-    {
-        static ProcessKDPPropertiesSP g_settings_sp;
-        if (!g_settings_sp)
-            g_settings_sp.reset (new PluginProperties ());
-        return g_settings_sp;
-    }
-    
-} // anonymous namespace end
+class PluginProperties : public Properties {
+public:
+  static ConstString GetSettingName() {
+    return ProcessKDP::GetPluginNameStatic();
+  }
+
+  PluginProperties() : Properties() {
+    m_collection_sp.reset(new OptionValueProperties(GetSettingName()));
+    m_collection_sp->Initialize(g_properties);
+  }
+
+  virtual ~PluginProperties() {}
+
+  uint64_t GetPacketTimeout() {
+    const uint32_t idx = ePropertyPacketTimeout;
+    return m_collection_sp->GetPropertyAtIndexAsUInt64(
+        NULL, idx, g_properties[idx].default_uint_value);
+  }
+};
 
-static const lldb::tid_t g_kernel_tid = 1;
+typedef std::shared_ptr<PluginProperties> ProcessKDPPropertiesSP;
 
-ConstString
-ProcessKDP::GetPluginNameStatic()
-{
-    static ConstString g_name("kdp-remote");
-    return g_name;
-}
-
-const char *
-ProcessKDP::GetPluginDescriptionStatic()
-{
-    return "KDP Remote protocol based debugging plug-in for darwin kernel debugging.";
-}
-
-void
-ProcessKDP::Terminate()
-{
-    PluginManager::UnregisterPlugin (ProcessKDP::CreateInstance);
+static const ProcessKDPPropertiesSP &GetGlobalPluginProperties() {
+  static ProcessKDPPropertiesSP g_settings_sp;
+  if (!g_settings_sp)
+    g_settings_sp.reset(new PluginProperties());
+  return g_settings_sp;
 }
 
+} // anonymous namespace end
 
-lldb::ProcessSP
-ProcessKDP::CreateInstance (TargetSP target_sp,
-                            ListenerSP listener_sp,
-                            const FileSpec *crash_file_path)
-{
-    lldb::ProcessSP process_sp;
-    if (crash_file_path == NULL)
-        process_sp.reset(new ProcessKDP (target_sp, listener_sp));
-    return process_sp;
-}
-
-bool
-ProcessKDP::CanDebug(TargetSP target_sp, bool plugin_specified_by_name)
-{
-    if (plugin_specified_by_name)
-        return true;
-
-    // For now we are just making sure the file exists for a given module
-    Module *exe_module = target_sp->GetExecutableModulePointer();
-    if (exe_module)
-    {
-        const llvm::Triple &triple_ref = target_sp->GetArchitecture().GetTriple();
-        switch (triple_ref.getOS())
-        {
-            case llvm::Triple::Darwin:  // Should use "macosx" for desktop and "ios" for iOS, but accept darwin just in case
-            case llvm::Triple::MacOSX:  // For desktop targets
-            case llvm::Triple::IOS:     // For arm targets
-            case llvm::Triple::TvOS:
-            case llvm::Triple::WatchOS:
-                if (triple_ref.getVendor() == llvm::Triple::Apple)
-                {
-                    ObjectFile *exe_objfile = exe_module->GetObjectFile();
-                    if (exe_objfile->GetType() == ObjectFile::eTypeExecutable && 
-                        exe_objfile->GetStrata() == ObjectFile::eStrataKernel)
-                        return true;
-                }
-                break;
+static const lldb::tid_t g_kernel_tid = 1;
 
-            default:
-                break;
-        }
+ConstString ProcessKDP::GetPluginNameStatic() {
+  static ConstString g_name("kdp-remote");
+  return g_name;
+}
+
+const char *ProcessKDP::GetPluginDescriptionStatic() {
+  return "KDP Remote protocol based debugging plug-in for darwin kernel "
+         "debugging.";
+}
+
+void ProcessKDP::Terminate() {
+  PluginManager::UnregisterPlugin(ProcessKDP::CreateInstance);
+}
+
+lldb::ProcessSP ProcessKDP::CreateInstance(TargetSP target_sp,
+                                           ListenerSP listener_sp,
+                                           const FileSpec *crash_file_path) {
+  lldb::ProcessSP process_sp;
+  if (crash_file_path == NULL)
+    process_sp.reset(new ProcessKDP(target_sp, listener_sp));
+  return process_sp;
+}
+
+bool ProcessKDP::CanDebug(TargetSP target_sp, bool plugin_specified_by_name) {
+  if (plugin_specified_by_name)
+    return true;
+
+  // For now we are just making sure the file exists for a given module
+  Module *exe_module = target_sp->GetExecutableModulePointer();
+  if (exe_module) {
+    const llvm::Triple &triple_ref = target_sp->GetArchitecture().GetTriple();
+    switch (triple_ref.getOS()) {
+    case llvm::Triple::Darwin: // Should use "macosx" for desktop and "ios" for
+                               // iOS, but accept darwin just in case
+    case llvm::Triple::MacOSX: // For desktop targets
+    case llvm::Triple::IOS:    // For arm targets
+    case llvm::Triple::TvOS:
+    case llvm::Triple::WatchOS:
+      if (triple_ref.getVendor() == llvm::Triple::Apple) {
+        ObjectFile *exe_objfile = exe_module->GetObjectFile();
+        if (exe_objfile->GetType() == ObjectFile::eTypeExecutable &&
+            exe_objfile->GetStrata() == ObjectFile::eStrataKernel)
+          return true;
+      }
+      break;
+
+    default:
+      break;
     }
-    return false;
+  }
+  return false;
 }
 
 //----------------------------------------------------------------------
 // ProcessKDP constructor
 //----------------------------------------------------------------------
-ProcessKDP::ProcessKDP(TargetSP target_sp, ListenerSP listener_sp) :
-    Process (target_sp, listener_sp),
-    m_comm("lldb.process.kdp-remote.communication"),
-    m_async_broadcaster (NULL, "lldb.process.kdp-remote.async-broadcaster"),
-    m_dyld_plugin_name (),
-    m_kernel_load_addr (LLDB_INVALID_ADDRESS),
-    m_command_sp(),
-    m_kernel_thread_wp()
-{
-    m_async_broadcaster.SetEventName (eBroadcastBitAsyncThreadShouldExit,   "async thread should exit");
-    m_async_broadcaster.SetEventName (eBroadcastBitAsyncContinue,           "async thread continue");
-    const uint64_t timeout_seconds = GetGlobalPluginProperties()->GetPacketTimeout();
-    if (timeout_seconds > 0)
-        m_comm.SetPacketTimeout(timeout_seconds);
+ProcessKDP::ProcessKDP(TargetSP target_sp, ListenerSP listener_sp)
+    : Process(target_sp, listener_sp),
+      m_comm("lldb.process.kdp-remote.communication"),
+      m_async_broadcaster(NULL, "lldb.process.kdp-remote.async-broadcaster"),
+      m_dyld_plugin_name(), m_kernel_load_addr(LLDB_INVALID_ADDRESS),
+      m_command_sp(), m_kernel_thread_wp() {
+  m_async_broadcaster.SetEventName(eBroadcastBitAsyncThreadShouldExit,
+                                   "async thread should exit");
+  m_async_broadcaster.SetEventName(eBroadcastBitAsyncContinue,
+                                   "async thread continue");
+  const uint64_t timeout_seconds =
+      GetGlobalPluginProperties()->GetPacketTimeout();
+  if (timeout_seconds > 0)
+    m_comm.SetPacketTimeout(timeout_seconds);
 }
 
 //----------------------------------------------------------------------
 // Destructor
 //----------------------------------------------------------------------
-ProcessKDP::~ProcessKDP()
-{
-    Clear();
-    // We need to call finalize on the process before destroying ourselves
-    // to make sure all of the broadcaster cleanup goes as planned. If we
-    // destruct this class, then Process::~Process() might have problems
-    // trying to fully destroy the broadcaster.
-    Finalize();
+ProcessKDP::~ProcessKDP() {
+  Clear();
+  // We need to call finalize on the process before destroying ourselves
+  // to make sure all of the broadcaster cleanup goes as planned. If we
+  // destruct this class, then Process::~Process() might have problems
+  // trying to fully destroy the broadcaster.
+  Finalize();
 }
 
 //----------------------------------------------------------------------
 // PluginInterface
 //----------------------------------------------------------------------
-lldb_private::ConstString
-ProcessKDP::GetPluginName()
-{
-    return GetPluginNameStatic();
+lldb_private::ConstString ProcessKDP::GetPluginName() {
+  return GetPluginNameStatic();
 }
 
-uint32_t
-ProcessKDP::GetPluginVersion()
-{
-    return 1;
-}
+uint32_t ProcessKDP::GetPluginVersion() { return 1; }
 
-Error
-ProcessKDP::WillLaunch (Module* module)
-{
-    Error error;
-    error.SetErrorString ("launching not supported in kdp-remote plug-in");
-    return error;
+Error ProcessKDP::WillLaunch(Module *module) {
+  Error error;
+  error.SetErrorString("launching not supported in kdp-remote plug-in");
+  return error;
 }
 
-Error
-ProcessKDP::WillAttachToProcessWithID (lldb::pid_t pid)
-{
-    Error error;
-    error.SetErrorString ("attaching to a by process ID not supported in kdp-remote plug-in");
-    return error;
+Error ProcessKDP::WillAttachToProcessWithID(lldb::pid_t pid) {
+  Error error;
+  error.SetErrorString(
+      "attaching to a by process ID not supported in kdp-remote plug-in");
+  return error;
 }
 
-Error
-ProcessKDP::WillAttachToProcessWithName (const char *process_name, bool wait_for_launch)
-{
-    Error error;
-    error.SetErrorString ("attaching to a by process name not supported in kdp-remote plug-in");
-    return error;
+Error ProcessKDP::WillAttachToProcessWithName(const char *process_name,
+                                              bool wait_for_launch) {
+  Error error;
+  error.SetErrorString(
+      "attaching to a by process name not supported in kdp-remote plug-in");
+  return error;
 }
 
-bool
-ProcessKDP::GetHostArchitecture(ArchSpec &arch)
-{
-    uint32_t cpu = m_comm.GetCPUType();
-    if (cpu)
-    {
-        uint32_t sub = m_comm.GetCPUSubtype();
-        arch.SetArchitecture(eArchTypeMachO, cpu, sub);
-        // Leave architecture vendor as unspecified unknown
-        arch.GetTriple().setVendor(llvm::Triple::UnknownVendor);
-        arch.GetTriple().setVendorName(llvm::StringRef());
-        return true;
-    }
-    arch.Clear();
-    return false;
+bool ProcessKDP::GetHostArchitecture(ArchSpec &arch) {
+  uint32_t cpu = m_comm.GetCPUType();
+  if (cpu) {
+    uint32_t sub = m_comm.GetCPUSubtype();
+    arch.SetArchitecture(eArchTypeMachO, cpu, sub);
+    // Leave architecture vendor as unspecified unknown
+    arch.GetTriple().setVendor(llvm::Triple::UnknownVendor);
+    arch.GetTriple().setVendorName(llvm::StringRef());
+    return true;
+  }
+  arch.Clear();
+  return false;
 }
 
-Error
-ProcessKDP::DoConnectRemote (Stream *strm, const char *remote_url)
-{
-    Error error;
+Error ProcessKDP::DoConnectRemote(Stream *strm, const char *remote_url) {
+  Error error;
 
-    // Don't let any JIT happen when doing KDP as we can't allocate
-    // memory and we don't want to be mucking with threads that might
-    // already be handling exceptions
-    SetCanJIT(false);
-
-    if (remote_url == NULL || remote_url[0] == '\0')
-    {
-        error.SetErrorStringWithFormat ("invalid connection URL '%s'", remote_url);
-        return error;
-    }
+  // Don't let any JIT happen when doing KDP as we can't allocate
+  // memory and we don't want to be mucking with threads that might
+  // already be handling exceptions
+  SetCanJIT(false);
 
-    std::unique_ptr<ConnectionFileDescriptor> conn_ap(new ConnectionFileDescriptor());
-    if (conn_ap.get())
-    {
-        // Only try once for now.
-        // TODO: check if we should be retrying?
-        const uint32_t max_retry_count = 1;
-        for (uint32_t retry_count = 0; retry_count < max_retry_count; ++retry_count)
-        {
-            if (conn_ap->Connect(remote_url, &error) == eConnectionStatusSuccess)
-                break;
-            usleep (100000);
-        }
-    }
+  if (remote_url == NULL || remote_url[0] == '\0') {
+    error.SetErrorStringWithFormat("invalid connection URL '%s'", remote_url);
+    return error;
+  }
 
-    if (conn_ap->IsConnected())
-    {
-        const TCPSocket& socket = static_cast<const TCPSocket&>(*conn_ap->GetReadObject());
-        const uint16_t reply_port = socket.GetLocalPortNumber();
-
-        if (reply_port != 0)
-        {
-            m_comm.SetConnection(conn_ap.release());
-
-            if (m_comm.SendRequestReattach(reply_port))
-            {
-                if (m_comm.SendRequestConnect(reply_port, reply_port, "Greetings from LLDB..."))
-                {
-                    m_comm.GetVersion();
-
-                    Target &target = GetTarget();
-                    ArchSpec kernel_arch;
-                    // The host architecture
-                    GetHostArchitecture(kernel_arch);
-                    ArchSpec target_arch = target.GetArchitecture();
-                    // Merge in any unspecified stuff into the target architecture in
-                    // case the target arch isn't set at all or incompletely.
-                    target_arch.MergeFrom(kernel_arch);
-                    target.SetArchitecture(target_arch);
-
-                    /* Get the kernel's UUID and load address via KDP_KERNELVERSION packet.  */
-                    /* An EFI kdp session has neither UUID nor load address. */
-
-                    UUID kernel_uuid = m_comm.GetUUID ();
-                    addr_t kernel_load_addr = m_comm.GetLoadAddress ();
-
-                    if (m_comm.RemoteIsEFI ())
-                    {
-                        // Select an invalid plugin name for the dynamic loader so one doesn't get used
-                        // since EFI does its own manual loading via python scripting
-                        static ConstString g_none_dynamic_loader("none");
-                        m_dyld_plugin_name = g_none_dynamic_loader;
-
-                        if (kernel_uuid.IsValid()) {
-                            // If EFI passed in a UUID= try to lookup UUID
-                            // The slide will not be provided. But the UUID
-                            // lookup will be used to launch EFI debug scripts
-                            // from the dSYM, that can load all of the symbols.
-                            ModuleSpec module_spec;
-                            module_spec.GetUUID() = kernel_uuid;
-                            module_spec.GetArchitecture() = target.GetArchitecture();
-
-                            // Lookup UUID locally, before attempting dsymForUUID like action
-                            module_spec.GetSymbolFileSpec() = Symbols::LocateExecutableSymbolFile(module_spec);
-                            if (module_spec.GetSymbolFileSpec())
-                            {
-                                ModuleSpec executable_module_spec = Symbols::LocateExecutableObjectFile (module_spec);
-                                if (executable_module_spec.GetFileSpec().Exists())
-                                {
-                                    module_spec.GetFileSpec() = executable_module_spec.GetFileSpec();
-                                }
-                            }
-                            if (!module_spec.GetSymbolFileSpec() || !module_spec.GetSymbolFileSpec())
-                                 Symbols::DownloadObjectAndSymbolFile (module_spec, true);
-
-                            if (module_spec.GetFileSpec().Exists())
-                            {
-                                ModuleSP module_sp(new Module (module_spec));
-                                if (module_sp.get() && module_sp->GetObjectFile())
-                                {
-                                    // Get the current target executable
-                                    ModuleSP exe_module_sp (target.GetExecutableModule ());
-
-                                    // Make sure you don't already have the right module loaded and they will be uniqued
-                                    if (exe_module_sp.get() != module_sp.get())
-                                        target.SetExecutableModule (module_sp, false);
-                                }
-                            }
-                        }
-                    }
-                    else if (m_comm.RemoteIsDarwinKernel ())
-                    {
-                        m_dyld_plugin_name = DynamicLoaderDarwinKernel::GetPluginNameStatic();
-                        if (kernel_load_addr != LLDB_INVALID_ADDRESS)
-                        {
-                            m_kernel_load_addr = kernel_load_addr;
-                        }
-                    }
-
-                    // Set the thread ID
-                    UpdateThreadListIfNeeded ();
-                    SetID (1);
-                    GetThreadList ();
-                    SetPrivateState (eStateStopped);
-                    StreamSP async_strm_sp(target.GetDebugger().GetAsyncOutputStream());
-                    if (async_strm_sp)
-                    {
-                        const char *cstr;
-                        if ((cstr = m_comm.GetKernelVersion ()) != NULL)
-                        {
-                            async_strm_sp->Printf ("Version: %s\n", cstr);
-                            async_strm_sp->Flush();
-                        }
-//                      if ((cstr = m_comm.GetImagePath ()) != NULL)
-//                      {
-//                          async_strm_sp->Printf ("Image Path: %s\n", cstr);
-//                          async_strm_sp->Flush();
-//                      }            
-                    }
+  std::unique_ptr<ConnectionFileDescriptor> conn_ap(
+      new ConnectionFileDescriptor());
+  if (conn_ap.get()) {
+    // Only try once for now.
+    // TODO: check if we should be retrying?
+    const uint32_t max_retry_count = 1;
+    for (uint32_t retry_count = 0; retry_count < max_retry_count;
+         ++retry_count) {
+      if (conn_ap->Connect(remote_url, &error) == eConnectionStatusSuccess)
+        break;
+      usleep(100000);
+    }
+  }
+
+  if (conn_ap->IsConnected()) {
+    const TCPSocket &socket =
+        static_cast<const TCPSocket &>(*conn_ap->GetReadObject());
+    const uint16_t reply_port = socket.GetLocalPortNumber();
+
+    if (reply_port != 0) {
+      m_comm.SetConnection(conn_ap.release());
+
+      if (m_comm.SendRequestReattach(reply_port)) {
+        if (m_comm.SendRequestConnect(reply_port, reply_port,
+                                      "Greetings from LLDB...")) {
+          m_comm.GetVersion();
+
+          Target &target = GetTarget();
+          ArchSpec kernel_arch;
+          // The host architecture
+          GetHostArchitecture(kernel_arch);
+          ArchSpec target_arch = target.GetArchitecture();
+          // Merge in any unspecified stuff into the target architecture in
+          // case the target arch isn't set at all or incompletely.
+          target_arch.MergeFrom(kernel_arch);
+          target.SetArchitecture(target_arch);
+
+          /* Get the kernel's UUID and load address via KDP_KERNELVERSION
+           * packet.  */
+          /* An EFI kdp session has neither UUID nor load address. */
+
+          UUID kernel_uuid = m_comm.GetUUID();
+          addr_t kernel_load_addr = m_comm.GetLoadAddress();
+
+          if (m_comm.RemoteIsEFI()) {
+            // Select an invalid plugin name for the dynamic loader so one
+            // doesn't get used
+            // since EFI does its own manual loading via python scripting
+            static ConstString g_none_dynamic_loader("none");
+            m_dyld_plugin_name = g_none_dynamic_loader;
+
+            if (kernel_uuid.IsValid()) {
+              // If EFI passed in a UUID= try to lookup UUID
+              // The slide will not be provided. But the UUID
+              // lookup will be used to launch EFI debug scripts
+              // from the dSYM, that can load all of the symbols.
+              ModuleSpec module_spec;
+              module_spec.GetUUID() = kernel_uuid;
+              module_spec.GetArchitecture() = target.GetArchitecture();
+
+              // Lookup UUID locally, before attempting dsymForUUID like action
+              module_spec.GetSymbolFileSpec() =
+                  Symbols::LocateExecutableSymbolFile(module_spec);
+              if (module_spec.GetSymbolFileSpec()) {
+                ModuleSpec executable_module_spec =
+                    Symbols::LocateExecutableObjectFile(module_spec);
+                if (executable_module_spec.GetFileSpec().Exists()) {
+                  module_spec.GetFileSpec() =
+                      executable_module_spec.GetFileSpec();
                 }
-                else
-                {
-                    error.SetErrorString("KDP_REATTACH failed");
+              }
+              if (!module_spec.GetSymbolFileSpec() ||
+                  !module_spec.GetSymbolFileSpec())
+                Symbols::DownloadObjectAndSymbolFile(module_spec, true);
+
+              if (module_spec.GetFileSpec().Exists()) {
+                ModuleSP module_sp(new Module(module_spec));
+                if (module_sp.get() && module_sp->GetObjectFile()) {
+                  // Get the current target executable
+                  ModuleSP exe_module_sp(target.GetExecutableModule());
+
+                  // Make sure you don't already have the right module loaded
+                  // and they will be uniqued
+                  if (exe_module_sp.get() != module_sp.get())
+                    target.SetExecutableModule(module_sp, false);
                 }
+              }
             }
-            else
-            {
-                error.SetErrorString("KDP_REATTACH failed");
+          } else if (m_comm.RemoteIsDarwinKernel()) {
+            m_dyld_plugin_name =
+                DynamicLoaderDarwinKernel::GetPluginNameStatic();
+            if (kernel_load_addr != LLDB_INVALID_ADDRESS) {
+              m_kernel_load_addr = kernel_load_addr;
             }
+          }
+
+          // Set the thread ID
+          UpdateThreadListIfNeeded();
+          SetID(1);
+          GetThreadList();
+          SetPrivateState(eStateStopped);
+          StreamSP async_strm_sp(target.GetDebugger().GetAsyncOutputStream());
+          if (async_strm_sp) {
+            const char *cstr;
+            if ((cstr = m_comm.GetKernelVersion()) != NULL) {
+              async_strm_sp->Printf("Version: %s\n", cstr);
+              async_strm_sp->Flush();
+            }
+            //                      if ((cstr = m_comm.GetImagePath ()) != NULL)
+            //                      {
+            //                          async_strm_sp->Printf ("Image Path:
+            //                          %s\n", cstr);
+            //                          async_strm_sp->Flush();
+            //                      }
+          }
+        } else {
+          error.SetErrorString("KDP_REATTACH failed");
         }
-        else
-        {
-            error.SetErrorString("invalid reply port from UDP connection");
-        }
-    }
-    else
-    {
-        if (error.Success())
-            error.SetErrorStringWithFormat ("failed to connect to '%s'", remote_url);
-    }
-    if (error.Fail())
-        m_comm.Disconnect();
+      } else {
+        error.SetErrorString("KDP_REATTACH failed");
+      }
+    } else {
+      error.SetErrorString("invalid reply port from UDP connection");
+    }
+  } else {
+    if (error.Success())
+      error.SetErrorStringWithFormat("failed to connect to '%s'", remote_url);
+  }
+  if (error.Fail())
+    m_comm.Disconnect();
 
-    return error;
+  return error;
 }
 
 //----------------------------------------------------------------------
 // Process Control
 //----------------------------------------------------------------------
-Error
-ProcessKDP::DoLaunch (Module *exe_module, 
-                      ProcessLaunchInfo &launch_info)
-{
-    Error error;
-    error.SetErrorString ("launching not supported in kdp-remote plug-in");
-    return error;
+Error ProcessKDP::DoLaunch(Module *exe_module, ProcessLaunchInfo &launch_info) {
+  Error error;
+  error.SetErrorString("launching not supported in kdp-remote plug-in");
+  return error;
 }
 
-Error
-ProcessKDP::DoAttachToProcessWithID (lldb::pid_t attach_pid, const ProcessAttachInfo &attach_info)
-{
-    Error error;
-    error.SetErrorString ("attach to process by ID is not suppported in kdp remote debugging");
-    return error;
+Error ProcessKDP::DoAttachToProcessWithID(
+    lldb::pid_t attach_pid, const ProcessAttachInfo &attach_info) {
+  Error error;
+  error.SetErrorString(
+      "attach to process by ID is not suppported in kdp remote debugging");
+  return error;
 }
 
-Error
-ProcessKDP::DoAttachToProcessWithName (const char *process_name, const ProcessAttachInfo &attach_info)
-{
-    Error error;
-    error.SetErrorString ("attach to process by name is not suppported in kdp remote debugging");
-    return error;
+Error ProcessKDP::DoAttachToProcessWithName(
+    const char *process_name, const ProcessAttachInfo &attach_info) {
+  Error error;
+  error.SetErrorString(
+      "attach to process by name is not suppported in kdp remote debugging");
+  return error;
 }
 
+void ProcessKDP::DidAttach(ArchSpec &process_arch) {
+  Process::DidAttach(process_arch);
 
-void
-ProcessKDP::DidAttach (ArchSpec &process_arch)
-{
-    Process::DidAttach(process_arch);
-    
-    Log *log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PROCESS));
-    if (log)
-        log->Printf ("ProcessKDP::DidAttach()");
-    if (GetID() != LLDB_INVALID_PROCESS_ID)
-    {
-        GetHostArchitecture(process_arch);
-    }
+  Log *log(ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PROCESS));
+  if (log)
+    log->Printf("ProcessKDP::DidAttach()");
+  if (GetID() != LLDB_INVALID_PROCESS_ID) {
+    GetHostArchitecture(process_arch);
+  }
 }
 
-addr_t
-ProcessKDP::GetImageInfoAddress()
-{
-    return m_kernel_load_addr;
-}
+addr_t ProcessKDP::GetImageInfoAddress() { return m_kernel_load_addr; }
 
-lldb_private::DynamicLoader *
-ProcessKDP::GetDynamicLoader ()
-{
-    if (m_dyld_ap.get() == NULL)
-        m_dyld_ap.reset (DynamicLoader::FindPlugin(this, m_dyld_plugin_name.IsEmpty() ? NULL : m_dyld_plugin_name.GetCString()));
-    return m_dyld_ap.get();
+lldb_private::DynamicLoader *ProcessKDP::GetDynamicLoader() {
+  if (m_dyld_ap.get() == NULL)
+    m_dyld_ap.reset(DynamicLoader::FindPlugin(
+        this,
+        m_dyld_plugin_name.IsEmpty() ? NULL : m_dyld_plugin_name.GetCString()));
+  return m_dyld_ap.get();
 }
 
-Error
-ProcessKDP::WillResume ()
-{
-    return Error();
-}
+Error ProcessKDP::WillResume() { return Error(); }
 
-Error
-ProcessKDP::DoResume ()
-{
-    Error error;
-    Log *log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PROCESS));
-    // Only start the async thread if we try to do any process control
-    if (!m_async_thread.IsJoinable())
-        StartAsyncThread();
-
-    bool resume = false;
-    
-    // With KDP there is only one thread we can tell what to do
-    ThreadSP kernel_thread_sp (m_thread_list.FindThreadByProtocolID(g_kernel_tid));
-                            
-    if (kernel_thread_sp)
-    {
-        const StateType thread_resume_state = kernel_thread_sp->GetTemporaryResumeState();
-        
-        if (log)
-            log->Printf ("ProcessKDP::DoResume() thread_resume_state = %s", StateAsCString(thread_resume_state));
-        switch (thread_resume_state)
-        {
-            case eStateSuspended:
-                // Nothing to do here when a thread will stay suspended
-                // we just leave the CPU mask bit set to zero for the thread
-                if (log)
-                    log->Printf ("ProcessKDP::DoResume() = suspended???");
-                break;
-                
-            case eStateStepping:
-                {
-                    lldb::RegisterContextSP reg_ctx_sp (kernel_thread_sp->GetRegisterContext());
-
-                    if (reg_ctx_sp)
-                    {
-                        if (log)
-                            log->Printf ("ProcessKDP::DoResume () reg_ctx_sp->HardwareSingleStep (true);");
-                        reg_ctx_sp->HardwareSingleStep (true);
-                        resume = true;
-                    }
-                    else
-                    {
-                        error.SetErrorStringWithFormat("KDP thread 0x%llx has no register context", kernel_thread_sp->GetID());
-                    }
-                }
-                break;
-    
-            case eStateRunning:
-                {
-                    lldb::RegisterContextSP reg_ctx_sp (kernel_thread_sp->GetRegisterContext());
-                    
-                    if (reg_ctx_sp)
-                    {
-                        if (log)
-                            log->Printf ("ProcessKDP::DoResume () reg_ctx_sp->HardwareSingleStep (false);");
-                        reg_ctx_sp->HardwareSingleStep (false);
-                        resume = true;
-                    }
-                    else
-                    {
-                        error.SetErrorStringWithFormat("KDP thread 0x%llx has no register context", kernel_thread_sp->GetID());
-                    }
-                }
-                break;
-
-            default:
-                // The only valid thread resume states are listed above
-                assert (!"invalid thread resume state");
-                break;
-        }
-    }
-
-    if (resume)
-    {
-        if (log)
-            log->Printf ("ProcessKDP::DoResume () sending resume");
-        
-        if (m_comm.SendRequestResume ())
-        {
-            m_async_broadcaster.BroadcastEvent (eBroadcastBitAsyncContinue);
-            SetPrivateState(eStateRunning);
-        }
-        else
-            error.SetErrorString ("KDP resume failed");
-    }
-    else
-    {
-        error.SetErrorString ("kernel thread is suspended");        
-    }
-    
-    return error;
-}
-
-lldb::ThreadSP
-ProcessKDP::GetKernelThread()
-{
-    // KDP only tells us about one thread/core. Any other threads will usually
-    // be the ones that are read from memory by the OS plug-ins.
-    
-    ThreadSP thread_sp (m_kernel_thread_wp.lock());
-    if (!thread_sp)
-    {
-        thread_sp.reset(new ThreadKDP (*this, g_kernel_tid));
-        m_kernel_thread_wp = thread_sp;
-    }
-    return thread_sp;
-}
+Error ProcessKDP::DoResume() {
+  Error error;
+  Log *log(ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PROCESS));
+  // Only start the async thread if we try to do any process control
+  if (!m_async_thread.IsJoinable())
+    StartAsyncThread();
 
+  bool resume = false;
 
+  // With KDP there is only one thread we can tell what to do
+  ThreadSP kernel_thread_sp(m_thread_list.FindThreadByProtocolID(g_kernel_tid));
 
+  if (kernel_thread_sp) {
+    const StateType thread_resume_state =
+        kernel_thread_sp->GetTemporaryResumeState();
 
-bool
-ProcessKDP::UpdateThreadList (ThreadList &old_thread_list, ThreadList &new_thread_list)
-{
-    // locker will keep a mutex locked until it goes out of scope
-    Log *log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_THREAD));
-    if (log && log->GetMask().Test(KDP_LOG_VERBOSE))
-        log->Printf ("ProcessKDP::%s (pid = %" PRIu64 ")", __FUNCTION__, GetID());
-    
-    // Even though there is a CPU mask, it doesn't mean we can see each CPU
-    // individually, there is really only one. Lets call this thread 1.
-    ThreadSP thread_sp (old_thread_list.FindThreadByProtocolID(g_kernel_tid, false));
-    if (!thread_sp)
-        thread_sp = GetKernelThread ();
-    new_thread_list.AddThread(thread_sp);
-
-    return new_thread_list.GetSize(false) > 0;
-}
+    if (log)
+      log->Printf("ProcessKDP::DoResume() thread_resume_state = %s",
+                  StateAsCString(thread_resume_state));
+    switch (thread_resume_state) {
+    case eStateSuspended:
+      // Nothing to do here when a thread will stay suspended
+      // we just leave the CPU mask bit set to zero for the thread
+      if (log)
+        log->Printf("ProcessKDP::DoResume() = suspended???");
+      break;
+
+    case eStateStepping: {
+      lldb::RegisterContextSP reg_ctx_sp(
+          kernel_thread_sp->GetRegisterContext());
 
-void
-ProcessKDP::RefreshStateAfterStop ()
-{
-    // Let all threads recover from stopping and do any clean up based
-    // on the previous thread state (if any).
-    m_thread_list.RefreshStateAfterStop();
-}
+      if (reg_ctx_sp) {
+        if (log)
+          log->Printf(
+              "ProcessKDP::DoResume () reg_ctx_sp->HardwareSingleStep (true);");
+        reg_ctx_sp->HardwareSingleStep(true);
+        resume = true;
+      } else {
+        error.SetErrorStringWithFormat(
+            "KDP thread 0x%llx has no register context",
+            kernel_thread_sp->GetID());
+      }
+    } break;
+
+    case eStateRunning: {
+      lldb::RegisterContextSP reg_ctx_sp(
+          kernel_thread_sp->GetRegisterContext());
 
-Error
-ProcessKDP::DoHalt (bool &caused_stop)
-{
-    Error error;
-    
-    if (m_comm.IsRunning())
-    {
-        if (m_destroy_in_process)
-        {
-            // If we are attemping to destroy, we need to not return an error to
-            // Halt or DoDestroy won't get called.
-            // We are also currently running, so send a process stopped event
-            SetPrivateState (eStateStopped);
-        }
-        else
-        {
-            error.SetErrorString ("KDP cannot interrupt a running kernel");
-        }
+      if (reg_ctx_sp) {
+        if (log)
+          log->Printf("ProcessKDP::DoResume () reg_ctx_sp->HardwareSingleStep "
+                      "(false);");
+        reg_ctx_sp->HardwareSingleStep(false);
+        resume = true;
+      } else {
+        error.SetErrorStringWithFormat(
+            "KDP thread 0x%llx has no register context",
+            kernel_thread_sp->GetID());
+      }
+    } break;
+
+    default:
+      // The only valid thread resume states are listed above
+      assert(!"invalid thread resume state");
+      break;
     }
-    return error;
-}
+  }
 
-Error
-ProcessKDP::DoDetach(bool keep_stopped)
-{
-    Error error;
-    Log *log (ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PROCESS));
+  if (resume) {
     if (log)
-        log->Printf ("ProcessKDP::DoDetach(keep_stopped = %i)", keep_stopped);
-    
-    if (m_comm.IsRunning())
-    {
-        // We are running and we can't interrupt a running kernel, so we need
-        // to just close the connection to the kernel and hope for the best
-    }
-    else
-    {
-        // If we are going to keep the target stopped, then don't send the disconnect message.
-        if (!keep_stopped && m_comm.IsConnected())
-        {
-            const bool success = m_comm.SendRequestDisconnect();
-            if (log)
-            {
-                if (success)
-                    log->PutCString ("ProcessKDP::DoDetach() detach packet sent successfully");
-                else
-                    log->PutCString ("ProcessKDP::DoDetach() connection channel shutdown failed");
-            }
-            m_comm.Disconnect ();
-        }
-    }
-    StopAsyncThread ();    
-    m_comm.Clear();
-    
-    SetPrivateState (eStateDetached);
-    ResumePrivateStateThread();
-    
-    //KillDebugserverProcess ();
-    return error;
-}
+      log->Printf("ProcessKDP::DoResume () sending resume");
 
-Error
-ProcessKDP::DoDestroy ()
-{
-    // For KDP there really is no difference between destroy and detach
-    bool keep_stopped = false;
-    return DoDetach(keep_stopped);
+    if (m_comm.SendRequestResume()) {
+      m_async_broadcaster.BroadcastEvent(eBroadcastBitAsyncContinue);
+      SetPrivateState(eStateRunning);
+    } else
+      error.SetErrorString("KDP resume failed");
+  } else {
+    error.SetErrorString("kernel thread is suspended");
+  }
+
+  return error;
+}
+
+lldb::ThreadSP ProcessKDP::GetKernelThread() {
+  // KDP only tells us about one thread/core. Any other threads will usually
+  // be the ones that are read from memory by the OS plug-ins.
+
+  ThreadSP thread_sp(m_kernel_thread_wp.lock());
+  if (!thread_sp) {
+    thread_sp.reset(new ThreadKDP(*this, g_kernel_tid));
+    m_kernel_thread_wp = thread_sp;
+  }
+  return thread_sp;
+}
+
+bool ProcessKDP::UpdateThreadList(ThreadList &old_thread_list,
+                                  ThreadList &new_thread_list) {
+  // locker will keep a mutex locked until it goes out of scope
+  Log *log(ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_THREAD));
+  if (log && log->GetMask().Test(KDP_LOG_VERBOSE))
+    log->Printf("ProcessKDP::%s (pid = %" PRIu64 ")", __FUNCTION__, GetID());
+
+  // Even though there is a CPU mask, it doesn't mean we can see each CPU
+  // individually, there is really only one. Lets call this thread 1.
+  ThreadSP thread_sp(
+      old_thread_list.FindThreadByProtocolID(g_kernel_tid, false));
+  if (!thread_sp)
+    thread_sp = GetKernelThread();
+  new_thread_list.AddThread(thread_sp);
+
+  return new_thread_list.GetSize(false) > 0;
+}
+
+void ProcessKDP::RefreshStateAfterStop() {
+  // Let all threads recover from stopping and do any clean up based
+  // on the previous thread state (if any).
+  m_thread_list.RefreshStateAfterStop();
+}
+
+Error ProcessKDP::DoHalt(bool &caused_stop) {
+  Error error;
+
+  if (m_comm.IsRunning()) {
+    if (m_destroy_in_process) {
+      // If we are attemping to destroy, we need to not return an error to
+      // Halt or DoDestroy won't get called.
+      // We are also currently running, so send a process stopped event
+      SetPrivateState(eStateStopped);
+    } else {
+      error.SetErrorString("KDP cannot interrupt a running kernel");
+    }
+  }
+  return error;
+}
+
+Error ProcessKDP::DoDetach(bool keep_stopped) {
+  Error error;
+  Log *log(ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PROCESS));
+  if (log)
+    log->Printf("ProcessKDP::DoDetach(keep_stopped = %i)", keep_stopped);
+
+  if (m_comm.IsRunning()) {
+    // We are running and we can't interrupt a running kernel, so we need
+    // to just close the connection to the kernel and hope for the best
+  } else {
+    // If we are going to keep the target stopped, then don't send the
+    // disconnect message.
+    if (!keep_stopped && m_comm.IsConnected()) {
+      const bool success = m_comm.SendRequestDisconnect();
+      if (log) {
+        if (success)
+          log->PutCString(
+              "ProcessKDP::DoDetach() detach packet sent successfully");
+        else
+          log->PutCString(
+              "ProcessKDP::DoDetach() connection channel shutdown failed");
+      }
+      m_comm.Disconnect();
+    }
+  }
+  StopAsyncThread();
+  m_comm.Clear();
+
+  SetPrivateState(eStateDetached);
+  ResumePrivateStateThread();
+
+  // KillDebugserverProcess ();
+  return error;
+}
+
+Error ProcessKDP::DoDestroy() {
+  // For KDP there really is no difference between destroy and detach
+  bool keep_stopped = false;
+  return DoDetach(keep_stopped);
 }
 
 //------------------------------------------------------------------
 // Process Queries
 //------------------------------------------------------------------
 
-bool
-ProcessKDP::IsAlive ()
-{
-    return m_comm.IsConnected() && Process::IsAlive();
+bool ProcessKDP::IsAlive() {
+  return m_comm.IsConnected() && Process::IsAlive();
 }
 
 //------------------------------------------------------------------
 // Process Memory
 //------------------------------------------------------------------
-size_t
-ProcessKDP::DoReadMemory (addr_t addr, void *buf, size_t size, Error &error)
-{
-    uint8_t *data_buffer = (uint8_t *) buf;
-    if (m_comm.IsConnected())
-    {
-        const size_t max_read_size = 512;
-        size_t total_bytes_read = 0;
-
-        // Read the requested amount of memory in 512 byte chunks
-        while (total_bytes_read < size)
-        {
-            size_t bytes_to_read_this_request = size - total_bytes_read;
-            if (bytes_to_read_this_request > max_read_size)
-            {
-                bytes_to_read_this_request = max_read_size;
-            }
-            size_t bytes_read = m_comm.SendRequestReadMemory (addr + total_bytes_read, 
-                                                              data_buffer + total_bytes_read, 
-                                                              bytes_to_read_this_request, error);
-            total_bytes_read += bytes_read;
-            if (error.Fail() || bytes_read == 0)
-            {
-                return total_bytes_read;
-            }
-        }
-
+size_t ProcessKDP::DoReadMemory(addr_t addr, void *buf, size_t size,
+                                Error &error) {
+  uint8_t *data_buffer = (uint8_t *)buf;
+  if (m_comm.IsConnected()) {
+    const size_t max_read_size = 512;
+    size_t total_bytes_read = 0;
+
+    // Read the requested amount of memory in 512 byte chunks
+    while (total_bytes_read < size) {
+      size_t bytes_to_read_this_request = size - total_bytes_read;
+      if (bytes_to_read_this_request > max_read_size) {
+        bytes_to_read_this_request = max_read_size;
+      }
+      size_t bytes_read = m_comm.SendRequestReadMemory(
+          addr + total_bytes_read, data_buffer + total_bytes_read,
+          bytes_to_read_this_request, error);
+      total_bytes_read += bytes_read;
+      if (error.Fail() || bytes_read == 0) {
         return total_bytes_read;
+      }
     }
-    error.SetErrorString ("not connected");
-    return 0;
+
+    return total_bytes_read;
+  }
+  error.SetErrorString("not connected");
+  return 0;
 }
 
-size_t
-ProcessKDP::DoWriteMemory (addr_t addr, const void *buf, size_t size, Error &error)
-{
-    if (m_comm.IsConnected())
-        return m_comm.SendRequestWriteMemory (addr, buf, size, error);
-    error.SetErrorString ("not connected");
-    return 0;
+size_t ProcessKDP::DoWriteMemory(addr_t addr, const void *buf, size_t size,
+                                 Error &error) {
+  if (m_comm.IsConnected())
+    return m_comm.SendRequestWriteMemory(addr, buf, size, error);
+  error.SetErrorString("not connected");
+  return 0;
 }
 
-lldb::addr_t
-ProcessKDP::DoAllocateMemory (size_t size, uint32_t permissions, Error &error)
-{
-    error.SetErrorString ("memory allocation not suppported in kdp remote debugging");
-    return LLDB_INVALID_ADDRESS;
+lldb::addr_t ProcessKDP::DoAllocateMemory(size_t size, uint32_t permissions,
+                                          Error &error) {
+  error.SetErrorString(
+      "memory allocation not suppported in kdp remote debugging");
+  return LLDB_INVALID_ADDRESS;
 }
 
-Error
-ProcessKDP::DoDeallocateMemory (lldb::addr_t addr)
-{
-    Error error;
-    error.SetErrorString ("memory deallocation not suppported in kdp remote debugging");
-    return error;
+Error ProcessKDP::DoDeallocateMemory(lldb::addr_t addr) {
+  Error error;
+  error.SetErrorString(
+      "memory deallocation not suppported in kdp remote debugging");
+  return error;
 }
 
-Error
-ProcessKDP::EnableBreakpointSite (BreakpointSite *bp_site)
-{
-    if (m_comm.LocalBreakpointsAreSupported ())
-    {
-        Error error;
-        if (!bp_site->IsEnabled())
-        {
-            if (m_comm.SendRequestBreakpoint(true, bp_site->GetLoadAddress()))
-            {
-                bp_site->SetEnabled(true);
-                bp_site->SetType (BreakpointSite::eExternal);
-            }
-            else
-            {
-                error.SetErrorString ("KDP set breakpoint failed");
-            }
-        }
-        return error;
+Error ProcessKDP::EnableBreakpointSite(BreakpointSite *bp_site) {
+  if (m_comm.LocalBreakpointsAreSupported()) {
+    Error error;
+    if (!bp_site->IsEnabled()) {
+      if (m_comm.SendRequestBreakpoint(true, bp_site->GetLoadAddress())) {
+        bp_site->SetEnabled(true);
+        bp_site->SetType(BreakpointSite::eExternal);
+      } else {
+        error.SetErrorString("KDP set breakpoint failed");
+      }
     }
-    return EnableSoftwareBreakpoint (bp_site);
+    return error;
+  }
+  return EnableSoftwareBreakpoint(bp_site);
 }
 
-Error
-ProcessKDP::DisableBreakpointSite (BreakpointSite *bp_site)
-{
-    if (m_comm.LocalBreakpointsAreSupported ())
-    {
-        Error error;
-        if (bp_site->IsEnabled())
-        {
-            BreakpointSite::Type bp_type = bp_site->GetType();
-            if (bp_type == BreakpointSite::eExternal)
-            {
-                if (m_destroy_in_process && m_comm.IsRunning())
-                {
-                    // We are trying to destroy our connection and we are running
-                    bp_site->SetEnabled(false);
-                }
-                else
-                {
-                    if (m_comm.SendRequestBreakpoint(false, bp_site->GetLoadAddress()))
-                        bp_site->SetEnabled(false);
-                    else
-                        error.SetErrorString ("KDP remove breakpoint failed");
-                }
-            }
-            else
-            {
-                error = DisableSoftwareBreakpoint (bp_site);
-            }
+Error ProcessKDP::DisableBreakpointSite(BreakpointSite *bp_site) {
+  if (m_comm.LocalBreakpointsAreSupported()) {
+    Error error;
+    if (bp_site->IsEnabled()) {
+      BreakpointSite::Type bp_type = bp_site->GetType();
+      if (bp_type == BreakpointSite::eExternal) {
+        if (m_destroy_in_process && m_comm.IsRunning()) {
+          // We are trying to destroy our connection and we are running
+          bp_site->SetEnabled(false);
+        } else {
+          if (m_comm.SendRequestBreakpoint(false, bp_site->GetLoadAddress()))
+            bp_site->SetEnabled(false);
+          else
+            error.SetErrorString("KDP remove breakpoint failed");
         }
-        return error;
+      } else {
+        error = DisableSoftwareBreakpoint(bp_site);
+      }
     }
-    return DisableSoftwareBreakpoint (bp_site);
+    return error;
+  }
+  return DisableSoftwareBreakpoint(bp_site);
 }
 
-Error
-ProcessKDP::EnableWatchpoint (Watchpoint *wp, bool notify)
-{
-    Error error;
-    error.SetErrorString ("watchpoints are not suppported in kdp remote debugging");
-    return error;
+Error ProcessKDP::EnableWatchpoint(Watchpoint *wp, bool notify) {
+  Error error;
+  error.SetErrorString(
+      "watchpoints are not suppported in kdp remote debugging");
+  return error;
 }
 
-Error
-ProcessKDP::DisableWatchpoint (Watchpoint *wp, bool notify)
-{
-    Error error;
-    error.SetErrorString ("watchpoints are not suppported in kdp remote debugging");
-    return error;
+Error ProcessKDP::DisableWatchpoint(Watchpoint *wp, bool notify) {
+  Error error;
+  error.SetErrorString(
+      "watchpoints are not suppported in kdp remote debugging");
+  return error;
 }
 
-void
-ProcessKDP::Clear()
-{
-    m_thread_list.Clear();
+void ProcessKDP::Clear() { m_thread_list.Clear(); }
+
+Error ProcessKDP::DoSignal(int signo) {
+  Error error;
+  error.SetErrorString(
+      "sending signals is not suppported in kdp remote debugging");
+  return error;
 }
 
-Error
-ProcessKDP::DoSignal (int signo)
-{
-    Error error;
-    error.SetErrorString ("sending signals is not suppported in kdp remote debugging");
-    return error;
+void ProcessKDP::Initialize() {
+  static std::once_flag g_once_flag;
+
+  std::call_once(g_once_flag, []() {
+    PluginManager::RegisterPlugin(GetPluginNameStatic(),
+                                  GetPluginDescriptionStatic(), CreateInstance,
+                                  DebuggerInitialize);
+
+    Log::Callbacks log_callbacks = {ProcessKDPLog::DisableLog,
+                                    ProcessKDPLog::EnableLog,
+                                    ProcessKDPLog::ListLogCategories};
+
+    Log::RegisterLogChannel(ProcessKDP::GetPluginNameStatic(), log_callbacks);
+  });
 }
 
-void
-ProcessKDP::Initialize()
-{
-    static std::once_flag g_once_flag;
-
-    std::call_once(g_once_flag, []()
-    {
-        PluginManager::RegisterPlugin (GetPluginNameStatic(),
-                                       GetPluginDescriptionStatic(),
-                                       CreateInstance,
-                                       DebuggerInitialize);
-
-        Log::Callbacks log_callbacks = {
-            ProcessKDPLog::DisableLog,
-            ProcessKDPLog::EnableLog,
-            ProcessKDPLog::ListLogCategories
-        };
-
-        Log::RegisterLogChannel (ProcessKDP::GetPluginNameStatic(), log_callbacks);
-    });
-}
-
-void
-ProcessKDP::DebuggerInitialize (lldb_private::Debugger &debugger)
-{
-    if (!PluginManager::GetSettingForProcessPlugin(debugger, PluginProperties::GetSettingName()))
-    {
-        const bool is_global_setting = true;
-        PluginManager::CreateSettingForProcessPlugin (debugger,
-                                                      GetGlobalPluginProperties()->GetValueProperties(),
-                                                      ConstString ("Properties for the kdp-remote process plug-in."),
-                                                      is_global_setting);
-    }
+void ProcessKDP::DebuggerInitialize(lldb_private::Debugger &debugger) {
+  if (!PluginManager::GetSettingForProcessPlugin(
+          debugger, PluginProperties::GetSettingName())) {
+    const bool is_global_setting = true;
+    PluginManager::CreateSettingForProcessPlugin(
+        debugger, GetGlobalPluginProperties()->GetValueProperties(),
+        ConstString("Properties for the kdp-remote process plug-in."),
+        is_global_setting);
+  }
 }
 
-bool
-ProcessKDP::StartAsyncThread ()
-{
-    Log *log (ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PROCESS));
-    
-    if (log)
-        log->Printf ("ProcessKDP::StartAsyncThread ()");
+bool ProcessKDP::StartAsyncThread() {
+  Log *log(ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PROCESS));
+
+  if (log)
+    log->Printf("ProcessKDP::StartAsyncThread ()");
 
-    if (m_async_thread.IsJoinable())
-        return true;
+  if (m_async_thread.IsJoinable())
+    return true;
 
-    m_async_thread = ThreadLauncher::LaunchThread("<lldb.process.kdp-remote.async>", ProcessKDP::AsyncThread, this, NULL);
-    return m_async_thread.IsJoinable();
+  m_async_thread = ThreadLauncher::LaunchThread(
+      "<lldb.process.kdp-remote.async>", ProcessKDP::AsyncThread, this, NULL);
+  return m_async_thread.IsJoinable();
 }
 
-void
-ProcessKDP::StopAsyncThread ()
-{
-    Log *log (ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PROCESS));
-    
-    if (log)
-        log->Printf ("ProcessKDP::StopAsyncThread ()");
-    
-    m_async_broadcaster.BroadcastEvent (eBroadcastBitAsyncThreadShouldExit);
-    
-    // Stop the stdio thread
-    if (m_async_thread.IsJoinable())
-        m_async_thread.Join(nullptr);
+void ProcessKDP::StopAsyncThread() {
+  Log *log(ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PROCESS));
+
+  if (log)
+    log->Printf("ProcessKDP::StopAsyncThread ()");
+
+  m_async_broadcaster.BroadcastEvent(eBroadcastBitAsyncThreadShouldExit);
+
+  // Stop the stdio thread
+  if (m_async_thread.IsJoinable())
+    m_async_thread.Join(nullptr);
 }
 
+void *ProcessKDP::AsyncThread(void *arg) {
+  ProcessKDP *process = (ProcessKDP *)arg;
 
-void *
-ProcessKDP::AsyncThread (void *arg)
-{
-    ProcessKDP *process = (ProcessKDP*) arg;
-    
-    const lldb::pid_t pid = process->GetID();
+  const lldb::pid_t pid = process->GetID();
 
-    Log *log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PROCESS));
-    if (log)
-        log->Printf ("ProcessKDP::AsyncThread (arg = %p, pid = %" PRIu64 ") thread starting...", arg, pid);
-    
-    ListenerSP listener_sp (Listener::MakeListener("ProcessKDP::AsyncThread"));
-    EventSP event_sp;
-    const uint32_t desired_event_mask = eBroadcastBitAsyncContinue |
-                                        eBroadcastBitAsyncThreadShouldExit;
-    
-    
-    if (listener_sp->StartListeningForEvents (&process->m_async_broadcaster, desired_event_mask) == desired_event_mask)
-    {
-        bool done = false;
-        while (!done)
-        {
-            if (log)
-                log->Printf ("ProcessKDP::AsyncThread (pid = %" PRIu64 ") listener.WaitForEvent (NULL, event_sp)...",
-                             pid);
-            if (listener_sp->WaitForEvent(std::chrono::microseconds(0), event_sp))
-            {
-                uint32_t event_type = event_sp->GetType();
-                if (log)
-                    log->Printf ("ProcessKDP::AsyncThread (pid = %" PRIu64 ") Got an event of type: %d...",
-                                 pid,
-                                 event_type);
-                
-                // When we are running, poll for 1 second to try and get an exception
-                // to indicate the process has stopped. If we don't get one, check to
-                // make sure no one asked us to exit
-                bool is_running = false;
-                DataExtractor exc_reply_packet;
-                do
-                {
-                    switch (event_type)
-                    {
-                    case eBroadcastBitAsyncContinue:
-                        {
-                            is_running = true;
-                            if (process->m_comm.WaitForPacketWithTimeoutMicroSeconds (exc_reply_packet, 1 * USEC_PER_SEC))
-                            {
-                                ThreadSP thread_sp (process->GetKernelThread());
-                                if (thread_sp)
-                                {
-                                    lldb::RegisterContextSP reg_ctx_sp (thread_sp->GetRegisterContext());
-                                    if (reg_ctx_sp)
-                                        reg_ctx_sp->InvalidateAllRegisters();
-                                    static_cast<ThreadKDP *>(thread_sp.get())->SetStopInfoFrom_KDP_EXCEPTION (exc_reply_packet);
-                                }
-
-                                // TODO: parse the stop reply packet
-                                is_running = false;                                
-                                process->SetPrivateState(eStateStopped);
-                            }
-                            else
-                            {
-                                // Check to see if we are supposed to exit. There is no way to
-                                // interrupt a running kernel, so all we can do is wait for an
-                                // exception or detach...
-                                if (listener_sp->GetNextEvent(event_sp))
-                                {
-                                    // We got an event, go through the loop again
-                                    event_type = event_sp->GetType();
-                                }
-                            }
-                        }
-                        break;
-                            
-                    case eBroadcastBitAsyncThreadShouldExit:
-                        if (log)
-                            log->Printf ("ProcessKDP::AsyncThread (pid = %" PRIu64 ") got eBroadcastBitAsyncThreadShouldExit...",
-                                         pid);
-                        done = true;
-                        is_running = false;
-                        break;
-                            
-                    default:
-                        if (log)
-                            log->Printf ("ProcessKDP::AsyncThread (pid = %" PRIu64 ") got unknown event 0x%8.8x",
-                                         pid,
-                                         event_type);
-                        done = true;
-                        is_running = false;
-                        break;
-                    }
-                } while (is_running);
-            }
-            else
-            {
-                if (log)
-                    log->Printf ("ProcessKDP::AsyncThread (pid = %" PRIu64 ") listener.WaitForEvent (NULL, event_sp) => false",
-                                 pid);
-                done = true;
+  Log *log(ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PROCESS));
+  if (log)
+    log->Printf("ProcessKDP::AsyncThread (arg = %p, pid = %" PRIu64
+                ") thread starting...",
+                arg, pid);
+
+  ListenerSP listener_sp(Listener::MakeListener("ProcessKDP::AsyncThread"));
+  EventSP event_sp;
+  const uint32_t desired_event_mask =
+      eBroadcastBitAsyncContinue | eBroadcastBitAsyncThreadShouldExit;
+
+  if (listener_sp->StartListeningForEvents(&process->m_async_broadcaster,
+                                           desired_event_mask) ==
+      desired_event_mask) {
+    bool done = false;
+    while (!done) {
+      if (log)
+        log->Printf("ProcessKDP::AsyncThread (pid = %" PRIu64
+                    ") listener.WaitForEvent (NULL, event_sp)...",
+                    pid);
+      if (listener_sp->WaitForEvent(std::chrono::microseconds(0), event_sp)) {
+        uint32_t event_type = event_sp->GetType();
+        if (log)
+          log->Printf("ProcessKDP::AsyncThread (pid = %" PRIu64
+                      ") Got an event of type: %d...",
+                      pid, event_type);
+
+        // When we are running, poll for 1 second to try and get an exception
+        // to indicate the process has stopped. If we don't get one, check to
+        // make sure no one asked us to exit
+        bool is_running = false;
+        DataExtractor exc_reply_packet;
+        do {
+          switch (event_type) {
+          case eBroadcastBitAsyncContinue: {
+            is_running = true;
+            if (process->m_comm.WaitForPacketWithTimeoutMicroSeconds(
+                    exc_reply_packet, 1 * USEC_PER_SEC)) {
+              ThreadSP thread_sp(process->GetKernelThread());
+              if (thread_sp) {
+                lldb::RegisterContextSP reg_ctx_sp(
+                    thread_sp->GetRegisterContext());
+                if (reg_ctx_sp)
+                  reg_ctx_sp->InvalidateAllRegisters();
+                static_cast<ThreadKDP *>(thread_sp.get())
+                    ->SetStopInfoFrom_KDP_EXCEPTION(exc_reply_packet);
+              }
+
+              // TODO: parse the stop reply packet
+              is_running = false;
+              process->SetPrivateState(eStateStopped);
+            } else {
+              // Check to see if we are supposed to exit. There is no way to
+              // interrupt a running kernel, so all we can do is wait for an
+              // exception or detach...
+              if (listener_sp->GetNextEvent(event_sp)) {
+                // We got an event, go through the loop again
+                event_type = event_sp->GetType();
+              }
             }
-        }
+          } break;
+
+          case eBroadcastBitAsyncThreadShouldExit:
+            if (log)
+              log->Printf("ProcessKDP::AsyncThread (pid = %" PRIu64
+                          ") got eBroadcastBitAsyncThreadShouldExit...",
+                          pid);
+            done = true;
+            is_running = false;
+            break;
+
+          default:
+            if (log)
+              log->Printf("ProcessKDP::AsyncThread (pid = %" PRIu64
+                          ") got unknown event 0x%8.8x",
+                          pid, event_type);
+            done = true;
+            is_running = false;
+            break;
+          }
+        } while (is_running);
+      } else {
+        if (log)
+          log->Printf("ProcessKDP::AsyncThread (pid = %" PRIu64
+                      ") listener.WaitForEvent (NULL, event_sp) => false",
+                      pid);
+        done = true;
+      }
     }
-    
-    if (log)
-        log->Printf ("ProcessKDP::AsyncThread (arg = %p, pid = %" PRIu64 ") thread exiting...",
-                     arg,
-                     pid);
+  }
 
-    process->m_async_thread.Reset();
-    return NULL;
-}
+  if (log)
+    log->Printf("ProcessKDP::AsyncThread (arg = %p, pid = %" PRIu64
+                ") thread exiting...",
+                arg, pid);
 
+  process->m_async_thread.Reset();
+  return NULL;
+}
 
-class CommandObjectProcessKDPPacketSend : public CommandObjectParsed
-{
+class CommandObjectProcessKDPPacketSend : public CommandObjectParsed {
 private:
-    
-    OptionGroupOptions m_option_group;
-    OptionGroupUInt64 m_command_byte;
-    OptionGroupString m_packet_data;
-    
-    virtual Options *
-    GetOptions ()
-    {
-        return &m_option_group;
-    }
-    
+  OptionGroupOptions m_option_group;
+  OptionGroupUInt64 m_command_byte;
+  OptionGroupString m_packet_data;
+
+  virtual Options *GetOptions() { return &m_option_group; }
 
 public:
-    CommandObjectProcessKDPPacketSend(CommandInterpreter &interpreter) :
-        CommandObjectParsed (interpreter,
-                             "process plugin packet send",
-                             "Send a custom packet through the KDP protocol by specifying the command byte and the packet payload data. A packet will be sent with a correct header and payload, and the raw result bytes will be displayed as a string value. ",
-                             NULL),
+  CommandObjectProcessKDPPacketSend(CommandInterpreter &interpreter)
+      : CommandObjectParsed(interpreter, "process plugin packet send",
+                            "Send a custom packet through the KDP protocol by "
+                            "specifying the command byte and the packet "
+                            "payload data. A packet will be sent with a "
+                            "correct header and payload, and the raw result "
+                            "bytes will be displayed as a string value. ",
+                            NULL),
         m_option_group(),
-        m_command_byte(LLDB_OPT_SET_1, true , "command", 'c', 0, eArgTypeNone, "Specify the command byte to use when sending the KDP request packet.", 0),
-        m_packet_data (LLDB_OPT_SET_1, false, "payload", 'p', 0, eArgTypeNone, "Specify packet payload bytes as a hex ASCII string with no spaces or hex prefixes.", NULL)
-    {
-        m_option_group.Append (&m_command_byte, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
-        m_option_group.Append (&m_packet_data , LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
-        m_option_group.Finalize();
-    }
-    
-    ~CommandObjectProcessKDPPacketSend ()
-    {
-    }
-    
-    bool
-    DoExecute (Args& command, CommandReturnObject &result)
-    {
-        const size_t argc = command.GetArgumentCount();
-        if (argc == 0)
-        {
-            if (!m_command_byte.GetOptionValue().OptionWasSet())
-            {
-                result.AppendError ("the --command option must be set to a valid command byte");
-                result.SetStatus (eReturnStatusFailed);
-            }
-            else
-            {
-                const uint64_t command_byte = m_command_byte.GetOptionValue().GetUInt64Value(0);
-                if (command_byte > 0 && command_byte <= UINT8_MAX)
-                {
-                    ProcessKDP *process = (ProcessKDP *)m_interpreter.GetExecutionContext().GetProcessPtr();
-                    if (process)
-                    {
-                        const StateType state = process->GetState();
-                        
-                        if (StateIsStoppedState (state, true))
-                        {
-                            std::vector<uint8_t> payload_bytes;
-                            const char *ascii_hex_bytes_cstr = m_packet_data.GetOptionValue().GetCurrentValue();
-                            if (ascii_hex_bytes_cstr && ascii_hex_bytes_cstr[0])
-                            {
-                                StringExtractor extractor(ascii_hex_bytes_cstr);
-                                const size_t ascii_hex_bytes_cstr_len = extractor.GetStringRef().size();
-                                if (ascii_hex_bytes_cstr_len & 1)
-                                {
-                                    result.AppendErrorWithFormat ("payload data must contain an even number of ASCII hex characters: '%s'", ascii_hex_bytes_cstr);
-                                    result.SetStatus (eReturnStatusFailed);
-                                    return false;
-                                }
-                                payload_bytes.resize(ascii_hex_bytes_cstr_len/2);
-                                if (extractor.GetHexBytes(payload_bytes, '\xdd') != payload_bytes.size())
-                                {
-                                    result.AppendErrorWithFormat ("payload data must only contain ASCII hex characters (no spaces or hex prefixes): '%s'", ascii_hex_bytes_cstr);
-                                    result.SetStatus (eReturnStatusFailed);
-                                    return false;
-                                }
-                            }
-                            Error error;
-                            DataExtractor reply;
-                            process->GetCommunication().SendRawRequest (command_byte,
-                                                                        payload_bytes.empty() ? NULL : payload_bytes.data(),
-                                                                        payload_bytes.size(),
-                                                                        reply,
-                                                                        error);
-                            
-                            if (error.Success())
-                            {
-                                // Copy the binary bytes into a hex ASCII string for the result
-                                StreamString packet;
-                                packet.PutBytesAsRawHex8(reply.GetDataStart(),
-                                                         reply.GetByteSize(),
-                                                         endian::InlHostByteOrder(),
-                                                         endian::InlHostByteOrder());
-                                result.AppendMessage(packet.GetString().c_str());
-                                result.SetStatus (eReturnStatusSuccessFinishResult);
-                                return true;
-                            }
-                            else
-                            {
-                                const char *error_cstr = error.AsCString();
-                                if (error_cstr && error_cstr[0])
-                                    result.AppendError (error_cstr);
-                                else
-                                    result.AppendErrorWithFormat ("unknown error 0x%8.8x", error.GetError());
-                                result.SetStatus (eReturnStatusFailed);
-                                return false;
-                            }
-                        }
-                        else
-                        {
-                            result.AppendErrorWithFormat ("process must be stopped in order to send KDP packets, state is %s", StateAsCString (state));
-                            result.SetStatus (eReturnStatusFailed);
-                        }
-                    }
-                    else
-                    {
-                        result.AppendError ("invalid process");
-                        result.SetStatus (eReturnStatusFailed);
-                    }
+        m_command_byte(LLDB_OPT_SET_1, true, "command", 'c', 0, eArgTypeNone,
+                       "Specify the command byte to use when sending the KDP "
+                       "request packet.",
+                       0),
+        m_packet_data(LLDB_OPT_SET_1, false, "payload", 'p', 0, eArgTypeNone,
+                      "Specify packet payload bytes as a hex ASCII string with "
+                      "no spaces or hex prefixes.",
+                      NULL) {
+    m_option_group.Append(&m_command_byte, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
+    m_option_group.Append(&m_packet_data, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
+    m_option_group.Finalize();
+  }
+
+  ~CommandObjectProcessKDPPacketSend() {}
+
+  bool DoExecute(Args &command, CommandReturnObject &result) {
+    const size_t argc = command.GetArgumentCount();
+    if (argc == 0) {
+      if (!m_command_byte.GetOptionValue().OptionWasSet()) {
+        result.AppendError(
+            "the --command option must be set to a valid command byte");
+        result.SetStatus(eReturnStatusFailed);
+      } else {
+        const uint64_t command_byte =
+            m_command_byte.GetOptionValue().GetUInt64Value(0);
+        if (command_byte > 0 && command_byte <= UINT8_MAX) {
+          ProcessKDP *process =
+              (ProcessKDP *)m_interpreter.GetExecutionContext().GetProcessPtr();
+          if (process) {
+            const StateType state = process->GetState();
+
+            if (StateIsStoppedState(state, true)) {
+              std::vector<uint8_t> payload_bytes;
+              const char *ascii_hex_bytes_cstr =
+                  m_packet_data.GetOptionValue().GetCurrentValue();
+              if (ascii_hex_bytes_cstr && ascii_hex_bytes_cstr[0]) {
+                StringExtractor extractor(ascii_hex_bytes_cstr);
+                const size_t ascii_hex_bytes_cstr_len =
+                    extractor.GetStringRef().size();
+                if (ascii_hex_bytes_cstr_len & 1) {
+                  result.AppendErrorWithFormat("payload data must contain an "
+                                               "even number of ASCII hex "
+                                               "characters: '%s'",
+                                               ascii_hex_bytes_cstr);
+                  result.SetStatus(eReturnStatusFailed);
+                  return false;
                 }
-                else
-                {
-                    result.AppendErrorWithFormat ("invalid command byte 0x%" PRIx64 ", valid values are 1 - 255", command_byte);
-                    result.SetStatus (eReturnStatusFailed);
+                payload_bytes.resize(ascii_hex_bytes_cstr_len / 2);
+                if (extractor.GetHexBytes(payload_bytes, '\xdd') !=
+                    payload_bytes.size()) {
+                  result.AppendErrorWithFormat("payload data must only contain "
+                                               "ASCII hex characters (no "
+                                               "spaces or hex prefixes): '%s'",
+                                               ascii_hex_bytes_cstr);
+                  result.SetStatus(eReturnStatusFailed);
+                  return false;
                 }
+              }
+              Error error;
+              DataExtractor reply;
+              process->GetCommunication().SendRawRequest(
+                  command_byte,
+                  payload_bytes.empty() ? NULL : payload_bytes.data(),
+                  payload_bytes.size(), reply, error);
+
+              if (error.Success()) {
+                // Copy the binary bytes into a hex ASCII string for the result
+                StreamString packet;
+                packet.PutBytesAsRawHex8(
+                    reply.GetDataStart(), reply.GetByteSize(),
+                    endian::InlHostByteOrder(), endian::InlHostByteOrder());
+                result.AppendMessage(packet.GetString().c_str());
+                result.SetStatus(eReturnStatusSuccessFinishResult);
+                return true;
+              } else {
+                const char *error_cstr = error.AsCString();
+                if (error_cstr && error_cstr[0])
+                  result.AppendError(error_cstr);
+                else
+                  result.AppendErrorWithFormat("unknown error 0x%8.8x",
+                                               error.GetError());
+                result.SetStatus(eReturnStatusFailed);
+                return false;
+              }
+            } else {
+              result.AppendErrorWithFormat("process must be stopped in order "
+                                           "to send KDP packets, state is %s",
+                                           StateAsCString(state));
+              result.SetStatus(eReturnStatusFailed);
             }
+          } else {
+            result.AppendError("invalid process");
+            result.SetStatus(eReturnStatusFailed);
+          }
+        } else {
+          result.AppendErrorWithFormat("invalid command byte 0x%" PRIx64
+                                       ", valid values are 1 - 255",
+                                       command_byte);
+          result.SetStatus(eReturnStatusFailed);
         }
-        else
-        {
-            result.AppendErrorWithFormat ("'%s' takes no arguments, only options.", m_cmd_name.c_str());
-            result.SetStatus (eReturnStatusFailed);
-        }
-        return false;
+      }
+    } else {
+      result.AppendErrorWithFormat("'%s' takes no arguments, only options.",
+                                   m_cmd_name.c_str());
+      result.SetStatus(eReturnStatusFailed);
     }
+    return false;
+  }
 };
 
-class CommandObjectProcessKDPPacket : public CommandObjectMultiword
-{
+class CommandObjectProcessKDPPacket : public CommandObjectMultiword {
 private:
-
 public:
-    CommandObjectProcessKDPPacket(CommandInterpreter &interpreter) :
-    CommandObjectMultiword (interpreter,
-                            "process plugin packet",
-                            "Commands that deal with KDP remote packets.",
-                            NULL)
-    {
-        LoadSubCommand ("send", CommandObjectSP (new CommandObjectProcessKDPPacketSend (interpreter)));
-    }
-    
-    ~CommandObjectProcessKDPPacket ()
-    {
-    }
+  CommandObjectProcessKDPPacket(CommandInterpreter &interpreter)
+      : CommandObjectMultiword(interpreter, "process plugin packet",
+                               "Commands that deal with KDP remote packets.",
+                               NULL) {
+    LoadSubCommand(
+        "send",
+        CommandObjectSP(new CommandObjectProcessKDPPacketSend(interpreter)));
+  }
+
+  ~CommandObjectProcessKDPPacket() {}
 };
 
-class CommandObjectMultiwordProcessKDP : public CommandObjectMultiword
-{
+class CommandObjectMultiwordProcessKDP : public CommandObjectMultiword {
 public:
-    CommandObjectMultiwordProcessKDP(CommandInterpreter &interpreter)
-        : CommandObjectMultiword(interpreter, "process plugin", "Commands for operating on a ProcessKDP process.",
-                                 "process plugin <subcommand> [<subcommand-options>]")
-    {
-        LoadSubCommand ("packet", CommandObjectSP (new CommandObjectProcessKDPPacket    (interpreter)));
-    }
-    
-    ~CommandObjectMultiwordProcessKDP ()
-    {
-    }
+  CommandObjectMultiwordProcessKDP(CommandInterpreter &interpreter)
+      : CommandObjectMultiword(
+            interpreter, "process plugin",
+            "Commands for operating on a ProcessKDP process.",
+            "process plugin <subcommand> [<subcommand-options>]") {
+    LoadSubCommand("packet", CommandObjectSP(new CommandObjectProcessKDPPacket(
+                                 interpreter)));
+  }
+
+  ~CommandObjectMultiwordProcessKDP() {}
 };
 
-CommandObject *
-ProcessKDP::GetPluginCommandObject()
-{
-    if (!m_command_sp)
-        m_command_sp.reset (new CommandObjectMultiwordProcessKDP (GetTarget().GetDebugger().GetCommandInterpreter()));
-    return m_command_sp.get();
+CommandObject *ProcessKDP::GetPluginCommandObject() {
+  if (!m_command_sp)
+    m_command_sp.reset(new CommandObjectMultiwordProcessKDP(
+        GetTarget().GetDebugger().GetCommandInterpreter()));
+  return m_command_sp.get();
 }
-

Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h Tue Sep  6 15:57:50 2016
@@ -32,243 +32,192 @@
 
 class ThreadKDP;
 
-class ProcessKDP : public lldb_private::Process
-{
+class ProcessKDP : public lldb_private::Process {
 public:
-    //------------------------------------------------------------------
-    // Constructors and Destructors
-    //------------------------------------------------------------------
-    static lldb::ProcessSP
-    CreateInstance (lldb::TargetSP target_sp,
-                    lldb::ListenerSP listener_sp,
-                    const lldb_private::FileSpec *crash_file_path);
-    
-    static void
-    Initialize();
-    
-    static void
-    DebuggerInitialize (lldb_private::Debugger &debugger);
-
-    static void
-    Terminate();
-    
-    static lldb_private::ConstString
-    GetPluginNameStatic();
-    
-    static const char *
-    GetPluginDescriptionStatic();
-    
-    //------------------------------------------------------------------
-    // Constructors and Destructors
-    //------------------------------------------------------------------
-    ProcessKDP(lldb::TargetSP target_sp, lldb::ListenerSP listener);
-    
-    virtual
-    ~ProcessKDP();
-    
-    //------------------------------------------------------------------
-    // Check if a given Process
-    //------------------------------------------------------------------
-    virtual bool
-    CanDebug (lldb::TargetSP target_sp,
-              bool plugin_specified_by_name);
-    
-    virtual lldb_private::CommandObject *
-    GetPluginCommandObject();
-    
-    //------------------------------------------------------------------
-    // Creating a new process, or attaching to an existing one
-    //------------------------------------------------------------------
-    virtual lldb_private::Error
-    WillLaunch (lldb_private::Module* module);
-    
-    virtual lldb_private::Error
-    DoLaunch (lldb_private::Module *exe_module, 
-              lldb_private::ProcessLaunchInfo &launch_info);
-    
-    virtual lldb_private::Error
-    WillAttachToProcessWithID (lldb::pid_t pid);
-    
-    virtual lldb_private::Error
-    WillAttachToProcessWithName (const char *process_name, bool wait_for_launch);
-    
-    virtual lldb_private::Error
-    DoConnectRemote (lldb_private::Stream *strm, const char *remote_url);
-    
-    virtual lldb_private::Error
-    DoAttachToProcessWithID (lldb::pid_t pid, const lldb_private::ProcessAttachInfo &attach_info);
-    
-    virtual lldb_private::Error
-    DoAttachToProcessWithName (const char *process_name, const lldb_private::ProcessAttachInfo &attach_info);
-    
-    virtual void
-    DidAttach (lldb_private::ArchSpec &process_arch);
-    
-    lldb::addr_t
-    GetImageInfoAddress();
-
-    lldb_private::DynamicLoader *
-    GetDynamicLoader ();
-
-    //------------------------------------------------------------------
-    // PluginInterface protocol
-    //------------------------------------------------------------------
-    virtual lldb_private::ConstString
-    GetPluginName();
-    
-    virtual uint32_t
-    GetPluginVersion();
-    
-    //------------------------------------------------------------------
-    // Process Control
-    //------------------------------------------------------------------
-    virtual lldb_private::Error
-    WillResume ();
-    
-    virtual lldb_private::Error
-    DoResume ();
-    
-    virtual lldb_private::Error
-    DoHalt (bool &caused_stop);
-    
-    virtual lldb_private::Error
-    DoDetach (bool keep_stopped);
-    
-    virtual lldb_private::Error
-    DoSignal (int signal);
-    
-    virtual lldb_private::Error
-    DoDestroy ();
-    
-    virtual void
-    RefreshStateAfterStop();
-    
-    //------------------------------------------------------------------
-    // Process Queries
-    //------------------------------------------------------------------
-    virtual bool
-    IsAlive ();
-    
-    //------------------------------------------------------------------
-    // Process Memory
-    //------------------------------------------------------------------
-    virtual size_t
-    DoReadMemory (lldb::addr_t addr, void *buf, size_t size, lldb_private::Error &error);
-    
-    virtual size_t
-    DoWriteMemory (lldb::addr_t addr, const void *buf, size_t size, lldb_private::Error &error);
-    
-    virtual lldb::addr_t
-    DoAllocateMemory (size_t size, uint32_t permissions, lldb_private::Error &error);
-    
-    virtual lldb_private::Error
-    DoDeallocateMemory (lldb::addr_t ptr);
-
-    //----------------------------------------------------------------------
-    // Process Breakpoints
-    //----------------------------------------------------------------------
-    virtual lldb_private::Error
-    EnableBreakpointSite (lldb_private::BreakpointSite *bp_site);
-    
-    virtual lldb_private::Error
-    DisableBreakpointSite (lldb_private::BreakpointSite *bp_site);
-    
-    //----------------------------------------------------------------------
-    // Process Watchpoints
-    //----------------------------------------------------------------------
-    virtual lldb_private::Error
-    EnableWatchpoint (lldb_private::Watchpoint *wp, bool notify = true);
-    
-    virtual lldb_private::Error
-    DisableWatchpoint (lldb_private::Watchpoint *wp, bool notify = true);
-    
-    CommunicationKDP &
-    GetCommunication()
-    {
-        return m_comm;
-    }
+  //------------------------------------------------------------------
+  // Constructors and Destructors
+  //------------------------------------------------------------------
+  static lldb::ProcessSP
+  CreateInstance(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
+                 const lldb_private::FileSpec *crash_file_path);
+
+  static void Initialize();
+
+  static void DebuggerInitialize(lldb_private::Debugger &debugger);
+
+  static void Terminate();
+
+  static lldb_private::ConstString GetPluginNameStatic();
+
+  static const char *GetPluginDescriptionStatic();
+
+  //------------------------------------------------------------------
+  // Constructors and Destructors
+  //------------------------------------------------------------------
+  ProcessKDP(lldb::TargetSP target_sp, lldb::ListenerSP listener);
+
+  virtual ~ProcessKDP();
+
+  //------------------------------------------------------------------
+  // Check if a given Process
+  //------------------------------------------------------------------
+  virtual bool CanDebug(lldb::TargetSP target_sp,
+                        bool plugin_specified_by_name);
+
+  virtual lldb_private::CommandObject *GetPluginCommandObject();
+
+  //------------------------------------------------------------------
+  // Creating a new process, or attaching to an existing one
+  //------------------------------------------------------------------
+  virtual lldb_private::Error WillLaunch(lldb_private::Module *module);
+
+  virtual lldb_private::Error
+  DoLaunch(lldb_private::Module *exe_module,
+           lldb_private::ProcessLaunchInfo &launch_info);
+
+  virtual lldb_private::Error WillAttachToProcessWithID(lldb::pid_t pid);
+
+  virtual lldb_private::Error
+  WillAttachToProcessWithName(const char *process_name, bool wait_for_launch);
+
+  virtual lldb_private::Error DoConnectRemote(lldb_private::Stream *strm,
+                                              const char *remote_url);
+
+  virtual lldb_private::Error
+  DoAttachToProcessWithID(lldb::pid_t pid,
+                          const lldb_private::ProcessAttachInfo &attach_info);
+
+  virtual lldb_private::Error
+  DoAttachToProcessWithName(const char *process_name,
+                            const lldb_private::ProcessAttachInfo &attach_info);
+
+  virtual void DidAttach(lldb_private::ArchSpec &process_arch);
+
+  lldb::addr_t GetImageInfoAddress();
+
+  lldb_private::DynamicLoader *GetDynamicLoader();
+
+  //------------------------------------------------------------------
+  // PluginInterface protocol
+  //------------------------------------------------------------------
+  virtual lldb_private::ConstString GetPluginName();
+
+  virtual uint32_t GetPluginVersion();
+
+  //------------------------------------------------------------------
+  // Process Control
+  //------------------------------------------------------------------
+  virtual lldb_private::Error WillResume();
+
+  virtual lldb_private::Error DoResume();
+
+  virtual lldb_private::Error DoHalt(bool &caused_stop);
+
+  virtual lldb_private::Error DoDetach(bool keep_stopped);
+
+  virtual lldb_private::Error DoSignal(int signal);
+
+  virtual lldb_private::Error DoDestroy();
+
+  virtual void RefreshStateAfterStop();
+
+  //------------------------------------------------------------------
+  // Process Queries
+  //------------------------------------------------------------------
+  virtual bool IsAlive();
+
+  //------------------------------------------------------------------
+  // Process Memory
+  //------------------------------------------------------------------
+  virtual size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
+                              lldb_private::Error &error);
+
+  virtual size_t DoWriteMemory(lldb::addr_t addr, const void *buf, size_t size,
+                               lldb_private::Error &error);
+
+  virtual lldb::addr_t DoAllocateMemory(size_t size, uint32_t permissions,
+                                        lldb_private::Error &error);
+
+  virtual lldb_private::Error DoDeallocateMemory(lldb::addr_t ptr);
+
+  //----------------------------------------------------------------------
+  // Process Breakpoints
+  //----------------------------------------------------------------------
+  virtual lldb_private::Error
+  EnableBreakpointSite(lldb_private::BreakpointSite *bp_site);
+
+  virtual lldb_private::Error
+  DisableBreakpointSite(lldb_private::BreakpointSite *bp_site);
+
+  //----------------------------------------------------------------------
+  // Process Watchpoints
+  //----------------------------------------------------------------------
+  virtual lldb_private::Error EnableWatchpoint(lldb_private::Watchpoint *wp,
+                                               bool notify = true);
+
+  virtual lldb_private::Error DisableWatchpoint(lldb_private::Watchpoint *wp,
+                                                bool notify = true);
+
+  CommunicationKDP &GetCommunication() { return m_comm; }
 
 protected:
-    friend class ThreadKDP;
-    friend class CommunicationKDP;
-    
-    //----------------------------------------------------------------------
-    // Accessors
-    //----------------------------------------------------------------------
-    bool
-    IsRunning ( lldb::StateType state )
-    {
-        return    state == lldb::eStateRunning || IsStepping(state);
-    }
-    
-    bool
-    IsStepping ( lldb::StateType state)
-    {
-        return    state == lldb::eStateStepping;
-    }
-
-    bool
-    CanResume ( lldb::StateType state)
-    {
-        return state == lldb::eStateStopped;
-    }
-    
-    bool
-    HasExited (lldb::StateType state)
-    {
-        return state == lldb::eStateExited;
-    }
-
-    bool
-    GetHostArchitecture (lldb_private::ArchSpec &arch);
-
-    bool
-    ProcessIDIsValid ( ) const;
-    
-    void
-    Clear ( );
-    
-    virtual bool
-    UpdateThreadList (lldb_private::ThreadList &old_thread_list, 
-                      lldb_private::ThreadList &new_thread_list);
-    
-    enum
-    {
-        eBroadcastBitAsyncContinue                  = (1 << 0),
-        eBroadcastBitAsyncThreadShouldExit          = (1 << 1)
-    };
-    
-    lldb::ThreadSP
-    GetKernelThread ();
-
-    //------------------------------------------------------------------
-    /// Broadcaster event bits definitions.
-    //------------------------------------------------------------------
-    CommunicationKDP m_comm;
-    lldb_private::Broadcaster m_async_broadcaster;
-    lldb_private::HostThread m_async_thread;
-    lldb_private::ConstString m_dyld_plugin_name;
-    lldb::addr_t m_kernel_load_addr;
-    lldb::CommandObjectSP m_command_sp;
-    lldb::ThreadWP m_kernel_thread_wp;
-
-
-    bool
-    StartAsyncThread ();
-    
-    void
-    StopAsyncThread ();
-    
-    static void *
-    AsyncThread (void *arg);
-    
+  friend class ThreadKDP;
+  friend class CommunicationKDP;
+
+  //----------------------------------------------------------------------
+  // Accessors
+  //----------------------------------------------------------------------
+  bool IsRunning(lldb::StateType state) {
+    return state == lldb::eStateRunning || IsStepping(state);
+  }
+
+  bool IsStepping(lldb::StateType state) {
+    return state == lldb::eStateStepping;
+  }
+
+  bool CanResume(lldb::StateType state) { return state == lldb::eStateStopped; }
+
+  bool HasExited(lldb::StateType state) { return state == lldb::eStateExited; }
+
+  bool GetHostArchitecture(lldb_private::ArchSpec &arch);
+
+  bool ProcessIDIsValid() const;
+
+  void Clear();
+
+  virtual bool UpdateThreadList(lldb_private::ThreadList &old_thread_list,
+                                lldb_private::ThreadList &new_thread_list);
+
+  enum {
+    eBroadcastBitAsyncContinue = (1 << 0),
+    eBroadcastBitAsyncThreadShouldExit = (1 << 1)
+  };
+
+  lldb::ThreadSP GetKernelThread();
+
+  //------------------------------------------------------------------
+  /// Broadcaster event bits definitions.
+  //------------------------------------------------------------------
+  CommunicationKDP m_comm;
+  lldb_private::Broadcaster m_async_broadcaster;
+  lldb_private::HostThread m_async_thread;
+  lldb_private::ConstString m_dyld_plugin_name;
+  lldb::addr_t m_kernel_load_addr;
+  lldb::CommandObjectSP m_command_sp;
+  lldb::ThreadWP m_kernel_thread_wp;
+
+  bool StartAsyncThread();
+
+  void StopAsyncThread();
+
+  static void *AsyncThread(void *arg);
+
 private:
-    //------------------------------------------------------------------
-    // For ProcessKDP only
-    //------------------------------------------------------------------
-    
-    DISALLOW_COPY_AND_ASSIGN (ProcessKDP);
-    
+  //------------------------------------------------------------------
+  // For ProcessKDP only
+  //------------------------------------------------------------------
+
+  DISALLOW_COPY_AND_ASSIGN(ProcessKDP);
 };
 
-#endif  // liblldb_ProcessKDP_h_
+#endif // liblldb_ProcessKDP_h_

Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp Tue Sep  6 15:57:50 2016
@@ -9,178 +9,184 @@
 
 #include "ProcessKDPLog.h"
 
-#include "lldb/Interpreter/Args.h"
 #include "lldb/Core/StreamFile.h"
+#include "lldb/Interpreter/Args.h"
 
 #include "ProcessKDP.h"
 
 using namespace lldb;
 using namespace lldb_private;
 
-
 // We want to avoid global constructors where code needs to be run so here we
 // control access to our static g_log_sp by hiding it in a singleton function
-// that will construct the static g_log_sp the first time this function is 
+// that will construct the static g_log_sp the first time this function is
 // called.
 static bool g_log_enabled = false;
-static Log * g_log = NULL;
-static Log *
-GetLog ()
-{
-    if (!g_log_enabled)
-        return NULL;
-    return g_log;
-}
-
-Log *
-ProcessKDPLog::GetLogIfAllCategoriesSet (uint32_t mask)
-{
-    Log *log(GetLog ());
-    if (log && mask)
-    {
-        uint32_t log_mask = log->GetMask().Get();
-        if ((log_mask & mask) != mask)
-            return NULL;
-    }
-    return log;
-}
+static Log *g_log = NULL;
+static Log *GetLog() {
+  if (!g_log_enabled)
+    return NULL;
+  return g_log;
+}
+
+Log *ProcessKDPLog::GetLogIfAllCategoriesSet(uint32_t mask) {
+  Log *log(GetLog());
+  if (log && mask) {
+    uint32_t log_mask = log->GetMask().Get();
+    if ((log_mask & mask) != mask)
+      return NULL;
+  }
+  return log;
+}
+
+void ProcessKDPLog::DisableLog(const char **categories, Stream *feedback_strm) {
+  Log *log(GetLog());
+  if (log) {
+    uint32_t flag_bits = 0;
 
-void
-ProcessKDPLog::DisableLog (const char **categories, Stream *feedback_strm)
-{
-    Log *log (GetLog ());
-    if (log)
-    {
-        uint32_t flag_bits = 0;
-        
-        if (categories[0] != NULL)
-        {
-            flag_bits = log->GetMask().Get();
-            for (size_t i = 0; categories[i] != NULL; ++i)
-            {
-                const char *arg = categories[i];
-                
-
-                if      (::strcasecmp (arg, "all")        == 0 ) flag_bits &= ~KDP_LOG_ALL;
-                else if (::strcasecmp (arg, "async")      == 0 ) flag_bits &= ~KDP_LOG_ASYNC;
-                else if (::strncasecmp (arg, "break", 5)  == 0 ) flag_bits &= ~KDP_LOG_BREAKPOINTS;
-                else if (::strncasecmp (arg, "comm", 4)   == 0 ) flag_bits &= ~KDP_LOG_COMM;
-                else if (::strcasecmp (arg, "default")    == 0 ) flag_bits &= ~KDP_LOG_DEFAULT;
-                else if (::strcasecmp (arg, "packets")    == 0 ) flag_bits &= ~KDP_LOG_PACKETS;
-                else if (::strcasecmp (arg, "memory")     == 0 ) flag_bits &= ~KDP_LOG_MEMORY;
-                else if (::strcasecmp (arg, "data-short") == 0 ) flag_bits &= ~KDP_LOG_MEMORY_DATA_SHORT;
-                else if (::strcasecmp (arg, "data-long")  == 0 ) flag_bits &= ~KDP_LOG_MEMORY_DATA_LONG;
-                else if (::strcasecmp (arg, "process")    == 0 ) flag_bits &= ~KDP_LOG_PROCESS;
-                else if (::strcasecmp (arg, "step")       == 0 ) flag_bits &= ~KDP_LOG_STEP;
-                else if (::strcasecmp (arg, "thread")     == 0 ) flag_bits &= ~KDP_LOG_THREAD;
-                else if (::strcasecmp (arg, "verbose")    == 0 ) flag_bits &= ~KDP_LOG_VERBOSE;
-                else if (::strncasecmp (arg, "watch", 5)  == 0 ) flag_bits &= ~KDP_LOG_WATCHPOINTS;
-                else
-                {
-                    feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
-                    ListLogCategories (feedback_strm);
-                }
-                
-            }
+    if (categories[0] != NULL) {
+      flag_bits = log->GetMask().Get();
+      for (size_t i = 0; categories[i] != NULL; ++i) {
+        const char *arg = categories[i];
+
+        if (::strcasecmp(arg, "all") == 0)
+          flag_bits &= ~KDP_LOG_ALL;
+        else if (::strcasecmp(arg, "async") == 0)
+          flag_bits &= ~KDP_LOG_ASYNC;
+        else if (::strncasecmp(arg, "break", 5) == 0)
+          flag_bits &= ~KDP_LOG_BREAKPOINTS;
+        else if (::strncasecmp(arg, "comm", 4) == 0)
+          flag_bits &= ~KDP_LOG_COMM;
+        else if (::strcasecmp(arg, "default") == 0)
+          flag_bits &= ~KDP_LOG_DEFAULT;
+        else if (::strcasecmp(arg, "packets") == 0)
+          flag_bits &= ~KDP_LOG_PACKETS;
+        else if (::strcasecmp(arg, "memory") == 0)
+          flag_bits &= ~KDP_LOG_MEMORY;
+        else if (::strcasecmp(arg, "data-short") == 0)
+          flag_bits &= ~KDP_LOG_MEMORY_DATA_SHORT;
+        else if (::strcasecmp(arg, "data-long") == 0)
+          flag_bits &= ~KDP_LOG_MEMORY_DATA_LONG;
+        else if (::strcasecmp(arg, "process") == 0)
+          flag_bits &= ~KDP_LOG_PROCESS;
+        else if (::strcasecmp(arg, "step") == 0)
+          flag_bits &= ~KDP_LOG_STEP;
+        else if (::strcasecmp(arg, "thread") == 0)
+          flag_bits &= ~KDP_LOG_THREAD;
+        else if (::strcasecmp(arg, "verbose") == 0)
+          flag_bits &= ~KDP_LOG_VERBOSE;
+        else if (::strncasecmp(arg, "watch", 5) == 0)
+          flag_bits &= ~KDP_LOG_WATCHPOINTS;
+        else {
+          feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
+          ListLogCategories(feedback_strm);
         }
-        
-        log->GetMask().Reset (flag_bits);
-        if (flag_bits == 0)
-            g_log_enabled = false;
+      }
     }
-    
-    return;
-}
 
-Log *
-ProcessKDPLog::EnableLog (StreamSP &log_stream_sp, uint32_t log_options, const char **categories, Stream *feedback_strm)
-{
-    // Try see if there already is a log - that way we can reuse its settings.
-    // We could reuse the log in toto, but we don't know that the stream is the same.
-    uint32_t flag_bits = 0;
-    if (g_log)
-        flag_bits = g_log->GetMask().Get();
-
-    // Now make a new log with this stream if one was provided
-    if (log_stream_sp)
-    {
-        if (g_log)
-            g_log->SetStream(log_stream_sp);
-        else
-            g_log = new Log(log_stream_sp);
-    }
+    log->GetMask().Reset(flag_bits);
+    if (flag_bits == 0)
+      g_log_enabled = false;
+  }
+
+  return;
+}
+
+Log *ProcessKDPLog::EnableLog(StreamSP &log_stream_sp, uint32_t log_options,
+                              const char **categories, Stream *feedback_strm) {
+  // Try see if there already is a log - that way we can reuse its settings.
+  // We could reuse the log in toto, but we don't know that the stream is the
+  // same.
+  uint32_t flag_bits = 0;
+  if (g_log)
+    flag_bits = g_log->GetMask().Get();
 
+  // Now make a new log with this stream if one was provided
+  if (log_stream_sp) {
     if (g_log)
-    {
-        bool got_unknown_category = false;
-        for (size_t i=0; categories[i] != NULL; ++i)
-        {
-            const char *arg = categories[i];
-
-            if      (::strcasecmp (arg, "all")        == 0 ) flag_bits |= KDP_LOG_ALL;
-            else if (::strcasecmp (arg, "async")      == 0 ) flag_bits |= KDP_LOG_ASYNC;
-            else if (::strncasecmp (arg, "break", 5)  == 0 ) flag_bits |= KDP_LOG_BREAKPOINTS;
-            else if (::strncasecmp (arg, "comm", 4)   == 0 ) flag_bits |= KDP_LOG_COMM;
-            else if (::strcasecmp (arg, "default")    == 0 ) flag_bits |= KDP_LOG_DEFAULT;
-            else if (::strcasecmp (arg, "packets")    == 0 ) flag_bits |= KDP_LOG_PACKETS;
-            else if (::strcasecmp (arg, "memory")     == 0 ) flag_bits |= KDP_LOG_MEMORY;
-            else if (::strcasecmp (arg, "data-short") == 0 ) flag_bits |= KDP_LOG_MEMORY_DATA_SHORT;
-            else if (::strcasecmp (arg, "data-long")  == 0 ) flag_bits |= KDP_LOG_MEMORY_DATA_LONG;
-            else if (::strcasecmp (arg, "process")    == 0 ) flag_bits |= KDP_LOG_PROCESS;
-            else if (::strcasecmp (arg, "step")       == 0 ) flag_bits |= KDP_LOG_STEP;
-            else if (::strcasecmp (arg, "thread")     == 0 ) flag_bits |= KDP_LOG_THREAD;
-            else if (::strcasecmp (arg, "verbose")    == 0 ) flag_bits |= KDP_LOG_VERBOSE;
-            else if (::strncasecmp (arg, "watch", 5)  == 0 ) flag_bits |= KDP_LOG_WATCHPOINTS;
-            else
-            {
-                feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
-                if (got_unknown_category == false)
-                {
-                    got_unknown_category = true;
-                    ListLogCategories (feedback_strm);
-                }
-            }
+      g_log->SetStream(log_stream_sp);
+    else
+      g_log = new Log(log_stream_sp);
+  }
+
+  if (g_log) {
+    bool got_unknown_category = false;
+    for (size_t i = 0; categories[i] != NULL; ++i) {
+      const char *arg = categories[i];
+
+      if (::strcasecmp(arg, "all") == 0)
+        flag_bits |= KDP_LOG_ALL;
+      else if (::strcasecmp(arg, "async") == 0)
+        flag_bits |= KDP_LOG_ASYNC;
+      else if (::strncasecmp(arg, "break", 5) == 0)
+        flag_bits |= KDP_LOG_BREAKPOINTS;
+      else if (::strncasecmp(arg, "comm", 4) == 0)
+        flag_bits |= KDP_LOG_COMM;
+      else if (::strcasecmp(arg, "default") == 0)
+        flag_bits |= KDP_LOG_DEFAULT;
+      else if (::strcasecmp(arg, "packets") == 0)
+        flag_bits |= KDP_LOG_PACKETS;
+      else if (::strcasecmp(arg, "memory") == 0)
+        flag_bits |= KDP_LOG_MEMORY;
+      else if (::strcasecmp(arg, "data-short") == 0)
+        flag_bits |= KDP_LOG_MEMORY_DATA_SHORT;
+      else if (::strcasecmp(arg, "data-long") == 0)
+        flag_bits |= KDP_LOG_MEMORY_DATA_LONG;
+      else if (::strcasecmp(arg, "process") == 0)
+        flag_bits |= KDP_LOG_PROCESS;
+      else if (::strcasecmp(arg, "step") == 0)
+        flag_bits |= KDP_LOG_STEP;
+      else if (::strcasecmp(arg, "thread") == 0)
+        flag_bits |= KDP_LOG_THREAD;
+      else if (::strcasecmp(arg, "verbose") == 0)
+        flag_bits |= KDP_LOG_VERBOSE;
+      else if (::strncasecmp(arg, "watch", 5) == 0)
+        flag_bits |= KDP_LOG_WATCHPOINTS;
+      else {
+        feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
+        if (got_unknown_category == false) {
+          got_unknown_category = true;
+          ListLogCategories(feedback_strm);
         }
-        if (flag_bits == 0)
-            flag_bits = KDP_LOG_DEFAULT;
-        g_log->GetMask().Reset(flag_bits);
-        g_log->GetOptions().Reset(log_options);
-    }
-    g_log_enabled = true;
-    return g_log;
-}
-
-void
-ProcessKDPLog::ListLogCategories (Stream *strm)
-{
-    strm->Printf ("Logging categories for '%s':\n"
-                  "  all - turn on all available logging categories\n"
-                  "  async - log asynchronous activity\n"
-                  "  break - log breakpoints\n"
-                  "  communication - log communication activity\n"
-                  "  default - enable the default set of logging categories for liblldb\n"
-                  "  packets - log gdb remote packets\n"
-                  "  memory - log memory reads and writes\n"
-                  "  data-short - log memory bytes for memory reads and writes for short transactions only\n"
-                  "  data-long - log memory bytes for memory reads and writes for all transactions\n"
-                  "  process - log process events and activities\n"
-                  "  thread - log thread events and activities\n"
-                  "  step - log step related activities\n"
-                  "  verbose - enable verbose logging\n"
-                  "  watch - log watchpoint related activities\n",
-                  ProcessKDP::GetPluginNameStatic().GetCString());
-}
-
-
-void
-ProcessKDPLog::LogIf (uint32_t mask, const char *format, ...)
-{
-    Log *log (ProcessKDPLog::GetLogIfAllCategoriesSet (mask));
-    if (log)
-    {
-        va_list args;
-        va_start (args, format);
-        log->VAPrintf (format, args);
-        va_end (args);
+      }
     }
+    if (flag_bits == 0)
+      flag_bits = KDP_LOG_DEFAULT;
+    g_log->GetMask().Reset(flag_bits);
+    g_log->GetOptions().Reset(log_options);
+  }
+  g_log_enabled = true;
+  return g_log;
+}
+
+void ProcessKDPLog::ListLogCategories(Stream *strm) {
+  strm->Printf(
+      "Logging categories for '%s':\n"
+      "  all - turn on all available logging categories\n"
+      "  async - log asynchronous activity\n"
+      "  break - log breakpoints\n"
+      "  communication - log communication activity\n"
+      "  default - enable the default set of logging categories for liblldb\n"
+      "  packets - log gdb remote packets\n"
+      "  memory - log memory reads and writes\n"
+      "  data-short - log memory bytes for memory reads and writes for short "
+      "transactions only\n"
+      "  data-long - log memory bytes for memory reads and writes for all "
+      "transactions\n"
+      "  process - log process events and activities\n"
+      "  thread - log thread events and activities\n"
+      "  step - log step related activities\n"
+      "  verbose - enable verbose logging\n"
+      "  watch - log watchpoint related activities\n",
+      ProcessKDP::GetPluginNameStatic().GetCString());
+}
+
+void ProcessKDPLog::LogIf(uint32_t mask, const char *format, ...) {
+  Log *log(ProcessKDPLog::GetLogIfAllCategoriesSet(mask));
+  if (log) {
+    va_list args;
+    va_start(args, format);
+    log->VAPrintf(format, args);
+    va_end(args);
+  }
 }

Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.h (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.h Tue Sep  6 15:57:50 2016
@@ -17,38 +17,37 @@
 // Project includes
 #include "lldb/Core/Log.h"
 
-#define KDP_LOG_VERBOSE                  (1u << 0)
-#define KDP_LOG_PROCESS                  (1u << 1)
-#define KDP_LOG_THREAD                   (1u << 2)
-#define KDP_LOG_PACKETS                  (1u << 3)
-#define KDP_LOG_MEMORY                   (1u << 4)    // Log memory reads/writes calls
-#define KDP_LOG_MEMORY_DATA_SHORT        (1u << 5)    // Log short memory reads/writes bytes
-#define KDP_LOG_MEMORY_DATA_LONG         (1u << 6)    // Log all memory reads/writes bytes
-#define KDP_LOG_BREAKPOINTS              (1u << 7)
-#define KDP_LOG_WATCHPOINTS              (1u << 8)
-#define KDP_LOG_STEP                     (1u << 9)
-#define KDP_LOG_COMM                     (1u << 10)
-#define KDP_LOG_ASYNC                    (1u << 11)
-#define KDP_LOG_ALL                      (UINT32_MAX)
-#define KDP_LOG_DEFAULT                  KDP_LOG_PACKETS
+#define KDP_LOG_VERBOSE (1u << 0)
+#define KDP_LOG_PROCESS (1u << 1)
+#define KDP_LOG_THREAD (1u << 2)
+#define KDP_LOG_PACKETS (1u << 3)
+#define KDP_LOG_MEMORY (1u << 4) // Log memory reads/writes calls
+#define KDP_LOG_MEMORY_DATA_SHORT                                              \
+  (1u << 5) // Log short memory reads/writes bytes
+#define KDP_LOG_MEMORY_DATA_LONG (1u << 6) // Log all memory reads/writes bytes
+#define KDP_LOG_BREAKPOINTS (1u << 7)
+#define KDP_LOG_WATCHPOINTS (1u << 8)
+#define KDP_LOG_STEP (1u << 9)
+#define KDP_LOG_COMM (1u << 10)
+#define KDP_LOG_ASYNC (1u << 11)
+#define KDP_LOG_ALL (UINT32_MAX)
+#define KDP_LOG_DEFAULT KDP_LOG_PACKETS
 
-class ProcessKDPLog
-{
+class ProcessKDPLog {
 public:
-    static lldb_private::Log *
-    GetLogIfAllCategoriesSet(uint32_t mask = 0);
+  static lldb_private::Log *GetLogIfAllCategoriesSet(uint32_t mask = 0);
 
-    static void
-    DisableLog (const char **categories, lldb_private::Stream *feedback_strm);
+  static void DisableLog(const char **categories,
+                         lldb_private::Stream *feedback_strm);
 
-    static lldb_private::Log *
-    EnableLog (lldb::StreamSP &log_stream_sp, uint32_t log_options, const char **categories, lldb_private::Stream *feedback_strm);
+  static lldb_private::Log *EnableLog(lldb::StreamSP &log_stream_sp,
+                                      uint32_t log_options,
+                                      const char **categories,
+                                      lldb_private::Stream *feedback_strm);
 
-    static void
-    ListLogCategories (lldb_private::Stream *strm);
+  static void ListLogCategories(lldb_private::Stream *strm);
 
-    static void
-    LogIf (uint32_t mask, const char *format, ...);
+  static void LogIf(uint32_t mask, const char *format, ...);
 };
 
-#endif  // liblldb_ProcessKDPLog_h_
+#endif // liblldb_ProcessKDPLog_h_

Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm.cpp Tue Sep  6 15:57:50 2016
@@ -19,143 +19,133 @@
 using namespace lldb;
 using namespace lldb_private;
 
-
-RegisterContextKDP_arm::RegisterContextKDP_arm (ThreadKDP &thread, uint32_t concrete_frame_idx) :
-    RegisterContextDarwin_arm (thread, concrete_frame_idx),
-    m_kdp_thread (thread)
-{
-}
-
-RegisterContextKDP_arm::~RegisterContextKDP_arm()
-{
-}
-
-int
-RegisterContextKDP_arm::DoReadGPR (lldb::tid_t tid, int flavor, GPR &gpr)
-{
-    ProcessSP process_sp (CalculateProcess());
-    if (process_sp)
-    {
-        Error error;
-        if (static_cast<ProcessKDP *>(process_sp.get())->GetCommunication().SendRequestReadRegisters (tid, GPRRegSet, &gpr, sizeof(gpr), error))
-        {
-            if (error.Success())
-                return 0;
-        }
-    }
-    return -1;
-}
-
-int
-RegisterContextKDP_arm::DoReadFPU (lldb::tid_t tid, int flavor, FPU &fpu)
-{
-    ProcessSP process_sp (CalculateProcess());
-    if (process_sp)
-    {
-        Error error;
-        if (static_cast<ProcessKDP *>(process_sp.get())->GetCommunication().SendRequestReadRegisters (tid, FPURegSet, &fpu, sizeof(fpu), error))
-        {
-            if (error.Success())
-                return 0;
-        }
-    }
-    return -1;
-}
-
-int
-RegisterContextKDP_arm::DoReadEXC (lldb::tid_t tid, int flavor, EXC &exc)
-{
-    ProcessSP process_sp (CalculateProcess());
-    if (process_sp)
-    {
-        Error error;
-        if (static_cast<ProcessKDP *>(process_sp.get())->GetCommunication().SendRequestReadRegisters (tid, EXCRegSet, &exc, sizeof(exc), error))
-        {
-            if (error.Success())
-                return 0;
-        }
-    }
-    return -1;
-}
-
-int
-RegisterContextKDP_arm::DoReadDBG (lldb::tid_t tid, int flavor, DBG &dbg)
-{
-    ProcessSP process_sp (CalculateProcess());
-    if (process_sp)
-    {
-        Error error;
-        if (static_cast<ProcessKDP *>(process_sp.get())->GetCommunication().SendRequestReadRegisters (tid, DBGRegSet, &dbg, sizeof(dbg), error))
-        {
-            if (error.Success())
-                return 0;
-        }
-    }
-    return -1;
-}
-
-int
-RegisterContextKDP_arm::DoWriteGPR (lldb::tid_t tid, int flavor, const GPR &gpr)
-{
-    ProcessSP process_sp (CalculateProcess());
-    if (process_sp)
-    {
-        Error error;
-        if (static_cast<ProcessKDP *>(process_sp.get())->GetCommunication().SendRequestWriteRegisters (tid, GPRRegSet, &gpr, sizeof(gpr), error))
-        {
-            if (error.Success())
-                return 0;
-        }
-    }
-    return -1;
-}
-
-int
-RegisterContextKDP_arm::DoWriteFPU (lldb::tid_t tid, int flavor, const FPU &fpu)
-{
-    ProcessSP process_sp (CalculateProcess());
-    if (process_sp)
-    {
-        Error error;
-        if (static_cast<ProcessKDP *>(process_sp.get())->GetCommunication().SendRequestWriteRegisters (tid, FPURegSet, &fpu, sizeof(fpu), error))
-        {
-            if (error.Success())
-                return 0;
-        }
-    }
-    return -1;
-}
-
-int
-RegisterContextKDP_arm::DoWriteEXC (lldb::tid_t tid, int flavor, const EXC &exc)
-{
-    ProcessSP process_sp (CalculateProcess());
-    if (process_sp)
-    {
-        Error error;
-        if (static_cast<ProcessKDP *>(process_sp.get())->GetCommunication().SendRequestWriteRegisters (tid, EXCRegSet, &exc, sizeof(exc), error))
-        {
-            if (error.Success())
-                return 0;
-        }
-    }
-    return -1;
-}
-
-int
-RegisterContextKDP_arm::DoWriteDBG (lldb::tid_t tid, int flavor, const DBG &dbg)
-{
-    ProcessSP process_sp (CalculateProcess());
-    if (process_sp)
-    {
-        Error error;
-        if (static_cast<ProcessKDP *>(process_sp.get())->GetCommunication().SendRequestWriteRegisters (tid, DBGRegSet, &dbg, sizeof(dbg), error))
-        {
-            if (error.Success())
-                return 0;
-        }
+RegisterContextKDP_arm::RegisterContextKDP_arm(ThreadKDP &thread,
+                                               uint32_t concrete_frame_idx)
+    : RegisterContextDarwin_arm(thread, concrete_frame_idx),
+      m_kdp_thread(thread) {}
+
+RegisterContextKDP_arm::~RegisterContextKDP_arm() {}
+
+int RegisterContextKDP_arm::DoReadGPR(lldb::tid_t tid, int flavor, GPR &gpr) {
+  ProcessSP process_sp(CalculateProcess());
+  if (process_sp) {
+    Error error;
+    if (static_cast<ProcessKDP *>(process_sp.get())
+            ->GetCommunication()
+            .SendRequestReadRegisters(tid, GPRRegSet, &gpr, sizeof(gpr),
+                                      error)) {
+      if (error.Success())
+        return 0;
+    }
+  }
+  return -1;
+}
+
+int RegisterContextKDP_arm::DoReadFPU(lldb::tid_t tid, int flavor, FPU &fpu) {
+  ProcessSP process_sp(CalculateProcess());
+  if (process_sp) {
+    Error error;
+    if (static_cast<ProcessKDP *>(process_sp.get())
+            ->GetCommunication()
+            .SendRequestReadRegisters(tid, FPURegSet, &fpu, sizeof(fpu),
+                                      error)) {
+      if (error.Success())
+        return 0;
+    }
+  }
+  return -1;
+}
+
+int RegisterContextKDP_arm::DoReadEXC(lldb::tid_t tid, int flavor, EXC &exc) {
+  ProcessSP process_sp(CalculateProcess());
+  if (process_sp) {
+    Error error;
+    if (static_cast<ProcessKDP *>(process_sp.get())
+            ->GetCommunication()
+            .SendRequestReadRegisters(tid, EXCRegSet, &exc, sizeof(exc),
+                                      error)) {
+      if (error.Success())
+        return 0;
+    }
+  }
+  return -1;
+}
+
+int RegisterContextKDP_arm::DoReadDBG(lldb::tid_t tid, int flavor, DBG &dbg) {
+  ProcessSP process_sp(CalculateProcess());
+  if (process_sp) {
+    Error error;
+    if (static_cast<ProcessKDP *>(process_sp.get())
+            ->GetCommunication()
+            .SendRequestReadRegisters(tid, DBGRegSet, &dbg, sizeof(dbg),
+                                      error)) {
+      if (error.Success())
+        return 0;
+    }
+  }
+  return -1;
+}
+
+int RegisterContextKDP_arm::DoWriteGPR(lldb::tid_t tid, int flavor,
+                                       const GPR &gpr) {
+  ProcessSP process_sp(CalculateProcess());
+  if (process_sp) {
+    Error error;
+    if (static_cast<ProcessKDP *>(process_sp.get())
+            ->GetCommunication()
+            .SendRequestWriteRegisters(tid, GPRRegSet, &gpr, sizeof(gpr),
+                                       error)) {
+      if (error.Success())
+        return 0;
+    }
+  }
+  return -1;
+}
+
+int RegisterContextKDP_arm::DoWriteFPU(lldb::tid_t tid, int flavor,
+                                       const FPU &fpu) {
+  ProcessSP process_sp(CalculateProcess());
+  if (process_sp) {
+    Error error;
+    if (static_cast<ProcessKDP *>(process_sp.get())
+            ->GetCommunication()
+            .SendRequestWriteRegisters(tid, FPURegSet, &fpu, sizeof(fpu),
+                                       error)) {
+      if (error.Success())
+        return 0;
+    }
+  }
+  return -1;
+}
+
+int RegisterContextKDP_arm::DoWriteEXC(lldb::tid_t tid, int flavor,
+                                       const EXC &exc) {
+  ProcessSP process_sp(CalculateProcess());
+  if (process_sp) {
+    Error error;
+    if (static_cast<ProcessKDP *>(process_sp.get())
+            ->GetCommunication()
+            .SendRequestWriteRegisters(tid, EXCRegSet, &exc, sizeof(exc),
+                                       error)) {
+      if (error.Success())
+        return 0;
+    }
+  }
+  return -1;
+}
+
+int RegisterContextKDP_arm::DoWriteDBG(lldb::tid_t tid, int flavor,
+                                       const DBG &dbg) {
+  ProcessSP process_sp(CalculateProcess());
+  if (process_sp) {
+    Error error;
+    if (static_cast<ProcessKDP *>(process_sp.get())
+            ->GetCommunication()
+            .SendRequestWriteRegisters(tid, DBGRegSet, &dbg, sizeof(dbg),
+                                       error)) {
+      if (error.Success())
+        return 0;
     }
-    return -1;
+  }
+  return -1;
 }
-
-

Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm.h (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm.h Tue Sep  6 15:57:50 2016
@@ -19,43 +19,30 @@
 
 class ThreadKDP;
 
-class RegisterContextKDP_arm : public RegisterContextDarwin_arm
-{
+class RegisterContextKDP_arm : public RegisterContextDarwin_arm {
 public:
+  RegisterContextKDP_arm(ThreadKDP &thread, uint32_t concrete_frame_idx);
 
-    RegisterContextKDP_arm (ThreadKDP &thread, 
-                            uint32_t concrete_frame_idx);
-
-    virtual
-    ~RegisterContextKDP_arm();
+  virtual ~RegisterContextKDP_arm();
 
 protected:
+  virtual int DoReadGPR(lldb::tid_t tid, int flavor, GPR &gpr);
+
+  int DoReadFPU(lldb::tid_t tid, int flavor, FPU &fpu);
+
+  int DoReadEXC(lldb::tid_t tid, int flavor, EXC &exc);
+
+  int DoReadDBG(lldb::tid_t tid, int flavor, DBG &dbg);
+
+  int DoWriteGPR(lldb::tid_t tid, int flavor, const GPR &gpr);
+
+  int DoWriteFPU(lldb::tid_t tid, int flavor, const FPU &fpu);
+
+  int DoWriteEXC(lldb::tid_t tid, int flavor, const EXC &exc);
+
+  int DoWriteDBG(lldb::tid_t tid, int flavor, const DBG &dbg);
 
-    virtual int
-    DoReadGPR (lldb::tid_t tid, int flavor, GPR &gpr);
-    
-    int
-    DoReadFPU (lldb::tid_t tid, int flavor, FPU &fpu);
-    
-    int
-    DoReadEXC (lldb::tid_t tid, int flavor, EXC &exc);
-    
-    int
-    DoReadDBG (lldb::tid_t tid, int flavor, DBG &dbg);
-    
-    int
-    DoWriteGPR (lldb::tid_t tid, int flavor, const GPR &gpr);
-    
-    int
-    DoWriteFPU (lldb::tid_t tid, int flavor, const FPU &fpu);
-    
-    int
-    DoWriteEXC (lldb::tid_t tid, int flavor, const EXC &exc);
-    
-    int
-    DoWriteDBG (lldb::tid_t tid, int flavor, const DBG &dbg);
-    
-    ThreadKDP &m_kdp_thread;
+  ThreadKDP &m_kdp_thread;
 };
 
-#endif  // liblldb_RegisterContextKDP_arm_h_
+#endif // liblldb_RegisterContextKDP_arm_h_

Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm64.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm64.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm64.cpp Tue Sep  6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- RegisterContextKDP_arm64.cpp ------------------------------*- C++ -*-===//
+//===-- RegisterContextKDP_arm64.cpp ------------------------------*- C++
+//-*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -19,143 +20,133 @@
 using namespace lldb;
 using namespace lldb_private;
 
-
-RegisterContextKDP_arm64::RegisterContextKDP_arm64 (ThreadKDP &thread, uint32_t concrete_frame_idx) :
-    RegisterContextDarwin_arm64 (thread, concrete_frame_idx),
-    m_kdp_thread (thread)
-{
-}
-
-RegisterContextKDP_arm64::~RegisterContextKDP_arm64()
-{
-}
-
-int
-RegisterContextKDP_arm64::DoReadGPR (lldb::tid_t tid, int flavor, GPR &gpr)
-{
-    ProcessSP process_sp (CalculateProcess());
-    if (process_sp)
-    {
-        Error error;
-        if (static_cast<ProcessKDP *>(process_sp.get())->GetCommunication().SendRequestReadRegisters (tid, GPRRegSet, &gpr, sizeof(gpr), error))
-        {
-            if (error.Success())
-                return 0;
-        }
-    }
-    return -1;
-}
-
-int
-RegisterContextKDP_arm64::DoReadFPU (lldb::tid_t tid, int flavor, FPU &fpu)
-{
-    ProcessSP process_sp (CalculateProcess());
-    if (process_sp)
-    {
-        Error error;
-        if (static_cast<ProcessKDP *>(process_sp.get())->GetCommunication().SendRequestReadRegisters (tid, FPURegSet, &fpu, sizeof(fpu), error))
-        {
-            if (error.Success())
-                return 0;
-        }
-    }
-    return -1;
-}
-
-int
-RegisterContextKDP_arm64::DoReadEXC (lldb::tid_t tid, int flavor, EXC &exc)
-{
-    ProcessSP process_sp (CalculateProcess());
-    if (process_sp)
-    {
-        Error error;
-        if (static_cast<ProcessKDP *>(process_sp.get())->GetCommunication().SendRequestReadRegisters (tid, EXCRegSet, &exc, sizeof(exc), error))
-        {
-            if (error.Success())
-                return 0;
-        }
-    }
-    return -1;
-}
-
-int
-RegisterContextKDP_arm64::DoReadDBG (lldb::tid_t tid, int flavor, DBG &dbg)
-{
-    ProcessSP process_sp (CalculateProcess());
-    if (process_sp)
-    {
-        Error error;
-        if (static_cast<ProcessKDP *>(process_sp.get())->GetCommunication().SendRequestReadRegisters (tid, DBGRegSet, &dbg, sizeof(dbg), error))
-        {
-            if (error.Success())
-                return 0;
-        }
-    }
-    return -1;
-}
-
-int
-RegisterContextKDP_arm64::DoWriteGPR (lldb::tid_t tid, int flavor, const GPR &gpr)
-{
-    ProcessSP process_sp (CalculateProcess());
-    if (process_sp)
-    {
-        Error error;
-        if (static_cast<ProcessKDP *>(process_sp.get())->GetCommunication().SendRequestWriteRegisters (tid, GPRRegSet, &gpr, sizeof(gpr), error))
-        {
-            if (error.Success())
-                return 0;
-        }
-    }
-    return -1;
-}
-
-int
-RegisterContextKDP_arm64::DoWriteFPU (lldb::tid_t tid, int flavor, const FPU &fpu)
-{
-    ProcessSP process_sp (CalculateProcess());
-    if (process_sp)
-    {
-        Error error;
-        if (static_cast<ProcessKDP *>(process_sp.get())->GetCommunication().SendRequestWriteRegisters (tid, FPURegSet, &fpu, sizeof(fpu), error))
-        {
-            if (error.Success())
-                return 0;
-        }
-    }
-    return -1;
-}
-
-int
-RegisterContextKDP_arm64::DoWriteEXC (lldb::tid_t tid, int flavor, const EXC &exc)
-{
-    ProcessSP process_sp (CalculateProcess());
-    if (process_sp)
-    {
-        Error error;
-        if (static_cast<ProcessKDP *>(process_sp.get())->GetCommunication().SendRequestWriteRegisters (tid, EXCRegSet, &exc, sizeof(exc), error))
-        {
-            if (error.Success())
-                return 0;
-        }
-    }
-    return -1;
-}
-
-int
-RegisterContextKDP_arm64::DoWriteDBG (lldb::tid_t tid, int flavor, const DBG &dbg)
-{
-    ProcessSP process_sp (CalculateProcess());
-    if (process_sp)
-    {
-        Error error;
-        if (static_cast<ProcessKDP *>(process_sp.get())->GetCommunication().SendRequestWriteRegisters (tid, DBGRegSet, &dbg, sizeof(dbg), error))
-        {
-            if (error.Success())
-                return 0;
-        }
+RegisterContextKDP_arm64::RegisterContextKDP_arm64(ThreadKDP &thread,
+                                                   uint32_t concrete_frame_idx)
+    : RegisterContextDarwin_arm64(thread, concrete_frame_idx),
+      m_kdp_thread(thread) {}
+
+RegisterContextKDP_arm64::~RegisterContextKDP_arm64() {}
+
+int RegisterContextKDP_arm64::DoReadGPR(lldb::tid_t tid, int flavor, GPR &gpr) {
+  ProcessSP process_sp(CalculateProcess());
+  if (process_sp) {
+    Error error;
+    if (static_cast<ProcessKDP *>(process_sp.get())
+            ->GetCommunication()
+            .SendRequestReadRegisters(tid, GPRRegSet, &gpr, sizeof(gpr),
+                                      error)) {
+      if (error.Success())
+        return 0;
+    }
+  }
+  return -1;
+}
+
+int RegisterContextKDP_arm64::DoReadFPU(lldb::tid_t tid, int flavor, FPU &fpu) {
+  ProcessSP process_sp(CalculateProcess());
+  if (process_sp) {
+    Error error;
+    if (static_cast<ProcessKDP *>(process_sp.get())
+            ->GetCommunication()
+            .SendRequestReadRegisters(tid, FPURegSet, &fpu, sizeof(fpu),
+                                      error)) {
+      if (error.Success())
+        return 0;
+    }
+  }
+  return -1;
+}
+
+int RegisterContextKDP_arm64::DoReadEXC(lldb::tid_t tid, int flavor, EXC &exc) {
+  ProcessSP process_sp(CalculateProcess());
+  if (process_sp) {
+    Error error;
+    if (static_cast<ProcessKDP *>(process_sp.get())
+            ->GetCommunication()
+            .SendRequestReadRegisters(tid, EXCRegSet, &exc, sizeof(exc),
+                                      error)) {
+      if (error.Success())
+        return 0;
+    }
+  }
+  return -1;
+}
+
+int RegisterContextKDP_arm64::DoReadDBG(lldb::tid_t tid, int flavor, DBG &dbg) {
+  ProcessSP process_sp(CalculateProcess());
+  if (process_sp) {
+    Error error;
+    if (static_cast<ProcessKDP *>(process_sp.get())
+            ->GetCommunication()
+            .SendRequestReadRegisters(tid, DBGRegSet, &dbg, sizeof(dbg),
+                                      error)) {
+      if (error.Success())
+        return 0;
+    }
+  }
+  return -1;
+}
+
+int RegisterContextKDP_arm64::DoWriteGPR(lldb::tid_t tid, int flavor,
+                                         const GPR &gpr) {
+  ProcessSP process_sp(CalculateProcess());
+  if (process_sp) {
+    Error error;
+    if (static_cast<ProcessKDP *>(process_sp.get())
+            ->GetCommunication()
+            .SendRequestWriteRegisters(tid, GPRRegSet, &gpr, sizeof(gpr),
+                                       error)) {
+      if (error.Success())
+        return 0;
+    }
+  }
+  return -1;
+}
+
+int RegisterContextKDP_arm64::DoWriteFPU(lldb::tid_t tid, int flavor,
+                                         const FPU &fpu) {
+  ProcessSP process_sp(CalculateProcess());
+  if (process_sp) {
+    Error error;
+    if (static_cast<ProcessKDP *>(process_sp.get())
+            ->GetCommunication()
+            .SendRequestWriteRegisters(tid, FPURegSet, &fpu, sizeof(fpu),
+                                       error)) {
+      if (error.Success())
+        return 0;
+    }
+  }
+  return -1;
+}
+
+int RegisterContextKDP_arm64::DoWriteEXC(lldb::tid_t tid, int flavor,
+                                         const EXC &exc) {
+  ProcessSP process_sp(CalculateProcess());
+  if (process_sp) {
+    Error error;
+    if (static_cast<ProcessKDP *>(process_sp.get())
+            ->GetCommunication()
+            .SendRequestWriteRegisters(tid, EXCRegSet, &exc, sizeof(exc),
+                                       error)) {
+      if (error.Success())
+        return 0;
+    }
+  }
+  return -1;
+}
+
+int RegisterContextKDP_arm64::DoWriteDBG(lldb::tid_t tid, int flavor,
+                                         const DBG &dbg) {
+  ProcessSP process_sp(CalculateProcess());
+  if (process_sp) {
+    Error error;
+    if (static_cast<ProcessKDP *>(process_sp.get())
+            ->GetCommunication()
+            .SendRequestWriteRegisters(tid, DBGRegSet, &dbg, sizeof(dbg),
+                                       error)) {
+      if (error.Success())
+        return 0;
     }
-    return -1;
+  }
+  return -1;
 }
-
-

Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm64.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm64.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm64.h (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm64.h Tue Sep  6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- RegisterContextKDP_arm64.h --------------------------------*- C++ -*-===//
+//===-- RegisterContextKDP_arm64.h --------------------------------*- C++
+//-*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -19,43 +20,30 @@
 
 class ThreadKDP;
 
-class RegisterContextKDP_arm64 : public RegisterContextDarwin_arm64
-{
+class RegisterContextKDP_arm64 : public RegisterContextDarwin_arm64 {
 public:
+  RegisterContextKDP_arm64(ThreadKDP &thread, uint32_t concrete_frame_idx);
 
-    RegisterContextKDP_arm64 (ThreadKDP &thread, 
-                            uint32_t concrete_frame_idx);
-
-    virtual
-    ~RegisterContextKDP_arm64();
+  virtual ~RegisterContextKDP_arm64();
 
 protected:
+  virtual int DoReadGPR(lldb::tid_t tid, int flavor, GPR &gpr);
+
+  int DoReadFPU(lldb::tid_t tid, int flavor, FPU &fpu);
+
+  int DoReadEXC(lldb::tid_t tid, int flavor, EXC &exc);
+
+  int DoReadDBG(lldb::tid_t tid, int flavor, DBG &dbg);
+
+  int DoWriteGPR(lldb::tid_t tid, int flavor, const GPR &gpr);
+
+  int DoWriteFPU(lldb::tid_t tid, int flavor, const FPU &fpu);
+
+  int DoWriteEXC(lldb::tid_t tid, int flavor, const EXC &exc);
+
+  int DoWriteDBG(lldb::tid_t tid, int flavor, const DBG &dbg);
 
-    virtual int
-    DoReadGPR (lldb::tid_t tid, int flavor, GPR &gpr);
-    
-    int
-    DoReadFPU (lldb::tid_t tid, int flavor, FPU &fpu);
-    
-    int
-    DoReadEXC (lldb::tid_t tid, int flavor, EXC &exc);
-    
-    int
-    DoReadDBG (lldb::tid_t tid, int flavor, DBG &dbg);
-    
-    int
-    DoWriteGPR (lldb::tid_t tid, int flavor, const GPR &gpr);
-    
-    int
-    DoWriteFPU (lldb::tid_t tid, int flavor, const FPU &fpu);
-    
-    int
-    DoWriteEXC (lldb::tid_t tid, int flavor, const EXC &exc);
-    
-    int
-    DoWriteDBG (lldb::tid_t tid, int flavor, const DBG &dbg);
-    
-    ThreadKDP &m_kdp_thread;
+  ThreadKDP &m_kdp_thread;
 };
 
-#endif  // liblldb_RegisterContextKDP_arm64_h_
+#endif // liblldb_RegisterContextKDP_arm64_h_

Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.cpp Tue Sep  6 15:57:50 2016
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-
 // C Includes
 // C++ Includes
 // Other libraries and framework includes
@@ -19,111 +18,102 @@
 using namespace lldb;
 using namespace lldb_private;
 
-
-RegisterContextKDP_i386::RegisterContextKDP_i386 (ThreadKDP &thread, uint32_t concrete_frame_idx) :
-    RegisterContextDarwin_i386 (thread, concrete_frame_idx),
-    m_kdp_thread (thread)
-{
-}
-
-RegisterContextKDP_i386::~RegisterContextKDP_i386()
-{
-}
-
-int
-RegisterContextKDP_i386::DoReadGPR (lldb::tid_t tid, int flavor, GPR &gpr)
-{
-    ProcessSP process_sp (CalculateProcess());
-    if (process_sp)
-    {
-        Error error;
-        if (static_cast<ProcessKDP *>(process_sp.get())->GetCommunication().SendRequestReadRegisters (tid, GPRRegSet, &gpr, sizeof(gpr), error))
-        {
-            if (error.Success())
-                return 0;
-        }
-    }
-    return -1;
-}
-
-int
-RegisterContextKDP_i386::DoReadFPU (lldb::tid_t tid, int flavor, FPU &fpu)
-{
-    ProcessSP process_sp (CalculateProcess());
-    if (process_sp)
-    {
-        Error error;
-        if (static_cast<ProcessKDP *>(process_sp.get())->GetCommunication().SendRequestReadRegisters (tid, FPURegSet, &fpu, sizeof(fpu), error))
-        {
-            if (error.Success())
-                return 0;
-        }
-    }
-    return -1;
-}
-
-int
-RegisterContextKDP_i386::DoReadEXC (lldb::tid_t tid, int flavor, EXC &exc)
-{
-    ProcessSP process_sp (CalculateProcess());
-    if (process_sp)
-    {
-        Error error;
-        if (static_cast<ProcessKDP *>(process_sp.get())->GetCommunication().SendRequestReadRegisters (tid, EXCRegSet, &exc, sizeof(exc), error))
-        {
-            if (error.Success())
-                return 0;
-        }
-    }
-    return -1;
-}
-
-int
-RegisterContextKDP_i386::DoWriteGPR (lldb::tid_t tid, int flavor, const GPR &gpr)
-{
-    ProcessSP process_sp (CalculateProcess());
-    if (process_sp)
-    {
-        Error error;
-        if (static_cast<ProcessKDP *>(process_sp.get())->GetCommunication().SendRequestWriteRegisters (tid, GPRRegSet, &gpr, sizeof(gpr), error))
-        {
-            if (error.Success())
-                return 0;
-        }
-    }
-    return -1;
-}
-
-int
-RegisterContextKDP_i386::DoWriteFPU (lldb::tid_t tid, int flavor, const FPU &fpu)
-{
-    ProcessSP process_sp (CalculateProcess());
-    if (process_sp)
-    {
-        Error error;
-        if (static_cast<ProcessKDP *>(process_sp.get())->GetCommunication().SendRequestWriteRegisters (tid, FPURegSet, &fpu, sizeof(fpu), error))
-        {
-            if (error.Success())
-                return 0;
-        }
-    }
-    return -1;
-}
-
-int
-RegisterContextKDP_i386::DoWriteEXC (lldb::tid_t tid, int flavor, const EXC &exc)
-{
-    ProcessSP process_sp (CalculateProcess());
-    if (process_sp)
-    {
-        Error error;
-        if (static_cast<ProcessKDP *>(process_sp.get())->GetCommunication().SendRequestWriteRegisters (tid, EXCRegSet, &exc, sizeof(exc), error))
-        {
-            if (error.Success())
-                return 0;
-        }
+RegisterContextKDP_i386::RegisterContextKDP_i386(ThreadKDP &thread,
+                                                 uint32_t concrete_frame_idx)
+    : RegisterContextDarwin_i386(thread, concrete_frame_idx),
+      m_kdp_thread(thread) {}
+
+RegisterContextKDP_i386::~RegisterContextKDP_i386() {}
+
+int RegisterContextKDP_i386::DoReadGPR(lldb::tid_t tid, int flavor, GPR &gpr) {
+  ProcessSP process_sp(CalculateProcess());
+  if (process_sp) {
+    Error error;
+    if (static_cast<ProcessKDP *>(process_sp.get())
+            ->GetCommunication()
+            .SendRequestReadRegisters(tid, GPRRegSet, &gpr, sizeof(gpr),
+                                      error)) {
+      if (error.Success())
+        return 0;
+    }
+  }
+  return -1;
+}
+
+int RegisterContextKDP_i386::DoReadFPU(lldb::tid_t tid, int flavor, FPU &fpu) {
+  ProcessSP process_sp(CalculateProcess());
+  if (process_sp) {
+    Error error;
+    if (static_cast<ProcessKDP *>(process_sp.get())
+            ->GetCommunication()
+            .SendRequestReadRegisters(tid, FPURegSet, &fpu, sizeof(fpu),
+                                      error)) {
+      if (error.Success())
+        return 0;
+    }
+  }
+  return -1;
+}
+
+int RegisterContextKDP_i386::DoReadEXC(lldb::tid_t tid, int flavor, EXC &exc) {
+  ProcessSP process_sp(CalculateProcess());
+  if (process_sp) {
+    Error error;
+    if (static_cast<ProcessKDP *>(process_sp.get())
+            ->GetCommunication()
+            .SendRequestReadRegisters(tid, EXCRegSet, &exc, sizeof(exc),
+                                      error)) {
+      if (error.Success())
+        return 0;
+    }
+  }
+  return -1;
+}
+
+int RegisterContextKDP_i386::DoWriteGPR(lldb::tid_t tid, int flavor,
+                                        const GPR &gpr) {
+  ProcessSP process_sp(CalculateProcess());
+  if (process_sp) {
+    Error error;
+    if (static_cast<ProcessKDP *>(process_sp.get())
+            ->GetCommunication()
+            .SendRequestWriteRegisters(tid, GPRRegSet, &gpr, sizeof(gpr),
+                                       error)) {
+      if (error.Success())
+        return 0;
+    }
+  }
+  return -1;
+}
+
+int RegisterContextKDP_i386::DoWriteFPU(lldb::tid_t tid, int flavor,
+                                        const FPU &fpu) {
+  ProcessSP process_sp(CalculateProcess());
+  if (process_sp) {
+    Error error;
+    if (static_cast<ProcessKDP *>(process_sp.get())
+            ->GetCommunication()
+            .SendRequestWriteRegisters(tid, FPURegSet, &fpu, sizeof(fpu),
+                                       error)) {
+      if (error.Success())
+        return 0;
+    }
+  }
+  return -1;
+}
+
+int RegisterContextKDP_i386::DoWriteEXC(lldb::tid_t tid, int flavor,
+                                        const EXC &exc) {
+  ProcessSP process_sp(CalculateProcess());
+  if (process_sp) {
+    Error error;
+    if (static_cast<ProcessKDP *>(process_sp.get())
+            ->GetCommunication()
+            .SendRequestWriteRegisters(tid, EXCRegSet, &exc, sizeof(exc),
+                                       error)) {
+      if (error.Success())
+        return 0;
     }
-    return -1;
+  }
+  return -1;
 }
-
-

Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.h (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.h Tue Sep  6 15:57:50 2016
@@ -18,36 +18,26 @@
 
 class ThreadKDP;
 
-class RegisterContextKDP_i386 : public RegisterContextDarwin_i386
-{
+class RegisterContextKDP_i386 : public RegisterContextDarwin_i386 {
 public:
-    RegisterContextKDP_i386 (ThreadKDP &thread, 
-                             uint32_t concrete_frame_idx);
-    
-    virtual
-    ~RegisterContextKDP_i386();
-    
+  RegisterContextKDP_i386(ThreadKDP &thread, uint32_t concrete_frame_idx);
+
+  virtual ~RegisterContextKDP_i386();
+
 protected:
-    
-    virtual int
-    DoReadGPR (lldb::tid_t tid, int flavor, GPR &gpr);
-    
-    int
-    DoReadFPU (lldb::tid_t tid, int flavor, FPU &fpu);
-    
-    int
-    DoReadEXC (lldb::tid_t tid, int flavor, EXC &exc);
-    
-    int
-    DoWriteGPR (lldb::tid_t tid, int flavor, const GPR &gpr);
-    
-    int
-    DoWriteFPU (lldb::tid_t tid, int flavor, const FPU &fpu);
-    
-    int
-    DoWriteEXC (lldb::tid_t tid, int flavor, const EXC &exc);
-    
-    ThreadKDP &m_kdp_thread;
+  virtual int DoReadGPR(lldb::tid_t tid, int flavor, GPR &gpr);
+
+  int DoReadFPU(lldb::tid_t tid, int flavor, FPU &fpu);
+
+  int DoReadEXC(lldb::tid_t tid, int flavor, EXC &exc);
+
+  int DoWriteGPR(lldb::tid_t tid, int flavor, const GPR &gpr);
+
+  int DoWriteFPU(lldb::tid_t tid, int flavor, const FPU &fpu);
+
+  int DoWriteEXC(lldb::tid_t tid, int flavor, const EXC &exc);
+
+  ThreadKDP &m_kdp_thread;
 };
 
-#endif  // liblldb_RegisterContextKDP_i386_h_
+#endif // liblldb_RegisterContextKDP_i386_h_

Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.cpp Tue Sep  6 15:57:50 2016
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-
 // C Includes
 // C++ Includes
 // Other libraries and framework includes
@@ -19,109 +18,105 @@
 using namespace lldb;
 using namespace lldb_private;
 
-
-RegisterContextKDP_x86_64::RegisterContextKDP_x86_64 (ThreadKDP &thread, uint32_t concrete_frame_idx) :
-    RegisterContextDarwin_x86_64 (thread, concrete_frame_idx),
-    m_kdp_thread (thread)
-{
-}
-
-RegisterContextKDP_x86_64::~RegisterContextKDP_x86_64()
-{
-}
-
-int
-RegisterContextKDP_x86_64::DoReadGPR (lldb::tid_t tid, int flavor, GPR &gpr)
-{
-    ProcessSP process_sp (CalculateProcess());
-    if (process_sp)
-    {
-        Error error;
-        if (static_cast<ProcessKDP *>(process_sp.get())->GetCommunication().SendRequestReadRegisters (tid, GPRRegSet, &gpr, sizeof(gpr), error))
-        {
-            if (error.Success())
-                return 0;
-        }
-    }
-    return -1;
-}
-
-int
-RegisterContextKDP_x86_64::DoReadFPU (lldb::tid_t tid, int flavor, FPU &fpu)
-{
-    ProcessSP process_sp (CalculateProcess());
-    if (process_sp)
-    {
-        Error error;
-        if (static_cast<ProcessKDP *>(process_sp.get())->GetCommunication().SendRequestReadRegisters (tid, FPURegSet, &fpu, sizeof(fpu), error))
-        {
-            if (error.Success())
-                return 0;
-        }
-    }
-    return -1;
-}
-
-int
-RegisterContextKDP_x86_64::DoReadEXC (lldb::tid_t tid, int flavor, EXC &exc)
-{
-    ProcessSP process_sp (CalculateProcess());
-    if (process_sp)
-    {
-        Error error;
-        if (static_cast<ProcessKDP *>(process_sp.get())->GetCommunication().SendRequestReadRegisters (tid, EXCRegSet, &exc, sizeof(exc), error))
-        {
-            if (error.Success())
-                return 0;
-        }
-    }
-    return -1;
-}
-
-int
-RegisterContextKDP_x86_64::DoWriteGPR (lldb::tid_t tid, int flavor, const GPR &gpr)
-{
-    ProcessSP process_sp (CalculateProcess());
-    if (process_sp)
-    {
-        Error error;
-        if (static_cast<ProcessKDP *>(process_sp.get())->GetCommunication().SendRequestWriteRegisters (tid, GPRRegSet, &gpr, sizeof(gpr), error))
-        {
-            if (error.Success())
-                return 0;
-        }
-    }
-    return -1;
-}
-
-int
-RegisterContextKDP_x86_64::DoWriteFPU (lldb::tid_t tid, int flavor, const FPU &fpu)
-{
-    ProcessSP process_sp (CalculateProcess());
-    if (process_sp)
-    {
-        Error error;
-        if (static_cast<ProcessKDP *>(process_sp.get())->GetCommunication().SendRequestWriteRegisters (tid, FPURegSet, &fpu, sizeof(fpu), error))
-        {
-            if (error.Success())
-                return 0;
-        }
-    }
-    return -1;
-}
-
-int
-RegisterContextKDP_x86_64::DoWriteEXC (lldb::tid_t tid, int flavor, const EXC &exc)
-{
-    ProcessSP process_sp (CalculateProcess());
-    if (process_sp)
-    {
-        Error error;
-        if (static_cast<ProcessKDP *>(process_sp.get())->GetCommunication().SendRequestWriteRegisters (tid, EXCRegSet, &exc, sizeof(exc), error))
-        {
-            if (error.Success())
-                return 0;
-        }
+RegisterContextKDP_x86_64::RegisterContextKDP_x86_64(
+    ThreadKDP &thread, uint32_t concrete_frame_idx)
+    : RegisterContextDarwin_x86_64(thread, concrete_frame_idx),
+      m_kdp_thread(thread) {}
+
+RegisterContextKDP_x86_64::~RegisterContextKDP_x86_64() {}
+
+int RegisterContextKDP_x86_64::DoReadGPR(lldb::tid_t tid, int flavor,
+                                         GPR &gpr) {
+  ProcessSP process_sp(CalculateProcess());
+  if (process_sp) {
+    Error error;
+    if (static_cast<ProcessKDP *>(process_sp.get())
+            ->GetCommunication()
+            .SendRequestReadRegisters(tid, GPRRegSet, &gpr, sizeof(gpr),
+                                      error)) {
+      if (error.Success())
+        return 0;
+    }
+  }
+  return -1;
+}
+
+int RegisterContextKDP_x86_64::DoReadFPU(lldb::tid_t tid, int flavor,
+                                         FPU &fpu) {
+  ProcessSP process_sp(CalculateProcess());
+  if (process_sp) {
+    Error error;
+    if (static_cast<ProcessKDP *>(process_sp.get())
+            ->GetCommunication()
+            .SendRequestReadRegisters(tid, FPURegSet, &fpu, sizeof(fpu),
+                                      error)) {
+      if (error.Success())
+        return 0;
+    }
+  }
+  return -1;
+}
+
+int RegisterContextKDP_x86_64::DoReadEXC(lldb::tid_t tid, int flavor,
+                                         EXC &exc) {
+  ProcessSP process_sp(CalculateProcess());
+  if (process_sp) {
+    Error error;
+    if (static_cast<ProcessKDP *>(process_sp.get())
+            ->GetCommunication()
+            .SendRequestReadRegisters(tid, EXCRegSet, &exc, sizeof(exc),
+                                      error)) {
+      if (error.Success())
+        return 0;
+    }
+  }
+  return -1;
+}
+
+int RegisterContextKDP_x86_64::DoWriteGPR(lldb::tid_t tid, int flavor,
+                                          const GPR &gpr) {
+  ProcessSP process_sp(CalculateProcess());
+  if (process_sp) {
+    Error error;
+    if (static_cast<ProcessKDP *>(process_sp.get())
+            ->GetCommunication()
+            .SendRequestWriteRegisters(tid, GPRRegSet, &gpr, sizeof(gpr),
+                                       error)) {
+      if (error.Success())
+        return 0;
+    }
+  }
+  return -1;
+}
+
+int RegisterContextKDP_x86_64::DoWriteFPU(lldb::tid_t tid, int flavor,
+                                          const FPU &fpu) {
+  ProcessSP process_sp(CalculateProcess());
+  if (process_sp) {
+    Error error;
+    if (static_cast<ProcessKDP *>(process_sp.get())
+            ->GetCommunication()
+            .SendRequestWriteRegisters(tid, FPURegSet, &fpu, sizeof(fpu),
+                                       error)) {
+      if (error.Success())
+        return 0;
+    }
+  }
+  return -1;
+}
+
+int RegisterContextKDP_x86_64::DoWriteEXC(lldb::tid_t tid, int flavor,
+                                          const EXC &exc) {
+  ProcessSP process_sp(CalculateProcess());
+  if (process_sp) {
+    Error error;
+    if (static_cast<ProcessKDP *>(process_sp.get())
+            ->GetCommunication()
+            .SendRequestWriteRegisters(tid, EXCRegSet, &exc, sizeof(exc),
+                                       error)) {
+      if (error.Success())
+        return 0;
     }
-    return -1;
+  }
+  return -1;
 }

Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.h (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.h Tue Sep  6 15:57:50 2016
@@ -18,37 +18,26 @@
 
 class ThreadKDP;
 
-class RegisterContextKDP_x86_64 : public RegisterContextDarwin_x86_64
-{
+class RegisterContextKDP_x86_64 : public RegisterContextDarwin_x86_64 {
 public:
-    
-    RegisterContextKDP_x86_64 (ThreadKDP &thread, 
-                               uint32_t concrete_frame_idx);
-    
-    virtual
-    ~RegisterContextKDP_x86_64();
-    
+  RegisterContextKDP_x86_64(ThreadKDP &thread, uint32_t concrete_frame_idx);
+
+  virtual ~RegisterContextKDP_x86_64();
+
 protected:
-    
-    virtual int
-    DoReadGPR (lldb::tid_t tid, int flavor, GPR &gpr);
-    
-    int
-    DoReadFPU (lldb::tid_t tid, int flavor, FPU &fpu);
-    
-    int
-    DoReadEXC (lldb::tid_t tid, int flavor, EXC &exc);
-    
-    int
-    DoWriteGPR (lldb::tid_t tid, int flavor, const GPR &gpr);
-    
-    int
-    DoWriteFPU (lldb::tid_t tid, int flavor, const FPU &fpu);
-    
-    int
-    DoWriteEXC (lldb::tid_t tid, int flavor, const EXC &exc);
-    
-    ThreadKDP &m_kdp_thread;
+  virtual int DoReadGPR(lldb::tid_t tid, int flavor, GPR &gpr);
+
+  int DoReadFPU(lldb::tid_t tid, int flavor, FPU &fpu);
+
+  int DoReadEXC(lldb::tid_t tid, int flavor, EXC &exc);
+
+  int DoWriteGPR(lldb::tid_t tid, int flavor, const GPR &gpr);
+
+  int DoWriteFPU(lldb::tid_t tid, int flavor, const FPU &fpu);
+
+  int DoWriteEXC(lldb::tid_t tid, int flavor, const EXC &exc);
+
+  ThreadKDP &m_kdp_thread;
 };
 
-#endif  // liblldb_RegisterContextKDP_x86_64_h_
+#endif // liblldb_RegisterContextKDP_x86_64_h_

Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp Tue Sep  6 15:57:50 2016
@@ -7,29 +7,28 @@
 //
 //===----------------------------------------------------------------------===//
 
-
 #include "ThreadKDP.h"
 
 #include "lldb/Utility/SafeMachO.h"
 
+#include "lldb/Breakpoint/Watchpoint.h"
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/StreamString.h"
 #include "lldb/Core/State.h"
+#include "lldb/Core/StreamString.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/StopInfo.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Target/Unwind.h"
-#include "lldb/Breakpoint/Watchpoint.h"
 
+#include "Plugins/Process/Utility/StopInfoMachException.h"
 #include "ProcessKDP.h"
 #include "ProcessKDPLog.h"
 #include "RegisterContextKDP_arm.h"
 #include "RegisterContextKDP_arm64.h"
 #include "RegisterContextKDP_i386.h"
 #include "RegisterContextKDP_x86_64.h"
-#include "Plugins/Process/Utility/StopInfoMachException.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -38,174 +37,137 @@ using namespace lldb_private;
 // Thread Registers
 //----------------------------------------------------------------------
 
-ThreadKDP::ThreadKDP (Process &process, lldb::tid_t tid) :
-    Thread(process, tid),
-    m_thread_name (),
-    m_dispatch_queue_name (),
-    m_thread_dispatch_qaddr (LLDB_INVALID_ADDRESS)
-{
-    ProcessKDPLog::LogIf(KDP_LOG_THREAD, "%p: ThreadKDP::ThreadKDP (tid = 0x%4.4x)", this, GetID());
-}
-
-ThreadKDP::~ThreadKDP ()
-{
-    ProcessKDPLog::LogIf(KDP_LOG_THREAD, "%p: ThreadKDP::~ThreadKDP (tid = 0x%4.4x)", this, GetID());
-    DestroyThread();
-}
-
-const char *
-ThreadKDP::GetName ()
-{
-    if (m_thread_name.empty())
-        return NULL;
-    return m_thread_name.c_str();
-}
-
-const char *
-ThreadKDP::GetQueueName ()
-{
-    return NULL;
+ThreadKDP::ThreadKDP(Process &process, lldb::tid_t tid)
+    : Thread(process, tid), m_thread_name(), m_dispatch_queue_name(),
+      m_thread_dispatch_qaddr(LLDB_INVALID_ADDRESS) {
+  ProcessKDPLog::LogIf(KDP_LOG_THREAD,
+                       "%p: ThreadKDP::ThreadKDP (tid = 0x%4.4x)", this,
+                       GetID());
+}
+
+ThreadKDP::~ThreadKDP() {
+  ProcessKDPLog::LogIf(KDP_LOG_THREAD,
+                       "%p: ThreadKDP::~ThreadKDP (tid = 0x%4.4x)", this,
+                       GetID());
+  DestroyThread();
 }
 
-void
-ThreadKDP::RefreshStateAfterStop()
-{
-    // Invalidate all registers in our register context. We don't set "force" to
-    // true because the stop reply packet might have had some register values
-    // that were expedited and these will already be copied into the register
-    // context by the time this function gets called. The KDPRegisterContext
-    // class has been made smart enough to detect when it needs to invalidate
-    // which registers are valid by putting hooks in the register read and 
-    // register supply functions where they check the process stop ID and do
-    // the right thing.
-    const bool force = false;
-    lldb::RegisterContextSP reg_ctx_sp (GetRegisterContext());
-    if (reg_ctx_sp)
-        reg_ctx_sp->InvalidateIfNeeded (force);
-}
-
-bool
-ThreadKDP::ThreadIDIsValid (lldb::tid_t thread)
-{
-    return thread != 0;
-}
-
-void
-ThreadKDP::Dump(Log *log, uint32_t index)
-{
+const char *ThreadKDP::GetName() {
+  if (m_thread_name.empty())
+    return NULL;
+  return m_thread_name.c_str();
 }
 
+const char *ThreadKDP::GetQueueName() { return NULL; }
 
-bool
-ThreadKDP::ShouldStop (bool &step_more)
-{
-    return true;
-}
-lldb::RegisterContextSP
-ThreadKDP::GetRegisterContext ()
-{
-    if (m_reg_context_sp.get() == NULL)
-        m_reg_context_sp = CreateRegisterContextForFrame (NULL);
-    return m_reg_context_sp;
+void ThreadKDP::RefreshStateAfterStop() {
+  // Invalidate all registers in our register context. We don't set "force" to
+  // true because the stop reply packet might have had some register values
+  // that were expedited and these will already be copied into the register
+  // context by the time this function gets called. The KDPRegisterContext
+  // class has been made smart enough to detect when it needs to invalidate
+  // which registers are valid by putting hooks in the register read and
+  // register supply functions where they check the process stop ID and do
+  // the right thing.
+  const bool force = false;
+  lldb::RegisterContextSP reg_ctx_sp(GetRegisterContext());
+  if (reg_ctx_sp)
+    reg_ctx_sp->InvalidateIfNeeded(force);
+}
+
+bool ThreadKDP::ThreadIDIsValid(lldb::tid_t thread) { return thread != 0; }
+
+void ThreadKDP::Dump(Log *log, uint32_t index) {}
+
+bool ThreadKDP::ShouldStop(bool &step_more) { return true; }
+lldb::RegisterContextSP ThreadKDP::GetRegisterContext() {
+  if (m_reg_context_sp.get() == NULL)
+    m_reg_context_sp = CreateRegisterContextForFrame(NULL);
+  return m_reg_context_sp;
 }
 
 lldb::RegisterContextSP
-ThreadKDP::CreateRegisterContextForFrame (StackFrame *frame)
-{
-    lldb::RegisterContextSP reg_ctx_sp;
-    uint32_t concrete_frame_idx = 0;
-    
-    if (frame)
-        concrete_frame_idx = frame->GetConcreteFrameIndex ();
-
-    if (concrete_frame_idx == 0)
-    {
-        ProcessSP process_sp (CalculateProcess());
-        if (process_sp)
-        {
-            switch (static_cast<ProcessKDP *>(process_sp.get())->GetCommunication().GetCPUType())
-            {
-                case llvm::MachO::CPU_TYPE_ARM:
-                    reg_ctx_sp.reset (new RegisterContextKDP_arm (*this, concrete_frame_idx));
-                    break;
-                case llvm::MachO::CPU_TYPE_ARM64:
-                    reg_ctx_sp.reset (new RegisterContextKDP_arm64 (*this, concrete_frame_idx));
-                    break;
-                case llvm::MachO::CPU_TYPE_I386:
-                    reg_ctx_sp.reset (new RegisterContextKDP_i386 (*this, concrete_frame_idx));
-                    break;
-                case llvm::MachO::CPU_TYPE_X86_64:
-                    reg_ctx_sp.reset (new RegisterContextKDP_x86_64 (*this, concrete_frame_idx));
-                    break;
-                default:
-                    assert (!"Add CPU type support in KDP");
-                    break;
-            }
-        }
+ThreadKDP::CreateRegisterContextForFrame(StackFrame *frame) {
+  lldb::RegisterContextSP reg_ctx_sp;
+  uint32_t concrete_frame_idx = 0;
+
+  if (frame)
+    concrete_frame_idx = frame->GetConcreteFrameIndex();
+
+  if (concrete_frame_idx == 0) {
+    ProcessSP process_sp(CalculateProcess());
+    if (process_sp) {
+      switch (static_cast<ProcessKDP *>(process_sp.get())
+                  ->GetCommunication()
+                  .GetCPUType()) {
+      case llvm::MachO::CPU_TYPE_ARM:
+        reg_ctx_sp.reset(new RegisterContextKDP_arm(*this, concrete_frame_idx));
+        break;
+      case llvm::MachO::CPU_TYPE_ARM64:
+        reg_ctx_sp.reset(
+            new RegisterContextKDP_arm64(*this, concrete_frame_idx));
+        break;
+      case llvm::MachO::CPU_TYPE_I386:
+        reg_ctx_sp.reset(
+            new RegisterContextKDP_i386(*this, concrete_frame_idx));
+        break;
+      case llvm::MachO::CPU_TYPE_X86_64:
+        reg_ctx_sp.reset(
+            new RegisterContextKDP_x86_64(*this, concrete_frame_idx));
+        break;
+      default:
+        assert(!"Add CPU type support in KDP");
+        break;
+      }
     }
-    else
-    {
-        Unwind *unwinder = GetUnwinder ();
-        if (unwinder)
-            reg_ctx_sp = unwinder->CreateRegisterContextForFrame (frame);
-    }
-    return reg_ctx_sp;
+  } else {
+    Unwind *unwinder = GetUnwinder();
+    if (unwinder)
+      reg_ctx_sp = unwinder->CreateRegisterContextForFrame(frame);
+  }
+  return reg_ctx_sp;
 }
 
-bool
-ThreadKDP::CalculateStopInfo ()
-{
-    ProcessSP process_sp (GetProcess());
-    if (process_sp)
-    {
-        if (m_cached_stop_info_sp)
-        {
-            SetStopInfo (m_cached_stop_info_sp);
-        }
-        else
-        {
-            SetStopInfo(StopInfo::CreateStopReasonWithSignal (*this, SIGSTOP));
-        }
-        return true;
+bool ThreadKDP::CalculateStopInfo() {
+  ProcessSP process_sp(GetProcess());
+  if (process_sp) {
+    if (m_cached_stop_info_sp) {
+      SetStopInfo(m_cached_stop_info_sp);
+    } else {
+      SetStopInfo(StopInfo::CreateStopReasonWithSignal(*this, SIGSTOP));
     }
-    return false;
+    return true;
+  }
+  return false;
 }
 
-void
-ThreadKDP::SetStopInfoFrom_KDP_EXCEPTION (const DataExtractor &exc_reply_packet)
-{
-    lldb::offset_t offset = 0;
-    uint8_t reply_command = exc_reply_packet.GetU8(&offset);
-    if (reply_command == CommunicationKDP::KDP_EXCEPTION)
-    {
-        offset = 8;
-        const uint32_t count = exc_reply_packet.GetU32 (&offset);
-        if (count >= 1)
-        {
-            //const uint32_t cpu = exc_reply_packet.GetU32 (&offset);
-            offset += 4; // Skip the useless CPU field
-            const uint32_t exc_type = exc_reply_packet.GetU32 (&offset);
-            const uint32_t exc_code = exc_reply_packet.GetU32 (&offset);
-            const uint32_t exc_subcode = exc_reply_packet.GetU32 (&offset);
-            // We have to make a copy of the stop info because the thread list
-            // will iterate through the threads and clear all stop infos..
-            
-            // Let the StopInfoMachException::CreateStopReasonWithMachException()
-            // function update the PC if needed as we might hit a software breakpoint
-            // and need to decrement the PC (i386 and x86_64 need this) and KDP
-            // doesn't do this for us.
-            const bool pc_already_adjusted = false;
-            const bool adjust_pc_if_needed = true;
-
-            m_cached_stop_info_sp = StopInfoMachException::CreateStopReasonWithMachException (*this,
-                                                                                              exc_type,
-                                                                                              2,
-                                                                                              exc_code,
-                                                                                              exc_subcode,
-                                                                                              0,
-                                                                                              pc_already_adjusted,
-                                                                                              adjust_pc_if_needed);            
-        }
+void ThreadKDP::SetStopInfoFrom_KDP_EXCEPTION(
+    const DataExtractor &exc_reply_packet) {
+  lldb::offset_t offset = 0;
+  uint8_t reply_command = exc_reply_packet.GetU8(&offset);
+  if (reply_command == CommunicationKDP::KDP_EXCEPTION) {
+    offset = 8;
+    const uint32_t count = exc_reply_packet.GetU32(&offset);
+    if (count >= 1) {
+      // const uint32_t cpu = exc_reply_packet.GetU32 (&offset);
+      offset += 4; // Skip the useless CPU field
+      const uint32_t exc_type = exc_reply_packet.GetU32(&offset);
+      const uint32_t exc_code = exc_reply_packet.GetU32(&offset);
+      const uint32_t exc_subcode = exc_reply_packet.GetU32(&offset);
+      // We have to make a copy of the stop info because the thread list
+      // will iterate through the threads and clear all stop infos..
+
+      // Let the StopInfoMachException::CreateStopReasonWithMachException()
+      // function update the PC if needed as we might hit a software breakpoint
+      // and need to decrement the PC (i386 and x86_64 need this) and KDP
+      // doesn't do this for us.
+      const bool pc_already_adjusted = false;
+      const bool adjust_pc_if_needed = true;
+
+      m_cached_stop_info_sp =
+          StopInfoMachException::CreateStopReasonWithMachException(
+              *this, exc_type, 2, exc_code, exc_subcode, 0, pc_already_adjusted,
+              adjust_pc_if_needed);
     }
+  }
 }
-

Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.h (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.h Tue Sep  6 15:57:50 2016
@@ -17,82 +17,61 @@
 
 class ProcessKDP;
 
-class ThreadKDP : public lldb_private::Thread
-{
+class ThreadKDP : public lldb_private::Thread {
 public:
-    ThreadKDP (lldb_private::Process &process,
-               lldb::tid_t tid);
+  ThreadKDP(lldb_private::Process &process, lldb::tid_t tid);
 
-    virtual
-    ~ThreadKDP ();
+  virtual ~ThreadKDP();
 
-    virtual void
-    RefreshStateAfterStop();
+  virtual void RefreshStateAfterStop();
 
-    virtual const char *
-    GetName ();
-
-    virtual const char *
-    GetQueueName ();
-
-    virtual lldb::RegisterContextSP
-    GetRegisterContext ();
-
-    virtual lldb::RegisterContextSP
-    CreateRegisterContextForFrame (lldb_private::StackFrame *frame);
-
-    void
-    Dump (lldb_private::Log *log, uint32_t index);
-
-    static bool
-    ThreadIDIsValid (lldb::tid_t thread);
-
-    bool
-    ShouldStop (bool &step_more);
-
-    const char *
-    GetBasicInfoAsString ();
-
-    void
-    SetName (const char *name)
-    {
-        if (name && name[0])
-            m_thread_name.assign (name);
-        else
-            m_thread_name.clear();
-    }
-
-    lldb::addr_t
-    GetThreadDispatchQAddr ()
-    {
-        return m_thread_dispatch_qaddr;
-    }
-
-    void
-    SetThreadDispatchQAddr (lldb::addr_t thread_dispatch_qaddr)
-    {
-        m_thread_dispatch_qaddr = thread_dispatch_qaddr;
-    }
-    
-    void
-    SetStopInfoFrom_KDP_EXCEPTION (const lldb_private::DataExtractor &exc_reply_packet);
+  virtual const char *GetName();
+
+  virtual const char *GetQueueName();
+
+  virtual lldb::RegisterContextSP GetRegisterContext();
+
+  virtual lldb::RegisterContextSP
+  CreateRegisterContextForFrame(lldb_private::StackFrame *frame);
+
+  void Dump(lldb_private::Log *log, uint32_t index);
+
+  static bool ThreadIDIsValid(lldb::tid_t thread);
+
+  bool ShouldStop(bool &step_more);
+
+  const char *GetBasicInfoAsString();
+
+  void SetName(const char *name) {
+    if (name && name[0])
+      m_thread_name.assign(name);
+    else
+      m_thread_name.clear();
+  }
+
+  lldb::addr_t GetThreadDispatchQAddr() { return m_thread_dispatch_qaddr; }
+
+  void SetThreadDispatchQAddr(lldb::addr_t thread_dispatch_qaddr) {
+    m_thread_dispatch_qaddr = thread_dispatch_qaddr;
+  }
+
+  void SetStopInfoFrom_KDP_EXCEPTION(
+      const lldb_private::DataExtractor &exc_reply_packet);
 
 protected:
-    
-    friend class ProcessKDP;
+  friend class ProcessKDP;
 
-    //------------------------------------------------------------------
-    // Member variables.
-    //------------------------------------------------------------------
-    std::string m_thread_name;
-    std::string m_dispatch_queue_name;
-    lldb::addr_t m_thread_dispatch_qaddr;
-    lldb::StopInfoSP m_cached_stop_info_sp;
-    //------------------------------------------------------------------
-    // Protected member functions.
-    //------------------------------------------------------------------
-    virtual bool
-    CalculateStopInfo ();
+  //------------------------------------------------------------------
+  // Member variables.
+  //------------------------------------------------------------------
+  std::string m_thread_name;
+  std::string m_dispatch_queue_name;
+  lldb::addr_t m_thread_dispatch_qaddr;
+  lldb::StopInfoSP m_cached_stop_info_sp;
+  //------------------------------------------------------------------
+  // Protected member functions.
+  //------------------------------------------------------------------
+  virtual bool CalculateStopInfo();
 };
 
-#endif  // liblldb_ThreadKDP_h_
+#endif // liblldb_ThreadKDP_h_

Modified: lldb/trunk/source/Plugins/Process/POSIX/CrashReason.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/POSIX/CrashReason.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/POSIX/CrashReason.cpp (original)
+++ lldb/trunk/source/Plugins/Process/POSIX/CrashReason.cpp Tue Sep  6 15:57:50 2016
@@ -13,304 +13,281 @@
 
 namespace {
 
-void
-AppendFaultAddr (std::string& str, lldb::addr_t addr)
-{
-    std::stringstream ss;
-    ss << " (fault address: 0x" << std::hex << addr << ")";
-    str += ss.str();
+void AppendFaultAddr(std::string &str, lldb::addr_t addr) {
+  std::stringstream ss;
+  ss << " (fault address: 0x" << std::hex << addr << ")";
+  str += ss.str();
 }
 
-CrashReason
-GetCrashReasonForSIGSEGV(const siginfo_t& info)
-{
-    assert(info.si_signo == SIGSEGV);
+CrashReason GetCrashReasonForSIGSEGV(const siginfo_t &info) {
+  assert(info.si_signo == SIGSEGV);
 
-    switch (info.si_code)
-    {
+  switch (info.si_code) {
 #ifdef SI_KERNEL
-    case SI_KERNEL:
-        // Some platforms will occasionally send nonstandard spurious SI_KERNEL codes.
-        // One way to get this is via unaligned SIMD loads.
-        return CrashReason::eInvalidAddress; // for lack of anything better
+  case SI_KERNEL:
+    // Some platforms will occasionally send nonstandard spurious SI_KERNEL
+    // codes.
+    // One way to get this is via unaligned SIMD loads.
+    return CrashReason::eInvalidAddress; // for lack of anything better
 #endif
-    case SEGV_MAPERR:
-        return CrashReason::eInvalidAddress;
-    case SEGV_ACCERR:
-        return CrashReason::ePrivilegedAddress;
-    }
+  case SEGV_MAPERR:
+    return CrashReason::eInvalidAddress;
+  case SEGV_ACCERR:
+    return CrashReason::ePrivilegedAddress;
+  }
 
-    assert(false && "unexpected si_code for SIGSEGV");
-    return CrashReason::eInvalidCrashReason;
+  assert(false && "unexpected si_code for SIGSEGV");
+  return CrashReason::eInvalidCrashReason;
 }
 
-CrashReason
-GetCrashReasonForSIGILL(const siginfo_t& info)
-{
-    assert(info.si_signo == SIGILL);
-
-    switch (info.si_code)
-    {
-    case ILL_ILLOPC:
-        return CrashReason::eIllegalOpcode;
-    case ILL_ILLOPN:
-        return CrashReason::eIllegalOperand;
-    case ILL_ILLADR:
-        return CrashReason::eIllegalAddressingMode;
-    case ILL_ILLTRP:
-        return CrashReason::eIllegalTrap;
-    case ILL_PRVOPC:
-        return CrashReason::ePrivilegedOpcode;
-    case ILL_PRVREG:
-        return CrashReason::ePrivilegedRegister;
-    case ILL_COPROC:
-        return CrashReason::eCoprocessorError;
-    case ILL_BADSTK:
-        return CrashReason::eInternalStackError;
-    }
+CrashReason GetCrashReasonForSIGILL(const siginfo_t &info) {
+  assert(info.si_signo == SIGILL);
 
-    assert(false && "unexpected si_code for SIGILL");
-    return CrashReason::eInvalidCrashReason;
+  switch (info.si_code) {
+  case ILL_ILLOPC:
+    return CrashReason::eIllegalOpcode;
+  case ILL_ILLOPN:
+    return CrashReason::eIllegalOperand;
+  case ILL_ILLADR:
+    return CrashReason::eIllegalAddressingMode;
+  case ILL_ILLTRP:
+    return CrashReason::eIllegalTrap;
+  case ILL_PRVOPC:
+    return CrashReason::ePrivilegedOpcode;
+  case ILL_PRVREG:
+    return CrashReason::ePrivilegedRegister;
+  case ILL_COPROC:
+    return CrashReason::eCoprocessorError;
+  case ILL_BADSTK:
+    return CrashReason::eInternalStackError;
+  }
+
+  assert(false && "unexpected si_code for SIGILL");
+  return CrashReason::eInvalidCrashReason;
 }
 
-CrashReason
-GetCrashReasonForSIGFPE(const siginfo_t& info)
-{
-    assert(info.si_signo == SIGFPE);
-
-    switch (info.si_code)
-    {
-    case FPE_INTDIV:
-        return CrashReason::eIntegerDivideByZero;
-    case FPE_INTOVF:
-        return CrashReason::eIntegerOverflow;
-    case FPE_FLTDIV:
-        return CrashReason::eFloatDivideByZero;
-    case FPE_FLTOVF:
-        return CrashReason::eFloatOverflow;
-    case FPE_FLTUND:
-        return CrashReason::eFloatUnderflow;
-    case FPE_FLTRES:
-        return CrashReason::eFloatInexactResult;
-    case FPE_FLTINV:
-        return CrashReason::eFloatInvalidOperation;
-    case FPE_FLTSUB:
-        return CrashReason::eFloatSubscriptRange;
-    }
+CrashReason GetCrashReasonForSIGFPE(const siginfo_t &info) {
+  assert(info.si_signo == SIGFPE);
+
+  switch (info.si_code) {
+  case FPE_INTDIV:
+    return CrashReason::eIntegerDivideByZero;
+  case FPE_INTOVF:
+    return CrashReason::eIntegerOverflow;
+  case FPE_FLTDIV:
+    return CrashReason::eFloatDivideByZero;
+  case FPE_FLTOVF:
+    return CrashReason::eFloatOverflow;
+  case FPE_FLTUND:
+    return CrashReason::eFloatUnderflow;
+  case FPE_FLTRES:
+    return CrashReason::eFloatInexactResult;
+  case FPE_FLTINV:
+    return CrashReason::eFloatInvalidOperation;
+  case FPE_FLTSUB:
+    return CrashReason::eFloatSubscriptRange;
+  }
 
-    assert(false && "unexpected si_code for SIGFPE");
-    return CrashReason::eInvalidCrashReason;
+  assert(false && "unexpected si_code for SIGFPE");
+  return CrashReason::eInvalidCrashReason;
 }
 
-CrashReason
-GetCrashReasonForSIGBUS(const siginfo_t& info)
-{
-    assert(info.si_signo == SIGBUS);
-
-    switch (info.si_code)
-    {
-    case BUS_ADRALN:
-        return CrashReason::eIllegalAlignment;
-    case BUS_ADRERR:
-        return CrashReason::eIllegalAddress;
-    case BUS_OBJERR:
-        return CrashReason::eHardwareError;
-    }
+CrashReason GetCrashReasonForSIGBUS(const siginfo_t &info) {
+  assert(info.si_signo == SIGBUS);
 
-    assert(false && "unexpected si_code for SIGBUS");
-    return CrashReason::eInvalidCrashReason;
-}
+  switch (info.si_code) {
+  case BUS_ADRALN:
+    return CrashReason::eIllegalAlignment;
+  case BUS_ADRERR:
+    return CrashReason::eIllegalAddress;
+  case BUS_OBJERR:
+    return CrashReason::eHardwareError;
+  }
 
+  assert(false && "unexpected si_code for SIGBUS");
+  return CrashReason::eInvalidCrashReason;
 }
+}
+
+std::string GetCrashReasonString(CrashReason reason, lldb::addr_t fault_addr) {
+  std::string str;
 
-std::string
-GetCrashReasonString (CrashReason reason, lldb::addr_t fault_addr)
-{
-    std::string str;
-
-    switch (reason)
-    {
-    default:
-        assert(false && "invalid CrashReason");
-        break;
-
-    case CrashReason::eInvalidAddress:
-        str = "signal SIGSEGV: invalid address";
-        AppendFaultAddr (str, fault_addr);
-        break;
-    case CrashReason::ePrivilegedAddress:
-        str = "signal SIGSEGV: address access protected";
-        AppendFaultAddr (str, fault_addr);
-        break;
-    case CrashReason::eIllegalOpcode:
-        str = "signal SIGILL: illegal instruction";
-        break;
-    case CrashReason::eIllegalOperand:
-        str = "signal SIGILL: illegal instruction operand";
-        break;
-    case CrashReason::eIllegalAddressingMode:
-        str = "signal SIGILL: illegal addressing mode";
-        break;
-    case CrashReason::eIllegalTrap:
-        str = "signal SIGILL: illegal trap";
-        break;
-    case CrashReason::ePrivilegedOpcode:
-        str = "signal SIGILL: privileged instruction";
-        break;
-    case CrashReason::ePrivilegedRegister:
-        str = "signal SIGILL: privileged register";
-        break;
-    case CrashReason::eCoprocessorError:
-        str = "signal SIGILL: coprocessor error";
-        break;
-    case CrashReason::eInternalStackError:
-        str = "signal SIGILL: internal stack error";
-        break;
-    case CrashReason::eIllegalAlignment:
-        str = "signal SIGBUS: illegal alignment";
-        break;
-    case CrashReason::eIllegalAddress:
-        str = "signal SIGBUS: illegal address";
-        break;
-    case CrashReason::eHardwareError:
-        str = "signal SIGBUS: hardware error";
-        break;
-    case CrashReason::eIntegerDivideByZero:
-        str = "signal SIGFPE: integer divide by zero";
-        break;
-    case CrashReason::eIntegerOverflow:
-        str = "signal SIGFPE: integer overflow";
-        break;
-    case CrashReason::eFloatDivideByZero:
-        str = "signal SIGFPE: floating point divide by zero";
-        break;
-    case CrashReason::eFloatOverflow:
-        str = "signal SIGFPE: floating point overflow";
-        break;
-    case CrashReason::eFloatUnderflow:
-        str = "signal SIGFPE: floating point underflow";
-        break;
-    case CrashReason::eFloatInexactResult:
-        str = "signal SIGFPE: inexact floating point result";
-        break;
-    case CrashReason::eFloatInvalidOperation:
-        str = "signal SIGFPE: invalid floating point operation";
-        break;
-    case CrashReason::eFloatSubscriptRange:
-        str = "signal SIGFPE: invalid floating point subscript range";
-        break;
-    }
+  switch (reason) {
+  default:
+    assert(false && "invalid CrashReason");
+    break;
+
+  case CrashReason::eInvalidAddress:
+    str = "signal SIGSEGV: invalid address";
+    AppendFaultAddr(str, fault_addr);
+    break;
+  case CrashReason::ePrivilegedAddress:
+    str = "signal SIGSEGV: address access protected";
+    AppendFaultAddr(str, fault_addr);
+    break;
+  case CrashReason::eIllegalOpcode:
+    str = "signal SIGILL: illegal instruction";
+    break;
+  case CrashReason::eIllegalOperand:
+    str = "signal SIGILL: illegal instruction operand";
+    break;
+  case CrashReason::eIllegalAddressingMode:
+    str = "signal SIGILL: illegal addressing mode";
+    break;
+  case CrashReason::eIllegalTrap:
+    str = "signal SIGILL: illegal trap";
+    break;
+  case CrashReason::ePrivilegedOpcode:
+    str = "signal SIGILL: privileged instruction";
+    break;
+  case CrashReason::ePrivilegedRegister:
+    str = "signal SIGILL: privileged register";
+    break;
+  case CrashReason::eCoprocessorError:
+    str = "signal SIGILL: coprocessor error";
+    break;
+  case CrashReason::eInternalStackError:
+    str = "signal SIGILL: internal stack error";
+    break;
+  case CrashReason::eIllegalAlignment:
+    str = "signal SIGBUS: illegal alignment";
+    break;
+  case CrashReason::eIllegalAddress:
+    str = "signal SIGBUS: illegal address";
+    break;
+  case CrashReason::eHardwareError:
+    str = "signal SIGBUS: hardware error";
+    break;
+  case CrashReason::eIntegerDivideByZero:
+    str = "signal SIGFPE: integer divide by zero";
+    break;
+  case CrashReason::eIntegerOverflow:
+    str = "signal SIGFPE: integer overflow";
+    break;
+  case CrashReason::eFloatDivideByZero:
+    str = "signal SIGFPE: floating point divide by zero";
+    break;
+  case CrashReason::eFloatOverflow:
+    str = "signal SIGFPE: floating point overflow";
+    break;
+  case CrashReason::eFloatUnderflow:
+    str = "signal SIGFPE: floating point underflow";
+    break;
+  case CrashReason::eFloatInexactResult:
+    str = "signal SIGFPE: inexact floating point result";
+    break;
+  case CrashReason::eFloatInvalidOperation:
+    str = "signal SIGFPE: invalid floating point operation";
+    break;
+  case CrashReason::eFloatSubscriptRange:
+    str = "signal SIGFPE: invalid floating point subscript range";
+    break;
+  }
 
-    return str;
+  return str;
 }
 
-const char *
-CrashReasonAsString (CrashReason reason)
-{
+const char *CrashReasonAsString(CrashReason reason) {
 #ifdef LLDB_CONFIGURATION_BUILDANDINTEGRATION
-    // Just return the code in ascii for integration builds.
-    chcar str[8];
-    sprintf(str, "%d", reason);
+  // Just return the code in ascii for integration builds.
+  chcar str[8];
+  sprintf(str, "%d", reason);
 #else
-    const char *str = nullptr;
+  const char *str = nullptr;
 
-    switch (reason)
-    {
-    case CrashReason::eInvalidCrashReason:
-        str = "eInvalidCrashReason";
-        break;
-
-    // SIGSEGV crash reasons.
-    case CrashReason::eInvalidAddress:
-        str = "eInvalidAddress";
-        break;
-    case CrashReason::ePrivilegedAddress:
-        str = "ePrivilegedAddress";
-        break;
-
-    // SIGILL crash reasons.
-    case CrashReason::eIllegalOpcode:
-        str = "eIllegalOpcode";
-        break;
-    case CrashReason::eIllegalOperand:
-        str = "eIllegalOperand";
-        break;
-    case CrashReason::eIllegalAddressingMode:
-        str = "eIllegalAddressingMode";
-        break;
-    case CrashReason::eIllegalTrap:
-        str = "eIllegalTrap";
-        break;
-    case CrashReason::ePrivilegedOpcode:
-        str = "ePrivilegedOpcode";
-        break;
-    case CrashReason::ePrivilegedRegister:
-        str = "ePrivilegedRegister";
-        break;
-    case CrashReason::eCoprocessorError:
-        str = "eCoprocessorError";
-        break;
-    case CrashReason::eInternalStackError:
-        str = "eInternalStackError";
-        break;
-
-    // SIGBUS crash reasons:
-    case CrashReason::eIllegalAlignment:
-        str = "eIllegalAlignment";
-        break;
-    case CrashReason::eIllegalAddress:
-        str = "eIllegalAddress";
-        break;
-    case CrashReason::eHardwareError:
-        str = "eHardwareError";
-        break;
-
-    // SIGFPE crash reasons:
-    case CrashReason::eIntegerDivideByZero:
-        str = "eIntegerDivideByZero";
-        break;
-    case CrashReason::eIntegerOverflow:
-        str = "eIntegerOverflow";
-        break;
-    case CrashReason::eFloatDivideByZero:
-        str = "eFloatDivideByZero";
-        break;
-    case CrashReason::eFloatOverflow:
-        str = "eFloatOverflow";
-        break;
-    case CrashReason::eFloatUnderflow:
-        str = "eFloatUnderflow";
-        break;
-    case CrashReason::eFloatInexactResult:
-        str = "eFloatInexactResult";
-        break;
-    case CrashReason::eFloatInvalidOperation:
-        str = "eFloatInvalidOperation";
-        break;
-    case CrashReason::eFloatSubscriptRange:
-        str = "eFloatSubscriptRange";
-        break;
-    }
+  switch (reason) {
+  case CrashReason::eInvalidCrashReason:
+    str = "eInvalidCrashReason";
+    break;
+
+  // SIGSEGV crash reasons.
+  case CrashReason::eInvalidAddress:
+    str = "eInvalidAddress";
+    break;
+  case CrashReason::ePrivilegedAddress:
+    str = "ePrivilegedAddress";
+    break;
+
+  // SIGILL crash reasons.
+  case CrashReason::eIllegalOpcode:
+    str = "eIllegalOpcode";
+    break;
+  case CrashReason::eIllegalOperand:
+    str = "eIllegalOperand";
+    break;
+  case CrashReason::eIllegalAddressingMode:
+    str = "eIllegalAddressingMode";
+    break;
+  case CrashReason::eIllegalTrap:
+    str = "eIllegalTrap";
+    break;
+  case CrashReason::ePrivilegedOpcode:
+    str = "ePrivilegedOpcode";
+    break;
+  case CrashReason::ePrivilegedRegister:
+    str = "ePrivilegedRegister";
+    break;
+  case CrashReason::eCoprocessorError:
+    str = "eCoprocessorError";
+    break;
+  case CrashReason::eInternalStackError:
+    str = "eInternalStackError";
+    break;
+
+  // SIGBUS crash reasons:
+  case CrashReason::eIllegalAlignment:
+    str = "eIllegalAlignment";
+    break;
+  case CrashReason::eIllegalAddress:
+    str = "eIllegalAddress";
+    break;
+  case CrashReason::eHardwareError:
+    str = "eHardwareError";
+    break;
+
+  // SIGFPE crash reasons:
+  case CrashReason::eIntegerDivideByZero:
+    str = "eIntegerDivideByZero";
+    break;
+  case CrashReason::eIntegerOverflow:
+    str = "eIntegerOverflow";
+    break;
+  case CrashReason::eFloatDivideByZero:
+    str = "eFloatDivideByZero";
+    break;
+  case CrashReason::eFloatOverflow:
+    str = "eFloatOverflow";
+    break;
+  case CrashReason::eFloatUnderflow:
+    str = "eFloatUnderflow";
+    break;
+  case CrashReason::eFloatInexactResult:
+    str = "eFloatInexactResult";
+    break;
+  case CrashReason::eFloatInvalidOperation:
+    str = "eFloatInvalidOperation";
+    break;
+  case CrashReason::eFloatSubscriptRange:
+    str = "eFloatSubscriptRange";
+    break;
+  }
 #endif
 
-    return str;
+  return str;
 }
 
-CrashReason
-GetCrashReason(const siginfo_t& info)
-{
-    switch(info.si_signo)
-    {
-    case SIGSEGV:
-        return GetCrashReasonForSIGSEGV(info);
-    case SIGBUS:
-        return GetCrashReasonForSIGBUS(info);
-    case SIGFPE:
-        return GetCrashReasonForSIGFPE(info);
-    case SIGILL:
-        return GetCrashReasonForSIGILL(info);
-    }
+CrashReason GetCrashReason(const siginfo_t &info) {
+  switch (info.si_signo) {
+  case SIGSEGV:
+    return GetCrashReasonForSIGSEGV(info);
+  case SIGBUS:
+    return GetCrashReasonForSIGBUS(info);
+  case SIGFPE:
+    return GetCrashReasonForSIGFPE(info);
+  case SIGILL:
+    return GetCrashReasonForSIGILL(info);
+  }
 
-    assert(false && "unexpected signal");
-    return CrashReason::eInvalidCrashReason;
+  assert(false && "unexpected signal");
+  return CrashReason::eInvalidCrashReason;
 }

Modified: lldb/trunk/source/Plugins/Process/POSIX/CrashReason.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/POSIX/CrashReason.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/POSIX/CrashReason.h (original)
+++ lldb/trunk/source/Plugins/Process/POSIX/CrashReason.h Tue Sep  6 15:57:50 2016
@@ -16,47 +16,43 @@
 
 #include <string>
 
-enum class CrashReason
-{
-    eInvalidCrashReason,
-
-    // SIGSEGV crash reasons.
-    eInvalidAddress,
-    ePrivilegedAddress,
-
-    // SIGILL crash reasons.
-    eIllegalOpcode,
-    eIllegalOperand,
-    eIllegalAddressingMode,
-    eIllegalTrap,
-    ePrivilegedOpcode,
-    ePrivilegedRegister,
-    eCoprocessorError,
-    eInternalStackError,
-
-    // SIGBUS crash reasons,
-    eIllegalAlignment,
-    eIllegalAddress,
-    eHardwareError,
-
-    // SIGFPE crash reasons,
-    eIntegerDivideByZero,
-    eIntegerOverflow,
-    eFloatDivideByZero,
-    eFloatOverflow,
-    eFloatUnderflow,
-    eFloatInexactResult,
-    eFloatInvalidOperation,
-    eFloatSubscriptRange
+enum class CrashReason {
+  eInvalidCrashReason,
+
+  // SIGSEGV crash reasons.
+  eInvalidAddress,
+  ePrivilegedAddress,
+
+  // SIGILL crash reasons.
+  eIllegalOpcode,
+  eIllegalOperand,
+  eIllegalAddressingMode,
+  eIllegalTrap,
+  ePrivilegedOpcode,
+  ePrivilegedRegister,
+  eCoprocessorError,
+  eInternalStackError,
+
+  // SIGBUS crash reasons,
+  eIllegalAlignment,
+  eIllegalAddress,
+  eHardwareError,
+
+  // SIGFPE crash reasons,
+  eIntegerDivideByZero,
+  eIntegerOverflow,
+  eFloatDivideByZero,
+  eFloatOverflow,
+  eFloatUnderflow,
+  eFloatInexactResult,
+  eFloatInvalidOperation,
+  eFloatSubscriptRange
 };
 
-std::string
-GetCrashReasonString (CrashReason reason, lldb::addr_t fault_addr);
+std::string GetCrashReasonString(CrashReason reason, lldb::addr_t fault_addr);
 
-const char *
-CrashReasonAsString (CrashReason reason);
+const char *CrashReasonAsString(CrashReason reason);
 
-CrashReason
-GetCrashReason(const siginfo_t& info);
+CrashReason GetCrashReason(const siginfo_t &info);
 
 #endif // #ifndef liblldb_CrashReason_H_

Modified: lldb/trunk/source/Plugins/Process/POSIX/ProcessMessage.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/POSIX/ProcessMessage.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/POSIX/ProcessMessage.cpp (original)
+++ lldb/trunk/source/Plugins/Process/POSIX/ProcessMessage.cpp Tue Sep  6 15:57:50 2016
@@ -11,68 +11,59 @@
 
 using namespace lldb_private;
 
-const char *
-ProcessMessage::PrintCrashReason() const
-{
-    return CrashReasonAsString(m_crash_reason);
+const char *ProcessMessage::PrintCrashReason() const {
+  return CrashReasonAsString(m_crash_reason);
 }
 
-const char *
-ProcessMessage::PrintKind(Kind kind)
-{
+const char *ProcessMessage::PrintKind(Kind kind) {
 #ifdef LLDB_CONFIGURATION_BUILDANDINTEGRATION
-    // Just return the code in ascii for integration builds.
-    chcar str[8];
-    sprintf(str, "%d", reason);
+  // Just return the code in ascii for integration builds.
+  chcar str[8];
+  sprintf(str, "%d", reason);
 #else
-    const char *str = NULL;
+  const char *str = NULL;
 
-    switch (kind)
-    {
-    case eInvalidMessage:
-        str = "eInvalidMessage";
-        break;
-    case eAttachMessage:
-        str = "eAttachMessage";
-        break;
-    case eExitMessage:
-        str = "eExitMessage";
-        break;
-    case eLimboMessage:
-        str = "eLimboMessage";
-        break;
-    case eSignalMessage:
-        str = "eSignalMessage";
-        break;
-    case eSignalDeliveredMessage:
-        str = "eSignalDeliveredMessage";
-        break;
-    case eTraceMessage:
-        str = "eTraceMessage";
-        break;
-    case eBreakpointMessage:
-        str = "eBreakpointMessage";
-        break;
-    case eWatchpointMessage:
-        str = "eWatchpointMessage";
-        break;
-    case eCrashMessage:
-        str = "eCrashMessage";
-        break;
-    case eNewThreadMessage:
-        str = "eNewThreadMessage";
-        break;
-    case eExecMessage:
-        str = "eExecMessage";
-        break;
-    }
+  switch (kind) {
+  case eInvalidMessage:
+    str = "eInvalidMessage";
+    break;
+  case eAttachMessage:
+    str = "eAttachMessage";
+    break;
+  case eExitMessage:
+    str = "eExitMessage";
+    break;
+  case eLimboMessage:
+    str = "eLimboMessage";
+    break;
+  case eSignalMessage:
+    str = "eSignalMessage";
+    break;
+  case eSignalDeliveredMessage:
+    str = "eSignalDeliveredMessage";
+    break;
+  case eTraceMessage:
+    str = "eTraceMessage";
+    break;
+  case eBreakpointMessage:
+    str = "eBreakpointMessage";
+    break;
+  case eWatchpointMessage:
+    str = "eWatchpointMessage";
+    break;
+  case eCrashMessage:
+    str = "eCrashMessage";
+    break;
+  case eNewThreadMessage:
+    str = "eNewThreadMessage";
+    break;
+  case eExecMessage:
+    str = "eExecMessage";
+    break;
+  }
 #endif
 
-    return str;
+  return str;
 }
 
-const char *
-ProcessMessage::PrintKind() const
-{
-    return PrintKind(m_kind);
-}
+const char *ProcessMessage::PrintKind() const { return PrintKind(m_kind); }

Modified: lldb/trunk/source/Plugins/Process/POSIX/ProcessMessage.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/POSIX/ProcessMessage.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/POSIX/ProcessMessage.h (original)
+++ lldb/trunk/source/Plugins/Process/POSIX/ProcessMessage.h Tue Sep  6 15:57:50 2016
@@ -18,165 +18,152 @@
 #include "lldb/lldb-defines.h"
 #include "lldb/lldb-types.h"
 
-class ProcessMessage
-{
+class ProcessMessage {
 public:
+  /// The type of signal this message can correspond to.
+  enum Kind {
+    eInvalidMessage,
+    eAttachMessage,
+    eExitMessage,
+    eLimboMessage,
+    eSignalMessage,
+    eSignalDeliveredMessage,
+    eTraceMessage,
+    eBreakpointMessage,
+    eWatchpointMessage,
+    eCrashMessage,
+    eNewThreadMessage,
+    eExecMessage
+  };
+
+  ProcessMessage()
+      : m_tid(LLDB_INVALID_PROCESS_ID), m_kind(eInvalidMessage),
+        m_crash_reason(CrashReason::eInvalidCrashReason), m_status(0),
+        m_addr(0) {}
+
+  Kind GetKind() const { return m_kind; }
+
+  lldb::tid_t GetTID() const { return m_tid; }
+
+  /// Indicates that the process @p pid has successfully attached.
+  static ProcessMessage Attach(lldb::pid_t pid) {
+    return ProcessMessage(pid, eAttachMessage);
+  }
+
+  /// Indicates that the thread @p tid is about to exit with status @p status.
+  static ProcessMessage Limbo(lldb::tid_t tid, int status) {
+    return ProcessMessage(tid, eLimboMessage, status);
+  }
+
+  /// Indicates that the thread @p tid had the signal @p signum delivered.
+  static ProcessMessage Signal(lldb::tid_t tid, int signum) {
+    return ProcessMessage(tid, eSignalMessage, signum);
+  }
+
+  /// Indicates that a signal @p signum generated by the debugging process was
+  /// delivered to the thread @p tid.
+  static ProcessMessage SignalDelivered(lldb::tid_t tid, int signum) {
+    return ProcessMessage(tid, eSignalDeliveredMessage, signum);
+  }
+
+  /// Indicates that the thread @p tid encountered a trace point.
+  static ProcessMessage Trace(lldb::tid_t tid) {
+    return ProcessMessage(tid, eTraceMessage);
+  }
+
+  /// Indicates that the thread @p tid encountered a break point.
+  static ProcessMessage Break(lldb::tid_t tid) {
+    return ProcessMessage(tid, eBreakpointMessage);
+  }
+
+  static ProcessMessage Watch(lldb::tid_t tid, lldb::addr_t wp_addr) {
+    return ProcessMessage(tid, eWatchpointMessage, 0, wp_addr);
+  }
+
+  /// Indicates that the thread @p tid crashed.
+  static ProcessMessage Crash(lldb::pid_t pid, CrashReason reason, int signo,
+                              lldb::addr_t fault_addr) {
+    ProcessMessage message(pid, eCrashMessage, signo, fault_addr);
+    message.m_crash_reason = reason;
+    return message;
+  }
+
+  /// Indicates that the thread @p child_tid was spawned.
+  static ProcessMessage NewThread(lldb::tid_t parent_tid,
+                                  lldb::tid_t child_tid) {
+    return ProcessMessage(parent_tid, eNewThreadMessage, child_tid);
+  }
+
+  /// Indicates that the thread @p tid is about to exit with status @p status.
+  static ProcessMessage Exit(lldb::tid_t tid, int status) {
+    return ProcessMessage(tid, eExitMessage, status);
+  }
+
+  /// Indicates that the thread @p pid has exec'd.
+  static ProcessMessage Exec(lldb::tid_t tid) {
+    return ProcessMessage(tid, eExecMessage);
+  }
+
+  int GetExitStatus() const {
+    assert(GetKind() == eExitMessage || GetKind() == eLimboMessage);
+    return m_status;
+  }
+
+  int GetSignal() const {
+    assert(GetKind() == eSignalMessage || GetKind() == eCrashMessage ||
+           GetKind() == eSignalDeliveredMessage);
+    return m_status;
+  }
+
+  int GetStopStatus() const {
+    assert(GetKind() == eSignalMessage);
+    return m_status;
+  }
+
+  CrashReason GetCrashReason() const {
+    assert(GetKind() == eCrashMessage);
+    return m_crash_reason;
+  }
+
+  lldb::addr_t GetFaultAddress() const {
+    assert(GetKind() == eCrashMessage);
+    return m_addr;
+  }
+
+  lldb::addr_t GetHWAddress() const {
+    assert(GetKind() == eWatchpointMessage || GetKind() == eTraceMessage);
+    return m_addr;
+  }
+
+  lldb::tid_t GetChildTID() const {
+    assert(GetKind() == eNewThreadMessage);
+    return m_child_tid;
+  }
 
-    /// The type of signal this message can correspond to.
-    enum Kind
-    {
-        eInvalidMessage,
-        eAttachMessage,
-        eExitMessage,
-        eLimboMessage,
-        eSignalMessage,
-        eSignalDeliveredMessage,
-        eTraceMessage,
-        eBreakpointMessage,
-        eWatchpointMessage,
-        eCrashMessage,
-        eNewThreadMessage,
-        eExecMessage
-    };
-
-    ProcessMessage()
-        : m_tid(LLDB_INVALID_PROCESS_ID),
-          m_kind(eInvalidMessage),
-          m_crash_reason(CrashReason::eInvalidCrashReason),
-          m_status(0),
-          m_addr(0) { }
-
-    Kind GetKind() const { return m_kind; }
-
-    lldb::tid_t GetTID() const { return m_tid; }
-
-    /// Indicates that the process @p pid has successfully attached.
-    static ProcessMessage Attach(lldb::pid_t pid) {
-        return ProcessMessage(pid, eAttachMessage);
-    }
-
-    /// Indicates that the thread @p tid is about to exit with status @p status.
-    static ProcessMessage Limbo(lldb::tid_t tid, int status) {
-        return ProcessMessage(tid, eLimboMessage, status);
-    }
-
-    /// Indicates that the thread @p tid had the signal @p signum delivered.
-    static ProcessMessage Signal(lldb::tid_t tid, int signum) {
-        return ProcessMessage(tid, eSignalMessage, signum);
-    }
-
-    /// Indicates that a signal @p signum generated by the debugging process was
-    /// delivered to the thread @p tid.
-    static ProcessMessage SignalDelivered(lldb::tid_t tid, int signum) {
-        return ProcessMessage(tid, eSignalDeliveredMessage, signum);
-    }
-
-    /// Indicates that the thread @p tid encountered a trace point.
-    static ProcessMessage Trace(lldb::tid_t tid) {
-        return ProcessMessage(tid, eTraceMessage);
-    }
-
-    /// Indicates that the thread @p tid encountered a break point.
-    static ProcessMessage Break(lldb::tid_t tid) {
-        return ProcessMessage(tid, eBreakpointMessage);
-    }
-
-    static ProcessMessage Watch(lldb::tid_t tid, lldb::addr_t wp_addr) {
-        return ProcessMessage(tid, eWatchpointMessage, 0, wp_addr);
-    }
-
-    /// Indicates that the thread @p tid crashed.
-    static ProcessMessage Crash(lldb::pid_t pid, CrashReason reason,
-                                int signo, lldb::addr_t fault_addr) {
-        ProcessMessage message(pid, eCrashMessage, signo, fault_addr);
-        message.m_crash_reason = reason;
-        return message;
-    }
-
-    /// Indicates that the thread @p child_tid was spawned.
-    static ProcessMessage NewThread(lldb::tid_t parent_tid, lldb::tid_t child_tid) {
-        return ProcessMessage(parent_tid, eNewThreadMessage, child_tid);
-    }
-
-    /// Indicates that the thread @p tid is about to exit with status @p status.
-    static ProcessMessage Exit(lldb::tid_t tid, int status) {
-        return ProcessMessage(tid, eExitMessage, status);
-    }
-
-    /// Indicates that the thread @p pid has exec'd.
-    static ProcessMessage Exec(lldb::tid_t tid) {
-        return ProcessMessage(tid, eExecMessage);
-    }
-
-    int GetExitStatus() const {
-        assert(GetKind() == eExitMessage || GetKind() == eLimboMessage);
-        return m_status;
-    }
-
-    int GetSignal() const {
-        assert(GetKind() == eSignalMessage || GetKind() == eCrashMessage ||
-               GetKind() == eSignalDeliveredMessage);
-        return m_status;
-    }
-
-    int GetStopStatus() const {
-        assert(GetKind() == eSignalMessage);
-        return m_status;
-    }
-
-    CrashReason GetCrashReason() const {
-        assert(GetKind() == eCrashMessage);
-        return m_crash_reason;
-    }
-
-    lldb::addr_t GetFaultAddress() const {
-        assert(GetKind() == eCrashMessage);
-        return m_addr;
-    }
-
-    lldb::addr_t GetHWAddress() const {
-        assert(GetKind() == eWatchpointMessage || GetKind() == eTraceMessage);
-        return m_addr;
-    }
-
-    lldb::tid_t GetChildTID() const {
-        assert(GetKind() == eNewThreadMessage);
-        return m_child_tid;
-    }
+  const char *PrintCrashReason() const;
 
-    const char *
-    PrintCrashReason() const;
+  const char *PrintKind() const;
 
-    const char *
-    PrintKind() const;
-
-    static const char *
-    PrintKind(Kind);
+  static const char *PrintKind(Kind);
 
 private:
-    ProcessMessage(lldb::tid_t tid, Kind kind, 
-                   int status = 0, lldb::addr_t addr = 0)
-        : m_tid(tid),
-          m_kind(kind),
-          m_crash_reason(CrashReason::eInvalidCrashReason),
-          m_status(status),
-          m_addr(addr),
-          m_child_tid(0) { }
-
-    ProcessMessage(lldb::tid_t tid, Kind kind, lldb::tid_t child_tid)
-        : m_tid(tid),
-          m_kind(kind),
-          m_crash_reason(CrashReason::eInvalidCrashReason),
-          m_status(0),
-          m_addr(0),
-          m_child_tid(child_tid) { }
-
-    lldb::tid_t m_tid;
-    Kind        m_kind         : 8;
-    CrashReason m_crash_reason;
-    int m_status;
-    lldb::addr_t m_addr;
-    lldb::tid_t m_child_tid;
+  ProcessMessage(lldb::tid_t tid, Kind kind, int status = 0,
+                 lldb::addr_t addr = 0)
+      : m_tid(tid), m_kind(kind),
+        m_crash_reason(CrashReason::eInvalidCrashReason), m_status(status),
+        m_addr(addr), m_child_tid(0) {}
+
+  ProcessMessage(lldb::tid_t tid, Kind kind, lldb::tid_t child_tid)
+      : m_tid(tid), m_kind(kind),
+        m_crash_reason(CrashReason::eInvalidCrashReason), m_status(0),
+        m_addr(0), m_child_tid(child_tid) {}
+
+  lldb::tid_t m_tid;
+  Kind m_kind : 8;
+  CrashReason m_crash_reason;
+  int m_status;
+  lldb::addr_t m_addr;
+  lldb::tid_t m_child_tid;
 };
 
 #endif // #ifndef liblldb_ProcessMessage_H_

Modified: lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp (original)
+++ lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp Tue Sep  6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- ProcessPOSIXLog.cpp ---------------------------------------*- C++ -*-===//
+//===-- ProcessPOSIXLog.cpp ---------------------------------------*- C++
+//-*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -11,199 +12,185 @@
 
 #include <mutex>
 
-#include "lldb/Interpreter/Args.h"
 #include "lldb/Core/StreamFile.h"
+#include "lldb/Interpreter/Args.h"
 
 #include "ProcessPOSIXLog.h"
 
 using namespace lldb;
 using namespace lldb_private;
 
-
 // We want to avoid global constructors where code needs to be run so here we
 // control access to our static g_log_sp by hiding it in a singleton function
-// that will construct the static g_log_sp the first time this function is 
+// that will construct the static g_log_sp the first time this function is
 // called.
 static bool g_log_enabled = false;
-static Log * g_log = NULL;
-static Log *
-GetLog ()
-{
-    if (!g_log_enabled)
-        return NULL;
-    return g_log;
-}
-
-void
-ProcessPOSIXLog::Initialize(ConstString name)
-{
-    static std::once_flag g_once_flag;
-
-    std::call_once(g_once_flag, [name](){
-        Log::Callbacks log_callbacks = {
-            DisableLog,
-            EnableLog,
-            ListLogCategories
-        };
-
-        Log::RegisterLogChannel (name, log_callbacks);
-        RegisterPluginName(name);
-    });
-}
-
-Log *
-ProcessPOSIXLog::GetLogIfAllCategoriesSet (uint32_t mask)
-{
-    Log *log(GetLog ());
-    if (log && mask)
-    {
-        uint32_t log_mask = log->GetMask().Get();
-        if ((log_mask & mask) != mask)
-            return NULL;
-    }
-    return log;
-}
-
-static uint32_t
-GetFlagBits (const char *arg)
-{
-    if      (::strcasecmp (arg, "all")        == 0 ) return POSIX_LOG_ALL;
-    else if (::strcasecmp (arg, "async")      == 0 ) return POSIX_LOG_ASYNC;
-    else if (::strncasecmp (arg, "break", 5)  == 0 ) return POSIX_LOG_BREAKPOINTS;
-    else if (::strncasecmp (arg, "comm", 4)   == 0 ) return POSIX_LOG_COMM;
-    else if (::strcasecmp (arg, "default")    == 0 ) return POSIX_LOG_DEFAULT;
-    else if (::strcasecmp (arg, "packets")    == 0 ) return POSIX_LOG_PACKETS;
-    else if (::strcasecmp (arg, "memory")     == 0 ) return POSIX_LOG_MEMORY;
-    else if (::strcasecmp (arg, "data-short") == 0 ) return POSIX_LOG_MEMORY_DATA_SHORT;
-    else if (::strcasecmp (arg, "data-long")  == 0 ) return POSIX_LOG_MEMORY_DATA_LONG;
-    else if (::strcasecmp (arg, "process")    == 0 ) return POSIX_LOG_PROCESS;
-    else if (::strcasecmp (arg, "ptrace")     == 0 ) return POSIX_LOG_PTRACE;
-    else if (::strcasecmp (arg, "registers")  == 0 ) return POSIX_LOG_REGISTERS;
-    else if (::strcasecmp (arg, "step")       == 0 ) return POSIX_LOG_STEP;
-    else if (::strcasecmp (arg, "thread")     == 0 ) return POSIX_LOG_THREAD;
-    else if (::strcasecmp (arg, "verbose")    == 0 ) return POSIX_LOG_VERBOSE;
-    else if (::strncasecmp (arg, "watch", 5)  == 0 ) return POSIX_LOG_WATCHPOINTS;
-    return 0;
-}
-
-void
-ProcessPOSIXLog::DisableLog (const char **args, Stream *feedback_strm)
-{
-    Log *log (GetLog ());
-    if (log)
-    {
-        uint32_t flag_bits = 0;
-        
-        flag_bits = log->GetMask().Get();
-        for (; args[0]; args++)
-        {
-            const char *arg = args[0];
-            uint32_t bits = GetFlagBits(arg);
-
-            if (bits)
-            {
-                flag_bits &= ~bits;
-            }
-            else
-            {
-                feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
-                ListLogCategories (feedback_strm);
-            }
-        }
-        
-        log->GetMask().Reset (flag_bits);
-        if (flag_bits == 0)
-            g_log_enabled = false;
-    }
-    
-    return;
-}
-
-Log *
-ProcessPOSIXLog::EnableLog (StreamSP &log_stream_sp, uint32_t log_options, const char **args, Stream *feedback_strm)
-{
-    // Try see if there already is a log - that way we can reuse its settings.
-    // We could reuse the log in toto, but we don't know that the stream is the same.
+static Log *g_log = NULL;
+static Log *GetLog() {
+  if (!g_log_enabled)
+    return NULL;
+  return g_log;
+}
+
+void ProcessPOSIXLog::Initialize(ConstString name) {
+  static std::once_flag g_once_flag;
+
+  std::call_once(g_once_flag, [name]() {
+    Log::Callbacks log_callbacks = {DisableLog, EnableLog, ListLogCategories};
+
+    Log::RegisterLogChannel(name, log_callbacks);
+    RegisterPluginName(name);
+  });
+}
+
+Log *ProcessPOSIXLog::GetLogIfAllCategoriesSet(uint32_t mask) {
+  Log *log(GetLog());
+  if (log && mask) {
+    uint32_t log_mask = log->GetMask().Get();
+    if ((log_mask & mask) != mask)
+      return NULL;
+  }
+  return log;
+}
+
+static uint32_t GetFlagBits(const char *arg) {
+  if (::strcasecmp(arg, "all") == 0)
+    return POSIX_LOG_ALL;
+  else if (::strcasecmp(arg, "async") == 0)
+    return POSIX_LOG_ASYNC;
+  else if (::strncasecmp(arg, "break", 5) == 0)
+    return POSIX_LOG_BREAKPOINTS;
+  else if (::strncasecmp(arg, "comm", 4) == 0)
+    return POSIX_LOG_COMM;
+  else if (::strcasecmp(arg, "default") == 0)
+    return POSIX_LOG_DEFAULT;
+  else if (::strcasecmp(arg, "packets") == 0)
+    return POSIX_LOG_PACKETS;
+  else if (::strcasecmp(arg, "memory") == 0)
+    return POSIX_LOG_MEMORY;
+  else if (::strcasecmp(arg, "data-short") == 0)
+    return POSIX_LOG_MEMORY_DATA_SHORT;
+  else if (::strcasecmp(arg, "data-long") == 0)
+    return POSIX_LOG_MEMORY_DATA_LONG;
+  else if (::strcasecmp(arg, "process") == 0)
+    return POSIX_LOG_PROCESS;
+  else if (::strcasecmp(arg, "ptrace") == 0)
+    return POSIX_LOG_PTRACE;
+  else if (::strcasecmp(arg, "registers") == 0)
+    return POSIX_LOG_REGISTERS;
+  else if (::strcasecmp(arg, "step") == 0)
+    return POSIX_LOG_STEP;
+  else if (::strcasecmp(arg, "thread") == 0)
+    return POSIX_LOG_THREAD;
+  else if (::strcasecmp(arg, "verbose") == 0)
+    return POSIX_LOG_VERBOSE;
+  else if (::strncasecmp(arg, "watch", 5) == 0)
+    return POSIX_LOG_WATCHPOINTS;
+  return 0;
+}
+
+void ProcessPOSIXLog::DisableLog(const char **args, Stream *feedback_strm) {
+  Log *log(GetLog());
+  if (log) {
     uint32_t flag_bits = 0;
-    if (g_log)
-        flag_bits = g_log->GetMask().Get();
 
-    // Now make a new log with this stream if one was provided
-    if (log_stream_sp)
-    {
-        if (g_log)
-            g_log->SetStream(log_stream_sp);
-        else
-            g_log = new Log(log_stream_sp);
+    flag_bits = log->GetMask().Get();
+    for (; args[0]; args++) {
+      const char *arg = args[0];
+      uint32_t bits = GetFlagBits(arg);
+
+      if (bits) {
+        flag_bits &= ~bits;
+      } else {
+        feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
+        ListLogCategories(feedback_strm);
+      }
     }
 
+    log->GetMask().Reset(flag_bits);
+    if (flag_bits == 0)
+      g_log_enabled = false;
+  }
+
+  return;
+}
+
+Log *ProcessPOSIXLog::EnableLog(StreamSP &log_stream_sp, uint32_t log_options,
+                                const char **args, Stream *feedback_strm) {
+  // Try see if there already is a log - that way we can reuse its settings.
+  // We could reuse the log in toto, but we don't know that the stream is the
+  // same.
+  uint32_t flag_bits = 0;
+  if (g_log)
+    flag_bits = g_log->GetMask().Get();
+
+  // Now make a new log with this stream if one was provided
+  if (log_stream_sp) {
     if (g_log)
-    {
-        bool got_unknown_category = false;
-        for (; args[0]; args++)
-        {
-            const char *arg = args[0];
-            uint32_t bits = GetFlagBits(arg);
-
-            if (bits)
-            {
-                flag_bits |= bits;
-            }
-            else
-            {
-                feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
-                if (got_unknown_category == false)
-                {
-                    got_unknown_category = true;
-                    ListLogCategories (feedback_strm);
-                }
-            }
+      g_log->SetStream(log_stream_sp);
+    else
+      g_log = new Log(log_stream_sp);
+  }
+
+  if (g_log) {
+    bool got_unknown_category = false;
+    for (; args[0]; args++) {
+      const char *arg = args[0];
+      uint32_t bits = GetFlagBits(arg);
+
+      if (bits) {
+        flag_bits |= bits;
+      } else {
+        feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
+        if (got_unknown_category == false) {
+          got_unknown_category = true;
+          ListLogCategories(feedback_strm);
         }
-        if (flag_bits == 0)
-            flag_bits = POSIX_LOG_DEFAULT;
-        g_log->GetMask().Reset(flag_bits);
-        g_log->GetOptions().Reset(log_options);
-        g_log_enabled = true;
+      }
     }
-    return g_log;
-}
-
-void
-ProcessPOSIXLog::ListLogCategories (Stream *strm)
-{
-    strm->Printf ("Logging categories for '%s':\n"
-                  "  all - turn on all available logging categories\n"
-                  "  async - log asynchronous activity\n"
-                  "  break - log breakpoints\n"
-                  "  communication - log communication activity\n"
-                  "  default - enable the default set of logging categories for liblldb\n"
-                  "  packets - log gdb remote packets\n"
-                  "  memory - log memory reads and writes\n"
-                  "  data-short - log memory bytes for memory reads and writes for short transactions only\n"
-                  "  data-long - log memory bytes for memory reads and writes for all transactions\n"
-                  "  process - log process events and activities\n"
+    if (flag_bits == 0)
+      flag_bits = POSIX_LOG_DEFAULT;
+    g_log->GetMask().Reset(flag_bits);
+    g_log->GetOptions().Reset(log_options);
+    g_log_enabled = true;
+  }
+  return g_log;
+}
+
+void ProcessPOSIXLog::ListLogCategories(Stream *strm) {
+  strm->Printf(
+      "Logging categories for '%s':\n"
+      "  all - turn on all available logging categories\n"
+      "  async - log asynchronous activity\n"
+      "  break - log breakpoints\n"
+      "  communication - log communication activity\n"
+      "  default - enable the default set of logging categories for liblldb\n"
+      "  packets - log gdb remote packets\n"
+      "  memory - log memory reads and writes\n"
+      "  data-short - log memory bytes for memory reads and writes for short "
+      "transactions only\n"
+      "  data-long - log memory bytes for memory reads and writes for all "
+      "transactions\n"
+      "  process - log process events and activities\n"
 #ifndef LLDB_CONFIGURATION_BUILDANDINTEGRATION
-                  "  ptrace - log all calls to ptrace\n"
+      "  ptrace - log all calls to ptrace\n"
 #endif
-                  "  registers - log register read/writes\n"
-                  "  thread - log thread events and activities\n"
-                  "  step - log step related activities\n"
-                  "  verbose - enable verbose logging\n"
-                  "  watch - log watchpoint related activities\n", ProcessPOSIXLog::m_pluginname);
-}
-
-
-void
-ProcessPOSIXLog::LogIf (uint32_t mask, const char *format, ...)
-{
-    Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (mask));
-    if (log)
-    {
-        va_list args;
-        va_start (args, format);
-        log->VAPrintf (format, args);
-        va_end (args);
-    }
+      "  registers - log register read/writes\n"
+      "  thread - log thread events and activities\n"
+      "  step - log step related activities\n"
+      "  verbose - enable verbose logging\n"
+      "  watch - log watchpoint related activities\n",
+      ProcessPOSIXLog::m_pluginname);
+}
+
+void ProcessPOSIXLog::LogIf(uint32_t mask, const char *format, ...) {
+  Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(mask));
+  if (log) {
+    va_list args;
+    va_start(args, format);
+    log->VAPrintf(format, args);
+    va_end(args);
+  }
 }
 
 int ProcessPOSIXLog::m_nestinglevel;

Modified: lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIXLog.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIXLog.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIXLog.h (original)
+++ lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIXLog.h Tue Sep  6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- ProcessPOSIXLog.h -----------------------------------------*- C++ -*-===//
+//===-- ProcessPOSIXLog.h -----------------------------------------*- C++
+//-*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -17,101 +18,85 @@
 // Project includes
 #include "lldb/Core/Log.h"
 
-#define POSIX_LOG_VERBOSE                  (1u << 0)
-#define POSIX_LOG_PROCESS                  (1u << 1)
-#define POSIX_LOG_THREAD                   (1u << 2)
-#define POSIX_LOG_PACKETS                  (1u << 3)
-#define POSIX_LOG_MEMORY                   (1u << 4)    // Log memory reads/writes calls
-#define POSIX_LOG_MEMORY_DATA_SHORT        (1u << 5)    // Log short memory reads/writes bytes
-#define POSIX_LOG_MEMORY_DATA_LONG         (1u << 6)    // Log all memory reads/writes bytes
-#define POSIX_LOG_BREAKPOINTS              (1u << 7)
-#define POSIX_LOG_WATCHPOINTS              (1u << 8)
-#define POSIX_LOG_STEP                     (1u << 9)
-#define POSIX_LOG_COMM                     (1u << 10)
-#define POSIX_LOG_ASYNC                    (1u << 11)
-#define POSIX_LOG_PTRACE                   (1u << 12)
-#define POSIX_LOG_REGISTERS                (1u << 13)
-#define POSIX_LOG_ALL                      (UINT32_MAX)
-#define POSIX_LOG_DEFAULT                  POSIX_LOG_PACKETS
+#define POSIX_LOG_VERBOSE (1u << 0)
+#define POSIX_LOG_PROCESS (1u << 1)
+#define POSIX_LOG_THREAD (1u << 2)
+#define POSIX_LOG_PACKETS (1u << 3)
+#define POSIX_LOG_MEMORY (1u << 4) // Log memory reads/writes calls
+#define POSIX_LOG_MEMORY_DATA_SHORT                                            \
+  (1u << 5) // Log short memory reads/writes bytes
+#define POSIX_LOG_MEMORY_DATA_LONG                                             \
+  (1u << 6) // Log all memory reads/writes bytes
+#define POSIX_LOG_BREAKPOINTS (1u << 7)
+#define POSIX_LOG_WATCHPOINTS (1u << 8)
+#define POSIX_LOG_STEP (1u << 9)
+#define POSIX_LOG_COMM (1u << 10)
+#define POSIX_LOG_ASYNC (1u << 11)
+#define POSIX_LOG_PTRACE (1u << 12)
+#define POSIX_LOG_REGISTERS (1u << 13)
+#define POSIX_LOG_ALL (UINT32_MAX)
+#define POSIX_LOG_DEFAULT POSIX_LOG_PACKETS
 
 // The size which determines "short memory reads/writes".
-#define POSIX_LOG_MEMORY_SHORT_BYTES       (4 * sizeof(ptrdiff_t))
+#define POSIX_LOG_MEMORY_SHORT_BYTES (4 * sizeof(ptrdiff_t))
 
-class ProcessPOSIXLog
-{
-    static int m_nestinglevel;
-    static const char *m_pluginname;
+class ProcessPOSIXLog {
+  static int m_nestinglevel;
+  static const char *m_pluginname;
 
 public:
-    // ---------------------------------------------------------------------
-    // Public Static Methods
-    // ---------------------------------------------------------------------
-    static void
-    Initialize(lldb_private::ConstString name);
-
-    static void
-    RegisterPluginName(const char *pluginName)
-    {
-        m_pluginname = pluginName;
-    }
-
-    static void
-    RegisterPluginName(lldb_private::ConstString pluginName)
-        {
-            m_pluginname = pluginName.GetCString();
-        }
-
-    static lldb_private::Log *
-    GetLogIfAllCategoriesSet(uint32_t mask = 0);
-
-    static void
-    DisableLog (const char **args, lldb_private::Stream *feedback_strm);
-
-    static lldb_private::Log *
-    EnableLog (lldb::StreamSP &log_stream_sp, uint32_t log_options,
-               const char **args, lldb_private::Stream *feedback_strm);
-
-    static void
-    ListLogCategories (lldb_private::Stream *strm);
-
-    static void
-    LogIf (uint32_t mask, const char *format, ...);
-
-    // The following functions can be used to enable the client to limit
-    // logging to only the top level function calls.  This is useful for
-    // recursive functions.  FIXME: not thread safe!
-    //     Example:
-    //     void NestingFunc() {
-    //         LogSP log (ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_ALL));
-    //         if (log)
-    //         {
-    //             ProcessPOSIXLog::IncNestLevel();
-    //             if (ProcessPOSIXLog::AtTopNestLevel())
-    //                 log->Print(msg);
-    //         }
-    //         NestingFunc();
-    //         if (log)
-    //             ProcessPOSIXLog::DecNestLevel();
-    //     }
-
-    static bool
-    AtTopNestLevel()
-    {
-        return m_nestinglevel == 1;
-    }
-
-    static void
-    IncNestLevel()
-    {
-        ++m_nestinglevel;
-    }
-
-    static void
-    DecNestLevel()
-    {
-        --m_nestinglevel;
-        assert(m_nestinglevel >= 0);
-    }
+  // ---------------------------------------------------------------------
+  // Public Static Methods
+  // ---------------------------------------------------------------------
+  static void Initialize(lldb_private::ConstString name);
+
+  static void RegisterPluginName(const char *pluginName) {
+    m_pluginname = pluginName;
+  }
+
+  static void RegisterPluginName(lldb_private::ConstString pluginName) {
+    m_pluginname = pluginName.GetCString();
+  }
+
+  static lldb_private::Log *GetLogIfAllCategoriesSet(uint32_t mask = 0);
+
+  static void DisableLog(const char **args,
+                         lldb_private::Stream *feedback_strm);
+
+  static lldb_private::Log *EnableLog(lldb::StreamSP &log_stream_sp,
+                                      uint32_t log_options, const char **args,
+                                      lldb_private::Stream *feedback_strm);
+
+  static void ListLogCategories(lldb_private::Stream *strm);
+
+  static void LogIf(uint32_t mask, const char *format, ...);
+
+  // The following functions can be used to enable the client to limit
+  // logging to only the top level function calls.  This is useful for
+  // recursive functions.  FIXME: not thread safe!
+  //     Example:
+  //     void NestingFunc() {
+  //         LogSP log
+  //         (ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_ALL));
+  //         if (log)
+  //         {
+  //             ProcessPOSIXLog::IncNestLevel();
+  //             if (ProcessPOSIXLog::AtTopNestLevel())
+  //                 log->Print(msg);
+  //         }
+  //         NestingFunc();
+  //         if (log)
+  //             ProcessPOSIXLog::DecNestLevel();
+  //     }
+
+  static bool AtTopNestLevel() { return m_nestinglevel == 1; }
+
+  static void IncNestLevel() { ++m_nestinglevel; }
+
+  static void DecNestLevel() {
+    --m_nestinglevel;
+    assert(m_nestinglevel >= 0);
+  }
 };
 
-#endif  // liblldb_ProcessPOSIXLog_h_
+#endif // liblldb_ProcessPOSIXLog_h_

Modified: lldb/trunk/source/Plugins/Process/Utility/ARMDefines.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/ARMDefines.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/ARMDefines.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/ARMDefines.h Tue Sep  6 15:57:50 2016
@@ -18,96 +18,142 @@
 namespace lldb_private {
 
 // ARM shifter types
-typedef enum
-{
-    SRType_LSL,
-    SRType_LSR,
-    SRType_ASR,
-    SRType_ROR,
-    SRType_RRX,
-    SRType_Invalid
+typedef enum {
+  SRType_LSL,
+  SRType_LSR,
+  SRType_ASR,
+  SRType_ROR,
+  SRType_RRX,
+  SRType_Invalid
 } ARM_ShifterType;
 
-// ARM conditions          // Meaning (integer)         Meaning (floating-point)      Condition flags
-#define COND_EQ     0x0    // Equal                     Equal                         Z == 1
-#define COND_NE     0x1    // Not equal                 Not equal, or unordered       Z == 0
-#define COND_CS     0x2    // Carry set                 >, ==, or unordered           C == 1
-#define COND_HS     0x2
-#define COND_CC     0x3    // Carry clear               Less than                     C == 0
-#define COND_LO     0x3
-#define COND_MI     0x4    // Minus, negative           Less than                     N == 1
-#define COND_PL     0x5    // Plus, positive or zero    >, ==, or unordered           N == 0
-#define COND_VS     0x6    // Overflow                  Unordered                     V == 1
-#define COND_VC     0x7    // No overflow               Not unordered                 V == 0
-#define COND_HI     0x8    // Unsigned higher           Greater than, or unordered    C == 1 and Z == 0
-#define COND_LS     0x9    // Unsigned lower or same    Less than or equal            C == 0 or Z == 1
-#define COND_GE     0xA    // Greater than or equal     Greater than or equal         N == V
-#define COND_LT     0xB    // Less than                 Less than, or unordered       N != V
-#define COND_GT     0xC    // Greater than              Greater than                  Z == 0 and N == V
-#define COND_LE     0xD    // Less than or equal        <, ==, or unordered           Z == 1 or N != V
-#define COND_AL     0xE    // Always (unconditional)    Always (unconditional)        Any
+// ARM conditions          // Meaning (integer)         Meaning (floating-point)
+// Condition flags
+#define COND_EQ                                                                \
+  0x0 // Equal                     Equal                         Z == 1
+#define COND_NE                                                                \
+  0x1 // Not equal                 Not equal, or unordered       Z == 0
+#define COND_CS                                                                \
+  0x2 // Carry set                 >, ==, or unordered           C == 1
+#define COND_HS 0x2
+#define COND_CC                                                                \
+  0x3 // Carry clear               Less than                     C == 0
+#define COND_LO 0x3
+#define COND_MI                                                                \
+  0x4 // Minus, negative           Less than                     N == 1
+#define COND_PL                                                                \
+  0x5 // Plus, positive or zero    >, ==, or unordered           N == 0
+#define COND_VS                                                                \
+  0x6 // Overflow                  Unordered                     V == 1
+#define COND_VC                                                                \
+  0x7 // No overflow               Not unordered                 V == 0
+#define COND_HI                                                                \
+  0x8 // Unsigned higher           Greater than, or unordered    C == 1 and Z ==
+      // 0
+#define COND_LS                                                                \
+  0x9 // Unsigned lower or same    Less than or equal            C == 0 or Z ==
+      // 1
+#define COND_GE                                                                \
+  0xA // Greater than or equal     Greater than or equal         N == V
+#define COND_LT                                                                \
+  0xB // Less than                 Less than, or unordered       N != V
+#define COND_GT                                                                \
+  0xC // Greater than              Greater than                  Z == 0 and N ==
+      // V
+#define COND_LE                                                                \
+  0xD // Less than or equal        <, ==, or unordered           Z == 1 or N !=
+      // V
+#define COND_AL                                                                \
+  0xE // Always (unconditional)    Always (unconditional)        Any
 #define COND_UNCOND 0xF
 
-static inline const char *
-ARMCondCodeToString(uint32_t CC)
-{
-    switch (CC) {
-    default: assert(0 && "Unknown condition code");
-    case COND_EQ:  return "eq";
-    case COND_NE:  return "ne";
-    case COND_HS:  return "hs";
-    case COND_LO:  return "lo";
-    case COND_MI:  return "mi";
-    case COND_PL:  return "pl";
-    case COND_VS:  return "vs";
-    case COND_VC:  return "vc";
-    case COND_HI:  return "hi";
-    case COND_LS:  return "ls";
-    case COND_GE:  return "ge";
-    case COND_LT:  return "lt";
-    case COND_GT:  return "gt";
-    case COND_LE:  return "le";
-    case COND_AL:  return "al";
-    }
+static inline const char *ARMCondCodeToString(uint32_t CC) {
+  switch (CC) {
+  default:
+    assert(0 && "Unknown condition code");
+  case COND_EQ:
+    return "eq";
+  case COND_NE:
+    return "ne";
+  case COND_HS:
+    return "hs";
+  case COND_LO:
+    return "lo";
+  case COND_MI:
+    return "mi";
+  case COND_PL:
+    return "pl";
+  case COND_VS:
+    return "vs";
+  case COND_VC:
+    return "vc";
+  case COND_HI:
+    return "hi";
+  case COND_LS:
+    return "ls";
+  case COND_GE:
+    return "ge";
+  case COND_LT:
+    return "lt";
+  case COND_GT:
+    return "gt";
+  case COND_LE:
+    return "le";
+  case COND_AL:
+    return "al";
+  }
 }
 
-static inline bool
-ARMConditionPassed(const uint32_t condition, const uint32_t cpsr)
-{
-    const uint32_t cpsr_n = (cpsr >> 31) & 1u; // Negative condition code flag
-    const uint32_t cpsr_z = (cpsr >> 30) & 1u; // Zero condition code flag
-    const uint32_t cpsr_c = (cpsr >> 29) & 1u; // Carry condition code flag
-    const uint32_t cpsr_v = (cpsr >> 28) & 1u; // Overflow condition code flag
-
-    switch (condition) {
-        case COND_EQ: return (cpsr_z == 1);
-        case COND_NE: return (cpsr_z == 0);
-        case COND_CS: return (cpsr_c == 1);
-        case COND_CC: return (cpsr_c == 0);
-        case COND_MI: return (cpsr_n == 1);
-        case COND_PL: return (cpsr_n == 0);
-        case COND_VS: return (cpsr_v == 1);
-        case COND_VC: return (cpsr_v == 0);
-        case COND_HI: return ((cpsr_c == 1) && (cpsr_z == 0));
-        case COND_LS: return ((cpsr_c == 0) || (cpsr_z == 1));
-        case COND_GE: return (cpsr_n == cpsr_v);
-        case COND_LT: return (cpsr_n != cpsr_v);
-        case COND_GT: return ((cpsr_z == 0) && (cpsr_n == cpsr_v));
-        case COND_LE: return ((cpsr_z == 1) || (cpsr_n != cpsr_v));
-        case COND_AL:
-        case COND_UNCOND:
-        default:
-            return true;
-    }
-    return false;
+static inline bool ARMConditionPassed(const uint32_t condition,
+                                      const uint32_t cpsr) {
+  const uint32_t cpsr_n = (cpsr >> 31) & 1u; // Negative condition code flag
+  const uint32_t cpsr_z = (cpsr >> 30) & 1u; // Zero condition code flag
+  const uint32_t cpsr_c = (cpsr >> 29) & 1u; // Carry condition code flag
+  const uint32_t cpsr_v = (cpsr >> 28) & 1u; // Overflow condition code flag
+
+  switch (condition) {
+  case COND_EQ:
+    return (cpsr_z == 1);
+  case COND_NE:
+    return (cpsr_z == 0);
+  case COND_CS:
+    return (cpsr_c == 1);
+  case COND_CC:
+    return (cpsr_c == 0);
+  case COND_MI:
+    return (cpsr_n == 1);
+  case COND_PL:
+    return (cpsr_n == 0);
+  case COND_VS:
+    return (cpsr_v == 1);
+  case COND_VC:
+    return (cpsr_v == 0);
+  case COND_HI:
+    return ((cpsr_c == 1) && (cpsr_z == 0));
+  case COND_LS:
+    return ((cpsr_c == 0) || (cpsr_z == 1));
+  case COND_GE:
+    return (cpsr_n == cpsr_v);
+  case COND_LT:
+    return (cpsr_n != cpsr_v);
+  case COND_GT:
+    return ((cpsr_z == 0) && (cpsr_n == cpsr_v));
+  case COND_LE:
+    return ((cpsr_z == 1) || (cpsr_n != cpsr_v));
+  case COND_AL:
+  case COND_UNCOND:
+  default:
+    return true;
+  }
+  return false;
 }
 
 // Bit positions for CPSR
-#define CPSR_T_POS  5
-#define CPSR_F_POS  6
-#define CPSR_I_POS  7
-#define CPSR_A_POS  8
-#define CPSR_E_POS  9
+#define CPSR_T_POS 5
+#define CPSR_F_POS 6
+#define CPSR_I_POS 7
+#define CPSR_A_POS 8
+#define CPSR_E_POS 9
 #define CPSR_J_POS 24
 #define CPSR_Q_POS 27
 #define CPSR_V_POS 28
@@ -116,30 +162,30 @@ ARMConditionPassed(const uint32_t condit
 #define CPSR_N_POS 31
 
 // CPSR mode definitions
-#define CPSR_MODE_USR  0x10u
-#define CPSR_MODE_FIQ  0x11u
-#define CPSR_MODE_IRQ  0x12u
-#define CPSR_MODE_SVC  0x13u
-#define CPSR_MODE_ABT  0x17u
-#define CPSR_MODE_UND  0x1bu
-#define CPSR_MODE_SYS  0x1fu
-    
+#define CPSR_MODE_USR 0x10u
+#define CPSR_MODE_FIQ 0x11u
+#define CPSR_MODE_IRQ 0x12u
+#define CPSR_MODE_SVC 0x13u
+#define CPSR_MODE_ABT 0x17u
+#define CPSR_MODE_UND 0x1bu
+#define CPSR_MODE_SYS 0x1fu
+
 // Masks for CPSR
 #define MASK_CPSR_MODE_MASK (0x0000001fu)
-#define MASK_CPSR_IT_MASK   (0x0600fc00u)
-#define MASK_CPSR_T         (1u << CPSR_T_POS)
-#define MASK_CPSR_F         (1u << CPSR_F_POS)
-#define MASK_CPSR_I         (1u << CPSR_I_POS)
-#define MASK_CPSR_A         (1u << CPSR_A_POS)
-#define MASK_CPSR_E         (1u << CPSR_E_POS)
-#define MASK_CPSR_GE_MASK   (0x000f0000u)
-#define MASK_CPSR_J         (1u << CPSR_J_POS)
-#define MASK_CPSR_Q         (1u << CPSR_Q_POS)
-#define MASK_CPSR_V         (1u << CPSR_V_POS)
-#define MASK_CPSR_C         (1u << CPSR_C_POS)
-#define MASK_CPSR_Z         (1u << CPSR_Z_POS)
-#define MASK_CPSR_N         (1u << CPSR_N_POS)
+#define MASK_CPSR_IT_MASK (0x0600fc00u)
+#define MASK_CPSR_T (1u << CPSR_T_POS)
+#define MASK_CPSR_F (1u << CPSR_F_POS)
+#define MASK_CPSR_I (1u << CPSR_I_POS)
+#define MASK_CPSR_A (1u << CPSR_A_POS)
+#define MASK_CPSR_E (1u << CPSR_E_POS)
+#define MASK_CPSR_GE_MASK (0x000f0000u)
+#define MASK_CPSR_J (1u << CPSR_J_POS)
+#define MASK_CPSR_Q (1u << CPSR_Q_POS)
+#define MASK_CPSR_V (1u << CPSR_V_POS)
+#define MASK_CPSR_C (1u << CPSR_C_POS)
+#define MASK_CPSR_Z (1u << CPSR_Z_POS)
+#define MASK_CPSR_N (1u << CPSR_N_POS)
 
-}   // namespace lldb_private
+} // namespace lldb_private
 
-#endif  // lldb_ARMDefines_h_
+#endif // lldb_ARMDefines_h_

Modified: lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h Tue Sep  6 15:57:50 2016
@@ -18,352 +18,335 @@
 
 namespace lldb_private {
 
-static inline uint32_t Align(uint32_t val, uint32_t alignment)
-{
-    return alignment * (val / alignment);
+static inline uint32_t Align(uint32_t val, uint32_t alignment) {
+  return alignment * (val / alignment);
 }
 
-static inline uint32_t DecodeImmShift(const uint32_t type, const uint32_t imm5, ARM_ShifterType &shift_t)
-{
-    switch (type)
-    {
-    default:
-        //assert(0 && "Invalid shift type");
-    case 0:
-        shift_t = SRType_LSL;
-        return imm5;
-    case 1:
-        shift_t = SRType_LSR;
-        return (imm5 == 0 ? 32 : imm5);
-    case 2:
-        shift_t = SRType_ASR;
-        return (imm5 == 0 ? 32 : imm5);
-    case 3:
-        if (imm5 == 0)
-        {
-            shift_t = SRType_RRX;
-            return 1;
-        }
-        else
-        {
-            shift_t = SRType_ROR;
-            return imm5;
-        }
-    }
-    shift_t = SRType_Invalid;
-    return UINT32_MAX;
-
+static inline uint32_t DecodeImmShift(const uint32_t type, const uint32_t imm5,
+                                      ARM_ShifterType &shift_t) {
+  switch (type) {
+  default:
+  // assert(0 && "Invalid shift type");
+  case 0:
+    shift_t = SRType_LSL;
+    return imm5;
+  case 1:
+    shift_t = SRType_LSR;
+    return (imm5 == 0 ? 32 : imm5);
+  case 2:
+    shift_t = SRType_ASR;
+    return (imm5 == 0 ? 32 : imm5);
+  case 3:
+    if (imm5 == 0) {
+      shift_t = SRType_RRX;
+      return 1;
+    } else {
+      shift_t = SRType_ROR;
+      return imm5;
+    }
+  }
+  shift_t = SRType_Invalid;
+  return UINT32_MAX;
 }
 
 // A8.6.35 CMP (register) -- Encoding T3
 // Convenience function.
-static inline uint32_t DecodeImmShiftThumb(const uint32_t opcode, ARM_ShifterType &shift_t)
-{
-    return DecodeImmShift(Bits32(opcode, 5, 4), Bits32(opcode, 14, 12)<<2 | Bits32(opcode, 7, 6), shift_t);
+static inline uint32_t DecodeImmShiftThumb(const uint32_t opcode,
+                                           ARM_ShifterType &shift_t) {
+  return DecodeImmShift(Bits32(opcode, 5, 4),
+                        Bits32(opcode, 14, 12) << 2 | Bits32(opcode, 7, 6),
+                        shift_t);
 }
 
 // A8.6.35 CMP (register) -- Encoding A1
 // Convenience function.
-static inline uint32_t DecodeImmShiftARM(const uint32_t opcode, ARM_ShifterType &shift_t)
-{
-    return DecodeImmShift(Bits32(opcode, 6, 5), Bits32(opcode, 11, 7), shift_t);
-}
-
-static inline uint32_t DecodeImmShift(const ARM_ShifterType shift_t, const uint32_t imm5)
-{
-    ARM_ShifterType dont_care;
-    return DecodeImmShift(shift_t, imm5, dont_care);
-}
-
-static inline ARM_ShifterType DecodeRegShift(const uint32_t type)
-{
-    switch (type) {
-    default:
-        //assert(0 && "Invalid shift type");
-        return SRType_Invalid;
-    case 0:
-        return SRType_LSL;
-    case 1:
-        return SRType_LSR;
-    case 2:
-        return SRType_ASR;
-    case 3:
-        return SRType_ROR;
-    }
+static inline uint32_t DecodeImmShiftARM(const uint32_t opcode,
+                                         ARM_ShifterType &shift_t) {
+  return DecodeImmShift(Bits32(opcode, 6, 5), Bits32(opcode, 11, 7), shift_t);
+}
+
+static inline uint32_t DecodeImmShift(const ARM_ShifterType shift_t,
+                                      const uint32_t imm5) {
+  ARM_ShifterType dont_care;
+  return DecodeImmShift(shift_t, imm5, dont_care);
+}
+
+static inline ARM_ShifterType DecodeRegShift(const uint32_t type) {
+  switch (type) {
+  default:
+    // assert(0 && "Invalid shift type");
+    return SRType_Invalid;
+  case 0:
+    return SRType_LSL;
+  case 1:
+    return SRType_LSR;
+  case 2:
+    return SRType_ASR;
+  case 3:
+    return SRType_ROR;
+  }
+}
+
+static inline uint32_t LSL_C(const uint32_t value, const uint32_t amount,
+                             uint32_t &carry_out, bool *success) {
+  if (amount == 0) {
+    *success = false;
+    return 0;
+  }
+  *success = true;
+  carry_out = amount <= 32 ? Bit32(value, 32 - amount) : 0;
+  return value << amount;
+}
+
+static inline uint32_t LSL(const uint32_t value, const uint32_t amount,
+                           bool *success) {
+  *success = true;
+  if (amount == 0)
+    return value;
+  uint32_t dont_care;
+  uint32_t result = LSL_C(value, amount, dont_care, success);
+  if (*success)
+    return result;
+  else
+    return 0;
 }
 
-static inline uint32_t LSL_C(const uint32_t value, const uint32_t amount, uint32_t &carry_out, bool *success)
-{
-    if (amount == 0) {
-        *success = false;
-        return 0;
-    }
-    *success = true;
-    carry_out = amount <= 32 ? Bit32(value, 32 - amount) : 0;
-    return value << amount;
-}
-
-static inline uint32_t LSL(const uint32_t value, const uint32_t amount, bool *success)
-{
-    *success = true;
-    if (amount == 0)
-        return value;
-    uint32_t dont_care;
-    uint32_t result = LSL_C(value, amount, dont_care, success);
-    if (*success)
-        return result;
-    else
-        return 0;
-}
-
-static inline uint32_t LSR_C(const uint32_t value, const uint32_t amount, uint32_t &carry_out, bool *success)
-{
-    if (amount == 0) {
-        *success = false;
-        return 0;
-    }
-    *success = true;
-    carry_out = amount <= 32 ? Bit32(value, amount - 1) : 0;
-    return value >> amount;
-}
-
-static inline uint32_t LSR(const uint32_t value, const uint32_t amount, bool *success)
-{
-    *success = true;
-    if (amount == 0)
-        return value;
-    uint32_t dont_care;
-    uint32_t result = LSR_C(value, amount, dont_care, success);
-    if (*success)
-        return result;
-    else
-        return 0;
-}
-
-static inline uint32_t ASR_C(const uint32_t value, const uint32_t amount, uint32_t &carry_out, bool *success)
-{
-    if (amount == 0 || amount > 32) {
-        *success = false;
-        return 0;
-    }
-    *success = true;
-    bool negative = BitIsSet(value, 31);
-    if (amount <= 32)
-    {
-        carry_out = Bit32(value, amount - 1);
-        int64_t extended = llvm::SignExtend64<32>(value);
-        return UnsignedBits(extended, amount + 31, amount);
-    }
-    else
-    {
-        carry_out = (negative ? 1 : 0);
-        return (negative ? 0xffffffff : 0);
-    }
+static inline uint32_t LSR_C(const uint32_t value, const uint32_t amount,
+                             uint32_t &carry_out, bool *success) {
+  if (amount == 0) {
+    *success = false;
+    return 0;
+  }
+  *success = true;
+  carry_out = amount <= 32 ? Bit32(value, amount - 1) : 0;
+  return value >> amount;
+}
+
+static inline uint32_t LSR(const uint32_t value, const uint32_t amount,
+                           bool *success) {
+  *success = true;
+  if (amount == 0)
+    return value;
+  uint32_t dont_care;
+  uint32_t result = LSR_C(value, amount, dont_care, success);
+  if (*success)
+    return result;
+  else
+    return 0;
 }
 
-static inline uint32_t ASR(const uint32_t value, const uint32_t amount, bool *success)
-{
-    *success = true;
-    if (amount == 0)
-        return value;
-    uint32_t dont_care;
-    uint32_t result = ASR_C(value, amount, dont_care, success);
-    if (*success)
-        return result;
-    else
-        return 0;
-}
-
-static inline uint32_t ROR_C(const uint32_t value, const uint32_t amount, uint32_t &carry_out, bool *success)
-{
-    if (amount == 0) {
-        *success = false;
-        return 0;
-    }
-    *success = true;
-    uint32_t amt = amount % 32;
-    uint32_t result = Rotr32(value, amt);
-    carry_out = Bit32(value, 31);
+static inline uint32_t ASR_C(const uint32_t value, const uint32_t amount,
+                             uint32_t &carry_out, bool *success) {
+  if (amount == 0 || amount > 32) {
+    *success = false;
+    return 0;
+  }
+  *success = true;
+  bool negative = BitIsSet(value, 31);
+  if (amount <= 32) {
+    carry_out = Bit32(value, amount - 1);
+    int64_t extended = llvm::SignExtend64<32>(value);
+    return UnsignedBits(extended, amount + 31, amount);
+  } else {
+    carry_out = (negative ? 1 : 0);
+    return (negative ? 0xffffffff : 0);
+  }
+}
+
+static inline uint32_t ASR(const uint32_t value, const uint32_t amount,
+                           bool *success) {
+  *success = true;
+  if (amount == 0)
+    return value;
+  uint32_t dont_care;
+  uint32_t result = ASR_C(value, amount, dont_care, success);
+  if (*success)
     return result;
+  else
+    return 0;
 }
 
-static inline uint32_t ROR(const uint32_t value, const uint32_t amount, bool *success)
-{
-    *success = true;
-    if (amount == 0)
-        return value;
-    uint32_t dont_care;
-    uint32_t result = ROR_C(value, amount, dont_care, success);
-    if (*success)
-        return result;
-    else
-        return 0;
-}
-
-static inline uint32_t RRX_C(const uint32_t value, const uint32_t carry_in, uint32_t &carry_out, bool *success)
-{
-    *success = true;
-    carry_out = Bit32(value, 0);
-    return Bit32(carry_in, 0) << 31 | Bits32(value, 31, 1);
-}
-
-static inline uint32_t RRX(const uint32_t value, const uint32_t carry_in, bool *success)
-{
-    *success = true;
-    uint32_t dont_care;
-    uint32_t result = RRX_C(value, carry_in, dont_care, success);
-    if (*success)
-        return result;
-    else
-        return 0;
-}
-
-static inline uint32_t Shift_C(const uint32_t value, ARM_ShifterType type, const uint32_t amount,
-                               const uint32_t carry_in, uint32_t &carry_out, bool *success)
-{
-    if (type == SRType_RRX && amount != 1) {
-        *success = false;
-        return 0;
-    }
-    *success = true;
+static inline uint32_t ROR_C(const uint32_t value, const uint32_t amount,
+                             uint32_t &carry_out, bool *success) {
+  if (amount == 0) {
+    *success = false;
+    return 0;
+  }
+  *success = true;
+  uint32_t amt = amount % 32;
+  uint32_t result = Rotr32(value, amt);
+  carry_out = Bit32(value, 31);
+  return result;
+}
+
+static inline uint32_t ROR(const uint32_t value, const uint32_t amount,
+                           bool *success) {
+  *success = true;
+  if (amount == 0)
+    return value;
+  uint32_t dont_care;
+  uint32_t result = ROR_C(value, amount, dont_care, success);
+  if (*success)
+    return result;
+  else
+    return 0;
+}
 
-    if (amount == 0) {
-        carry_out = carry_in;
-        return value;
-    }
-    uint32_t result;
-    switch (type) {
-    case SRType_LSL:
-        result = LSL_C(value, amount, carry_out, success);
-        break;
-    case SRType_LSR:
-        result = LSR_C(value, amount, carry_out, success);
-        break;
-    case SRType_ASR:
-        result = ASR_C(value, amount, carry_out, success);
-        break;
-    case SRType_ROR:
-        result = ROR_C(value, amount, carry_out, success);
-        break;
-    case SRType_RRX:
-        result = RRX_C(value, carry_in, carry_out, success);
-        break;
-    default:
-        *success = false;
-        break;
-    }
-    if (*success)
-        return result;
-    else
-        return 0;
-}
-
-static inline uint32_t Shift(const uint32_t value, ARM_ShifterType type, const uint32_t amount,
-                             const uint32_t carry_in, bool *success)
-{
-    // Don't care about carry out in this case.
-    uint32_t dont_care;
-    uint32_t result = Shift_C(value, type, amount, carry_in, dont_care, success);
-    if (*success)
-        return result;
-    else
-        return 0;
-}
-
-static inline uint32_t bits(const uint32_t val, const uint32_t msbit, const uint32_t lsbit)
-{
-    return Bits32(val, msbit, lsbit);
-}
-
-static inline uint32_t bit(const uint32_t val, const uint32_t msbit)
-{
-    return bits(val, msbit, msbit);
-}
-
-static uint32_t ror(uint32_t val, uint32_t N, uint32_t shift)
-{
-    uint32_t m = shift % N;
-    return (val >> m) | (val << (N - m));
+static inline uint32_t RRX_C(const uint32_t value, const uint32_t carry_in,
+                             uint32_t &carry_out, bool *success) {
+  *success = true;
+  carry_out = Bit32(value, 0);
+  return Bit32(carry_in, 0) << 31 | Bits32(value, 31, 1);
+}
+
+static inline uint32_t RRX(const uint32_t value, const uint32_t carry_in,
+                           bool *success) {
+  *success = true;
+  uint32_t dont_care;
+  uint32_t result = RRX_C(value, carry_in, dont_care, success);
+  if (*success)
+    return result;
+  else
+    return 0;
 }
 
-// (imm32, carry_out) = ARMExpandImm_C(imm12, carry_in)
-static inline uint32_t ARMExpandImm_C(uint32_t opcode, uint32_t carry_in, uint32_t &carry_out)
-{
-    uint32_t imm32;                         // the expanded result
-    uint32_t imm = bits(opcode, 7, 0);      // immediate value
-    uint32_t amt = 2 * bits(opcode, 11, 8); // rotate amount
-    if (amt == 0)
-    {
-        imm32 = imm;
-        carry_out = carry_in;
-    }
-    else
-    {
-        imm32 = ror(imm, 32, amt);
-        carry_out = Bit32(imm32, 31);
-    }
-    return imm32;
+static inline uint32_t Shift_C(const uint32_t value, ARM_ShifterType type,
+                               const uint32_t amount, const uint32_t carry_in,
+                               uint32_t &carry_out, bool *success) {
+  if (type == SRType_RRX && amount != 1) {
+    *success = false;
+    return 0;
+  }
+  *success = true;
+
+  if (amount == 0) {
+    carry_out = carry_in;
+    return value;
+  }
+  uint32_t result;
+  switch (type) {
+  case SRType_LSL:
+    result = LSL_C(value, amount, carry_out, success);
+    break;
+  case SRType_LSR:
+    result = LSR_C(value, amount, carry_out, success);
+    break;
+  case SRType_ASR:
+    result = ASR_C(value, amount, carry_out, success);
+    break;
+  case SRType_ROR:
+    result = ROR_C(value, amount, carry_out, success);
+    break;
+  case SRType_RRX:
+    result = RRX_C(value, carry_in, carry_out, success);
+    break;
+  default:
+    *success = false;
+    break;
+  }
+  if (*success)
+    return result;
+  else
+    return 0;
 }
 
-static inline uint32_t ARMExpandImm(uint32_t opcode)
-{
-    // 'carry_in' argument to following function call does not affect the imm32 result.
-    uint32_t carry_in = 0;
-    uint32_t carry_out;
-    return ARMExpandImm_C(opcode, carry_in, carry_out);
+static inline uint32_t Shift(const uint32_t value, ARM_ShifterType type,
+                             const uint32_t amount, const uint32_t carry_in,
+                             bool *success) {
+  // Don't care about carry out in this case.
+  uint32_t dont_care;
+  uint32_t result = Shift_C(value, type, amount, carry_in, dont_care, success);
+  if (*success)
+    return result;
+  else
+    return 0;
 }
 
-// (imm32, carry_out) = ThumbExpandImm_C(imm12, carry_in)
-static inline uint32_t ThumbExpandImm_C(uint32_t opcode, uint32_t carry_in, uint32_t &carry_out)
-{
-    uint32_t imm32; // the expanded result
-    const uint32_t i = bit(opcode, 26);
-    const uint32_t imm3 = bits(opcode, 14, 12);
-    const uint32_t abcdefgh = bits(opcode, 7, 0);
-    const uint32_t imm12 = i << 11 | imm3 << 8 | abcdefgh;
-
-    if (bits(imm12, 11, 10) == 0)
-    {
-        switch (bits(imm12, 9, 8)) {
-        default: // Keep static analyzer happy with a default case
-        case 0:
-            imm32 = abcdefgh;
-            break;
-
-        case 1:
-            imm32 = abcdefgh << 16 | abcdefgh;
-            break;
-
-        case 2:
-            imm32 = abcdefgh << 24 | abcdefgh << 8;
-            break;
-
-        case 3:
-            imm32 = abcdefgh  << 24 | abcdefgh << 16 | abcdefgh << 8 | abcdefgh; 
-            break;
-        }
-        carry_out = carry_in;
-    }
-    else
-    {
-        const uint32_t unrotated_value = 0x80 | bits(imm12, 6, 0);
-        imm32 = ror(unrotated_value, 32, bits(imm12, 11, 7));
-        carry_out = Bit32(imm32, 31);
-    }
-    return imm32;
+static inline uint32_t bits(const uint32_t val, const uint32_t msbit,
+                            const uint32_t lsbit) {
+  return Bits32(val, msbit, lsbit);
+}
+
+static inline uint32_t bit(const uint32_t val, const uint32_t msbit) {
+  return bits(val, msbit, msbit);
+}
+
+static uint32_t ror(uint32_t val, uint32_t N, uint32_t shift) {
+  uint32_t m = shift % N;
+  return (val >> m) | (val << (N - m));
+}
+
+// (imm32, carry_out) = ARMExpandImm_C(imm12, carry_in)
+static inline uint32_t ARMExpandImm_C(uint32_t opcode, uint32_t carry_in,
+                                      uint32_t &carry_out) {
+  uint32_t imm32;                         // the expanded result
+  uint32_t imm = bits(opcode, 7, 0);      // immediate value
+  uint32_t amt = 2 * bits(opcode, 11, 8); // rotate amount
+  if (amt == 0) {
+    imm32 = imm;
+    carry_out = carry_in;
+  } else {
+    imm32 = ror(imm, 32, amt);
+    carry_out = Bit32(imm32, 31);
+  }
+  return imm32;
+}
+
+static inline uint32_t ARMExpandImm(uint32_t opcode) {
+  // 'carry_in' argument to following function call does not affect the imm32
+  // result.
+  uint32_t carry_in = 0;
+  uint32_t carry_out;
+  return ARMExpandImm_C(opcode, carry_in, carry_out);
 }
 
-static inline uint32_t ThumbExpandImm(uint32_t opcode)
-{
-    // 'carry_in' argument to following function call does not affect the imm32 result.
-    uint32_t carry_in = 0;
-    uint32_t carry_out;
-    return ThumbExpandImm_C(opcode, carry_in, carry_out);
+// (imm32, carry_out) = ThumbExpandImm_C(imm12, carry_in)
+static inline uint32_t ThumbExpandImm_C(uint32_t opcode, uint32_t carry_in,
+                                        uint32_t &carry_out) {
+  uint32_t imm32; // the expanded result
+  const uint32_t i = bit(opcode, 26);
+  const uint32_t imm3 = bits(opcode, 14, 12);
+  const uint32_t abcdefgh = bits(opcode, 7, 0);
+  const uint32_t imm12 = i << 11 | imm3 << 8 | abcdefgh;
+
+  if (bits(imm12, 11, 10) == 0) {
+    switch (bits(imm12, 9, 8)) {
+    default: // Keep static analyzer happy with a default case
+    case 0:
+      imm32 = abcdefgh;
+      break;
+
+    case 1:
+      imm32 = abcdefgh << 16 | abcdefgh;
+      break;
+
+    case 2:
+      imm32 = abcdefgh << 24 | abcdefgh << 8;
+      break;
+
+    case 3:
+      imm32 = abcdefgh << 24 | abcdefgh << 16 | abcdefgh << 8 | abcdefgh;
+      break;
+    }
+    carry_out = carry_in;
+  } else {
+    const uint32_t unrotated_value = 0x80 | bits(imm12, 6, 0);
+    imm32 = ror(unrotated_value, 32, bits(imm12, 11, 7));
+    carry_out = Bit32(imm32, 31);
+  }
+  return imm32;
+}
+
+static inline uint32_t ThumbExpandImm(uint32_t opcode) {
+  // 'carry_in' argument to following function call does not affect the imm32
+  // result.
+  uint32_t carry_in = 0;
+  uint32_t carry_out;
+  return ThumbExpandImm_C(opcode, carry_in, carry_out);
 }
 
 // imm32 = ZeroExtend(i:imm3:imm8, 32)
-static inline uint32_t ThumbImm12(uint32_t opcode)
-{
+static inline uint32_t ThumbImm12(uint32_t opcode) {
   const uint32_t i = bit(opcode, 26);
   const uint32_t imm3 = bits(opcode, 14, 12);
   const uint32_t imm8 = bits(opcode, 7, 0);
@@ -372,15 +355,13 @@ static inline uint32_t ThumbImm12(uint32
 }
 
 // imm32 = ZeroExtend(imm7:'00', 32)
-static inline uint32_t ThumbImm7Scaled(uint32_t opcode)
-{
+static inline uint32_t ThumbImm7Scaled(uint32_t opcode) {
   const uint32_t imm7 = bits(opcode, 6, 0);
   return imm7 * 4;
 }
 
 // imm32 = ZeroExtend(imm8:'00', 32)
-static inline uint32_t ThumbImm8Scaled(uint32_t opcode)
-{
+static inline uint32_t ThumbImm8Scaled(uint32_t opcode) {
   const uint32_t imm8 = bits(opcode, 7, 0);
   return imm8 * 4;
 }
@@ -389,6 +370,6 @@ static inline uint32_t ThumbImm8Scaled(u
 // not permitted for many Thumb register specifiers.
 static inline bool BadReg(uint32_t n) { return n == 13 || n == 15; }
 
-}   // namespace lldb_private
+} // namespace lldb_private
 
-#endif  // lldb_ARMUtils_h_
+#endif // lldb_ARMUtils_h_

Modified: lldb/trunk/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp Tue Sep  6 15:57:50 2016
@@ -24,787 +24,726 @@
 using namespace lldb;
 using namespace lldb_private;
 
-DynamicRegisterInfo::DynamicRegisterInfo () :
-    m_regs (),
-    m_sets (),
-    m_set_reg_nums (),
-    m_set_names (),
-    m_value_regs_map (),
-    m_invalidate_regs_map (),
-    m_dynamic_reg_size_map (),
-    m_reg_data_byte_size (0),
-    m_finalized (false)
-{
-}
-
-DynamicRegisterInfo::DynamicRegisterInfo(const lldb_private::StructuredData::Dictionary &dict,
-                                         const lldb_private::ArchSpec &arch) :
-    m_regs (),
-    m_sets (),
-    m_set_reg_nums (),
-    m_set_names (),
-    m_value_regs_map (),
-    m_invalidate_regs_map (),
-    m_dynamic_reg_size_map (),
-    m_reg_data_byte_size (0),
-    m_finalized (false)
-{
-    SetRegisterInfo (dict, arch);
+DynamicRegisterInfo::DynamicRegisterInfo()
+    : m_regs(), m_sets(), m_set_reg_nums(), m_set_names(), m_value_regs_map(),
+      m_invalidate_regs_map(), m_dynamic_reg_size_map(),
+      m_reg_data_byte_size(0), m_finalized(false) {}
+
+DynamicRegisterInfo::DynamicRegisterInfo(
+    const lldb_private::StructuredData::Dictionary &dict,
+    const lldb_private::ArchSpec &arch)
+    : m_regs(), m_sets(), m_set_reg_nums(), m_set_names(), m_value_regs_map(),
+      m_invalidate_regs_map(), m_dynamic_reg_size_map(),
+      m_reg_data_byte_size(0), m_finalized(false) {
+  SetRegisterInfo(dict, arch);
 }
 
-DynamicRegisterInfo::~DynamicRegisterInfo ()
-{
-}
+DynamicRegisterInfo::~DynamicRegisterInfo() {}
 
 size_t
-DynamicRegisterInfo::SetRegisterInfo(const StructuredData::Dictionary &dict, const ArchSpec &arch)
-{
-    assert(!m_finalized);
-    StructuredData::Array *sets = nullptr;
-    if (dict.GetValueForKeyAsArray("sets", sets))
-    {
-        const uint32_t num_sets = sets->GetSize();
-        for (uint32_t i=0; i<num_sets; ++i)
-        {
-            std::string set_name_str;
-            ConstString set_name;
-            if (sets->GetItemAtIndexAsString(i, set_name_str))
-                set_name.SetCString(set_name_str.c_str());
-            if (set_name)
-            {
-                RegisterSet new_set = { set_name.AsCString(), NULL, 0, NULL };
-                m_sets.push_back (new_set);
-            }
-            else
-            {
-                Clear();
-                printf("error: register sets must have valid names\n");
-                return 0;
-            }
-        }
-        m_set_reg_nums.resize(m_sets.size());
-    }
-    StructuredData::Array *regs = nullptr;
-    if (!dict.GetValueForKeyAsArray("registers", regs))
+DynamicRegisterInfo::SetRegisterInfo(const StructuredData::Dictionary &dict,
+                                     const ArchSpec &arch) {
+  assert(!m_finalized);
+  StructuredData::Array *sets = nullptr;
+  if (dict.GetValueForKeyAsArray("sets", sets)) {
+    const uint32_t num_sets = sets->GetSize();
+    for (uint32_t i = 0; i < num_sets; ++i) {
+      std::string set_name_str;
+      ConstString set_name;
+      if (sets->GetItemAtIndexAsString(i, set_name_str))
+        set_name.SetCString(set_name_str.c_str());
+      if (set_name) {
+        RegisterSet new_set = {set_name.AsCString(), NULL, 0, NULL};
+        m_sets.push_back(new_set);
+      } else {
+        Clear();
+        printf("error: register sets must have valid names\n");
         return 0;
-
-    const uint32_t num_regs = regs->GetSize();
-//        typedef std::map<std::string, std::vector<std::string> > InvalidateNameMap;
-//        InvalidateNameMap invalidate_map;
-    for (uint32_t i = 0; i < num_regs; ++i)
-    {
-        StructuredData::Dictionary *reg_info_dict = nullptr;
-        if (!regs->GetItemAtIndexAsDictionary(i, reg_info_dict))
-        {
-            Clear();
-            printf("error: items in the 'registers' array must be dictionaries\n");
-            regs->DumpToStdout();
-            return 0;
-        }
-
-        // { 'name':'rcx'       , 'bitsize' :  64, 'offset' :  16, 'encoding':'uint'  , 'format':'hex'         , 'set': 0, 'ehframe' : 2,
-        // 'dwarf' : 2, 'generic':'arg4', 'alt-name':'arg4', },
-        RegisterInfo reg_info;
-        std::vector<uint32_t> value_regs;
-        std::vector<uint32_t> invalidate_regs;
-        memset(&reg_info, 0, sizeof(reg_info));
-
-        ConstString name_val;
-        ConstString alt_name_val;
-        if (!reg_info_dict->GetValueForKeyAsString("name", name_val, nullptr))
-        {
-            Clear();
-            printf("error: registers must have valid names and offsets\n");
-            reg_info_dict->DumpToStdout();
-            return 0;
-        }
-        reg_info.name = name_val.GetCString();
-        reg_info_dict->GetValueForKeyAsString("alt-name", alt_name_val, nullptr);
-        reg_info.alt_name = alt_name_val.GetCString();
-
-        reg_info_dict->GetValueForKeyAsInteger("offset", reg_info.byte_offset, UINT32_MAX);
-
-        const ByteOrder byte_order = arch.GetByteOrder();
-        
-        if (reg_info.byte_offset == UINT32_MAX)
-        {
-            // No offset for this register, see if the register has a value expression
-            // which indicates this register is part of another register. Value expressions
-            // are things like "rax[31:0]" which state that the current register's value
-            // is in a concrete register "rax" in bits 31:0. If there is a value expression
-            // we can calculate the offset
-            bool success = false;
-            std::string slice_str;
-            if (reg_info_dict->GetValueForKeyAsString("slice", slice_str, nullptr))
-            {
-                // Slices use the following format:
-                //  REGNAME[MSBIT:LSBIT]
-                // REGNAME - name of the register to grab a slice of
-                // MSBIT - the most significant bit at which the current register value starts at
-                // LSBIT - the least significant bit at which the current register value ends at
-                static RegularExpression g_bitfield_regex("([A-Za-z_][A-Za-z0-9_]*)\\[([0-9]+):([0-9]+)\\]");
-                RegularExpression::Match regex_match(3);
-                if (g_bitfield_regex.Execute(slice_str.c_str(), &regex_match))
-                {
-                    llvm::StringRef reg_name_str;
-                    std::string msbit_str;
-                    std::string lsbit_str;
-                    if (regex_match.GetMatchAtIndex(slice_str.c_str(), 1, reg_name_str) &&
-                        regex_match.GetMatchAtIndex(slice_str.c_str(), 2, msbit_str) &&
-                        regex_match.GetMatchAtIndex(slice_str.c_str(), 3, lsbit_str))
-                    {
-                        const uint32_t msbit = StringConvert::ToUInt32(msbit_str.c_str(), UINT32_MAX);
-                        const uint32_t lsbit = StringConvert::ToUInt32(lsbit_str.c_str(), UINT32_MAX);
-                        if (msbit != UINT32_MAX && lsbit != UINT32_MAX)
-                        {
-                            if (msbit > lsbit)
-                            {
-                                const uint32_t msbyte = msbit / 8;
-                                const uint32_t lsbyte = lsbit / 8;
-
-                                ConstString containing_reg_name(reg_name_str);
-
-                                RegisterInfo *containing_reg_info = GetRegisterInfo(containing_reg_name);
-                                if (containing_reg_info)
-                                {
-                                    const uint32_t max_bit = containing_reg_info->byte_size * 8;
-                                    if (msbit < max_bit && lsbit < max_bit)
-                                    {
-                                        m_invalidate_regs_map[containing_reg_info->kinds[eRegisterKindLLDB]].push_back(i);
-                                        m_value_regs_map[i].push_back(containing_reg_info->kinds[eRegisterKindLLDB]);
-                                        m_invalidate_regs_map[i].push_back(containing_reg_info->kinds[eRegisterKindLLDB]);
-
-                                        if (byte_order == eByteOrderLittle)
-                                        {
-                                            success = true;
-                                            reg_info.byte_offset = containing_reg_info->byte_offset + lsbyte;
-                                        }
-                                        else if (byte_order == eByteOrderBig)
-                                        {
-                                            success = true;
-                                            reg_info.byte_offset = containing_reg_info->byte_offset + msbyte;
-                                        }
-                                        else
-                                        {
-                                            assert(!"Invalid byte order");
-                                        }
-                                    }
-                                    else
-                                    {
-                                        if (msbit > max_bit)
-                                            printf("error: msbit (%u) must be less than the bitsize of the register (%u)\n", msbit,
-                                                   max_bit);
-                                        else
-                                            printf("error: lsbit (%u) must be less than the bitsize of the register (%u)\n", lsbit,
-                                                   max_bit);
-                                    }
-                                }
-                                else
-                                {
-                                    printf("error: invalid concrete register \"%s\"\n", containing_reg_name.GetCString());
-                                }
-                            }
-                            else
-                            {
-                                printf("error: msbit (%u) must be greater than lsbit (%u)\n", msbit, lsbit);
-                            }
-                        }
-                        else
-                        {
-                            printf("error: msbit (%u) and lsbit (%u) must be valid\n", msbit, lsbit);
-                        }
-                    }
-                    else
-                    {
-                        // TODO: print error invalid slice string that doesn't follow the format
-                        printf("error: failed to extract regex matches for parsing the register bitfield regex\n");
-                    }
-                }
-                else
-                {
-                    // TODO: print error invalid slice string that doesn't follow the format
-                    printf("error: failed to match against register bitfield regex\n");
-                }
-            }
-            else
-            {
-                StructuredData::Array *composite_reg_list = nullptr;
-                if (reg_info_dict->GetValueForKeyAsArray("composite", composite_reg_list))
-                {
-                    const size_t num_composite_regs = composite_reg_list->GetSize();
-                    if (num_composite_regs > 0)
-                    {
-                        uint32_t composite_offset = UINT32_MAX;
-                        for (uint32_t composite_idx = 0; composite_idx < num_composite_regs; ++composite_idx)
-                        {
-                            ConstString composite_reg_name;
-                            if (composite_reg_list->GetItemAtIndexAsString(composite_idx, composite_reg_name, nullptr))
-                            {
-                                RegisterInfo *composite_reg_info = GetRegisterInfo(composite_reg_name);
-                                if (composite_reg_info)
-                                {
-                                    composite_offset = std::min(composite_offset, composite_reg_info->byte_offset);
-                                    m_value_regs_map[i].push_back(composite_reg_info->kinds[eRegisterKindLLDB]);
-                                    m_invalidate_regs_map[composite_reg_info->kinds[eRegisterKindLLDB]].push_back(i);
-                                    m_invalidate_regs_map[i].push_back(composite_reg_info->kinds[eRegisterKindLLDB]);
-                                }
-                                else
-                                {
-                                    // TODO: print error invalid slice string that doesn't follow the format
-                                    printf("error: failed to find composite register by name: \"%s\"\n", composite_reg_name.GetCString());
-                                }
-                            }
-                            else
-                            {
-                                printf("error: 'composite' list value wasn't a python string\n");
-                            }
-                        }
-                        if (composite_offset != UINT32_MAX)
-                        {
-                            reg_info.byte_offset = composite_offset;
-                            success = m_value_regs_map.find(i) != m_value_regs_map.end();
-                        }
-                        else
-                        {
-                            printf("error: 'composite' registers must specify at least one real register\n");
-                        }
+      }
+    }
+    m_set_reg_nums.resize(m_sets.size());
+  }
+  StructuredData::Array *regs = nullptr;
+  if (!dict.GetValueForKeyAsArray("registers", regs))
+    return 0;
+
+  const uint32_t num_regs = regs->GetSize();
+  //        typedef std::map<std::string, std::vector<std::string> >
+  //        InvalidateNameMap;
+  //        InvalidateNameMap invalidate_map;
+  for (uint32_t i = 0; i < num_regs; ++i) {
+    StructuredData::Dictionary *reg_info_dict = nullptr;
+    if (!regs->GetItemAtIndexAsDictionary(i, reg_info_dict)) {
+      Clear();
+      printf("error: items in the 'registers' array must be dictionaries\n");
+      regs->DumpToStdout();
+      return 0;
+    }
+
+    // { 'name':'rcx'       , 'bitsize' :  64, 'offset' :  16, 'encoding':'uint'
+    // , 'format':'hex'         , 'set': 0, 'ehframe' : 2,
+    // 'dwarf' : 2, 'generic':'arg4', 'alt-name':'arg4', },
+    RegisterInfo reg_info;
+    std::vector<uint32_t> value_regs;
+    std::vector<uint32_t> invalidate_regs;
+    memset(&reg_info, 0, sizeof(reg_info));
+
+    ConstString name_val;
+    ConstString alt_name_val;
+    if (!reg_info_dict->GetValueForKeyAsString("name", name_val, nullptr)) {
+      Clear();
+      printf("error: registers must have valid names and offsets\n");
+      reg_info_dict->DumpToStdout();
+      return 0;
+    }
+    reg_info.name = name_val.GetCString();
+    reg_info_dict->GetValueForKeyAsString("alt-name", alt_name_val, nullptr);
+    reg_info.alt_name = alt_name_val.GetCString();
+
+    reg_info_dict->GetValueForKeyAsInteger("offset", reg_info.byte_offset,
+                                           UINT32_MAX);
+
+    const ByteOrder byte_order = arch.GetByteOrder();
+
+    if (reg_info.byte_offset == UINT32_MAX) {
+      // No offset for this register, see if the register has a value expression
+      // which indicates this register is part of another register. Value
+      // expressions
+      // are things like "rax[31:0]" which state that the current register's
+      // value
+      // is in a concrete register "rax" in bits 31:0. If there is a value
+      // expression
+      // we can calculate the offset
+      bool success = false;
+      std::string slice_str;
+      if (reg_info_dict->GetValueForKeyAsString("slice", slice_str, nullptr)) {
+        // Slices use the following format:
+        //  REGNAME[MSBIT:LSBIT]
+        // REGNAME - name of the register to grab a slice of
+        // MSBIT - the most significant bit at which the current register value
+        // starts at
+        // LSBIT - the least significant bit at which the current register value
+        // ends at
+        static RegularExpression g_bitfield_regex(
+            "([A-Za-z_][A-Za-z0-9_]*)\\[([0-9]+):([0-9]+)\\]");
+        RegularExpression::Match regex_match(3);
+        if (g_bitfield_regex.Execute(slice_str.c_str(), &regex_match)) {
+          llvm::StringRef reg_name_str;
+          std::string msbit_str;
+          std::string lsbit_str;
+          if (regex_match.GetMatchAtIndex(slice_str.c_str(), 1, reg_name_str) &&
+              regex_match.GetMatchAtIndex(slice_str.c_str(), 2, msbit_str) &&
+              regex_match.GetMatchAtIndex(slice_str.c_str(), 3, lsbit_str)) {
+            const uint32_t msbit =
+                StringConvert::ToUInt32(msbit_str.c_str(), UINT32_MAX);
+            const uint32_t lsbit =
+                StringConvert::ToUInt32(lsbit_str.c_str(), UINT32_MAX);
+            if (msbit != UINT32_MAX && lsbit != UINT32_MAX) {
+              if (msbit > lsbit) {
+                const uint32_t msbyte = msbit / 8;
+                const uint32_t lsbyte = lsbit / 8;
+
+                ConstString containing_reg_name(reg_name_str);
+
+                RegisterInfo *containing_reg_info =
+                    GetRegisterInfo(containing_reg_name);
+                if (containing_reg_info) {
+                  const uint32_t max_bit = containing_reg_info->byte_size * 8;
+                  if (msbit < max_bit && lsbit < max_bit) {
+                    m_invalidate_regs_map[containing_reg_info
+                                              ->kinds[eRegisterKindLLDB]]
+                        .push_back(i);
+                    m_value_regs_map[i].push_back(
+                        containing_reg_info->kinds[eRegisterKindLLDB]);
+                    m_invalidate_regs_map[i].push_back(
+                        containing_reg_info->kinds[eRegisterKindLLDB]);
+
+                    if (byte_order == eByteOrderLittle) {
+                      success = true;
+                      reg_info.byte_offset =
+                          containing_reg_info->byte_offset + lsbyte;
+                    } else if (byte_order == eByteOrderBig) {
+                      success = true;
+                      reg_info.byte_offset =
+                          containing_reg_info->byte_offset + msbyte;
+                    } else {
+                      assert(!"Invalid byte order");
                     }
+                  } else {
+                    if (msbit > max_bit)
+                      printf("error: msbit (%u) must be less than the bitsize "
+                             "of the register (%u)\n",
+                             msbit, max_bit);
                     else
-                    {
-                        printf("error: 'composite' list was empty\n");
-                    }
+                      printf("error: lsbit (%u) must be less than the bitsize "
+                             "of the register (%u)\n",
+                             lsbit, max_bit);
+                  }
+                } else {
+                  printf("error: invalid concrete register \"%s\"\n",
+                         containing_reg_name.GetCString());
                 }
-            }
-
-            if (!success)
-            {
-                Clear();
-                reg_info_dict->DumpToStdout();
-                return 0;
-            }
-        }
-
-        int64_t bitsize = 0;
-        if (!reg_info_dict->GetValueForKeyAsInteger("bitsize", bitsize))
-        {
-            Clear();
-            printf("error: invalid or missing 'bitsize' key/value pair in register dictionary\n");
-            reg_info_dict->DumpToStdout();
-            return 0;
-        }
-
-        reg_info.byte_size = bitsize / 8;
-
-        std::string dwarf_opcode_string;
-        if (reg_info_dict->GetValueForKeyAsString ("dynamic_size_dwarf_expr_bytes", dwarf_opcode_string))
-        {
-            reg_info.dynamic_size_dwarf_len = dwarf_opcode_string.length () / 2;
-            assert (reg_info.dynamic_size_dwarf_len > 0);
-
-            std::vector<uint8_t> dwarf_opcode_bytes(reg_info.dynamic_size_dwarf_len);
-            uint32_t j;
-            StringExtractor opcode_extractor;
-            // Swap "dwarf_opcode_string" over into "opcode_extractor"
-            opcode_extractor.GetStringRef ().swap (dwarf_opcode_string);
-            uint32_t ret_val = opcode_extractor.GetHexBytesAvail (dwarf_opcode_bytes);
-            assert (ret_val == reg_info.dynamic_size_dwarf_len);
-
-            for (j = 0; j < reg_info.dynamic_size_dwarf_len; ++j)
-                m_dynamic_reg_size_map[i].push_back(dwarf_opcode_bytes[j]);
-
-            reg_info.dynamic_size_dwarf_expr_bytes = m_dynamic_reg_size_map[i].data ();
-        }
-
-        std::string format_str;
-        if (reg_info_dict->GetValueForKeyAsString("format", format_str, nullptr))
-        {
-            if (Args::StringToFormat(format_str.c_str(), reg_info.format, NULL).Fail())
-            {
-                Clear();
-                printf("error: invalid 'format' value in register dictionary\n");
-                reg_info_dict->DumpToStdout();
-                return 0;
-            }
-        }
-        else
-        {
-            reg_info_dict->GetValueForKeyAsInteger("format", reg_info.format, eFormatHex);
-        }
-
-        std::string encoding_str;
-        if (reg_info_dict->GetValueForKeyAsString("encoding", encoding_str))
-            reg_info.encoding = Args::StringToEncoding(encoding_str.c_str(), eEncodingUint);
-        else
-            reg_info_dict->GetValueForKeyAsInteger("encoding", reg_info.encoding, eEncodingUint);
-
-        size_t set = 0;
-        if (!reg_info_dict->GetValueForKeyAsInteger<size_t>("set", set, -1) || set >= m_sets.size())
-        {
-            Clear();
-            printf("error: invalid 'set' value in register dictionary, valid values are 0 - %i\n", (int)set);
-            reg_info_dict->DumpToStdout();
-            return 0;
-        }
-
-        // Fill in the register numbers
-        reg_info.kinds[lldb::eRegisterKindLLDB] = i;
-        reg_info.kinds[lldb::eRegisterKindProcessPlugin] = i;
-        uint32_t eh_frame_regno = LLDB_INVALID_REGNUM;
-        reg_info_dict->GetValueForKeyAsInteger("gcc", eh_frame_regno, LLDB_INVALID_REGNUM);
-        if (eh_frame_regno == LLDB_INVALID_REGNUM)
-            reg_info_dict->GetValueForKeyAsInteger("ehframe", eh_frame_regno, LLDB_INVALID_REGNUM);
-        reg_info.kinds[lldb::eRegisterKindEHFrame] = eh_frame_regno;
-        reg_info_dict->GetValueForKeyAsInteger("dwarf", reg_info.kinds[lldb::eRegisterKindDWARF], LLDB_INVALID_REGNUM);
-        std::string generic_str;
-        if (reg_info_dict->GetValueForKeyAsString("generic", generic_str))
-            reg_info.kinds[lldb::eRegisterKindGeneric] = Args::StringToGenericRegister(generic_str.c_str());
-        else
-            reg_info_dict->GetValueForKeyAsInteger("generic", reg_info.kinds[lldb::eRegisterKindGeneric], LLDB_INVALID_REGNUM);
-
-        // Check if this register invalidates any other register values when it is modified
-        StructuredData::Array *invalidate_reg_list = nullptr;
-        if (reg_info_dict->GetValueForKeyAsArray("invalidate-regs", invalidate_reg_list))
-        {
-            const size_t num_regs = invalidate_reg_list->GetSize();
-            if (num_regs > 0)
-            {
-                for (uint32_t idx = 0; idx < num_regs; ++idx)
-                {
-                    ConstString invalidate_reg_name;
-                    uint64_t invalidate_reg_num;
-                    if (invalidate_reg_list->GetItemAtIndexAsString(idx, invalidate_reg_name))
-                    {
-                        RegisterInfo *invalidate_reg_info = GetRegisterInfo(invalidate_reg_name);
-                        if (invalidate_reg_info)
-                        {
-                            m_invalidate_regs_map[i].push_back(invalidate_reg_info->kinds[eRegisterKindLLDB]);
-                        }
-                        else
-                        {
-                            // TODO: print error invalid slice string that doesn't follow the format
-                            printf("error: failed to find a 'invalidate-regs' register for \"%s\" while parsing register \"%s\"\n",
-                                   invalidate_reg_name.GetCString(), reg_info.name);
-                        }
-                    }
-                    else if (invalidate_reg_list->GetItemAtIndexAsInteger(idx, invalidate_reg_num))
-                    {
-                        if (invalidate_reg_num != UINT64_MAX)
-                            m_invalidate_regs_map[i].push_back(invalidate_reg_num);
-                        else
-                            printf("error: 'invalidate-regs' list value wasn't a valid integer\n");
-                    }
-                    else
-                    {
-                        printf("error: 'invalidate-regs' list value wasn't a python string or integer\n");
-                    }
+              } else {
+                printf("error: msbit (%u) must be greater than lsbit (%u)\n",
+                       msbit, lsbit);
+              }
+            } else {
+              printf("error: msbit (%u) and lsbit (%u) must be valid\n", msbit,
+                     lsbit);
+            }
+          } else {
+            // TODO: print error invalid slice string that doesn't follow the
+            // format
+            printf("error: failed to extract regex matches for parsing the "
+                   "register bitfield regex\n");
+          }
+        } else {
+          // TODO: print error invalid slice string that doesn't follow the
+          // format
+          printf("error: failed to match against register bitfield regex\n");
+        }
+      } else {
+        StructuredData::Array *composite_reg_list = nullptr;
+        if (reg_info_dict->GetValueForKeyAsArray("composite",
+                                                 composite_reg_list)) {
+          const size_t num_composite_regs = composite_reg_list->GetSize();
+          if (num_composite_regs > 0) {
+            uint32_t composite_offset = UINT32_MAX;
+            for (uint32_t composite_idx = 0; composite_idx < num_composite_regs;
+                 ++composite_idx) {
+              ConstString composite_reg_name;
+              if (composite_reg_list->GetItemAtIndexAsString(
+                      composite_idx, composite_reg_name, nullptr)) {
+                RegisterInfo *composite_reg_info =
+                    GetRegisterInfo(composite_reg_name);
+                if (composite_reg_info) {
+                  composite_offset = std::min(composite_offset,
+                                              composite_reg_info->byte_offset);
+                  m_value_regs_map[i].push_back(
+                      composite_reg_info->kinds[eRegisterKindLLDB]);
+                  m_invalidate_regs_map[composite_reg_info
+                                            ->kinds[eRegisterKindLLDB]]
+                      .push_back(i);
+                  m_invalidate_regs_map[i].push_back(
+                      composite_reg_info->kinds[eRegisterKindLLDB]);
+                } else {
+                  // TODO: print error invalid slice string that doesn't follow
+                  // the format
+                  printf("error: failed to find composite register by name: "
+                         "\"%s\"\n",
+                         composite_reg_name.GetCString());
                 }
-            }
-            else
-            {
-                printf("error: 'invalidate-regs' contained an empty list\n");
-            }
-        }
-
-        // Calculate the register offset
-        const size_t end_reg_offset = reg_info.byte_offset + reg_info.byte_size;
-        if (m_reg_data_byte_size < end_reg_offset)
-            m_reg_data_byte_size = end_reg_offset;
-
-        m_regs.push_back(reg_info);
-        m_set_reg_nums[set].push_back(i);
-    }
-    Finalize(arch);
-    return m_regs.size();
-}
-
-
-void
-DynamicRegisterInfo::AddRegister (RegisterInfo &reg_info,
-                                  ConstString &reg_name, 
-                                  ConstString &reg_alt_name, 
-                                  ConstString &set_name)
-{
-    assert(!m_finalized);
-    const uint32_t reg_num = m_regs.size();
-    reg_info.name = reg_name.AsCString();
-    assert (reg_info.name);
-    reg_info.alt_name = reg_alt_name.AsCString(NULL);
-    uint32_t i;
-    if (reg_info.value_regs)
-    {
-        for (i=0; reg_info.value_regs[i] != LLDB_INVALID_REGNUM; ++i)
-            m_value_regs_map[reg_num].push_back(reg_info.value_regs[i]);
-    }
-    if (reg_info.invalidate_regs)
-    {
-        for (i=0; reg_info.invalidate_regs[i] != LLDB_INVALID_REGNUM; ++i)
-            m_invalidate_regs_map[reg_num].push_back(reg_info.invalidate_regs[i]);
-    }
-    if (reg_info.dynamic_size_dwarf_expr_bytes)
-    {
-        for (i = 0; i < reg_info.dynamic_size_dwarf_len; ++i)
-           m_dynamic_reg_size_map[reg_num].push_back(reg_info.dynamic_size_dwarf_expr_bytes[i]);
-
-        reg_info.dynamic_size_dwarf_expr_bytes = m_dynamic_reg_size_map[reg_num].data ();
-    }
-
-    m_regs.push_back (reg_info);
-    uint32_t set = GetRegisterSetIndexByName (set_name, true);
-    assert (set < m_sets.size());
-    assert (set < m_set_reg_nums.size());
-    assert (set < m_set_names.size());
-    m_set_reg_nums[set].push_back(reg_num);
-    size_t end_reg_offset = reg_info.byte_offset + reg_info.byte_size;
-    if (m_reg_data_byte_size < end_reg_offset)
-        m_reg_data_byte_size = end_reg_offset;
-}
-
-void
-DynamicRegisterInfo::Finalize (const ArchSpec &arch)
-{
-    if (m_finalized)
-        return;
-    
-    m_finalized = true;
-    const size_t num_sets = m_sets.size();
-    for (size_t set = 0; set < num_sets; ++set)
-    {
-        assert (m_sets.size() == m_set_reg_nums.size());
-        m_sets[set].num_registers = m_set_reg_nums[set].size();
-        m_sets[set].registers = &m_set_reg_nums[set][0];
-    }
-    
-    // sort and unique all value registers and make sure each is terminated with
-    // LLDB_INVALID_REGNUM
-    
-    for (reg_to_regs_map::iterator pos = m_value_regs_map.begin(), end = m_value_regs_map.end();
-         pos != end;
-         ++pos)
-    {
-        if (pos->second.size() > 1)
-        {
-            std::sort (pos->second.begin(), pos->second.end());
-            reg_num_collection::iterator unique_end = std::unique (pos->second.begin(), pos->second.end());
-            if (unique_end != pos->second.end())
-                pos->second.erase(unique_end, pos->second.end());
-        }
-        assert (!pos->second.empty());
-        if (pos->second.back() != LLDB_INVALID_REGNUM)
-            pos->second.push_back(LLDB_INVALID_REGNUM);
-    }
-    
-    // Now update all value_regs with each register info as needed
-    const size_t num_regs = m_regs.size();
-    for (size_t i=0; i<num_regs; ++i)
-    {
-        if (m_value_regs_map.find(i) != m_value_regs_map.end())
-            m_regs[i].value_regs = m_value_regs_map[i].data();
-        else
-            m_regs[i].value_regs = NULL;
-    }
-
-    // Expand all invalidation dependencies
-    for (reg_to_regs_map::iterator pos = m_invalidate_regs_map.begin(), end = m_invalidate_regs_map.end();
-         pos != end;
-         ++pos)
-    {
-        const uint32_t reg_num = pos->first;
-        
-        if (m_regs[reg_num].value_regs)
-        {
-            reg_num_collection extra_invalid_regs;
-            for (const uint32_t invalidate_reg_num : pos->second)
-            {
-                reg_to_regs_map::iterator invalidate_pos = m_invalidate_regs_map.find(invalidate_reg_num);
-                if (invalidate_pos != m_invalidate_regs_map.end())
-                {
-                    for (const uint32_t concrete_invalidate_reg_num : invalidate_pos->second)
-                    {
-                        if (concrete_invalidate_reg_num != reg_num)
-                            extra_invalid_regs.push_back(concrete_invalidate_reg_num);
-                    }
-                }
-            }
-            pos->second.insert(pos->second.end(), extra_invalid_regs.begin(), extra_invalid_regs.end());
-        }
+              } else {
+                printf(
+                    "error: 'composite' list value wasn't a python string\n");
+              }
+            }
+            if (composite_offset != UINT32_MAX) {
+              reg_info.byte_offset = composite_offset;
+              success = m_value_regs_map.find(i) != m_value_regs_map.end();
+            } else {
+              printf("error: 'composite' registers must specify at least one "
+                     "real register\n");
+            }
+          } else {
+            printf("error: 'composite' list was empty\n");
+          }
+        }
+      }
+
+      if (!success) {
+        Clear();
+        reg_info_dict->DumpToStdout();
+        return 0;
+      }
     }
 
-    // sort and unique all invalidate registers and make sure each is terminated with
-    // LLDB_INVALID_REGNUM
-    for (reg_to_regs_map::iterator pos = m_invalidate_regs_map.begin(), end = m_invalidate_regs_map.end();
-         pos != end;
-         ++pos)
-    {
-        if (pos->second.size() > 1)
-        {
-            std::sort (pos->second.begin(), pos->second.end());
-            reg_num_collection::iterator unique_end = std::unique (pos->second.begin(), pos->second.end());
-            if (unique_end != pos->second.end())
-                pos->second.erase(unique_end, pos->second.end());
-        }
-        assert (!pos->second.empty());
-        if (pos->second.back() != LLDB_INVALID_REGNUM)
-            pos->second.push_back(LLDB_INVALID_REGNUM);
-    }
-
-    // Now update all invalidate_regs with each register info as needed
-    for (size_t i=0; i<num_regs; ++i)
-    {
-        if (m_invalidate_regs_map.find(i) != m_invalidate_regs_map.end())
-            m_regs[i].invalidate_regs = m_invalidate_regs_map[i].data();
-        else
-            m_regs[i].invalidate_regs = NULL;
-    }
-    
-    // Check if we need to automatically set the generic registers in case
-    // they weren't set
-    bool generic_regs_specified = false;
-    for (const auto &reg: m_regs)
-    {
-        if (reg.kinds[eRegisterKindGeneric] != LLDB_INVALID_REGNUM)
-        {
-            generic_regs_specified = true;
-            break;
-        }
+    int64_t bitsize = 0;
+    if (!reg_info_dict->GetValueForKeyAsInteger("bitsize", bitsize)) {
+      Clear();
+      printf("error: invalid or missing 'bitsize' key/value pair in register "
+             "dictionary\n");
+      reg_info_dict->DumpToStdout();
+      return 0;
+    }
+
+    reg_info.byte_size = bitsize / 8;
+
+    std::string dwarf_opcode_string;
+    if (reg_info_dict->GetValueForKeyAsString("dynamic_size_dwarf_expr_bytes",
+                                              dwarf_opcode_string)) {
+      reg_info.dynamic_size_dwarf_len = dwarf_opcode_string.length() / 2;
+      assert(reg_info.dynamic_size_dwarf_len > 0);
+
+      std::vector<uint8_t> dwarf_opcode_bytes(reg_info.dynamic_size_dwarf_len);
+      uint32_t j;
+      StringExtractor opcode_extractor;
+      // Swap "dwarf_opcode_string" over into "opcode_extractor"
+      opcode_extractor.GetStringRef().swap(dwarf_opcode_string);
+      uint32_t ret_val = opcode_extractor.GetHexBytesAvail(dwarf_opcode_bytes);
+      assert(ret_val == reg_info.dynamic_size_dwarf_len);
+
+      for (j = 0; j < reg_info.dynamic_size_dwarf_len; ++j)
+        m_dynamic_reg_size_map[i].push_back(dwarf_opcode_bytes[j]);
+
+      reg_info.dynamic_size_dwarf_expr_bytes = m_dynamic_reg_size_map[i].data();
+    }
+
+    std::string format_str;
+    if (reg_info_dict->GetValueForKeyAsString("format", format_str, nullptr)) {
+      if (Args::StringToFormat(format_str.c_str(), reg_info.format, NULL)
+              .Fail()) {
+        Clear();
+        printf("error: invalid 'format' value in register dictionary\n");
+        reg_info_dict->DumpToStdout();
+        return 0;
+      }
+    } else {
+      reg_info_dict->GetValueForKeyAsInteger("format", reg_info.format,
+                                             eFormatHex);
+    }
+
+    std::string encoding_str;
+    if (reg_info_dict->GetValueForKeyAsString("encoding", encoding_str))
+      reg_info.encoding =
+          Args::StringToEncoding(encoding_str.c_str(), eEncodingUint);
+    else
+      reg_info_dict->GetValueForKeyAsInteger("encoding", reg_info.encoding,
+                                             eEncodingUint);
+
+    size_t set = 0;
+    if (!reg_info_dict->GetValueForKeyAsInteger<size_t>("set", set, -1) ||
+        set >= m_sets.size()) {
+      Clear();
+      printf("error: invalid 'set' value in register dictionary, valid values "
+             "are 0 - %i\n",
+             (int)set);
+      reg_info_dict->DumpToStdout();
+      return 0;
+    }
+
+    // Fill in the register numbers
+    reg_info.kinds[lldb::eRegisterKindLLDB] = i;
+    reg_info.kinds[lldb::eRegisterKindProcessPlugin] = i;
+    uint32_t eh_frame_regno = LLDB_INVALID_REGNUM;
+    reg_info_dict->GetValueForKeyAsInteger("gcc", eh_frame_regno,
+                                           LLDB_INVALID_REGNUM);
+    if (eh_frame_regno == LLDB_INVALID_REGNUM)
+      reg_info_dict->GetValueForKeyAsInteger("ehframe", eh_frame_regno,
+                                             LLDB_INVALID_REGNUM);
+    reg_info.kinds[lldb::eRegisterKindEHFrame] = eh_frame_regno;
+    reg_info_dict->GetValueForKeyAsInteger(
+        "dwarf", reg_info.kinds[lldb::eRegisterKindDWARF], LLDB_INVALID_REGNUM);
+    std::string generic_str;
+    if (reg_info_dict->GetValueForKeyAsString("generic", generic_str))
+      reg_info.kinds[lldb::eRegisterKindGeneric] =
+          Args::StringToGenericRegister(generic_str.c_str());
+    else
+      reg_info_dict->GetValueForKeyAsInteger(
+          "generic", reg_info.kinds[lldb::eRegisterKindGeneric],
+          LLDB_INVALID_REGNUM);
+
+    // Check if this register invalidates any other register values when it is
+    // modified
+    StructuredData::Array *invalidate_reg_list = nullptr;
+    if (reg_info_dict->GetValueForKeyAsArray("invalidate-regs",
+                                             invalidate_reg_list)) {
+      const size_t num_regs = invalidate_reg_list->GetSize();
+      if (num_regs > 0) {
+        for (uint32_t idx = 0; idx < num_regs; ++idx) {
+          ConstString invalidate_reg_name;
+          uint64_t invalidate_reg_num;
+          if (invalidate_reg_list->GetItemAtIndexAsString(
+                  idx, invalidate_reg_name)) {
+            RegisterInfo *invalidate_reg_info =
+                GetRegisterInfo(invalidate_reg_name);
+            if (invalidate_reg_info) {
+              m_invalidate_regs_map[i].push_back(
+                  invalidate_reg_info->kinds[eRegisterKindLLDB]);
+            } else {
+              // TODO: print error invalid slice string that doesn't follow the
+              // format
+              printf("error: failed to find a 'invalidate-regs' register for "
+                     "\"%s\" while parsing register \"%s\"\n",
+                     invalidate_reg_name.GetCString(), reg_info.name);
+            }
+          } else if (invalidate_reg_list->GetItemAtIndexAsInteger(
+                         idx, invalidate_reg_num)) {
+            if (invalidate_reg_num != UINT64_MAX)
+              m_invalidate_regs_map[i].push_back(invalidate_reg_num);
+            else
+              printf("error: 'invalidate-regs' list value wasn't a valid "
+                     "integer\n");
+          } else {
+            printf("error: 'invalidate-regs' list value wasn't a python string "
+                   "or integer\n");
+          }
+        }
+      } else {
+        printf("error: 'invalidate-regs' contained an empty list\n");
+      }
     }
 
-    if (!generic_regs_specified)
-    {
-        switch (arch.GetMachine())
-        {
-        case llvm::Triple::aarch64:
-        case llvm::Triple::aarch64_be:
-            for (auto &reg: m_regs)
-            {
-                if (strcmp(reg.name, "pc") == 0)
-                    reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_PC;
-                else if ((strcmp(reg.name, "fp") == 0) || (strcmp(reg.name, "x29") == 0))
-                    reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FP;
-                else if ((strcmp(reg.name, "lr") == 0) || (strcmp(reg.name, "x30") == 0))
-                    reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_RA;
-                else if ((strcmp(reg.name, "sp") == 0) || (strcmp(reg.name, "x31") == 0))
-                    reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_SP;
-                else if (strcmp(reg.name, "cpsr") == 0)
-                    reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FLAGS;
-            }
-            break;
-            
-        case llvm::Triple::arm:
-        case llvm::Triple::armeb:
-        case llvm::Triple::thumb:
-        case llvm::Triple::thumbeb:
-            for (auto &reg: m_regs)
-            {
-                if ((strcmp(reg.name, "pc") == 0) || (strcmp(reg.name, "r15") == 0))
-                    reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_PC;
-                else if ((strcmp(reg.name, "sp") == 0) || (strcmp(reg.name, "r13") == 0))
-                    reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_SP;
-                else if ((strcmp(reg.name, "lr") == 0) || (strcmp(reg.name, "r14") == 0))
-                    reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_RA;
-                else if ((strcmp(reg.name, "r7") == 0) && arch.GetTriple().getVendor() == llvm::Triple::Apple)
-                    reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FP;
-                else if ((strcmp(reg.name, "r11") == 0) && arch.GetTriple().getVendor() != llvm::Triple::Apple)
-                    reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FP;
-                else if (strcmp(reg.name, "fp") == 0)
-                    reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FP;
-                else if (strcmp(reg.name, "cpsr") == 0)
-                    reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FLAGS;
-            }
-            break;
-            
-        case llvm::Triple::x86:
-            for (auto &reg: m_regs)
-            {
-                if ((strcmp(reg.name, "eip") == 0) || (strcmp(reg.name, "pc") == 0))
-                    reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_PC;
-                else if ((strcmp(reg.name, "esp") == 0) || (strcmp(reg.name, "sp") == 0))
-                    reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_SP;
-                else if ((strcmp(reg.name, "ebp") == 0) || (strcmp(reg.name, "fp") == 0))
-                    reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FP;
-                else if ((strcmp(reg.name, "eflags") == 0) || (strcmp(reg.name, "flags") == 0))
-                    reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FLAGS;
-            }
-            break;
-
-        case llvm::Triple::x86_64:
-            for (auto &reg: m_regs)
-            {
-                if ((strcmp(reg.name, "rip") == 0) || (strcmp(reg.name, "pc") == 0))
-                    reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_PC;
-                else if ((strcmp(reg.name, "rsp") == 0) || (strcmp(reg.name, "sp") == 0))
-                    reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_SP;
-                else if ((strcmp(reg.name, "rbp") == 0) || (strcmp(reg.name, "fp") == 0))
-                    reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FP;
-                else if ((strcmp(reg.name, "rflags") == 0) || (strcmp(reg.name, "flags") == 0))
-                    reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FLAGS;
-            }
-            break;
+    // Calculate the register offset
+    const size_t end_reg_offset = reg_info.byte_offset + reg_info.byte_size;
+    if (m_reg_data_byte_size < end_reg_offset)
+      m_reg_data_byte_size = end_reg_offset;
 
-        default:
-            break;
-        }
-    }
+    m_regs.push_back(reg_info);
+    m_set_reg_nums[set].push_back(i);
+  }
+  Finalize(arch);
+  return m_regs.size();
+}
+
+void DynamicRegisterInfo::AddRegister(RegisterInfo &reg_info,
+                                      ConstString &reg_name,
+                                      ConstString &reg_alt_name,
+                                      ConstString &set_name) {
+  assert(!m_finalized);
+  const uint32_t reg_num = m_regs.size();
+  reg_info.name = reg_name.AsCString();
+  assert(reg_info.name);
+  reg_info.alt_name = reg_alt_name.AsCString(NULL);
+  uint32_t i;
+  if (reg_info.value_regs) {
+    for (i = 0; reg_info.value_regs[i] != LLDB_INVALID_REGNUM; ++i)
+      m_value_regs_map[reg_num].push_back(reg_info.value_regs[i]);
+  }
+  if (reg_info.invalidate_regs) {
+    for (i = 0; reg_info.invalidate_regs[i] != LLDB_INVALID_REGNUM; ++i)
+      m_invalidate_regs_map[reg_num].push_back(reg_info.invalidate_regs[i]);
+  }
+  if (reg_info.dynamic_size_dwarf_expr_bytes) {
+    for (i = 0; i < reg_info.dynamic_size_dwarf_len; ++i)
+      m_dynamic_reg_size_map[reg_num].push_back(
+          reg_info.dynamic_size_dwarf_expr_bytes[i]);
+
+    reg_info.dynamic_size_dwarf_expr_bytes =
+        m_dynamic_reg_size_map[reg_num].data();
+  }
+
+  m_regs.push_back(reg_info);
+  uint32_t set = GetRegisterSetIndexByName(set_name, true);
+  assert(set < m_sets.size());
+  assert(set < m_set_reg_nums.size());
+  assert(set < m_set_names.size());
+  m_set_reg_nums[set].push_back(reg_num);
+  size_t end_reg_offset = reg_info.byte_offset + reg_info.byte_size;
+  if (m_reg_data_byte_size < end_reg_offset)
+    m_reg_data_byte_size = end_reg_offset;
+}
+
+void DynamicRegisterInfo::Finalize(const ArchSpec &arch) {
+  if (m_finalized)
+    return;
+
+  m_finalized = true;
+  const size_t num_sets = m_sets.size();
+  for (size_t set = 0; set < num_sets; ++set) {
+    assert(m_sets.size() == m_set_reg_nums.size());
+    m_sets[set].num_registers = m_set_reg_nums[set].size();
+    m_sets[set].registers = &m_set_reg_nums[set][0];
+  }
+
+  // sort and unique all value registers and make sure each is terminated with
+  // LLDB_INVALID_REGNUM
+
+  for (reg_to_regs_map::iterator pos = m_value_regs_map.begin(),
+                                 end = m_value_regs_map.end();
+       pos != end; ++pos) {
+    if (pos->second.size() > 1) {
+      std::sort(pos->second.begin(), pos->second.end());
+      reg_num_collection::iterator unique_end =
+          std::unique(pos->second.begin(), pos->second.end());
+      if (unique_end != pos->second.end())
+        pos->second.erase(unique_end, pos->second.end());
+    }
+    assert(!pos->second.empty());
+    if (pos->second.back() != LLDB_INVALID_REGNUM)
+      pos->second.push_back(LLDB_INVALID_REGNUM);
+  }
+
+  // Now update all value_regs with each register info as needed
+  const size_t num_regs = m_regs.size();
+  for (size_t i = 0; i < num_regs; ++i) {
+    if (m_value_regs_map.find(i) != m_value_regs_map.end())
+      m_regs[i].value_regs = m_value_regs_map[i].data();
+    else
+      m_regs[i].value_regs = NULL;
+  }
+
+  // Expand all invalidation dependencies
+  for (reg_to_regs_map::iterator pos = m_invalidate_regs_map.begin(),
+                                 end = m_invalidate_regs_map.end();
+       pos != end; ++pos) {
+    const uint32_t reg_num = pos->first;
+
+    if (m_regs[reg_num].value_regs) {
+      reg_num_collection extra_invalid_regs;
+      for (const uint32_t invalidate_reg_num : pos->second) {
+        reg_to_regs_map::iterator invalidate_pos =
+            m_invalidate_regs_map.find(invalidate_reg_num);
+        if (invalidate_pos != m_invalidate_regs_map.end()) {
+          for (const uint32_t concrete_invalidate_reg_num :
+               invalidate_pos->second) {
+            if (concrete_invalidate_reg_num != reg_num)
+              extra_invalid_regs.push_back(concrete_invalidate_reg_num);
+          }
+        }
+      }
+      pos->second.insert(pos->second.end(), extra_invalid_regs.begin(),
+                         extra_invalid_regs.end());
+    }
+  }
+
+  // sort and unique all invalidate registers and make sure each is terminated
+  // with
+  // LLDB_INVALID_REGNUM
+  for (reg_to_regs_map::iterator pos = m_invalidate_regs_map.begin(),
+                                 end = m_invalidate_regs_map.end();
+       pos != end; ++pos) {
+    if (pos->second.size() > 1) {
+      std::sort(pos->second.begin(), pos->second.end());
+      reg_num_collection::iterator unique_end =
+          std::unique(pos->second.begin(), pos->second.end());
+      if (unique_end != pos->second.end())
+        pos->second.erase(unique_end, pos->second.end());
+    }
+    assert(!pos->second.empty());
+    if (pos->second.back() != LLDB_INVALID_REGNUM)
+      pos->second.push_back(LLDB_INVALID_REGNUM);
+  }
+
+  // Now update all invalidate_regs with each register info as needed
+  for (size_t i = 0; i < num_regs; ++i) {
+    if (m_invalidate_regs_map.find(i) != m_invalidate_regs_map.end())
+      m_regs[i].invalidate_regs = m_invalidate_regs_map[i].data();
+    else
+      m_regs[i].invalidate_regs = NULL;
+  }
+
+  // Check if we need to automatically set the generic registers in case
+  // they weren't set
+  bool generic_regs_specified = false;
+  for (const auto &reg : m_regs) {
+    if (reg.kinds[eRegisterKindGeneric] != LLDB_INVALID_REGNUM) {
+      generic_regs_specified = true;
+      break;
+    }
+  }
+
+  if (!generic_regs_specified) {
+    switch (arch.GetMachine()) {
+    case llvm::Triple::aarch64:
+    case llvm::Triple::aarch64_be:
+      for (auto &reg : m_regs) {
+        if (strcmp(reg.name, "pc") == 0)
+          reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_PC;
+        else if ((strcmp(reg.name, "fp") == 0) ||
+                 (strcmp(reg.name, "x29") == 0))
+          reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FP;
+        else if ((strcmp(reg.name, "lr") == 0) ||
+                 (strcmp(reg.name, "x30") == 0))
+          reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_RA;
+        else if ((strcmp(reg.name, "sp") == 0) ||
+                 (strcmp(reg.name, "x31") == 0))
+          reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_SP;
+        else if (strcmp(reg.name, "cpsr") == 0)
+          reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FLAGS;
+      }
+      break;
+
+    case llvm::Triple::arm:
+    case llvm::Triple::armeb:
+    case llvm::Triple::thumb:
+    case llvm::Triple::thumbeb:
+      for (auto &reg : m_regs) {
+        if ((strcmp(reg.name, "pc") == 0) || (strcmp(reg.name, "r15") == 0))
+          reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_PC;
+        else if ((strcmp(reg.name, "sp") == 0) ||
+                 (strcmp(reg.name, "r13") == 0))
+          reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_SP;
+        else if ((strcmp(reg.name, "lr") == 0) ||
+                 (strcmp(reg.name, "r14") == 0))
+          reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_RA;
+        else if ((strcmp(reg.name, "r7") == 0) &&
+                 arch.GetTriple().getVendor() == llvm::Triple::Apple)
+          reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FP;
+        else if ((strcmp(reg.name, "r11") == 0) &&
+                 arch.GetTriple().getVendor() != llvm::Triple::Apple)
+          reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FP;
+        else if (strcmp(reg.name, "fp") == 0)
+          reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FP;
+        else if (strcmp(reg.name, "cpsr") == 0)
+          reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FLAGS;
+      }
+      break;
+
+    case llvm::Triple::x86:
+      for (auto &reg : m_regs) {
+        if ((strcmp(reg.name, "eip") == 0) || (strcmp(reg.name, "pc") == 0))
+          reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_PC;
+        else if ((strcmp(reg.name, "esp") == 0) ||
+                 (strcmp(reg.name, "sp") == 0))
+          reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_SP;
+        else if ((strcmp(reg.name, "ebp") == 0) ||
+                 (strcmp(reg.name, "fp") == 0))
+          reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FP;
+        else if ((strcmp(reg.name, "eflags") == 0) ||
+                 (strcmp(reg.name, "flags") == 0))
+          reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FLAGS;
+      }
+      break;
+
+    case llvm::Triple::x86_64:
+      for (auto &reg : m_regs) {
+        if ((strcmp(reg.name, "rip") == 0) || (strcmp(reg.name, "pc") == 0))
+          reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_PC;
+        else if ((strcmp(reg.name, "rsp") == 0) ||
+                 (strcmp(reg.name, "sp") == 0))
+          reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_SP;
+        else if ((strcmp(reg.name, "rbp") == 0) ||
+                 (strcmp(reg.name, "fp") == 0))
+          reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FP;
+        else if ((strcmp(reg.name, "rflags") == 0) ||
+                 (strcmp(reg.name, "flags") == 0))
+          reg.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FLAGS;
+      }
+      break;
+
+    default:
+      break;
+    }
+  }
 }
 
-size_t
-DynamicRegisterInfo::GetNumRegisters() const
-{
-    return m_regs.size();
-}
+size_t DynamicRegisterInfo::GetNumRegisters() const { return m_regs.size(); }
 
-size_t
-DynamicRegisterInfo::GetNumRegisterSets() const
-{
-    return m_sets.size();
-}
+size_t DynamicRegisterInfo::GetNumRegisterSets() const { return m_sets.size(); }
 
-size_t
-DynamicRegisterInfo::GetRegisterDataByteSize() const
-{
-    return m_reg_data_byte_size;
+size_t DynamicRegisterInfo::GetRegisterDataByteSize() const {
+  return m_reg_data_byte_size;
 }
 
 const RegisterInfo *
-DynamicRegisterInfo::GetRegisterInfoAtIndex (uint32_t i) const
-{
-    if (i < m_regs.size())
-        return &m_regs[i];
-    return NULL;
-}
-
-RegisterInfo *
-DynamicRegisterInfo::GetRegisterInfoAtIndex (uint32_t i)
-{
-    if (i < m_regs.size())
-        return &m_regs[i];
-    return NULL;
-}
-
-const RegisterSet *
-DynamicRegisterInfo::GetRegisterSet (uint32_t i) const
-{
-    if (i < m_sets.size())
-        return &m_sets[i];
-    return NULL;
+DynamicRegisterInfo::GetRegisterInfoAtIndex(uint32_t i) const {
+  if (i < m_regs.size())
+    return &m_regs[i];
+  return NULL;
+}
+
+RegisterInfo *DynamicRegisterInfo::GetRegisterInfoAtIndex(uint32_t i) {
+  if (i < m_regs.size())
+    return &m_regs[i];
+  return NULL;
+}
+
+const RegisterSet *DynamicRegisterInfo::GetRegisterSet(uint32_t i) const {
+  if (i < m_sets.size())
+    return &m_sets[i];
+  return NULL;
+}
+
+uint32_t DynamicRegisterInfo::GetRegisterSetIndexByName(ConstString &set_name,
+                                                        bool can_create) {
+  name_collection::iterator pos, end = m_set_names.end();
+  for (pos = m_set_names.begin(); pos != end; ++pos) {
+    if (*pos == set_name)
+      return std::distance(m_set_names.begin(), pos);
+  }
+
+  m_set_names.push_back(set_name);
+  m_set_reg_nums.resize(m_set_reg_nums.size() + 1);
+  RegisterSet new_set = {set_name.AsCString(), NULL, 0, NULL};
+  m_sets.push_back(new_set);
+  return m_sets.size() - 1;
 }
 
 uint32_t
-DynamicRegisterInfo::GetRegisterSetIndexByName (ConstString &set_name, bool can_create)
-{
-    name_collection::iterator pos, end = m_set_names.end();
-    for (pos = m_set_names.begin(); pos != end; ++pos)
-    {
-        if (*pos == set_name)
-            return std::distance (m_set_names.begin(), pos);
-    }
-    
-    m_set_names.push_back(set_name);
-    m_set_reg_nums.resize(m_set_reg_nums.size()+1);
-    RegisterSet new_set = { set_name.AsCString(), NULL, 0, NULL };
-    m_sets.push_back (new_set);
-    return m_sets.size() - 1;
-}
-
-uint32_t
-DynamicRegisterInfo::ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t num) const
-{
-    reg_collection::const_iterator pos, end = m_regs.end();
-    for (pos = m_regs.begin(); pos != end; ++pos)
-    {
-        if (pos->kinds[kind] == num)
-            return std::distance (m_regs.begin(), pos);
-    }
-    
-    return LLDB_INVALID_REGNUM;
-}
-
-void
-DynamicRegisterInfo::Clear()
-{
-    m_regs.clear();
-    m_sets.clear();
-    m_set_reg_nums.clear();
-    m_set_names.clear();
-    m_value_regs_map.clear();
-    m_invalidate_regs_map.clear();
-    m_dynamic_reg_size_map.clear();
-    m_reg_data_byte_size = 0;
-    m_finalized = false;
-}
-
-void
-DynamicRegisterInfo::Dump () const
-{
-    StreamFile s(stdout, false);
-    const size_t num_regs = m_regs.size();
-    s.Printf("%p: DynamicRegisterInfo contains %" PRIu64 " registers:\n",
-             static_cast<const void*>(this), static_cast<uint64_t>(num_regs));
-    for (size_t i=0; i<num_regs; ++i)
-    {
-        s.Printf("[%3" PRIu64 "] name = %-10s", (uint64_t)i, m_regs[i].name);
-        s.Printf(", size = %2u, offset = %4u, encoding = %u, format = %-10s",
-                 m_regs[i].byte_size,
-                 m_regs[i].byte_offset,
-                 m_regs[i].encoding,
-                 FormatManager::GetFormatAsCString (m_regs[i].format));
-        if (m_regs[i].kinds[eRegisterKindProcessPlugin] != LLDB_INVALID_REGNUM)
-            s.Printf(", process plugin = %3u", m_regs[i].kinds[eRegisterKindProcessPlugin]);
-        if (m_regs[i].kinds[eRegisterKindDWARF] != LLDB_INVALID_REGNUM)
-            s.Printf(", dwarf = %3u", m_regs[i].kinds[eRegisterKindDWARF]);
-        if (m_regs[i].kinds[eRegisterKindEHFrame] != LLDB_INVALID_REGNUM)
-            s.Printf(", ehframe = %3u", m_regs[i].kinds[eRegisterKindEHFrame]);
-        if (m_regs[i].kinds[eRegisterKindGeneric] != LLDB_INVALID_REGNUM)
-            s.Printf(", generic = %3u", m_regs[i].kinds[eRegisterKindGeneric]);
-        if (m_regs[i].alt_name)
-            s.Printf(", alt-name = %s", m_regs[i].alt_name);
-        if (m_regs[i].value_regs)
-        {
-            s.Printf(", value_regs = [ ");
-            for (size_t j=0; m_regs[i].value_regs[j] != LLDB_INVALID_REGNUM; ++j)
-            {
-                s.Printf("%s ", m_regs[m_regs[i].value_regs[j]].name);
-            }
-            s.Printf("]");
-        }
-        if (m_regs[i].invalidate_regs)
-        {
-            s.Printf(", invalidate_regs = [ ");
-            for (size_t j=0; m_regs[i].invalidate_regs[j] != LLDB_INVALID_REGNUM; ++j)
-            {
-                s.Printf("%s ", m_regs[m_regs[i].invalidate_regs[j]].name);
-            }
-            s.Printf("]");
-        }
-        s.EOL();
-    }
-
-    const size_t num_sets = m_sets.size();
-    s.Printf("%p: DynamicRegisterInfo contains %" PRIu64 " register sets:\n",
-             static_cast<const void*>(this), static_cast<uint64_t>(num_sets));
-    for (size_t i=0; i<num_sets; ++i)
-    {
-        s.Printf("set[%" PRIu64 "] name = %s, regs = [", (uint64_t)i, m_sets[i].name);
-        for (size_t idx=0; idx<m_sets[i].num_registers; ++idx)
-        {
-            s.Printf("%s ", m_regs[m_sets[i].registers[idx]].name);
-        }
-        s.Printf("]\n");
-    }
-}
-
-
-
-lldb_private::RegisterInfo *
-DynamicRegisterInfo::GetRegisterInfo (const lldb_private::ConstString &reg_name)
-{
-    for (auto &reg_info : m_regs)
-    {
-        // We can use pointer comparison since we used a ConstString to set
-        // the "name" member in AddRegister()
-        if (reg_info.name == reg_name.GetCString())
-        {
-            return &reg_info;
-        }
+DynamicRegisterInfo::ConvertRegisterKindToRegisterNumber(uint32_t kind,
+                                                         uint32_t num) const {
+  reg_collection::const_iterator pos, end = m_regs.end();
+  for (pos = m_regs.begin(); pos != end; ++pos) {
+    if (pos->kinds[kind] == num)
+      return std::distance(m_regs.begin(), pos);
+  }
+
+  return LLDB_INVALID_REGNUM;
+}
+
+void DynamicRegisterInfo::Clear() {
+  m_regs.clear();
+  m_sets.clear();
+  m_set_reg_nums.clear();
+  m_set_names.clear();
+  m_value_regs_map.clear();
+  m_invalidate_regs_map.clear();
+  m_dynamic_reg_size_map.clear();
+  m_reg_data_byte_size = 0;
+  m_finalized = false;
+}
+
+void DynamicRegisterInfo::Dump() const {
+  StreamFile s(stdout, false);
+  const size_t num_regs = m_regs.size();
+  s.Printf("%p: DynamicRegisterInfo contains %" PRIu64 " registers:\n",
+           static_cast<const void *>(this), static_cast<uint64_t>(num_regs));
+  for (size_t i = 0; i < num_regs; ++i) {
+    s.Printf("[%3" PRIu64 "] name = %-10s", (uint64_t)i, m_regs[i].name);
+    s.Printf(", size = %2u, offset = %4u, encoding = %u, format = %-10s",
+             m_regs[i].byte_size, m_regs[i].byte_offset, m_regs[i].encoding,
+             FormatManager::GetFormatAsCString(m_regs[i].format));
+    if (m_regs[i].kinds[eRegisterKindProcessPlugin] != LLDB_INVALID_REGNUM)
+      s.Printf(", process plugin = %3u",
+               m_regs[i].kinds[eRegisterKindProcessPlugin]);
+    if (m_regs[i].kinds[eRegisterKindDWARF] != LLDB_INVALID_REGNUM)
+      s.Printf(", dwarf = %3u", m_regs[i].kinds[eRegisterKindDWARF]);
+    if (m_regs[i].kinds[eRegisterKindEHFrame] != LLDB_INVALID_REGNUM)
+      s.Printf(", ehframe = %3u", m_regs[i].kinds[eRegisterKindEHFrame]);
+    if (m_regs[i].kinds[eRegisterKindGeneric] != LLDB_INVALID_REGNUM)
+      s.Printf(", generic = %3u", m_regs[i].kinds[eRegisterKindGeneric]);
+    if (m_regs[i].alt_name)
+      s.Printf(", alt-name = %s", m_regs[i].alt_name);
+    if (m_regs[i].value_regs) {
+      s.Printf(", value_regs = [ ");
+      for (size_t j = 0; m_regs[i].value_regs[j] != LLDB_INVALID_REGNUM; ++j) {
+        s.Printf("%s ", m_regs[m_regs[i].value_regs[j]].name);
+      }
+      s.Printf("]");
+    }
+    if (m_regs[i].invalidate_regs) {
+      s.Printf(", invalidate_regs = [ ");
+      for (size_t j = 0; m_regs[i].invalidate_regs[j] != LLDB_INVALID_REGNUM;
+           ++j) {
+        s.Printf("%s ", m_regs[m_regs[i].invalidate_regs[j]].name);
+      }
+      s.Printf("]");
+    }
+    s.EOL();
+  }
+
+  const size_t num_sets = m_sets.size();
+  s.Printf("%p: DynamicRegisterInfo contains %" PRIu64 " register sets:\n",
+           static_cast<const void *>(this), static_cast<uint64_t>(num_sets));
+  for (size_t i = 0; i < num_sets; ++i) {
+    s.Printf("set[%" PRIu64 "] name = %s, regs = [", (uint64_t)i,
+             m_sets[i].name);
+    for (size_t idx = 0; idx < m_sets[i].num_registers; ++idx) {
+      s.Printf("%s ", m_regs[m_sets[i].registers[idx]].name);
+    }
+    s.Printf("]\n");
+  }
+}
+
+lldb_private::RegisterInfo *DynamicRegisterInfo::GetRegisterInfo(
+    const lldb_private::ConstString &reg_name) {
+  for (auto &reg_info : m_regs) {
+    // We can use pointer comparison since we used a ConstString to set
+    // the "name" member in AddRegister()
+    if (reg_info.name == reg_name.GetCString()) {
+      return &reg_info;
     }
-    return NULL;
+  }
+  return NULL;
 }

Modified: lldb/trunk/source/Plugins/Process/Utility/DynamicRegisterInfo.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/DynamicRegisterInfo.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/DynamicRegisterInfo.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/DynamicRegisterInfo.h Tue Sep  6 15:57:50 2016
@@ -12,93 +12,82 @@
 
 // C Includes
 // C++ Includes
-#include <vector>
 #include <map>
+#include <vector>
 
 // Other libraries and framework includes
 // Project includes
-#include "lldb/lldb-private.h"
 #include "lldb/Core/ConstString.h"
 #include "lldb/Core/StructuredData.h"
+#include "lldb/lldb-private.h"
 
-class DynamicRegisterInfo
-{
+class DynamicRegisterInfo {
 public:
-    DynamicRegisterInfo ();
+  DynamicRegisterInfo();
 
-    DynamicRegisterInfo(const lldb_private::StructuredData::Dictionary &dict,
-                        const lldb_private::ArchSpec &arch);
+  DynamicRegisterInfo(const lldb_private::StructuredData::Dictionary &dict,
+                      const lldb_private::ArchSpec &arch);
 
-    virtual 
-    ~DynamicRegisterInfo ();
+  virtual ~DynamicRegisterInfo();
 
-    size_t SetRegisterInfo(const lldb_private::StructuredData::Dictionary &dict,
-                           const lldb_private::ArchSpec &arch);
+  size_t SetRegisterInfo(const lldb_private::StructuredData::Dictionary &dict,
+                         const lldb_private::ArchSpec &arch);
 
-    void
-    AddRegister (lldb_private::RegisterInfo &reg_info, 
-                 lldb_private::ConstString &reg_name, 
-                 lldb_private::ConstString &reg_alt_name, 
-                 lldb_private::ConstString &set_name);
+  void AddRegister(lldb_private::RegisterInfo &reg_info,
+                   lldb_private::ConstString &reg_name,
+                   lldb_private::ConstString &reg_alt_name,
+                   lldb_private::ConstString &set_name);
 
-    void
-    Finalize (const lldb_private::ArchSpec &arch);
+  void Finalize(const lldb_private::ArchSpec &arch);
 
-    size_t
-    GetNumRegisters() const;
+  size_t GetNumRegisters() const;
 
-    size_t
-    GetNumRegisterSets() const;
+  size_t GetNumRegisterSets() const;
 
-    size_t
-    GetRegisterDataByteSize() const;
+  size_t GetRegisterDataByteSize() const;
 
-    const lldb_private::RegisterInfo *
-    GetRegisterInfoAtIndex (uint32_t i) const;
+  const lldb_private::RegisterInfo *GetRegisterInfoAtIndex(uint32_t i) const;
 
-    lldb_private::RegisterInfo *
-    GetRegisterInfoAtIndex (uint32_t i);
+  lldb_private::RegisterInfo *GetRegisterInfoAtIndex(uint32_t i);
 
-    const lldb_private::RegisterSet *
-    GetRegisterSet (uint32_t i) const;
+  const lldb_private::RegisterSet *GetRegisterSet(uint32_t i) const;
 
-    uint32_t
-    GetRegisterSetIndexByName (lldb_private::ConstString &set_name, bool can_create);
+  uint32_t GetRegisterSetIndexByName(lldb_private::ConstString &set_name,
+                                     bool can_create);
 
-    uint32_t
-    ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t num) const;
+  uint32_t ConvertRegisterKindToRegisterNumber(uint32_t kind,
+                                               uint32_t num) const;
 
-    void
-    Dump () const;
+  void Dump() const;
 
-    void
-    Clear();
+  void Clear();
 
 protected:
-    //------------------------------------------------------------------
-    // Classes that inherit from DynamicRegisterInfo can see and modify these
-    //------------------------------------------------------------------
-    typedef std::vector <lldb_private::RegisterInfo> reg_collection;
-    typedef std::vector <lldb_private::RegisterSet> set_collection;
-    typedef std::vector <uint32_t> reg_num_collection;
-    typedef std::vector <reg_num_collection> set_reg_num_collection;
-    typedef std::vector <lldb_private::ConstString> name_collection;
-    typedef std::map<uint32_t, reg_num_collection> reg_to_regs_map;
-    typedef std::vector <uint8_t> dwarf_opcode;
-    typedef std::map<uint32_t, dwarf_opcode> dynamic_reg_size_map;
-
-    lldb_private::RegisterInfo *
-    GetRegisterInfo (const lldb_private::ConstString &reg_name);
-
-    reg_collection m_regs;
-    set_collection m_sets;
-    set_reg_num_collection m_set_reg_nums;
-    name_collection m_set_names;
-    reg_to_regs_map m_value_regs_map;
-    reg_to_regs_map m_invalidate_regs_map;
-    dynamic_reg_size_map m_dynamic_reg_size_map;
-    size_t m_reg_data_byte_size;   // The number of bytes required to store all registers
-    bool m_finalized;
+  //------------------------------------------------------------------
+  // Classes that inherit from DynamicRegisterInfo can see and modify these
+  //------------------------------------------------------------------
+  typedef std::vector<lldb_private::RegisterInfo> reg_collection;
+  typedef std::vector<lldb_private::RegisterSet> set_collection;
+  typedef std::vector<uint32_t> reg_num_collection;
+  typedef std::vector<reg_num_collection> set_reg_num_collection;
+  typedef std::vector<lldb_private::ConstString> name_collection;
+  typedef std::map<uint32_t, reg_num_collection> reg_to_regs_map;
+  typedef std::vector<uint8_t> dwarf_opcode;
+  typedef std::map<uint32_t, dwarf_opcode> dynamic_reg_size_map;
+
+  lldb_private::RegisterInfo *
+  GetRegisterInfo(const lldb_private::ConstString &reg_name);
+
+  reg_collection m_regs;
+  set_collection m_sets;
+  set_reg_num_collection m_set_reg_nums;
+  name_collection m_set_names;
+  reg_to_regs_map m_value_regs_map;
+  reg_to_regs_map m_invalidate_regs_map;
+  dynamic_reg_size_map m_dynamic_reg_size_map;
+  size_t m_reg_data_byte_size; // The number of bytes required to store all
+                               // registers
+  bool m_finalized;
 };
 
-#endif  // lldb_DynamicRegisterInfo_h_
+#endif // lldb_DynamicRegisterInfo_h_

Modified: lldb/trunk/source/Plugins/Process/Utility/FreeBSDSignals.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/FreeBSDSignals.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/FreeBSDSignals.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/FreeBSDSignals.cpp Tue Sep  6 15:57:50 2016
@@ -15,81 +15,77 @@
 
 using namespace lldb_private;
 
-FreeBSDSignals::FreeBSDSignals()
-    : UnixSignals()
-{
-    Reset();
-}
+FreeBSDSignals::FreeBSDSignals() : UnixSignals() { Reset(); }
 
-void
-FreeBSDSignals::Reset()
-{
-    UnixSignals::Reset();
+void FreeBSDSignals::Reset() {
+  UnixSignals::Reset();
 
-    //        SIGNO   NAME            SUPPRESS STOP   NOTIFY DESCRIPTION 
-    //        ======  ============    ======== ====== ====== ===================================================
-    AddSignal (32,    "SIGTHR",       false,   false, false, "thread interrupt");
-    AddSignal (33,    "SIGLIBRT",     false,   false, false, "reserved by real-time library");
-    AddSignal (65,    "SIGRTMIN",     false,   false, false, "real time signal 0");
-    AddSignal (66,    "SIGRTMIN+1",   false,   false, false, "real time signal 1");
-    AddSignal (67,    "SIGRTMIN+2",   false,   false, false, "real time signal 2");
-    AddSignal (68,    "SIGRTMIN+3",   false,   false, false, "real time signal 3");
-    AddSignal (69,    "SIGRTMIN+4",   false,   false, false, "real time signal 4");
-    AddSignal (70,    "SIGRTMIN+5",   false,   false, false, "real time signal 5");
-    AddSignal (71,    "SIGRTMIN+6",   false,   false, false, "real time signal 6");
-    AddSignal (72,    "SIGRTMIN+7",   false,   false, false, "real time signal 7");
-    AddSignal (73,    "SIGRTMIN+8",   false,   false, false, "real time signal 8");
-    AddSignal (74,    "SIGRTMIN+9",   false,   false, false, "real time signal 9");
-    AddSignal (75,    "SIGRTMIN+10",  false,   false, false, "real time signal 10");
-    AddSignal (76,    "SIGRTMIN+11",  false,   false, false, "real time signal 11");
-    AddSignal (77,    "SIGRTMIN+12",  false,   false, false, "real time signal 12");
-    AddSignal (78,    "SIGRTMIN+13",  false,   false, false, "real time signal 13");
-    AddSignal (79,    "SIGRTMIN+14",  false,   false, false, "real time signal 14");
-    AddSignal (80,    "SIGRTMIN+15",  false,   false, false, "real time signal 15");
-    AddSignal (81,    "SIGRTMIN+16",  false,   false, false, "real time signal 16");
-    AddSignal (82,    "SIGRTMIN+17",  false,   false, false, "real time signal 17");
-    AddSignal (83,    "SIGRTMIN+18",  false,   false, false, "real time signal 18");
-    AddSignal (84,    "SIGRTMIN+19",  false,   false, false, "real time signal 19");
-    AddSignal (85,    "SIGRTMIN+20",  false,   false, false, "real time signal 20");
-    AddSignal (86,    "SIGRTMIN+21",  false,   false, false, "real time signal 21");
-    AddSignal (87,    "SIGRTMIN+22",  false,   false, false, "real time signal 22");
-    AddSignal (88,    "SIGRTMIN+23",  false,   false, false, "real time signal 23");
-    AddSignal (89,    "SIGRTMIN+24",  false,   false, false, "real time signal 24");
-    AddSignal (90,    "SIGRTMIN+25",  false,   false, false, "real time signal 25");
-    AddSignal (91,    "SIGRTMIN+26",  false,   false, false, "real time signal 26");
-    AddSignal (92,    "SIGRTMIN+27",  false,   false, false, "real time signal 27");
-    AddSignal (93,    "SIGRTMIN+28",  false,   false, false, "real time signal 28");
-    AddSignal (94,    "SIGRTMIN+29",  false,   false, false, "real time signal 29");
-    AddSignal (95,    "SIGRTMIN+30",  false,   false, false, "real time signal 30");
-    AddSignal (96,    "SIGRTMAX-30",  false,   false, false, "real time signal 31");
-    AddSignal (97,    "SIGRTMAX-29",  false,   false, false, "real time signal 32");
-    AddSignal (98,    "SIGRTMAX-28",  false,   false, false, "real time signal 33");
-    AddSignal (99,    "SIGRTMAX-27",  false,   false, false, "real time signal 34");
-    AddSignal (100,   "SIGRTMAX-26",  false,   false, false, "real time signal 35");
-    AddSignal (101,   "SIGRTMAX-25",  false,   false, false, "real time signal 36");
-    AddSignal (102,   "SIGRTMAX-24",  false,   false, false, "real time signal 37");
-    AddSignal (103,   "SIGRTMAX-23",  false,   false, false, "real time signal 38");
-    AddSignal (104,   "SIGRTMAX-22",  false,   false, false, "real time signal 39");
-    AddSignal (105,   "SIGRTMAX-21",  false,   false, false, "real time signal 40");
-    AddSignal (106,   "SIGRTMAX-20",  false,   false, false, "real time signal 41");
-    AddSignal (107,   "SIGRTMAX-19",  false,   false, false, "real time signal 42");
-    AddSignal (108,   "SIGRTMAX-18",  false,   false, false, "real time signal 43");
-    AddSignal (109,   "SIGRTMAX-17",  false,   false, false, "real time signal 44");
-    AddSignal (110,   "SIGRTMAX-16",  false,   false, false, "real time signal 45");
-    AddSignal (111,   "SIGRTMAX-15",  false,   false, false, "real time signal 46");
-    AddSignal (112,   "SIGRTMAX-14",  false,   false, false, "real time signal 47");
-    AddSignal (113,   "SIGRTMAX-13",  false,   false, false, "real time signal 48");
-    AddSignal (114,   "SIGRTMAX-12",  false,   false, false, "real time signal 49");
-    AddSignal (115,   "SIGRTMAX-11",  false,   false, false, "real time signal 50");
-    AddSignal (116,   "SIGRTMAX-10",  false,   false, false, "real time signal 51");
-    AddSignal (117,   "SIGRTMAX-9",   false,   false, false, "real time signal 52");
-    AddSignal (118,   "SIGRTMAX-8",   false,   false, false, "real time signal 53");
-    AddSignal (119,   "SIGRTMAX-7",   false,   false, false, "real time signal 54");
-    AddSignal (120,   "SIGRTMAX-6",   false,   false, false, "real time signal 55");
-    AddSignal (121,   "SIGRTMAX-5",   false,   false, false, "real time signal 56");
-    AddSignal (122,   "SIGRTMAX-4",   false,   false, false, "real time signal 57");
-    AddSignal (123,   "SIGRTMAX-3",   false,   false, false, "real time signal 58");
-    AddSignal (124,   "SIGRTMAX-2",   false,   false, false, "real time signal 59");
-    AddSignal (125,   "SIGRTMAX-1",   false,   false, false, "real time signal 60");
-    AddSignal (126,   "SIGRTMAX",     false,   false, false, "real time signal 61");
+  //        SIGNO   NAME            SUPPRESS STOP   NOTIFY DESCRIPTION
+  //        ======  ============    ======== ====== ======
+  //        ===================================================
+  AddSignal(32, "SIGTHR", false, false, false, "thread interrupt");
+  AddSignal(33, "SIGLIBRT", false, false, false,
+            "reserved by real-time library");
+  AddSignal(65, "SIGRTMIN", false, false, false, "real time signal 0");
+  AddSignal(66, "SIGRTMIN+1", false, false, false, "real time signal 1");
+  AddSignal(67, "SIGRTMIN+2", false, false, false, "real time signal 2");
+  AddSignal(68, "SIGRTMIN+3", false, false, false, "real time signal 3");
+  AddSignal(69, "SIGRTMIN+4", false, false, false, "real time signal 4");
+  AddSignal(70, "SIGRTMIN+5", false, false, false, "real time signal 5");
+  AddSignal(71, "SIGRTMIN+6", false, false, false, "real time signal 6");
+  AddSignal(72, "SIGRTMIN+7", false, false, false, "real time signal 7");
+  AddSignal(73, "SIGRTMIN+8", false, false, false, "real time signal 8");
+  AddSignal(74, "SIGRTMIN+9", false, false, false, "real time signal 9");
+  AddSignal(75, "SIGRTMIN+10", false, false, false, "real time signal 10");
+  AddSignal(76, "SIGRTMIN+11", false, false, false, "real time signal 11");
+  AddSignal(77, "SIGRTMIN+12", false, false, false, "real time signal 12");
+  AddSignal(78, "SIGRTMIN+13", false, false, false, "real time signal 13");
+  AddSignal(79, "SIGRTMIN+14", false, false, false, "real time signal 14");
+  AddSignal(80, "SIGRTMIN+15", false, false, false, "real time signal 15");
+  AddSignal(81, "SIGRTMIN+16", false, false, false, "real time signal 16");
+  AddSignal(82, "SIGRTMIN+17", false, false, false, "real time signal 17");
+  AddSignal(83, "SIGRTMIN+18", false, false, false, "real time signal 18");
+  AddSignal(84, "SIGRTMIN+19", false, false, false, "real time signal 19");
+  AddSignal(85, "SIGRTMIN+20", false, false, false, "real time signal 20");
+  AddSignal(86, "SIGRTMIN+21", false, false, false, "real time signal 21");
+  AddSignal(87, "SIGRTMIN+22", false, false, false, "real time signal 22");
+  AddSignal(88, "SIGRTMIN+23", false, false, false, "real time signal 23");
+  AddSignal(89, "SIGRTMIN+24", false, false, false, "real time signal 24");
+  AddSignal(90, "SIGRTMIN+25", false, false, false, "real time signal 25");
+  AddSignal(91, "SIGRTMIN+26", false, false, false, "real time signal 26");
+  AddSignal(92, "SIGRTMIN+27", false, false, false, "real time signal 27");
+  AddSignal(93, "SIGRTMIN+28", false, false, false, "real time signal 28");
+  AddSignal(94, "SIGRTMIN+29", false, false, false, "real time signal 29");
+  AddSignal(95, "SIGRTMIN+30", false, false, false, "real time signal 30");
+  AddSignal(96, "SIGRTMAX-30", false, false, false, "real time signal 31");
+  AddSignal(97, "SIGRTMAX-29", false, false, false, "real time signal 32");
+  AddSignal(98, "SIGRTMAX-28", false, false, false, "real time signal 33");
+  AddSignal(99, "SIGRTMAX-27", false, false, false, "real time signal 34");
+  AddSignal(100, "SIGRTMAX-26", false, false, false, "real time signal 35");
+  AddSignal(101, "SIGRTMAX-25", false, false, false, "real time signal 36");
+  AddSignal(102, "SIGRTMAX-24", false, false, false, "real time signal 37");
+  AddSignal(103, "SIGRTMAX-23", false, false, false, "real time signal 38");
+  AddSignal(104, "SIGRTMAX-22", false, false, false, "real time signal 39");
+  AddSignal(105, "SIGRTMAX-21", false, false, false, "real time signal 40");
+  AddSignal(106, "SIGRTMAX-20", false, false, false, "real time signal 41");
+  AddSignal(107, "SIGRTMAX-19", false, false, false, "real time signal 42");
+  AddSignal(108, "SIGRTMAX-18", false, false, false, "real time signal 43");
+  AddSignal(109, "SIGRTMAX-17", false, false, false, "real time signal 44");
+  AddSignal(110, "SIGRTMAX-16", false, false, false, "real time signal 45");
+  AddSignal(111, "SIGRTMAX-15", false, false, false, "real time signal 46");
+  AddSignal(112, "SIGRTMAX-14", false, false, false, "real time signal 47");
+  AddSignal(113, "SIGRTMAX-13", false, false, false, "real time signal 48");
+  AddSignal(114, "SIGRTMAX-12", false, false, false, "real time signal 49");
+  AddSignal(115, "SIGRTMAX-11", false, false, false, "real time signal 50");
+  AddSignal(116, "SIGRTMAX-10", false, false, false, "real time signal 51");
+  AddSignal(117, "SIGRTMAX-9", false, false, false, "real time signal 52");
+  AddSignal(118, "SIGRTMAX-8", false, false, false, "real time signal 53");
+  AddSignal(119, "SIGRTMAX-7", false, false, false, "real time signal 54");
+  AddSignal(120, "SIGRTMAX-6", false, false, false, "real time signal 55");
+  AddSignal(121, "SIGRTMAX-5", false, false, false, "real time signal 56");
+  AddSignal(122, "SIGRTMAX-4", false, false, false, "real time signal 57");
+  AddSignal(123, "SIGRTMAX-3", false, false, false, "real time signal 58");
+  AddSignal(124, "SIGRTMAX-2", false, false, false, "real time signal 59");
+  AddSignal(125, "SIGRTMAX-1", false, false, false, "real time signal 60");
+  AddSignal(126, "SIGRTMAX", false, false, false, "real time signal 61");
 }

Modified: lldb/trunk/source/Plugins/Process/Utility/FreeBSDSignals.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/FreeBSDSignals.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/FreeBSDSignals.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/FreeBSDSignals.h Tue Sep  6 15:57:50 2016
@@ -16,14 +16,12 @@
 namespace lldb_private {
 
 /// FreeBSD specific set of Unix signals.
-class FreeBSDSignals : public UnixSignals
-{
+class FreeBSDSignals : public UnixSignals {
 public:
-    FreeBSDSignals();
+  FreeBSDSignals();
 
 private:
-    void
-    Reset() override;
+  void Reset() override;
 };
 
 } // namespace lldb_private

Modified: lldb/trunk/source/Plugins/Process/Utility/GDBRemoteSignals.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/GDBRemoteSignals.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/GDBRemoteSignals.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/GDBRemoteSignals.cpp Tue Sep  6 15:57:50 2016
@@ -14,19 +14,9 @@
 
 using namespace lldb_private;
 
-GDBRemoteSignals::GDBRemoteSignals()
-    : UnixSignals()
-{
-    Reset();
-}
+GDBRemoteSignals::GDBRemoteSignals() : UnixSignals() { Reset(); }
 
 GDBRemoteSignals::GDBRemoteSignals(const lldb::UnixSignalsSP &rhs)
-    : UnixSignals(*rhs)
-{
-}
+    : UnixSignals(*rhs) {}
 
-void
-GDBRemoteSignals::Reset()
-{
-    m_signals.clear();
-}
+void GDBRemoteSignals::Reset() { m_signals.clear(); }

Modified: lldb/trunk/source/Plugins/Process/Utility/GDBRemoteSignals.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/GDBRemoteSignals.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/GDBRemoteSignals.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/GDBRemoteSignals.h Tue Sep  6 15:57:50 2016
@@ -19,16 +19,14 @@
 namespace lldb_private {
 
 /// Empty set of Unix signals to be filled by PlatformRemoteGDBServer
-class GDBRemoteSignals : public UnixSignals
-{
+class GDBRemoteSignals : public UnixSignals {
 public:
-    GDBRemoteSignals();
+  GDBRemoteSignals();
 
-    GDBRemoteSignals(const lldb::UnixSignalsSP &rhs);
+  GDBRemoteSignals(const lldb::UnixSignalsSP &rhs);
 
 private:
-    void
-    Reset() override;
+  void Reset() override;
 };
 
 } // namespace lldb_private

Modified: lldb/trunk/source/Plugins/Process/Utility/HistoryThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/HistoryThread.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/HistoryThread.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/HistoryThread.cpp Tue Sep  6 15:57:50 2016
@@ -9,91 +9,75 @@
 
 #include "lldb/lldb-private.h"
 
-#include "Plugins/Process/Utility/HistoryUnwind.h"
 #include "Plugins/Process/Utility/HistoryThread.h"
+#include "Plugins/Process/Utility/HistoryUnwind.h"
 #include "Plugins/Process/Utility/RegisterContextHistory.h"
 
 #include "lldb/Core/Log.h"
-#include "lldb/Target/StackFrameList.h"
 #include "lldb/Target/Process.h"
+#include "lldb/Target/StackFrameList.h"
 
 using namespace lldb;
 using namespace lldb_private;
 
 //  Constructor
 
-HistoryThread::HistoryThread(lldb_private::Process &process, lldb::tid_t tid, std::vector<lldb::addr_t> pcs,
-                             uint32_t stop_id, bool stop_id_is_valid)
-    : Thread(process, tid, true),
-      m_framelist_mutex(),
-      m_framelist(),
-      m_pcs(pcs),
-      m_stop_id(stop_id),
-      m_stop_id_is_valid(stop_id_is_valid),
-      m_extended_unwind_token(LLDB_INVALID_ADDRESS),
-      m_queue_name(),
-      m_thread_name(),
-      m_originating_unique_thread_id(tid),
-      m_queue_id(LLDB_INVALID_QUEUE_ID)
-{
-    m_unwinder_ap.reset(new HistoryUnwind(*this, pcs, stop_id_is_valid));
-    Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
-    if (log)
-        log->Printf("%p HistoryThread::HistoryThread", static_cast<void *>(this));
+HistoryThread::HistoryThread(lldb_private::Process &process, lldb::tid_t tid,
+                             std::vector<lldb::addr_t> pcs, uint32_t stop_id,
+                             bool stop_id_is_valid)
+    : Thread(process, tid, true), m_framelist_mutex(), m_framelist(),
+      m_pcs(pcs), m_stop_id(stop_id), m_stop_id_is_valid(stop_id_is_valid),
+      m_extended_unwind_token(LLDB_INVALID_ADDRESS), m_queue_name(),
+      m_thread_name(), m_originating_unique_thread_id(tid),
+      m_queue_id(LLDB_INVALID_QUEUE_ID) {
+  m_unwinder_ap.reset(new HistoryUnwind(*this, pcs, stop_id_is_valid));
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
+  if (log)
+    log->Printf("%p HistoryThread::HistoryThread", static_cast<void *>(this));
 }
 
 //  Destructor
 
-HistoryThread::~HistoryThread ()
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
-    if (log)
-        log->Printf ("%p HistoryThread::~HistoryThread (tid=0x%" PRIx64 ")",
-                     static_cast<void*>(this), GetID());
-    DestroyThread();
+HistoryThread::~HistoryThread() {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
+  if (log)
+    log->Printf("%p HistoryThread::~HistoryThread (tid=0x%" PRIx64 ")",
+                static_cast<void *>(this), GetID());
+  DestroyThread();
 }
 
-lldb::RegisterContextSP
-HistoryThread::GetRegisterContext ()
-{
-    RegisterContextSP rctx ;
-    if (m_pcs.size() > 0)
-    {
-        rctx.reset (new RegisterContextHistory (*this, 0, GetProcess()->GetAddressByteSize(), m_pcs[0]));
-    }
-    return rctx;
-
+lldb::RegisterContextSP HistoryThread::GetRegisterContext() {
+  RegisterContextSP rctx;
+  if (m_pcs.size() > 0) {
+    rctx.reset(new RegisterContextHistory(
+        *this, 0, GetProcess()->GetAddressByteSize(), m_pcs[0]));
+  }
+  return rctx;
 }
 
 lldb::RegisterContextSP
-HistoryThread::CreateRegisterContextForFrame (StackFrame *frame)
-{
-    return m_unwinder_ap->CreateRegisterContextForFrame (frame);
-}
-
-lldb::StackFrameListSP
-HistoryThread::GetStackFrameList ()
-{
-    // FIXME do not throw away the lock after we acquire it..
-    std::unique_lock<std::mutex> lock(m_framelist_mutex);
-    lock.unlock();
-    if (m_framelist.get() == NULL)
-    {
-        m_framelist.reset (new StackFrameList (*this, StackFrameListSP(), true));
-    }
-
-    return m_framelist;
+HistoryThread::CreateRegisterContextForFrame(StackFrame *frame) {
+  return m_unwinder_ap->CreateRegisterContextForFrame(frame);
 }
 
-uint32_t
-HistoryThread::GetExtendedBacktraceOriginatingIndexID ()
-{
-    if (m_originating_unique_thread_id != LLDB_INVALID_THREAD_ID)
-    {
-        if (GetProcess()->HasAssignedIndexIDToThread (m_originating_unique_thread_id))
-        {
-            return GetProcess()->AssignIndexIDToThread (m_originating_unique_thread_id);
-        }
+lldb::StackFrameListSP HistoryThread::GetStackFrameList() {
+  // FIXME do not throw away the lock after we acquire it..
+  std::unique_lock<std::mutex> lock(m_framelist_mutex);
+  lock.unlock();
+  if (m_framelist.get() == NULL) {
+    m_framelist.reset(new StackFrameList(*this, StackFrameListSP(), true));
+  }
+
+  return m_framelist;
+}
+
+uint32_t HistoryThread::GetExtendedBacktraceOriginatingIndexID() {
+  if (m_originating_unique_thread_id != LLDB_INVALID_THREAD_ID) {
+    if (GetProcess()->HasAssignedIndexIDToThread(
+            m_originating_unique_thread_id)) {
+      return GetProcess()->AssignIndexIDToThread(
+          m_originating_unique_thread_id);
     }
-    return LLDB_INVALID_THREAD_ID;
+  }
+  return LLDB_INVALID_THREAD_ID;
 }

Modified: lldb/trunk/source/Plugins/Process/Utility/HistoryThread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/HistoryThread.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/HistoryThread.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/HistoryThread.h Tue Sep  6 15:57:50 2016
@@ -16,7 +16,6 @@
 
 // Other libraries and framework includes
 // Project includes
-#include "lldb/lldb-private.h"
 #include "lldb/Core/Broadcaster.h"
 #include "lldb/Core/Event.h"
 #include "lldb/Core/UserID.h"
@@ -24,119 +23,78 @@
 #include "lldb/Target/ExecutionContextScope.h"
 #include "lldb/Target/StackFrameList.h"
 #include "lldb/Target/Thread.h"
+#include "lldb/lldb-private.h"
 
 namespace lldb_private {
 
 //----------------------------------------------------------------------
 /// @class HistoryThread HistoryThread.h "HistoryThread.h"
-/// @brief A thread object representing a backtrace from a previous point in the process execution
+/// @brief A thread object representing a backtrace from a previous point in the
+/// process execution
 ///
 /// This subclass of Thread is used to provide a backtrace from earlier in
-/// process execution.  It is given a backtrace list of pc addresses and 
+/// process execution.  It is given a backtrace list of pc addresses and
 /// optionally a stop_id of when those pc addresses were collected, and it will
 /// create stack frames for them.
 //----------------------------------------------------------------------
 
-class HistoryThread : public lldb_private::Thread
-{
+class HistoryThread : public lldb_private::Thread {
 public:
-    HistoryThread (lldb_private::Process &process, lldb::tid_t tid, std::vector<lldb::addr_t> pcs, uint32_t stop_id, bool stop_id_is_valid);
+  HistoryThread(lldb_private::Process &process, lldb::tid_t tid,
+                std::vector<lldb::addr_t> pcs, uint32_t stop_id,
+                bool stop_id_is_valid);
+
+  ~HistoryThread() override;
+
+  lldb::RegisterContextSP GetRegisterContext() override;
+
+  lldb::RegisterContextSP
+  CreateRegisterContextForFrame(StackFrame *frame) override;
+
+  void RefreshStateAfterStop() override {}
+
+  bool CalculateStopInfo() override { return false; }
+
+  void SetExtendedBacktraceToken(uint64_t token) override {
+    m_extended_unwind_token = token;
+  }
+
+  uint64_t GetExtendedBacktraceToken() override {
+    return m_extended_unwind_token;
+  }
+
+  const char *GetQueueName() override { return m_queue_name.c_str(); }
+
+  void SetQueueName(const char *name) override { m_queue_name = name; }
+
+  lldb::queue_id_t GetQueueID() override { return m_queue_id; }
+
+  void SetQueueID(lldb::queue_id_t queue) override { m_queue_id = queue; }
+
+  const char *GetThreadName() { return m_thread_name.c_str(); }
+
+  uint32_t GetExtendedBacktraceOriginatingIndexID() override;
 
-    ~HistoryThread() override;
+  void SetThreadName(const char *name) { m_thread_name = name; }
 
-    lldb::RegisterContextSP
-    GetRegisterContext() override;
+  const char *GetName() override { return m_thread_name.c_str(); }
 
-    lldb::RegisterContextSP
-    CreateRegisterContextForFrame(StackFrame *frame) override;
-
-    void
-    RefreshStateAfterStop() override { }
-
-    bool
-    CalculateStopInfo() override
-    {
-        return false;
-    }
-
-    void 
-    SetExtendedBacktraceToken(uint64_t token) override
-    {
-        m_extended_unwind_token = token;
-    }
-
-    uint64_t
-    GetExtendedBacktraceToken() override
-    {
-        return m_extended_unwind_token;
-    }
-
-    const char *
-    GetQueueName() override
-    {
-        return m_queue_name.c_str();
-    }
-
-    void
-    SetQueueName(const char *name) override
-    {
-        m_queue_name = name;
-    }
-
-    lldb::queue_id_t
-    GetQueueID() override
-    {
-        return m_queue_id;
-    }
-
-    void
-    SetQueueID(lldb::queue_id_t queue) override
-    {
-        m_queue_id = queue;
-    }
-
-    const char *
-    GetThreadName ()
-    {
-        return m_thread_name.c_str();
-    }
-
-    uint32_t
-    GetExtendedBacktraceOriginatingIndexID() override;
-
-    void
-    SetThreadName (const char *name)
-    {
-        m_thread_name = name;
-    }
-    
-    const char *
-    GetName() override
-    {
-        return m_thread_name.c_str();
-    }
-    
-    void
-    SetName(const char *name) override
-    {
-        m_thread_name = name;
-    }
+  void SetName(const char *name) override { m_thread_name = name; }
 
 protected:
-    virtual lldb::StackFrameListSP
-    GetStackFrameList ();
+  virtual lldb::StackFrameListSP GetStackFrameList();
 
-    mutable std::mutex m_framelist_mutex;
-    lldb::StackFrameListSP      m_framelist;
-    std::vector<lldb::addr_t>   m_pcs;
-    uint32_t                    m_stop_id;
-    bool                        m_stop_id_is_valid;
-
-    uint64_t                    m_extended_unwind_token;
-    std::string                 m_queue_name;
-    std::string                 m_thread_name;
-    lldb::tid_t                 m_originating_unique_thread_id;
-    lldb::queue_id_t            m_queue_id;
+  mutable std::mutex m_framelist_mutex;
+  lldb::StackFrameListSP m_framelist;
+  std::vector<lldb::addr_t> m_pcs;
+  uint32_t m_stop_id;
+  bool m_stop_id_is_valid;
+
+  uint64_t m_extended_unwind_token;
+  std::string m_queue_name;
+  std::string m_thread_name;
+  lldb::tid_t m_originating_unique_thread_id;
+  lldb::queue_id_t m_queue_id;
 };
 
 } // namespace lldb_private

Modified: lldb/trunk/source/Plugins/Process/Utility/HistoryUnwind.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/HistoryUnwind.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/HistoryUnwind.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/HistoryUnwind.cpp Tue Sep  6 15:57:50 2016
@@ -9,75 +9,59 @@
 
 #include "lldb/lldb-private.h"
 
-#include "Plugins/Process/Utility/RegisterContextHistory.h"
 #include "Plugins/Process/Utility/HistoryUnwind.h"
+#include "Plugins/Process/Utility/RegisterContextHistory.h"
 
-#include "lldb/Target/StackFrame.h"
-#include "lldb/Target/Thread.h"
 #include "lldb/Target/Process.h"
+#include "lldb/Target/StackFrame.h"
 #include "lldb/Target/Target.h"
+#include "lldb/Target/Thread.h"
 
 using namespace lldb;
 using namespace lldb_private;
 
-// Constructor 
+// Constructor
 
-HistoryUnwind::HistoryUnwind (Thread &thread,
-                              std::vector<lldb::addr_t> pcs,
-                              bool stop_id_is_valid) :
-        Unwind (thread),
-        m_pcs (pcs),
-        m_stop_id_is_valid (stop_id_is_valid)
-{
-}
+HistoryUnwind::HistoryUnwind(Thread &thread, std::vector<lldb::addr_t> pcs,
+                             bool stop_id_is_valid)
+    : Unwind(thread), m_pcs(pcs), m_stop_id_is_valid(stop_id_is_valid) {}
 
 // Destructor
 
-HistoryUnwind::~HistoryUnwind ()
-{
-}
+HistoryUnwind::~HistoryUnwind() {}
 
-void
-HistoryUnwind::DoClear ()
-{
-    std::lock_guard<std::recursive_mutex> guard(m_unwind_mutex);
-    m_pcs.clear();
-    m_stop_id_is_valid = false;
+void HistoryUnwind::DoClear() {
+  std::lock_guard<std::recursive_mutex> guard(m_unwind_mutex);
+  m_pcs.clear();
+  m_stop_id_is_valid = false;
 }
 
 lldb::RegisterContextSP
-HistoryUnwind::DoCreateRegisterContextForFrame (StackFrame *frame)
-{
-    RegisterContextSP rctx;
-    if (frame)
-    {
-        addr_t pc = frame->GetFrameCodeAddress().GetLoadAddress (&frame->GetThread()->GetProcess()->GetTarget());
-        if (pc != LLDB_INVALID_ADDRESS)
-        {
-            rctx.reset (new RegisterContextHistory (*frame->GetThread().get(), frame->GetConcreteFrameIndex(), 
-                        frame->GetThread()->GetProcess()->GetAddressByteSize(), pc));
-        }
+HistoryUnwind::DoCreateRegisterContextForFrame(StackFrame *frame) {
+  RegisterContextSP rctx;
+  if (frame) {
+    addr_t pc = frame->GetFrameCodeAddress().GetLoadAddress(
+        &frame->GetThread()->GetProcess()->GetTarget());
+    if (pc != LLDB_INVALID_ADDRESS) {
+      rctx.reset(new RegisterContextHistory(
+          *frame->GetThread().get(), frame->GetConcreteFrameIndex(),
+          frame->GetThread()->GetProcess()->GetAddressByteSize(), pc));
     }
-    return rctx;
+  }
+  return rctx;
 }
 
-bool
-HistoryUnwind::DoGetFrameInfoAtIndex (uint32_t frame_idx, lldb::addr_t& cfa, lldb::addr_t& pc)
-{
-    // FIXME do not throw away the lock after we acquire it..
-    std::unique_lock<std::recursive_mutex> guard(m_unwind_mutex);
-    guard.unlock();
-    if (frame_idx < m_pcs.size())
-    {
-        cfa = frame_idx;
-        pc = m_pcs[frame_idx];
-        return true;
-    }
-    return false;
+bool HistoryUnwind::DoGetFrameInfoAtIndex(uint32_t frame_idx, lldb::addr_t &cfa,
+                                          lldb::addr_t &pc) {
+  // FIXME do not throw away the lock after we acquire it..
+  std::unique_lock<std::recursive_mutex> guard(m_unwind_mutex);
+  guard.unlock();
+  if (frame_idx < m_pcs.size()) {
+    cfa = frame_idx;
+    pc = m_pcs[frame_idx];
+    return true;
+  }
+  return false;
 }
 
-uint32_t
-HistoryUnwind::DoGetFrameCount ()
-{
-    return m_pcs.size();
-}
+uint32_t HistoryUnwind::DoGetFrameCount() { return m_pcs.size(); }

Modified: lldb/trunk/source/Plugins/Process/Utility/HistoryUnwind.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/HistoryUnwind.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/HistoryUnwind.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/HistoryUnwind.h Tue Sep  6 15:57:50 2016
@@ -16,36 +16,31 @@
 
 // Other libraries and framework includes
 // Project includes
-#include "lldb/lldb-private.h"
 #include "lldb/Target/Unwind.h"
+#include "lldb/lldb-private.h"
 
 namespace lldb_private {
 
-class HistoryUnwind : public lldb_private::Unwind
-{
+class HistoryUnwind : public lldb_private::Unwind {
 public:
-    HistoryUnwind (Thread &thread, std::vector<lldb::addr_t> pcs, bool stop_id_is_valid);
+  HistoryUnwind(Thread &thread, std::vector<lldb::addr_t> pcs,
+                bool stop_id_is_valid);
 
-    ~HistoryUnwind() override;
+  ~HistoryUnwind() override;
 
 protected:
-    void
-    DoClear() override;
+  void DoClear() override;
 
-    lldb::RegisterContextSP
-    DoCreateRegisterContextForFrame(StackFrame *frame) override;
+  lldb::RegisterContextSP
+  DoCreateRegisterContextForFrame(StackFrame *frame) override;
 
-    bool
-    DoGetFrameInfoAtIndex(uint32_t frame_idx,
-                          lldb::addr_t& cfa, 
-                          lldb::addr_t& pc) override;
-    uint32_t
-    DoGetFrameCount() override;
+  bool DoGetFrameInfoAtIndex(uint32_t frame_idx, lldb::addr_t &cfa,
+                             lldb::addr_t &pc) override;
+  uint32_t DoGetFrameCount() override;
 
 private:
-
-    std::vector<lldb::addr_t>   m_pcs;
-    bool                        m_stop_id_is_valid;
+  std::vector<lldb::addr_t> m_pcs;
+  bool m_stop_id_is_valid;
 };
 
 } // namespace lldb_private

Modified: lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp Tue Sep  6 15:57:50 2016
@@ -34,225 +34,207 @@
 using namespace lldb;
 using namespace lldb_private;
 
-bool
-lldb_private::InferiorCallMmap (Process *process,
-                                addr_t &allocated_addr,
-                                addr_t addr,
-                                addr_t length,
-                                unsigned prot,
-                                unsigned flags,
-                                addr_t fd,
-                                addr_t offset)
-{
-    Thread *thread = process->GetThreadList().GetExpressionExecutionThread().get();
-    if (thread == NULL)
-        return false;
-
-    const bool append = true;
-    const bool include_symbols = true;
-    const bool include_inlines = false;
-    SymbolContextList sc_list;
-    const uint32_t count
-      = process->GetTarget().GetImages().FindFunctions (ConstString ("mmap"), 
-                                                        eFunctionNameTypeFull,
-                                                        include_symbols,
-                                                        include_inlines,
-                                                        append, 
-                                                        sc_list);
-    if (count > 0)
-    {
-        SymbolContext sc;
-        if (sc_list.GetContextAtIndex(0, sc))
-        {
-            const uint32_t range_scope = eSymbolContextFunction | eSymbolContextSymbol;
-            const bool use_inline_block_range = false;
-            EvaluateExpressionOptions options;
-            options.SetStopOthers(true);
-            options.SetUnwindOnError(true);
-            options.SetIgnoreBreakpoints(true);
-            options.SetTryAllThreads(true);
-            options.SetDebug (false);
-            options.SetTimeoutUsec(500000);
-            options.SetTrapExceptions(false);
-
-            addr_t prot_arg, flags_arg = 0;
-            if (prot == eMmapProtNone)
-              prot_arg = PROT_NONE;
-            else {
-              prot_arg = 0;
-              if (prot & eMmapProtExec)
-                prot_arg |= PROT_EXEC;
-              if (prot & eMmapProtRead)
-                prot_arg |= PROT_READ;
-              if (prot & eMmapProtWrite)
-                prot_arg |= PROT_WRITE;
-            }
+bool lldb_private::InferiorCallMmap(Process *process, addr_t &allocated_addr,
+                                    addr_t addr, addr_t length, unsigned prot,
+                                    unsigned flags, addr_t fd, addr_t offset) {
+  Thread *thread =
+      process->GetThreadList().GetExpressionExecutionThread().get();
+  if (thread == NULL)
+    return false;
 
-            const ArchSpec arch =  process->GetTarget().GetArchitecture();
-            flags_arg = process->GetTarget().GetPlatform()->ConvertMmapFlagsToPlatform(arch,flags);
+  const bool append = true;
+  const bool include_symbols = true;
+  const bool include_inlines = false;
+  SymbolContextList sc_list;
+  const uint32_t count = process->GetTarget().GetImages().FindFunctions(
+      ConstString("mmap"), eFunctionNameTypeFull, include_symbols,
+      include_inlines, append, sc_list);
+  if (count > 0) {
+    SymbolContext sc;
+    if (sc_list.GetContextAtIndex(0, sc)) {
+      const uint32_t range_scope =
+          eSymbolContextFunction | eSymbolContextSymbol;
+      const bool use_inline_block_range = false;
+      EvaluateExpressionOptions options;
+      options.SetStopOthers(true);
+      options.SetUnwindOnError(true);
+      options.SetIgnoreBreakpoints(true);
+      options.SetTryAllThreads(true);
+      options.SetDebug(false);
+      options.SetTimeoutUsec(500000);
+      options.SetTrapExceptions(false);
+
+      addr_t prot_arg, flags_arg = 0;
+      if (prot == eMmapProtNone)
+        prot_arg = PROT_NONE;
+      else {
+        prot_arg = 0;
+        if (prot & eMmapProtExec)
+          prot_arg |= PROT_EXEC;
+        if (prot & eMmapProtRead)
+          prot_arg |= PROT_READ;
+        if (prot & eMmapProtWrite)
+          prot_arg |= PROT_WRITE;
+      }
+
+      const ArchSpec arch = process->GetTarget().GetArchitecture();
+      flags_arg =
+          process->GetTarget().GetPlatform()->ConvertMmapFlagsToPlatform(arch,
+                                                                         flags);
+
+      AddressRange mmap_range;
+      if (sc.GetAddressRange(range_scope, 0, use_inline_block_range,
+                             mmap_range)) {
+        ClangASTContext *clang_ast_context =
+            process->GetTarget().GetScratchClangASTContext();
+        CompilerType clang_void_ptr_type =
+            clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType();
+        lldb::addr_t args[] = {addr, length, prot_arg, flags_arg, fd, offset};
+        lldb::ThreadPlanSP call_plan_sp(
+            new ThreadPlanCallFunction(*thread, mmap_range.GetBaseAddress(),
+                                       clang_void_ptr_type, args, options));
+        if (call_plan_sp) {
+          DiagnosticManager diagnostics;
 
-            AddressRange mmap_range;
-            if (sc.GetAddressRange(range_scope, 0, use_inline_block_range, mmap_range))
-            {
-                ClangASTContext *clang_ast_context = process->GetTarget().GetScratchClangASTContext();
-                CompilerType clang_void_ptr_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType();
-                lldb::addr_t args[] = { addr, length, prot_arg, flags_arg, fd, offset };
-                lldb::ThreadPlanSP call_plan_sp(new ThreadPlanCallFunction(*thread, mmap_range.GetBaseAddress(),
-                                                                           clang_void_ptr_type, args, options));
-                if (call_plan_sp)
-                {
-                    DiagnosticManager diagnostics;
-
-                    StackFrame *frame = thread->GetStackFrameAtIndex(0).get();
-                    if (frame)
-                    {
-                        ExecutionContext exe_ctx;
-                        frame->CalculateExecutionContext (exe_ctx);
-                        ExpressionResults result = process->RunThreadPlan(exe_ctx, call_plan_sp, options, diagnostics);
-                        if (result == eExpressionCompleted)
-                        {
-
-                            allocated_addr = call_plan_sp->GetReturnValueObject()->GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
-                            if (process->GetAddressByteSize() == 4)
-                            {
-                                if (allocated_addr == UINT32_MAX)
-                                    return false;
-                            }
-                            else if (process->GetAddressByteSize() == 8)
-                            {
-                                if (allocated_addr == UINT64_MAX)
-                                    return false;
-                            }
-                            return true;
-                        }
-                    }
-                }
+          StackFrame *frame = thread->GetStackFrameAtIndex(0).get();
+          if (frame) {
+            ExecutionContext exe_ctx;
+            frame->CalculateExecutionContext(exe_ctx);
+            ExpressionResults result = process->RunThreadPlan(
+                exe_ctx, call_plan_sp, options, diagnostics);
+            if (result == eExpressionCompleted) {
+
+              allocated_addr =
+                  call_plan_sp->GetReturnValueObject()->GetValueAsUnsigned(
+                      LLDB_INVALID_ADDRESS);
+              if (process->GetAddressByteSize() == 4) {
+                if (allocated_addr == UINT32_MAX)
+                  return false;
+              } else if (process->GetAddressByteSize() == 8) {
+                if (allocated_addr == UINT64_MAX)
+                  return false;
+              }
+              return true;
             }
+          }
         }
+      }
     }
+  }
 
-    return false;
+  return false;
 }
 
-bool
-lldb_private::InferiorCallMunmap (Process *process,
-                                  addr_t addr,
-                                  addr_t length)
-{
-   Thread *thread = process->GetThreadList().GetExpressionExecutionThread().get();
-   if (thread == NULL)
-       return false;
-   
-   const bool append = true;
-   const bool include_symbols = true;
-   const bool include_inlines = false;
-   SymbolContextList sc_list;
-   const uint32_t count
-     = process->GetTarget().GetImages().FindFunctions (ConstString ("munmap"), 
-                                                       eFunctionNameTypeFull,
-                                                       include_symbols, 
-                                                       include_inlines,
-                                                       append, 
-                                                       sc_list);
-   if (count > 0)
-   {
-       SymbolContext sc;
-       if (sc_list.GetContextAtIndex(0, sc))
-       {
-            const uint32_t range_scope = eSymbolContextFunction | eSymbolContextSymbol;
-            const bool use_inline_block_range = false;
-            EvaluateExpressionOptions options;
-            options.SetStopOthers(true);
-            options.SetUnwindOnError(true);
-            options.SetIgnoreBreakpoints(true);
-            options.SetTryAllThreads(true);
-            options.SetDebug (false);
-            options.SetTimeoutUsec(500000);
-            options.SetTrapExceptions(false);
-           
-            AddressRange munmap_range;
-            if (sc.GetAddressRange(range_scope, 0, use_inline_block_range, munmap_range))
-            {
-                lldb::addr_t args[] = { addr, length };
-                lldb::ThreadPlanSP call_plan_sp(
-                    new ThreadPlanCallFunction(*thread, munmap_range.GetBaseAddress(), CompilerType(), args, options));
-                if (call_plan_sp)
-                {
-                    DiagnosticManager diagnostics;
-
-                    StackFrame *frame = thread->GetStackFrameAtIndex(0).get();
-                    if (frame)
-                    {
-                        ExecutionContext exe_ctx;
-                        frame->CalculateExecutionContext (exe_ctx);
-                        ExpressionResults result = process->RunThreadPlan(exe_ctx, call_plan_sp, options, diagnostics);
-                        if (result == eExpressionCompleted)
-                        {
-                            return true;
-                        }
-                    }
-                }
+bool lldb_private::InferiorCallMunmap(Process *process, addr_t addr,
+                                      addr_t length) {
+  Thread *thread =
+      process->GetThreadList().GetExpressionExecutionThread().get();
+  if (thread == NULL)
+    return false;
+
+  const bool append = true;
+  const bool include_symbols = true;
+  const bool include_inlines = false;
+  SymbolContextList sc_list;
+  const uint32_t count = process->GetTarget().GetImages().FindFunctions(
+      ConstString("munmap"), eFunctionNameTypeFull, include_symbols,
+      include_inlines, append, sc_list);
+  if (count > 0) {
+    SymbolContext sc;
+    if (sc_list.GetContextAtIndex(0, sc)) {
+      const uint32_t range_scope =
+          eSymbolContextFunction | eSymbolContextSymbol;
+      const bool use_inline_block_range = false;
+      EvaluateExpressionOptions options;
+      options.SetStopOthers(true);
+      options.SetUnwindOnError(true);
+      options.SetIgnoreBreakpoints(true);
+      options.SetTryAllThreads(true);
+      options.SetDebug(false);
+      options.SetTimeoutUsec(500000);
+      options.SetTrapExceptions(false);
+
+      AddressRange munmap_range;
+      if (sc.GetAddressRange(range_scope, 0, use_inline_block_range,
+                             munmap_range)) {
+        lldb::addr_t args[] = {addr, length};
+        lldb::ThreadPlanSP call_plan_sp(
+            new ThreadPlanCallFunction(*thread, munmap_range.GetBaseAddress(),
+                                       CompilerType(), args, options));
+        if (call_plan_sp) {
+          DiagnosticManager diagnostics;
+
+          StackFrame *frame = thread->GetStackFrameAtIndex(0).get();
+          if (frame) {
+            ExecutionContext exe_ctx;
+            frame->CalculateExecutionContext(exe_ctx);
+            ExpressionResults result = process->RunThreadPlan(
+                exe_ctx, call_plan_sp, options, diagnostics);
+            if (result == eExpressionCompleted) {
+              return true;
             }
+          }
         }
+      }
     }
+  }
 
-    return false;
+  return false;
 }
 
-// FIXME: This has nothing to do with Posix, it is just a convenience function that calls a
-// function of the form "void * (*)(void)".  We should find a better place to put this.
+// FIXME: This has nothing to do with Posix, it is just a convenience function
+// that calls a
+// function of the form "void * (*)(void)".  We should find a better place to
+// put this.
+
+bool lldb_private::InferiorCall(Process *process, const Address *address,
+                                addr_t &returned_func, bool trap_exceptions) {
+  Thread *thread =
+      process->GetThreadList().GetExpressionExecutionThread().get();
+  if (thread == NULL || address == NULL)
+    return false;
 
-bool
-lldb_private::InferiorCall (Process *process,
-                            const Address *address,
-                            addr_t &returned_func,
-                            bool trap_exceptions)
-{
-    Thread *thread = process->GetThreadList().GetExpressionExecutionThread().get();
-    if (thread == NULL || address == NULL)
-        return false;
-
-    EvaluateExpressionOptions options;
-    options.SetStopOthers(true);
-    options.SetUnwindOnError(true);
-    options.SetIgnoreBreakpoints(true);
-    options.SetTryAllThreads(true);
-    options.SetDebug (false);
-    options.SetTimeoutUsec(500000);
-    options.SetTrapExceptions(trap_exceptions);
-
-    ClangASTContext *clang_ast_context = process->GetTarget().GetScratchClangASTContext();
-    CompilerType clang_void_ptr_type = clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType();
-    lldb::ThreadPlanSP call_plan_sp(
-        new ThreadPlanCallFunction(*thread, *address, clang_void_ptr_type, llvm::ArrayRef<addr_t>(), options));
-    if (call_plan_sp)
-    {
-        DiagnosticManager diagnostics;
-
-        StackFrame *frame = thread->GetStackFrameAtIndex(0).get();
-        if (frame)
-        {
-            ExecutionContext exe_ctx;
-            frame->CalculateExecutionContext (exe_ctx);
-            ExpressionResults result = process->RunThreadPlan(exe_ctx, call_plan_sp, options, diagnostics);
-            if (result == eExpressionCompleted)
-            {
-                returned_func = call_plan_sp->GetReturnValueObject()->GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
-
-                if (process->GetAddressByteSize() == 4)
-                {
-                    if (returned_func == UINT32_MAX)
-                        return false;
-                }
-                else if (process->GetAddressByteSize() == 8)
-                {
-                    if (returned_func == UINT64_MAX)
-                        return false;
-                }
-                return true;
-            }
+  EvaluateExpressionOptions options;
+  options.SetStopOthers(true);
+  options.SetUnwindOnError(true);
+  options.SetIgnoreBreakpoints(true);
+  options.SetTryAllThreads(true);
+  options.SetDebug(false);
+  options.SetTimeoutUsec(500000);
+  options.SetTrapExceptions(trap_exceptions);
+
+  ClangASTContext *clang_ast_context =
+      process->GetTarget().GetScratchClangASTContext();
+  CompilerType clang_void_ptr_type =
+      clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType();
+  lldb::ThreadPlanSP call_plan_sp(
+      new ThreadPlanCallFunction(*thread, *address, clang_void_ptr_type,
+                                 llvm::ArrayRef<addr_t>(), options));
+  if (call_plan_sp) {
+    DiagnosticManager diagnostics;
+
+    StackFrame *frame = thread->GetStackFrameAtIndex(0).get();
+    if (frame) {
+      ExecutionContext exe_ctx;
+      frame->CalculateExecutionContext(exe_ctx);
+      ExpressionResults result =
+          process->RunThreadPlan(exe_ctx, call_plan_sp, options, diagnostics);
+      if (result == eExpressionCompleted) {
+        returned_func =
+            call_plan_sp->GetReturnValueObject()->GetValueAsUnsigned(
+                LLDB_INVALID_ADDRESS);
+
+        if (process->GetAddressByteSize() == 4) {
+          if (returned_func == UINT32_MAX)
+            return false;
+        } else if (process->GetAddressByteSize() == 8) {
+          if (returned_func == UINT64_MAX)
+            return false;
         }
+        return true;
+      }
     }
+  }
 
-    return false;
+  return false;
 }

Modified: lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.h Tue Sep  6 15:57:50 2016
@@ -31,9 +31,9 @@ bool InferiorCallMmap(Process *proc, lld
 
 bool InferiorCallMunmap(Process *proc, lldb::addr_t addr, lldb::addr_t length);
 
-bool InferiorCall(Process *proc, const Address *address, lldb::addr_t &returned_func,
-                  bool trap_exceptions = false);
+bool InferiorCall(Process *proc, const Address *address,
+                  lldb::addr_t &returned_func, bool trap_exceptions = false);
 
-}   // namespace lldb_private
+} // namespace lldb_private
 
-#endif  // lldb_InferiorCallPOSIX_h_
+#endif // lldb_InferiorCallPOSIX_h_

Modified: lldb/trunk/source/Plugins/Process/Utility/InstructionUtils.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/InstructionUtils.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/InstructionUtils.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/InstructionUtils.h Tue Sep  6 15:57:50 2016
@@ -16,123 +16,99 @@ namespace lldb_private {
 
 // Return the bit field(s) from the most significant bit (msbit) to the
 // least significant bit (lsbit) of a 64-bit unsigned value.
-static inline uint64_t
-Bits64 (const uint64_t bits, const uint32_t msbit, const uint32_t lsbit)
-{
-    assert(msbit < 64 && lsbit <= msbit);
-    return (bits >> lsbit) & ((1ull << (msbit - lsbit + 1)) - 1);
+static inline uint64_t Bits64(const uint64_t bits, const uint32_t msbit,
+                              const uint32_t lsbit) {
+  assert(msbit < 64 && lsbit <= msbit);
+  return (bits >> lsbit) & ((1ull << (msbit - lsbit + 1)) - 1);
 }
 
 // Return the bit field(s) from the most significant bit (msbit) to the
 // least significant bit (lsbit) of a 32-bit unsigned value.
-static inline uint32_t
-Bits32 (const uint32_t bits, const uint32_t msbit, const uint32_t lsbit)
-{
-    assert(msbit < 32 && lsbit <= msbit);
-    return (bits >> lsbit) & ((1u << (msbit - lsbit + 1)) - 1);
+static inline uint32_t Bits32(const uint32_t bits, const uint32_t msbit,
+                              const uint32_t lsbit) {
+  assert(msbit < 32 && lsbit <= msbit);
+  return (bits >> lsbit) & ((1u << (msbit - lsbit + 1)) - 1);
 }
 
 // Return the bit value from the 'bit' position of a 32-bit unsigned value.
-static inline uint32_t
-Bit32 (const uint32_t bits, const uint32_t bit)
-{
-    return (bits >> bit) & 1u;
+static inline uint32_t Bit32(const uint32_t bits, const uint32_t bit) {
+  return (bits >> bit) & 1u;
 }
 
-static inline uint64_t
-Bit64 (const uint64_t bits, const uint32_t bit)
-{
-    return (bits >> bit) & 1ull;
+static inline uint64_t Bit64(const uint64_t bits, const uint32_t bit) {
+  return (bits >> bit) & 1ull;
 }
 
 // Set the bit field(s) from the most significant bit (msbit) to the
 // least significant bit (lsbit) of a 32-bit unsigned value to 'val'.
-static inline void
-SetBits32(uint32_t &bits, const uint32_t msbit, const uint32_t lsbit, const uint32_t val)
-{
-    assert(msbit < 32 && lsbit < 32 && msbit >= lsbit);
-    uint32_t mask = ((1u << (msbit - lsbit + 1)) - 1);
-    bits &= ~(mask << lsbit);
-    bits |= (val & mask) << lsbit;
+static inline void SetBits32(uint32_t &bits, const uint32_t msbit,
+                             const uint32_t lsbit, const uint32_t val) {
+  assert(msbit < 32 && lsbit < 32 && msbit >= lsbit);
+  uint32_t mask = ((1u << (msbit - lsbit + 1)) - 1);
+  bits &= ~(mask << lsbit);
+  bits |= (val & mask) << lsbit;
 }
 
 // Set the 'bit' position of a 32-bit unsigned value to 'val'.
-static inline void
-SetBit32(uint32_t &bits, const uint32_t bit, const uint32_t val)
-{
-    SetBits32(bits, bit, bit, val);
+static inline void SetBit32(uint32_t &bits, const uint32_t bit,
+                            const uint32_t val) {
+  SetBits32(bits, bit, bit, val);
 }
 
 // Rotate a 32-bit unsigned value right by the specified amount.
-static inline uint32_t
-Rotr32 (uint32_t bits, uint32_t amt)
-{
-    assert(amt < 32 && "Invalid rotate amount");
-    return (bits >> amt) | (bits << ((32-amt)&31));
+static inline uint32_t Rotr32(uint32_t bits, uint32_t amt) {
+  assert(amt < 32 && "Invalid rotate amount");
+  return (bits >> amt) | (bits << ((32 - amt) & 31));
 }
 
 // Rotate a 32-bit unsigned value left by the specified amount.
-static inline uint32_t
-Rotl32 (uint32_t bits, uint32_t amt)
-{
-    assert(amt < 32 && "Invalid rotate amount");
-    return (bits << amt) | (bits >> ((32-amt)&31));
+static inline uint32_t Rotl32(uint32_t bits, uint32_t amt) {
+  assert(amt < 32 && "Invalid rotate amount");
+  return (bits << amt) | (bits >> ((32 - amt) & 31));
 }
 
 // Create a mask that starts at bit zero and includes "bit"
-static inline uint64_t
-MaskUpToBit (const uint64_t bit)
-{
-    if (bit >= 63)
-        return -1ll;
-    return (1ull << (bit + 1ull)) - 1ull;
+static inline uint64_t MaskUpToBit(const uint64_t bit) {
+  if (bit >= 63)
+    return -1ll;
+  return (1ull << (bit + 1ull)) - 1ull;
 }
 
 // Return an integer result equal to the number of bits of x that are ones.
-static inline uint32_t
-BitCount (uint64_t x)
-{
-    // c accumulates the total bits set in x
-    uint32_t c;
-    for (c = 0; x; ++c)
-    {
-        x &= x - 1; // clear the least significant bit set
-    }
-    return c;
-}
-
-static inline bool
-BitIsSet (const uint64_t value, const uint64_t bit)
-{
-    return (value & (1ull << bit)) != 0;
-}
-
-static inline bool
-BitIsClear (const uint64_t value, const uint64_t bit)
-{
-    return (value & (1ull << bit)) == 0;
-}
-
-static inline uint64_t
-UnsignedBits (const uint64_t value, const uint64_t msbit, const uint64_t lsbit)
-{
-    uint64_t result = value >> lsbit;
-    result &= MaskUpToBit (msbit - lsbit);
-    return result;
-}
-
-static inline int64_t
-SignedBits (const uint64_t value, const uint64_t msbit, const uint64_t lsbit)
-{
-    uint64_t result = UnsignedBits (value, msbit, lsbit);
-    if (BitIsSet(value, msbit))
-    {
-        // Sign extend
-        result |= ~MaskUpToBit (msbit - lsbit);
-    }
-    return result;
+static inline uint32_t BitCount(uint64_t x) {
+  // c accumulates the total bits set in x
+  uint32_t c;
+  for (c = 0; x; ++c) {
+    x &= x - 1; // clear the least significant bit set
+  }
+  return c;
 }
 
-}   // namespace lldb_private
+static inline bool BitIsSet(const uint64_t value, const uint64_t bit) {
+  return (value & (1ull << bit)) != 0;
+}
+
+static inline bool BitIsClear(const uint64_t value, const uint64_t bit) {
+  return (value & (1ull << bit)) == 0;
+}
+
+static inline uint64_t UnsignedBits(const uint64_t value, const uint64_t msbit,
+                                    const uint64_t lsbit) {
+  uint64_t result = value >> lsbit;
+  result &= MaskUpToBit(msbit - lsbit);
+  return result;
+}
+
+static inline int64_t SignedBits(const uint64_t value, const uint64_t msbit,
+                                 const uint64_t lsbit) {
+  uint64_t result = UnsignedBits(value, msbit, lsbit);
+  if (BitIsSet(value, msbit)) {
+    // Sign extend
+    result |= ~MaskUpToBit(msbit - lsbit);
+  }
+  return result;
+}
+
+} // namespace lldb_private
 
-#endif  // lldb_InstructionUtils_h_
+#endif // lldb_InstructionUtils_h_

Modified: lldb/trunk/source/Plugins/Process/Utility/LinuxSignals.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/LinuxSignals.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/LinuxSignals.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/LinuxSignals.cpp Tue Sep  6 15:57:50 2016
@@ -14,80 +14,83 @@
 
 using namespace lldb_private;
 
-LinuxSignals::LinuxSignals()
-    : UnixSignals()
-{
-    Reset();
-}
+LinuxSignals::LinuxSignals() : UnixSignals() { Reset(); }
 
-void
-LinuxSignals::Reset()
-{
-    m_signals.clear();
-    //        SIGNO  NAME             SUPPRESS STOP   NOTIFY DESCRIPTION                              ALIAS
-    //        =====  ===========      ======== =====  ====== ======================================   ======
-    AddSignal (1,    "SIGHUP",        false,   true , true , "hangup"                                        );
-    AddSignal (2,    "SIGINT",        true ,   true , true , "interrupt"                                     );
-    AddSignal (3,    "SIGQUIT",       false,   true , true , "quit"                                          );
-    AddSignal (4,    "SIGILL",        false,   true , true , "illegal instruction"                           );
-    AddSignal (5,    "SIGTRAP",       true ,   true , true , "trace trap (not reset when caught)"            );
-    AddSignal (6,    "SIGABRT",       false,   true , true , "abort()/IOT trap",                     "SIGIOT");
-    AddSignal (7,    "SIGBUS",        false,   true , true , "bus error"                                     );
-    AddSignal (8,    "SIGFPE",        false,   true , true , "floating point exception"                      );
-    AddSignal (9,    "SIGKILL",       false,   true , true , "kill"                                          );
-    AddSignal (10,   "SIGUSR1",       false,   true , true , "user defined signal 1"                         );
-    AddSignal (11,   "SIGSEGV",       false,   true , true , "segmentation violation"                        );
-    AddSignal (12,   "SIGUSR2",       false,   true , true , "user defined signal 2"                         );
-    AddSignal (13,   "SIGPIPE",       false,   true , true , "write to pipe with reading end closed"         );
-    AddSignal (14,   "SIGALRM",       false,   false, false, "alarm"                                         );
-    AddSignal (15,   "SIGTERM",       false,   true , true , "termination requested"                         );
-    AddSignal (16,   "SIGSTKFLT",     false,   true , true , "stack fault"                                   );
-    AddSignal (17,   "SIGCHLD",       false,   false, true , "child status has changed",             "SIGCLD");
-    AddSignal (18,   "SIGCONT",       false,   true , true , "process continue"                              );
-    AddSignal (19,   "SIGSTOP",       true ,   true , true , "process stop"                                  );
-    AddSignal (20,   "SIGTSTP",       false,   true , true , "tty stop"                                      );
-    AddSignal (21,   "SIGTTIN",       false,   true , true , "background tty read"                           );
-    AddSignal (22,   "SIGTTOU",       false,   true , true , "background tty write"                          );
-    AddSignal (23,   "SIGURG",        false,   true , true , "urgent data on socket"                         );
-    AddSignal (24,   "SIGXCPU",       false,   true , true , "CPU resource exceeded"                         );
-    AddSignal (25,   "SIGXFSZ",       false,   true , true , "file size limit exceeded"                      );
-    AddSignal (26,   "SIGVTALRM",     false,   true , true , "virtual time alarm"                            );
-    AddSignal (27,   "SIGPROF",       false,   false, false, "profiling time alarm"                          );
-    AddSignal (28,   "SIGWINCH",      false,   true , true , "window size changes"                           );
-    AddSignal (29,   "SIGIO",         false,   true , true , "input/output ready/Pollable event",   "SIGPOLL");
-    AddSignal (30,   "SIGPWR",        false,   true , true , "power failure"                                 );
-    AddSignal (31,   "SIGSYS",        false,   true , true , "invalid system call"                           );
-    AddSignal (32,   "SIG32",         false,   false, false, "threading library internal signal 1"           );
-    AddSignal (33,   "SIG33",         false,   false, false, "threading library internal signal 2"           );
-    AddSignal (34,   "SIGRTMIN",      false,   false, false, "real time signal 0"                            );
-    AddSignal (35,   "SIGRTMIN+1",    false,   false, false, "real time signal 1"                            );
-    AddSignal (36,   "SIGRTMIN+2",    false,   false, false, "real time signal 2"                            );
-    AddSignal (37,   "SIGRTMIN+3",    false,   false, false, "real time signal 3"                            );
-    AddSignal (38,   "SIGRTMIN+4",    false,   false, false, "real time signal 4"                            );
-    AddSignal (39,   "SIGRTMIN+5",    false,   false, false, "real time signal 5"                            );
-    AddSignal (40,   "SIGRTMIN+6",    false,   false, false, "real time signal 6"                            );
-    AddSignal (41,   "SIGRTMIN+7",    false,   false, false, "real time signal 7"                            );
-    AddSignal (42,   "SIGRTMIN+8",    false,   false, false, "real time signal 8"                            );
-    AddSignal (43,   "SIGRTMIN+9",    false,   false, false, "real time signal 9"                            );
-    AddSignal (44,   "SIGRTMIN+10",   false,   false, false, "real time signal 10"                           );
-    AddSignal (45,   "SIGRTMIN+11",   false,   false, false, "real time signal 11"                           );
-    AddSignal (46,   "SIGRTMIN+12",   false,   false, false, "real time signal 12"                           );
-    AddSignal (47,   "SIGRTMIN+13",   false,   false, false, "real time signal 13"                           );
-    AddSignal (48,   "SIGRTMIN+14",   false,   false, false, "real time signal 14"                           );
-    AddSignal (49,   "SIGRTMIN+15",   false,   false, false, "real time signal 15"                           );
-    AddSignal (50,   "SIGRTMAX-14",   false,   false, false, "real time signal 16"                           ); // switching to SIGRTMAX-xxx to match "kill -l" output
-    AddSignal (51,   "SIGRTMAX-13",   false,   false, false, "real time signal 17"                           );
-    AddSignal (52,   "SIGRTMAX-12",   false,   false, false, "real time signal 18"                           );
-    AddSignal (53,   "SIGRTMAX-11",   false,   false, false, "real time signal 19"                           );
-    AddSignal (54,   "SIGRTMAX-10",   false,   false, false, "real time signal 20"                           );
-    AddSignal (55,   "SIGRTMAX-9",    false,   false, false, "real time signal 21"                           );
-    AddSignal (56,   "SIGRTMAX-8",    false,   false, false, "real time signal 22"                           );
-    AddSignal (57,   "SIGRTMAX-7",    false,   false, false, "real time signal 23"                           );
-    AddSignal (58,   "SIGRTMAX-6",    false,   false, false, "real time signal 24"                           );
-    AddSignal (59,   "SIGRTMAX-5",    false,   false, false, "real time signal 25"                           );
-    AddSignal (60,   "SIGRTMAX-4",    false,   false, false, "real time signal 26"                           );
-    AddSignal (61,   "SIGRTMAX-3",    false,   false, false, "real time signal 27"                           );
-    AddSignal (62,   "SIGRTMAX-2",    false,   false, false, "real time signal 28"                           );
-    AddSignal (63,   "SIGRTMAX-1",    false,   false, false, "real time signal 29"                           );
-    AddSignal (64,   "SIGRTMAX",      false,   false, false, "real time signal 30"                           );
+void LinuxSignals::Reset() {
+  m_signals.clear();
+  //        SIGNO  NAME             SUPPRESS STOP   NOTIFY DESCRIPTION ALIAS
+  //        =====  ===========      ======== =====  ======
+  //        ======================================   ======
+  AddSignal(1, "SIGHUP", false, true, true, "hangup");
+  AddSignal(2, "SIGINT", true, true, true, "interrupt");
+  AddSignal(3, "SIGQUIT", false, true, true, "quit");
+  AddSignal(4, "SIGILL", false, true, true, "illegal instruction");
+  AddSignal(5, "SIGTRAP", true, true, true,
+            "trace trap (not reset when caught)");
+  AddSignal(6, "SIGABRT", false, true, true, "abort()/IOT trap", "SIGIOT");
+  AddSignal(7, "SIGBUS", false, true, true, "bus error");
+  AddSignal(8, "SIGFPE", false, true, true, "floating point exception");
+  AddSignal(9, "SIGKILL", false, true, true, "kill");
+  AddSignal(10, "SIGUSR1", false, true, true, "user defined signal 1");
+  AddSignal(11, "SIGSEGV", false, true, true, "segmentation violation");
+  AddSignal(12, "SIGUSR2", false, true, true, "user defined signal 2");
+  AddSignal(13, "SIGPIPE", false, true, true,
+            "write to pipe with reading end closed");
+  AddSignal(14, "SIGALRM", false, false, false, "alarm");
+  AddSignal(15, "SIGTERM", false, true, true, "termination requested");
+  AddSignal(16, "SIGSTKFLT", false, true, true, "stack fault");
+  AddSignal(17, "SIGCHLD", false, false, true, "child status has changed",
+            "SIGCLD");
+  AddSignal(18, "SIGCONT", false, true, true, "process continue");
+  AddSignal(19, "SIGSTOP", true, true, true, "process stop");
+  AddSignal(20, "SIGTSTP", false, true, true, "tty stop");
+  AddSignal(21, "SIGTTIN", false, true, true, "background tty read");
+  AddSignal(22, "SIGTTOU", false, true, true, "background tty write");
+  AddSignal(23, "SIGURG", false, true, true, "urgent data on socket");
+  AddSignal(24, "SIGXCPU", false, true, true, "CPU resource exceeded");
+  AddSignal(25, "SIGXFSZ", false, true, true, "file size limit exceeded");
+  AddSignal(26, "SIGVTALRM", false, true, true, "virtual time alarm");
+  AddSignal(27, "SIGPROF", false, false, false, "profiling time alarm");
+  AddSignal(28, "SIGWINCH", false, true, true, "window size changes");
+  AddSignal(29, "SIGIO", false, true, true, "input/output ready/Pollable event",
+            "SIGPOLL");
+  AddSignal(30, "SIGPWR", false, true, true, "power failure");
+  AddSignal(31, "SIGSYS", false, true, true, "invalid system call");
+  AddSignal(32, "SIG32", false, false, false,
+            "threading library internal signal 1");
+  AddSignal(33, "SIG33", false, false, false,
+            "threading library internal signal 2");
+  AddSignal(34, "SIGRTMIN", false, false, false, "real time signal 0");
+  AddSignal(35, "SIGRTMIN+1", false, false, false, "real time signal 1");
+  AddSignal(36, "SIGRTMIN+2", false, false, false, "real time signal 2");
+  AddSignal(37, "SIGRTMIN+3", false, false, false, "real time signal 3");
+  AddSignal(38, "SIGRTMIN+4", false, false, false, "real time signal 4");
+  AddSignal(39, "SIGRTMIN+5", false, false, false, "real time signal 5");
+  AddSignal(40, "SIGRTMIN+6", false, false, false, "real time signal 6");
+  AddSignal(41, "SIGRTMIN+7", false, false, false, "real time signal 7");
+  AddSignal(42, "SIGRTMIN+8", false, false, false, "real time signal 8");
+  AddSignal(43, "SIGRTMIN+9", false, false, false, "real time signal 9");
+  AddSignal(44, "SIGRTMIN+10", false, false, false, "real time signal 10");
+  AddSignal(45, "SIGRTMIN+11", false, false, false, "real time signal 11");
+  AddSignal(46, "SIGRTMIN+12", false, false, false, "real time signal 12");
+  AddSignal(47, "SIGRTMIN+13", false, false, false, "real time signal 13");
+  AddSignal(48, "SIGRTMIN+14", false, false, false, "real time signal 14");
+  AddSignal(49, "SIGRTMIN+15", false, false, false, "real time signal 15");
+  AddSignal(50, "SIGRTMAX-14", false, false, false,
+            "real time signal 16"); // switching to SIGRTMAX-xxx to match "kill
+                                    // -l" output
+  AddSignal(51, "SIGRTMAX-13", false, false, false, "real time signal 17");
+  AddSignal(52, "SIGRTMAX-12", false, false, false, "real time signal 18");
+  AddSignal(53, "SIGRTMAX-11", false, false, false, "real time signal 19");
+  AddSignal(54, "SIGRTMAX-10", false, false, false, "real time signal 20");
+  AddSignal(55, "SIGRTMAX-9", false, false, false, "real time signal 21");
+  AddSignal(56, "SIGRTMAX-8", false, false, false, "real time signal 22");
+  AddSignal(57, "SIGRTMAX-7", false, false, false, "real time signal 23");
+  AddSignal(58, "SIGRTMAX-6", false, false, false, "real time signal 24");
+  AddSignal(59, "SIGRTMAX-5", false, false, false, "real time signal 25");
+  AddSignal(60, "SIGRTMAX-4", false, false, false, "real time signal 26");
+  AddSignal(61, "SIGRTMAX-3", false, false, false, "real time signal 27");
+  AddSignal(62, "SIGRTMAX-2", false, false, false, "real time signal 28");
+  AddSignal(63, "SIGRTMAX-1", false, false, false, "real time signal 29");
+  AddSignal(64, "SIGRTMAX", false, false, false, "real time signal 30");
 }

Modified: lldb/trunk/source/Plugins/Process/Utility/LinuxSignals.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/LinuxSignals.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/LinuxSignals.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/LinuxSignals.h Tue Sep  6 15:57:50 2016
@@ -19,14 +19,12 @@
 namespace lldb_private {
 
 /// Linux specific set of Unix signals.
-class LinuxSignals : public UnixSignals
-{
+class LinuxSignals : public UnixSignals {
 public:
-    LinuxSignals();
+  LinuxSignals();
 
 private:
-    void
-    Reset() override;
+  void Reset() override;
 };
 
 } // namespace lldb_private

Modified: lldb/trunk/source/Plugins/Process/Utility/MipsLinuxSignals.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/MipsLinuxSignals.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/MipsLinuxSignals.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/MipsLinuxSignals.cpp Tue Sep  6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- MipsLinuxSignals.cpp ----------------------------------------*- C++ -*-===//
+//===-- MipsLinuxSignals.cpp ----------------------------------------*- C++
+//-*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -14,80 +15,83 @@
 
 using namespace lldb_private;
 
-MipsLinuxSignals::MipsLinuxSignals()
-    : UnixSignals()
-{
-    Reset();
-}
+MipsLinuxSignals::MipsLinuxSignals() : UnixSignals() { Reset(); }
 
-void
-MipsLinuxSignals::Reset()
-{
-    m_signals.clear();
-    //        SIGNO  NAME            SUPPRESS STOP   NOTIFY DESCRIPTION                              ALIAS
-    //        =====  ===========     ======== =====  ====== ======================================   ========
-    AddSignal (1,    "SIGHUP",       false,   true , true , "hangup"                                         );
-    AddSignal (2,    "SIGINT",       true ,   true , true , "interrupt"                                      );
-    AddSignal (3,    "SIGQUIT",      false,   true , true , "quit"                                           );
-    AddSignal (4,    "SIGILL",       false,   true , true , "illegal instruction"                            );
-    AddSignal (5,    "SIGTRAP",      true ,   true , true , "trace trap (not reset when caught)"             );
-    AddSignal (6,    "SIGABRT",      false,   true , true , "abort()/IOT trap",                      "SIGIOT");
-    AddSignal (7,    "SIGEMT",       false,   true , true , "terminate process with core dump"               );
-    AddSignal (8,    "SIGFPE",       false,   true , true , "floating point exception"                       );
-    AddSignal (9,    "SIGKILL",      false,   true , true , "kill"                                           );
-    AddSignal (10,   "SIGBUS",       false,   true , true , "bus error"                                      );
-    AddSignal (11,   "SIGSEGV",      false,   true , true , "segmentation violation"                         );
-    AddSignal (12,   "SIGSYS",       false,   true , true , "invalid system call"                            );
-    AddSignal (13,   "SIGPIPE",      false,   true , true , "write to pipe with reading end closed"          );
-    AddSignal (14,   "SIGALRM",      false,   false, false, "alarm"                                          );
-    AddSignal (15,   "SIGTERM",      false,   true , true , "termination requested"                          );
-    AddSignal (16,   "SIGUSR1",      false,   true , true , "user defined signal 1"                          );
-    AddSignal (17,   "SIGUSR2",      false,   true , true , "user defined signal 2"                          );
-    AddSignal (18,   "SIGCHLD",      false,   false, true , "child status has changed",              "SIGCLD");
-    AddSignal (19,   "SIGPWR",       false,   true , true , "power failure"                                  );
-    AddSignal (20,   "SIGWINCH",     false,   true , true , "window size changes"                            );
-    AddSignal (21,   "SIGURG",       false,   true , true , "urgent data on socket"                          );
-    AddSignal (22,   "SIGIO",        false,   true , true , "input/output ready/Pollable event",    "SIGPOLL");
-    AddSignal (23,   "SIGSTOP",      true ,   true , true , "process stop"                                   );
-    AddSignal (24,   "SIGTSTP",      false,   true , true , "tty stop"                                       );
-    AddSignal (25,   "SIGCONT",      false,   true , true , "process continue"                               );
-    AddSignal (26,   "SIGTTIN",      false,   true , true , "background tty read"                            );
-    AddSignal (27,   "SIGTTOU",      false,   true , true , "background tty write"                           );
-    AddSignal (28,   "SIGVTALRM",    false,   true , true , "virtual time alarm"                             );
-    AddSignal (29,   "SIGPROF",      false,   false, false, "profiling time alarm"                           );
-    AddSignal (30,   "SIGXCPU",      false,   true , true , "CPU resource exceeded"                          );
-    AddSignal (31,   "SIGXFSZ",      false,   true , true , "file size limit exceeded"                       );
-    AddSignal (32,   "SIG32",        false,   false, false, "threading library internal signal 1"            );
-    AddSignal (33,   "SIG33",        false,   false, false, "threading library internal signal 2"            );
-    AddSignal (34,   "SIGRTMIN",     false,   false, false, "real time signal 0"                             );
-    AddSignal (35,   "SIGRTMIN+1",   false,   false, false, "real time signal 1"                             );
-    AddSignal (36,   "SIGRTMIN+2",   false,   false, false, "real time signal 2"                             );
-    AddSignal (37,   "SIGRTMIN+3",   false,   false, false, "real time signal 3"                             );
-    AddSignal (38,   "SIGRTMIN+4",   false,   false, false, "real time signal 4"                             );
-    AddSignal (39,   "SIGRTMIN+5",   false,   false, false, "real time signal 5"                             );
-    AddSignal (40,   "SIGRTMIN+6",   false,   false, false, "real time signal 6"                             );
-    AddSignal (41,   "SIGRTMIN+7",   false,   false, false, "real time signal 7"                             );
-    AddSignal (42,   "SIGRTMIN+8",   false,   false, false, "real time signal 8"                             );
-    AddSignal (43,   "SIGRTMIN+9",   false,   false, false, "real time signal 9"                             );
-    AddSignal (44,   "SIGRTMIN+10",  false,   false, false, "real time signal 10"                            );
-    AddSignal (45,   "SIGRTMIN+11",  false,   false, false, "real time signal 11"                            );
-    AddSignal (46,   "SIGRTMIN+12",  false,   false, false, "real time signal 12"                            );
-    AddSignal (47,   "SIGRTMIN+13",  false,   false, false, "real time signal 13"                            );
-    AddSignal (48,   "SIGRTMIN+14",  false,   false, false, "real time signal 14"                            );
-    AddSignal (49,   "SIGRTMIN+15",  false,   false, false, "real time signal 15"                            );
-    AddSignal (50,   "SIGRTMAX-14",  false,   false, false, "real time signal 16"                            ); // switching to SIGRTMAX-xxx to match "kill -l" output
-    AddSignal (51,   "SIGRTMAX-13",  false,   false, false, "real time signal 17"                            );
-    AddSignal (52,   "SIGRTMAX-12",  false,   false, false, "real time signal 18"                            );
-    AddSignal (53,   "SIGRTMAX-11",  false,   false, false, "real time signal 19"                            );
-    AddSignal (54,   "SIGRTMAX-10",  false,   false, false, "real time signal 20"                            );
-    AddSignal (55,   "SIGRTMAX-9",   false,   false, false, "real time signal 21"                            );
-    AddSignal (56,   "SIGRTMAX-8",   false,   false, false, "real time signal 22"                            );
-    AddSignal (57,   "SIGRTMAX-7",   false,   false, false, "real time signal 23"                            );
-    AddSignal (58,   "SIGRTMAX-6",   false,   false, false, "real time signal 24"                            );
-    AddSignal (59,   "SIGRTMAX-5",   false,   false, false, "real time signal 25"                            );
-    AddSignal (60,   "SIGRTMAX-4",   false,   false, false, "real time signal 26"                            );
-    AddSignal (61,   "SIGRTMAX-3",   false,   false, false, "real time signal 27"                            );
-    AddSignal (62,   "SIGRTMAX-2",   false,   false, false, "real time signal 28"                            );
-    AddSignal (63,   "SIGRTMAX-1",   false,   false, false, "real time signal 29"                            );
-    AddSignal (64,   "SIGRTMAX",     false,   false, false, "real time signal 30"                            );
+void MipsLinuxSignals::Reset() {
+  m_signals.clear();
+  //        SIGNO  NAME            SUPPRESS STOP   NOTIFY DESCRIPTION ALIAS
+  //        =====  ===========     ======== =====  ======
+  //        ======================================   ========
+  AddSignal(1, "SIGHUP", false, true, true, "hangup");
+  AddSignal(2, "SIGINT", true, true, true, "interrupt");
+  AddSignal(3, "SIGQUIT", false, true, true, "quit");
+  AddSignal(4, "SIGILL", false, true, true, "illegal instruction");
+  AddSignal(5, "SIGTRAP", true, true, true,
+            "trace trap (not reset when caught)");
+  AddSignal(6, "SIGABRT", false, true, true, "abort()/IOT trap", "SIGIOT");
+  AddSignal(7, "SIGEMT", false, true, true, "terminate process with core dump");
+  AddSignal(8, "SIGFPE", false, true, true, "floating point exception");
+  AddSignal(9, "SIGKILL", false, true, true, "kill");
+  AddSignal(10, "SIGBUS", false, true, true, "bus error");
+  AddSignal(11, "SIGSEGV", false, true, true, "segmentation violation");
+  AddSignal(12, "SIGSYS", false, true, true, "invalid system call");
+  AddSignal(13, "SIGPIPE", false, true, true,
+            "write to pipe with reading end closed");
+  AddSignal(14, "SIGALRM", false, false, false, "alarm");
+  AddSignal(15, "SIGTERM", false, true, true, "termination requested");
+  AddSignal(16, "SIGUSR1", false, true, true, "user defined signal 1");
+  AddSignal(17, "SIGUSR2", false, true, true, "user defined signal 2");
+  AddSignal(18, "SIGCHLD", false, false, true, "child status has changed",
+            "SIGCLD");
+  AddSignal(19, "SIGPWR", false, true, true, "power failure");
+  AddSignal(20, "SIGWINCH", false, true, true, "window size changes");
+  AddSignal(21, "SIGURG", false, true, true, "urgent data on socket");
+  AddSignal(22, "SIGIO", false, true, true, "input/output ready/Pollable event",
+            "SIGPOLL");
+  AddSignal(23, "SIGSTOP", true, true, true, "process stop");
+  AddSignal(24, "SIGTSTP", false, true, true, "tty stop");
+  AddSignal(25, "SIGCONT", false, true, true, "process continue");
+  AddSignal(26, "SIGTTIN", false, true, true, "background tty read");
+  AddSignal(27, "SIGTTOU", false, true, true, "background tty write");
+  AddSignal(28, "SIGVTALRM", false, true, true, "virtual time alarm");
+  AddSignal(29, "SIGPROF", false, false, false, "profiling time alarm");
+  AddSignal(30, "SIGXCPU", false, true, true, "CPU resource exceeded");
+  AddSignal(31, "SIGXFSZ", false, true, true, "file size limit exceeded");
+  AddSignal(32, "SIG32", false, false, false,
+            "threading library internal signal 1");
+  AddSignal(33, "SIG33", false, false, false,
+            "threading library internal signal 2");
+  AddSignal(34, "SIGRTMIN", false, false, false, "real time signal 0");
+  AddSignal(35, "SIGRTMIN+1", false, false, false, "real time signal 1");
+  AddSignal(36, "SIGRTMIN+2", false, false, false, "real time signal 2");
+  AddSignal(37, "SIGRTMIN+3", false, false, false, "real time signal 3");
+  AddSignal(38, "SIGRTMIN+4", false, false, false, "real time signal 4");
+  AddSignal(39, "SIGRTMIN+5", false, false, false, "real time signal 5");
+  AddSignal(40, "SIGRTMIN+6", false, false, false, "real time signal 6");
+  AddSignal(41, "SIGRTMIN+7", false, false, false, "real time signal 7");
+  AddSignal(42, "SIGRTMIN+8", false, false, false, "real time signal 8");
+  AddSignal(43, "SIGRTMIN+9", false, false, false, "real time signal 9");
+  AddSignal(44, "SIGRTMIN+10", false, false, false, "real time signal 10");
+  AddSignal(45, "SIGRTMIN+11", false, false, false, "real time signal 11");
+  AddSignal(46, "SIGRTMIN+12", false, false, false, "real time signal 12");
+  AddSignal(47, "SIGRTMIN+13", false, false, false, "real time signal 13");
+  AddSignal(48, "SIGRTMIN+14", false, false, false, "real time signal 14");
+  AddSignal(49, "SIGRTMIN+15", false, false, false, "real time signal 15");
+  AddSignal(50, "SIGRTMAX-14", false, false, false,
+            "real time signal 16"); // switching to SIGRTMAX-xxx to match "kill
+                                    // -l" output
+  AddSignal(51, "SIGRTMAX-13", false, false, false, "real time signal 17");
+  AddSignal(52, "SIGRTMAX-12", false, false, false, "real time signal 18");
+  AddSignal(53, "SIGRTMAX-11", false, false, false, "real time signal 19");
+  AddSignal(54, "SIGRTMAX-10", false, false, false, "real time signal 20");
+  AddSignal(55, "SIGRTMAX-9", false, false, false, "real time signal 21");
+  AddSignal(56, "SIGRTMAX-8", false, false, false, "real time signal 22");
+  AddSignal(57, "SIGRTMAX-7", false, false, false, "real time signal 23");
+  AddSignal(58, "SIGRTMAX-6", false, false, false, "real time signal 24");
+  AddSignal(59, "SIGRTMAX-5", false, false, false, "real time signal 25");
+  AddSignal(60, "SIGRTMAX-4", false, false, false, "real time signal 26");
+  AddSignal(61, "SIGRTMAX-3", false, false, false, "real time signal 27");
+  AddSignal(62, "SIGRTMAX-2", false, false, false, "real time signal 28");
+  AddSignal(63, "SIGRTMAX-1", false, false, false, "real time signal 29");
+  AddSignal(64, "SIGRTMAX", false, false, false, "real time signal 30");
 }

Modified: lldb/trunk/source/Plugins/Process/Utility/MipsLinuxSignals.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/MipsLinuxSignals.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/MipsLinuxSignals.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/MipsLinuxSignals.h Tue Sep  6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- MipsLinuxSignals.h ------------------------------------------*- C++ -*-===//
+//===-- MipsLinuxSignals.h ------------------------------------------*- C++
+//-*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -19,14 +20,12 @@
 namespace lldb_private {
 
 /// Linux specific set of Unix signals.
-class MipsLinuxSignals : public UnixSignals
-{
+class MipsLinuxSignals : public UnixSignals {
 public:
-    MipsLinuxSignals();
+  MipsLinuxSignals();
 
 private:
-    void
-    Reset() override;
+  void Reset() override;
 };
 
 } // namespace lldb_private

Modified: lldb/trunk/source/Plugins/Process/Utility/NetBSDSignals.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/NetBSDSignals.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/NetBSDSignals.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/NetBSDSignals.cpp Tue Sep  6 15:57:50 2016
@@ -15,20 +15,16 @@
 
 using namespace lldb_private;
 
-NetBSDSignals::NetBSDSignals()
-    : UnixSignals()
-{
-    Reset();
-}
+NetBSDSignals::NetBSDSignals() : UnixSignals() { Reset(); }
 
-void
-NetBSDSignals::Reset()
-{
-    UnixSignals::Reset();
-    //        SIGNO  NAME          SUPPRESS STOP   NOTIFY DESCRIPTION
-    //        ====== ============  ======== ====== ====== ===================================================
-    AddSignal (32,   "SIGPWR",     false,   true , true , "power fail/restart (not reset when caught)");
+void NetBSDSignals::Reset() {
+  UnixSignals::Reset();
+  //        SIGNO  NAME          SUPPRESS STOP   NOTIFY DESCRIPTION
+  //        ====== ============  ======== ====== ======
+  //        ===================================================
+  AddSignal(32, "SIGPWR", false, true, true,
+            "power fail/restart (not reset when caught)");
 #ifdef SIGRTMIN /* SIGRTMAX */
-    /* Kernel only; not exposed to userland yet */
+                /* Kernel only; not exposed to userland yet */
 #endif
 }

Modified: lldb/trunk/source/Plugins/Process/Utility/NetBSDSignals.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/NetBSDSignals.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/NetBSDSignals.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/NetBSDSignals.h Tue Sep  6 15:57:50 2016
@@ -16,14 +16,12 @@
 namespace lldb_private {
 
 /// NetBSD specific set of Unix signals.
-class NetBSDSignals : public UnixSignals
-{
+class NetBSDSignals : public UnixSignals {
 public:
-    NetBSDSignals();
+  NetBSDSignals();
 
 private:
-    void
-    Reset() override;
+  void Reset() override;
 };
 
 } // namespace lldb_private

Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp Tue Sep  6 15:57:50 2016
@@ -42,403 +42,926 @@
 using namespace lldb;
 using namespace lldb_private;
 
-enum
-{
-    gpr_r0 = 0,
-    gpr_r1,
-    gpr_r2,
-    gpr_r3,
-    gpr_r4,
-    gpr_r5,
-    gpr_r6,
-    gpr_r7,
-    gpr_r8,
-    gpr_r9,
-    gpr_r10,
-    gpr_r11,
-    gpr_r12,
-    gpr_r13, gpr_sp = gpr_r13,
-    gpr_r14, gpr_lr = gpr_r14,
-    gpr_r15, gpr_pc = gpr_r15,
-    gpr_cpsr,
-
-    fpu_s0,
-    fpu_s1,
-    fpu_s2,
-    fpu_s3,
-    fpu_s4,
-    fpu_s5,
-    fpu_s6,
-    fpu_s7,
-    fpu_s8,
-    fpu_s9,
-    fpu_s10,
-    fpu_s11,
-    fpu_s12,
-    fpu_s13,
-    fpu_s14,
-    fpu_s15,
-    fpu_s16,
-    fpu_s17,
-    fpu_s18,
-    fpu_s19,
-    fpu_s20,
-    fpu_s21,
-    fpu_s22,
-    fpu_s23,
-    fpu_s24,
-    fpu_s25,
-    fpu_s26,
-    fpu_s27,
-    fpu_s28,
-    fpu_s29,
-    fpu_s30,
-    fpu_s31,
-    fpu_fpscr,
-
-    exc_exception,
-    exc_fsr,
-    exc_far,
-
-    dbg_bvr0,
-    dbg_bvr1,
-    dbg_bvr2,
-    dbg_bvr3,
-    dbg_bvr4,
-    dbg_bvr5,
-    dbg_bvr6,
-    dbg_bvr7,
-    dbg_bvr8,
-    dbg_bvr9,
-    dbg_bvr10,
-    dbg_bvr11,
-    dbg_bvr12,
-    dbg_bvr13,
-    dbg_bvr14,
-    dbg_bvr15,
-
-    dbg_bcr0,
-    dbg_bcr1,
-    dbg_bcr2,
-    dbg_bcr3,
-    dbg_bcr4,
-    dbg_bcr5,
-    dbg_bcr6,
-    dbg_bcr7,
-    dbg_bcr8,
-    dbg_bcr9,
-    dbg_bcr10,
-    dbg_bcr11,
-    dbg_bcr12,
-    dbg_bcr13,
-    dbg_bcr14,
-    dbg_bcr15,
-
-    dbg_wvr0,
-    dbg_wvr1,
-    dbg_wvr2,
-    dbg_wvr3,
-    dbg_wvr4,
-    dbg_wvr5,
-    dbg_wvr6,
-    dbg_wvr7,
-    dbg_wvr8,
-    dbg_wvr9,
-    dbg_wvr10,
-    dbg_wvr11,
-    dbg_wvr12,
-    dbg_wvr13,
-    dbg_wvr14,
-    dbg_wvr15,
-
-    dbg_wcr0,
-    dbg_wcr1,
-    dbg_wcr2,
-    dbg_wcr3,
-    dbg_wcr4,
-    dbg_wcr5,
-    dbg_wcr6,
-    dbg_wcr7,
-    dbg_wcr8,
-    dbg_wcr9,
-    dbg_wcr10,
-    dbg_wcr11,
-    dbg_wcr12,
-    dbg_wcr13,
-    dbg_wcr14,
-    dbg_wcr15,
+enum {
+  gpr_r0 = 0,
+  gpr_r1,
+  gpr_r2,
+  gpr_r3,
+  gpr_r4,
+  gpr_r5,
+  gpr_r6,
+  gpr_r7,
+  gpr_r8,
+  gpr_r9,
+  gpr_r10,
+  gpr_r11,
+  gpr_r12,
+  gpr_r13,
+  gpr_sp = gpr_r13,
+  gpr_r14,
+  gpr_lr = gpr_r14,
+  gpr_r15,
+  gpr_pc = gpr_r15,
+  gpr_cpsr,
+
+  fpu_s0,
+  fpu_s1,
+  fpu_s2,
+  fpu_s3,
+  fpu_s4,
+  fpu_s5,
+  fpu_s6,
+  fpu_s7,
+  fpu_s8,
+  fpu_s9,
+  fpu_s10,
+  fpu_s11,
+  fpu_s12,
+  fpu_s13,
+  fpu_s14,
+  fpu_s15,
+  fpu_s16,
+  fpu_s17,
+  fpu_s18,
+  fpu_s19,
+  fpu_s20,
+  fpu_s21,
+  fpu_s22,
+  fpu_s23,
+  fpu_s24,
+  fpu_s25,
+  fpu_s26,
+  fpu_s27,
+  fpu_s28,
+  fpu_s29,
+  fpu_s30,
+  fpu_s31,
+  fpu_fpscr,
+
+  exc_exception,
+  exc_fsr,
+  exc_far,
+
+  dbg_bvr0,
+  dbg_bvr1,
+  dbg_bvr2,
+  dbg_bvr3,
+  dbg_bvr4,
+  dbg_bvr5,
+  dbg_bvr6,
+  dbg_bvr7,
+  dbg_bvr8,
+  dbg_bvr9,
+  dbg_bvr10,
+  dbg_bvr11,
+  dbg_bvr12,
+  dbg_bvr13,
+  dbg_bvr14,
+  dbg_bvr15,
+
+  dbg_bcr0,
+  dbg_bcr1,
+  dbg_bcr2,
+  dbg_bcr3,
+  dbg_bcr4,
+  dbg_bcr5,
+  dbg_bcr6,
+  dbg_bcr7,
+  dbg_bcr8,
+  dbg_bcr9,
+  dbg_bcr10,
+  dbg_bcr11,
+  dbg_bcr12,
+  dbg_bcr13,
+  dbg_bcr14,
+  dbg_bcr15,
+
+  dbg_wvr0,
+  dbg_wvr1,
+  dbg_wvr2,
+  dbg_wvr3,
+  dbg_wvr4,
+  dbg_wvr5,
+  dbg_wvr6,
+  dbg_wvr7,
+  dbg_wvr8,
+  dbg_wvr9,
+  dbg_wvr10,
+  dbg_wvr11,
+  dbg_wvr12,
+  dbg_wvr13,
+  dbg_wvr14,
+  dbg_wvr15,
+
+  dbg_wcr0,
+  dbg_wcr1,
+  dbg_wcr2,
+  dbg_wcr3,
+  dbg_wcr4,
+  dbg_wcr5,
+  dbg_wcr6,
+  dbg_wcr7,
+  dbg_wcr8,
+  dbg_wcr9,
+  dbg_wcr10,
+  dbg_wcr11,
+  dbg_wcr12,
+  dbg_wcr13,
+  dbg_wcr14,
+  dbg_wcr15,
 
-    k_num_registers
+  k_num_registers
 };
 
-
-#define GPR_OFFSET(idx) ((idx) * 4)
-#define FPU_OFFSET(idx) ((idx) * 4 + sizeof (RegisterContextDarwin_arm::GPR))
-#define EXC_OFFSET(idx) ((idx) * 4 + sizeof (RegisterContextDarwin_arm::GPR) + sizeof (RegisterContextDarwin_arm::FPU))
-#define DBG_OFFSET(reg) ((LLVM_EXTENSION offsetof (RegisterContextDarwin_arm::DBG, reg) + sizeof (RegisterContextDarwin_arm::GPR) + sizeof (RegisterContextDarwin_arm::FPU) + sizeof (RegisterContextDarwin_arm::EXC)))
-
-#define DEFINE_DBG(reg, i)  #reg, NULL, sizeof(((RegisterContextDarwin_arm::DBG *)NULL)->reg[i]), DBG_OFFSET(reg[i]), eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr, nullptr, 0
-#define REG_CONTEXT_SIZE (sizeof (RegisterContextDarwin_arm::GPR) + sizeof (RegisterContextDarwin_arm::FPU) + sizeof (RegisterContextDarwin_arm::EXC))
+#define GPR_OFFSET(idx) ((idx)*4)
+#define FPU_OFFSET(idx) ((idx)*4 + sizeof(RegisterContextDarwin_arm::GPR))
+#define EXC_OFFSET(idx)                                                        \
+  ((idx)*4 + sizeof(RegisterContextDarwin_arm::GPR) +                          \
+   sizeof(RegisterContextDarwin_arm::FPU))
+#define DBG_OFFSET(reg)                                                        \
+  ((LLVM_EXTENSION offsetof(RegisterContextDarwin_arm::DBG, reg) +             \
+    sizeof(RegisterContextDarwin_arm::GPR) +                                   \
+    sizeof(RegisterContextDarwin_arm::FPU) +                                   \
+    sizeof(RegisterContextDarwin_arm::EXC)))
+
+#define DEFINE_DBG(reg, i)                                                     \
+  #reg, NULL, sizeof(((RegisterContextDarwin_arm::DBG *) NULL)->reg[i]),       \
+                      DBG_OFFSET(reg[i]), eEncodingUint, eFormatHex,           \
+                                 {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,    \
+                                  LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,    \
+                                  LLDB_INVALID_REGNUM },                       \
+                                  nullptr, nullptr, nullptr, 0
+#define REG_CONTEXT_SIZE                                                       \
+  (sizeof(RegisterContextDarwin_arm::GPR) +                                    \
+   sizeof(RegisterContextDarwin_arm::FPU) +                                    \
+   sizeof(RegisterContextDarwin_arm::EXC))
 
 static RegisterInfo g_register_infos[] = {
-// General purpose registers
-//  NAME        ALT     SZ  OFFSET              ENCODING        FORMAT          EH_FRAME                DWARF               GENERIC                     PROCESS PLUGIN          LLDB NATIVE
-//  ======      ======= ==  =============       =============   ============    ===============         ===============     =========================   =====================   =============
-{   "r0",       NULL,   4,  GPR_OFFSET(0),      eEncodingUint,  eFormatHex,     { ehframe_r0,           dwarf_r0,           LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    gpr_r0      }, nullptr, nullptr, nullptr, 0 },
-{   "r1",       NULL,   4,  GPR_OFFSET(1),      eEncodingUint,  eFormatHex,     { ehframe_r1,           dwarf_r1,           LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    gpr_r1      }, nullptr, nullptr, nullptr, 0 },
-{   "r2",       NULL,   4,  GPR_OFFSET(2),      eEncodingUint,  eFormatHex,     { ehframe_r2,           dwarf_r2,           LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    gpr_r2      }, nullptr, nullptr, nullptr, 0 },
-{   "r3",       NULL,   4,  GPR_OFFSET(3),      eEncodingUint,  eFormatHex,     { ehframe_r3,           dwarf_r3,           LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    gpr_r3      }, nullptr, nullptr, nullptr, 0 },
-{   "r4",       NULL,   4,  GPR_OFFSET(4),      eEncodingUint,  eFormatHex,     { ehframe_r4,           dwarf_r4,           LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    gpr_r4      }, nullptr, nullptr, nullptr, 0 },
-{   "r5",       NULL,   4,  GPR_OFFSET(5),      eEncodingUint,  eFormatHex,     { ehframe_r5,           dwarf_r5,           LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    gpr_r5      }, nullptr, nullptr, nullptr, 0 },
-{   "r6",       NULL,   4,  GPR_OFFSET(6),      eEncodingUint,  eFormatHex,     { ehframe_r6,           dwarf_r6,           LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    gpr_r6      }, nullptr, nullptr, nullptr, 0 },
-{   "r7",       NULL,   4,  GPR_OFFSET(7),      eEncodingUint,  eFormatHex,     { ehframe_r7,           dwarf_r7,           LLDB_REGNUM_GENERIC_FP,     LLDB_INVALID_REGNUM,    gpr_r7      }, nullptr, nullptr, nullptr, 0 },
-{   "r8",       NULL,   4,  GPR_OFFSET(8),      eEncodingUint,  eFormatHex,     { ehframe_r8,           dwarf_r8,           LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    gpr_r8      }, nullptr, nullptr, nullptr, 0 },
-{   "r9",       NULL,   4,  GPR_OFFSET(9),      eEncodingUint,  eFormatHex,     { ehframe_r9,           dwarf_r9,           LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    gpr_r9      }, nullptr, nullptr, nullptr, 0 },
-{   "r10",      NULL,   4,  GPR_OFFSET(10),     eEncodingUint,  eFormatHex,     { ehframe_r10,          dwarf_r10,          LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    gpr_r10     }, nullptr, nullptr, nullptr, 0 },
-{   "r11",      NULL,   4,  GPR_OFFSET(11),     eEncodingUint,  eFormatHex,     { ehframe_r11,          dwarf_r11,          LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    gpr_r11     }, nullptr, nullptr, nullptr, 0 },
-{   "r12",      NULL,   4,  GPR_OFFSET(12),     eEncodingUint,  eFormatHex,     { ehframe_r12,          dwarf_r12,          LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    gpr_r12     }, nullptr, nullptr, nullptr, 0 },
-{   "sp",       "r13",  4,  GPR_OFFSET(13),     eEncodingUint,  eFormatHex,     { ehframe_sp,           dwarf_sp,           LLDB_REGNUM_GENERIC_SP,     LLDB_INVALID_REGNUM,    gpr_sp      }, nullptr, nullptr, nullptr, 0 },
-{   "lr",       "r14",  4,  GPR_OFFSET(14),     eEncodingUint,  eFormatHex,     { ehframe_lr,           dwarf_lr,           LLDB_REGNUM_GENERIC_RA,     LLDB_INVALID_REGNUM,    gpr_lr      }, nullptr, nullptr, nullptr, 0 },
-{   "pc",       "r15",  4,  GPR_OFFSET(15),     eEncodingUint,  eFormatHex,     { ehframe_pc,           dwarf_pc,           LLDB_REGNUM_GENERIC_PC,     LLDB_INVALID_REGNUM,    gpr_pc      }, nullptr, nullptr, nullptr, 0 },
-{   "cpsr",     "psr",  4,  GPR_OFFSET(16),     eEncodingUint,  eFormatHex,     { ehframe_cpsr,         dwarf_cpsr,         LLDB_REGNUM_GENERIC_FLAGS,  LLDB_INVALID_REGNUM,    gpr_cpsr    }, nullptr, nullptr, nullptr, 0 },
-
-{   "s0",       NULL,   4,  FPU_OFFSET(0),      eEncodingIEEE754,eFormatFloat,  { LLDB_INVALID_REGNUM,  dwarf_s0,           LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    fpu_s0      }, nullptr, nullptr, nullptr, 0 },
-{   "s1",       NULL,   4,  FPU_OFFSET(1),      eEncodingIEEE754,eFormatFloat,  { LLDB_INVALID_REGNUM,  dwarf_s1,           LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    fpu_s1      }, nullptr, nullptr, nullptr, 0 },
-{   "s2",       NULL,   4,  FPU_OFFSET(2),      eEncodingIEEE754,eFormatFloat,  { LLDB_INVALID_REGNUM,  dwarf_s2,           LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    fpu_s2      }, nullptr, nullptr, nullptr, 0 },
-{   "s3",       NULL,   4,  FPU_OFFSET(3),      eEncodingIEEE754,eFormatFloat,  { LLDB_INVALID_REGNUM,  dwarf_s3,           LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    fpu_s3      }, nullptr, nullptr, nullptr, 0 },
-{   "s4",       NULL,   4,  FPU_OFFSET(4),      eEncodingIEEE754,eFormatFloat,  { LLDB_INVALID_REGNUM,  dwarf_s4,           LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    fpu_s4      }, nullptr, nullptr, nullptr, 0 },
-{   "s5",       NULL,   4,  FPU_OFFSET(5),      eEncodingIEEE754,eFormatFloat,  { LLDB_INVALID_REGNUM,  dwarf_s5,           LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    fpu_s5      }, nullptr, nullptr, nullptr, 0 },
-{   "s6",       NULL,   4,  FPU_OFFSET(6),      eEncodingIEEE754,eFormatFloat,  { LLDB_INVALID_REGNUM,  dwarf_s6,           LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    fpu_s6      }, nullptr, nullptr, nullptr, 0 },
-{   "s7",       NULL,   4,  FPU_OFFSET(7),      eEncodingIEEE754,eFormatFloat,  { LLDB_INVALID_REGNUM,  dwarf_s7,           LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    fpu_s7      }, nullptr, nullptr, nullptr, 0 },
-{   "s8",       NULL,   4,  FPU_OFFSET(8),      eEncodingIEEE754,eFormatFloat,  { LLDB_INVALID_REGNUM,  dwarf_s8,           LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    fpu_s8      }, nullptr, nullptr, nullptr, 0 },
-{   "s9",       NULL,   4,  FPU_OFFSET(9),      eEncodingIEEE754,eFormatFloat,  { LLDB_INVALID_REGNUM,  dwarf_s9,           LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    fpu_s9      }, nullptr, nullptr, nullptr, 0 },
-{   "s10",      NULL,   4,  FPU_OFFSET(10),     eEncodingIEEE754,eFormatFloat,  { LLDB_INVALID_REGNUM,  dwarf_s10,          LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    fpu_s10     }, nullptr, nullptr, nullptr, 0 },
-{   "s11",      NULL,   4,  FPU_OFFSET(11),     eEncodingIEEE754,eFormatFloat,  { LLDB_INVALID_REGNUM,  dwarf_s11,          LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    fpu_s11     }, nullptr, nullptr, nullptr, 0 },
-{   "s12",      NULL,   4,  FPU_OFFSET(12),     eEncodingIEEE754,eFormatFloat,  { LLDB_INVALID_REGNUM,  dwarf_s12,          LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    fpu_s12     }, nullptr, nullptr, nullptr, 0 },
-{   "s13",      NULL,   4,  FPU_OFFSET(13),     eEncodingIEEE754,eFormatFloat,  { LLDB_INVALID_REGNUM,  dwarf_s13,          LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    fpu_s13     }, nullptr, nullptr, nullptr, 0 },
-{   "s14",      NULL,   4,  FPU_OFFSET(14),     eEncodingIEEE754,eFormatFloat,  { LLDB_INVALID_REGNUM,  dwarf_s14,          LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    fpu_s14     }, nullptr, nullptr, nullptr, 0 },
-{   "s15",      NULL,   4,  FPU_OFFSET(15),     eEncodingIEEE754,eFormatFloat,  { LLDB_INVALID_REGNUM,  dwarf_s15,          LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    fpu_s15     }, nullptr, nullptr, nullptr, 0 },
-{   "s16",      NULL,   4,  FPU_OFFSET(16),     eEncodingIEEE754,eFormatFloat,  { LLDB_INVALID_REGNUM,  dwarf_s16,          LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    fpu_s16     }, nullptr, nullptr, nullptr, 0 },
-{   "s17",      NULL,   4,  FPU_OFFSET(17),     eEncodingIEEE754,eFormatFloat,  { LLDB_INVALID_REGNUM,  dwarf_s17,          LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    fpu_s17     }, nullptr, nullptr, nullptr, 0 },
-{   "s18",      NULL,   4,  FPU_OFFSET(18),     eEncodingIEEE754,eFormatFloat,  { LLDB_INVALID_REGNUM,  dwarf_s18,          LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    fpu_s18     }, nullptr, nullptr, nullptr, 0 },
-{   "s19",      NULL,   4,  FPU_OFFSET(19),     eEncodingIEEE754,eFormatFloat,  { LLDB_INVALID_REGNUM,  dwarf_s19,          LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    fpu_s19     }, nullptr, nullptr, nullptr, 0 },
-{   "s20",      NULL,   4,  FPU_OFFSET(20),     eEncodingIEEE754,eFormatFloat,  { LLDB_INVALID_REGNUM,  dwarf_s20,          LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    fpu_s20     }, nullptr, nullptr, nullptr, 0 },
-{   "s21",      NULL,   4,  FPU_OFFSET(21),     eEncodingIEEE754,eFormatFloat,  { LLDB_INVALID_REGNUM,  dwarf_s21,          LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    fpu_s21     }, nullptr, nullptr, nullptr, 0 },
-{   "s22",      NULL,   4,  FPU_OFFSET(22),     eEncodingIEEE754,eFormatFloat,  { LLDB_INVALID_REGNUM,  dwarf_s22,          LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    fpu_s22     }, nullptr, nullptr, nullptr, 0 },
-{   "s23",      NULL,   4,  FPU_OFFSET(23),     eEncodingIEEE754,eFormatFloat,  { LLDB_INVALID_REGNUM,  dwarf_s23,          LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    fpu_s23     }, nullptr, nullptr, nullptr, 0 },
-{   "s24",      NULL,   4,  FPU_OFFSET(24),     eEncodingIEEE754,eFormatFloat,  { LLDB_INVALID_REGNUM,  dwarf_s24,          LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    fpu_s24     }, nullptr, nullptr, nullptr, 0 },
-{   "s25",      NULL,   4,  FPU_OFFSET(25),     eEncodingIEEE754,eFormatFloat,  { LLDB_INVALID_REGNUM,  dwarf_s25,          LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    fpu_s25     }, nullptr, nullptr, nullptr, 0 },
-{   "s26",      NULL,   4,  FPU_OFFSET(26),     eEncodingIEEE754,eFormatFloat,  { LLDB_INVALID_REGNUM,  dwarf_s26,          LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    fpu_s26     }, nullptr, nullptr, nullptr, 0 },
-{   "s27",      NULL,   4,  FPU_OFFSET(27),     eEncodingIEEE754,eFormatFloat,  { LLDB_INVALID_REGNUM,  dwarf_s27,          LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    fpu_s27     }, nullptr, nullptr, nullptr, 0 },
-{   "s28",      NULL,   4,  FPU_OFFSET(28),     eEncodingIEEE754,eFormatFloat,  { LLDB_INVALID_REGNUM,  dwarf_s28,          LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    fpu_s28     }, nullptr, nullptr, nullptr, 0 },
-{   "s29",      NULL,   4,  FPU_OFFSET(29),     eEncodingIEEE754,eFormatFloat,  { LLDB_INVALID_REGNUM,  dwarf_s29,          LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    fpu_s29     }, nullptr, nullptr, nullptr, 0 },
-{   "s30",      NULL,   4,  FPU_OFFSET(30),     eEncodingIEEE754,eFormatFloat,  { LLDB_INVALID_REGNUM,  dwarf_s30,          LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    fpu_s30     }, nullptr, nullptr, nullptr, 0 },
-{   "s31",      NULL,   4,  FPU_OFFSET(31),     eEncodingIEEE754,eFormatFloat,  { LLDB_INVALID_REGNUM,  dwarf_s31,          LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    fpu_s31     }, nullptr, nullptr, nullptr, 0 },
-{   "fpscr",    NULL,   4,  FPU_OFFSET(32),     eEncodingUint,  eFormatHex,     { LLDB_INVALID_REGNUM,  LLDB_INVALID_REGNUM,LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    fpu_fpscr   }, nullptr, nullptr, nullptr, 0 },
-
-{   "exception",NULL,   4,  EXC_OFFSET(0),      eEncodingUint,  eFormatHex,     { LLDB_INVALID_REGNUM,  LLDB_INVALID_REGNUM,LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    exc_exception },    nullptr, nullptr, nullptr, 0 },
-{   "fsr",      NULL,   4,  EXC_OFFSET(1),      eEncodingUint,  eFormatHex,     { LLDB_INVALID_REGNUM,  LLDB_INVALID_REGNUM,LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    exc_fsr       },    nullptr, nullptr, nullptr, 0 },
-{   "far",      NULL,   4,  EXC_OFFSET(2),      eEncodingUint,  eFormatHex,     { LLDB_INVALID_REGNUM,  LLDB_INVALID_REGNUM,LLDB_INVALID_REGNUM,        LLDB_INVALID_REGNUM,    exc_far       },    nullptr, nullptr, nullptr, 0 },
-
-{   DEFINE_DBG (bvr, 0) },
-{   DEFINE_DBG (bvr, 1) },
-{   DEFINE_DBG (bvr, 2) },
-{   DEFINE_DBG (bvr, 3) },
-{   DEFINE_DBG (bvr, 4) },
-{   DEFINE_DBG (bvr, 5) },
-{   DEFINE_DBG (bvr, 6) },
-{   DEFINE_DBG (bvr, 7) },
-{   DEFINE_DBG (bvr, 8) },
-{   DEFINE_DBG (bvr, 9) },
-{   DEFINE_DBG (bvr, 10) },
-{   DEFINE_DBG (bvr, 11) },
-{   DEFINE_DBG (bvr, 12) },
-{   DEFINE_DBG (bvr, 13) },
-{   DEFINE_DBG (bvr, 14) },
-{   DEFINE_DBG (bvr, 15) },
-
-{   DEFINE_DBG (bcr, 0) },
-{   DEFINE_DBG (bcr, 1) },
-{   DEFINE_DBG (bcr, 2) },
-{   DEFINE_DBG (bcr, 3) },
-{   DEFINE_DBG (bcr, 4) },
-{   DEFINE_DBG (bcr, 5) },
-{   DEFINE_DBG (bcr, 6) },
-{   DEFINE_DBG (bcr, 7) },
-{   DEFINE_DBG (bcr, 8) },
-{   DEFINE_DBG (bcr, 9) },
-{   DEFINE_DBG (bcr, 10) },
-{   DEFINE_DBG (bcr, 11) },
-{   DEFINE_DBG (bcr, 12) },
-{   DEFINE_DBG (bcr, 13) },
-{   DEFINE_DBG (bcr, 14) },
-{   DEFINE_DBG (bcr, 15) },
-
-{   DEFINE_DBG (wvr, 0) },
-{   DEFINE_DBG (wvr, 1) },
-{   DEFINE_DBG (wvr, 2) },
-{   DEFINE_DBG (wvr, 3) },
-{   DEFINE_DBG (wvr, 4) },
-{   DEFINE_DBG (wvr, 5) },
-{   DEFINE_DBG (wvr, 6) },
-{   DEFINE_DBG (wvr, 7) },
-{   DEFINE_DBG (wvr, 8) },
-{   DEFINE_DBG (wvr, 9) },
-{   DEFINE_DBG (wvr, 10) },
-{   DEFINE_DBG (wvr, 11) },
-{   DEFINE_DBG (wvr, 12) },
-{   DEFINE_DBG (wvr, 13) },
-{   DEFINE_DBG (wvr, 14) },
-{   DEFINE_DBG (wvr, 15) },
-
-{   DEFINE_DBG (wcr, 0) },
-{   DEFINE_DBG (wcr, 1) },
-{   DEFINE_DBG (wcr, 2) },
-{   DEFINE_DBG (wcr, 3) },
-{   DEFINE_DBG (wcr, 4) },
-{   DEFINE_DBG (wcr, 5) },
-{   DEFINE_DBG (wcr, 6) },
-{   DEFINE_DBG (wcr, 7) },
-{   DEFINE_DBG (wcr, 8) },
-{   DEFINE_DBG (wcr, 9) },
-{   DEFINE_DBG (wcr, 10) },
-{   DEFINE_DBG (wcr, 11) },
-{   DEFINE_DBG (wcr, 12) },
-{   DEFINE_DBG (wcr, 13) },
-{   DEFINE_DBG (wcr, 14) },
-{   DEFINE_DBG (wcr, 15) }
-};
+    // General purpose registers
+    //  NAME        ALT     SZ  OFFSET              ENCODING        FORMAT
+    //  EH_FRAME                DWARF               GENERIC
+    //  PROCESS PLUGIN          LLDB NATIVE
+    //  ======      ======= ==  =============       =============   ============
+    //  ===============         ===============     =========================
+    //  =====================   =============
+    {"r0",
+     NULL,
+     4,
+     GPR_OFFSET(0),
+     eEncodingUint,
+     eFormatHex,
+     {ehframe_r0, dwarf_r0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_r0},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"r1",
+     NULL,
+     4,
+     GPR_OFFSET(1),
+     eEncodingUint,
+     eFormatHex,
+     {ehframe_r1, dwarf_r1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_r1},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"r2",
+     NULL,
+     4,
+     GPR_OFFSET(2),
+     eEncodingUint,
+     eFormatHex,
+     {ehframe_r2, dwarf_r2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_r2},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"r3",
+     NULL,
+     4,
+     GPR_OFFSET(3),
+     eEncodingUint,
+     eFormatHex,
+     {ehframe_r3, dwarf_r3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_r3},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"r4",
+     NULL,
+     4,
+     GPR_OFFSET(4),
+     eEncodingUint,
+     eFormatHex,
+     {ehframe_r4, dwarf_r4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_r4},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"r5",
+     NULL,
+     4,
+     GPR_OFFSET(5),
+     eEncodingUint,
+     eFormatHex,
+     {ehframe_r5, dwarf_r5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_r5},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"r6",
+     NULL,
+     4,
+     GPR_OFFSET(6),
+     eEncodingUint,
+     eFormatHex,
+     {ehframe_r6, dwarf_r6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_r6},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"r7",
+     NULL,
+     4,
+     GPR_OFFSET(7),
+     eEncodingUint,
+     eFormatHex,
+     {ehframe_r7, dwarf_r7, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM,
+      gpr_r7},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"r8",
+     NULL,
+     4,
+     GPR_OFFSET(8),
+     eEncodingUint,
+     eFormatHex,
+     {ehframe_r8, dwarf_r8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_r8},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"r9",
+     NULL,
+     4,
+     GPR_OFFSET(9),
+     eEncodingUint,
+     eFormatHex,
+     {ehframe_r9, dwarf_r9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gpr_r9},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"r10",
+     NULL,
+     4,
+     GPR_OFFSET(10),
+     eEncodingUint,
+     eFormatHex,
+     {ehframe_r10, dwarf_r10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      gpr_r10},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"r11",
+     NULL,
+     4,
+     GPR_OFFSET(11),
+     eEncodingUint,
+     eFormatHex,
+     {ehframe_r11, dwarf_r11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      gpr_r11},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"r12",
+     NULL,
+     4,
+     GPR_OFFSET(12),
+     eEncodingUint,
+     eFormatHex,
+     {ehframe_r12, dwarf_r12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      gpr_r12},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"sp",
+     "r13",
+     4,
+     GPR_OFFSET(13),
+     eEncodingUint,
+     eFormatHex,
+     {ehframe_sp, dwarf_sp, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM,
+      gpr_sp},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"lr",
+     "r14",
+     4,
+     GPR_OFFSET(14),
+     eEncodingUint,
+     eFormatHex,
+     {ehframe_lr, dwarf_lr, LLDB_REGNUM_GENERIC_RA, LLDB_INVALID_REGNUM,
+      gpr_lr},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"pc",
+     "r15",
+     4,
+     GPR_OFFSET(15),
+     eEncodingUint,
+     eFormatHex,
+     {ehframe_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM,
+      gpr_pc},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"cpsr",
+     "psr",
+     4,
+     GPR_OFFSET(16),
+     eEncodingUint,
+     eFormatHex,
+     {ehframe_cpsr, dwarf_cpsr, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM,
+      gpr_cpsr},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+
+    {"s0",
+     NULL,
+     4,
+     FPU_OFFSET(0),
+     eEncodingIEEE754,
+     eFormatFloat,
+     {LLDB_INVALID_REGNUM, dwarf_s0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      fpu_s0},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"s1",
+     NULL,
+     4,
+     FPU_OFFSET(1),
+     eEncodingIEEE754,
+     eFormatFloat,
+     {LLDB_INVALID_REGNUM, dwarf_s1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      fpu_s1},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"s2",
+     NULL,
+     4,
+     FPU_OFFSET(2),
+     eEncodingIEEE754,
+     eFormatFloat,
+     {LLDB_INVALID_REGNUM, dwarf_s2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      fpu_s2},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"s3",
+     NULL,
+     4,
+     FPU_OFFSET(3),
+     eEncodingIEEE754,
+     eFormatFloat,
+     {LLDB_INVALID_REGNUM, dwarf_s3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      fpu_s3},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"s4",
+     NULL,
+     4,
+     FPU_OFFSET(4),
+     eEncodingIEEE754,
+     eFormatFloat,
+     {LLDB_INVALID_REGNUM, dwarf_s4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      fpu_s4},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"s5",
+     NULL,
+     4,
+     FPU_OFFSET(5),
+     eEncodingIEEE754,
+     eFormatFloat,
+     {LLDB_INVALID_REGNUM, dwarf_s5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      fpu_s5},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"s6",
+     NULL,
+     4,
+     FPU_OFFSET(6),
+     eEncodingIEEE754,
+     eFormatFloat,
+     {LLDB_INVALID_REGNUM, dwarf_s6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      fpu_s6},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"s7",
+     NULL,
+     4,
+     FPU_OFFSET(7),
+     eEncodingIEEE754,
+     eFormatFloat,
+     {LLDB_INVALID_REGNUM, dwarf_s7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      fpu_s7},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"s8",
+     NULL,
+     4,
+     FPU_OFFSET(8),
+     eEncodingIEEE754,
+     eFormatFloat,
+     {LLDB_INVALID_REGNUM, dwarf_s8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      fpu_s8},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"s9",
+     NULL,
+     4,
+     FPU_OFFSET(9),
+     eEncodingIEEE754,
+     eFormatFloat,
+     {LLDB_INVALID_REGNUM, dwarf_s9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      fpu_s9},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"s10",
+     NULL,
+     4,
+     FPU_OFFSET(10),
+     eEncodingIEEE754,
+     eFormatFloat,
+     {LLDB_INVALID_REGNUM, dwarf_s10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      fpu_s10},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"s11",
+     NULL,
+     4,
+     FPU_OFFSET(11),
+     eEncodingIEEE754,
+     eFormatFloat,
+     {LLDB_INVALID_REGNUM, dwarf_s11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      fpu_s11},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"s12",
+     NULL,
+     4,
+     FPU_OFFSET(12),
+     eEncodingIEEE754,
+     eFormatFloat,
+     {LLDB_INVALID_REGNUM, dwarf_s12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      fpu_s12},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"s13",
+     NULL,
+     4,
+     FPU_OFFSET(13),
+     eEncodingIEEE754,
+     eFormatFloat,
+     {LLDB_INVALID_REGNUM, dwarf_s13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      fpu_s13},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"s14",
+     NULL,
+     4,
+     FPU_OFFSET(14),
+     eEncodingIEEE754,
+     eFormatFloat,
+     {LLDB_INVALID_REGNUM, dwarf_s14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      fpu_s14},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"s15",
+     NULL,
+     4,
+     FPU_OFFSET(15),
+     eEncodingIEEE754,
+     eFormatFloat,
+     {LLDB_INVALID_REGNUM, dwarf_s15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      fpu_s15},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"s16",
+     NULL,
+     4,
+     FPU_OFFSET(16),
+     eEncodingIEEE754,
+     eFormatFloat,
+     {LLDB_INVALID_REGNUM, dwarf_s16, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      fpu_s16},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"s17",
+     NULL,
+     4,
+     FPU_OFFSET(17),
+     eEncodingIEEE754,
+     eFormatFloat,
+     {LLDB_INVALID_REGNUM, dwarf_s17, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      fpu_s17},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"s18",
+     NULL,
+     4,
+     FPU_OFFSET(18),
+     eEncodingIEEE754,
+     eFormatFloat,
+     {LLDB_INVALID_REGNUM, dwarf_s18, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      fpu_s18},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"s19",
+     NULL,
+     4,
+     FPU_OFFSET(19),
+     eEncodingIEEE754,
+     eFormatFloat,
+     {LLDB_INVALID_REGNUM, dwarf_s19, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      fpu_s19},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"s20",
+     NULL,
+     4,
+     FPU_OFFSET(20),
+     eEncodingIEEE754,
+     eFormatFloat,
+     {LLDB_INVALID_REGNUM, dwarf_s20, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      fpu_s20},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"s21",
+     NULL,
+     4,
+     FPU_OFFSET(21),
+     eEncodingIEEE754,
+     eFormatFloat,
+     {LLDB_INVALID_REGNUM, dwarf_s21, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      fpu_s21},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"s22",
+     NULL,
+     4,
+     FPU_OFFSET(22),
+     eEncodingIEEE754,
+     eFormatFloat,
+     {LLDB_INVALID_REGNUM, dwarf_s22, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      fpu_s22},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"s23",
+     NULL,
+     4,
+     FPU_OFFSET(23),
+     eEncodingIEEE754,
+     eFormatFloat,
+     {LLDB_INVALID_REGNUM, dwarf_s23, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      fpu_s23},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"s24",
+     NULL,
+     4,
+     FPU_OFFSET(24),
+     eEncodingIEEE754,
+     eFormatFloat,
+     {LLDB_INVALID_REGNUM, dwarf_s24, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      fpu_s24},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"s25",
+     NULL,
+     4,
+     FPU_OFFSET(25),
+     eEncodingIEEE754,
+     eFormatFloat,
+     {LLDB_INVALID_REGNUM, dwarf_s25, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      fpu_s25},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"s26",
+     NULL,
+     4,
+     FPU_OFFSET(26),
+     eEncodingIEEE754,
+     eFormatFloat,
+     {LLDB_INVALID_REGNUM, dwarf_s26, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      fpu_s26},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"s27",
+     NULL,
+     4,
+     FPU_OFFSET(27),
+     eEncodingIEEE754,
+     eFormatFloat,
+     {LLDB_INVALID_REGNUM, dwarf_s27, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      fpu_s27},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"s28",
+     NULL,
+     4,
+     FPU_OFFSET(28),
+     eEncodingIEEE754,
+     eFormatFloat,
+     {LLDB_INVALID_REGNUM, dwarf_s28, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      fpu_s28},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"s29",
+     NULL,
+     4,
+     FPU_OFFSET(29),
+     eEncodingIEEE754,
+     eFormatFloat,
+     {LLDB_INVALID_REGNUM, dwarf_s29, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      fpu_s29},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"s30",
+     NULL,
+     4,
+     FPU_OFFSET(30),
+     eEncodingIEEE754,
+     eFormatFloat,
+     {LLDB_INVALID_REGNUM, dwarf_s30, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      fpu_s30},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"s31",
+     NULL,
+     4,
+     FPU_OFFSET(31),
+     eEncodingIEEE754,
+     eFormatFloat,
+     {LLDB_INVALID_REGNUM, dwarf_s31, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      fpu_s31},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"fpscr",
+     NULL,
+     4,
+     FPU_OFFSET(32),
+     eEncodingUint,
+     eFormatHex,
+     {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      LLDB_INVALID_REGNUM, fpu_fpscr},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+
+    {"exception",
+     NULL,
+     4,
+     EXC_OFFSET(0),
+     eEncodingUint,
+     eFormatHex,
+     {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      LLDB_INVALID_REGNUM, exc_exception},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"fsr",
+     NULL,
+     4,
+     EXC_OFFSET(1),
+     eEncodingUint,
+     eFormatHex,
+     {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      LLDB_INVALID_REGNUM, exc_fsr},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+    {"far",
+     NULL,
+     4,
+     EXC_OFFSET(2),
+     eEncodingUint,
+     eFormatHex,
+     {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+      LLDB_INVALID_REGNUM, exc_far},
+     nullptr,
+     nullptr,
+     nullptr,
+     0},
+
+    {DEFINE_DBG(bvr, 0)},
+    {DEFINE_DBG(bvr, 1)},
+    {DEFINE_DBG(bvr, 2)},
+    {DEFINE_DBG(bvr, 3)},
+    {DEFINE_DBG(bvr, 4)},
+    {DEFINE_DBG(bvr, 5)},
+    {DEFINE_DBG(bvr, 6)},
+    {DEFINE_DBG(bvr, 7)},
+    {DEFINE_DBG(bvr, 8)},
+    {DEFINE_DBG(bvr, 9)},
+    {DEFINE_DBG(bvr, 10)},
+    {DEFINE_DBG(bvr, 11)},
+    {DEFINE_DBG(bvr, 12)},
+    {DEFINE_DBG(bvr, 13)},
+    {DEFINE_DBG(bvr, 14)},
+    {DEFINE_DBG(bvr, 15)},
+
+    {DEFINE_DBG(bcr, 0)},
+    {DEFINE_DBG(bcr, 1)},
+    {DEFINE_DBG(bcr, 2)},
+    {DEFINE_DBG(bcr, 3)},
+    {DEFINE_DBG(bcr, 4)},
+    {DEFINE_DBG(bcr, 5)},
+    {DEFINE_DBG(bcr, 6)},
+    {DEFINE_DBG(bcr, 7)},
+    {DEFINE_DBG(bcr, 8)},
+    {DEFINE_DBG(bcr, 9)},
+    {DEFINE_DBG(bcr, 10)},
+    {DEFINE_DBG(bcr, 11)},
+    {DEFINE_DBG(bcr, 12)},
+    {DEFINE_DBG(bcr, 13)},
+    {DEFINE_DBG(bcr, 14)},
+    {DEFINE_DBG(bcr, 15)},
+
+    {DEFINE_DBG(wvr, 0)},
+    {DEFINE_DBG(wvr, 1)},
+    {DEFINE_DBG(wvr, 2)},
+    {DEFINE_DBG(wvr, 3)},
+    {DEFINE_DBG(wvr, 4)},
+    {DEFINE_DBG(wvr, 5)},
+    {DEFINE_DBG(wvr, 6)},
+    {DEFINE_DBG(wvr, 7)},
+    {DEFINE_DBG(wvr, 8)},
+    {DEFINE_DBG(wvr, 9)},
+    {DEFINE_DBG(wvr, 10)},
+    {DEFINE_DBG(wvr, 11)},
+    {DEFINE_DBG(wvr, 12)},
+    {DEFINE_DBG(wvr, 13)},
+    {DEFINE_DBG(wvr, 14)},
+    {DEFINE_DBG(wvr, 15)},
+
+    {DEFINE_DBG(wcr, 0)},
+    {DEFINE_DBG(wcr, 1)},
+    {DEFINE_DBG(wcr, 2)},
+    {DEFINE_DBG(wcr, 3)},
+    {DEFINE_DBG(wcr, 4)},
+    {DEFINE_DBG(wcr, 5)},
+    {DEFINE_DBG(wcr, 6)},
+    {DEFINE_DBG(wcr, 7)},
+    {DEFINE_DBG(wcr, 8)},
+    {DEFINE_DBG(wcr, 9)},
+    {DEFINE_DBG(wcr, 10)},
+    {DEFINE_DBG(wcr, 11)},
+    {DEFINE_DBG(wcr, 12)},
+    {DEFINE_DBG(wcr, 13)},
+    {DEFINE_DBG(wcr, 14)},
+    {DEFINE_DBG(wcr, 15)}};
 
 // General purpose registers
-static uint32_t
-g_gpr_regnums[] =
-{
-    gpr_r0,
-    gpr_r1,
-    gpr_r2,
-    gpr_r3,
-    gpr_r4,
-    gpr_r5,
-    gpr_r6,
-    gpr_r7,
-    gpr_r8,
-    gpr_r9,
-    gpr_r10,
-    gpr_r11,
-    gpr_r12,
-    gpr_sp,
-    gpr_lr,
-    gpr_pc,
-    gpr_cpsr
-};
+static uint32_t g_gpr_regnums[] = {
+    gpr_r0, gpr_r1,  gpr_r2,  gpr_r3,  gpr_r4, gpr_r5, gpr_r6, gpr_r7,  gpr_r8,
+    gpr_r9, gpr_r10, gpr_r11, gpr_r12, gpr_sp, gpr_lr, gpr_pc, gpr_cpsr};
 
 // Floating point registers
-static uint32_t
-g_fpu_regnums[] =
-{
-    fpu_s0,
-    fpu_s1,
-    fpu_s2,
-    fpu_s3,
-    fpu_s4,
-    fpu_s5,
-    fpu_s6,
-    fpu_s7,
-    fpu_s8,
-    fpu_s9,
-    fpu_s10,
-    fpu_s11,
-    fpu_s12,
-    fpu_s13,
-    fpu_s14,
-    fpu_s15,
-    fpu_s16,
-    fpu_s17,
-    fpu_s18,
-    fpu_s19,
-    fpu_s20,
-    fpu_s21,
-    fpu_s22,
-    fpu_s23,
-    fpu_s24,
-    fpu_s25,
-    fpu_s26,
-    fpu_s27,
-    fpu_s28,
-    fpu_s29,
-    fpu_s30,
-    fpu_s31,
-    fpu_fpscr,
+static uint32_t g_fpu_regnums[] = {
+    fpu_s0,  fpu_s1,  fpu_s2,  fpu_s3,  fpu_s4,    fpu_s5,  fpu_s6,
+    fpu_s7,  fpu_s8,  fpu_s9,  fpu_s10, fpu_s11,   fpu_s12, fpu_s13,
+    fpu_s14, fpu_s15, fpu_s16, fpu_s17, fpu_s18,   fpu_s19, fpu_s20,
+    fpu_s21, fpu_s22, fpu_s23, fpu_s24, fpu_s25,   fpu_s26, fpu_s27,
+    fpu_s28, fpu_s29, fpu_s30, fpu_s31, fpu_fpscr,
 };
 
 // Exception registers
 
-static uint32_t
-g_exc_regnums[] =
-{
-    exc_exception,
-    exc_fsr,
-    exc_far,
+static uint32_t g_exc_regnums[] = {
+    exc_exception, exc_fsr, exc_far,
 };
 
 static size_t k_num_register_infos = llvm::array_lengthof(g_register_infos);
 
-RegisterContextDarwin_arm::RegisterContextDarwin_arm(Thread &thread, uint32_t concrete_frame_idx) :
-    RegisterContext(thread, concrete_frame_idx),
-    gpr(),
-    fpu(),
-    exc()
-{
-    uint32_t i;
-    for (i=0; i<kNumErrors; i++)
-    {
-        gpr_errs[i] = -1;
-        fpu_errs[i] = -1;
-        exc_errs[i] = -1;
-    }
-}
-
-RegisterContextDarwin_arm::~RegisterContextDarwin_arm()
-{
-}
-
-
-void
-RegisterContextDarwin_arm::InvalidateAllRegisters ()
-{
-    InvalidateAllRegisterStates();
-}
-
-
-size_t
-RegisterContextDarwin_arm::GetRegisterCount ()
-{
-    assert(k_num_register_infos == k_num_registers);
-    return k_num_registers;
+RegisterContextDarwin_arm::RegisterContextDarwin_arm(
+    Thread &thread, uint32_t concrete_frame_idx)
+    : RegisterContext(thread, concrete_frame_idx), gpr(), fpu(), exc() {
+  uint32_t i;
+  for (i = 0; i < kNumErrors; i++) {
+    gpr_errs[i] = -1;
+    fpu_errs[i] = -1;
+    exc_errs[i] = -1;
+  }
+}
+
+RegisterContextDarwin_arm::~RegisterContextDarwin_arm() {}
+
+void RegisterContextDarwin_arm::InvalidateAllRegisters() {
+  InvalidateAllRegisterStates();
+}
+
+size_t RegisterContextDarwin_arm::GetRegisterCount() {
+  assert(k_num_register_infos == k_num_registers);
+  return k_num_registers;
 }
 
 const RegisterInfo *
-RegisterContextDarwin_arm::GetRegisterInfoAtIndex (size_t reg)
-{
-    assert(k_num_register_infos == k_num_registers);
-    if (reg < k_num_registers)
-        return &g_register_infos[reg];
-    return NULL;
+RegisterContextDarwin_arm::GetRegisterInfoAtIndex(size_t reg) {
+  assert(k_num_register_infos == k_num_registers);
+  if (reg < k_num_registers)
+    return &g_register_infos[reg];
+  return NULL;
 }
 
-size_t
-RegisterContextDarwin_arm::GetRegisterInfosCount ()
-{
-    return k_num_register_infos;
+size_t RegisterContextDarwin_arm::GetRegisterInfosCount() {
+  return k_num_register_infos;
 }
 
-const RegisterInfo *
-RegisterContextDarwin_arm::GetRegisterInfos ()
-{
-    return g_register_infos;
+const RegisterInfo *RegisterContextDarwin_arm::GetRegisterInfos() {
+  return g_register_infos;
 }
 
-
 // Number of registers in each register set
 const size_t k_num_gpr_registers = llvm::array_lengthof(g_gpr_regnums);
 const size_t k_num_fpu_registers = llvm::array_lengthof(g_fpu_regnums);
@@ -449,782 +972,799 @@ const size_t k_num_exc_registers = llvm:
 // of zero is for all registers, followed by other registers sets. The
 // register information for the all register set need not be filled in.
 //----------------------------------------------------------------------
-static const RegisterSet g_reg_sets[] =
-{
-    { "General Purpose Registers",  "gpr",  k_num_gpr_registers,    g_gpr_regnums,      },
-    { "Floating Point Registers",   "fpu",  k_num_fpu_registers,    g_fpu_regnums       },
-    { "Exception State Registers",  "exc",  k_num_exc_registers,    g_exc_regnums       }
-};
+static const RegisterSet g_reg_sets[] = {
+    {
+        "General Purpose Registers", "gpr", k_num_gpr_registers, g_gpr_regnums,
+    },
+    {"Floating Point Registers", "fpu", k_num_fpu_registers, g_fpu_regnums},
+    {"Exception State Registers", "exc", k_num_exc_registers, g_exc_regnums}};
 
 const size_t k_num_regsets = llvm::array_lengthof(g_reg_sets);
 
-
-size_t
-RegisterContextDarwin_arm::GetRegisterSetCount ()
-{
-    return k_num_regsets;
+size_t RegisterContextDarwin_arm::GetRegisterSetCount() {
+  return k_num_regsets;
 }
 
-const RegisterSet *
-RegisterContextDarwin_arm::GetRegisterSet (size_t reg_set)
-{
-    if (reg_set < k_num_regsets)
-        return &g_reg_sets[reg_set];
-    return NULL;
+const RegisterSet *RegisterContextDarwin_arm::GetRegisterSet(size_t reg_set) {
+  if (reg_set < k_num_regsets)
+    return &g_reg_sets[reg_set];
+  return NULL;
 }
 
-
 //----------------------------------------------------------------------
 // Register information definitions for 32 bit i386.
 //----------------------------------------------------------------------
-int
-RegisterContextDarwin_arm::GetSetForNativeRegNum (int reg)
-{
-    if (reg < fpu_s0)
-        return GPRRegSet;
-    else if (reg < exc_exception)
-        return FPURegSet;
-    else if (reg < k_num_registers)
-        return EXCRegSet;
-    return -1;
-}
-
-int
-RegisterContextDarwin_arm::ReadGPR (bool force)
-{
-    int set = GPRRegSet;
-    if (force || !RegisterSetIsCached(set))
-    {
-        SetError(set, Read, DoReadGPR(GetThreadID(), set, gpr));
-    }
-    return GetError(GPRRegSet, Read);
-}
-
-int
-RegisterContextDarwin_arm::ReadFPU (bool force)
-{
-    int set = FPURegSet;
-    if (force || !RegisterSetIsCached(set))
-    {
-        SetError(set, Read, DoReadFPU(GetThreadID(), set, fpu));
-    }
-    return GetError(FPURegSet, Read);
-}
-
-int
-RegisterContextDarwin_arm::ReadEXC (bool force)
-{
-    int set = EXCRegSet;
-    if (force || !RegisterSetIsCached(set))
-    {
-        SetError(set, Read, DoReadEXC(GetThreadID(), set, exc));
-    }
-    return GetError(EXCRegSet, Read);
-}
-
-int
-RegisterContextDarwin_arm::ReadDBG (bool force)
-{
-    int set = DBGRegSet;
-    if (force || !RegisterSetIsCached(set))
-    {
-        SetError(set, Read, DoReadDBG(GetThreadID(), set, dbg));
-    }
-    return GetError(DBGRegSet, Read);
-}
-
-int
-RegisterContextDarwin_arm::WriteGPR ()
-{
-    int set = GPRRegSet;
-    if (!RegisterSetIsCached(set))
-    {
-        SetError (set, Write, -1);
-        return KERN_INVALID_ARGUMENT;
-    }
-    SetError (set, Write, DoWriteGPR(GetThreadID(), set, gpr));
-    SetError (set, Read, -1);
-    return GetError(GPRRegSet, Write);
-}
-
-int
-RegisterContextDarwin_arm::WriteFPU ()
-{
-    int set = FPURegSet;
-    if (!RegisterSetIsCached(set))
-    {
-        SetError (set, Write, -1);
-        return KERN_INVALID_ARGUMENT;
-    }
-    SetError (set, Write, DoWriteFPU(GetThreadID(), set, fpu));
-    SetError (set, Read, -1);
-    return GetError(FPURegSet, Write);
-}
-
-int
-RegisterContextDarwin_arm::WriteEXC ()
-{
-    int set = EXCRegSet;
-    if (!RegisterSetIsCached(set))
-    {
-        SetError (set, Write, -1);
-        return KERN_INVALID_ARGUMENT;
-    }
-    SetError (set, Write, DoWriteEXC(GetThreadID(), set, exc));
-    SetError (set, Read, -1);
-    return GetError(EXCRegSet, Write);
-}
-
-int
-RegisterContextDarwin_arm::WriteDBG ()
-{
-    int set = DBGRegSet;
-    if (!RegisterSetIsCached(set))
-    {
-        SetError (set, Write, -1);
-        return KERN_INVALID_ARGUMENT;
-    }
-    SetError (set, Write, DoWriteDBG(GetThreadID(), set, dbg));
-    SetError (set, Read, -1);
-    return GetError(DBGRegSet, Write);
-}
-
-
-int
-RegisterContextDarwin_arm::ReadRegisterSet (uint32_t set, bool force)
-{
-    switch (set)
-    {
-    case GPRRegSet:    return ReadGPR(force);
-    case GPRAltRegSet: return ReadGPR(force);
-    case FPURegSet:    return ReadFPU(force);
-    case EXCRegSet:    return ReadEXC(force);
-    case DBGRegSet:    return ReadDBG(force);
-    default: break;
-    }
+int RegisterContextDarwin_arm::GetSetForNativeRegNum(int reg) {
+  if (reg < fpu_s0)
+    return GPRRegSet;
+  else if (reg < exc_exception)
+    return FPURegSet;
+  else if (reg < k_num_registers)
+    return EXCRegSet;
+  return -1;
+}
+
+int RegisterContextDarwin_arm::ReadGPR(bool force) {
+  int set = GPRRegSet;
+  if (force || !RegisterSetIsCached(set)) {
+    SetError(set, Read, DoReadGPR(GetThreadID(), set, gpr));
+  }
+  return GetError(GPRRegSet, Read);
+}
+
+int RegisterContextDarwin_arm::ReadFPU(bool force) {
+  int set = FPURegSet;
+  if (force || !RegisterSetIsCached(set)) {
+    SetError(set, Read, DoReadFPU(GetThreadID(), set, fpu));
+  }
+  return GetError(FPURegSet, Read);
+}
+
+int RegisterContextDarwin_arm::ReadEXC(bool force) {
+  int set = EXCRegSet;
+  if (force || !RegisterSetIsCached(set)) {
+    SetError(set, Read, DoReadEXC(GetThreadID(), set, exc));
+  }
+  return GetError(EXCRegSet, Read);
+}
+
+int RegisterContextDarwin_arm::ReadDBG(bool force) {
+  int set = DBGRegSet;
+  if (force || !RegisterSetIsCached(set)) {
+    SetError(set, Read, DoReadDBG(GetThreadID(), set, dbg));
+  }
+  return GetError(DBGRegSet, Read);
+}
+
+int RegisterContextDarwin_arm::WriteGPR() {
+  int set = GPRRegSet;
+  if (!RegisterSetIsCached(set)) {
+    SetError(set, Write, -1);
     return KERN_INVALID_ARGUMENT;
+  }
+  SetError(set, Write, DoWriteGPR(GetThreadID(), set, gpr));
+  SetError(set, Read, -1);
+  return GetError(GPRRegSet, Write);
 }
 
-int
-RegisterContextDarwin_arm::WriteRegisterSet (uint32_t set)
-{
-    // Make sure we have a valid context to set.
-    if (RegisterSetIsCached(set))
-    {
-        switch (set)
-        {
-        case GPRRegSet:    return WriteGPR();
-        case GPRAltRegSet: return WriteGPR();
-        case FPURegSet:    return WriteFPU();
-        case EXCRegSet:    return WriteEXC();
-        case DBGRegSet:    return WriteDBG();
-        default: break;
-        }
-    }
+int RegisterContextDarwin_arm::WriteFPU() {
+  int set = FPURegSet;
+  if (!RegisterSetIsCached(set)) {
+    SetError(set, Write, -1);
     return KERN_INVALID_ARGUMENT;
+  }
+  SetError(set, Write, DoWriteFPU(GetThreadID(), set, fpu));
+  SetError(set, Read, -1);
+  return GetError(FPURegSet, Write);
 }
 
-void
-RegisterContextDarwin_arm::LogDBGRegisters (Log *log, const DBG& dbg)
-{
-    if (log)
-    {
-        for (uint32_t i=0; i<16; i++)
-            log->Printf("BVR%-2u/BCR%-2u = { 0x%8.8x, 0x%8.8x } WVR%-2u/WCR%-2u = { 0x%8.8x, 0x%8.8x }",
-                i, i, dbg.bvr[i], dbg.bcr[i],
-                i, i, dbg.wvr[i], dbg.wcr[i]);
-    }
+int RegisterContextDarwin_arm::WriteEXC() {
+  int set = EXCRegSet;
+  if (!RegisterSetIsCached(set)) {
+    SetError(set, Write, -1);
+    return KERN_INVALID_ARGUMENT;
+  }
+  SetError(set, Write, DoWriteEXC(GetThreadID(), set, exc));
+  SetError(set, Read, -1);
+  return GetError(EXCRegSet, Write);
 }
 
-
-bool
-RegisterContextDarwin_arm::ReadRegister (const RegisterInfo *reg_info, RegisterValue &value)
-{
-    const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
-    int set = RegisterContextDarwin_arm::GetSetForNativeRegNum (reg);
-
-    if (set == -1)
-        return false;
-
-    if (ReadRegisterSet(set, false) != KERN_SUCCESS)
-        return false;
-
-    switch (reg)
-    {
-    case gpr_r0:
-    case gpr_r1:
-    case gpr_r2:
-    case gpr_r3:
-    case gpr_r4:
-    case gpr_r5:
-    case gpr_r6:
-    case gpr_r7:
-    case gpr_r8:
-    case gpr_r9:
-    case gpr_r10:
-    case gpr_r11:
-    case gpr_r12:
-    case gpr_sp:
-    case gpr_lr:
-    case gpr_pc:
-    case gpr_cpsr:
-        value.SetUInt32 (gpr.r[reg - gpr_r0]);
-        break;
-
-    case fpu_s0:
-    case fpu_s1:
-    case fpu_s2:
-    case fpu_s3:
-    case fpu_s4:
-    case fpu_s5:
-    case fpu_s6:
-    case fpu_s7:
-    case fpu_s8:
-    case fpu_s9:
-    case fpu_s10:
-    case fpu_s11:
-    case fpu_s12:
-    case fpu_s13:
-    case fpu_s14:
-    case fpu_s15:
-    case fpu_s16:
-    case fpu_s17:
-    case fpu_s18:
-    case fpu_s19:
-    case fpu_s20:
-    case fpu_s21:
-    case fpu_s22:
-    case fpu_s23:
-    case fpu_s24:
-    case fpu_s25:
-    case fpu_s26:
-    case fpu_s27:
-    case fpu_s28:
-    case fpu_s29:
-    case fpu_s30:
-    case fpu_s31:
-        value.SetUInt32 (fpu.floats.s[reg], RegisterValue::eTypeFloat);
-        break;
-
-    case fpu_fpscr:
-        value.SetUInt32 (fpu.fpscr);
-        break;
-
-    case exc_exception:
-        value.SetUInt32 (exc.exception);
-        break;
-    case exc_fsr:
-        value.SetUInt32 (exc.fsr);
-        break;
-    case exc_far:
-        value.SetUInt32 (exc.far);
-        break;
-
+int RegisterContextDarwin_arm::WriteDBG() {
+  int set = DBGRegSet;
+  if (!RegisterSetIsCached(set)) {
+    SetError(set, Write, -1);
+    return KERN_INVALID_ARGUMENT;
+  }
+  SetError(set, Write, DoWriteDBG(GetThreadID(), set, dbg));
+  SetError(set, Read, -1);
+  return GetError(DBGRegSet, Write);
+}
+
+int RegisterContextDarwin_arm::ReadRegisterSet(uint32_t set, bool force) {
+  switch (set) {
+  case GPRRegSet:
+    return ReadGPR(force);
+  case GPRAltRegSet:
+    return ReadGPR(force);
+  case FPURegSet:
+    return ReadFPU(force);
+  case EXCRegSet:
+    return ReadEXC(force);
+  case DBGRegSet:
+    return ReadDBG(force);
+  default:
+    break;
+  }
+  return KERN_INVALID_ARGUMENT;
+}
+
+int RegisterContextDarwin_arm::WriteRegisterSet(uint32_t set) {
+  // Make sure we have a valid context to set.
+  if (RegisterSetIsCached(set)) {
+    switch (set) {
+    case GPRRegSet:
+      return WriteGPR();
+    case GPRAltRegSet:
+      return WriteGPR();
+    case FPURegSet:
+      return WriteFPU();
+    case EXCRegSet:
+      return WriteEXC();
+    case DBGRegSet:
+      return WriteDBG();
     default:
-        value.SetValueToInvalid();
-        return false;
-
+      break;
     }
-    return true;
+  }
+  return KERN_INVALID_ARGUMENT;
 }
 
+void RegisterContextDarwin_arm::LogDBGRegisters(Log *log, const DBG &dbg) {
+  if (log) {
+    for (uint32_t i = 0; i < 16; i++)
+      log->Printf("BVR%-2u/BCR%-2u = { 0x%8.8x, 0x%8.8x } WVR%-2u/WCR%-2u = { "
+                  "0x%8.8x, 0x%8.8x }",
+                  i, i, dbg.bvr[i], dbg.bcr[i], i, i, dbg.wvr[i], dbg.wcr[i]);
+  }
+}
 
-bool
-RegisterContextDarwin_arm::WriteRegister (const RegisterInfo *reg_info,
-                                        const RegisterValue &value)
-{
-    const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
-    int set = GetSetForNativeRegNum (reg);
-
-    if (set == -1)
-        return false;
+bool RegisterContextDarwin_arm::ReadRegister(const RegisterInfo *reg_info,
+                                             RegisterValue &value) {
+  const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
+  int set = RegisterContextDarwin_arm::GetSetForNativeRegNum(reg);
 
-    if (ReadRegisterSet(set, false) != KERN_SUCCESS)
-        return false;
+  if (set == -1)
+    return false;
 
-    switch (reg)
-    {
-    case gpr_r0:
-    case gpr_r1:
-    case gpr_r2:
-    case gpr_r3:
-    case gpr_r4:
-    case gpr_r5:
-    case gpr_r6:
-    case gpr_r7:
-    case gpr_r8:
-    case gpr_r9:
-    case gpr_r10:
-    case gpr_r11:
-    case gpr_r12:
-    case gpr_sp:
-    case gpr_lr:
-    case gpr_pc:
-    case gpr_cpsr:
-            gpr.r[reg - gpr_r0] = value.GetAsUInt32();
-        break;
-
-    case fpu_s0:
-    case fpu_s1:
-    case fpu_s2:
-    case fpu_s3:
-    case fpu_s4:
-    case fpu_s5:
-    case fpu_s6:
-    case fpu_s7:
-    case fpu_s8:
-    case fpu_s9:
-    case fpu_s10:
-    case fpu_s11:
-    case fpu_s12:
-    case fpu_s13:
-    case fpu_s14:
-    case fpu_s15:
-    case fpu_s16:
-    case fpu_s17:
-    case fpu_s18:
-    case fpu_s19:
-    case fpu_s20:
-    case fpu_s21:
-    case fpu_s22:
-    case fpu_s23:
-    case fpu_s24:
-    case fpu_s25:
-    case fpu_s26:
-    case fpu_s27:
-    case fpu_s28:
-    case fpu_s29:
-    case fpu_s30:
-    case fpu_s31:
-        fpu.floats.s[reg] = value.GetAsUInt32();
-        break;
-
-    case fpu_fpscr:
-        fpu.fpscr = value.GetAsUInt32();
-        break;
-
-    case exc_exception:
-        exc.exception = value.GetAsUInt32();
-        break;
-    case exc_fsr:
-        exc.fsr = value.GetAsUInt32();
-        break;
-    case exc_far:
-        exc.far = value.GetAsUInt32();
-        break;
+  if (ReadRegisterSet(set, false) != KERN_SUCCESS)
+    return false;
 
-    default:
-        return false;
+  switch (reg) {
+  case gpr_r0:
+  case gpr_r1:
+  case gpr_r2:
+  case gpr_r3:
+  case gpr_r4:
+  case gpr_r5:
+  case gpr_r6:
+  case gpr_r7:
+  case gpr_r8:
+  case gpr_r9:
+  case gpr_r10:
+  case gpr_r11:
+  case gpr_r12:
+  case gpr_sp:
+  case gpr_lr:
+  case gpr_pc:
+  case gpr_cpsr:
+    value.SetUInt32(gpr.r[reg - gpr_r0]);
+    break;
+
+  case fpu_s0:
+  case fpu_s1:
+  case fpu_s2:
+  case fpu_s3:
+  case fpu_s4:
+  case fpu_s5:
+  case fpu_s6:
+  case fpu_s7:
+  case fpu_s8:
+  case fpu_s9:
+  case fpu_s10:
+  case fpu_s11:
+  case fpu_s12:
+  case fpu_s13:
+  case fpu_s14:
+  case fpu_s15:
+  case fpu_s16:
+  case fpu_s17:
+  case fpu_s18:
+  case fpu_s19:
+  case fpu_s20:
+  case fpu_s21:
+  case fpu_s22:
+  case fpu_s23:
+  case fpu_s24:
+  case fpu_s25:
+  case fpu_s26:
+  case fpu_s27:
+  case fpu_s28:
+  case fpu_s29:
+  case fpu_s30:
+  case fpu_s31:
+    value.SetUInt32(fpu.floats.s[reg], RegisterValue::eTypeFloat);
+    break;
+
+  case fpu_fpscr:
+    value.SetUInt32(fpu.fpscr);
+    break;
+
+  case exc_exception:
+    value.SetUInt32(exc.exception);
+    break;
+  case exc_fsr:
+    value.SetUInt32(exc.fsr);
+    break;
+  case exc_far:
+    value.SetUInt32(exc.far);
+    break;
 
-    }
-    return WriteRegisterSet(set) == KERN_SUCCESS;
+  default:
+    value.SetValueToInvalid();
+    return false;
+  }
+  return true;
 }
 
-bool
-RegisterContextDarwin_arm::ReadAllRegisterValues (lldb::DataBufferSP &data_sp)
-{
-    data_sp.reset (new DataBufferHeap (REG_CONTEXT_SIZE, 0));
-    if (data_sp &&
-        ReadGPR (false) == KERN_SUCCESS &&
-        ReadFPU (false) == KERN_SUCCESS &&
-        ReadEXC (false) == KERN_SUCCESS)
-    {
-        uint8_t *dst = data_sp->GetBytes();
-        ::memcpy (dst, &gpr, sizeof(gpr));
-        dst += sizeof(gpr);
-
-        ::memcpy (dst, &fpu, sizeof(fpu));
-        dst += sizeof(gpr);
+bool RegisterContextDarwin_arm::WriteRegister(const RegisterInfo *reg_info,
+                                              const RegisterValue &value) {
+  const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
+  int set = GetSetForNativeRegNum(reg);
 
-        ::memcpy (dst, &exc, sizeof(exc));
-        return true;
-    }
+  if (set == -1)
     return false;
-}
 
-bool
-RegisterContextDarwin_arm::WriteAllRegisterValues (const lldb::DataBufferSP &data_sp)
-{
-    if (data_sp && data_sp->GetByteSize() == REG_CONTEXT_SIZE)
-    {
-        const uint8_t *src = data_sp->GetBytes();
-        ::memcpy (&gpr, src, sizeof(gpr));
-        src += sizeof(gpr);
-
-        ::memcpy (&fpu, src, sizeof(fpu));
-        src += sizeof(gpr);
-
-        ::memcpy (&exc, src, sizeof(exc));
-        uint32_t success_count = 0;
-        if (WriteGPR() == KERN_SUCCESS)
-            ++success_count;
-        if (WriteFPU() == KERN_SUCCESS)
-            ++success_count;
-        if (WriteEXC() == KERN_SUCCESS)
-            ++success_count;
-        return success_count == 3;
-    }
+  if (ReadRegisterSet(set, false) != KERN_SUCCESS)
     return false;
-}
 
-uint32_t
-RegisterContextDarwin_arm::ConvertRegisterKindToRegisterNumber (lldb::RegisterKind kind, uint32_t reg)
-{
-    if (kind == eRegisterKindGeneric)
-    {
-        switch (reg)
-        {
-        case LLDB_REGNUM_GENERIC_PC: return gpr_pc;
-        case LLDB_REGNUM_GENERIC_SP: return gpr_sp;
-        case LLDB_REGNUM_GENERIC_FP: return gpr_r7;
-        case LLDB_REGNUM_GENERIC_RA: return gpr_lr;
-        case LLDB_REGNUM_GENERIC_FLAGS: return gpr_cpsr;
-        default:
-            break;
-        }
-    }
-    else if (kind == eRegisterKindDWARF)
-    {
-        switch (reg)
-        {
-        case dwarf_r0:  return gpr_r0;
-        case dwarf_r1:  return gpr_r1;
-        case dwarf_r2:  return gpr_r2;
-        case dwarf_r3:  return gpr_r3;
-        case dwarf_r4:  return gpr_r4;
-        case dwarf_r5:  return gpr_r5;
-        case dwarf_r6:  return gpr_r6;
-        case dwarf_r7:  return gpr_r7;
-        case dwarf_r8:  return gpr_r8;
-        case dwarf_r9:  return gpr_r9;
-        case dwarf_r10: return gpr_r10;
-        case dwarf_r11: return gpr_r11;
-        case dwarf_r12: return gpr_r12;
-        case dwarf_sp:  return gpr_sp;
-        case dwarf_lr:  return gpr_lr;
-        case dwarf_pc:  return gpr_pc;
-        case dwarf_spsr: return gpr_cpsr;
-
-        case dwarf_s0:  return fpu_s0;
-        case dwarf_s1:  return fpu_s1;
-        case dwarf_s2:  return fpu_s2;
-        case dwarf_s3:  return fpu_s3;
-        case dwarf_s4:  return fpu_s4;
-        case dwarf_s5:  return fpu_s5;
-        case dwarf_s6:  return fpu_s6;
-        case dwarf_s7:  return fpu_s7;
-        case dwarf_s8:  return fpu_s8;
-        case dwarf_s9:  return fpu_s9;
-        case dwarf_s10: return fpu_s10;
-        case dwarf_s11: return fpu_s11;
-        case dwarf_s12: return fpu_s12;
-        case dwarf_s13: return fpu_s13;
-        case dwarf_s14: return fpu_s14;
-        case dwarf_s15: return fpu_s15;
-        case dwarf_s16: return fpu_s16;
-        case dwarf_s17: return fpu_s17;
-        case dwarf_s18: return fpu_s18;
-        case dwarf_s19: return fpu_s19;
-        case dwarf_s20: return fpu_s20;
-        case dwarf_s21: return fpu_s21;
-        case dwarf_s22: return fpu_s22;
-        case dwarf_s23: return fpu_s23;
-        case dwarf_s24: return fpu_s24;
-        case dwarf_s25: return fpu_s25;
-        case dwarf_s26: return fpu_s26;
-        case dwarf_s27: return fpu_s27;
-        case dwarf_s28: return fpu_s28;
-        case dwarf_s29: return fpu_s29;
-        case dwarf_s30: return fpu_s30;
-        case dwarf_s31: return fpu_s31;
-
-        default:
-            break;
-        }
-    }
-    else if (kind == eRegisterKindEHFrame)
-    {
-        switch (reg)
-        {
-        case ehframe_r0:    return gpr_r0;
-        case ehframe_r1:    return gpr_r1;
-        case ehframe_r2:    return gpr_r2;
-        case ehframe_r3:    return gpr_r3;
-        case ehframe_r4:    return gpr_r4;
-        case ehframe_r5:    return gpr_r5;
-        case ehframe_r6:    return gpr_r6;
-        case ehframe_r7:    return gpr_r7;
-        case ehframe_r8:    return gpr_r8;
-        case ehframe_r9:    return gpr_r9;
-        case ehframe_r10:   return gpr_r10;
-        case ehframe_r11:   return gpr_r11;
-        case ehframe_r12:   return gpr_r12;
-        case ehframe_sp:    return gpr_sp;
-        case ehframe_lr:    return gpr_lr;
-        case ehframe_pc:    return gpr_pc;
-        case ehframe_cpsr:  return gpr_cpsr;
-        }
-    }
-    else if (kind == eRegisterKindLLDB)
-    {
-        return reg;
-    }
-    return LLDB_INVALID_REGNUM;
+  switch (reg) {
+  case gpr_r0:
+  case gpr_r1:
+  case gpr_r2:
+  case gpr_r3:
+  case gpr_r4:
+  case gpr_r5:
+  case gpr_r6:
+  case gpr_r7:
+  case gpr_r8:
+  case gpr_r9:
+  case gpr_r10:
+  case gpr_r11:
+  case gpr_r12:
+  case gpr_sp:
+  case gpr_lr:
+  case gpr_pc:
+  case gpr_cpsr:
+    gpr.r[reg - gpr_r0] = value.GetAsUInt32();
+    break;
+
+  case fpu_s0:
+  case fpu_s1:
+  case fpu_s2:
+  case fpu_s3:
+  case fpu_s4:
+  case fpu_s5:
+  case fpu_s6:
+  case fpu_s7:
+  case fpu_s8:
+  case fpu_s9:
+  case fpu_s10:
+  case fpu_s11:
+  case fpu_s12:
+  case fpu_s13:
+  case fpu_s14:
+  case fpu_s15:
+  case fpu_s16:
+  case fpu_s17:
+  case fpu_s18:
+  case fpu_s19:
+  case fpu_s20:
+  case fpu_s21:
+  case fpu_s22:
+  case fpu_s23:
+  case fpu_s24:
+  case fpu_s25:
+  case fpu_s26:
+  case fpu_s27:
+  case fpu_s28:
+  case fpu_s29:
+  case fpu_s30:
+  case fpu_s31:
+    fpu.floats.s[reg] = value.GetAsUInt32();
+    break;
+
+  case fpu_fpscr:
+    fpu.fpscr = value.GetAsUInt32();
+    break;
+
+  case exc_exception:
+    exc.exception = value.GetAsUInt32();
+    break;
+  case exc_fsr:
+    exc.fsr = value.GetAsUInt32();
+    break;
+  case exc_far:
+    exc.far = value.GetAsUInt32();
+    break;
+
+  default:
+    return false;
+  }
+  return WriteRegisterSet(set) == KERN_SUCCESS;
 }
 
+bool RegisterContextDarwin_arm::ReadAllRegisterValues(
+    lldb::DataBufferSP &data_sp) {
+  data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0));
+  if (data_sp && ReadGPR(false) == KERN_SUCCESS &&
+      ReadFPU(false) == KERN_SUCCESS && ReadEXC(false) == KERN_SUCCESS) {
+    uint8_t *dst = data_sp->GetBytes();
+    ::memcpy(dst, &gpr, sizeof(gpr));
+    dst += sizeof(gpr);
 
-uint32_t
-RegisterContextDarwin_arm::NumSupportedHardwareBreakpoints ()
-{
-#if defined (__arm__)
-    // Set the init value to something that will let us know that we need to
-    // autodetect how many breakpoints are supported dynamically...
-    static uint32_t g_num_supported_hw_breakpoints = UINT32_MAX;
-    if (g_num_supported_hw_breakpoints == UINT32_MAX)
-    {
-        // Set this to zero in case we can't tell if there are any HW breakpoints
-        g_num_supported_hw_breakpoints = 0;
+    ::memcpy(dst, &fpu, sizeof(fpu));
+    dst += sizeof(gpr);
 
-        uint32_t register_DBGDIDR;
+    ::memcpy(dst, &exc, sizeof(exc));
+    return true;
+  }
+  return false;
+}
 
-        asm("mrc p14, 0, %0, c0, c0, 0" : "=r" (register_DBGDIDR));
-        g_num_supported_hw_breakpoints = Bits32 (register_DBGDIDR, 27, 24);
-        // Zero is reserved for the BRP count, so don't increment it if it is zero
-        if (g_num_supported_hw_breakpoints > 0)
-            g_num_supported_hw_breakpoints++;
-//        if (log) log->Printf ("DBGDIDR=0x%8.8x (number BRP pairs = %u)", register_DBGDIDR, g_num_supported_hw_breakpoints);
+bool RegisterContextDarwin_arm::WriteAllRegisterValues(
+    const lldb::DataBufferSP &data_sp) {
+  if (data_sp && data_sp->GetByteSize() == REG_CONTEXT_SIZE) {
+    const uint8_t *src = data_sp->GetBytes();
+    ::memcpy(&gpr, src, sizeof(gpr));
+    src += sizeof(gpr);
+
+    ::memcpy(&fpu, src, sizeof(fpu));
+    src += sizeof(gpr);
+
+    ::memcpy(&exc, src, sizeof(exc));
+    uint32_t success_count = 0;
+    if (WriteGPR() == KERN_SUCCESS)
+      ++success_count;
+    if (WriteFPU() == KERN_SUCCESS)
+      ++success_count;
+    if (WriteEXC() == KERN_SUCCESS)
+      ++success_count;
+    return success_count == 3;
+  }
+  return false;
+}
+
+uint32_t RegisterContextDarwin_arm::ConvertRegisterKindToRegisterNumber(
+    lldb::RegisterKind kind, uint32_t reg) {
+  if (kind == eRegisterKindGeneric) {
+    switch (reg) {
+    case LLDB_REGNUM_GENERIC_PC:
+      return gpr_pc;
+    case LLDB_REGNUM_GENERIC_SP:
+      return gpr_sp;
+    case LLDB_REGNUM_GENERIC_FP:
+      return gpr_r7;
+    case LLDB_REGNUM_GENERIC_RA:
+      return gpr_lr;
+    case LLDB_REGNUM_GENERIC_FLAGS:
+      return gpr_cpsr;
+    default:
+      break;
+    }
+  } else if (kind == eRegisterKindDWARF) {
+    switch (reg) {
+    case dwarf_r0:
+      return gpr_r0;
+    case dwarf_r1:
+      return gpr_r1;
+    case dwarf_r2:
+      return gpr_r2;
+    case dwarf_r3:
+      return gpr_r3;
+    case dwarf_r4:
+      return gpr_r4;
+    case dwarf_r5:
+      return gpr_r5;
+    case dwarf_r6:
+      return gpr_r6;
+    case dwarf_r7:
+      return gpr_r7;
+    case dwarf_r8:
+      return gpr_r8;
+    case dwarf_r9:
+      return gpr_r9;
+    case dwarf_r10:
+      return gpr_r10;
+    case dwarf_r11:
+      return gpr_r11;
+    case dwarf_r12:
+      return gpr_r12;
+    case dwarf_sp:
+      return gpr_sp;
+    case dwarf_lr:
+      return gpr_lr;
+    case dwarf_pc:
+      return gpr_pc;
+    case dwarf_spsr:
+      return gpr_cpsr;
+
+    case dwarf_s0:
+      return fpu_s0;
+    case dwarf_s1:
+      return fpu_s1;
+    case dwarf_s2:
+      return fpu_s2;
+    case dwarf_s3:
+      return fpu_s3;
+    case dwarf_s4:
+      return fpu_s4;
+    case dwarf_s5:
+      return fpu_s5;
+    case dwarf_s6:
+      return fpu_s6;
+    case dwarf_s7:
+      return fpu_s7;
+    case dwarf_s8:
+      return fpu_s8;
+    case dwarf_s9:
+      return fpu_s9;
+    case dwarf_s10:
+      return fpu_s10;
+    case dwarf_s11:
+      return fpu_s11;
+    case dwarf_s12:
+      return fpu_s12;
+    case dwarf_s13:
+      return fpu_s13;
+    case dwarf_s14:
+      return fpu_s14;
+    case dwarf_s15:
+      return fpu_s15;
+    case dwarf_s16:
+      return fpu_s16;
+    case dwarf_s17:
+      return fpu_s17;
+    case dwarf_s18:
+      return fpu_s18;
+    case dwarf_s19:
+      return fpu_s19;
+    case dwarf_s20:
+      return fpu_s20;
+    case dwarf_s21:
+      return fpu_s21;
+    case dwarf_s22:
+      return fpu_s22;
+    case dwarf_s23:
+      return fpu_s23;
+    case dwarf_s24:
+      return fpu_s24;
+    case dwarf_s25:
+      return fpu_s25;
+    case dwarf_s26:
+      return fpu_s26;
+    case dwarf_s27:
+      return fpu_s27;
+    case dwarf_s28:
+      return fpu_s28;
+    case dwarf_s29:
+      return fpu_s29;
+    case dwarf_s30:
+      return fpu_s30;
+    case dwarf_s31:
+      return fpu_s31;
 
+    default:
+      break;
     }
-    return g_num_supported_hw_breakpoints;
+  } else if (kind == eRegisterKindEHFrame) {
+    switch (reg) {
+    case ehframe_r0:
+      return gpr_r0;
+    case ehframe_r1:
+      return gpr_r1;
+    case ehframe_r2:
+      return gpr_r2;
+    case ehframe_r3:
+      return gpr_r3;
+    case ehframe_r4:
+      return gpr_r4;
+    case ehframe_r5:
+      return gpr_r5;
+    case ehframe_r6:
+      return gpr_r6;
+    case ehframe_r7:
+      return gpr_r7;
+    case ehframe_r8:
+      return gpr_r8;
+    case ehframe_r9:
+      return gpr_r9;
+    case ehframe_r10:
+      return gpr_r10;
+    case ehframe_r11:
+      return gpr_r11;
+    case ehframe_r12:
+      return gpr_r12;
+    case ehframe_sp:
+      return gpr_sp;
+    case ehframe_lr:
+      return gpr_lr;
+    case ehframe_pc:
+      return gpr_pc;
+    case ehframe_cpsr:
+      return gpr_cpsr;
+    }
+  } else if (kind == eRegisterKindLLDB) {
+    return reg;
+  }
+  return LLDB_INVALID_REGNUM;
+}
+
+uint32_t RegisterContextDarwin_arm::NumSupportedHardwareBreakpoints() {
+#if defined(__arm__)
+  // Set the init value to something that will let us know that we need to
+  // autodetect how many breakpoints are supported dynamically...
+  static uint32_t g_num_supported_hw_breakpoints = UINT32_MAX;
+  if (g_num_supported_hw_breakpoints == UINT32_MAX) {
+    // Set this to zero in case we can't tell if there are any HW breakpoints
+    g_num_supported_hw_breakpoints = 0;
+
+    uint32_t register_DBGDIDR;
+
+    asm("mrc p14, 0, %0, c0, c0, 0" : "=r"(register_DBGDIDR));
+    g_num_supported_hw_breakpoints = Bits32(register_DBGDIDR, 27, 24);
+    // Zero is reserved for the BRP count, so don't increment it if it is zero
+    if (g_num_supported_hw_breakpoints > 0)
+      g_num_supported_hw_breakpoints++;
+    //        if (log) log->Printf ("DBGDIDR=0x%8.8x (number BRP pairs = %u)",
+    //        register_DBGDIDR, g_num_supported_hw_breakpoints);
+  }
+  return g_num_supported_hw_breakpoints;
 #else
-    // TODO: figure out remote case here!
-    return 6;
+  // TODO: figure out remote case here!
+  return 6;
 #endif
 }
 
-uint32_t
-RegisterContextDarwin_arm::SetHardwareBreakpoint (lldb::addr_t addr, size_t size)
-{
-    // Make sure our address isn't bogus
-    if (addr & 1)
-        return LLDB_INVALID_INDEX32;
-
-    int kret = ReadDBG (false);
+uint32_t RegisterContextDarwin_arm::SetHardwareBreakpoint(lldb::addr_t addr,
+                                                          size_t size) {
+  // Make sure our address isn't bogus
+  if (addr & 1)
+    return LLDB_INVALID_INDEX32;
 
-    if (kret == KERN_SUCCESS)
-    {
-        const uint32_t num_hw_breakpoints = NumSupportedHardwareBreakpoints();
-        uint32_t i;
-        for (i=0; i<num_hw_breakpoints; ++i)
-        {
-            if ((dbg.bcr[i] & BCR_ENABLE) == 0)
-                break; // We found an available hw breakpoint slot (in i)
-        }
-
-        // See if we found an available hw breakpoint slot above
-        if (i < num_hw_breakpoints)
-        {
-            // Make sure bits 1:0 are clear in our address
-            dbg.bvr[i] = addr & ~((lldb::addr_t)3);
-
-            if (size == 2 || addr & 2)
-            {
-                uint32_t byte_addr_select = (addr & 2) ? BAS_IMVA_2_3 : BAS_IMVA_0_1;
-
-                // We have a thumb breakpoint
-                // We have an ARM breakpoint
-                dbg.bcr[i] =  BCR_M_IMVA_MATCH |    // Stop on address mismatch
-                                        byte_addr_select |  // Set the correct byte address select so we only trigger on the correct opcode
-                                        S_USER |            // Which modes should this breakpoint stop in?
-                                        BCR_ENABLE;         // Enable this hardware breakpoint
-//                if (log) log->Printf ("RegisterContextDarwin_arm::EnableHardwareBreakpoint( addr = %8.8p, size = %u ) - BVR%u/BCR%u = 0x%8.8x / 0x%8.8x (Thumb)",
-//                        addr,
-//                        size,
-//                        i,
-//                        i,
-//                        dbg.bvr[i],
-//                        dbg.bcr[i]);
-            }
-            else if (size == 4)
-            {
-                // We have an ARM breakpoint
-                dbg.bcr[i] =  BCR_M_IMVA_MATCH |    // Stop on address mismatch
-                                        BAS_IMVA_ALL |      // Stop on any of the four bytes following the IMVA
-                                        S_USER |            // Which modes should this breakpoint stop in?
-                                        BCR_ENABLE;         // Enable this hardware breakpoint
-//                if (log) log->Printf ("RegisterContextDarwin_arm::EnableHardwareBreakpoint( addr = %8.8p, size = %u ) - BVR%u/BCR%u = 0x%8.8x / 0x%8.8x (ARM)",
-//                        addr,
-//                        size,
-//                        i,
-//                        i,
-//                        dbg.bvr[i],
-//                        dbg.bcr[i]);
-            }
-
-            kret = WriteDBG();
-//            if (log) log->Printf ("RegisterContextDarwin_arm::EnableHardwareBreakpoint() WriteDBG() => 0x%8.8x.", kret);
-
-            if (kret == KERN_SUCCESS)
-                return i;
-        }
-//        else
-//        {
-//            if (log) log->Printf ("RegisterContextDarwin_arm::EnableHardwareBreakpoint(addr = %8.8p, size = %u) => all hardware breakpoint resources are being used.", addr, size);
-//        }
-    }
+  int kret = ReadDBG(false);
 
-    return LLDB_INVALID_INDEX32;
-}
+  if (kret == KERN_SUCCESS) {
+    const uint32_t num_hw_breakpoints = NumSupportedHardwareBreakpoints();
+    uint32_t i;
+    for (i = 0; i < num_hw_breakpoints; ++i) {
+      if ((dbg.bcr[i] & BCR_ENABLE) == 0)
+        break; // We found an available hw breakpoint slot (in i)
+    }
+
+    // See if we found an available hw breakpoint slot above
+    if (i < num_hw_breakpoints) {
+      // Make sure bits 1:0 are clear in our address
+      dbg.bvr[i] = addr & ~((lldb::addr_t)3);
+
+      if (size == 2 || addr & 2) {
+        uint32_t byte_addr_select = (addr & 2) ? BAS_IMVA_2_3 : BAS_IMVA_0_1;
+
+        // We have a thumb breakpoint
+        // We have an ARM breakpoint
+        dbg.bcr[i] = BCR_M_IMVA_MATCH | // Stop on address mismatch
+                     byte_addr_select | // Set the correct byte address select
+                                        // so we only trigger on the correct
+                                        // opcode
+                     S_USER |    // Which modes should this breakpoint stop in?
+                     BCR_ENABLE; // Enable this hardware breakpoint
+                                 //                if (log) log->Printf
+        //                ("RegisterContextDarwin_arm::EnableHardwareBreakpoint(
+        //                addr = %8.8p, size = %u ) - BVR%u/BCR%u = 0x%8.8x /
+        //                0x%8.8x (Thumb)",
+        //                        addr,
+        //                        size,
+        //                        i,
+        //                        i,
+        //                        dbg.bvr[i],
+        //                        dbg.bcr[i]);
+      } else if (size == 4) {
+        // We have an ARM breakpoint
+        dbg.bcr[i] =
+            BCR_M_IMVA_MATCH | // Stop on address mismatch
+            BAS_IMVA_ALL | // Stop on any of the four bytes following the IMVA
+            S_USER |       // Which modes should this breakpoint stop in?
+            BCR_ENABLE;    // Enable this hardware breakpoint
+                           //                if (log) log->Printf
+        //                ("RegisterContextDarwin_arm::EnableHardwareBreakpoint(
+        //                addr = %8.8p, size = %u ) - BVR%u/BCR%u = 0x%8.8x /
+        //                0x%8.8x (ARM)",
+        //                        addr,
+        //                        size,
+        //                        i,
+        //                        i,
+        //                        dbg.bvr[i],
+        //                        dbg.bcr[i]);
+      }
+
+      kret = WriteDBG();
+      //            if (log) log->Printf
+      //            ("RegisterContextDarwin_arm::EnableHardwareBreakpoint()
+      //            WriteDBG() => 0x%8.8x.", kret);
+
+      if (kret == KERN_SUCCESS)
+        return i;
+    }
+    //        else
+    //        {
+    //            if (log) log->Printf
+    //            ("RegisterContextDarwin_arm::EnableHardwareBreakpoint(addr =
+    //            %8.8p, size = %u) => all hardware breakpoint resources are
+    //            being used.", addr, size);
+    //        }
+  }
+
+  return LLDB_INVALID_INDEX32;
+}
+
+bool RegisterContextDarwin_arm::ClearHardwareBreakpoint(uint32_t hw_index) {
+  int kret = ReadDBG(false);
+
+  const uint32_t num_hw_points = NumSupportedHardwareBreakpoints();
+  if (kret == KERN_SUCCESS) {
+    if (hw_index < num_hw_points) {
+      dbg.bcr[hw_index] = 0;
+      //            if (log) log->Printf
+      //            ("RegisterContextDarwin_arm::SetHardwareBreakpoint( %u ) -
+      //            BVR%u = 0x%8.8x  BCR%u = 0x%8.8x",
+      //                    hw_index,
+      //                    hw_index,
+      //                    dbg.bvr[hw_index],
+      //                    hw_index,
+      //                    dbg.bcr[hw_index]);
 
-bool
-RegisterContextDarwin_arm::ClearHardwareBreakpoint (uint32_t hw_index)
-{
-    int kret = ReadDBG (false);
+      kret = WriteDBG();
 
-    const uint32_t num_hw_points = NumSupportedHardwareBreakpoints();
-    if (kret == KERN_SUCCESS)
-    {
-        if (hw_index < num_hw_points)
-        {
-            dbg.bcr[hw_index] = 0;
-//            if (log) log->Printf ("RegisterContextDarwin_arm::SetHardwareBreakpoint( %u ) - BVR%u = 0x%8.8x  BCR%u = 0x%8.8x",
-//                    hw_index,
-//                    hw_index,
-//                    dbg.bvr[hw_index],
-//                    hw_index,
-//                    dbg.bcr[hw_index]);
-
-            kret = WriteDBG();
-
-            if (kret == KERN_SUCCESS)
-                return true;
-        }
+      if (kret == KERN_SUCCESS)
+        return true;
     }
-    return false;
+  }
+  return false;
 }
 
-uint32_t
-RegisterContextDarwin_arm::NumSupportedHardwareWatchpoints ()
-{
-#if defined (__arm__)
-    // Set the init value to something that will let us know that we need to
-    // autodetect how many watchpoints are supported dynamically...
-    static uint32_t g_num_supported_hw_watchpoints = UINT32_MAX;
-    if (g_num_supported_hw_watchpoints == UINT32_MAX)
-    {
-        // Set this to zero in case we can't tell if there are any HW breakpoints
-        g_num_supported_hw_watchpoints = 0;
-
-        uint32_t register_DBGDIDR;
-        asm("mrc p14, 0, %0, c0, c0, 0" : "=r" (register_DBGDIDR));
-        g_num_supported_hw_watchpoints = Bits32 (register_DBGDIDR, 31, 28) + 1;
-//        if (log) log->Printf ("DBGDIDR=0x%8.8x (number WRP pairs = %u)", register_DBGDIDR, g_num_supported_hw_watchpoints);
-    }
-    return g_num_supported_hw_watchpoints;
+uint32_t RegisterContextDarwin_arm::NumSupportedHardwareWatchpoints() {
+#if defined(__arm__)
+  // Set the init value to something that will let us know that we need to
+  // autodetect how many watchpoints are supported dynamically...
+  static uint32_t g_num_supported_hw_watchpoints = UINT32_MAX;
+  if (g_num_supported_hw_watchpoints == UINT32_MAX) {
+    // Set this to zero in case we can't tell if there are any HW breakpoints
+    g_num_supported_hw_watchpoints = 0;
+
+    uint32_t register_DBGDIDR;
+    asm("mrc p14, 0, %0, c0, c0, 0" : "=r"(register_DBGDIDR));
+    g_num_supported_hw_watchpoints = Bits32(register_DBGDIDR, 31, 28) + 1;
+    //        if (log) log->Printf ("DBGDIDR=0x%8.8x (number WRP pairs = %u)",
+    //        register_DBGDIDR, g_num_supported_hw_watchpoints);
+  }
+  return g_num_supported_hw_watchpoints;
 #else
-    // TODO: figure out remote case here!
-    return 2;
+  // TODO: figure out remote case here!
+  return 2;
 #endif
 }
 
+uint32_t RegisterContextDarwin_arm::SetHardwareWatchpoint(lldb::addr_t addr,
+                                                          size_t size,
+                                                          bool read,
+                                                          bool write) {
+  //    if (log) log->Printf
+  //    ("RegisterContextDarwin_arm::EnableHardwareWatchpoint(addr = %8.8p, size
+  //    = %u, read = %u, write = %u)", addr, size, read, write);
 
-uint32_t
-RegisterContextDarwin_arm::SetHardwareWatchpoint (lldb::addr_t addr, size_t size, bool read, bool write)
-{
-//    if (log) log->Printf ("RegisterContextDarwin_arm::EnableHardwareWatchpoint(addr = %8.8p, size = %u, read = %u, write = %u)", addr, size, read, write);
-
-    const uint32_t num_hw_watchpoints = NumSupportedHardwareWatchpoints();
-
-    // Can't watch zero bytes
-    if (size == 0)
-        return LLDB_INVALID_INDEX32;
-
-    // We must watch for either read or write
-    if (read == false && write == false)
-        return LLDB_INVALID_INDEX32;
-
-    // Can't watch more than 4 bytes per WVR/WCR pair
-    if (size > 4)
-        return LLDB_INVALID_INDEX32;
-
-    // We can only watch up to four bytes that follow a 4 byte aligned address
-    // per watchpoint register pair. Since we have at most so we can only watch
-    // until the next 4 byte boundary and we need to make sure we can properly
-    // encode this.
-    uint32_t addr_word_offset = addr % 4;
-//    if (log) log->Printf ("RegisterContextDarwin_arm::EnableHardwareWatchpoint() - addr_word_offset = 0x%8.8x", addr_word_offset);
-
-    uint32_t byte_mask = ((1u << size) - 1u) << addr_word_offset;
-//    if (log) log->Printf ("RegisterContextDarwin_arm::EnableHardwareWatchpoint() - byte_mask = 0x%8.8x", byte_mask);
-    if (byte_mask > 0xfu)
-        return LLDB_INVALID_INDEX32;
+  const uint32_t num_hw_watchpoints = NumSupportedHardwareWatchpoints();
 
-    // Read the debug state
-    int kret = ReadDBG (false);
+  // Can't watch zero bytes
+  if (size == 0)
+    return LLDB_INVALID_INDEX32;
 
-    if (kret == KERN_SUCCESS)
-    {
-        // Check to make sure we have the needed hardware support
-        uint32_t i = 0;
+  // We must watch for either read or write
+  if (read == false && write == false)
+    return LLDB_INVALID_INDEX32;
 
-        for (i=0; i<num_hw_watchpoints; ++i)
-        {
-            if ((dbg.wcr[i] & WCR_ENABLE) == 0)
-                break; // We found an available hw breakpoint slot (in i)
-        }
-
-        // See if we found an available hw breakpoint slot above
-        if (i < num_hw_watchpoints)
-        {
-            // Make the byte_mask into a valid Byte Address Select mask
-            uint32_t byte_address_select = byte_mask << 5;
-            // Make sure bits 1:0 are clear in our address
-            dbg.wvr[i] = addr & ~((lldb::addr_t)3);
-            dbg.wcr[i] =  byte_address_select |       // Which bytes that follow the IMVA that we will watch
-                                    S_USER |                    // Stop only in user mode
-                                    (read ? WCR_LOAD : 0) |     // Stop on read access?
-                                    (write ? WCR_STORE : 0) |   // Stop on write access?
-                                    WCR_ENABLE;                 // Enable this watchpoint;
-
-            kret = WriteDBG();
-//            if (log) log->Printf ("RegisterContextDarwin_arm::EnableHardwareWatchpoint() WriteDBG() => 0x%8.8x.", kret);
-
-            if (kret == KERN_SUCCESS)
-                return i;
-        }
-        else
-        {
-//            if (log) log->Printf ("RegisterContextDarwin_arm::EnableHardwareWatchpoint(): All hardware resources (%u) are in use.", num_hw_watchpoints);
-        }
-    }
+  // Can't watch more than 4 bytes per WVR/WCR pair
+  if (size > 4)
+    return LLDB_INVALID_INDEX32;
+
+  // We can only watch up to four bytes that follow a 4 byte aligned address
+  // per watchpoint register pair. Since we have at most so we can only watch
+  // until the next 4 byte boundary and we need to make sure we can properly
+  // encode this.
+  uint32_t addr_word_offset = addr % 4;
+  //    if (log) log->Printf
+  //    ("RegisterContextDarwin_arm::EnableHardwareWatchpoint() -
+  //    addr_word_offset = 0x%8.8x", addr_word_offset);
+
+  uint32_t byte_mask = ((1u << size) - 1u) << addr_word_offset;
+  //    if (log) log->Printf
+  //    ("RegisterContextDarwin_arm::EnableHardwareWatchpoint() - byte_mask =
+  //    0x%8.8x", byte_mask);
+  if (byte_mask > 0xfu)
     return LLDB_INVALID_INDEX32;
-}
 
-bool
-RegisterContextDarwin_arm::ClearHardwareWatchpoint (uint32_t hw_index)
-{
-    int kret = ReadDBG (false);
+  // Read the debug state
+  int kret = ReadDBG(false);
 
-    const uint32_t num_hw_points = NumSupportedHardwareWatchpoints();
-    if (kret == KERN_SUCCESS)
-    {
-        if (hw_index < num_hw_points)
-        {
-            dbg.wcr[hw_index] = 0;
-//            if (log) log->Printf ("RegisterContextDarwin_arm::ClearHardwareWatchpoint( %u ) - WVR%u = 0x%8.8x  WCR%u = 0x%8.8x",
-//                    hw_index,
-//                    hw_index,
-//                    dbg.wvr[hw_index],
-//                    hw_index,
-//                    dbg.wcr[hw_index]);
-
-            kret = WriteDBG();
-
-            if (kret == KERN_SUCCESS)
-                return true;
-        }
+  if (kret == KERN_SUCCESS) {
+    // Check to make sure we have the needed hardware support
+    uint32_t i = 0;
+
+    for (i = 0; i < num_hw_watchpoints; ++i) {
+      if ((dbg.wcr[i] & WCR_ENABLE) == 0)
+        break; // We found an available hw breakpoint slot (in i)
+    }
+
+    // See if we found an available hw breakpoint slot above
+    if (i < num_hw_watchpoints) {
+      // Make the byte_mask into a valid Byte Address Select mask
+      uint32_t byte_address_select = byte_mask << 5;
+      // Make sure bits 1:0 are clear in our address
+      dbg.wvr[i] = addr & ~((lldb::addr_t)3);
+      dbg.wcr[i] = byte_address_select |     // Which bytes that follow the IMVA
+                                             // that we will watch
+                   S_USER |                  // Stop only in user mode
+                   (read ? WCR_LOAD : 0) |   // Stop on read access?
+                   (write ? WCR_STORE : 0) | // Stop on write access?
+                   WCR_ENABLE;               // Enable this watchpoint;
+
+      kret = WriteDBG();
+      //            if (log) log->Printf
+      //            ("RegisterContextDarwin_arm::EnableHardwareWatchpoint()
+      //            WriteDBG() => 0x%8.8x.", kret);
+
+      if (kret == KERN_SUCCESS)
+        return i;
+    } else {
+      //            if (log) log->Printf
+      //            ("RegisterContextDarwin_arm::EnableHardwareWatchpoint(): All
+      //            hardware resources (%u) are in use.", num_hw_watchpoints);
+    }
+  }
+  return LLDB_INVALID_INDEX32;
+}
+
+bool RegisterContextDarwin_arm::ClearHardwareWatchpoint(uint32_t hw_index) {
+  int kret = ReadDBG(false);
+
+  const uint32_t num_hw_points = NumSupportedHardwareWatchpoints();
+  if (kret == KERN_SUCCESS) {
+    if (hw_index < num_hw_points) {
+      dbg.wcr[hw_index] = 0;
+      //            if (log) log->Printf
+      //            ("RegisterContextDarwin_arm::ClearHardwareWatchpoint( %u ) -
+      //            WVR%u = 0x%8.8x  WCR%u = 0x%8.8x",
+      //                    hw_index,
+      //                    hw_index,
+      //                    dbg.wvr[hw_index],
+      //                    hw_index,
+      //                    dbg.wcr[hw_index]);
+
+      kret = WriteDBG();
+
+      if (kret == KERN_SUCCESS)
+        return true;
     }
-    return false;
+  }
+  return false;
 }
 
 #endif

Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.h Tue Sep  6 15:57:50 2016
@@ -14,317 +14,256 @@
 // C++ Includes
 // Other libraries and framework includes
 // Project includes
-#include "lldb/lldb-private.h"
 #include "lldb/Target/RegisterContext.h"
+#include "lldb/lldb-private.h"
 
 // BCR address match type
-#define BCR_M_IMVA_MATCH        ((uint32_t)(0u << 21))
-#define BCR_M_CONTEXT_ID_MATCH  ((uint32_t)(1u << 21))
-#define BCR_M_IMVA_MISMATCH     ((uint32_t)(2u << 21))
-#define BCR_M_RESERVED          ((uint32_t)(3u << 21))
+#define BCR_M_IMVA_MATCH ((uint32_t)(0u << 21))
+#define BCR_M_CONTEXT_ID_MATCH ((uint32_t)(1u << 21))
+#define BCR_M_IMVA_MISMATCH ((uint32_t)(2u << 21))
+#define BCR_M_RESERVED ((uint32_t)(3u << 21))
 
 // Link a BVR/BCR or WVR/WCR pair to another
-#define E_ENABLE_LINKING        ((uint32_t)(1u << 20))
+#define E_ENABLE_LINKING ((uint32_t)(1u << 20))
 
 // Byte Address Select
-#define BAS_IMVA_PLUS_0         ((uint32_t)(1u << 5))
-#define BAS_IMVA_PLUS_1         ((uint32_t)(1u << 6))
-#define BAS_IMVA_PLUS_2         ((uint32_t)(1u << 7))
-#define BAS_IMVA_PLUS_3         ((uint32_t)(1u << 8))
-#define BAS_IMVA_0_1            ((uint32_t)(3u << 5))
-#define BAS_IMVA_2_3            ((uint32_t)(3u << 7))
-#define BAS_IMVA_ALL            ((uint32_t)(0xfu << 5))
+#define BAS_IMVA_PLUS_0 ((uint32_t)(1u << 5))
+#define BAS_IMVA_PLUS_1 ((uint32_t)(1u << 6))
+#define BAS_IMVA_PLUS_2 ((uint32_t)(1u << 7))
+#define BAS_IMVA_PLUS_3 ((uint32_t)(1u << 8))
+#define BAS_IMVA_0_1 ((uint32_t)(3u << 5))
+#define BAS_IMVA_2_3 ((uint32_t)(3u << 7))
+#define BAS_IMVA_ALL ((uint32_t)(0xfu << 5))
 
 // Break only in privileged or user mode
-#define S_RSVD                  ((uint32_t)(0u << 1))
-#define S_PRIV                  ((uint32_t)(1u << 1))
-#define S_USER                  ((uint32_t)(2u << 1))
-#define S_PRIV_USER             ((S_PRIV) | (S_USER))
+#define S_RSVD ((uint32_t)(0u << 1))
+#define S_PRIV ((uint32_t)(1u << 1))
+#define S_USER ((uint32_t)(2u << 1))
+#define S_PRIV_USER ((S_PRIV) | (S_USER))
 
-#define BCR_ENABLE              ((uint32_t)(1u))
-#define WCR_ENABLE              ((uint32_t)(1u))
+#define BCR_ENABLE ((uint32_t)(1u))
+#define WCR_ENABLE ((uint32_t)(1u))
 
 // Watchpoint load/store
-#define WCR_LOAD                ((uint32_t)(1u << 3))
-#define WCR_STORE               ((uint32_t)(1u << 4))
+#define WCR_LOAD ((uint32_t)(1u << 3))
+#define WCR_STORE ((uint32_t)(1u << 4))
 
-class RegisterContextDarwin_arm : public lldb_private::RegisterContext
-{
+class RegisterContextDarwin_arm : public lldb_private::RegisterContext {
 public:
-    RegisterContextDarwin_arm(lldb_private::Thread &thread, uint32_t concrete_frame_idx);
+  RegisterContextDarwin_arm(lldb_private::Thread &thread,
+                            uint32_t concrete_frame_idx);
+
+  ~RegisterContextDarwin_arm() override;
+
+  void InvalidateAllRegisters() override;
+
+  size_t GetRegisterCount() override;
+
+  const lldb_private::RegisterInfo *GetRegisterInfoAtIndex(size_t reg) override;
+
+  size_t GetRegisterSetCount() override;
+
+  const lldb_private::RegisterSet *GetRegisterSet(size_t set) override;
+
+  bool ReadRegister(const lldb_private::RegisterInfo *reg_info,
+                    lldb_private::RegisterValue &reg_value) override;
+
+  bool WriteRegister(const lldb_private::RegisterInfo *reg_info,
+                     const lldb_private::RegisterValue &reg_value) override;
+
+  bool ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
+
+  bool WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
+
+  uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind,
+                                               uint32_t num) override;
+
+  uint32_t NumSupportedHardwareBreakpoints() override;
+
+  uint32_t SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override;
+
+  bool ClearHardwareBreakpoint(uint32_t hw_idx) override;
+
+  uint32_t NumSupportedHardwareWatchpoints() override;
 
-    ~RegisterContextDarwin_arm() override;
+  uint32_t SetHardwareWatchpoint(lldb::addr_t addr, size_t size, bool read,
+                                 bool write) override;
 
-    void
-    InvalidateAllRegisters() override;
+  bool ClearHardwareWatchpoint(uint32_t hw_index) override;
 
-    size_t
-    GetRegisterCount() override;
-
-    const lldb_private::RegisterInfo *
-    GetRegisterInfoAtIndex(size_t reg) override;
-
-    size_t
-    GetRegisterSetCount() override;
-
-    const lldb_private::RegisterSet *
-    GetRegisterSet(size_t set) override;
-
-    bool
-    ReadRegister(const lldb_private::RegisterInfo *reg_info,
-                 lldb_private::RegisterValue &reg_value) override;
-    
-    bool
-    WriteRegister(const lldb_private::RegisterInfo *reg_info,
-                  const lldb_private::RegisterValue &reg_value) override;
-    
-    bool
-    ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
-
-    bool
-    WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
-
-    uint32_t
-    ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num) override;
-
-    uint32_t
-    NumSupportedHardwareBreakpoints() override;
-
-    uint32_t
-    SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override;
-
-    bool
-    ClearHardwareBreakpoint(uint32_t hw_idx) override;
-
-    uint32_t
-    NumSupportedHardwareWatchpoints() override;
-
-    uint32_t
-    SetHardwareWatchpoint(lldb::addr_t addr, size_t size, bool read, bool write) override;
-
-    bool
-    ClearHardwareWatchpoint(uint32_t hw_index) override;
-
-    struct GPR
-    {
-        uint32_t    r[16];  // R0-R15
-        uint32_t    cpsr;   // CPSR
-    };
-
-    struct QReg
-    {
-        uint8_t bytes[16];
-    };
-
-    struct FPU
-    {
-        union {
-            uint32_t s[32];
-            uint64_t d[32];
-            QReg     q[16];  // the 128-bit NEON registers
-        } floats;
-        uint32_t fpscr;
-    };
-
-//  struct NeonReg
-//  {
-//      uint8_t bytes[16];
-//  };
-//
-//  struct VFPv3
-//  {
-//      union {
-//          uint32_t s[32];
-//          uint64_t d[32];
-//          NeonReg  q[16];
-//      } v3;
-//      uint32_t fpscr;
-//  };
-
-    struct EXC
-    {
-        uint32_t    exception;
-        uint32_t    fsr; /* Fault status */
-        uint32_t    far; /* Virtual Fault Address */
-    };
-
-    struct DBG
-    {
-        uint32_t bvr[16];
-        uint32_t bcr[16];
-        uint32_t wvr[16];
-        uint32_t wcr[16];
-    };
+  struct GPR {
+    uint32_t r[16]; // R0-R15
+    uint32_t cpsr;  // CPSR
+  };
 
-    static void
-    LogDBGRegisters (lldb_private::Log *log, const DBG& dbg);
+  struct QReg {
+    uint8_t bytes[16];
+  };
+
+  struct FPU {
+    union {
+      uint32_t s[32];
+      uint64_t d[32];
+      QReg q[16]; // the 128-bit NEON registers
+    } floats;
+    uint32_t fpscr;
+  };
+
+  //  struct NeonReg
+  //  {
+  //      uint8_t bytes[16];
+  //  };
+  //
+  //  struct VFPv3
+  //  {
+  //      union {
+  //          uint32_t s[32];
+  //          uint64_t d[32];
+  //          NeonReg  q[16];
+  //      } v3;
+  //      uint32_t fpscr;
+  //  };
+
+  struct EXC {
+    uint32_t exception;
+    uint32_t fsr; /* Fault status */
+    uint32_t far; /* Virtual Fault Address */
+  };
+
+  struct DBG {
+    uint32_t bvr[16];
+    uint32_t bcr[16];
+    uint32_t wvr[16];
+    uint32_t wcr[16];
+  };
+
+  static void LogDBGRegisters(lldb_private::Log *log, const DBG &dbg);
 
 protected:
-    enum
-    {
-        GPRRegSet = 1,    // ARM_THREAD_STATE
-        GPRAltRegSet = 9, // ARM_THREAD_STATE32
-        FPURegSet = 2,    // ARM_VFP_STATE
-        EXCRegSet = 3,    // ARM_EXCEPTION_STATE
-        DBGRegSet = 4     // ARM_DEBUG_STATE
-    };
-
-    enum
-    {
-        GPRWordCount = sizeof(GPR)/sizeof(uint32_t),
-        FPUWordCount = sizeof(FPU)/sizeof(uint32_t),
-        EXCWordCount = sizeof(EXC)/sizeof(uint32_t),
-        DBGWordCount = sizeof(DBG)/sizeof(uint32_t)
-    };
-
-    enum
-    {
-        Read = 0,
-        Write = 1,
-        kNumErrors = 2
-    };
-
-    GPR gpr;
-    FPU fpu;
-    EXC exc;
-    DBG dbg;
-    int gpr_errs[2]; // Read/Write errors
-    int fpu_errs[2]; // Read/Write errors
-    int exc_errs[2]; // Read/Write errors
-    int dbg_errs[2]; // Read/Write errors
-
-    void
-    InvalidateAllRegisterStates()
-    {
-        SetError (GPRRegSet, Read, -1);
-        SetError (FPURegSet, Read, -1);
-        SetError (EXCRegSet, Read, -1);
+  enum {
+    GPRRegSet = 1,    // ARM_THREAD_STATE
+    GPRAltRegSet = 9, // ARM_THREAD_STATE32
+    FPURegSet = 2,    // ARM_VFP_STATE
+    EXCRegSet = 3,    // ARM_EXCEPTION_STATE
+    DBGRegSet = 4     // ARM_DEBUG_STATE
+  };
+
+  enum {
+    GPRWordCount = sizeof(GPR) / sizeof(uint32_t),
+    FPUWordCount = sizeof(FPU) / sizeof(uint32_t),
+    EXCWordCount = sizeof(EXC) / sizeof(uint32_t),
+    DBGWordCount = sizeof(DBG) / sizeof(uint32_t)
+  };
+
+  enum { Read = 0, Write = 1, kNumErrors = 2 };
+
+  GPR gpr;
+  FPU fpu;
+  EXC exc;
+  DBG dbg;
+  int gpr_errs[2]; // Read/Write errors
+  int fpu_errs[2]; // Read/Write errors
+  int exc_errs[2]; // Read/Write errors
+  int dbg_errs[2]; // Read/Write errors
+
+  void InvalidateAllRegisterStates() {
+    SetError(GPRRegSet, Read, -1);
+    SetError(FPURegSet, Read, -1);
+    SetError(EXCRegSet, Read, -1);
+  }
+
+  int GetError(int flavor, uint32_t err_idx) const {
+    if (err_idx < kNumErrors) {
+      switch (flavor) {
+      // When getting all errors, just OR all values together to see if
+      // we got any kind of error.
+      case GPRRegSet:
+        return gpr_errs[err_idx];
+      case FPURegSet:
+        return fpu_errs[err_idx];
+      case EXCRegSet:
+        return exc_errs[err_idx];
+      case DBGRegSet:
+        return dbg_errs[err_idx];
+      default:
+        break;
+      }
     }
+    return -1;
+  }
 
-    int
-    GetError (int flavor, uint32_t err_idx) const
-    {
-        if (err_idx < kNumErrors)
-        {
-            switch (flavor)
-            {
-            // When getting all errors, just OR all values together to see if
-            // we got any kind of error.
-            case GPRRegSet:    return gpr_errs[err_idx];
-            case FPURegSet:    return fpu_errs[err_idx];
-            case EXCRegSet:    return exc_errs[err_idx];
-            case DBGRegSet:    return dbg_errs[err_idx];
-            default: break;
-            }
-        }
-        return -1;
+  bool SetError(int flavor, uint32_t err_idx, int err) {
+    if (err_idx < kNumErrors) {
+      switch (flavor) {
+      case GPRRegSet:
+        gpr_errs[err_idx] = err;
+        return true;
+
+      case FPURegSet:
+        fpu_errs[err_idx] = err;
+        return true;
+
+      case EXCRegSet:
+        exc_errs[err_idx] = err;
+        return true;
+
+      case DBGRegSet:
+        exc_errs[err_idx] = err;
+        return true;
+
+      default:
+        break;
+      }
     }
+    return false;
+  }
 
-    bool
-    SetError (int flavor, uint32_t err_idx, int err)
-    {
-        if (err_idx < kNumErrors)
-        {
-            switch (flavor)
-            {
-            case GPRRegSet:
-                gpr_errs[err_idx] = err;
-                return true;
-
-            case FPURegSet:
-                fpu_errs[err_idx] = err;
-                return true;
-
-            case EXCRegSet:
-                exc_errs[err_idx] = err;
-                return true;
-
-            case DBGRegSet:
-                exc_errs[err_idx] = err;
-                return true;
-
-            default: break;
-            }
-        }
-        return false;
-    }
+  bool RegisterSetIsCached(int set) const { return GetError(set, Read) == 0; }
 
-    bool
-    RegisterSetIsCached (int set) const
-    {
-        return GetError(set, Read) == 0;
-    }
+  int ReadGPR(bool force);
 
-    int
-    ReadGPR (bool force);
+  int ReadFPU(bool force);
 
-    int
-    ReadFPU (bool force);
+  int ReadEXC(bool force);
 
-    int
-    ReadEXC (bool force);
+  int ReadDBG(bool force);
 
-    int
-    ReadDBG (bool force);
+  int WriteGPR();
 
-    int
-    WriteGPR ();
+  int WriteFPU();
 
-    int
-    WriteFPU ();
+  int WriteEXC();
 
-    int
-    WriteEXC ();
+  int WriteDBG();
 
-    int
-    WriteDBG ();
+  // Subclasses override these to do the actual reading.
+  virtual int DoReadGPR(lldb::tid_t tid, int flavor, GPR &gpr) { return -1; }
 
-    
-    // Subclasses override these to do the actual reading.
-    virtual int
-    DoReadGPR (lldb::tid_t tid, int flavor, GPR &gpr)
-    {
-        return -1;
-    }
-    
-    virtual int
-    DoReadFPU (lldb::tid_t tid, int flavor, FPU &fpu) = 0;
-    
-    virtual int
-    DoReadEXC (lldb::tid_t tid, int flavor, EXC &exc) = 0;
-
-    virtual int
-    DoReadDBG (lldb::tid_t tid, int flavor, DBG &dbg) = 0;
-
-    virtual int
-    DoWriteGPR (lldb::tid_t tid, int flavor, const GPR &gpr) = 0;
-    
-    virtual int
-    DoWriteFPU (lldb::tid_t tid, int flavor, const FPU &fpu) = 0;
-    
-    virtual int
-    DoWriteEXC (lldb::tid_t tid, int flavor, const EXC &exc) = 0;
-
-    virtual int
-    DoWriteDBG (lldb::tid_t tid, int flavor, const DBG &dbg) = 0;
-
-    int
-    ReadRegisterSet (uint32_t set, bool force);
-
-    int
-    WriteRegisterSet (uint32_t set);
-
-    static uint32_t
-    GetRegisterNumber (uint32_t reg_kind, uint32_t reg_num);
+  virtual int DoReadFPU(lldb::tid_t tid, int flavor, FPU &fpu) = 0;
+
+  virtual int DoReadEXC(lldb::tid_t tid, int flavor, EXC &exc) = 0;
+
+  virtual int DoReadDBG(lldb::tid_t tid, int flavor, DBG &dbg) = 0;
+
+  virtual int DoWriteGPR(lldb::tid_t tid, int flavor, const GPR &gpr) = 0;
+
+  virtual int DoWriteFPU(lldb::tid_t tid, int flavor, const FPU &fpu) = 0;
+
+  virtual int DoWriteEXC(lldb::tid_t tid, int flavor, const EXC &exc) = 0;
+
+  virtual int DoWriteDBG(lldb::tid_t tid, int flavor, const DBG &dbg) = 0;
+
+  int ReadRegisterSet(uint32_t set, bool force);
+
+  int WriteRegisterSet(uint32_t set);
+
+  static uint32_t GetRegisterNumber(uint32_t reg_kind, uint32_t reg_num);
 
-    static int
-    GetSetForNativeRegNum (int reg_num);
+  static int GetSetForNativeRegNum(int reg_num);
 
-    static size_t
-    GetRegisterInfosCount ();
+  static size_t GetRegisterInfosCount();
 
-    static const lldb_private::RegisterInfo *
-    GetRegisterInfos ();
+  static const lldb_private::RegisterInfo *GetRegisterInfos();
 };
 
 #endif // liblldb_RegisterContextDarwin_arm_h_




More information about the lldb-commits mailing list