[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/Host/common/File.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/File.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/File.cpp (original)
+++ lldb/trunk/source/Host/common/File.cpp Tue Sep  6 15:57:50 2016
@@ -34,1028 +34,829 @@
 using namespace lldb;
 using namespace lldb_private;
 
-static const char *
-GetStreamOpenModeFromOptions (uint32_t options)
-{
-    if (options & File::eOpenOptionAppend)
-    {
-        if (options & File::eOpenOptionRead)
-        {
-            if (options & File::eOpenOptionCanCreateNewOnly)
-                return "a+x";
-            else
-                return "a+";
-        }
-        else if (options & File::eOpenOptionWrite)
-        {
-            if (options & File::eOpenOptionCanCreateNewOnly)
-                return "ax";
-            else
-                return "a";
-        }
-    }
-    else if (options & File::eOpenOptionRead && options & File::eOpenOptionWrite)
-    {
-        if (options & File::eOpenOptionCanCreate)
-        {
-            if (options & File::eOpenOptionCanCreateNewOnly)
-                return "w+x";
-            else
-                return "w+";
-        }
-        else
-            return "r+";
-    }
-    else if (options & File::eOpenOptionRead)
-    {
-        return "r";
-    }
-    else if (options & File::eOpenOptionWrite)
-    {
-        return "w";
-    }
-    return NULL;
+static const char *GetStreamOpenModeFromOptions(uint32_t options) {
+  if (options & File::eOpenOptionAppend) {
+    if (options & File::eOpenOptionRead) {
+      if (options & File::eOpenOptionCanCreateNewOnly)
+        return "a+x";
+      else
+        return "a+";
+    } else if (options & File::eOpenOptionWrite) {
+      if (options & File::eOpenOptionCanCreateNewOnly)
+        return "ax";
+      else
+        return "a";
+    }
+  } else if (options & File::eOpenOptionRead &&
+             options & File::eOpenOptionWrite) {
+    if (options & File::eOpenOptionCanCreate) {
+      if (options & File::eOpenOptionCanCreateNewOnly)
+        return "w+x";
+      else
+        return "w+";
+    } else
+      return "r+";
+  } else if (options & File::eOpenOptionRead) {
+    return "r";
+  } else if (options & File::eOpenOptionWrite) {
+    return "w";
+  }
+  return NULL;
 }
 
 int File::kInvalidDescriptor = -1;
-FILE * File::kInvalidStream = NULL;
+FILE *File::kInvalidStream = NULL;
 
-File::File(const char *path, uint32_t options, uint32_t permissions) :
-    IOObject(eFDTypeFile, false),
-    m_descriptor (kInvalidDescriptor),
-    m_stream (kInvalidStream),
-    m_options (),
-    m_own_stream (false),
-    m_is_interactive (eLazyBoolCalculate),
-    m_is_real_terminal (eLazyBoolCalculate)
-{
-    Open (path, options, permissions);
+File::File(const char *path, uint32_t options, uint32_t permissions)
+    : IOObject(eFDTypeFile, false), m_descriptor(kInvalidDescriptor),
+      m_stream(kInvalidStream), m_options(), m_own_stream(false),
+      m_is_interactive(eLazyBoolCalculate),
+      m_is_real_terminal(eLazyBoolCalculate) {
+  Open(path, options, permissions);
 }
 
-File::File (const FileSpec& filespec,
-            uint32_t options,
-            uint32_t permissions) :
-    IOObject(eFDTypeFile, false),
-    m_descriptor (kInvalidDescriptor),
-    m_stream (kInvalidStream),
-    m_options (0),
-    m_own_stream (false),
-    m_is_interactive (eLazyBoolCalculate),
-    m_is_real_terminal (eLazyBoolCalculate)
-
-{
-    if (filespec)
-    {
-        Open (filespec.GetPath().c_str(), options, permissions);
-    }
-}
+File::File(const FileSpec &filespec, uint32_t options, uint32_t permissions)
+    : IOObject(eFDTypeFile, false), m_descriptor(kInvalidDescriptor),
+      m_stream(kInvalidStream), m_options(0), m_own_stream(false),
+      m_is_interactive(eLazyBoolCalculate),
+      m_is_real_terminal(eLazyBoolCalculate)
 
-File::~File()
 {
-    Close ();
+  if (filespec) {
+    Open(filespec.GetPath().c_str(), options, permissions);
+  }
 }
 
+File::~File() { Close(); }
 
-int
-File::GetDescriptor() const
-{
-    if (DescriptorIsValid())
-        return m_descriptor;
+int File::GetDescriptor() const {
+  if (DescriptorIsValid())
+    return m_descriptor;
 
-    // Don't open the file descriptor if we don't need to, just get it from the
-    // stream if we have one.
-    if (StreamIsValid())
-    {
+  // Don't open the file descriptor if we don't need to, just get it from the
+  // stream if we have one.
+  if (StreamIsValid()) {
 #if defined(LLVM_ON_WIN32)
-        return _fileno(m_stream);
+    return _fileno(m_stream);
 #else
-        return fileno(m_stream);
+    return fileno(m_stream);
 #endif
-    }
-
-    // Invalid descriptor and invalid stream, return invalid descriptor.
-    return kInvalidDescriptor;
-}
+  }
 
-IOObject::WaitableHandle
-File::GetWaitableHandle()
-{
-    return m_descriptor;
+  // Invalid descriptor and invalid stream, return invalid descriptor.
+  return kInvalidDescriptor;
 }
 
+IOObject::WaitableHandle File::GetWaitableHandle() { return m_descriptor; }
 
-void
-File::SetDescriptor (int fd, bool transfer_ownership)
-{
-    if (IsValid())
-        Close();
-    m_descriptor = fd;
-    m_should_close_fd = transfer_ownership;
+void File::SetDescriptor(int fd, bool transfer_ownership) {
+  if (IsValid())
+    Close();
+  m_descriptor = fd;
+  m_should_close_fd = transfer_ownership;
 }
 
-
-FILE *
-File::GetStream ()
-{
-    if (!StreamIsValid())
-    {
-        if (DescriptorIsValid())
-        {
-            const char *mode = GetStreamOpenModeFromOptions (m_options);
-            if (mode)
-            {
-                if (!m_should_close_fd)
-                {
-                    // We must duplicate the file descriptor if we don't own it because
-                    // when you call fdopen, the stream will own the fd
+FILE *File::GetStream() {
+  if (!StreamIsValid()) {
+    if (DescriptorIsValid()) {
+      const char *mode = GetStreamOpenModeFromOptions(m_options);
+      if (mode) {
+        if (!m_should_close_fd) {
+// We must duplicate the file descriptor if we don't own it because
+// when you call fdopen, the stream will own the fd
 #ifdef _WIN32
-                    m_descriptor = ::_dup(GetDescriptor());
+          m_descriptor = ::_dup(GetDescriptor());
 #else
-                    m_descriptor = dup(GetDescriptor());
+          m_descriptor = dup(GetDescriptor());
 #endif
-                    m_should_close_fd = true;
-                }
+          m_should_close_fd = true;
+        }
 
-                do
-                {
-                    m_stream = ::fdopen (m_descriptor, mode);
-                } while (m_stream == NULL && errno == EINTR);
-
-                // If we got a stream, then we own the stream and should no
-                // longer own the descriptor because fclose() will close it for us
-
-                if (m_stream)
-                {
-                    m_own_stream = true;
-                    m_should_close_fd = false;
-                }
-            }
+        do {
+          m_stream = ::fdopen(m_descriptor, mode);
+        } while (m_stream == NULL && errno == EINTR);
+
+        // If we got a stream, then we own the stream and should no
+        // longer own the descriptor because fclose() will close it for us
+
+        if (m_stream) {
+          m_own_stream = true;
+          m_should_close_fd = false;
         }
+      }
     }
-    return m_stream;
+  }
+  return m_stream;
 }
 
-void
-File::SetStream (FILE *fh, bool transfer_ownership)
-{
-    if (IsValid())
-        Close();
-    m_stream = fh;
-    m_own_stream = transfer_ownership;
+void File::SetStream(FILE *fh, bool transfer_ownership) {
+  if (IsValid())
+    Close();
+  m_stream = fh;
+  m_own_stream = transfer_ownership;
 }
 
-Error
-File::Open (const char *path, uint32_t options, uint32_t permissions)
-{
-    Error error;
-    if (IsValid())
-        Close ();
-
-    int oflag = 0;
-    const bool read = options & eOpenOptionRead;
-    const bool write = options & eOpenOptionWrite;
-    if (write)
-    {
-        if (read)
-            oflag |= O_RDWR;
-        else
-            oflag |= O_WRONLY;
-        
-        if (options & eOpenOptionAppend)
-            oflag |= O_APPEND;
-
-        if (options & eOpenOptionTruncate)
-            oflag |= O_TRUNC;
-
-        if (options & eOpenOptionCanCreate)
-            oflag |= O_CREAT;
-        
-        if (options & eOpenOptionCanCreateNewOnly)
-            oflag |= O_CREAT | O_EXCL;
-    }
-    else if (read)
-    {
-        oflag |= O_RDONLY;
+Error File::Open(const char *path, uint32_t options, uint32_t permissions) {
+  Error error;
+  if (IsValid())
+    Close();
+
+  int oflag = 0;
+  const bool read = options & eOpenOptionRead;
+  const bool write = options & eOpenOptionWrite;
+  if (write) {
+    if (read)
+      oflag |= O_RDWR;
+    else
+      oflag |= O_WRONLY;
+
+    if (options & eOpenOptionAppend)
+      oflag |= O_APPEND;
+
+    if (options & eOpenOptionTruncate)
+      oflag |= O_TRUNC;
+
+    if (options & eOpenOptionCanCreate)
+      oflag |= O_CREAT;
+
+    if (options & eOpenOptionCanCreateNewOnly)
+      oflag |= O_CREAT | O_EXCL;
+  } else if (read) {
+    oflag |= O_RDONLY;
 
 #ifndef _WIN32
-        if (options & eOpenOptionDontFollowSymlinks)
-            oflag |= O_NOFOLLOW;
+    if (options & eOpenOptionDontFollowSymlinks)
+      oflag |= O_NOFOLLOW;
 #endif
-    }
-    
+  }
+
 #ifndef _WIN32
-    if (options & eOpenOptionNonBlocking)
-        oflag |= O_NONBLOCK;
-    if (options & eOpenOptionCloseOnExec)
-        oflag |= O_CLOEXEC;
+  if (options & eOpenOptionNonBlocking)
+    oflag |= O_NONBLOCK;
+  if (options & eOpenOptionCloseOnExec)
+    oflag |= O_CLOEXEC;
 #else
-    oflag |= O_BINARY;
+  oflag |= O_BINARY;
 #endif
 
-    mode_t mode = 0;
-    if (oflag & O_CREAT)
-    {
-        if (permissions & lldb::eFilePermissionsUserRead)     mode |= S_IRUSR;
-        if (permissions & lldb::eFilePermissionsUserWrite)    mode |= S_IWUSR;
-        if (permissions & lldb::eFilePermissionsUserExecute)  mode |= S_IXUSR;
-        if (permissions & lldb::eFilePermissionsGroupRead)    mode |= S_IRGRP;
-        if (permissions & lldb::eFilePermissionsGroupWrite)   mode |= S_IWGRP;
-        if (permissions & lldb::eFilePermissionsGroupExecute) mode |= S_IXGRP;
-        if (permissions & lldb::eFilePermissionsWorldRead)    mode |= S_IROTH;
-        if (permissions & lldb::eFilePermissionsWorldWrite)   mode |= S_IWOTH;
-        if (permissions & lldb::eFilePermissionsWorldExecute) mode |= S_IXOTH;
-    }
+  mode_t mode = 0;
+  if (oflag & O_CREAT) {
+    if (permissions & lldb::eFilePermissionsUserRead)
+      mode |= S_IRUSR;
+    if (permissions & lldb::eFilePermissionsUserWrite)
+      mode |= S_IWUSR;
+    if (permissions & lldb::eFilePermissionsUserExecute)
+      mode |= S_IXUSR;
+    if (permissions & lldb::eFilePermissionsGroupRead)
+      mode |= S_IRGRP;
+    if (permissions & lldb::eFilePermissionsGroupWrite)
+      mode |= S_IWGRP;
+    if (permissions & lldb::eFilePermissionsGroupExecute)
+      mode |= S_IXGRP;
+    if (permissions & lldb::eFilePermissionsWorldRead)
+      mode |= S_IROTH;
+    if (permissions & lldb::eFilePermissionsWorldWrite)
+      mode |= S_IWOTH;
+    if (permissions & lldb::eFilePermissionsWorldExecute)
+      mode |= S_IXOTH;
+  }
 
-    do
-    {
+  do {
 #ifdef _WIN32
-        std::wstring wpath;
-        if (!llvm::ConvertUTF8toWide(path, wpath))
-        {
-            m_descriptor = -1;
-            error.SetErrorString("Error converting path to UTF-16");
-            return error;
-        }
-        ::_wsopen_s(&m_descriptor, wpath.c_str(), oflag, _SH_DENYNO, mode);
+    std::wstring wpath;
+    if (!llvm::ConvertUTF8toWide(path, wpath)) {
+      m_descriptor = -1;
+      error.SetErrorString("Error converting path to UTF-16");
+      return error;
+    }
+    ::_wsopen_s(&m_descriptor, wpath.c_str(), oflag, _SH_DENYNO, mode);
 #else
-        m_descriptor = ::open(path, oflag, mode);
+    m_descriptor = ::open(path, oflag, mode);
 #endif
-    } while (m_descriptor < 0 && errno == EINTR);
-
-    if (!DescriptorIsValid())
-        error.SetErrorToErrno();
-    else
-    {
-        m_should_close_fd = true;
-        m_options = options;
-    }
-    
-    return error;
-}
+  } while (m_descriptor < 0 && errno == EINTR);
 
-uint32_t
-File::GetPermissions(const FileSpec &file_spec, Error &error)
-{
-    if (file_spec)
-    {
-        struct stat file_stats;
-        int stat_result = FileSystem::Stat(file_spec.GetCString(), &file_stats);
-        if (stat_result == -1)
-            error.SetErrorToErrno();
-        else
-        {
-            error.Clear();
-            return file_stats.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
-        }
-    }
-    else
-        error.SetErrorString ("empty file spec");
-    return 0;
+  if (!DescriptorIsValid())
+    error.SetErrorToErrno();
+  else {
+    m_should_close_fd = true;
+    m_options = options;
+  }
+
+  return error;
+}
+
+uint32_t File::GetPermissions(const FileSpec &file_spec, Error &error) {
+  if (file_spec) {
+    struct stat file_stats;
+    int stat_result = FileSystem::Stat(file_spec.GetCString(), &file_stats);
+    if (stat_result == -1)
+      error.SetErrorToErrno();
+    else {
+      error.Clear();
+      return file_stats.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
+    }
+  } else
+    error.SetErrorString("empty file spec");
+  return 0;
+}
+
+uint32_t File::GetPermissions(Error &error) const {
+  int fd = GetDescriptor();
+  if (fd != kInvalidDescriptor) {
+    struct stat file_stats;
+    if (::fstat(fd, &file_stats) == -1)
+      error.SetErrorToErrno();
+    else {
+      error.Clear();
+      return file_stats.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
+    }
+  } else {
+    error.SetErrorString("invalid file descriptor");
+  }
+  return 0;
+}
+
+Error File::Close() {
+  Error error;
+  if (StreamIsValid() && m_own_stream) {
+    if (::fclose(m_stream) == EOF)
+      error.SetErrorToErrno();
+  }
+
+  if (DescriptorIsValid() && m_should_close_fd) {
+    if (::close(m_descriptor) != 0)
+      error.SetErrorToErrno();
+  }
+  m_descriptor = kInvalidDescriptor;
+  m_stream = kInvalidStream;
+  m_options = 0;
+  m_own_stream = false;
+  m_should_close_fd = false;
+  m_is_interactive = eLazyBoolCalculate;
+  m_is_real_terminal = eLazyBoolCalculate;
+  return error;
+}
+
+void File::Clear() {
+  m_stream = nullptr;
+  m_descriptor = -1;
+  m_options = 0;
+  m_own_stream = false;
+  m_is_interactive = m_supports_colors = m_is_real_terminal =
+      eLazyBoolCalculate;
 }
 
-uint32_t
-File::GetPermissions(Error &error) const
-{
-    int fd = GetDescriptor();
-    if (fd != kInvalidDescriptor)
-    {
-        struct stat file_stats;
-        if (::fstat (fd, &file_stats) == -1)
-            error.SetErrorToErrno();
-        else
-        {
-            error.Clear();
-            return file_stats.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
-        }
-    }
-    else
-    {
-        error.SetErrorString ("invalid file descriptor");
-    }
-    return 0;
-}
-
-
-Error
-File::Close ()
-{
-    Error error;
-    if (StreamIsValid() && m_own_stream)
-    {
-        if (::fclose (m_stream) == EOF)
-            error.SetErrorToErrno();
-    }
-    
-    if (DescriptorIsValid() && m_should_close_fd)
-    {
-        if (::close (m_descriptor) != 0)
-            error.SetErrorToErrno();
-    }
-    m_descriptor = kInvalidDescriptor;
-    m_stream = kInvalidStream;
-    m_options = 0;
-    m_own_stream = false;
-    m_should_close_fd = false;
-    m_is_interactive = eLazyBoolCalculate;
-    m_is_real_terminal = eLazyBoolCalculate;
-    return error;
-}
-
-void
-File::Clear ()
-{
-    m_stream = nullptr;
-    m_descriptor = -1;
-    m_options = 0;
-    m_own_stream = false;
-    m_is_interactive = m_supports_colors = m_is_real_terminal = eLazyBoolCalculate;
-}
-
-Error
-File::GetFileSpec (FileSpec &file_spec) const
-{
-    Error error;
+Error File::GetFileSpec(FileSpec &file_spec) const {
+  Error error;
 #ifdef LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED
-    if (IsValid ())
-    {
-        char path[PATH_MAX];
-        if (::fcntl(GetDescriptor(), F_GETPATH, path) == -1)
-            error.SetErrorToErrno();
-        else
-            file_spec.SetFile (path, false);
-    }
-    else 
-    {
-        error.SetErrorString("invalid file handle");
-    }
-#elif defined(__linux__)
-    char proc[64];
+  if (IsValid()) {
     char path[PATH_MAX];
-    if (::snprintf(proc, sizeof(proc), "/proc/self/fd/%d", GetDescriptor()) < 0)
-        error.SetErrorString ("cannot resolve file descriptor");
+    if (::fcntl(GetDescriptor(), F_GETPATH, path) == -1)
+      error.SetErrorToErrno();
     else
-    {
-        ssize_t len;
-        if ((len = ::readlink(proc, path, sizeof(path) - 1)) == -1)
-            error.SetErrorToErrno();
-        else
-        {
-            path[len] = '\0';
-            file_spec.SetFile (path, false);
-        }
+      file_spec.SetFile(path, false);
+  } else {
+    error.SetErrorString("invalid file handle");
+  }
+#elif defined(__linux__)
+  char proc[64];
+  char path[PATH_MAX];
+  if (::snprintf(proc, sizeof(proc), "/proc/self/fd/%d", GetDescriptor()) < 0)
+    error.SetErrorString("cannot resolve file descriptor");
+  else {
+    ssize_t len;
+    if ((len = ::readlink(proc, path, sizeof(path) - 1)) == -1)
+      error.SetErrorToErrno();
+    else {
+      path[len] = '\0';
+      file_spec.SetFile(path, false);
     }
+  }
 #else
-    error.SetErrorString ("File::GetFileSpec is not supported on this platform");
+  error.SetErrorString("File::GetFileSpec is not supported on this platform");
 #endif
 
-    if (error.Fail())
-        file_spec.Clear();
-    return error;
-}
-
-off_t
-File::SeekFromStart (off_t offset, Error *error_ptr)
-{
-    off_t result = 0;
-    if (DescriptorIsValid())
-    {
-        result = ::lseek (m_descriptor, offset, SEEK_SET);
-
-        if (error_ptr)
-        {
-            if (result == -1)
-                error_ptr->SetErrorToErrno();
-            else
-                error_ptr->Clear();
-        }
-    }
-    else if (StreamIsValid ())
-    {
-        result = ::fseek(m_stream, offset, SEEK_SET);
-        
-        if (error_ptr)
-        {
-            if (result == -1)
-                error_ptr->SetErrorToErrno();
-            else
-                error_ptr->Clear();
-        }
-    }
-    else if (error_ptr)
-    {
-        error_ptr->SetErrorString("invalid file handle");
-    }
-    return result;
-}
-
-off_t
-File::SeekFromCurrent (off_t offset,  Error *error_ptr)
-{
-    off_t result = -1;
-    if (DescriptorIsValid())
-    {
-        result = ::lseek (m_descriptor, offset, SEEK_CUR);
-        
-        if (error_ptr)
-        {
-            if (result == -1)
-                error_ptr->SetErrorToErrno();
-            else
-                error_ptr->Clear();
-        }
-    }
-    else if (StreamIsValid ())
-    {
-        result = ::fseek(m_stream, offset, SEEK_CUR);
-        
-        if (error_ptr)
-        {
-            if (result == -1)
-                error_ptr->SetErrorToErrno();
-            else
-                error_ptr->Clear();
-        }
-    }
-    else if (error_ptr)
-    {
-        error_ptr->SetErrorString("invalid file handle");
-    }
-    return result;
-}
-
-off_t
-File::SeekFromEnd (off_t offset, Error *error_ptr)
-{
-    off_t result = -1;
-    if (DescriptorIsValid())
-    {
-        result = ::lseek (m_descriptor, offset, SEEK_END);
-        
-        if (error_ptr)
-        {
-            if (result == -1)
-                error_ptr->SetErrorToErrno();
-            else
-                error_ptr->Clear();
-        }
-    }
-    else if (StreamIsValid ())
-    {
-        result = ::fseek(m_stream, offset, SEEK_END);
-        
-        if (error_ptr)
-        {
-            if (result == -1)
-                error_ptr->SetErrorToErrno();
-            else
-                error_ptr->Clear();
-        }
-    }
-    else if (error_ptr)
-    {
-        error_ptr->SetErrorString("invalid file handle");
-    }
-    return result;
-}
-
-Error
-File::Flush ()
-{
-    Error error;
-    if (StreamIsValid())
-    {
-        int err = 0;
-        do
-        {
-            err = ::fflush (m_stream);
-        } while (err == EOF && errno == EINTR);
-        
-        if (err == EOF)
-            error.SetErrorToErrno();
-    }
-    else if (!DescriptorIsValid())
-    {
-        error.SetErrorString("invalid file handle");
-    }
-    return error;
-}
-
-
-Error
-File::Sync ()
-{
-    Error error;
-    if (DescriptorIsValid())
-    {
+  if (error.Fail())
+    file_spec.Clear();
+  return error;
+}
+
+off_t File::SeekFromStart(off_t offset, Error *error_ptr) {
+  off_t result = 0;
+  if (DescriptorIsValid()) {
+    result = ::lseek(m_descriptor, offset, SEEK_SET);
+
+    if (error_ptr) {
+      if (result == -1)
+        error_ptr->SetErrorToErrno();
+      else
+        error_ptr->Clear();
+    }
+  } else if (StreamIsValid()) {
+    result = ::fseek(m_stream, offset, SEEK_SET);
+
+    if (error_ptr) {
+      if (result == -1)
+        error_ptr->SetErrorToErrno();
+      else
+        error_ptr->Clear();
+    }
+  } else if (error_ptr) {
+    error_ptr->SetErrorString("invalid file handle");
+  }
+  return result;
+}
+
+off_t File::SeekFromCurrent(off_t offset, Error *error_ptr) {
+  off_t result = -1;
+  if (DescriptorIsValid()) {
+    result = ::lseek(m_descriptor, offset, SEEK_CUR);
+
+    if (error_ptr) {
+      if (result == -1)
+        error_ptr->SetErrorToErrno();
+      else
+        error_ptr->Clear();
+    }
+  } else if (StreamIsValid()) {
+    result = ::fseek(m_stream, offset, SEEK_CUR);
+
+    if (error_ptr) {
+      if (result == -1)
+        error_ptr->SetErrorToErrno();
+      else
+        error_ptr->Clear();
+    }
+  } else if (error_ptr) {
+    error_ptr->SetErrorString("invalid file handle");
+  }
+  return result;
+}
+
+off_t File::SeekFromEnd(off_t offset, Error *error_ptr) {
+  off_t result = -1;
+  if (DescriptorIsValid()) {
+    result = ::lseek(m_descriptor, offset, SEEK_END);
+
+    if (error_ptr) {
+      if (result == -1)
+        error_ptr->SetErrorToErrno();
+      else
+        error_ptr->Clear();
+    }
+  } else if (StreamIsValid()) {
+    result = ::fseek(m_stream, offset, SEEK_END);
+
+    if (error_ptr) {
+      if (result == -1)
+        error_ptr->SetErrorToErrno();
+      else
+        error_ptr->Clear();
+    }
+  } else if (error_ptr) {
+    error_ptr->SetErrorString("invalid file handle");
+  }
+  return result;
+}
+
+Error File::Flush() {
+  Error error;
+  if (StreamIsValid()) {
+    int err = 0;
+    do {
+      err = ::fflush(m_stream);
+    } while (err == EOF && errno == EINTR);
+
+    if (err == EOF)
+      error.SetErrorToErrno();
+  } else if (!DescriptorIsValid()) {
+    error.SetErrorString("invalid file handle");
+  }
+  return error;
+}
+
+Error File::Sync() {
+  Error error;
+  if (DescriptorIsValid()) {
 #ifdef _WIN32
-        int err = FlushFileBuffers((HANDLE)_get_osfhandle(m_descriptor));
-        if (err == 0)
-            error.SetErrorToGenericError();
+    int err = FlushFileBuffers((HANDLE)_get_osfhandle(m_descriptor));
+    if (err == 0)
+      error.SetErrorToGenericError();
 #else
-        int err = 0;
-        do
-        {
-            err = ::fsync (m_descriptor);
-        } while (err == -1 && errno == EINTR);
-        
-        if (err == -1)
-            error.SetErrorToErrno();
+    int err = 0;
+    do {
+      err = ::fsync(m_descriptor);
+    } while (err == -1 && errno == EINTR);
+
+    if (err == -1)
+      error.SetErrorToErrno();
 #endif
-    }
-    else 
-    {
-        error.SetErrorString("invalid file handle");
-    }
-    return error;
+  } else {
+    error.SetErrorString("invalid file handle");
+  }
+  return error;
 }
 
-#if defined (__APPLE__)
+#if defined(__APPLE__)
 // Darwin kernels only can read/write <= INT_MAX bytes
 #define MAX_READ_SIZE INT_MAX
 #define MAX_WRITE_SIZE INT_MAX
 #endif
 
-Error
-File::Read (void *buf, size_t &num_bytes)
-{
-    Error error;
+Error File::Read(void *buf, size_t &num_bytes) {
+  Error error;
 
-#if defined (MAX_READ_SIZE)
-    if (num_bytes > MAX_READ_SIZE)
-    {
-        uint8_t *p = (uint8_t *)buf;
-        size_t bytes_left = num_bytes;
-        // Init the num_bytes read to zero
-        num_bytes = 0;
-
-        while (bytes_left > 0)
-        {
-            size_t curr_num_bytes;
-            if (bytes_left > MAX_READ_SIZE)
-                curr_num_bytes = MAX_READ_SIZE;
-            else
-                curr_num_bytes = bytes_left;
-
-            error = Read (p + num_bytes, curr_num_bytes);
-
-            // Update how many bytes were read
-            num_bytes += curr_num_bytes;
-            if (bytes_left < curr_num_bytes)
-                bytes_left = 0;
-            else
-                bytes_left -= curr_num_bytes;
+#if defined(MAX_READ_SIZE)
+  if (num_bytes > MAX_READ_SIZE) {
+    uint8_t *p = (uint8_t *)buf;
+    size_t bytes_left = num_bytes;
+    // Init the num_bytes read to zero
+    num_bytes = 0;
 
-            if (error.Fail())
-                break;
-        }
-        return error;
-    }
-#endif
+    while (bytes_left > 0) {
+      size_t curr_num_bytes;
+      if (bytes_left > MAX_READ_SIZE)
+        curr_num_bytes = MAX_READ_SIZE;
+      else
+        curr_num_bytes = bytes_left;
+
+      error = Read(p + num_bytes, curr_num_bytes);
+
+      // Update how many bytes were read
+      num_bytes += curr_num_bytes;
+      if (bytes_left < curr_num_bytes)
+        bytes_left = 0;
+      else
+        bytes_left -= curr_num_bytes;
 
-    ssize_t bytes_read = -1;
-    if (DescriptorIsValid())
-    {
-        do
-        {
-            bytes_read = ::read (m_descriptor, buf, num_bytes);
-        } while (bytes_read < 0 && errno == EINTR);
-
-        if (bytes_read == -1)
-        {
-            error.SetErrorToErrno();
-            num_bytes = 0;
-        }
-        else
-            num_bytes = bytes_read;
-    }
-    else if (StreamIsValid())
-    {
-        bytes_read = ::fread (buf, 1, num_bytes, m_stream);
-
-        if (bytes_read == 0)
-        {
-            if (::feof(m_stream))
-                error.SetErrorString ("feof");
-            else if (::ferror (m_stream))
-                error.SetErrorString ("ferror");
-            num_bytes = 0;
-        }
-        else
-            num_bytes = bytes_read;
-    }
-    else 
-    {
-        num_bytes = 0;
-        error.SetErrorString("invalid file handle");
+      if (error.Fail())
+        break;
     }
     return error;
+  }
+#endif
+
+  ssize_t bytes_read = -1;
+  if (DescriptorIsValid()) {
+    do {
+      bytes_read = ::read(m_descriptor, buf, num_bytes);
+    } while (bytes_read < 0 && errno == EINTR);
+
+    if (bytes_read == -1) {
+      error.SetErrorToErrno();
+      num_bytes = 0;
+    } else
+      num_bytes = bytes_read;
+  } else if (StreamIsValid()) {
+    bytes_read = ::fread(buf, 1, num_bytes, m_stream);
+
+    if (bytes_read == 0) {
+      if (::feof(m_stream))
+        error.SetErrorString("feof");
+      else if (::ferror(m_stream))
+        error.SetErrorString("ferror");
+      num_bytes = 0;
+    } else
+      num_bytes = bytes_read;
+  } else {
+    num_bytes = 0;
+    error.SetErrorString("invalid file handle");
+  }
+  return error;
 }
-          
-Error
-File::Write (const void *buf, size_t &num_bytes)
-{
-    Error error;
 
-#if defined (MAX_WRITE_SIZE)
-    if (num_bytes > MAX_WRITE_SIZE)
-    {
-        const uint8_t *p = (const uint8_t *)buf;
-        size_t bytes_left = num_bytes;
-        // Init the num_bytes written to zero
-        num_bytes = 0;
-
-        while (bytes_left > 0)
-        {
-            size_t curr_num_bytes;
-            if (bytes_left > MAX_WRITE_SIZE)
-                curr_num_bytes = MAX_WRITE_SIZE;
-            else
-                curr_num_bytes = bytes_left;
-
-            error = Write (p + num_bytes, curr_num_bytes);
-
-            // Update how many bytes were read
-            num_bytes += curr_num_bytes;
-            if (bytes_left < curr_num_bytes)
-                bytes_left = 0;
-            else
-                bytes_left -= curr_num_bytes;
+Error File::Write(const void *buf, size_t &num_bytes) {
+  Error error;
+
+#if defined(MAX_WRITE_SIZE)
+  if (num_bytes > MAX_WRITE_SIZE) {
+    const uint8_t *p = (const uint8_t *)buf;
+    size_t bytes_left = num_bytes;
+    // Init the num_bytes written to zero
+    num_bytes = 0;
 
-            if (error.Fail())
-                break;
-        }
-        return error;
+    while (bytes_left > 0) {
+      size_t curr_num_bytes;
+      if (bytes_left > MAX_WRITE_SIZE)
+        curr_num_bytes = MAX_WRITE_SIZE;
+      else
+        curr_num_bytes = bytes_left;
+
+      error = Write(p + num_bytes, curr_num_bytes);
+
+      // Update how many bytes were read
+      num_bytes += curr_num_bytes;
+      if (bytes_left < curr_num_bytes)
+        bytes_left = 0;
+      else
+        bytes_left -= curr_num_bytes;
+
+      if (error.Fail())
+        break;
     }
+    return error;
+  }
 #endif
 
-    ssize_t bytes_written = -1;
-    if (DescriptorIsValid())
-    {
-        do
-        {
-            bytes_written = ::write (m_descriptor, buf, num_bytes);
-        } while (bytes_written < 0 && errno == EINTR);
-
-        if (bytes_written == -1)
-        {
-            error.SetErrorToErrno();
-            num_bytes = 0;
-        }
-        else
-            num_bytes = bytes_written;
-    }
-    else if (StreamIsValid())
-    {
-        bytes_written = ::fwrite (buf, 1, num_bytes, m_stream);
-
-        if (bytes_written == 0)
-        {
-            if (::feof(m_stream))
-                error.SetErrorString ("feof");
-            else if (::ferror (m_stream))
-                error.SetErrorString ("ferror");
-            num_bytes = 0;
-        }
-        else
-            num_bytes = bytes_written;
-        
-    }
-    else 
-    {
-        num_bytes = 0;
-        error.SetErrorString("invalid file handle");
-    }
+  ssize_t bytes_written = -1;
+  if (DescriptorIsValid()) {
+    do {
+      bytes_written = ::write(m_descriptor, buf, num_bytes);
+    } while (bytes_written < 0 && errno == EINTR);
+
+    if (bytes_written == -1) {
+      error.SetErrorToErrno();
+      num_bytes = 0;
+    } else
+      num_bytes = bytes_written;
+  } else if (StreamIsValid()) {
+    bytes_written = ::fwrite(buf, 1, num_bytes, m_stream);
+
+    if (bytes_written == 0) {
+      if (::feof(m_stream))
+        error.SetErrorString("feof");
+      else if (::ferror(m_stream))
+        error.SetErrorString("ferror");
+      num_bytes = 0;
+    } else
+      num_bytes = bytes_written;
 
-    return error;
+  } else {
+    num_bytes = 0;
+    error.SetErrorString("invalid file handle");
+  }
+
+  return error;
 }
 
+Error File::Read(void *buf, size_t &num_bytes, off_t &offset) {
+  Error error;
 
-Error
-File::Read (void *buf, size_t &num_bytes, off_t &offset)
-{
-    Error error;
+#if defined(MAX_READ_SIZE)
+  if (num_bytes > MAX_READ_SIZE) {
+    uint8_t *p = (uint8_t *)buf;
+    size_t bytes_left = num_bytes;
+    // Init the num_bytes read to zero
+    num_bytes = 0;
 
-#if defined (MAX_READ_SIZE)
-    if (num_bytes > MAX_READ_SIZE)
-    {
-        uint8_t *p = (uint8_t *)buf;
-        size_t bytes_left = num_bytes;
-        // Init the num_bytes read to zero
-        num_bytes = 0;
-
-        while (bytes_left > 0)
-        {
-            size_t curr_num_bytes;
-            if (bytes_left > MAX_READ_SIZE)
-                curr_num_bytes = MAX_READ_SIZE;
-            else
-                curr_num_bytes = bytes_left;
-
-            error = Read (p + num_bytes, curr_num_bytes, offset);
-
-            // Update how many bytes were read
-            num_bytes += curr_num_bytes;
-            if (bytes_left < curr_num_bytes)
-                bytes_left = 0;
-            else
-                bytes_left -= curr_num_bytes;
+    while (bytes_left > 0) {
+      size_t curr_num_bytes;
+      if (bytes_left > MAX_READ_SIZE)
+        curr_num_bytes = MAX_READ_SIZE;
+      else
+        curr_num_bytes = bytes_left;
+
+      error = Read(p + num_bytes, curr_num_bytes, offset);
+
+      // Update how many bytes were read
+      num_bytes += curr_num_bytes;
+      if (bytes_left < curr_num_bytes)
+        bytes_left = 0;
+      else
+        bytes_left -= curr_num_bytes;
 
-            if (error.Fail())
-                break;
-        }
-        return error;
+      if (error.Fail())
+        break;
     }
+    return error;
+  }
 #endif
 
 #ifndef _WIN32
-    int fd = GetDescriptor();
-    if (fd != kInvalidDescriptor)
-    {
-        ssize_t bytes_read = -1;
-        do
-        {
-            bytes_read = ::pread (fd, buf, num_bytes, offset);
-        } while (bytes_read < 0 && errno == EINTR);
-
-        if (bytes_read < 0)
-        {
-            num_bytes = 0;
-            error.SetErrorToErrno();
-        }
-        else
-        {
-            offset += bytes_read;
-            num_bytes = bytes_read;
-        }
-    }
-    else 
-    {
-        num_bytes = 0;
-        error.SetErrorString("invalid file handle");
+  int fd = GetDescriptor();
+  if (fd != kInvalidDescriptor) {
+    ssize_t bytes_read = -1;
+    do {
+      bytes_read = ::pread(fd, buf, num_bytes, offset);
+    } while (bytes_read < 0 && errno == EINTR);
+
+    if (bytes_read < 0) {
+      num_bytes = 0;
+      error.SetErrorToErrno();
+    } else {
+      offset += bytes_read;
+      num_bytes = bytes_read;
     }
+  } else {
+    num_bytes = 0;
+    error.SetErrorString("invalid file handle");
+  }
 #else
-    long cur = ::lseek(m_descriptor, 0, SEEK_CUR);
-    SeekFromStart(offset);
-    error = Read(buf, num_bytes);
-    if (!error.Fail())
-        SeekFromStart(cur);
+  long cur = ::lseek(m_descriptor, 0, SEEK_CUR);
+  SeekFromStart(offset);
+  error = Read(buf, num_bytes);
+  if (!error.Fail())
+    SeekFromStart(cur);
 #endif
-    return error;
+  return error;
 }
 
-Error
-File::Read (size_t &num_bytes, off_t &offset, bool null_terminate, DataBufferSP &data_buffer_sp)
-{
-    Error error;
-    
-    if (num_bytes > 0)
-    {
-        int fd = GetDescriptor();
-        if (fd != kInvalidDescriptor)
-        {
-            struct stat file_stats;
-            if (::fstat (fd, &file_stats) == 0)
-            {
-                if (file_stats.st_size > offset)
-                {
-                    const size_t bytes_left = file_stats.st_size - offset;
-                    if (num_bytes > bytes_left)
-                        num_bytes = bytes_left;
-                        
-                    size_t num_bytes_plus_nul_char = num_bytes + (null_terminate ? 1 : 0);
-                    std::unique_ptr<DataBufferHeap> data_heap_ap;
-                    data_heap_ap.reset(new DataBufferHeap());
-                    data_heap_ap->SetByteSize(num_bytes_plus_nul_char);
-                        
-                    if (data_heap_ap.get())
-                    {
-                        error = Read (data_heap_ap->GetBytes(), num_bytes, offset);
-                        if (error.Success())
-                        {
-                            // Make sure we read exactly what we asked for and if we got
-                            // less, adjust the array
-                            if (num_bytes_plus_nul_char < data_heap_ap->GetByteSize())
-                                data_heap_ap->SetByteSize(num_bytes_plus_nul_char);
-                            data_buffer_sp.reset(data_heap_ap.release());
-                            return error;
-                        }
-                    }
-                }
-                else 
-                    error.SetErrorString("file is empty");
-            }
-            else
-                error.SetErrorToErrno();
-        }
-        else 
-            error.SetErrorString("invalid file handle");
-    }
-    else
-        error.SetErrorString("invalid file handle");
+Error File::Read(size_t &num_bytes, off_t &offset, bool null_terminate,
+                 DataBufferSP &data_buffer_sp) {
+  Error error;
 
+  if (num_bytes > 0) {
+    int fd = GetDescriptor();
+    if (fd != kInvalidDescriptor) {
+      struct stat file_stats;
+      if (::fstat(fd, &file_stats) == 0) {
+        if (file_stats.st_size > offset) {
+          const size_t bytes_left = file_stats.st_size - offset;
+          if (num_bytes > bytes_left)
+            num_bytes = bytes_left;
+
+          size_t num_bytes_plus_nul_char = num_bytes + (null_terminate ? 1 : 0);
+          std::unique_ptr<DataBufferHeap> data_heap_ap;
+          data_heap_ap.reset(new DataBufferHeap());
+          data_heap_ap->SetByteSize(num_bytes_plus_nul_char);
+
+          if (data_heap_ap.get()) {
+            error = Read(data_heap_ap->GetBytes(), num_bytes, offset);
+            if (error.Success()) {
+              // Make sure we read exactly what we asked for and if we got
+              // less, adjust the array
+              if (num_bytes_plus_nul_char < data_heap_ap->GetByteSize())
+                data_heap_ap->SetByteSize(num_bytes_plus_nul_char);
+              data_buffer_sp.reset(data_heap_ap.release());
+              return error;
+            }
+          }
+        } else
+          error.SetErrorString("file is empty");
+      } else
+        error.SetErrorToErrno();
+    } else
+      error.SetErrorString("invalid file handle");
+  } else
+    error.SetErrorString("invalid file handle");
+
+  num_bytes = 0;
+  data_buffer_sp.reset();
+  return error;
+}
+
+Error File::Write(const void *buf, size_t &num_bytes, off_t &offset) {
+  Error error;
+
+#if defined(MAX_WRITE_SIZE)
+  if (num_bytes > MAX_WRITE_SIZE) {
+    const uint8_t *p = (const uint8_t *)buf;
+    size_t bytes_left = num_bytes;
+    // Init the num_bytes written to zero
     num_bytes = 0;
-    data_buffer_sp.reset();
-    return error;
-}
-
-Error
-File::Write (const void *buf, size_t &num_bytes, off_t &offset)
-{
-    Error error;
 
-#if defined (MAX_WRITE_SIZE)
-    if (num_bytes > MAX_WRITE_SIZE)
-    {
-        const uint8_t *p = (const uint8_t *)buf;
-        size_t bytes_left = num_bytes;
-        // Init the num_bytes written to zero
-        num_bytes = 0;
-
-        while (bytes_left > 0)
-        {
-            size_t curr_num_bytes;
-            if (bytes_left > MAX_WRITE_SIZE)
-                curr_num_bytes = MAX_WRITE_SIZE;
-            else
-                curr_num_bytes = bytes_left;
-
-            error = Write (p + num_bytes, curr_num_bytes, offset);
-
-            // Update how many bytes were read
-            num_bytes += curr_num_bytes;
-            if (bytes_left < curr_num_bytes)
-                bytes_left = 0;
-            else
-                bytes_left -= curr_num_bytes;
+    while (bytes_left > 0) {
+      size_t curr_num_bytes;
+      if (bytes_left > MAX_WRITE_SIZE)
+        curr_num_bytes = MAX_WRITE_SIZE;
+      else
+        curr_num_bytes = bytes_left;
+
+      error = Write(p + num_bytes, curr_num_bytes, offset);
+
+      // Update how many bytes were read
+      num_bytes += curr_num_bytes;
+      if (bytes_left < curr_num_bytes)
+        bytes_left = 0;
+      else
+        bytes_left -= curr_num_bytes;
 
-            if (error.Fail())
-                break;
-        }
-        return error;
+      if (error.Fail())
+        break;
     }
+    return error;
+  }
 #endif
 
-    int fd = GetDescriptor();
-    if (fd != kInvalidDescriptor)
-    {
+  int fd = GetDescriptor();
+  if (fd != kInvalidDescriptor) {
 #ifndef _WIN32
-        ssize_t bytes_written = -1;
-        do
-        {
-            bytes_written = ::pwrite (m_descriptor, buf, num_bytes, offset);
-        } while (bytes_written < 0 && errno == EINTR);
-
-        if (bytes_written < 0)
-        {
-            num_bytes = 0;
-            error.SetErrorToErrno();
-        }
-        else
-        {
-            offset += bytes_written;
-            num_bytes = bytes_written;
-        }
+    ssize_t bytes_written = -1;
+    do {
+      bytes_written = ::pwrite(m_descriptor, buf, num_bytes, offset);
+    } while (bytes_written < 0 && errno == EINTR);
+
+    if (bytes_written < 0) {
+      num_bytes = 0;
+      error.SetErrorToErrno();
+    } else {
+      offset += bytes_written;
+      num_bytes = bytes_written;
+    }
 #else
-        long cur = ::lseek(m_descriptor, 0, SEEK_CUR);
-        error = Write(buf, num_bytes);
-        long after = ::lseek(m_descriptor, 0, SEEK_CUR);
+    long cur = ::lseek(m_descriptor, 0, SEEK_CUR);
+    error = Write(buf, num_bytes);
+    long after = ::lseek(m_descriptor, 0, SEEK_CUR);
 
-        if (!error.Fail())
-            SeekFromStart(cur);
+    if (!error.Fail())
+      SeekFromStart(cur);
 
-        offset = after;
+    offset = after;
 #endif
-    }
-    else 
-    {
-        num_bytes = 0;
-        error.SetErrorString("invalid file handle");
-    }
-    return error;
+  } else {
+    num_bytes = 0;
+    error.SetErrorString("invalid file handle");
+  }
+  return error;
 }
 
 //------------------------------------------------------------------
 // Print some formatted output to the stream.
 //------------------------------------------------------------------
-size_t
-File::Printf (const char *format, ...)
-{
-    va_list args;
-    va_start (args, format);
-    size_t result = PrintfVarArg (format, args);
-    va_end (args);
-    return result;
+size_t File::Printf(const char *format, ...) {
+  va_list args;
+  va_start(args, format);
+  size_t result = PrintfVarArg(format, args);
+  va_end(args);
+  return result;
 }
 
 //------------------------------------------------------------------
 // Print some formatted output to the stream.
 //------------------------------------------------------------------
-size_t
-File::PrintfVarArg (const char *format, va_list args)
-{
-    size_t result = 0;
-    if (DescriptorIsValid())
-    {
-        char *s = NULL;
-        result = vasprintf(&s, format, args);
-        if (s != NULL)
-        {
-            if (result > 0)
-            {
-                size_t s_len = result;
-                Write (s, s_len);
-                result = s_len;
-            }
-            free (s);
-        }
-    }
-    else if (StreamIsValid())
-    {
-        result = ::vfprintf (m_stream, format, args);
-    }
-    return result;
-}
-
-mode_t
-File::ConvertOpenOptionsForPOSIXOpen (uint32_t open_options)
-{
-    mode_t mode = 0;
-    if (open_options & eOpenOptionRead && open_options & eOpenOptionWrite)
-        mode |= O_RDWR;
-    else if (open_options & eOpenOptionWrite)
-        mode |= O_WRONLY;
-    
-    if (open_options & eOpenOptionAppend)
-        mode |= O_APPEND;
-
-    if (open_options & eOpenOptionTruncate)
-        mode |= O_TRUNC;
-
-    if (open_options & eOpenOptionNonBlocking)
-        mode |= O_NONBLOCK;
-
-    if (open_options & eOpenOptionCanCreateNewOnly)
-        mode |= O_CREAT | O_EXCL;
-    else if (open_options & eOpenOptionCanCreate)
-        mode |= O_CREAT;
-
-    return mode;
-}
-
-void
-File::CalculateInteractiveAndTerminal ()
-{
-    const int fd = GetDescriptor();
-    if (fd >= 0)
-    {
-        m_is_interactive = eLazyBoolNo;
-        m_is_real_terminal = eLazyBoolNo;
+size_t File::PrintfVarArg(const char *format, va_list args) {
+  size_t result = 0;
+  if (DescriptorIsValid()) {
+    char *s = NULL;
+    result = vasprintf(&s, format, args);
+    if (s != NULL) {
+      if (result > 0) {
+        size_t s_len = result;
+        Write(s, s_len);
+        result = s_len;
+      }
+      free(s);
+    }
+  } else if (StreamIsValid()) {
+    result = ::vfprintf(m_stream, format, args);
+  }
+  return result;
+}
+
+mode_t File::ConvertOpenOptionsForPOSIXOpen(uint32_t open_options) {
+  mode_t mode = 0;
+  if (open_options & eOpenOptionRead && open_options & eOpenOptionWrite)
+    mode |= O_RDWR;
+  else if (open_options & eOpenOptionWrite)
+    mode |= O_WRONLY;
+
+  if (open_options & eOpenOptionAppend)
+    mode |= O_APPEND;
+
+  if (open_options & eOpenOptionTruncate)
+    mode |= O_TRUNC;
+
+  if (open_options & eOpenOptionNonBlocking)
+    mode |= O_NONBLOCK;
+
+  if (open_options & eOpenOptionCanCreateNewOnly)
+    mode |= O_CREAT | O_EXCL;
+  else if (open_options & eOpenOptionCanCreate)
+    mode |= O_CREAT;
+
+  return mode;
+}
+
+void File::CalculateInteractiveAndTerminal() {
+  const int fd = GetDescriptor();
+  if (fd >= 0) {
+    m_is_interactive = eLazyBoolNo;
+    m_is_real_terminal = eLazyBoolNo;
 #if defined(_WIN32)
-        if (_isatty(fd))
-        {
-            m_is_interactive = eLazyBoolYes;
-            m_is_real_terminal = eLazyBoolYes;
-        }
+    if (_isatty(fd)) {
+      m_is_interactive = eLazyBoolYes;
+      m_is_real_terminal = eLazyBoolYes;
+    }
 #else
-        if (isatty(fd))
-        {
-            m_is_interactive = eLazyBoolYes;
-            struct winsize window_size;
-            if (::ioctl (fd, TIOCGWINSZ, &window_size) == 0)
-            {
-                if (window_size.ws_col > 0)
-                {
-                    m_is_real_terminal = eLazyBoolYes;
-                    if (llvm::sys::Process::FileDescriptorHasColors(fd))
-                        m_supports_colors = eLazyBoolYes;
-                }
-            }
+    if (isatty(fd)) {
+      m_is_interactive = eLazyBoolYes;
+      struct winsize window_size;
+      if (::ioctl(fd, TIOCGWINSZ, &window_size) == 0) {
+        if (window_size.ws_col > 0) {
+          m_is_real_terminal = eLazyBoolYes;
+          if (llvm::sys::Process::FileDescriptorHasColors(fd))
+            m_supports_colors = eLazyBoolYes;
         }
-#endif
+      }
     }
+#endif
+  }
 }
 
-bool
-File::GetIsInteractive ()
-{
-    if (m_is_interactive == eLazyBoolCalculate)
-        CalculateInteractiveAndTerminal ();
-    return m_is_interactive == eLazyBoolYes;
+bool File::GetIsInteractive() {
+  if (m_is_interactive == eLazyBoolCalculate)
+    CalculateInteractiveAndTerminal();
+  return m_is_interactive == eLazyBoolYes;
 }
 
-bool
-File::GetIsRealTerminal ()
-{
-    if (m_is_real_terminal == eLazyBoolCalculate)
-        CalculateInteractiveAndTerminal();
-    return m_is_real_terminal == eLazyBoolYes;
+bool File::GetIsRealTerminal() {
+  if (m_is_real_terminal == eLazyBoolCalculate)
+    CalculateInteractiveAndTerminal();
+  return m_is_real_terminal == eLazyBoolYes;
 }
 
-bool
-File::GetIsTerminalWithColors ()
-{
-    if (m_supports_colors == eLazyBoolCalculate)
-        CalculateInteractiveAndTerminal();
-    return m_supports_colors == eLazyBoolYes;
+bool File::GetIsTerminalWithColors() {
+  if (m_supports_colors == eLazyBoolCalculate)
+    CalculateInteractiveAndTerminal();
+  return m_supports_colors == eLazyBoolYes;
 }
-

Modified: lldb/trunk/source/Host/common/FileCache.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/FileCache.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/FileCache.cpp (original)
+++ lldb/trunk/source/Host/common/FileCache.cpp Tue Sep  6 15:57:50 2016
@@ -16,112 +16,97 @@ using namespace lldb_private;
 
 FileCache *FileCache::m_instance = nullptr;
 
-FileCache &
-FileCache::GetInstance()
-{
-    if (m_instance == nullptr)
-        m_instance = new FileCache();
+FileCache &FileCache::GetInstance() {
+  if (m_instance == nullptr)
+    m_instance = new FileCache();
 
-    return *m_instance;
+  return *m_instance;
 }
 
-lldb::user_id_t
-FileCache::OpenFile(const FileSpec &file_spec, uint32_t flags, uint32_t mode, Error &error)
-{
-    std::string path(file_spec.GetPath());
-    if (path.empty())
-    {
-        error.SetErrorString("empty path");
-        return UINT64_MAX;
-    }
-    FileSP file_sp(new File());
-    error = file_sp->Open(path.c_str(), flags, mode);
-    if (file_sp->IsValid() == false)
-        return UINT64_MAX;
-    lldb::user_id_t fd = file_sp->GetDescriptor();
-    m_cache[fd] = file_sp;
-    return fd;
+lldb::user_id_t FileCache::OpenFile(const FileSpec &file_spec, uint32_t flags,
+                                    uint32_t mode, Error &error) {
+  std::string path(file_spec.GetPath());
+  if (path.empty()) {
+    error.SetErrorString("empty path");
+    return UINT64_MAX;
+  }
+  FileSP file_sp(new File());
+  error = file_sp->Open(path.c_str(), flags, mode);
+  if (file_sp->IsValid() == false)
+    return UINT64_MAX;
+  lldb::user_id_t fd = file_sp->GetDescriptor();
+  m_cache[fd] = file_sp;
+  return fd;
 }
 
-bool
-FileCache::CloseFile(lldb::user_id_t fd, Error &error)
-{
-    if (fd == UINT64_MAX)
-    {
-        error.SetErrorString("invalid file descriptor");
-        return false;
-    }
-    FDToFileMap::iterator pos = m_cache.find(fd);
-    if (pos == m_cache.end())
-    {
-        error.SetErrorStringWithFormat("invalid host file descriptor %" PRIu64, fd);
-        return false;
-    }
-    FileSP file_sp = pos->second;
-    if (!file_sp)
-    {
-        error.SetErrorString("invalid host backing file");
-        return false;
-    }
-    error = file_sp->Close();
-    m_cache.erase(pos);
-    return error.Success();
+bool FileCache::CloseFile(lldb::user_id_t fd, Error &error) {
+  if (fd == UINT64_MAX) {
+    error.SetErrorString("invalid file descriptor");
+    return false;
+  }
+  FDToFileMap::iterator pos = m_cache.find(fd);
+  if (pos == m_cache.end()) {
+    error.SetErrorStringWithFormat("invalid host file descriptor %" PRIu64, fd);
+    return false;
+  }
+  FileSP file_sp = pos->second;
+  if (!file_sp) {
+    error.SetErrorString("invalid host backing file");
+    return false;
+  }
+  error = file_sp->Close();
+  m_cache.erase(pos);
+  return error.Success();
 }
 
-uint64_t
-FileCache::WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src, uint64_t src_len, Error &error)
-{
-    if (fd == UINT64_MAX)
-    {
-        error.SetErrorString("invalid file descriptor");
-        return UINT64_MAX;
-    }
-    FDToFileMap::iterator pos = m_cache.find(fd);
-    if (pos == m_cache.end())
-    {
-        error.SetErrorStringWithFormat("invalid host file descriptor %" PRIu64, fd);
-        return false;
-    }
-    FileSP file_sp = pos->second;
-    if (!file_sp)
-    {
-        error.SetErrorString("invalid host backing file");
-        return UINT64_MAX;
-    }
-    if (static_cast<uint64_t>(file_sp->SeekFromStart(offset, &error)) != offset || error.Fail())
-        return UINT64_MAX;
-    size_t bytes_written = src_len;
-    error = file_sp->Write(src, bytes_written);
-    if (error.Fail())
-        return UINT64_MAX;
-    return bytes_written;
+uint64_t FileCache::WriteFile(lldb::user_id_t fd, uint64_t offset,
+                              const void *src, uint64_t src_len, Error &error) {
+  if (fd == UINT64_MAX) {
+    error.SetErrorString("invalid file descriptor");
+    return UINT64_MAX;
+  }
+  FDToFileMap::iterator pos = m_cache.find(fd);
+  if (pos == m_cache.end()) {
+    error.SetErrorStringWithFormat("invalid host file descriptor %" PRIu64, fd);
+    return false;
+  }
+  FileSP file_sp = pos->second;
+  if (!file_sp) {
+    error.SetErrorString("invalid host backing file");
+    return UINT64_MAX;
+  }
+  if (static_cast<uint64_t>(file_sp->SeekFromStart(offset, &error)) != offset ||
+      error.Fail())
+    return UINT64_MAX;
+  size_t bytes_written = src_len;
+  error = file_sp->Write(src, bytes_written);
+  if (error.Fail())
+    return UINT64_MAX;
+  return bytes_written;
 }
 
-uint64_t
-FileCache::ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst, uint64_t dst_len, Error &error)
-{
-    if (fd == UINT64_MAX)
-    {
-        error.SetErrorString("invalid file descriptor");
-        return UINT64_MAX;
-    }
-    FDToFileMap::iterator pos = m_cache.find(fd);
-    if (pos == m_cache.end())
-    {
-        error.SetErrorStringWithFormat("invalid host file descriptor %" PRIu64, fd);
-        return false;
-    }
-    FileSP file_sp = pos->second;
-    if (!file_sp)
-    {
-        error.SetErrorString("invalid host backing file");
-        return UINT64_MAX;
-    }
-    if (static_cast<uint64_t>(file_sp->SeekFromStart(offset, &error)) != offset || error.Fail())
-        return UINT64_MAX;
-    size_t bytes_read = dst_len;
-    error = file_sp->Read(dst, bytes_read);
-    if (error.Fail())
-        return UINT64_MAX;
-    return bytes_read;
+uint64_t FileCache::ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst,
+                             uint64_t dst_len, Error &error) {
+  if (fd == UINT64_MAX) {
+    error.SetErrorString("invalid file descriptor");
+    return UINT64_MAX;
+  }
+  FDToFileMap::iterator pos = m_cache.find(fd);
+  if (pos == m_cache.end()) {
+    error.SetErrorStringWithFormat("invalid host file descriptor %" PRIu64, fd);
+    return false;
+  }
+  FileSP file_sp = pos->second;
+  if (!file_sp) {
+    error.SetErrorString("invalid host backing file");
+    return UINT64_MAX;
+  }
+  if (static_cast<uint64_t>(file_sp->SeekFromStart(offset, &error)) != offset ||
+      error.Fail())
+    return UINT64_MAX;
+  size_t bytes_read = dst_len;
+  error = file_sp->Read(dst, bytes_read);
+  if (error.Fail())
+    return UINT64_MAX;
+  return bytes_read;
 }

Modified: lldb/trunk/source/Host/common/FileSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/FileSpec.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/FileSpec.cpp (original)
+++ lldb/trunk/source/Host/common/FileSpec.cpp Tue Sep  6 15:57:50 2016
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-
 #ifndef _WIN32
 #include <dirent.h>
 #else
@@ -17,9 +16,9 @@
 #ifndef _MSC_VER
 #include <libgen.h>
 #endif
+#include <fstream>
 #include <set>
 #include <string.h>
-#include <fstream>
 
 #include "lldb/Host/Config.h" // Have to include this before we test the define...
 #ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER
@@ -30,8 +29,8 @@
 #include "lldb/Core/DataBufferHeap.h"
 #include "lldb/Core/DataBufferMemoryMap.h"
 #include "lldb/Core/RegularExpression.h"
-#include "lldb/Core/StreamString.h"
 #include "lldb/Core/Stream.h"
+#include "lldb/Core/StreamString.h"
 #include "lldb/Host/File.h"
 #include "lldb/Host/FileSpec.h"
 #include "lldb/Host/FileSystem.h"
@@ -49,339 +48,291 @@ using namespace lldb_private;
 
 namespace {
 
-bool
-PathSyntaxIsPosix(FileSpec::PathSyntax syntax)
-{
-    return (syntax == FileSpec::ePathSyntaxPosix ||
-            (syntax == FileSpec::ePathSyntaxHostNative &&
-             FileSystem::GetNativePathSyntax() == FileSpec::ePathSyntaxPosix));
+bool PathSyntaxIsPosix(FileSpec::PathSyntax syntax) {
+  return (syntax == FileSpec::ePathSyntaxPosix ||
+          (syntax == FileSpec::ePathSyntaxHostNative &&
+           FileSystem::GetNativePathSyntax() == FileSpec::ePathSyntaxPosix));
 }
 
-const char *
-GetPathSeparators(FileSpec::PathSyntax syntax)
-{
-    return PathSyntaxIsPosix(syntax) ? "/" : "\\/";
+const char *GetPathSeparators(FileSpec::PathSyntax syntax) {
+  return PathSyntaxIsPosix(syntax) ? "/" : "\\/";
 }
 
-char
-GetPrefferedPathSeparator(FileSpec::PathSyntax syntax)
-{
-    return GetPathSeparators(syntax)[0];
+char GetPrefferedPathSeparator(FileSpec::PathSyntax syntax) {
+  return GetPathSeparators(syntax)[0];
 }
 
-bool
-IsPathSeparator(char value, FileSpec::PathSyntax syntax)
-{
-    return value == '/' || (!PathSyntaxIsPosix(syntax) && value == '\\');
+bool IsPathSeparator(char value, FileSpec::PathSyntax syntax) {
+  return value == '/' || (!PathSyntaxIsPosix(syntax) && value == '\\');
 }
 
-void
-Normalize(llvm::SmallVectorImpl<char> &path, FileSpec::PathSyntax syntax)
-{
-    if (PathSyntaxIsPosix(syntax)) return;
+void Normalize(llvm::SmallVectorImpl<char> &path, FileSpec::PathSyntax syntax) {
+  if (PathSyntaxIsPosix(syntax))
+    return;
 
-    std::replace(path.begin(), path.end(), '\\', '/');
-    // Windows path can have \\ slashes which can be changed by replace
-    // call above to //. Here we remove the duplicate.
-    auto iter = std::unique ( path.begin(), path.end(),
-                               []( char &c1, char &c2 ){
-                                  return (c1 == '/' && c2 == '/');});
-    path.erase(iter, path.end());
+  std::replace(path.begin(), path.end(), '\\', '/');
+  // Windows path can have \\ slashes which can be changed by replace
+  // call above to //. Here we remove the duplicate.
+  auto iter = std::unique(path.begin(), path.end(), [](char &c1, char &c2) {
+    return (c1 == '/' && c2 == '/');
+  });
+  path.erase(iter, path.end());
 }
 
-void
-Denormalize(llvm::SmallVectorImpl<char> &path, FileSpec::PathSyntax syntax)
-{
-    if (PathSyntaxIsPosix(syntax)) return;
+void Denormalize(llvm::SmallVectorImpl<char> &path,
+                 FileSpec::PathSyntax syntax) {
+  if (PathSyntaxIsPosix(syntax))
+    return;
 
-    std::replace(path.begin(), path.end(), '/', '\\');
+  std::replace(path.begin(), path.end(), '/', '\\');
 }
 
-bool
-GetFileStats (const FileSpec *file_spec, struct stat *stats_ptr)
-{
-    char resolved_path[PATH_MAX];
-    if (file_spec->GetPath (resolved_path, sizeof(resolved_path)))
-        return FileSystem::Stat(resolved_path, stats_ptr) == 0;
-    return false;
+bool GetFileStats(const FileSpec *file_spec, struct stat *stats_ptr) {
+  char resolved_path[PATH_MAX];
+  if (file_spec->GetPath(resolved_path, sizeof(resolved_path)))
+    return FileSystem::Stat(resolved_path, stats_ptr) == 0;
+  return false;
 }
 
-size_t
-FilenamePos(llvm::StringRef str, FileSpec::PathSyntax syntax)
-{
-    if (str.size() == 2 && IsPathSeparator(str[0], syntax) && str[0] == str[1])
-        return 0;
+size_t FilenamePos(llvm::StringRef str, FileSpec::PathSyntax syntax) {
+  if (str.size() == 2 && IsPathSeparator(str[0], syntax) && str[0] == str[1])
+    return 0;
 
-    if (str.size() > 0 && IsPathSeparator(str.back(), syntax))
-        return str.size() - 1;
+  if (str.size() > 0 && IsPathSeparator(str.back(), syntax))
+    return str.size() - 1;
 
-    size_t pos = str.find_last_of(GetPathSeparators(syntax), str.size() - 1);
+  size_t pos = str.find_last_of(GetPathSeparators(syntax), str.size() - 1);
 
-    if (!PathSyntaxIsPosix(syntax) && pos == llvm::StringRef::npos)
-        pos = str.find_last_of(':', str.size() - 2);
+  if (!PathSyntaxIsPosix(syntax) && pos == llvm::StringRef::npos)
+    pos = str.find_last_of(':', str.size() - 2);
 
-    if (pos == llvm::StringRef::npos || (pos == 1 && IsPathSeparator(str[0], syntax)))
-        return 0;
+  if (pos == llvm::StringRef::npos ||
+      (pos == 1 && IsPathSeparator(str[0], syntax)))
+    return 0;
 
-    return pos + 1;
+  return pos + 1;
 }
 
-size_t
-RootDirStart(llvm::StringRef str, FileSpec::PathSyntax syntax)
-{
-    // case "c:/"
-    if (!PathSyntaxIsPosix(syntax) && (str.size() > 2 && str[1] == ':' && IsPathSeparator(str[2], syntax)))
-        return 2;
+size_t RootDirStart(llvm::StringRef str, FileSpec::PathSyntax syntax) {
+  // case "c:/"
+  if (!PathSyntaxIsPosix(syntax) &&
+      (str.size() > 2 && str[1] == ':' && IsPathSeparator(str[2], syntax)))
+    return 2;
 
-    // case "//"
-    if (str.size() == 2 && IsPathSeparator(str[0], syntax) && str[0] == str[1])
-        return llvm::StringRef::npos;
+  // case "//"
+  if (str.size() == 2 && IsPathSeparator(str[0], syntax) && str[0] == str[1])
+    return llvm::StringRef::npos;
 
-    // case "//net"
-    if (str.size() > 3 && IsPathSeparator(str[0], syntax) && str[0] == str[1] && !IsPathSeparator(str[2], syntax))
-        return str.find_first_of(GetPathSeparators(syntax), 2);
+  // case "//net"
+  if (str.size() > 3 && IsPathSeparator(str[0], syntax) && str[0] == str[1] &&
+      !IsPathSeparator(str[2], syntax))
+    return str.find_first_of(GetPathSeparators(syntax), 2);
 
-    // case "/"
-    if (str.size() > 0 && IsPathSeparator(str[0], syntax))
-        return 0;
+  // case "/"
+  if (str.size() > 0 && IsPathSeparator(str[0], syntax))
+    return 0;
 
-    return llvm::StringRef::npos;
+  return llvm::StringRef::npos;
 }
 
-size_t
-ParentPathEnd(llvm::StringRef path, FileSpec::PathSyntax syntax)
-{
-    size_t end_pos = FilenamePos(path, syntax);
+size_t ParentPathEnd(llvm::StringRef path, FileSpec::PathSyntax syntax) {
+  size_t end_pos = FilenamePos(path, syntax);
 
-    bool filename_was_sep = path.size() > 0 && IsPathSeparator(path[end_pos], syntax);
+  bool filename_was_sep =
+      path.size() > 0 && IsPathSeparator(path[end_pos], syntax);
 
-    // Skip separators except for root dir.
-    size_t root_dir_pos = RootDirStart(path.substr(0, end_pos), syntax);
+  // Skip separators except for root dir.
+  size_t root_dir_pos = RootDirStart(path.substr(0, end_pos), syntax);
 
-    while (end_pos > 0 && (end_pos - 1) != root_dir_pos && IsPathSeparator(path[end_pos - 1], syntax))
-        --end_pos;
+  while (end_pos > 0 && (end_pos - 1) != root_dir_pos &&
+         IsPathSeparator(path[end_pos - 1], syntax))
+    --end_pos;
 
-    if (end_pos == 1 && root_dir_pos == 0 && filename_was_sep)
-        return llvm::StringRef::npos;
+  if (end_pos == 1 && root_dir_pos == 0 && filename_was_sep)
+    return llvm::StringRef::npos;
 
-    return end_pos;
+  return end_pos;
 }
 
 } // end anonymous namespace
 
 // Resolves the username part of a path of the form ~user/other/directories, and
-// writes the result into dst_path.  This will also resolve "~" to the current user.
-// If you want to complete "~" to the list of users, pass it to ResolvePartialUsername.
-void
-FileSpec::ResolveUsername (llvm::SmallVectorImpl<char> &path)
-{
+// writes the result into dst_path.  This will also resolve "~" to the current
+// user.
+// If you want to complete "~" to the list of users, pass it to
+// ResolvePartialUsername.
+void FileSpec::ResolveUsername(llvm::SmallVectorImpl<char> &path) {
 #if LLDB_CONFIG_TILDE_RESOLVES_TO_USER
-    if (path.empty() || path[0] != '~')
-        return;
-    
-    llvm::StringRef path_str(path.data(), path.size());
-    size_t slash_pos = path_str.find('/', 1);
-    if (slash_pos == 1 || path.size() == 1)
-    {
-        // A path of ~/ resolves to the current user's home dir
-        llvm::SmallString<64> home_dir;
-        // llvm::sys::path::home_directory() only checks if "HOME" is set in the
-        // environment and does nothing else to locate the user home directory
-        if (!llvm::sys::path::home_directory(home_dir))
-        {
-            struct passwd *pw = getpwuid(getuid());
-            if (pw && pw->pw_dir && pw->pw_dir[0])
-            {
-                // Update our environemnt so llvm::sys::path::home_directory() works next time
-                setenv("HOME", pw->pw_dir, 0);
-                home_dir.assign(llvm::StringRef(pw->pw_dir));
-            }
-            else
-            {
-                return;
-            }
-        }
-        
-        // Overwrite the ~ with the first character of the homedir, and insert
-        // the rest.  This way we only trigger one move, whereas an insert
-        // followed by a delete (or vice versa) would trigger two.
-        path[0] = home_dir[0];
-        path.insert(path.begin() + 1, home_dir.begin() + 1, home_dir.end());
+  if (path.empty() || path[0] != '~')
+    return;
+
+  llvm::StringRef path_str(path.data(), path.size());
+  size_t slash_pos = path_str.find('/', 1);
+  if (slash_pos == 1 || path.size() == 1) {
+    // A path of ~/ resolves to the current user's home dir
+    llvm::SmallString<64> home_dir;
+    // llvm::sys::path::home_directory() only checks if "HOME" is set in the
+    // environment and does nothing else to locate the user home directory
+    if (!llvm::sys::path::home_directory(home_dir)) {
+      struct passwd *pw = getpwuid(getuid());
+      if (pw && pw->pw_dir && pw->pw_dir[0]) {
+        // Update our environemnt so llvm::sys::path::home_directory() works
+        // next time
+        setenv("HOME", pw->pw_dir, 0);
+        home_dir.assign(llvm::StringRef(pw->pw_dir));
+      } else {
         return;
+      }
     }
-    
-    auto username_begin = path.begin()+1;
-    auto username_end = (slash_pos == llvm::StringRef::npos)
-                        ? path.end()
-                        : (path.begin() + slash_pos);
-    size_t replacement_length = std::distance(path.begin(), username_end);
-
-    llvm::SmallString<20> username(username_begin, username_end);
-    struct passwd *user_entry = ::getpwnam(username.c_str());
-    if (user_entry != nullptr)
-    {
-        // Copy over the first n characters of the path, where n is the smaller of the length
-        // of the home directory and the slash pos.
-        llvm::StringRef homedir(user_entry->pw_dir);
-        size_t initial_copy_length = std::min(homedir.size(), replacement_length);
-        auto src_begin = homedir.begin();
-        auto src_end = src_begin + initial_copy_length;
-        std::copy(src_begin, src_end, path.begin());
-        if (replacement_length > homedir.size())
-        {
-            // We copied the entire home directory, but the ~username portion of the path was
-            // longer, so there's characters that need to be removed.
-            path.erase(path.begin() + initial_copy_length, username_end);
-        }
-        else if (replacement_length < homedir.size())
-        {
-            // We copied all the way up to the slash in the destination, but there's still more
-            // characters that need to be inserted.
-            path.insert(username_end, src_end, homedir.end());
-        }
-    }
-    else
-    {
-        // Unable to resolve username (user doesn't exist?)
-        path.clear();
-    }
+
+    // Overwrite the ~ with the first character of the homedir, and insert
+    // the rest.  This way we only trigger one move, whereas an insert
+    // followed by a delete (or vice versa) would trigger two.
+    path[0] = home_dir[0];
+    path.insert(path.begin() + 1, home_dir.begin() + 1, home_dir.end());
+    return;
+  }
+
+  auto username_begin = path.begin() + 1;
+  auto username_end = (slash_pos == llvm::StringRef::npos)
+                          ? path.end()
+                          : (path.begin() + slash_pos);
+  size_t replacement_length = std::distance(path.begin(), username_end);
+
+  llvm::SmallString<20> username(username_begin, username_end);
+  struct passwd *user_entry = ::getpwnam(username.c_str());
+  if (user_entry != nullptr) {
+    // Copy over the first n characters of the path, where n is the smaller of
+    // the length
+    // of the home directory and the slash pos.
+    llvm::StringRef homedir(user_entry->pw_dir);
+    size_t initial_copy_length = std::min(homedir.size(), replacement_length);
+    auto src_begin = homedir.begin();
+    auto src_end = src_begin + initial_copy_length;
+    std::copy(src_begin, src_end, path.begin());
+    if (replacement_length > homedir.size()) {
+      // We copied the entire home directory, but the ~username portion of the
+      // path was
+      // longer, so there's characters that need to be removed.
+      path.erase(path.begin() + initial_copy_length, username_end);
+    } else if (replacement_length < homedir.size()) {
+      // We copied all the way up to the slash in the destination, but there's
+      // still more
+      // characters that need to be inserted.
+      path.insert(username_end, src_end, homedir.end());
+    }
+  } else {
+    // Unable to resolve username (user doesn't exist?)
+    path.clear();
+  }
 #endif
 }
 
-size_t
-FileSpec::ResolvePartialUsername (const char *partial_name, StringList &matches)
-{
+size_t FileSpec::ResolvePartialUsername(const char *partial_name,
+                                        StringList &matches) {
 #ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER
-    size_t extant_entries = matches.GetSize();
-    
-    setpwent();
-    struct passwd *user_entry;
-    const char *name_start = partial_name + 1;
-    std::set<std::string> name_list;
-    
-    while ((user_entry = getpwent()) != NULL)
-    {
-        if (strstr(user_entry->pw_name, name_start) == user_entry->pw_name)
-        {
-            std::string tmp_buf("~");
-            tmp_buf.append(user_entry->pw_name);
-            tmp_buf.push_back('/');
-            name_list.insert(tmp_buf);                    
-        }
-    }
-    std::set<std::string>::iterator pos, end = name_list.end();
-    for (pos = name_list.begin(); pos != end; pos++)
-    {  
-        matches.AppendString((*pos).c_str());
-    }
-    return matches.GetSize() - extant_entries;
+  size_t extant_entries = matches.GetSize();
+
+  setpwent();
+  struct passwd *user_entry;
+  const char *name_start = partial_name + 1;
+  std::set<std::string> name_list;
+
+  while ((user_entry = getpwent()) != NULL) {
+    if (strstr(user_entry->pw_name, name_start) == user_entry->pw_name) {
+      std::string tmp_buf("~");
+      tmp_buf.append(user_entry->pw_name);
+      tmp_buf.push_back('/');
+      name_list.insert(tmp_buf);
+    }
+  }
+  std::set<std::string>::iterator pos, end = name_list.end();
+  for (pos = name_list.begin(); pos != end; pos++) {
+    matches.AppendString((*pos).c_str());
+  }
+  return matches.GetSize() - extant_entries;
 #else
-    // Resolving home directories is not supported, just copy the path...
-    return 0;
-#endif // #ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER    
+  // Resolving home directories is not supported, just copy the path...
+  return 0;
+#endif // #ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER
 }
 
-void
-FileSpec::Resolve (llvm::SmallVectorImpl<char> &path)
-{
-    if (path.empty())
-        return;
+void FileSpec::Resolve(llvm::SmallVectorImpl<char> &path) {
+  if (path.empty())
+    return;
 
 #ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER
-    if (path[0] == '~')
-        ResolveUsername(path);
+  if (path[0] == '~')
+    ResolveUsername(path);
 #endif // #ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER
 
-    // Save a copy of the original path that's passed in
-    llvm::SmallString<128> original_path(path.begin(), path.end());
+  // Save a copy of the original path that's passed in
+  llvm::SmallString<128> original_path(path.begin(), path.end());
 
-    llvm::sys::fs::make_absolute(path);
-    if (!llvm::sys::fs::exists(path))
-    {
-        path.clear();
-        path.append(original_path.begin(), original_path.end());
-    }
+  llvm::sys::fs::make_absolute(path);
+  if (!llvm::sys::fs::exists(path)) {
+    path.clear();
+    path.append(original_path.begin(), original_path.end());
+  }
 }
 
-FileSpec::FileSpec() : 
-    m_directory(), 
-    m_filename(), 
-    m_syntax(FileSystem::GetNativePathSyntax())
-{
+FileSpec::FileSpec()
+    : m_directory(), m_filename(), m_syntax(FileSystem::GetNativePathSyntax()) {
 }
 
 //------------------------------------------------------------------
 // Default constructor that can take an optional full path to a
 // file on disk.
 //------------------------------------------------------------------
-FileSpec::FileSpec(const char *pathname, bool resolve_path, PathSyntax syntax) :
-    m_directory(),
-    m_filename(),
-    m_is_resolved(false),
-    m_syntax(syntax)
-{
-    if (pathname && pathname[0])
-        SetFile(pathname, resolve_path, syntax);
-}
+FileSpec::FileSpec(const char *pathname, bool resolve_path, PathSyntax syntax)
+    : m_directory(), m_filename(), m_is_resolved(false), m_syntax(syntax) {
+  if (pathname && pathname[0])
+    SetFile(pathname, resolve_path, syntax);
+}
+
+FileSpec::FileSpec(const char *pathname, bool resolve_path, ArchSpec arch)
+    : FileSpec{pathname, resolve_path, arch.GetTriple().isOSWindows()
+                                           ? ePathSyntaxWindows
+                                           : ePathSyntaxPosix} {}
+
+FileSpec::FileSpec(const std::string &path, bool resolve_path,
+                   PathSyntax syntax)
+    : FileSpec{path.c_str(), resolve_path, syntax} {}
 
-FileSpec::FileSpec(const char *pathname, bool resolve_path, ArchSpec arch) :
-    FileSpec{pathname, resolve_path, arch.GetTriple().isOSWindows() ? ePathSyntaxWindows : ePathSyntaxPosix}
-{
-}
-
-FileSpec::FileSpec(const std::string &path, bool resolve_path, PathSyntax syntax) :
-    FileSpec{path.c_str(), resolve_path, syntax}
-{
-}
-
-FileSpec::FileSpec(const std::string &path, bool resolve_path, ArchSpec arch) :
-    FileSpec{path.c_str(), resolve_path, arch}
-{
-}
+FileSpec::FileSpec(const std::string &path, bool resolve_path, ArchSpec arch)
+    : FileSpec{path.c_str(), resolve_path, arch} {}
 
 //------------------------------------------------------------------
 // Copy constructor
 //------------------------------------------------------------------
-FileSpec::FileSpec(const FileSpec& rhs) :
-    m_directory (rhs.m_directory),
-    m_filename (rhs.m_filename),
-    m_is_resolved (rhs.m_is_resolved),
-    m_syntax (rhs.m_syntax)
-{
-}
+FileSpec::FileSpec(const FileSpec &rhs)
+    : m_directory(rhs.m_directory), m_filename(rhs.m_filename),
+      m_is_resolved(rhs.m_is_resolved), m_syntax(rhs.m_syntax) {}
 
 //------------------------------------------------------------------
 // Copy constructor
 //------------------------------------------------------------------
-FileSpec::FileSpec(const FileSpec* rhs) :
-    m_directory(),
-    m_filename()
-{
-    if (rhs)
-        *this = *rhs;
+FileSpec::FileSpec(const FileSpec *rhs) : m_directory(), m_filename() {
+  if (rhs)
+    *this = *rhs;
 }
 
 //------------------------------------------------------------------
 // Virtual destructor in case anyone inherits from this class.
 //------------------------------------------------------------------
-FileSpec::~FileSpec()
-{
-}
+FileSpec::~FileSpec() {}
 
 //------------------------------------------------------------------
 // Assignment operator.
 //------------------------------------------------------------------
-const FileSpec&
-FileSpec::operator= (const FileSpec& rhs)
-{
-    if (this != &rhs)
-    {
-        m_directory = rhs.m_directory;
-        m_filename = rhs.m_filename;
-        m_is_resolved = rhs.m_is_resolved;
-        m_syntax = rhs.m_syntax;
-    }
-    return *this;
+const FileSpec &FileSpec::operator=(const FileSpec &rhs) {
+  if (this != &rhs) {
+    m_directory = rhs.m_directory;
+    m_filename = rhs.m_filename;
+    m_is_resolved = rhs.m_is_resolved;
+    m_syntax = rhs.m_syntax;
+  }
+  return *this;
 }
 
 //------------------------------------------------------------------
@@ -389,66 +340,62 @@ FileSpec::operator= (const FileSpec& rhs
 // be split up into a directory and filename and stored as uniqued
 // string values for quick comparison and efficient memory usage.
 //------------------------------------------------------------------
-void
-FileSpec::SetFile (const char *pathname, bool resolve, PathSyntax syntax)
-{
-    m_filename.Clear();
-    m_directory.Clear();
-    m_is_resolved = false;
-    m_syntax = (syntax == ePathSyntaxHostNative) ? FileSystem::GetNativePathSyntax() : syntax;
+void FileSpec::SetFile(const char *pathname, bool resolve, PathSyntax syntax) {
+  m_filename.Clear();
+  m_directory.Clear();
+  m_is_resolved = false;
+  m_syntax = (syntax == ePathSyntaxHostNative)
+                 ? FileSystem::GetNativePathSyntax()
+                 : syntax;
 
-    if (pathname == NULL || pathname[0] == '\0')
-        return;
+  if (pathname == NULL || pathname[0] == '\0')
+    return;
 
-    llvm::SmallString<64> resolved(pathname);
+  llvm::SmallString<64> resolved(pathname);
 
-    if (resolve)
-    {
-        FileSpec::Resolve (resolved);
-        m_is_resolved = true;
-    }
+  if (resolve) {
+    FileSpec::Resolve(resolved);
+    m_is_resolved = true;
+  }
+
+  Normalize(resolved, syntax);
+
+  llvm::StringRef resolve_path_ref(resolved.c_str());
+  size_t dir_end = ParentPathEnd(resolve_path_ref, syntax);
+  if (dir_end == 0) {
+    m_filename.SetString(resolve_path_ref);
+    return;
+  }
 
-    Normalize(resolved, syntax);
+  m_directory.SetString(resolve_path_ref.substr(0, dir_end));
 
-    llvm::StringRef resolve_path_ref(resolved.c_str());
-    size_t dir_end = ParentPathEnd(resolve_path_ref, syntax);
-    if (dir_end == 0)
-    {
-        m_filename.SetString(resolve_path_ref);
-        return;
-    }
+  size_t filename_begin = dir_end;
+  size_t root_dir_start = RootDirStart(resolve_path_ref, syntax);
+  while (filename_begin != llvm::StringRef::npos &&
+         filename_begin < resolve_path_ref.size() &&
+         filename_begin != root_dir_start &&
+         IsPathSeparator(resolve_path_ref[filename_begin], syntax))
+    ++filename_begin;
+  m_filename.SetString((filename_begin == llvm::StringRef::npos ||
+                        filename_begin >= resolve_path_ref.size())
+                           ? "."
+                           : resolve_path_ref.substr(filename_begin));
+}
 
-    m_directory.SetString(resolve_path_ref.substr(0, dir_end));
+void FileSpec::SetFile(const char *pathname, bool resolve, ArchSpec arch) {
+  return SetFile(pathname, resolve, arch.GetTriple().isOSWindows()
+                                        ? ePathSyntaxWindows
+                                        : ePathSyntaxPosix);
+}
+
+void FileSpec::SetFile(const std::string &pathname, bool resolve,
+                       PathSyntax syntax) {
+  return SetFile(pathname.c_str(), resolve, syntax);
+}
 
-    size_t filename_begin = dir_end;
-    size_t root_dir_start = RootDirStart(resolve_path_ref, syntax);
-    while (filename_begin != llvm::StringRef::npos && filename_begin < resolve_path_ref.size() &&
-           filename_begin != root_dir_start && IsPathSeparator(resolve_path_ref[filename_begin], syntax))
-        ++filename_begin;
-    m_filename.SetString((filename_begin == llvm::StringRef::npos || filename_begin >= resolve_path_ref.size())
-                             ? "."
-                             : resolve_path_ref.substr(filename_begin));
-}
-
-void
-FileSpec::SetFile(const char *pathname, bool resolve, ArchSpec arch)
-{
-    return SetFile(pathname, resolve,
-            arch.GetTriple().isOSWindows()
-            ? ePathSyntaxWindows
-            : ePathSyntaxPosix);
-}
-
-void
-FileSpec::SetFile(const std::string &pathname, bool resolve, PathSyntax syntax)
-{
-    return SetFile(pathname.c_str(), resolve, syntax);
-}
-
-void
-FileSpec::SetFile(const std::string &pathname, bool resolve, ArchSpec arch)
-{
-    return SetFile(pathname.c_str(), resolve, arch);
+void FileSpec::SetFile(const std::string &pathname, bool resolve,
+                       ArchSpec arch) {
+  return SetFile(pathname.c_str(), resolve, arch);
 }
 
 //----------------------------------------------------------------------
@@ -458,10 +405,7 @@ FileSpec::SetFile(const std::string &pat
 //  if (file_spec)
 //  {}
 //----------------------------------------------------------------------
-FileSpec::operator bool() const
-{
-    return m_filename || m_directory;
-}
+FileSpec::operator bool() const { return m_filename || m_directory; }
 
 //----------------------------------------------------------------------
 // Logical NOT operator. This allows code to check any FileSpec
@@ -470,123 +414,96 @@ FileSpec::operator bool() const
 //  if (!file_spec)
 //  {}
 //----------------------------------------------------------------------
-bool
-FileSpec::operator!() const
-{
-    return !m_directory && !m_filename;
-}
-
-bool
-FileSpec::DirectoryEquals(const FileSpec &rhs) const
-{
-    const bool case_sensitive = IsCaseSensitive() || rhs.IsCaseSensitive();
-    return ConstString::Equals(m_directory, rhs.m_directory, case_sensitive);
-}
-
-bool
-FileSpec::FileEquals(const FileSpec &rhs) const
-{
-    const bool case_sensitive = IsCaseSensitive() || rhs.IsCaseSensitive();
-    return ConstString::Equals(m_filename, rhs.m_filename, case_sensitive);
+bool FileSpec::operator!() const { return !m_directory && !m_filename; }
+
+bool FileSpec::DirectoryEquals(const FileSpec &rhs) const {
+  const bool case_sensitive = IsCaseSensitive() || rhs.IsCaseSensitive();
+  return ConstString::Equals(m_directory, rhs.m_directory, case_sensitive);
+}
+
+bool FileSpec::FileEquals(const FileSpec &rhs) const {
+  const bool case_sensitive = IsCaseSensitive() || rhs.IsCaseSensitive();
+  return ConstString::Equals(m_filename, rhs.m_filename, case_sensitive);
 }
 
 //------------------------------------------------------------------
 // Equal to operator
 //------------------------------------------------------------------
-bool
-FileSpec::operator== (const FileSpec& rhs) const
-{
-    if (!FileEquals(rhs))
-        return false;
-    if (DirectoryEquals(rhs))
-        return true;
-
-    // TODO: determine if we want to keep this code in here.
-    // The code below was added to handle a case where we were
-    // trying to set a file and line breakpoint and one path
-    // was resolved, and the other not and the directory was
-    // in a mount point that resolved to a more complete path:
-    // "/tmp/a.c" == "/private/tmp/a.c". I might end up pulling
-    // this out...
-    if (IsResolved() && rhs.IsResolved())
-    {
-        // Both paths are resolved, no need to look further...
-        return false;
-    }
-
-    FileSpec resolved_lhs(*this);
+bool FileSpec::operator==(const FileSpec &rhs) const {
+  if (!FileEquals(rhs))
+    return false;
+  if (DirectoryEquals(rhs))
+    return true;
 
-    // If "this" isn't resolved, resolve it
-    if (!IsResolved())
-    {
-        if (resolved_lhs.ResolvePath())
-        {
-            // This path wasn't resolved but now it is. Check if the resolved
-            // directory is the same as our unresolved directory, and if so,
-            // we can mark this object as resolved to avoid more future resolves
-            m_is_resolved = (m_directory == resolved_lhs.m_directory);
-        }
-        else
-            return false;
-    }
+  // TODO: determine if we want to keep this code in here.
+  // The code below was added to handle a case where we were
+  // trying to set a file and line breakpoint and one path
+  // was resolved, and the other not and the directory was
+  // in a mount point that resolved to a more complete path:
+  // "/tmp/a.c" == "/private/tmp/a.c". I might end up pulling
+  // this out...
+  if (IsResolved() && rhs.IsResolved()) {
+    // Both paths are resolved, no need to look further...
+    return false;
+  }
 
-    FileSpec resolved_rhs(rhs);
-    if (!rhs.IsResolved())
-    {
-        if (resolved_rhs.ResolvePath())
-        {
-            // rhs's path wasn't resolved but now it is. Check if the resolved
-            // directory is the same as rhs's unresolved directory, and if so,
-            // we can mark this object as resolved to avoid more future resolves
-            rhs.m_is_resolved = (rhs.m_directory == resolved_rhs.m_directory);
-        }
-        else
-            return false;
-    }
+  FileSpec resolved_lhs(*this);
 
-    // If we reach this point in the code we were able to resolve both paths
-    // and since we only resolve the paths if the basenames are equal, then
-    // we can just check if both directories are equal...
-    return DirectoryEquals(rhs);
+  // If "this" isn't resolved, resolve it
+  if (!IsResolved()) {
+    if (resolved_lhs.ResolvePath()) {
+      // This path wasn't resolved but now it is. Check if the resolved
+      // directory is the same as our unresolved directory, and if so,
+      // we can mark this object as resolved to avoid more future resolves
+      m_is_resolved = (m_directory == resolved_lhs.m_directory);
+    } else
+      return false;
+  }
+
+  FileSpec resolved_rhs(rhs);
+  if (!rhs.IsResolved()) {
+    if (resolved_rhs.ResolvePath()) {
+      // rhs's path wasn't resolved but now it is. Check if the resolved
+      // directory is the same as rhs's unresolved directory, and if so,
+      // we can mark this object as resolved to avoid more future resolves
+      rhs.m_is_resolved = (rhs.m_directory == resolved_rhs.m_directory);
+    } else
+      return false;
+  }
+
+  // If we reach this point in the code we were able to resolve both paths
+  // and since we only resolve the paths if the basenames are equal, then
+  // we can just check if both directories are equal...
+  return DirectoryEquals(rhs);
 }
 
 //------------------------------------------------------------------
 // Not equal to operator
 //------------------------------------------------------------------
-bool
-FileSpec::operator!= (const FileSpec& rhs) const
-{
-    return !(*this == rhs);
-}
+bool FileSpec::operator!=(const FileSpec &rhs) const { return !(*this == rhs); }
 
 //------------------------------------------------------------------
 // Less than operator
 //------------------------------------------------------------------
-bool
-FileSpec::operator< (const FileSpec& rhs) const
-{
-    return FileSpec::Compare(*this, rhs, true) < 0;
+bool FileSpec::operator<(const FileSpec &rhs) const {
+  return FileSpec::Compare(*this, rhs, true) < 0;
 }
 
 //------------------------------------------------------------------
 // Dump a FileSpec object to a stream
 //------------------------------------------------------------------
-Stream&
-lldb_private::operator << (Stream &s, const FileSpec& f)
-{
-    f.Dump(&s);
-    return s;
+Stream &lldb_private::operator<<(Stream &s, const FileSpec &f) {
+  f.Dump(&s);
+  return s;
 }
 
 //------------------------------------------------------------------
 // Clear this object by releasing both the directory and filename
 // string values and making them both the empty string.
 //------------------------------------------------------------------
-void
-FileSpec::Clear()
-{
-    m_directory.Clear();
-    m_filename.Clear();
+void FileSpec::Clear() {
+  m_directory.Clear();
+  m_filename.Clear();
 }
 
 //------------------------------------------------------------------
@@ -600,166 +517,148 @@ FileSpec::Clear()
 // Return -1 if the "a" is less than "b", 0 if "a" is equal to "b"
 // and "1" if "a" is greater than "b".
 //------------------------------------------------------------------
-int
-FileSpec::Compare(const FileSpec& a, const FileSpec& b, bool full)
-{
-    int result = 0;
-
-    // case sensitivity of compare
-    const bool case_sensitive = a.IsCaseSensitive() || b.IsCaseSensitive();
-
-    // If full is true, then we must compare both the directory and filename.
-
-    // If full is false, then if either directory is empty, then we match on
-    // the basename only, and if both directories have valid values, we still
-    // do a full compare. This allows for matching when we just have a filename
-    // in one of the FileSpec objects.
-
-    if (full || (a.m_directory && b.m_directory))
-    {
-        result = ConstString::Compare(a.m_directory, b.m_directory, case_sensitive);
-        if (result)
-            return result;
-    }
-    return ConstString::Compare(a.m_filename, b.m_filename, case_sensitive);
-}
+int FileSpec::Compare(const FileSpec &a, const FileSpec &b, bool full) {
+  int result = 0;
 
-bool
-FileSpec::Equal (const FileSpec& a, const FileSpec& b, bool full, bool remove_backups)
-{
-    // case sensitivity of equality test
-    const bool case_sensitive = a.IsCaseSensitive() || b.IsCaseSensitive();
-
-    if (!full && (a.GetDirectory().IsEmpty() || b.GetDirectory().IsEmpty()))
-        return ConstString::Equals(a.m_filename, b.m_filename, case_sensitive);
-    else if (remove_backups == false)
-        return a == b;
-    else
-    {
-        if (!ConstString::Equals(a.m_filename, b.m_filename, case_sensitive))
-            return false;
-        if (ConstString::Equals(a.m_directory, b.m_directory, case_sensitive))
-            return true;
-        ConstString a_without_dots;
-        ConstString b_without_dots;
+  // case sensitivity of compare
+  const bool case_sensitive = a.IsCaseSensitive() || b.IsCaseSensitive();
 
-        RemoveBackupDots (a.m_directory, a_without_dots);
-        RemoveBackupDots (b.m_directory, b_without_dots);
-        return ConstString::Equals(a_without_dots, b_without_dots, case_sensitive);
-    }
-}
+  // If full is true, then we must compare both the directory and filename.
 
-void
-FileSpec::NormalizePath ()
-{
-    ConstString normalized_directory;
-    FileSpec::RemoveBackupDots(m_directory, normalized_directory);
-    m_directory = normalized_directory;
-}
+  // If full is false, then if either directory is empty, then we match on
+  // the basename only, and if both directories have valid values, we still
+  // do a full compare. This allows for matching when we just have a filename
+  // in one of the FileSpec objects.
+
+  if (full || (a.m_directory && b.m_directory)) {
+    result = ConstString::Compare(a.m_directory, b.m_directory, case_sensitive);
+    if (result)
+      return result;
+  }
+  return ConstString::Compare(a.m_filename, b.m_filename, case_sensitive);
+}
+
+bool FileSpec::Equal(const FileSpec &a, const FileSpec &b, bool full,
+                     bool remove_backups) {
+  // case sensitivity of equality test
+  const bool case_sensitive = a.IsCaseSensitive() || b.IsCaseSensitive();
+
+  if (!full && (a.GetDirectory().IsEmpty() || b.GetDirectory().IsEmpty()))
+    return ConstString::Equals(a.m_filename, b.m_filename, case_sensitive);
+  else if (remove_backups == false)
+    return a == b;
+  else {
+    if (!ConstString::Equals(a.m_filename, b.m_filename, case_sensitive))
+      return false;
+    if (ConstString::Equals(a.m_directory, b.m_directory, case_sensitive))
+      return true;
+    ConstString a_without_dots;
+    ConstString b_without_dots;
+
+    RemoveBackupDots(a.m_directory, a_without_dots);
+    RemoveBackupDots(b.m_directory, b_without_dots);
+    return ConstString::Equals(a_without_dots, b_without_dots, case_sensitive);
+  }
+}
+
+void FileSpec::NormalizePath() {
+  ConstString normalized_directory;
+  FileSpec::RemoveBackupDots(m_directory, normalized_directory);
+  m_directory = normalized_directory;
+}
+
+void FileSpec::RemoveBackupDots(const ConstString &input_const_str,
+                                ConstString &result_const_str) {
+  const char *input = input_const_str.GetCString();
+  result_const_str.Clear();
+  if (!input || input[0] == '\0')
+    return;
 
-void
-FileSpec::RemoveBackupDots (const ConstString &input_const_str, ConstString &result_const_str)
-{
-    const char *input = input_const_str.GetCString();
-    result_const_str.Clear();
-    if (!input || input[0] == '\0')
-        return;
+  const char win_sep = '\\';
+  const char unix_sep = '/';
+  char found_sep;
+  const char *win_backup = "\\..";
+  const char *unix_backup = "/..";
+
+  bool is_win = false;
+
+  // Determine the platform for the path (win or unix):
+
+  if (input[0] == win_sep)
+    is_win = true;
+  else if (input[0] == unix_sep)
+    is_win = false;
+  else if (input[1] == ':')
+    is_win = true;
+  else if (strchr(input, unix_sep) != nullptr)
+    is_win = false;
+  else if (strchr(input, win_sep) != nullptr)
+    is_win = true;
+  else {
+    // No separators at all, no reason to do any work here.
+    result_const_str = input_const_str;
+    return;
+  }
 
-    const char win_sep = '\\';
-    const char unix_sep = '/';
-    char found_sep;
-    const char *win_backup = "\\..";
-    const char *unix_backup = "/..";
-
-    bool is_win = false;
-
-    // Determine the platform for the path (win or unix):
-    
-    if (input[0] == win_sep)
-        is_win = true;
-    else if (input[0] == unix_sep)
-        is_win = false;
-    else if (input[1] == ':')
-        is_win = true;
-    else if (strchr(input, unix_sep) != nullptr)
-        is_win = false;
-    else if (strchr(input, win_sep) != nullptr)
-        is_win = true;
-    else
-    {
-        // No separators at all, no reason to do any work here.
+  llvm::StringRef backup_sep;
+  if (is_win) {
+    found_sep = win_sep;
+    backup_sep = win_backup;
+  } else {
+    found_sep = unix_sep;
+    backup_sep = unix_backup;
+  }
+
+  llvm::StringRef input_ref(input);
+  llvm::StringRef curpos(input);
+
+  bool had_dots = false;
+  std::string result;
+
+  while (1) {
+    // Start of loop
+    llvm::StringRef before_sep;
+    std::pair<llvm::StringRef, llvm::StringRef> around_sep =
+        curpos.split(backup_sep);
+
+    before_sep = around_sep.first;
+    curpos = around_sep.second;
+
+    if (curpos.empty()) {
+      if (had_dots) {
+        while (before_sep.startswith("//"))
+          before_sep = before_sep.substr(1);
+        if (!before_sep.empty()) {
+          result.append(before_sep.data(), before_sep.size());
+        }
+      }
+      break;
+    }
+    had_dots = true;
+
+    unsigned num_backups = 1;
+    while (curpos.startswith(backup_sep)) {
+      num_backups++;
+      curpos = curpos.slice(backup_sep.size(), curpos.size());
+    }
+
+    size_t end_pos = before_sep.size();
+    while (num_backups-- > 0) {
+      end_pos = before_sep.rfind(found_sep, end_pos);
+      if (end_pos == llvm::StringRef::npos) {
         result_const_str = input_const_str;
         return;
+      }
     }
+    result.append(before_sep.data(), end_pos);
+  }
 
-    llvm::StringRef backup_sep;
-    if (is_win)
-    {
-        found_sep = win_sep;
-        backup_sep = win_backup;
-    }
-    else
-    {
-        found_sep = unix_sep;
-        backup_sep = unix_backup;
-    }
-    
-    llvm::StringRef input_ref(input);
-    llvm::StringRef curpos(input);
-
-    bool had_dots = false;
-    std::string result;
-
-    while (1)
-    {
-        // Start of loop
-        llvm::StringRef before_sep;
-        std::pair<llvm::StringRef, llvm::StringRef> around_sep = curpos.split(backup_sep);
-        
-        before_sep = around_sep.first;
-        curpos     = around_sep.second;
-
-        if (curpos.empty())
-        {
-            if (had_dots)
-            {
-                while (before_sep.startswith("//"))
-                    before_sep = before_sep.substr(1);
-                if (!before_sep.empty())
-                {
-                    result.append(before_sep.data(), before_sep.size());
-                }
-            }
-            break;
-        }
-        had_dots = true;
+  if (had_dots)
+    result_const_str.SetCString(result.c_str());
+  else
+    result_const_str = input_const_str;
 
-        unsigned num_backups = 1;
-        while (curpos.startswith(backup_sep))
-        {
-            num_backups++;
-            curpos = curpos.slice(backup_sep.size(), curpos.size());
-        }
-        
-        size_t end_pos = before_sep.size();
-        while (num_backups-- > 0)
-        {
-            end_pos = before_sep.rfind(found_sep, end_pos);
-            if (end_pos == llvm::StringRef::npos)
-            {
-                result_const_str = input_const_str;
-                return;
-            }
-        }
-        result.append(before_sep.data(), end_pos);
-    }
-
-    if (had_dots)
-        result_const_str.SetCString(result.c_str());
-    else
-        result_const_str = input_const_str;
-        
-    return;
+  return;
 }
 
 //------------------------------------------------------------------
@@ -767,279 +666,230 @@ FileSpec::RemoveBackupDots (const ConstS
 // a valid directory name, it will be displayed followed by a
 // directory delimiter, and the filename.
 //------------------------------------------------------------------
-void
-FileSpec::Dump(Stream *s) const
-{
-    if (s)
-    {
-        std::string path{GetPath(true)};
-        s->PutCString(path.c_str());
-        char path_separator = GetPrefferedPathSeparator(m_syntax);
-        if (!m_filename && !path.empty() && path.back() != path_separator)
-            s->PutChar(path_separator);
-    }
+void FileSpec::Dump(Stream *s) const {
+  if (s) {
+    std::string path{GetPath(true)};
+    s->PutCString(path.c_str());
+    char path_separator = GetPrefferedPathSeparator(m_syntax);
+    if (!m_filename && !path.empty() && path.back() != path_separator)
+      s->PutChar(path_separator);
+  }
 }
 
 //------------------------------------------------------------------
 // Returns true if the file exists.
 //------------------------------------------------------------------
-bool
-FileSpec::Exists () const
-{
-    struct stat file_stats;
-    return GetFileStats (this, &file_stats);
-}
-
-bool
-FileSpec::Readable () const
-{
-    const uint32_t permissions = GetPermissions();
-    if (permissions & eFilePermissionsEveryoneR)
-        return true;
-    return false;
-}
-
-bool
-FileSpec::ResolveExecutableLocation ()
-{
-    if (!m_directory)
-    {
-        const char *file_cstr = m_filename.GetCString();
-        if (file_cstr)
-        {
-            const std::string file_str (file_cstr);
-            llvm::ErrorOr<std::string> error_or_path = llvm::sys::findProgramByName (file_str);
-            if (!error_or_path)
-                return false;
-            std::string path = error_or_path.get();
-            llvm::StringRef dir_ref = llvm::sys::path::parent_path(path);
-            if (!dir_ref.empty())
-            {
-                // FindProgramByName returns "." if it can't find the file.
-                if (strcmp (".", dir_ref.data()) == 0)
-                    return false;
-
-                m_directory.SetCString (dir_ref.data());
-                if (Exists())
-                    return true;
-                else
-                {
-                    // If FindProgramByName found the file, it returns the directory + filename in its return results.
-                    // We need to separate them.
-                    FileSpec tmp_file (dir_ref.data(), false);
-                    if (tmp_file.Exists())
-                    {
-                        m_directory = tmp_file.m_directory;
-                        return true;
-                    }
-                }
-            }
+bool FileSpec::Exists() const {
+  struct stat file_stats;
+  return GetFileStats(this, &file_stats);
+}
+
+bool FileSpec::Readable() const {
+  const uint32_t permissions = GetPermissions();
+  if (permissions & eFilePermissionsEveryoneR)
+    return true;
+  return false;
+}
+
+bool FileSpec::ResolveExecutableLocation() {
+  if (!m_directory) {
+    const char *file_cstr = m_filename.GetCString();
+    if (file_cstr) {
+      const std::string file_str(file_cstr);
+      llvm::ErrorOr<std::string> error_or_path =
+          llvm::sys::findProgramByName(file_str);
+      if (!error_or_path)
+        return false;
+      std::string path = error_or_path.get();
+      llvm::StringRef dir_ref = llvm::sys::path::parent_path(path);
+      if (!dir_ref.empty()) {
+        // FindProgramByName returns "." if it can't find the file.
+        if (strcmp(".", dir_ref.data()) == 0)
+          return false;
+
+        m_directory.SetCString(dir_ref.data());
+        if (Exists())
+          return true;
+        else {
+          // If FindProgramByName found the file, it returns the directory +
+          // filename in its return results.
+          // We need to separate them.
+          FileSpec tmp_file(dir_ref.data(), false);
+          if (tmp_file.Exists()) {
+            m_directory = tmp_file.m_directory;
+            return true;
+          }
         }
+      }
     }
-    
-    return false;
-}
-
-bool
-FileSpec::ResolvePath ()
-{
-    if (m_is_resolved)
-        return true;    // We have already resolved this path
+  }
 
-    char path_buf[PATH_MAX];    
-    if (!GetPath (path_buf, PATH_MAX, false))
-        return false;
-    // SetFile(...) will set m_is_resolved correctly if it can resolve the path
-    SetFile (path_buf, true);
-    return m_is_resolved; 
+  return false;
 }
 
-uint64_t
-FileSpec::GetByteSize() const
-{
-    struct stat file_stats;
-    if (GetFileStats (this, &file_stats))
-        return file_stats.st_size;
-    return 0;
-}
+bool FileSpec::ResolvePath() {
+  if (m_is_resolved)
+    return true; // We have already resolved this path
 
-FileSpec::PathSyntax
-FileSpec::GetPathSyntax() const
-{
-    return m_syntax;
-}
-
-FileSpec::FileType
-FileSpec::GetFileType () const
-{
-    struct stat file_stats;
-    if (GetFileStats (this, &file_stats))
-    {
-        mode_t file_type = file_stats.st_mode & S_IFMT;
-        switch (file_type)
-        {
-        case S_IFDIR:   return eFileTypeDirectory;
-        case S_IFREG:   return eFileTypeRegular;
+  char path_buf[PATH_MAX];
+  if (!GetPath(path_buf, PATH_MAX, false))
+    return false;
+  // SetFile(...) will set m_is_resolved correctly if it can resolve the path
+  SetFile(path_buf, true);
+  return m_is_resolved;
+}
+
+uint64_t FileSpec::GetByteSize() const {
+  struct stat file_stats;
+  if (GetFileStats(this, &file_stats))
+    return file_stats.st_size;
+  return 0;
+}
+
+FileSpec::PathSyntax FileSpec::GetPathSyntax() const { return m_syntax; }
+
+FileSpec::FileType FileSpec::GetFileType() const {
+  struct stat file_stats;
+  if (GetFileStats(this, &file_stats)) {
+    mode_t file_type = file_stats.st_mode & S_IFMT;
+    switch (file_type) {
+    case S_IFDIR:
+      return eFileTypeDirectory;
+    case S_IFREG:
+      return eFileTypeRegular;
 #ifndef _WIN32
-        case S_IFIFO:   return eFileTypePipe;
-        case S_IFSOCK:  return eFileTypeSocket;
-        case S_IFLNK:   return eFileTypeSymbolicLink;
+    case S_IFIFO:
+      return eFileTypePipe;
+    case S_IFSOCK:
+      return eFileTypeSocket;
+    case S_IFLNK:
+      return eFileTypeSymbolicLink;
 #endif
-        default:
-            break;
-        }
-        return eFileTypeUnknown;
+    default:
+      break;
     }
-    return eFileTypeInvalid;
+    return eFileTypeUnknown;
+  }
+  return eFileTypeInvalid;
 }
 
-bool
-FileSpec::IsSymbolicLink () const
-{
-    char resolved_path[PATH_MAX];
-    if (!GetPath (resolved_path, sizeof (resolved_path)))
-        return false;
+bool FileSpec::IsSymbolicLink() const {
+  char resolved_path[PATH_MAX];
+  if (!GetPath(resolved_path, sizeof(resolved_path)))
+    return false;
 
 #ifdef _WIN32
-    std::wstring wpath;
-    if (!llvm::ConvertUTF8toWide(resolved_path, wpath))
-        return false;
-    auto attrs = ::GetFileAttributesW(wpath.c_str());
-    if (attrs == INVALID_FILE_ATTRIBUTES)
-        return false;
+  std::wstring wpath;
+  if (!llvm::ConvertUTF8toWide(resolved_path, wpath))
+    return false;
+  auto attrs = ::GetFileAttributesW(wpath.c_str());
+  if (attrs == INVALID_FILE_ATTRIBUTES)
+    return false;
 
-    return (attrs & FILE_ATTRIBUTE_REPARSE_POINT);
+  return (attrs & FILE_ATTRIBUTE_REPARSE_POINT);
 #else
-    struct stat file_stats;
-    if (::lstat (resolved_path, &file_stats) != 0)
-        return false;
+  struct stat file_stats;
+  if (::lstat(resolved_path, &file_stats) != 0)
+    return false;
 
-    return (file_stats.st_mode & S_IFMT) == S_IFLNK;
+  return (file_stats.st_mode & S_IFMT) == S_IFLNK;
 #endif
 }
 
-uint32_t
-FileSpec::GetPermissions () const
-{
-    uint32_t file_permissions = 0;
-    if (*this)
-        FileSystem::GetFilePermissions(*this, file_permissions);
-    return file_permissions;
-}
-
-TimeValue
-FileSpec::GetModificationTime () const
-{
-    TimeValue mod_time;
-    struct stat file_stats;
-    if (GetFileStats (this, &file_stats))
-        mod_time.OffsetWithSeconds(file_stats.st_mtime);
-    return mod_time;
+uint32_t FileSpec::GetPermissions() const {
+  uint32_t file_permissions = 0;
+  if (*this)
+    FileSystem::GetFilePermissions(*this, file_permissions);
+  return file_permissions;
+}
+
+TimeValue FileSpec::GetModificationTime() const {
+  TimeValue mod_time;
+  struct stat file_stats;
+  if (GetFileStats(this, &file_stats))
+    mod_time.OffsetWithSeconds(file_stats.st_mtime);
+  return mod_time;
 }
 
 //------------------------------------------------------------------
 // Directory string get accessor.
 //------------------------------------------------------------------
-ConstString &
-FileSpec::GetDirectory()
-{
-    return m_directory;
-}
+ConstString &FileSpec::GetDirectory() { return m_directory; }
 
 //------------------------------------------------------------------
 // Directory string const get accessor.
 //------------------------------------------------------------------
-const ConstString &
-FileSpec::GetDirectory() const
-{
-    return m_directory;
-}
+const ConstString &FileSpec::GetDirectory() const { return m_directory; }
 
 //------------------------------------------------------------------
 // Filename string get accessor.
 //------------------------------------------------------------------
-ConstString &
-FileSpec::GetFilename()
-{
-    return m_filename;
-}
+ConstString &FileSpec::GetFilename() { return m_filename; }
 
 //------------------------------------------------------------------
 // Filename string const get accessor.
 //------------------------------------------------------------------
-const ConstString &
-FileSpec::GetFilename() const
-{
-    return m_filename;
-}
+const ConstString &FileSpec::GetFilename() const { return m_filename; }
 
 //------------------------------------------------------------------
 // Extract the directory and path into a fixed buffer. This is
 // needed as the directory and path are stored in separate string
 // values.
 //------------------------------------------------------------------
-size_t
-FileSpec::GetPath(char *path, size_t path_max_len, bool denormalize) const
-{
-    if (!path)
-        return 0;
-
-    std::string result = GetPath(denormalize);
-    ::snprintf(path, path_max_len, "%s", result.c_str());
-    return std::min(path_max_len-1, result.length());
-}
-
-std::string
-FileSpec::GetPath(bool denormalize) const
-{
-    llvm::SmallString<64> result;
-    GetPath(result, denormalize);
-    return std::string(result.begin(), result.end());
-}
-
-const char *
-FileSpec::GetCString(bool denormalize) const
-{
-    return ConstString{GetPath(denormalize)}.AsCString(NULL);
-}
-
-void
-FileSpec::GetPath(llvm::SmallVectorImpl<char> &path, bool denormalize) const
-{
-    path.append(m_directory.GetStringRef().begin(), m_directory.GetStringRef().end());
-    if (m_directory && m_filename && !IsPathSeparator(m_directory.GetStringRef().back(), m_syntax))
-        path.insert(path.end(), GetPrefferedPathSeparator(m_syntax));
-    path.append(m_filename.GetStringRef().begin(), m_filename.GetStringRef().end());
-    Normalize(path, m_syntax);
-    if (denormalize && !path.empty())
-        Denormalize(path, m_syntax);
-}
-
-ConstString
-FileSpec::GetFileNameExtension () const
-{
-    if (m_filename)
-    {
-        const char *filename = m_filename.GetCString();
-        const char* dot_pos = strrchr(filename, '.');
-        if (dot_pos && dot_pos[1] != '\0')
-            return ConstString(dot_pos+1);
-    }
-    return ConstString();
+size_t FileSpec::GetPath(char *path, size_t path_max_len,
+                         bool denormalize) const {
+  if (!path)
+    return 0;
+
+  std::string result = GetPath(denormalize);
+  ::snprintf(path, path_max_len, "%s", result.c_str());
+  return std::min(path_max_len - 1, result.length());
+}
+
+std::string FileSpec::GetPath(bool denormalize) const {
+  llvm::SmallString<64> result;
+  GetPath(result, denormalize);
+  return std::string(result.begin(), result.end());
+}
+
+const char *FileSpec::GetCString(bool denormalize) const {
+  return ConstString{GetPath(denormalize)}.AsCString(NULL);
+}
+
+void FileSpec::GetPath(llvm::SmallVectorImpl<char> &path,
+                       bool denormalize) const {
+  path.append(m_directory.GetStringRef().begin(),
+              m_directory.GetStringRef().end());
+  if (m_directory && m_filename &&
+      !IsPathSeparator(m_directory.GetStringRef().back(), m_syntax))
+    path.insert(path.end(), GetPrefferedPathSeparator(m_syntax));
+  path.append(m_filename.GetStringRef().begin(),
+              m_filename.GetStringRef().end());
+  Normalize(path, m_syntax);
+  if (denormalize && !path.empty())
+    Denormalize(path, m_syntax);
 }
 
-ConstString
-FileSpec::GetFileNameStrippingExtension () const
-{
+ConstString FileSpec::GetFileNameExtension() const {
+  if (m_filename) {
     const char *filename = m_filename.GetCString();
-    if (filename == NULL)
-        return ConstString();
-    
-    const char* dot_pos = strrchr(filename, '.');
-    if (dot_pos == NULL)
-        return m_filename;
-    
-    return ConstString(filename, dot_pos-filename);
+    const char *dot_pos = strrchr(filename, '.');
+    if (dot_pos && dot_pos[1] != '\0')
+      return ConstString(dot_pos + 1);
+  }
+  return ConstString();
+}
+
+ConstString FileSpec::GetFileNameStrippingExtension() const {
+  const char *filename = m_filename.GetCString();
+  if (filename == NULL)
+    return ConstString();
+
+  const char *dot_pos = strrchr(filename, '.');
+  if (dot_pos == NULL)
+    return m_filename;
+
+  return ConstString(filename, dot_pos - filename);
 }
 
 //------------------------------------------------------------------
@@ -1053,66 +903,56 @@ FileSpec::GetFileNameStrippingExtension
 // truncated. The final number of bytes that get mapped can be
 // verified using the DataBuffer::GetByteSize() function.
 //------------------------------------------------------------------
-DataBufferSP
-FileSpec::MemoryMapFileContents(off_t file_offset, size_t file_size) const
-{
-    DataBufferSP data_sp;
-    std::unique_ptr<DataBufferMemoryMap> mmap_data(new DataBufferMemoryMap());
-    if (mmap_data.get())
-    {
-        const size_t mapped_length = mmap_data->MemoryMapFromFileSpec (this, file_offset, file_size);
-        if (((file_size == SIZE_MAX) && (mapped_length > 0)) || (mapped_length >= file_size))
-            data_sp.reset(mmap_data.release());
-    }
-    return data_sp;
+DataBufferSP FileSpec::MemoryMapFileContents(off_t file_offset,
+                                             size_t file_size) const {
+  DataBufferSP data_sp;
+  std::unique_ptr<DataBufferMemoryMap> mmap_data(new DataBufferMemoryMap());
+  if (mmap_data.get()) {
+    const size_t mapped_length =
+        mmap_data->MemoryMapFromFileSpec(this, file_offset, file_size);
+    if (((file_size == SIZE_MAX) && (mapped_length > 0)) ||
+        (mapped_length >= file_size))
+      data_sp.reset(mmap_data.release());
+  }
+  return data_sp;
+}
+
+DataBufferSP FileSpec::MemoryMapFileContentsIfLocal(off_t file_offset,
+                                                    size_t file_size) const {
+  if (FileSystem::IsLocal(*this))
+    return MemoryMapFileContents(file_offset, file_size);
+  else
+    return ReadFileContents(file_offset, file_size, NULL);
 }
 
-DataBufferSP
-FileSpec::MemoryMapFileContentsIfLocal(off_t file_offset, size_t file_size) const
-{
-    if (FileSystem::IsLocal(*this))
-        return MemoryMapFileContents(file_offset, file_size);
-    else
-        return ReadFileContents(file_offset, file_size, NULL);
-}
-
-
 //------------------------------------------------------------------
 // Return the size in bytes that this object takes in memory. This
 // returns the size in bytes of this object, not any shared string
 // values it may refer to.
 //------------------------------------------------------------------
-size_t
-FileSpec::MemorySize() const
-{
-    return m_filename.MemorySize() + m_directory.MemorySize();
+size_t FileSpec::MemorySize() const {
+  return m_filename.MemorySize() + m_directory.MemorySize();
 }
 
-
-size_t
-FileSpec::ReadFileContents (off_t file_offset, void *dst, size_t dst_len, Error *error_ptr) const
-{
-    Error error;
-    size_t bytes_read = 0;
-    char resolved_path[PATH_MAX];
-    if (GetPath(resolved_path, sizeof(resolved_path)))
-    {
-        File file;
-        error = file.Open(resolved_path, File::eOpenOptionRead);
-        if (error.Success())
-        {
-            off_t file_offset_after_seek = file_offset;
-            bytes_read = dst_len;
-            error = file.Read(dst, bytes_read, file_offset_after_seek);
-        }
-    }
-    else
-    {
-        error.SetErrorString("invalid file specification");
-    }
-    if (error_ptr)
-        *error_ptr = error;
-    return bytes_read;
+size_t FileSpec::ReadFileContents(off_t file_offset, void *dst, size_t dst_len,
+                                  Error *error_ptr) const {
+  Error error;
+  size_t bytes_read = 0;
+  char resolved_path[PATH_MAX];
+  if (GetPath(resolved_path, sizeof(resolved_path))) {
+    File file;
+    error = file.Open(resolved_path, File::eOpenOptionRead);
+    if (error.Success()) {
+      off_t file_offset_after_seek = file_offset;
+      bytes_read = dst_len;
+      error = file.Read(dst, bytes_read, file_offset_after_seek);
+    }
+  } else {
+    error.SetErrorString("invalid file specification");
+  }
+  if (error_ptr)
+    *error_ptr = error;
+  return bytes_read;
 }
 
 //------------------------------------------------------------------
@@ -1126,489 +966,450 @@ FileSpec::ReadFileContents (off_t file_o
 // truncated. The final number of bytes that get mapped can be
 // verified using the DataBuffer::GetByteSize() function.
 //------------------------------------------------------------------
-DataBufferSP
-FileSpec::ReadFileContents (off_t file_offset, size_t file_size, Error *error_ptr) const
-{
-    Error error;
-    DataBufferSP data_sp;
-    char resolved_path[PATH_MAX];
-    if (GetPath(resolved_path, sizeof(resolved_path)))
-    {
-        File file;
-        error = file.Open(resolved_path, File::eOpenOptionRead);
-        if (error.Success())
-        {
-            const bool null_terminate = false;
-            error = file.Read (file_size, file_offset, null_terminate, data_sp);
-        }
+DataBufferSP FileSpec::ReadFileContents(off_t file_offset, size_t file_size,
+                                        Error *error_ptr) const {
+  Error error;
+  DataBufferSP data_sp;
+  char resolved_path[PATH_MAX];
+  if (GetPath(resolved_path, sizeof(resolved_path))) {
+    File file;
+    error = file.Open(resolved_path, File::eOpenOptionRead);
+    if (error.Success()) {
+      const bool null_terminate = false;
+      error = file.Read(file_size, file_offset, null_terminate, data_sp);
+    }
+  } else {
+    error.SetErrorString("invalid file specification");
+  }
+  if (error_ptr)
+    *error_ptr = error;
+  return data_sp;
+}
+
+DataBufferSP FileSpec::ReadFileContentsAsCString(Error *error_ptr) {
+  Error error;
+  DataBufferSP data_sp;
+  char resolved_path[PATH_MAX];
+  if (GetPath(resolved_path, sizeof(resolved_path))) {
+    File file;
+    error = file.Open(resolved_path, File::eOpenOptionRead);
+    if (error.Success()) {
+      off_t offset = 0;
+      size_t length = SIZE_MAX;
+      const bool null_terminate = true;
+      error = file.Read(length, offset, null_terminate, data_sp);
+    }
+  } else {
+    error.SetErrorString("invalid file specification");
+  }
+  if (error_ptr)
+    *error_ptr = error;
+  return data_sp;
+}
+
+size_t FileSpec::ReadFileLines(STLStringArray &lines) {
+  lines.clear();
+  char path[PATH_MAX];
+  if (GetPath(path, sizeof(path))) {
+    std::ifstream file_stream(path);
+
+    if (file_stream) {
+      std::string line;
+      while (getline(file_stream, line))
+        lines.push_back(line);
     }
-    else
-    {
-        error.SetErrorString("invalid file specification");
-    }
-    if (error_ptr)
-        *error_ptr = error;
-    return data_sp;
-}
-
-DataBufferSP
-FileSpec::ReadFileContentsAsCString(Error *error_ptr)
-{
-    Error error;
-    DataBufferSP data_sp;
-    char resolved_path[PATH_MAX];
-    if (GetPath(resolved_path, sizeof(resolved_path)))
-    {
-        File file;
-        error = file.Open(resolved_path, File::eOpenOptionRead);
-        if (error.Success())
-        {
-            off_t offset = 0;
-            size_t length = SIZE_MAX;
-            const bool null_terminate = true;
-            error = file.Read (length, offset, null_terminate, data_sp);
-        }
-    }
-    else
-    {
-        error.SetErrorString("invalid file specification");
-    }
-    if (error_ptr)
-        *error_ptr = error;
-    return data_sp;
-}
-
-size_t
-FileSpec::ReadFileLines (STLStringArray &lines)
-{
-    lines.clear();
-    char path[PATH_MAX];
-    if (GetPath(path, sizeof(path)))
-    {
-        std::ifstream file_stream (path);
-
-        if (file_stream)
-        {
-            std::string line;
-            while (getline (file_stream, line))
-                lines.push_back (line);
-        }
-    }
-    return lines.size();
+  }
+  return lines.size();
 }
 
 FileSpec::EnumerateDirectoryResult
-FileSpec::ForEachItemInDirectory (const char *dir_path, DirectoryCallback const &callback)
-{
-    if (dir_path && dir_path[0])
-    {
+FileSpec::ForEachItemInDirectory(const char *dir_path,
+                                 DirectoryCallback const &callback) {
+  if (dir_path && dir_path[0]) {
 #ifdef _WIN32
-        std::string szDir(dir_path);
-        szDir += "\\*";
+    std::string szDir(dir_path);
+    szDir += "\\*";
 
-        std::wstring wszDir;
-        if (!llvm::ConvertUTF8toWide(szDir, wszDir))
-        {
-            return eEnumerateDirectoryResultNext;
+    std::wstring wszDir;
+    if (!llvm::ConvertUTF8toWide(szDir, wszDir)) {
+      return eEnumerateDirectoryResultNext;
+    }
+
+    WIN32_FIND_DATAW ffd;
+    HANDLE hFind = FindFirstFileW(wszDir.c_str(), &ffd);
+
+    if (hFind == INVALID_HANDLE_VALUE) {
+      return eEnumerateDirectoryResultNext;
+    }
+
+    do {
+      FileSpec::FileType file_type = eFileTypeUnknown;
+      if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
+        size_t len = wcslen(ffd.cFileName);
+
+        if (len == 1 && ffd.cFileName[0] == L'.')
+          continue;
+
+        if (len == 2 && ffd.cFileName[0] == L'.' && ffd.cFileName[1] == L'.')
+          continue;
+
+        file_type = eFileTypeDirectory;
+      } else if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DEVICE) {
+        file_type = eFileTypeOther;
+      } else {
+        file_type = eFileTypeRegular;
+      }
+
+      std::string fileName;
+      if (!llvm::convertWideToUTF8(ffd.cFileName, fileName)) {
+        continue;
+      }
+
+      std::vector<char> child_path(PATH_MAX);
+      const int child_path_len =
+          ::snprintf(child_path.data(), child_path.size(), "%s\\%s", dir_path,
+                     fileName.c_str());
+      if (child_path_len < (int)(child_path.size() - 1)) {
+        // Don't resolve the file type or path
+        FileSpec child_path_spec(child_path.data(), false);
+
+        EnumerateDirectoryResult result = callback(file_type, child_path_spec);
+
+        switch (result) {
+        case eEnumerateDirectoryResultNext:
+          // Enumerate next entry in the current directory. We just
+          // exit this switch and will continue enumerating the
+          // current directory as we currently are...
+          break;
+
+        case eEnumerateDirectoryResultEnter: // Recurse into the current entry
+                                             // if it is a directory or symlink,
+                                             // or next if not
+          if (FileSpec::ForEachItemInDirectory(child_path.data(), callback) ==
+              eEnumerateDirectoryResultQuit) {
+            // The subdirectory returned Quit, which means to
+            // stop all directory enumerations at all levels.
+            return eEnumerateDirectoryResultQuit;
+          }
+          break;
+
+        case eEnumerateDirectoryResultExit: // Exit from the current directory
+                                            // at the current level.
+          // Exit from this directory level and tell parent to
+          // keep enumerating.
+          return eEnumerateDirectoryResultNext;
+
+        case eEnumerateDirectoryResultQuit: // Stop directory enumerations at
+                                            // any level
+          return eEnumerateDirectoryResultQuit;
         }
+      }
+    } while (FindNextFileW(hFind, &ffd) != 0);
 
-        WIN32_FIND_DATAW ffd;
-        HANDLE hFind = FindFirstFileW(wszDir.c_str(), &ffd);
+    FindClose(hFind);
+#else
+    lldb_utility::CleanUp<DIR *, int> dir_path_dir(opendir(dir_path), NULL,
+                                                   closedir);
+    if (dir_path_dir.is_valid()) {
+      char dir_path_last_char = dir_path[strlen(dir_path) - 1];
+
+      long path_max = fpathconf(dirfd(dir_path_dir.get()), _PC_NAME_MAX);
+#if defined(__APPLE_) && defined(__DARWIN_MAXPATHLEN)
+      if (path_max < __DARWIN_MAXPATHLEN)
+        path_max = __DARWIN_MAXPATHLEN;
+#endif
+      struct dirent *buf, *dp;
+      buf = (struct dirent *)malloc(offsetof(struct dirent, d_name) + path_max +
+                                    1);
 
-        if (hFind == INVALID_HANDLE_VALUE)
-        {
-            return eEnumerateDirectoryResultNext;
-        }
+      while (buf && readdir_r(dir_path_dir.get(), buf, &dp) == 0 && dp) {
+        // Only search directories
+        if (dp->d_type == DT_DIR || dp->d_type == DT_UNKNOWN) {
+          size_t len = strlen(dp->d_name);
 
-        do
-        {
-            FileSpec::FileType file_type = eFileTypeUnknown;
-            if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
-            {
-                size_t len = wcslen(ffd.cFileName);
+          if (len == 1 && dp->d_name[0] == '.')
+            continue;
 
-                if (len == 1 && ffd.cFileName[0] == L'.')
-                    continue;
+          if (len == 2 && dp->d_name[0] == '.' && dp->d_name[1] == '.')
+            continue;
+        }
 
-                if (len == 2 && ffd.cFileName[0] == L'.' && ffd.cFileName[1] == L'.')
-                    continue;
+        FileSpec::FileType file_type = eFileTypeUnknown;
 
-                file_type = eFileTypeDirectory;
-            }
-            else if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DEVICE)
-            {
-                file_type = eFileTypeOther;
-            }
-            else
-            {
-                file_type = eFileTypeRegular;
-            }
+        switch (dp->d_type) {
+        default:
+        case DT_UNKNOWN:
+          file_type = eFileTypeUnknown;
+          break;
+        case DT_FIFO:
+          file_type = eFileTypePipe;
+          break;
+        case DT_CHR:
+          file_type = eFileTypeOther;
+          break;
+        case DT_DIR:
+          file_type = eFileTypeDirectory;
+          break;
+        case DT_BLK:
+          file_type = eFileTypeOther;
+          break;
+        case DT_REG:
+          file_type = eFileTypeRegular;
+          break;
+        case DT_LNK:
+          file_type = eFileTypeSymbolicLink;
+          break;
+        case DT_SOCK:
+          file_type = eFileTypeSocket;
+          break;
+#if !defined(__OpenBSD__)
+        case DT_WHT:
+          file_type = eFileTypeOther;
+          break;
+#endif
+        }
 
-            std::string fileName;
-            if (!llvm::convertWideToUTF8(ffd.cFileName, fileName))
-            {
-                continue;
-            }
+        char child_path[PATH_MAX];
 
-            std::vector<char> child_path(PATH_MAX);
-            const int child_path_len =
-                ::snprintf(child_path.data(), child_path.size(), "%s\\%s", dir_path, fileName.c_str());
-            if (child_path_len < (int)(child_path.size() - 1))
-            {
-                // Don't resolve the file type or path
-                FileSpec child_path_spec(child_path.data(), false);
-
-                EnumerateDirectoryResult result = callback (file_type, child_path_spec);
-
-                switch (result)
-                {
-                    case eEnumerateDirectoryResultNext:
-                        // Enumerate next entry in the current directory. We just
-                        // exit this switch and will continue enumerating the
-                        // current directory as we currently are...
-                        break;
-
-                    case eEnumerateDirectoryResultEnter: // Recurse into the current entry if it is a directory or symlink, or next if not
-                        if (FileSpec::ForEachItemInDirectory(child_path.data(), callback) ==
-                            eEnumerateDirectoryResultQuit)
-                        {
-                            // The subdirectory returned Quit, which means to
-                            // stop all directory enumerations at all levels.
-                            return eEnumerateDirectoryResultQuit;
-                        }
-                        break;
-
-                    case eEnumerateDirectoryResultExit:  // Exit from the current directory at the current level.
-                        // Exit from this directory level and tell parent to
-                        // keep enumerating.
-                        return eEnumerateDirectoryResultNext;
-
-                    case eEnumerateDirectoryResultQuit:  // Stop directory enumerations at any level
-                        return eEnumerateDirectoryResultQuit;
-                }
-            }
-        } while (FindNextFileW(hFind, &ffd) != 0);
+        // Don't make paths with "/foo//bar", that just confuses everybody.
+        int child_path_len;
+        if (dir_path_last_char == '/')
+          child_path_len = ::snprintf(child_path, sizeof(child_path), "%s%s",
+                                      dir_path, dp->d_name);
+        else
+          child_path_len = ::snprintf(child_path, sizeof(child_path), "%s/%s",
+                                      dir_path, dp->d_name);
 
-        FindClose(hFind);
-#else
-        lldb_utility::CleanUp <DIR *, int> dir_path_dir(opendir(dir_path), NULL, closedir);
-        if (dir_path_dir.is_valid())
-        {
-            char dir_path_last_char = dir_path[strlen(dir_path) - 1];
-
-            long path_max = fpathconf (dirfd (dir_path_dir.get()), _PC_NAME_MAX);
-#if defined (__APPLE_) && defined (__DARWIN_MAXPATHLEN)
-            if (path_max < __DARWIN_MAXPATHLEN)
-                path_max = __DARWIN_MAXPATHLEN;
-#endif
-            struct dirent *buf, *dp;
-            buf = (struct dirent *) malloc (offsetof (struct dirent, d_name) + path_max + 1);
+        if (child_path_len < (int)(sizeof(child_path) - 1)) {
+          // Don't resolve the file type or path
+          FileSpec child_path_spec(child_path, false);
+
+          EnumerateDirectoryResult result =
+              callback(file_type, child_path_spec);
+
+          switch (result) {
+          case eEnumerateDirectoryResultNext:
+            // Enumerate next entry in the current directory. We just
+            // exit this switch and will continue enumerating the
+            // current directory as we currently are...
+            break;
 
-            while (buf && readdir_r(dir_path_dir.get(), buf, &dp) == 0 && dp)
-            {
-                // Only search directories
-                if (dp->d_type == DT_DIR || dp->d_type == DT_UNKNOWN)
-                {
-                    size_t len = strlen(dp->d_name);
-
-                    if (len == 1 && dp->d_name[0] == '.')
-                        continue;
-
-                    if (len == 2 && dp->d_name[0] == '.' && dp->d_name[1] == '.')
-                        continue;
-                }
-
-                FileSpec::FileType file_type = eFileTypeUnknown;
-
-                switch (dp->d_type)
-                {
-                    default:
-                    case DT_UNKNOWN:    file_type = eFileTypeUnknown;       break;
-                    case DT_FIFO:       file_type = eFileTypePipe;          break;
-                    case DT_CHR:        file_type = eFileTypeOther;         break;
-                    case DT_DIR:        file_type = eFileTypeDirectory;     break;
-                    case DT_BLK:        file_type = eFileTypeOther;         break;
-                    case DT_REG:        file_type = eFileTypeRegular;       break;
-                    case DT_LNK:        file_type = eFileTypeSymbolicLink;  break;
-                    case DT_SOCK:       file_type = eFileTypeSocket;        break;
-#if !defined(__OpenBSD__)
-                    case DT_WHT:        file_type = eFileTypeOther;         break;
-#endif
-                }
+          case eEnumerateDirectoryResultEnter: // Recurse into the current entry
+                                               // if it is a directory or
+                                               // symlink, or next if not
+            if (FileSpec::ForEachItemInDirectory(child_path, callback) ==
+                eEnumerateDirectoryResultQuit) {
+              // The subdirectory returned Quit, which means to
+              // stop all directory enumerations at all levels.
+              if (buf)
+                free(buf);
+              return eEnumerateDirectoryResultQuit;
+            }
+            break;
 
-                char child_path[PATH_MAX];
+          case eEnumerateDirectoryResultExit: // Exit from the current directory
+                                              // at the current level.
+            // Exit from this directory level and tell parent to
+            // keep enumerating.
+            if (buf)
+              free(buf);
+            return eEnumerateDirectoryResultNext;
 
-                // Don't make paths with "/foo//bar", that just confuses everybody.
-                int child_path_len;
-                if (dir_path_last_char == '/')
-                    child_path_len = ::snprintf (child_path, sizeof(child_path), "%s%s", dir_path, dp->d_name);
-                else
-                    child_path_len = ::snprintf (child_path, sizeof(child_path), "%s/%s", dir_path, dp->d_name);
-
-                if (child_path_len < (int)(sizeof(child_path) - 1))
-                {
-                    // Don't resolve the file type or path
-                    FileSpec child_path_spec (child_path, false);
-
-                    EnumerateDirectoryResult result = callback (file_type, child_path_spec);
-
-                    switch (result)
-                    {
-                        case eEnumerateDirectoryResultNext:
-                            // Enumerate next entry in the current directory. We just
-                            // exit this switch and will continue enumerating the
-                            // current directory as we currently are...
-                            break;
-
-                        case eEnumerateDirectoryResultEnter: // Recurse into the current entry if it is a directory or symlink, or next if not
-                            if (FileSpec::ForEachItemInDirectory (child_path, callback) == eEnumerateDirectoryResultQuit)
-                            {
-                                // The subdirectory returned Quit, which means to
-                                // stop all directory enumerations at all levels.
-                                if (buf)
-                                    free (buf);
-                                return eEnumerateDirectoryResultQuit;
-                            }
-                            break;
-
-                        case eEnumerateDirectoryResultExit:  // Exit from the current directory at the current level.
-                            // Exit from this directory level and tell parent to
-                            // keep enumerating.
-                            if (buf)
-                                free (buf);
-                            return eEnumerateDirectoryResultNext;
-                            
-                        case eEnumerateDirectoryResultQuit:  // Stop directory enumerations at any level
-                            if (buf)
-                                free (buf);
-                            return eEnumerateDirectoryResultQuit;
-                    }
-                }
-            }
+          case eEnumerateDirectoryResultQuit: // Stop directory enumerations at
+                                              // any level
             if (buf)
-            {
-                free (buf);
-            }
-        }
-#endif
+              free(buf);
+            return eEnumerateDirectoryResultQuit;
+          }
+        }
+      }
+      if (buf) {
+        free(buf);
+      }
     }
-    // By default when exiting a directory, we tell the parent enumeration
-    // to continue enumerating.
-    return eEnumerateDirectoryResultNext;    
+#endif
+  }
+  // By default when exiting a directory, we tell the parent enumeration
+  // to continue enumerating.
+  return eEnumerateDirectoryResultNext;
 }
 
 FileSpec::EnumerateDirectoryResult
-FileSpec::EnumerateDirectory
-(
-    const char *dir_path, 
-    bool find_directories,
-    bool find_files,
-    bool find_other,
-    EnumerateDirectoryCallbackType callback,
-    void *callback_baton
-)
-{
-    return ForEachItemInDirectory(dir_path,
-            [&find_directories, &find_files, &find_other, &callback, &callback_baton]
-            (FileType file_type, const FileSpec &file_spec) {
-                switch (file_type)
-                {
-                    case FileType::eFileTypeDirectory:
-                        if (find_directories)
-                            return callback(callback_baton, file_type, file_spec);
-                        break;
-                    case FileType::eFileTypeRegular:
-                        if (find_files)
-                            return callback(callback_baton, file_type, file_spec);
-                        break;
-                    default:
-                        if (find_other)
-                            return callback(callback_baton, file_type, file_spec);
-                        break;
-                }
-                return eEnumerateDirectoryResultNext;
-            });
-}
-
-FileSpec
-FileSpec::CopyByAppendingPathComponent (const char *new_path)  const
-{
-    FileSpec ret = *this;
-    ret.AppendPathComponent(new_path);
-    return ret;
-}
-
-FileSpec
-FileSpec::CopyByRemovingLastPathComponent ()  const
-{
-    const bool resolve = false;
-    if (m_filename.IsEmpty() && m_directory.IsEmpty())
-        return FileSpec("",resolve);
-    if (m_directory.IsEmpty())
-        return FileSpec("",resolve);
-    if (m_filename.IsEmpty())
-    {
-        const char* dir_cstr = m_directory.GetCString();
-        const char* last_slash_ptr = ::strrchr(dir_cstr, '/');
-        
-        // check for obvious cases before doing the full thing
-        if (!last_slash_ptr)
-            return FileSpec("",resolve);
-        if (last_slash_ptr == dir_cstr)
-            return FileSpec("/",resolve);
-        
-        size_t last_slash_pos = last_slash_ptr - dir_cstr+1;
-        ConstString new_path(dir_cstr,last_slash_pos);
-        return FileSpec(new_path.GetCString(),resolve);
-    }
-    else
-        return FileSpec(m_directory.GetCString(),resolve);
+FileSpec::EnumerateDirectory(const char *dir_path, bool find_directories,
+                             bool find_files, bool find_other,
+                             EnumerateDirectoryCallbackType callback,
+                             void *callback_baton) {
+  return ForEachItemInDirectory(
+      dir_path,
+      [&find_directories, &find_files, &find_other, &callback,
+       &callback_baton](FileType file_type, const FileSpec &file_spec) {
+        switch (file_type) {
+        case FileType::eFileTypeDirectory:
+          if (find_directories)
+            return callback(callback_baton, file_type, file_spec);
+          break;
+        case FileType::eFileTypeRegular:
+          if (find_files)
+            return callback(callback_baton, file_type, file_spec);
+          break;
+        default:
+          if (find_other)
+            return callback(callback_baton, file_type, file_spec);
+          break;
+        }
+        return eEnumerateDirectoryResultNext;
+      });
+}
+
+FileSpec FileSpec::CopyByAppendingPathComponent(const char *new_path) const {
+  FileSpec ret = *this;
+  ret.AppendPathComponent(new_path);
+  return ret;
+}
+
+FileSpec FileSpec::CopyByRemovingLastPathComponent() const {
+  const bool resolve = false;
+  if (m_filename.IsEmpty() && m_directory.IsEmpty())
+    return FileSpec("", resolve);
+  if (m_directory.IsEmpty())
+    return FileSpec("", resolve);
+  if (m_filename.IsEmpty()) {
+    const char *dir_cstr = m_directory.GetCString();
+    const char *last_slash_ptr = ::strrchr(dir_cstr, '/');
+
+    // check for obvious cases before doing the full thing
+    if (!last_slash_ptr)
+      return FileSpec("", resolve);
+    if (last_slash_ptr == dir_cstr)
+      return FileSpec("/", resolve);
+
+    size_t last_slash_pos = last_slash_ptr - dir_cstr + 1;
+    ConstString new_path(dir_cstr, last_slash_pos);
+    return FileSpec(new_path.GetCString(), resolve);
+  } else
+    return FileSpec(m_directory.GetCString(), resolve);
 }
 
-ConstString
-FileSpec::GetLastPathComponent () const
-{
-    if (m_filename)
-        return m_filename;
-    if (m_directory)
-    {
-        const char* dir_cstr = m_directory.GetCString();
-        const char* last_slash_ptr = ::strrchr(dir_cstr, '/');
-        if (last_slash_ptr == NULL)
-            return m_directory;
-        if (last_slash_ptr == dir_cstr)
-        {
-            if (last_slash_ptr[1] == 0)
-                return ConstString(last_slash_ptr);
-            else
-                return ConstString(last_slash_ptr+1);
-        }
-        if (last_slash_ptr[1] != 0)
-            return ConstString(last_slash_ptr+1);
-        const char* penultimate_slash_ptr = last_slash_ptr;
-        while (*penultimate_slash_ptr)
-        {
-            --penultimate_slash_ptr;
-            if (penultimate_slash_ptr == dir_cstr)
-                break;
-            if (*penultimate_slash_ptr == '/')
-                break;
-        }
-        ConstString result(penultimate_slash_ptr+1,last_slash_ptr-penultimate_slash_ptr);
-        return result;
-    }
-    return ConstString();
+ConstString FileSpec::GetLastPathComponent() const {
+  if (m_filename)
+    return m_filename;
+  if (m_directory) {
+    const char *dir_cstr = m_directory.GetCString();
+    const char *last_slash_ptr = ::strrchr(dir_cstr, '/');
+    if (last_slash_ptr == NULL)
+      return m_directory;
+    if (last_slash_ptr == dir_cstr) {
+      if (last_slash_ptr[1] == 0)
+        return ConstString(last_slash_ptr);
+      else
+        return ConstString(last_slash_ptr + 1);
+    }
+    if (last_slash_ptr[1] != 0)
+      return ConstString(last_slash_ptr + 1);
+    const char *penultimate_slash_ptr = last_slash_ptr;
+    while (*penultimate_slash_ptr) {
+      --penultimate_slash_ptr;
+      if (penultimate_slash_ptr == dir_cstr)
+        break;
+      if (*penultimate_slash_ptr == '/')
+        break;
+    }
+    ConstString result(penultimate_slash_ptr + 1,
+                       last_slash_ptr - penultimate_slash_ptr);
+    return result;
+  }
+  return ConstString();
 }
 
-void
-FileSpec::PrependPathComponent(const char *new_path)
-{
-    if (!new_path) return;
-    const bool resolve = false;
-    if (m_filename.IsEmpty() && m_directory.IsEmpty())
-    {
-        SetFile(new_path, resolve);
-        return;
-    }
-    StreamString stream;
-    if (m_filename.IsEmpty())
-        stream.Printf("%s/%s", new_path, m_directory.GetCString());
-    else if (m_directory.IsEmpty())
-        stream.Printf("%s/%s", new_path, m_filename.GetCString());
-    else
-        stream.Printf("%s/%s/%s", new_path, m_directory.GetCString(), m_filename.GetCString());
-    SetFile(stream.GetData(), resolve);
-}
-
-void
-FileSpec::PrependPathComponent(const std::string &new_path)
-{
-    return PrependPathComponent(new_path.c_str());
-}
-
-void
-FileSpec::PrependPathComponent(const FileSpec &new_path)
-{
-    return PrependPathComponent(new_path.GetPath(false));
-}
-
-void
-FileSpec::AppendPathComponent(const char *new_path)
-{
-    if (!new_path) return;
-
-    StreamString stream;
-    if (!m_directory.IsEmpty())
-    {
-        stream.PutCString(m_directory.GetCString());
-        if (!IsPathSeparator(m_directory.GetStringRef().back(), m_syntax))
-            stream.PutChar(GetPrefferedPathSeparator(m_syntax));
-    }
+void FileSpec::PrependPathComponent(const char *new_path) {
+  if (!new_path)
+    return;
+  const bool resolve = false;
+  if (m_filename.IsEmpty() && m_directory.IsEmpty()) {
+    SetFile(new_path, resolve);
+    return;
+  }
+  StreamString stream;
+  if (m_filename.IsEmpty())
+    stream.Printf("%s/%s", new_path, m_directory.GetCString());
+  else if (m_directory.IsEmpty())
+    stream.Printf("%s/%s", new_path, m_filename.GetCString());
+  else
+    stream.Printf("%s/%s/%s", new_path, m_directory.GetCString(),
+                  m_filename.GetCString());
+  SetFile(stream.GetData(), resolve);
+}
 
-    if (!m_filename.IsEmpty())
-    {
-        stream.PutCString(m_filename.GetCString());
-        if (!IsPathSeparator(m_filename.GetStringRef().back(), m_syntax))
-            stream.PutChar(GetPrefferedPathSeparator(m_syntax));
-    }
+void FileSpec::PrependPathComponent(const std::string &new_path) {
+  return PrependPathComponent(new_path.c_str());
+}
 
-    while (IsPathSeparator(new_path[0], m_syntax))
-        new_path++;
+void FileSpec::PrependPathComponent(const FileSpec &new_path) {
+  return PrependPathComponent(new_path.GetPath(false));
+}
+
+void FileSpec::AppendPathComponent(const char *new_path) {
+  if (!new_path)
+    return;
+
+  StreamString stream;
+  if (!m_directory.IsEmpty()) {
+    stream.PutCString(m_directory.GetCString());
+    if (!IsPathSeparator(m_directory.GetStringRef().back(), m_syntax))
+      stream.PutChar(GetPrefferedPathSeparator(m_syntax));
+  }
 
-    stream.PutCString(new_path);
+  if (!m_filename.IsEmpty()) {
+    stream.PutCString(m_filename.GetCString());
+    if (!IsPathSeparator(m_filename.GetStringRef().back(), m_syntax))
+      stream.PutChar(GetPrefferedPathSeparator(m_syntax));
+  }
 
-    const bool resolve = false;
-    SetFile(stream.GetData(), resolve, m_syntax);
+  while (IsPathSeparator(new_path[0], m_syntax))
+    new_path++;
+
+  stream.PutCString(new_path);
+
+  const bool resolve = false;
+  SetFile(stream.GetData(), resolve, m_syntax);
 }
 
-void
-FileSpec::AppendPathComponent(const std::string &new_path)
-{
-    return AppendPathComponent(new_path.c_str());
+void FileSpec::AppendPathComponent(const std::string &new_path) {
+  return AppendPathComponent(new_path.c_str());
 }
 
-void
-FileSpec::AppendPathComponent(const FileSpec &new_path)
-{
-    return AppendPathComponent(new_path.GetPath(false));
+void FileSpec::AppendPathComponent(const FileSpec &new_path) {
+  return AppendPathComponent(new_path.GetPath(false));
 }
 
-void
-FileSpec::RemoveLastPathComponent ()
-{
-    const bool resolve = false;
-    if (m_filename.IsEmpty() && m_directory.IsEmpty())
-    {
-        SetFile("",resolve);
-        return;
-    }
-    if (m_directory.IsEmpty())
-    {
-        SetFile("",resolve);
-        return;
-    }
-    if (m_filename.IsEmpty())
-    {
-        const char* dir_cstr = m_directory.GetCString();
-        const char* last_slash_ptr = ::strrchr(dir_cstr, '/');
-        
-        // check for obvious cases before doing the full thing
-        if (!last_slash_ptr)
-        {
-            SetFile("",resolve);
-            return;
-        }
-        if (last_slash_ptr == dir_cstr)
-        {
-            SetFile("/",resolve);
-            return;
-        }        
-        size_t last_slash_pos = last_slash_ptr - dir_cstr+1;
-        ConstString new_path(dir_cstr,last_slash_pos);
-        SetFile(new_path.GetCString(),resolve);
-    }
-    else
-        SetFile(m_directory.GetCString(),resolve);
+void FileSpec::RemoveLastPathComponent() {
+  const bool resolve = false;
+  if (m_filename.IsEmpty() && m_directory.IsEmpty()) {
+    SetFile("", resolve);
+    return;
+  }
+  if (m_directory.IsEmpty()) {
+    SetFile("", resolve);
+    return;
+  }
+  if (m_filename.IsEmpty()) {
+    const char *dir_cstr = m_directory.GetCString();
+    const char *last_slash_ptr = ::strrchr(dir_cstr, '/');
+
+    // check for obvious cases before doing the full thing
+    if (!last_slash_ptr) {
+      SetFile("", resolve);
+      return;
+    }
+    if (last_slash_ptr == dir_cstr) {
+      SetFile("/", resolve);
+      return;
+    }
+    size_t last_slash_pos = last_slash_ptr - dir_cstr + 1;
+    ConstString new_path(dir_cstr, last_slash_pos);
+    SetFile(new_path.GetCString(), resolve);
+  } else
+    SetFile(m_directory.GetCString(), resolve);
 }
 //------------------------------------------------------------------
 /// Returns true if the filespec represents an implementation source
@@ -1619,57 +1420,45 @@ FileSpec::RemoveLastPathComponent ()
 ///     \b true if the filespec represents an implementation source
 ///     file, \b false otherwise.
 //------------------------------------------------------------------
-bool
-FileSpec::IsSourceImplementationFile () const
-{
-    ConstString extension (GetFileNameExtension());
-    if (extension)
-    {
-        static RegularExpression g_source_file_regex ("^([cC]|[mM]|[mM][mM]|[cC][pP][pP]|[cC]\\+\\+|[cC][xX][xX]|[cC][cC]|[cC][pP]|[sS]|[aA][sS][mM]|[fF]|[fF]77|[fF]90|[fF]95|[fF]03|[fF][oO][rR]|[fF][tT][nN]|[fF][pP][pP]|[aA][dD][aA]|[aA][dD][bB]|[aA][dD][sS])$");
-        return g_source_file_regex.Execute (extension.GetCString());
-    }
-    return false;
-}
-
-bool
-FileSpec::IsRelative() const
-{
-    const char *dir = m_directory.GetCString();
-    llvm::StringRef directory(dir ? dir : "");
-
-    if (directory.size() > 0)
-    {
-        if (PathSyntaxIsPosix(m_syntax))
-        {
-            // If the path doesn't start with '/' or '~', return true
-            switch (directory[0])
-            {
-                case '/':
-                case '~':
-                    return false;
-                default:
-                    return true;
-            }
-        }
-        else
-        {
-            if (directory.size() >= 2 && directory[1] == ':')
-                return false;
-            if (directory[0] == '/')
-                return false;
-            return true;
-        }
-    }
-    else if (m_filename)
-    {
-        // No directory, just a basename, return true
+bool FileSpec::IsSourceImplementationFile() const {
+  ConstString extension(GetFileNameExtension());
+  if (extension) {
+    static RegularExpression g_source_file_regex(
+        "^([cC]|[mM]|[mM][mM]|[cC][pP][pP]|[cC]\\+\\+|[cC][xX][xX]|[cC][cC]|["
+        "cC][pP]|[sS]|[aA][sS][mM]|[fF]|[fF]77|[fF]90|[fF]95|[fF]03|[fF][oO]["
+        "rR]|[fF][tT][nN]|[fF][pP][pP]|[aA][dD][aA]|[aA][dD][bB]|[aA][dD][sS])"
+        "$");
+    return g_source_file_regex.Execute(extension.GetCString());
+  }
+  return false;
+}
+
+bool FileSpec::IsRelative() const {
+  const char *dir = m_directory.GetCString();
+  llvm::StringRef directory(dir ? dir : "");
+
+  if (directory.size() > 0) {
+    if (PathSyntaxIsPosix(m_syntax)) {
+      // If the path doesn't start with '/' or '~', return true
+      switch (directory[0]) {
+      case '/':
+      case '~':
+        return false;
+      default:
         return true;
+      }
+    } else {
+      if (directory.size() >= 2 && directory[1] == ':')
+        return false;
+      if (directory[0] == '/')
+        return false;
+      return true;
     }
-    return false;
+  } else if (m_filename) {
+    // No directory, just a basename, return true
+    return true;
+  }
+  return false;
 }
 
-bool
-FileSpec::IsAbsolute() const
-{
-    return !FileSpec::IsRelative();
-}
+bool FileSpec::IsAbsolute() const { return !FileSpec::IsRelative(); }

Modified: lldb/trunk/source/Host/common/FileSystem.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/FileSystem.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/FileSystem.cpp (original)
+++ lldb/trunk/source/Host/common/FileSystem.cpp Tue Sep  6 15:57:50 2016
@@ -20,84 +20,73 @@ using namespace lldb_private;
 
 namespace {
 
-bool
-CalcMD5(const FileSpec &file_spec, uint64_t offset, uint64_t length, llvm::MD5::MD5Result &md5_result)
-{
-    llvm::MD5 md5_hash;
-    std::ifstream file(file_spec.GetPath(), std::ios::binary);
-    if (!file.is_open())
-        return false;
-
-    if (offset > 0)
-        file.seekg(offset, file.beg);
-
-    std::vector<char> read_buf(4096);
-    uint64_t total_read_bytes = 0;
-    while (!file.eof())
-    {
-        const uint64_t to_read = (length > 0) ?
-            std::min(static_cast<uint64_t>(read_buf.size()), length - total_read_bytes) :
-            read_buf.size();
-        if (to_read == 0)
-            break;
-
-        file.read(&read_buf[0], to_read);
-        const auto read_bytes = file.gcount();
-        if (read_bytes == 0)
-            break;
-
-        md5_hash.update(llvm::StringRef(&read_buf[0], read_bytes));
-        total_read_bytes += read_bytes;
-    }
+bool CalcMD5(const FileSpec &file_spec, uint64_t offset, uint64_t length,
+             llvm::MD5::MD5Result &md5_result) {
+  llvm::MD5 md5_hash;
+  std::ifstream file(file_spec.GetPath(), std::ios::binary);
+  if (!file.is_open())
+    return false;
+
+  if (offset > 0)
+    file.seekg(offset, file.beg);
+
+  std::vector<char> read_buf(4096);
+  uint64_t total_read_bytes = 0;
+  while (!file.eof()) {
+    const uint64_t to_read =
+        (length > 0) ? std::min(static_cast<uint64_t>(read_buf.size()),
+                                length - total_read_bytes)
+                     : read_buf.size();
+    if (to_read == 0)
+      break;
+
+    file.read(&read_buf[0], to_read);
+    const auto read_bytes = file.gcount();
+    if (read_bytes == 0)
+      break;
+
+    md5_hash.update(llvm::StringRef(&read_buf[0], read_bytes));
+    total_read_bytes += read_bytes;
+  }
 
-    md5_hash.final(md5_result);
-    return true;
+  md5_hash.final(md5_result);
+  return true;
 }
 
-}  // namespace
+} // namespace
 
-bool
-FileSystem::CalculateMD5(const FileSpec &file_spec, uint64_t &low, uint64_t &high)
-{
-    return CalculateMD5(file_spec, 0, 0, low, high);
+bool FileSystem::CalculateMD5(const FileSpec &file_spec, uint64_t &low,
+                              uint64_t &high) {
+  return CalculateMD5(file_spec, 0, 0, low, high);
 }
 
-bool
-FileSystem::CalculateMD5(const FileSpec &file_spec,
-                         uint64_t offset,
-                         uint64_t length,
-                         uint64_t &low,
-                         uint64_t &high)
-{
-    llvm::MD5::MD5Result md5_result;
-    if (!CalcMD5(file_spec, offset, length, md5_result))
-        return false;
-
-    const auto uint64_res = reinterpret_cast<const uint64_t*>(md5_result);
-    high = uint64_res[0];
-    low = uint64_res[1];
+bool FileSystem::CalculateMD5(const FileSpec &file_spec, uint64_t offset,
+                              uint64_t length, uint64_t &low, uint64_t &high) {
+  llvm::MD5::MD5Result md5_result;
+  if (!CalcMD5(file_spec, offset, length, md5_result))
+    return false;
+
+  const auto uint64_res = reinterpret_cast<const uint64_t *>(md5_result);
+  high = uint64_res[0];
+  low = uint64_res[1];
 
-    return true;
+  return true;
 }
 
-bool
-FileSystem::CalculateMD5AsString(const FileSpec &file_spec, std::string& digest_str)
-{
-    return CalculateMD5AsString(file_spec, 0, 0, digest_str);
+bool FileSystem::CalculateMD5AsString(const FileSpec &file_spec,
+                                      std::string &digest_str) {
+  return CalculateMD5AsString(file_spec, 0, 0, digest_str);
 }
 
-bool
-FileSystem::CalculateMD5AsString(const FileSpec &file_spec,
-                                 uint64_t offset,
-                                 uint64_t length,
-                                 std::string& digest_str)
-{
-    llvm::MD5::MD5Result md5_result;
-    if (!CalcMD5(file_spec, offset, length, md5_result))
-        return false;
-
-    llvm::SmallString<32> result_str;
-    llvm::MD5::stringifyResult(md5_result, result_str);
-    digest_str = result_str.c_str();
-    return true;
+bool FileSystem::CalculateMD5AsString(const FileSpec &file_spec,
+                                      uint64_t offset, uint64_t length,
+                                      std::string &digest_str) {
+  llvm::MD5::MD5Result md5_result;
+  if (!CalcMD5(file_spec, offset, length, md5_result))
+    return false;
+
+  llvm::SmallString<32> result_str;
+  llvm::MD5::stringifyResult(md5_result, result_str);
+  digest_str = result_str.c_str();
+  return true;
 }

Modified: lldb/trunk/source/Host/common/GetOptInc.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/GetOptInc.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/GetOptInc.cpp (original)
+++ lldb/trunk/source/Host/common/GetOptInc.cpp Tue Sep  6 15:57:50 2016
@@ -1,6 +1,7 @@
 #include "lldb/Host/common/GetOptInc.h"
 
-#if defined(REPLACE_GETOPT) || defined(REPLACE_GETOPT_LONG) || defined(REPLACE_GETOPT_LONG_ONLY)
+#if defined(REPLACE_GETOPT) || defined(REPLACE_GETOPT_LONG) ||                 \
+    defined(REPLACE_GETOPT_LONG_ONLY)
 
 // getopt.cpp
 #include <errno.h>
@@ -8,32 +9,32 @@
 #include <string.h>
 
 #if defined(REPLACE_GETOPT)
-int opterr = 1;     /* if error message should be printed */
-int optind = 1;     /* index into parent argv vector */
-int optopt = '?';   /* character checked for validity */
-int optreset;       /* reset getopt */
-char *optarg;       /* argument associated with option */
+int opterr = 1;   /* if error message should be printed */
+int optind = 1;   /* index into parent argv vector */
+int optopt = '?'; /* character checked for validity */
+int optreset;     /* reset getopt */
+char *optarg;     /* argument associated with option */
 #endif
 
 #define PRINT_ERROR ((opterr) && (*options != ':'))
 
-#define FLAG_PERMUTE    0x01    /* permute non-options to the end of argv */
-#define FLAG_ALLARGS    0x02    /* treat non-options as args to option "-1" */
-#define FLAG_LONGONLY   0x04    /* operate as getopt_long_only */
+#define FLAG_PERMUTE 0x01  /* permute non-options to the end of argv */
+#define FLAG_ALLARGS 0x02  /* treat non-options as args to option "-1" */
+#define FLAG_LONGONLY 0x04 /* operate as getopt_long_only */
 
 /* return values */
-#define BADCH       (int)'?'
-#define BADARG      ((*options == ':') ? (int)':' : (int)'?')
-#define INORDER     (int)1
-
-#define EMSG        ""
-
-static int getopt_internal(int, char * const *, const char *,
-    const struct option *, int *, int);
-static int parse_long_options(char * const *, const char *,
-    const struct option *, int *, int);
+#define BADCH (int)'?'
+#define BADARG ((*options == ':') ? (int)':' : (int)'?')
+#define INORDER (int)1
+
+#define EMSG ""
+
+static int getopt_internal(int, char *const *, const char *,
+                           const struct option *, int *, int);
+static int parse_long_options(char *const *, const char *,
+                              const struct option *, int *, int);
 static int gcd(int, int);
-static void permute_args(int, int, int, char * const *);
+static void permute_args(int, int, int, char *const *);
 
 static const char *place = EMSG; /* option letter processing */
 
@@ -44,19 +45,17 @@ static int nonopt_end = -1;   /* first o
 /*
 * Compute the greatest common divisor of a and b.
 */
-static int
-gcd(int a, int b)
-{
-    int c;
+static int gcd(int a, int b) {
+  int c;
 
+  c = a % b;
+  while (c != 0) {
+    a = b;
+    b = c;
     c = a % b;
-    while (c != 0) {
-        a = b;
-        b = c;
-        c = a % b;
-    }
+  }
 
-    return (b);
+  return (b);
 }
 
 static void pass() {}
@@ -67,36 +66,34 @@ static void pass() {}
 * from nonopt_end to opt_end (keeping the same order of arguments
 * in each block).
 */
-static void
-permute_args(int panonopt_start, int panonopt_end, int opt_end,
-char * const *nargv)
-{
-    int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos;
-    char *swap;
-
-    /*
-    * compute lengths of blocks and number and size of cycles
-    */
-    nnonopts = panonopt_end - panonopt_start;
-    nopts = opt_end - panonopt_end;
-    ncycle = gcd(nnonopts, nopts);
-    cyclelen = (opt_end - panonopt_start) / ncycle;
-
-    for (i = 0; i < ncycle; i++) {
-        cstart = panonopt_end + i;
-        pos = cstart;
-        for (j = 0; j < cyclelen; j++) {
-            if (pos >= panonopt_end)
-                pos -= nnonopts;
-            else
-                pos += nopts;
-            swap = nargv[pos];
-            /* LINTED const cast */
-            ((char **)nargv)[pos] = nargv[cstart];
-            /* LINTED const cast */
-            ((char **)nargv)[cstart] = swap;
-        }
+static void permute_args(int panonopt_start, int panonopt_end, int opt_end,
+                         char *const *nargv) {
+  int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos;
+  char *swap;
+
+  /*
+  * compute lengths of blocks and number and size of cycles
+  */
+  nnonopts = panonopt_end - panonopt_start;
+  nopts = opt_end - panonopt_end;
+  ncycle = gcd(nnonopts, nopts);
+  cyclelen = (opt_end - panonopt_start) / ncycle;
+
+  for (i = 0; i < ncycle; i++) {
+    cstart = panonopt_end + i;
+    pos = cstart;
+    for (j = 0; j < cyclelen; j++) {
+      if (pos >= panonopt_end)
+        pos -= nnonopts;
+      else
+        pos += nopts;
+      swap = nargv[pos];
+      /* LINTED const cast */
+      ((char **)nargv)[pos] = nargv[cstart];
+      /* LINTED const cast */
+      ((char **)nargv)[cstart] = swap;
     }
+  }
 }
 
 /*
@@ -104,318 +101,297 @@ char * const *nargv)
 *  Parse long options in argc/argv argument vector.
 * Returns -1 if short_too is set and the option does not match long_options.
 */
-static int
-parse_long_options(char * const *nargv, const char *options,
-const struct option *long_options, int *idx, int short_too)
-{
-    char *current_argv, *has_equal;
-    size_t current_argv_len;
-    int i, match;
-
-    current_argv = const_cast<char*>(place);
-    match = -1;
-
-    optind++;
-
-    if ((has_equal = strchr(current_argv, '=')) != NULL) {
-        /* argument found (--option=arg) */
-        current_argv_len = has_equal - current_argv;
-        has_equal++;
-    }
-    else
-        current_argv_len = strlen(current_argv);
-
-    for (i = 0; long_options[i].name; i++) {
-        /* find matching long option */
-        if (strncmp(current_argv, long_options[i].name,
-            current_argv_len))
-            continue;
-
-        if (strlen(long_options[i].name) == current_argv_len) {
-            /* exact match */
-            match = i;
-            break;
-        }
-        /*
-        * If this is a known short option, don't allow
-        * a partial match of a single character.
-        */
-        if (short_too && current_argv_len == 1)
-            continue;
+static int parse_long_options(char *const *nargv, const char *options,
+                              const struct option *long_options, int *idx,
+                              int short_too) {
+  char *current_argv, *has_equal;
+  size_t current_argv_len;
+  int i, match;
+
+  current_argv = const_cast<char *>(place);
+  match = -1;
+
+  optind++;
+
+  if ((has_equal = strchr(current_argv, '=')) != NULL) {
+    /* argument found (--option=arg) */
+    current_argv_len = has_equal - current_argv;
+    has_equal++;
+  } else
+    current_argv_len = strlen(current_argv);
+
+  for (i = 0; long_options[i].name; i++) {
+    /* find matching long option */
+    if (strncmp(current_argv, long_options[i].name, current_argv_len))
+      continue;
+
+    if (strlen(long_options[i].name) == current_argv_len) {
+      /* exact match */
+      match = i;
+      break;
+    }
+    /*
+    * If this is a known short option, don't allow
+    * a partial match of a single character.
+    */
+    if (short_too && current_argv_len == 1)
+      continue;
 
-        if (match == -1)    /* partial match */
-            match = i;
-        else {
-            /* ambiguous abbreviation */
-            if (PRINT_ERROR)
-                warnx(ambig, (int)current_argv_len,
-                current_argv);
-            optopt = 0;
-            return (BADCH);
-        }
-    }
-    if (match != -1) {      /* option found */
-        if (long_options[match].has_arg == no_argument
-            && has_equal) {
-            if (PRINT_ERROR)
-                warnx(noarg, (int)current_argv_len,
-                current_argv);
-            /*
-            * XXX: GNU sets optopt to val regardless of flag
-            */
-            if (long_options[match].flag == NULL)
-                optopt = long_options[match].val;
-            else
-                optopt = 0;
-            return (BADARG);
-        }
-        if (long_options[match].has_arg == required_argument ||
-            long_options[match].has_arg == optional_argument) {
-            if (has_equal)
-                optarg = has_equal;
-            else if (long_options[match].has_arg ==
-                required_argument) {
-                /*
-                * optional argument doesn't use next nargv
-                */
-                optarg = nargv[optind++];
-            }
-        }
-        if ((long_options[match].has_arg == required_argument)
-            && (optarg == NULL)) {
-            /*
-            * Missing argument; leading ':' indicates no error
-            * should be generated.
-            */
-            if (PRINT_ERROR)
-                warnx(recargstring,
-                current_argv);
-            /*
-            * XXX: GNU sets optopt to val regardless of flag
-            */
-            if (long_options[match].flag == NULL)
-                optopt = long_options[match].val;
-            else
-                optopt = 0;
-            --optind;
-            return (BADARG);
-        }
-    }
-    else {            /* unknown option */
-        if (short_too) {
-            --optind;
-            return (-1);
-        }
-        if (PRINT_ERROR)
-            warnx(illoptstring, current_argv);
+    if (match == -1) /* partial match */
+      match = i;
+    else {
+      /* ambiguous abbreviation */
+      if (PRINT_ERROR)
+        warnx(ambig, (int)current_argv_len, current_argv);
+      optopt = 0;
+      return (BADCH);
+    }
+  }
+  if (match != -1) { /* option found */
+    if (long_options[match].has_arg == no_argument && has_equal) {
+      if (PRINT_ERROR)
+        warnx(noarg, (int)current_argv_len, current_argv);
+      /*
+      * XXX: GNU sets optopt to val regardless of flag
+      */
+      if (long_options[match].flag == NULL)
+        optopt = long_options[match].val;
+      else
         optopt = 0;
-        return (BADCH);
+      return (BADARG);
     }
-    if (idx)
-        *idx = match;
-    if (long_options[match].flag) {
-        *long_options[match].flag = long_options[match].val;
-        return (0);
+    if (long_options[match].has_arg == required_argument ||
+        long_options[match].has_arg == optional_argument) {
+      if (has_equal)
+        optarg = has_equal;
+      else if (long_options[match].has_arg == required_argument) {
+        /*
+        * optional argument doesn't use next nargv
+        */
+        optarg = nargv[optind++];
+      }
     }
-    else
-        return (long_options[match].val);
+    if ((long_options[match].has_arg == required_argument) &&
+        (optarg == NULL)) {
+      /*
+      * Missing argument; leading ':' indicates no error
+      * should be generated.
+      */
+      if (PRINT_ERROR)
+        warnx(recargstring, current_argv);
+      /*
+      * XXX: GNU sets optopt to val regardless of flag
+      */
+      if (long_options[match].flag == NULL)
+        optopt = long_options[match].val;
+      else
+        optopt = 0;
+      --optind;
+      return (BADARG);
+    }
+  } else { /* unknown option */
+    if (short_too) {
+      --optind;
+      return (-1);
+    }
+    if (PRINT_ERROR)
+      warnx(illoptstring, current_argv);
+    optopt = 0;
+    return (BADCH);
+  }
+  if (idx)
+    *idx = match;
+  if (long_options[match].flag) {
+    *long_options[match].flag = long_options[match].val;
+    return (0);
+  } else
+    return (long_options[match].val);
 }
 
 /*
 * getopt_internal --
 *  Parse argc/argv argument vector.  Called by user level routines.
 */
-static int
-getopt_internal(int nargc, char * const *nargv, const char *options,
-const struct option *long_options, int *idx, int flags)
-{
-    const char *oli;                /* option letter list index */
-    int optchar, short_too;
-    static int posixly_correct = -1;
-
-    if (options == NULL)
-        return (-1);
-
-    /*
-    * XXX Some GNU programs (like cvs) set optind to 0 instead of
-    * XXX using optreset.  Work around this braindamage.
-    */
-    if (optind == 0)
-        optind = optreset = 1;
-
-    /*
-    * Disable GNU extensions if POSIXLY_CORRECT is set or options
-    * string begins with a '+'.
-    */
-    if (posixly_correct == -1 || optreset)
-        posixly_correct = (getenv("POSIXLY_CORRECT") != NULL);
-    if (*options == '-')
-        flags |= FLAG_ALLARGS;
-    else if (posixly_correct || *options == '+')
-        flags &= ~FLAG_PERMUTE;
-    if (*options == '+' || *options == '-')
-        options++;
-
-    optarg = NULL;
-    if (optreset)
-        nonopt_start = nonopt_end = -1;
+static int getopt_internal(int nargc, char *const *nargv, const char *options,
+                           const struct option *long_options, int *idx,
+                           int flags) {
+  const char *oli; /* option letter list index */
+  int optchar, short_too;
+  static int posixly_correct = -1;
+
+  if (options == NULL)
+    return (-1);
+
+  /*
+  * XXX Some GNU programs (like cvs) set optind to 0 instead of
+  * XXX using optreset.  Work around this braindamage.
+  */
+  if (optind == 0)
+    optind = optreset = 1;
+
+  /*
+  * Disable GNU extensions if POSIXLY_CORRECT is set or options
+  * string begins with a '+'.
+  */
+  if (posixly_correct == -1 || optreset)
+    posixly_correct = (getenv("POSIXLY_CORRECT") != NULL);
+  if (*options == '-')
+    flags |= FLAG_ALLARGS;
+  else if (posixly_correct || *options == '+')
+    flags &= ~FLAG_PERMUTE;
+  if (*options == '+' || *options == '-')
+    options++;
+
+  optarg = NULL;
+  if (optreset)
+    nonopt_start = nonopt_end = -1;
 start:
-    if (optreset || !*place) {      /* update scanning pointer */
-        optreset = 0;
-        if (optind >= nargc) {          /* end of argument vector */
-            place = EMSG;
-            if (nonopt_end != -1) {
-                /* do permutation, if we have to */
-                permute_args(nonopt_start, nonopt_end,
-                    optind, nargv);
-                optind -= nonopt_end - nonopt_start;
-            }
-            else if (nonopt_start != -1) {
-                /*
-                * If we skipped non-options, set optind
-                * to the first of them.
-                */
-                optind = nonopt_start;
-            }
-            nonopt_start = nonopt_end = -1;
-            return (-1);
-        }
-        if (*(place = nargv[optind]) != '-' ||
-            (place[1] == '\0' && strchr(options, '-') == NULL)) {
-            place = EMSG;       /* found non-option */
-            if (flags & FLAG_ALLARGS) {
-                /*
-                * GNU extension:
-                * return non-option as argument to option 1
-                */
-                optarg = nargv[optind++];
-                return (INORDER);
-            }
-            if (!(flags & FLAG_PERMUTE)) {
-                /*
-                * If no permutation wanted, stop parsing
-                * at first non-option.
-                */
-                return (-1);
-            }
-            /* do permutation */
-            if (nonopt_start == -1)
-                nonopt_start = optind;
-            else if (nonopt_end != -1) {
-                permute_args(nonopt_start, nonopt_end,
-                    optind, nargv);
-                nonopt_start = optind -
-                    (nonopt_end - nonopt_start);
-                nonopt_end = -1;
-            }
-            optind++;
-            /* process next argument */
-            goto start;
-        }
-        if (nonopt_start != -1 && nonopt_end == -1)
-            nonopt_end = optind;
-
+  if (optreset || !*place) { /* update scanning pointer */
+    optreset = 0;
+    if (optind >= nargc) { /* end of argument vector */
+      place = EMSG;
+      if (nonopt_end != -1) {
+        /* do permutation, if we have to */
+        permute_args(nonopt_start, nonopt_end, optind, nargv);
+        optind -= nonopt_end - nonopt_start;
+      } else if (nonopt_start != -1) {
+        /*
+        * If we skipped non-options, set optind
+        * to the first of them.
+        */
+        optind = nonopt_start;
+      }
+      nonopt_start = nonopt_end = -1;
+      return (-1);
+    }
+    if (*(place = nargv[optind]) != '-' ||
+        (place[1] == '\0' && strchr(options, '-') == NULL)) {
+      place = EMSG; /* found non-option */
+      if (flags & FLAG_ALLARGS) {
+        /*
+        * GNU extension:
+        * return non-option as argument to option 1
+        */
+        optarg = nargv[optind++];
+        return (INORDER);
+      }
+      if (!(flags & FLAG_PERMUTE)) {
         /*
-        * If we have "-" do nothing, if "--" we are done.
+        * If no permutation wanted, stop parsing
+        * at first non-option.
         */
-        if (place[1] != '\0' && *++place == '-' && place[1] == '\0') {
-            optind++;
-            place = EMSG;
-            /*
-            * We found an option (--), so if we skipped
-            * non-options, we have to permute.
-            */
-            if (nonopt_end != -1) {
-                permute_args(nonopt_start, nonopt_end,
-                    optind, nargv);
-                optind -= nonopt_end - nonopt_start;
-            }
-            nonopt_start = nonopt_end = -1;
-            return (-1);
-        }
+        return (-1);
+      }
+      /* do permutation */
+      if (nonopt_start == -1)
+        nonopt_start = optind;
+      else if (nonopt_end != -1) {
+        permute_args(nonopt_start, nonopt_end, optind, nargv);
+        nonopt_start = optind - (nonopt_end - nonopt_start);
+        nonopt_end = -1;
+      }
+      optind++;
+      /* process next argument */
+      goto start;
     }
+    if (nonopt_start != -1 && nonopt_end == -1)
+      nonopt_end = optind;
 
     /*
-    * Check long options if:
-    *  1) we were passed some
-    *  2) the arg is not just "-"
-    *  3) either the arg starts with -- we are getopt_long_only()
+    * If we have "-" do nothing, if "--" we are done.
     */
-    if (long_options != NULL && place != nargv[optind] &&
-        (*place == '-' || (flags & FLAG_LONGONLY))) {
-        short_too = 0;
-        if (*place == '-')
-            place++;        /* --foo long option */
-        else if (*place != ':' && strchr(options, *place) != NULL)
-            short_too = 1;      /* could be short option too */
-
-        optchar = parse_long_options(nargv, options, long_options,
-            idx, short_too);
-        if (optchar != -1) {
-            place = EMSG;
-            return (optchar);
-        }
-    }
-
-    if ((optchar = (int)*place++) == (int)':' ||
-        (optchar == (int)'-' && *place != '\0') ||
-        (oli = strchr(options, optchar)) == NULL) {
-        /*
-        * If the user specified "-" and  '-' isn't listed in
-        * options, return -1 (non-option) as per POSIX.
-        * Otherwise, it is an unknown option character (or ':').
-        */
-        if (optchar == (int)'-' && *place == '\0')
-            return (-1);
-        if (!*place)
-            ++optind;
+    if (place[1] != '\0' && *++place == '-' && place[1] == '\0') {
+      optind++;
+      place = EMSG;
+      /*
+      * We found an option (--), so if we skipped
+      * non-options, we have to permute.
+      */
+      if (nonopt_end != -1) {
+        permute_args(nonopt_start, nonopt_end, optind, nargv);
+        optind -= nonopt_end - nonopt_start;
+      }
+      nonopt_start = nonopt_end = -1;
+      return (-1);
+    }
+  }
+
+  /*
+  * Check long options if:
+  *  1) we were passed some
+  *  2) the arg is not just "-"
+  *  3) either the arg starts with -- we are getopt_long_only()
+  */
+  if (long_options != NULL && place != nargv[optind] &&
+      (*place == '-' || (flags & FLAG_LONGONLY))) {
+    short_too = 0;
+    if (*place == '-')
+      place++; /* --foo long option */
+    else if (*place != ':' && strchr(options, *place) != NULL)
+      short_too = 1; /* could be short option too */
+
+    optchar = parse_long_options(nargv, options, long_options, idx, short_too);
+    if (optchar != -1) {
+      place = EMSG;
+      return (optchar);
+    }
+  }
+
+  if ((optchar = (int)*place++) == (int)':' ||
+      (optchar == (int)'-' && *place != '\0') ||
+      (oli = strchr(options, optchar)) == NULL) {
+    /*
+    * If the user specified "-" and  '-' isn't listed in
+    * options, return -1 (non-option) as per POSIX.
+    * Otherwise, it is an unknown option character (or ':').
+    */
+    if (optchar == (int)'-' && *place == '\0')
+      return (-1);
+    if (!*place)
+      ++optind;
+    if (PRINT_ERROR)
+      warnx(illoptchar, optchar);
+    optopt = optchar;
+    return (BADCH);
+  }
+  if (long_options != NULL && optchar == 'W' && oli[1] == ';') {
+    /* -W long-option */
+    if (*place) /* no space */
+      /* NOTHING */;
+    else if (++optind >= nargc) { /* no arg */
+      place = EMSG;
+      if (PRINT_ERROR)
+        warnx(recargchar, optchar);
+      optopt = optchar;
+      return (BADARG);
+    } else /* white space */
+      place = nargv[optind];
+    optchar = parse_long_options(nargv, options, long_options, idx, 0);
+    place = EMSG;
+    return (optchar);
+  }
+  if (*++oli != ':') { /* doesn't take argument */
+    if (!*place)
+      ++optind;
+  } else { /* takes (optional) argument */
+    optarg = NULL;
+    if (*place) /* no white space */
+      optarg = const_cast<char *>(place);
+    else if (oli[1] != ':') {  /* arg not optional */
+      if (++optind >= nargc) { /* no arg */
+        place = EMSG;
         if (PRINT_ERROR)
-            warnx(illoptchar, optchar);
+          warnx(recargchar, optchar);
         optopt = optchar;
-        return (BADCH);
-    }
-    if (long_options != NULL && optchar == 'W' && oli[1] == ';') {
-        /* -W long-option */
-        if (*place)         /* no space */
-            /* NOTHING */;
-        else if (++optind >= nargc) {   /* no arg */
-            place = EMSG;
-            if (PRINT_ERROR)
-                warnx(recargchar, optchar);
-            optopt = optchar;
-            return (BADARG);
-        }
-        else              /* white space */
-            place = nargv[optind];
-        optchar = parse_long_options(nargv, options, long_options,
-            idx, 0);
-        place = EMSG;
-        return (optchar);
-    }
-    if (*++oli != ':') {            /* doesn't take argument */
-        if (!*place)
-            ++optind;
-    }
-    else {                /* takes (optional) argument */
-        optarg = NULL;
-        if (*place)         /* no white space */
-            optarg = const_cast<char*>(place);
-        else if (oli[1] != ':') {   /* arg not optional */
-            if (++optind >= nargc) {    /* no arg */
-                place = EMSG;
-                if (PRINT_ERROR)
-                    warnx(recargchar, optchar);
-                optopt = optchar;
-                return (BADARG);
-            }
-            else
-                optarg = nargv[optind];
-        }
-        place = EMSG;
-        ++optind;
-    }
-    /* dump back option letter */
-    return (optchar);
+        return (BADARG);
+      } else
+        optarg = nargv[optind];
+    }
+    place = EMSG;
+    ++optind;
+  }
+  /* dump back option letter */
+  return (optchar);
 }
 
 /*
@@ -425,19 +401,17 @@ start:
 * [eventually this will replace the BSD getopt]
 */
 #if defined(REPLACE_GETOPT)
-int
-getopt(int nargc, char * const *nargv, const char *options)
-{
+int getopt(int nargc, char *const *nargv, const char *options) {
 
-    /*
-    * We don't pass FLAG_PERMUTE to getopt_internal() since
-    * the BSD getopt(3) (unlike GNU) has never done this.
-    *
-    * Furthermore, since many privileged programs call getopt()
-    * before dropping privileges it makes sense to keep things
-    * as simple (and bug-free) as possible.
-    */
-    return (getopt_internal(nargc, nargv, options, NULL, NULL, 0));
+  /*
+  * We don't pass FLAG_PERMUTE to getopt_internal() since
+  * the BSD getopt(3) (unlike GNU) has never done this.
+  *
+  * Furthermore, since many privileged programs call getopt()
+  * before dropping privileges it makes sense to keep things
+  * as simple (and bug-free) as possible.
+  */
+  return (getopt_internal(nargc, nargv, options, NULL, NULL, 0));
 }
 #endif
 
@@ -446,12 +420,10 @@ getopt(int nargc, char * const *nargv, c
 *  Parse argc/argv argument vector.
 */
 #if defined(REPLACE_GETOPT_LONG)
-int
-getopt_long(int nargc, char * const *nargv, const char *options,
-const struct option *long_options, int *idx)
-{
-    return (getopt_internal(nargc, nargv, options, long_options, idx,
-        FLAG_PERMUTE));
+int getopt_long(int nargc, char *const *nargv, const char *options,
+                const struct option *long_options, int *idx) {
+  return (
+      getopt_internal(nargc, nargv, options, long_options, idx, FLAG_PERMUTE));
 }
 #endif
 
@@ -460,13 +432,11 @@ const struct option *long_options, int *
 *  Parse argc/argv argument vector.
 */
 #if defined(REPLACE_GETOPT_LONG_ONLY)
-int
-getopt_long_only(int nargc, char * const *nargv, const char *options,
-const struct option *long_options, int *idx)
-{
+int getopt_long_only(int nargc, char *const *nargv, const char *options,
+                     const struct option *long_options, int *idx) {
 
-    return (getopt_internal(nargc, nargv, options, long_options, idx,
-        FLAG_PERMUTE | FLAG_LONGONLY));
+  return (getopt_internal(nargc, nargv, options, long_options, idx,
+                          FLAG_PERMUTE | FLAG_LONGONLY));
 }
 #endif
 

Modified: lldb/trunk/source/Host/common/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/Host.cpp (original)
+++ lldb/trunk/source/Host/common/Host.cpp Tue Sep  6 15:57:50 2016
@@ -13,29 +13,30 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #ifndef _WIN32
-#include <unistd.h>
 #include <dlfcn.h>
 #include <grp.h>
 #include <netdb.h>
 #include <pwd.h>
 #include <sys/stat.h>
+#include <unistd.h>
 #endif
 
-#if defined (__APPLE__)
-#include <mach/mach_port.h>
-#include <mach/mach_init.h>
+#if defined(__APPLE__)
 #include <mach-o/dyld.h>
+#include <mach/mach_init.h>
+#include <mach/mach_port.h>
 #endif
 
-#if defined (__linux__) || defined (__FreeBSD__) || defined (__FreeBSD_kernel__) || defined (__APPLE__) || defined(__NetBSD__)
+#if defined(__linux__) || defined(__FreeBSD__) ||                              \
+    defined(__FreeBSD_kernel__) || defined(__APPLE__) || defined(__NetBSD__)
 #if !defined(__ANDROID__) && !defined(__ANDROID_NDK__)
 #include <spawn.h>
 #endif
-#include <sys/wait.h>
 #include <sys/syscall.h>
+#include <sys/wait.h>
 #endif
 
-#if defined (__FreeBSD__)
+#if defined(__FreeBSD__)
 #include <pthread_np.h>
 #endif
 
@@ -44,25 +45,25 @@
 // Other libraries and framework includes
 // Project includes
 
-#include "lldb/Host/FileSystem.h"
-#include "lldb/Host/Host.h"
-#include "lldb/Host/HostInfo.h"
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/Error.h"
 #include "lldb/Core/Log.h"
 #include "lldb/Host/FileSpec.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/Host.h"
+#include "lldb/Host/HostInfo.h"
 #include "lldb/Host/HostProcess.h"
 #include "lldb/Host/MonitoringProcessLauncher.h"
 #include "lldb/Host/Predicate.h"
 #include "lldb/Host/ProcessLauncher.h"
 #include "lldb/Host/ThreadLauncher.h"
-#include "lldb/lldb-private-forward.h"
-#include "llvm/Support/FileSystem.h"
 #include "lldb/Target/FileAction.h"
 #include "lldb/Target/ProcessLaunchInfo.h"
 #include "lldb/Target/UnixSignals.h"
 #include "lldb/Utility/CleanUp.h"
+#include "lldb/lldb-private-forward.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/Support/FileSystem.h"
 
 #if defined(_WIN32)
 #include "lldb/Host/windows/ProcessLauncherWindows.h"
@@ -72,15 +73,14 @@
 #include "lldb/Host/posix/ProcessLauncherPosix.h"
 #endif
 
-#if defined (__APPLE__)
+#if defined(__APPLE__)
 #ifndef _POSIX_SPAWN_DISABLE_ASLR
-#define _POSIX_SPAWN_DISABLE_ASLR       0x0100
+#define _POSIX_SPAWN_DISABLE_ASLR 0x0100
 #endif
 
-extern "C"
-{
-    int __pthread_chdir(const char *path);
-    int __pthread_fchdir (int fildes);
+extern "C" {
+int __pthread_chdir(const char *path);
+int __pthread_fchdir(int fildes);
 }
 
 #endif
@@ -88,30 +88,30 @@ extern "C"
 using namespace lldb;
 using namespace lldb_private;
 
-#if !defined (__APPLE__) && !defined (_WIN32)
-struct MonitorInfo
-{
-    lldb::pid_t pid;                            // The process ID to monitor
-    Host::MonitorChildProcessCallback callback; // The callback function to call when "pid" exits or signals
-    bool monitor_signals;                       // If true, call the callback when "pid" gets signaled.
+#if !defined(__APPLE__) && !defined(_WIN32)
+struct MonitorInfo {
+  lldb::pid_t pid; // The process ID to monitor
+  Host::MonitorChildProcessCallback
+      callback; // The callback function to call when "pid" exits or signals
+  bool monitor_signals; // If true, call the callback when "pid" gets signaled.
 };
 
-static thread_result_t
-MonitorChildProcessThreadFunction (void *arg);
-
-HostThread
-Host::StartMonitoringChildProcess(const Host::MonitorChildProcessCallback &callback, lldb::pid_t pid,
-                                  bool monitor_signals)
-{
-    MonitorInfo * info_ptr = new MonitorInfo();
+static thread_result_t MonitorChildProcessThreadFunction(void *arg);
 
-    info_ptr->pid = pid;
-    info_ptr->callback = callback;
-    info_ptr->monitor_signals = monitor_signals;
-    
-    char thread_name[256];
-    ::snprintf(thread_name, sizeof(thread_name), "<lldb.host.wait4(pid=%" PRIu64 ")>", pid);
-    return ThreadLauncher::LaunchThread(thread_name, MonitorChildProcessThreadFunction, info_ptr, NULL);
+HostThread Host::StartMonitoringChildProcess(
+    const Host::MonitorChildProcessCallback &callback, lldb::pid_t pid,
+    bool monitor_signals) {
+  MonitorInfo *info_ptr = new MonitorInfo();
+
+  info_ptr->pid = pid;
+  info_ptr->callback = callback;
+  info_ptr->monitor_signals = monitor_signals;
+
+  char thread_name[256];
+  ::snprintf(thread_name, sizeof(thread_name),
+             "<lldb.host.wait4(pid=%" PRIu64 ")>", pid);
+  return ThreadLauncher::LaunchThread(
+      thread_name, MonitorChildProcessThreadFunction, info_ptr, NULL);
 }
 
 #ifndef __linux__
@@ -120,26 +120,24 @@ Host::StartMonitoringChildProcess(const
 // constructed, and exception safely restore the previous value it
 // when it goes out of scope.
 //------------------------------------------------------------------
-class ScopedPThreadCancelDisabler
-{
+class ScopedPThreadCancelDisabler {
 public:
-    ScopedPThreadCancelDisabler()
-    {
-        // Disable the ability for this thread to be cancelled
-        int err = ::pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &m_old_state);
-        if (err != 0)
-            m_old_state = -1;
-    }
+  ScopedPThreadCancelDisabler() {
+    // Disable the ability for this thread to be cancelled
+    int err = ::pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &m_old_state);
+    if (err != 0)
+      m_old_state = -1;
+  }
+
+  ~ScopedPThreadCancelDisabler() {
+    // Restore the ability for this thread to be cancelled to what it
+    // previously was.
+    if (m_old_state != -1)
+      ::pthread_setcancelstate(m_old_state, 0);
+  }
 
-    ~ScopedPThreadCancelDisabler()
-    {
-        // Restore the ability for this thread to be cancelled to what it
-        // previously was.
-        if (m_old_state != -1)
-            ::pthread_setcancelstate (m_old_state, 0);
-    }
 private:
-    int m_old_state;    // Save the old cancelability state.
+  int m_old_state; // Save the old cancelability state.
 };
 #endif // __linux__
 
@@ -150,279 +148,275 @@ static __thread volatile sig_atomic_t g_
 static thread_local volatile sig_atomic_t g_usr1_called;
 #endif
 
-static void
-SigUsr1Handler (int)
-{
-    g_usr1_called = 1;
-}
+static void SigUsr1Handler(int) { g_usr1_called = 1; }
 #endif // __linux__
 
-static bool
-CheckForMonitorCancellation()
-{
+static bool CheckForMonitorCancellation() {
 #ifdef __linux__
-    if (g_usr1_called)
-    {
-        g_usr1_called = 0;
-        return true;
-    }
+  if (g_usr1_called) {
+    g_usr1_called = 0;
+    return true;
+  }
 #else
-    ::pthread_testcancel ();
+  ::pthread_testcancel();
 #endif
-    return false;
+  return false;
 }
 
-static thread_result_t
-MonitorChildProcessThreadFunction (void *arg)
-{
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
-    const char *function = __FUNCTION__;
-    if (log)
-        log->Printf ("%s (arg = %p) thread starting...", function, arg);
+static thread_result_t MonitorChildProcessThreadFunction(void *arg) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+  const char *function = __FUNCTION__;
+  if (log)
+    log->Printf("%s (arg = %p) thread starting...", function, arg);
 
-    MonitorInfo *info = (MonitorInfo *)arg;
+  MonitorInfo *info = (MonitorInfo *)arg;
 
-    const Host::MonitorChildProcessCallback callback = info->callback;
-    const bool monitor_signals = info->monitor_signals;
+  const Host::MonitorChildProcessCallback callback = info->callback;
+  const bool monitor_signals = info->monitor_signals;
 
-    assert (info->pid <= UINT32_MAX);
-    const ::pid_t pid = monitor_signals ? -1 * getpgid(info->pid) : info->pid;
+  assert(info->pid <= UINT32_MAX);
+  const ::pid_t pid = monitor_signals ? -1 * getpgid(info->pid) : info->pid;
 
-    delete info;
+  delete info;
 
-    int status = -1;
-#if defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
-    #define __WALL 0
+  int status = -1;
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#define __WALL 0
 #endif
-    const int options = __WALL;
+  const int options = __WALL;
 
 #ifdef __linux__
-    // This signal is only used to interrupt the thread from waitpid
-    struct sigaction sigUsr1Action;
-    memset(&sigUsr1Action, 0, sizeof(sigUsr1Action));
-    sigUsr1Action.sa_handler = SigUsr1Handler;
-    ::sigaction(SIGUSR1, &sigUsr1Action, nullptr);
-#endif // __linux__    
-
-    while (1)
-    {
-        log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS);
-        if (log)
-            log->Printf("%s ::waitpid (pid = %" PRIi32 ", &status, options = %i)...", function, pid, options);
+  // This signal is only used to interrupt the thread from waitpid
+  struct sigaction sigUsr1Action;
+  memset(&sigUsr1Action, 0, sizeof(sigUsr1Action));
+  sigUsr1Action.sa_handler = SigUsr1Handler;
+  ::sigaction(SIGUSR1, &sigUsr1Action, nullptr);
+#endif // __linux__
 
-        if (CheckForMonitorCancellation ())
-            break;
+  while (1) {
+    log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS);
+    if (log)
+      log->Printf("%s ::waitpid (pid = %" PRIi32 ", &status, options = %i)...",
+                  function, pid, options);
 
-        // Get signals from all children with same process group of pid
-        const ::pid_t wait_pid = ::waitpid (pid, &status, options);
+    if (CheckForMonitorCancellation())
+      break;
 
-        if (CheckForMonitorCancellation ())
-            break;
+    // Get signals from all children with same process group of pid
+    const ::pid_t wait_pid = ::waitpid(pid, &status, options);
 
-        if (wait_pid == -1)
-        {
-            if (errno == EINTR)
-                continue;
-            else
-            {
-                if (log)
-                    log->Printf ("%s (arg = %p) thread exiting because waitpid failed (%s)...", __FUNCTION__, arg, strerror(errno));
-                break;
-            }
-        }
-        else if (wait_pid > 0)
-        {
-            bool exited = false;
-            int signal = 0;
-            int exit_status = 0;
-            const char *status_cstr = NULL;
-            if (WIFSTOPPED(status))
-            {
-                signal = WSTOPSIG(status);
-                status_cstr = "STOPPED";
-            }
-            else if (WIFEXITED(status))
-            {
-                exit_status = WEXITSTATUS(status);
-                status_cstr = "EXITED";
-                exited = true;
-            }
-            else if (WIFSIGNALED(status))
-            {
-                signal = WTERMSIG(status);
-                status_cstr = "SIGNALED";
-                if (wait_pid == abs(pid)) {
-                    exited = true;
-                    exit_status = -1;
-                }
-            }
-            else
-            {
-                status_cstr = "(\?\?\?)";
-            }
+    if (CheckForMonitorCancellation())
+      break;
+
+    if (wait_pid == -1) {
+      if (errno == EINTR)
+        continue;
+      else {
+        if (log)
+          log->Printf(
+              "%s (arg = %p) thread exiting because waitpid failed (%s)...",
+              __FUNCTION__, arg, strerror(errno));
+        break;
+      }
+    } else if (wait_pid > 0) {
+      bool exited = false;
+      int signal = 0;
+      int exit_status = 0;
+      const char *status_cstr = NULL;
+      if (WIFSTOPPED(status)) {
+        signal = WSTOPSIG(status);
+        status_cstr = "STOPPED";
+      } else if (WIFEXITED(status)) {
+        exit_status = WEXITSTATUS(status);
+        status_cstr = "EXITED";
+        exited = true;
+      } else if (WIFSIGNALED(status)) {
+        signal = WTERMSIG(status);
+        status_cstr = "SIGNALED";
+        if (wait_pid == abs(pid)) {
+          exited = true;
+          exit_status = -1;
+        }
+      } else {
+        status_cstr = "(\?\?\?)";
+      }
 
-            // Scope for pthread_cancel_disabler
-            {
+      // Scope for pthread_cancel_disabler
+      {
 #ifndef __linux__
-                ScopedPThreadCancelDisabler pthread_cancel_disabler;
+        ScopedPThreadCancelDisabler pthread_cancel_disabler;
 #endif
 
-                log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS);
-                if (log)
-                    log->Printf ("%s ::waitpid (pid = %" PRIi32 ", &status, options = %i) => pid = %" PRIi32 ", status = 0x%8.8x (%s), signal = %i, exit_state = %i",
-                                 function,
-                                 pid,
-                                 options,
-                                 wait_pid,
-                                 status,
-                                 status_cstr,
-                                 signal,
-                                 exit_status);
-
-                if (exited || (signal != 0 && monitor_signals))
-                {
-                    bool callback_return = false;
-                    if (callback)
-                        callback_return = callback(wait_pid, exited, signal, exit_status);
-
-                    // If our process exited, then this thread should exit
-                    if (exited && wait_pid == abs(pid))
-                    {
-                        if (log)
-                            log->Printf ("%s (arg = %p) thread exiting because pid received exit signal...", __FUNCTION__, arg);
-                        break;
-                    }
-                    // If the callback returns true, it means this process should
-                    // exit
-                    if (callback_return)
-                    {
-                        if (log)
-                            log->Printf ("%s (arg = %p) thread exiting because callback returned true...", __FUNCTION__, arg);
-                        break;
-                    }
-                }
-            }
+        log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS);
+        if (log)
+          log->Printf("%s ::waitpid (pid = %" PRIi32
+                      ", &status, options = %i) => pid = %" PRIi32
+                      ", status = 0x%8.8x (%s), signal = %i, exit_state = %i",
+                      function, pid, options, wait_pid, status, status_cstr,
+                      signal, exit_status);
+
+        if (exited || (signal != 0 && monitor_signals)) {
+          bool callback_return = false;
+          if (callback)
+            callback_return = callback(wait_pid, exited, signal, exit_status);
+
+          // If our process exited, then this thread should exit
+          if (exited && wait_pid == abs(pid)) {
+            if (log)
+              log->Printf("%s (arg = %p) thread exiting because pid received "
+                          "exit signal...",
+                          __FUNCTION__, arg);
+            break;
+          }
+          // If the callback returns true, it means this process should
+          // exit
+          if (callback_return) {
+            if (log)
+              log->Printf("%s (arg = %p) thread exiting because callback "
+                          "returned true...",
+                          __FUNCTION__, arg);
+            break;
+          }
         }
+      }
     }
+  }
 
-    log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS);
-    if (log)
-        log->Printf ("%s (arg = %p) thread exiting...", __FUNCTION__, arg);
+  log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS);
+  if (log)
+    log->Printf("%s (arg = %p) thread exiting...", __FUNCTION__, arg);
 
-    return NULL;
+  return NULL;
 }
 
 #endif // #if !defined (__APPLE__) && !defined (_WIN32)
 
-#if !defined (__APPLE__)
+#if !defined(__APPLE__)
 
-void
-Host::SystemLog (SystemLogType type, const char *format, va_list args)
-{
-    vfprintf (stderr, format, args);
+void Host::SystemLog(SystemLogType type, const char *format, va_list args) {
+  vfprintf(stderr, format, args);
 }
 
 #endif
 
-void
-Host::SystemLog (SystemLogType type, const char *format, ...)
-{
-    va_list args;
-    va_start (args, format);
-    SystemLog (type, format, args);
-    va_end (args);
+void Host::SystemLog(SystemLogType type, const char *format, ...) {
+  va_list args;
+  va_start(args, format);
+  SystemLog(type, format, args);
+  va_end(args);
 }
 
-lldb::pid_t
-Host::GetCurrentProcessID()
-{
-    return ::getpid();
-}
+lldb::pid_t Host::GetCurrentProcessID() { return ::getpid(); }
 
 #ifndef _WIN32
 
-lldb::tid_t
-Host::GetCurrentThreadID()
-{
-#if defined (__APPLE__)
-    // Calling "mach_thread_self()" bumps the reference count on the thread
-    // port, so we need to deallocate it. mach_task_self() doesn't bump the ref
-    // count.
-    thread_port_t thread_self = mach_thread_self();
-    mach_port_deallocate(mach_task_self(), thread_self);
-    return thread_self;
+lldb::tid_t Host::GetCurrentThreadID() {
+#if defined(__APPLE__)
+  // Calling "mach_thread_self()" bumps the reference count on the thread
+  // port, so we need to deallocate it. mach_task_self() doesn't bump the ref
+  // count.
+  thread_port_t thread_self = mach_thread_self();
+  mach_port_deallocate(mach_task_self(), thread_self);
+  return thread_self;
 #elif defined(__FreeBSD__)
-    return lldb::tid_t(pthread_getthreadid_np());
+  return lldb::tid_t(pthread_getthreadid_np());
 #elif defined(__ANDROID_NDK__)
-    return lldb::tid_t(gettid());
+  return lldb::tid_t(gettid());
 #elif defined(__linux__)
-    return lldb::tid_t(syscall(SYS_gettid));
+  return lldb::tid_t(syscall(SYS_gettid));
 #else
-    return lldb::tid_t(pthread_self());
+  return lldb::tid_t(pthread_self());
 #endif
 }
 
-lldb::thread_t
-Host::GetCurrentThread ()
-{
-    return lldb::thread_t(pthread_self());
+lldb::thread_t Host::GetCurrentThread() {
+  return lldb::thread_t(pthread_self());
 }
 
-const char *
-Host::GetSignalAsCString (int signo)
-{
-    switch (signo)
-    {
-    case SIGHUP:    return "SIGHUP";    // 1    hangup
-    case SIGINT:    return "SIGINT";    // 2    interrupt
-    case SIGQUIT:   return "SIGQUIT";   // 3    quit
-    case SIGILL:    return "SIGILL";    // 4    illegal instruction (not reset when caught)
-    case SIGTRAP:   return "SIGTRAP";   // 5    trace trap (not reset when caught)
-    case SIGABRT:   return "SIGABRT";   // 6    abort()
-#if  defined(SIGPOLL)
+const char *Host::GetSignalAsCString(int signo) {
+  switch (signo) {
+  case SIGHUP:
+    return "SIGHUP"; // 1    hangup
+  case SIGINT:
+    return "SIGINT"; // 2    interrupt
+  case SIGQUIT:
+    return "SIGQUIT"; // 3    quit
+  case SIGILL:
+    return "SIGILL"; // 4    illegal instruction (not reset when caught)
+  case SIGTRAP:
+    return "SIGTRAP"; // 5    trace trap (not reset when caught)
+  case SIGABRT:
+    return "SIGABRT"; // 6    abort()
+#if defined(SIGPOLL)
 #if !defined(SIGIO) || (SIGPOLL != SIGIO)
-// Under some GNU/Linux, SIGPOLL and SIGIO are the same. Causing the build to
-// fail with 'multiple define cases with same value'
-    case SIGPOLL:   return "SIGPOLL";   // 7    pollable event ([XSR] generated, not supported)
-#endif
-#endif
-#if  defined(SIGEMT)
-    case SIGEMT:    return "SIGEMT";    // 7    EMT instruction
-#endif
-    case SIGFPE:    return "SIGFPE";    // 8    floating point exception
-    case SIGKILL:   return "SIGKILL";   // 9    kill (cannot be caught or ignored)
-    case SIGBUS:    return "SIGBUS";    // 10    bus error
-    case SIGSEGV:   return "SIGSEGV";   // 11    segmentation violation
-    case SIGSYS:    return "SIGSYS";    // 12    bad argument to system call
-    case SIGPIPE:   return "SIGPIPE";   // 13    write on a pipe with no one to read it
-    case SIGALRM:   return "SIGALRM";   // 14    alarm clock
-    case SIGTERM:   return "SIGTERM";   // 15    software termination signal from kill
-    case SIGURG:    return "SIGURG";    // 16    urgent condition on IO channel
-    case SIGSTOP:   return "SIGSTOP";   // 17    sendable stop signal not from tty
-    case SIGTSTP:   return "SIGTSTP";   // 18    stop signal from tty
-    case SIGCONT:   return "SIGCONT";   // 19    continue a stopped process
-    case SIGCHLD:   return "SIGCHLD";   // 20    to parent on child stop or exit
-    case SIGTTIN:   return "SIGTTIN";   // 21    to readers pgrp upon background tty read
-    case SIGTTOU:   return "SIGTTOU";   // 22    like TTIN for output if (tp->t_local&LTOSTOP)
-#if  defined(SIGIO)
-    case SIGIO:     return "SIGIO";     // 23    input/output possible signal
-#endif
-    case SIGXCPU:   return "SIGXCPU";   // 24    exceeded CPU time limit
-    case SIGXFSZ:   return "SIGXFSZ";   // 25    exceeded file size limit
-    case SIGVTALRM: return "SIGVTALRM"; // 26    virtual time alarm
-    case SIGPROF:   return "SIGPROF";   // 27    profiling time alarm
-#if  defined(SIGWINCH)
-    case SIGWINCH:  return "SIGWINCH";  // 28    window size changes
-#endif
-#if  defined(SIGINFO)
-    case SIGINFO:   return "SIGINFO";   // 29    information request
-#endif
-    case SIGUSR1:   return "SIGUSR1";   // 30    user defined signal 1
-    case SIGUSR2:   return "SIGUSR2";   // 31    user defined signal 2
-    default:
-        break;
-    }
-    return NULL;
+  // Under some GNU/Linux, SIGPOLL and SIGIO are the same. Causing the build to
+  // fail with 'multiple define cases with same value'
+  case SIGPOLL:
+    return "SIGPOLL"; // 7    pollable event ([XSR] generated, not supported)
+#endif
+#endif
+#if defined(SIGEMT)
+  case SIGEMT:
+    return "SIGEMT"; // 7    EMT instruction
+#endif
+  case SIGFPE:
+    return "SIGFPE"; // 8    floating point exception
+  case SIGKILL:
+    return "SIGKILL"; // 9    kill (cannot be caught or ignored)
+  case SIGBUS:
+    return "SIGBUS"; // 10    bus error
+  case SIGSEGV:
+    return "SIGSEGV"; // 11    segmentation violation
+  case SIGSYS:
+    return "SIGSYS"; // 12    bad argument to system call
+  case SIGPIPE:
+    return "SIGPIPE"; // 13    write on a pipe with no one to read it
+  case SIGALRM:
+    return "SIGALRM"; // 14    alarm clock
+  case SIGTERM:
+    return "SIGTERM"; // 15    software termination signal from kill
+  case SIGURG:
+    return "SIGURG"; // 16    urgent condition on IO channel
+  case SIGSTOP:
+    return "SIGSTOP"; // 17    sendable stop signal not from tty
+  case SIGTSTP:
+    return "SIGTSTP"; // 18    stop signal from tty
+  case SIGCONT:
+    return "SIGCONT"; // 19    continue a stopped process
+  case SIGCHLD:
+    return "SIGCHLD"; // 20    to parent on child stop or exit
+  case SIGTTIN:
+    return "SIGTTIN"; // 21    to readers pgrp upon background tty read
+  case SIGTTOU:
+    return "SIGTTOU"; // 22    like TTIN for output if (tp->t_local&LTOSTOP)
+#if defined(SIGIO)
+  case SIGIO:
+    return "SIGIO"; // 23    input/output possible signal
+#endif
+  case SIGXCPU:
+    return "SIGXCPU"; // 24    exceeded CPU time limit
+  case SIGXFSZ:
+    return "SIGXFSZ"; // 25    exceeded file size limit
+  case SIGVTALRM:
+    return "SIGVTALRM"; // 26    virtual time alarm
+  case SIGPROF:
+    return "SIGPROF"; // 27    profiling time alarm
+#if defined(SIGWINCH)
+  case SIGWINCH:
+    return "SIGWINCH"; // 28    window size changes
+#endif
+#if defined(SIGINFO)
+  case SIGINFO:
+    return "SIGINFO"; // 29    information request
+#endif
+  case SIGUSR1:
+    return "SIGUSR1"; // 30    user defined signal 1
+  case SIGUSR2:
+    return "SIGUSR2"; // 31    user defined signal 2
+  default:
+    break;
+  }
+  return NULL;
 }
 
 #endif
@@ -430,84 +424,63 @@ Host::GetSignalAsCString (int signo)
 #ifndef _WIN32
 
 lldb::thread_key_t
-Host::ThreadLocalStorageCreate(ThreadLocalStorageCleanupCallback callback)
-{
-    pthread_key_t key;
-    ::pthread_key_create (&key, callback);
-    return key;
+Host::ThreadLocalStorageCreate(ThreadLocalStorageCleanupCallback callback) {
+  pthread_key_t key;
+  ::pthread_key_create(&key, callback);
+  return key;
 }
 
-void*
-Host::ThreadLocalStorageGet(lldb::thread_key_t key)
-{
-    return ::pthread_getspecific (key);
+void *Host::ThreadLocalStorageGet(lldb::thread_key_t key) {
+  return ::pthread_getspecific(key);
 }
 
-void
-Host::ThreadLocalStorageSet(lldb::thread_key_t key, void *value)
-{
-   ::pthread_setspecific (key, value);
+void Host::ThreadLocalStorageSet(lldb::thread_key_t key, void *value) {
+  ::pthread_setspecific(key, value);
 }
 
 #endif
 
-#if !defined (__APPLE__) // see Host.mm
+#if !defined(__APPLE__) // see Host.mm
 
-bool
-Host::GetBundleDirectory (const FileSpec &file, FileSpec &bundle)
-{
-    bundle.Clear();
-    return false;
+bool Host::GetBundleDirectory(const FileSpec &file, FileSpec &bundle) {
+  bundle.Clear();
+  return false;
 }
 
-bool
-Host::ResolveExecutableInBundle (FileSpec &file)
-{
-    return false;
-}
+bool Host::ResolveExecutableInBundle(FileSpec &file) { return false; }
 #endif
 
 #ifndef _WIN32
 
-FileSpec
-Host::GetModuleFileSpecForHostAddress (const void *host_addr)
-{
-    FileSpec module_filespec;
+FileSpec Host::GetModuleFileSpecForHostAddress(const void *host_addr) {
+  FileSpec module_filespec;
 #if !defined(__ANDROID__) && !defined(__ANDROID_NDK__)
-    Dl_info info;
-    if (::dladdr (host_addr, &info))
-    {
-        if (info.dli_fname)
-            module_filespec.SetFile(info.dli_fname, true);
-    }
+  Dl_info info;
+  if (::dladdr(host_addr, &info)) {
+    if (info.dli_fname)
+      module_filespec.SetFile(info.dli_fname, true);
+  }
 #endif
-    return module_filespec;
+  return module_filespec;
 }
 
 #endif
 
 #if !defined(__linux__)
-bool
-Host::FindProcessThreads (const lldb::pid_t pid, TidMap &tids_to_attach)
-{
-    return false;
+bool Host::FindProcessThreads(const lldb::pid_t pid, TidMap &tids_to_attach) {
+  return false;
 }
 #endif
 
-struct ShellInfo
-{
-    ShellInfo () :
-        process_reaped (false),
-        pid (LLDB_INVALID_PROCESS_ID),
-        signo(-1),
-        status(-1)
-    {
-    }
+struct ShellInfo {
+  ShellInfo()
+      : process_reaped(false), pid(LLDB_INVALID_PROCESS_ID), signo(-1),
+        status(-1) {}
 
-    lldb_private::Predicate<bool> process_reaped;
-    lldb::pid_t pid;
-    int signo;
-    int status;
+  lldb_private::Predicate<bool> process_reaped;
+  lldb::pid_t pid;
+  int signo;
+  int status;
 };
 
 static bool
@@ -516,540 +489,524 @@ MonitorShellCommand(std::shared_ptr<Shel
                     int signo,   // Zero for no signal
                     int status)  // Exit value of process if signal is zero
 {
-    shell_info->pid = pid;
-    shell_info->signo = signo;
-    shell_info->status = status;
-    // Let the thread running Host::RunShellCommand() know that the process
-    // exited and that ShellInfo has been filled in by broadcasting to it
-    shell_info->process_reaped.SetValue(true, eBroadcastAlways);
-    return true;
-}
-
-Error
-Host::RunShellCommand(const char *command,
-                      const FileSpec &working_dir,
-                      int *status_ptr,
-                      int *signo_ptr,
-                      std::string *command_output_ptr,
-                      uint32_t timeout_sec,
-                      bool run_in_default_shell)
-{
-    return RunShellCommand(Args(command), working_dir, status_ptr, signo_ptr, command_output_ptr, timeout_sec, run_in_default_shell);
-}
-
-Error
-Host::RunShellCommand(const Args &args,
-                      const FileSpec &working_dir,
-                      int *status_ptr,
-                      int *signo_ptr,
-                      std::string *command_output_ptr,
-                      uint32_t timeout_sec,
-                      bool run_in_default_shell)
-{
-    Error error;
-    ProcessLaunchInfo launch_info;
-    launch_info.SetArchitecture(HostInfo::GetArchitecture());
-    if (run_in_default_shell)
-    {
-        // Run the command in a shell
-        launch_info.SetShell(HostInfo::GetDefaultShell());
-        launch_info.GetArguments().AppendArguments(args);
-        const bool localhost = true;
-        const bool will_debug = false;
-        const bool first_arg_is_full_shell_command = false;
-        launch_info.ConvertArgumentsForLaunchingInShell (error,
-                                                         localhost,
-                                                         will_debug,
-                                                         first_arg_is_full_shell_command,
-                                                         0);
-    }
-    else
-    {
-        // No shell, just run it
-        const bool first_arg_is_executable = true;
-        launch_info.SetArguments(args, first_arg_is_executable);
-    }
-    
-    if (working_dir)
-        launch_info.SetWorkingDirectory(working_dir);
-    llvm::SmallString<PATH_MAX> output_file_path;
-    
-    if (command_output_ptr)
-    {
-        // Create a temporary file to get the stdout/stderr and redirect the
-        // output of the command into this file. We will later read this file
-        // if all goes well and fill the data into "command_output_ptr"
-        FileSpec tmpdir_file_spec;
-        if (HostInfo::GetLLDBPath(ePathTypeLLDBTempSystemDir, tmpdir_file_spec))
-        {
-            tmpdir_file_spec.AppendPathComponent("lldb-shell-output.%%%%%%");
-            llvm::sys::fs::createUniqueFile(tmpdir_file_spec.GetPath().c_str(), output_file_path);
-        }
-        else
-        {
-            llvm::sys::fs::createTemporaryFile("lldb-shell-output.%%%%%%", "", output_file_path);
-        }
-    }
-
-    FileSpec output_file_spec{output_file_path.c_str(), false};
-
-    launch_info.AppendSuppressFileAction (STDIN_FILENO, true, false);
-    if (output_file_spec)
-    {
-        launch_info.AppendOpenFileAction(STDOUT_FILENO, output_file_spec, false, true);
-        launch_info.AppendDuplicateFileAction(STDOUT_FILENO, STDERR_FILENO);
-    }
-    else
-    {
-        launch_info.AppendSuppressFileAction (STDOUT_FILENO, false, true);
-        launch_info.AppendSuppressFileAction (STDERR_FILENO, false, true);
-    }
-
-    std::shared_ptr<ShellInfo> shell_info_sp(new ShellInfo());
-    const bool monitor_signals = false;
-    launch_info.SetMonitorProcessCallback(std::bind(MonitorShellCommand, shell_info_sp, std::placeholders::_1,
-                                                    std::placeholders::_2, std::placeholders::_3,
-                                                    std::placeholders::_4),
-                                          monitor_signals);
-
-    error = LaunchProcess (launch_info);
-    const lldb::pid_t pid = launch_info.GetProcessID();
-    
-    if (error.Success() && pid == LLDB_INVALID_PROCESS_ID)
-        error.SetErrorString("failed to get process ID");
-    
-    if (error.Success())
-    {
-        bool timed_out = false;
-        shell_info_sp->process_reaped.WaitForValueEqualTo(true, std::chrono::seconds(timeout_sec), &timed_out);
-        if (timed_out)
-        {
-            error.SetErrorString("timed out waiting for shell command to complete");
-            
-            // Kill the process since it didn't complete within the timeout specified
-            Kill (pid, SIGKILL);
-            // Wait for the monitor callback to get the message
-            timed_out = false;
-            shell_info_sp->process_reaped.WaitForValueEqualTo(true, std::chrono::seconds(1), &timed_out);
-        }
-        else
-        {
-            if (status_ptr)
-                *status_ptr = shell_info_sp->status;
-
-            if (signo_ptr)
-                *signo_ptr = shell_info_sp->signo;
-
-            if (command_output_ptr)
-            {
-                command_output_ptr->clear();
-                uint64_t file_size = output_file_spec.GetByteSize();
-                if (file_size > 0)
-                {
-                    if (file_size > command_output_ptr->max_size())
-                    {
-                        error.SetErrorStringWithFormat("shell command output is too large to fit into a std::string");
-                    }
-                    else
-                    {
-                        std::vector<char> command_output(file_size);
-                        output_file_spec.ReadFileContents(0, command_output.data(), file_size, &error);
-                        if (error.Success())
-                            command_output_ptr->assign(command_output.data(), file_size);
-                    }
-                }
-            }
-        }
-    }
-
-    if (FileSystem::GetFileExists(output_file_spec))
-        FileSystem::Unlink(output_file_spec);
-    return error;
+  shell_info->pid = pid;
+  shell_info->signo = signo;
+  shell_info->status = status;
+  // Let the thread running Host::RunShellCommand() know that the process
+  // exited and that ShellInfo has been filled in by broadcasting to it
+  shell_info->process_reaped.SetValue(true, eBroadcastAlways);
+  return true;
+}
+
+Error Host::RunShellCommand(const char *command, const FileSpec &working_dir,
+                            int *status_ptr, int *signo_ptr,
+                            std::string *command_output_ptr,
+                            uint32_t timeout_sec, bool run_in_default_shell) {
+  return RunShellCommand(Args(command), working_dir, status_ptr, signo_ptr,
+                         command_output_ptr, timeout_sec, run_in_default_shell);
+}
+
+Error Host::RunShellCommand(const Args &args, const FileSpec &working_dir,
+                            int *status_ptr, int *signo_ptr,
+                            std::string *command_output_ptr,
+                            uint32_t timeout_sec, bool run_in_default_shell) {
+  Error error;
+  ProcessLaunchInfo launch_info;
+  launch_info.SetArchitecture(HostInfo::GetArchitecture());
+  if (run_in_default_shell) {
+    // Run the command in a shell
+    launch_info.SetShell(HostInfo::GetDefaultShell());
+    launch_info.GetArguments().AppendArguments(args);
+    const bool localhost = true;
+    const bool will_debug = false;
+    const bool first_arg_is_full_shell_command = false;
+    launch_info.ConvertArgumentsForLaunchingInShell(
+        error, localhost, will_debug, first_arg_is_full_shell_command, 0);
+  } else {
+    // No shell, just run it
+    const bool first_arg_is_executable = true;
+    launch_info.SetArguments(args, first_arg_is_executable);
+  }
+
+  if (working_dir)
+    launch_info.SetWorkingDirectory(working_dir);
+  llvm::SmallString<PATH_MAX> output_file_path;
+
+  if (command_output_ptr) {
+    // Create a temporary file to get the stdout/stderr and redirect the
+    // output of the command into this file. We will later read this file
+    // if all goes well and fill the data into "command_output_ptr"
+    FileSpec tmpdir_file_spec;
+    if (HostInfo::GetLLDBPath(ePathTypeLLDBTempSystemDir, tmpdir_file_spec)) {
+      tmpdir_file_spec.AppendPathComponent("lldb-shell-output.%%%%%%");
+      llvm::sys::fs::createUniqueFile(tmpdir_file_spec.GetPath().c_str(),
+                                      output_file_path);
+    } else {
+      llvm::sys::fs::createTemporaryFile("lldb-shell-output.%%%%%%", "",
+                                         output_file_path);
+    }
+  }
+
+  FileSpec output_file_spec{output_file_path.c_str(), false};
+
+  launch_info.AppendSuppressFileAction(STDIN_FILENO, true, false);
+  if (output_file_spec) {
+    launch_info.AppendOpenFileAction(STDOUT_FILENO, output_file_spec, false,
+                                     true);
+    launch_info.AppendDuplicateFileAction(STDOUT_FILENO, STDERR_FILENO);
+  } else {
+    launch_info.AppendSuppressFileAction(STDOUT_FILENO, false, true);
+    launch_info.AppendSuppressFileAction(STDERR_FILENO, false, true);
+  }
+
+  std::shared_ptr<ShellInfo> shell_info_sp(new ShellInfo());
+  const bool monitor_signals = false;
+  launch_info.SetMonitorProcessCallback(
+      std::bind(MonitorShellCommand, shell_info_sp, std::placeholders::_1,
+                std::placeholders::_2, std::placeholders::_3,
+                std::placeholders::_4),
+      monitor_signals);
+
+  error = LaunchProcess(launch_info);
+  const lldb::pid_t pid = launch_info.GetProcessID();
+
+  if (error.Success() && pid == LLDB_INVALID_PROCESS_ID)
+    error.SetErrorString("failed to get process ID");
+
+  if (error.Success()) {
+    bool timed_out = false;
+    shell_info_sp->process_reaped.WaitForValueEqualTo(
+        true, std::chrono::seconds(timeout_sec), &timed_out);
+    if (timed_out) {
+      error.SetErrorString("timed out waiting for shell command to complete");
+
+      // Kill the process since it didn't complete within the timeout specified
+      Kill(pid, SIGKILL);
+      // Wait for the monitor callback to get the message
+      timed_out = false;
+      shell_info_sp->process_reaped.WaitForValueEqualTo(
+          true, std::chrono::seconds(1), &timed_out);
+    } else {
+      if (status_ptr)
+        *status_ptr = shell_info_sp->status;
+
+      if (signo_ptr)
+        *signo_ptr = shell_info_sp->signo;
+
+      if (command_output_ptr) {
+        command_output_ptr->clear();
+        uint64_t file_size = output_file_spec.GetByteSize();
+        if (file_size > 0) {
+          if (file_size > command_output_ptr->max_size()) {
+            error.SetErrorStringWithFormat(
+                "shell command output is too large to fit into a std::string");
+          } else {
+            std::vector<char> command_output(file_size);
+            output_file_spec.ReadFileContents(0, command_output.data(),
+                                              file_size, &error);
+            if (error.Success())
+              command_output_ptr->assign(command_output.data(), file_size);
+          }
+        }
+      }
+    }
+  }
+
+  if (FileSystem::GetFileExists(output_file_spec))
+    FileSystem::Unlink(output_file_spec);
+  return error;
 }
 
 // LaunchProcessPosixSpawn for Apple, Linux, FreeBSD and other GLIBC
 // systems
 
-#if defined (__APPLE__) || defined (__linux__) || defined (__FreeBSD__) || defined (__GLIBC__) || defined(__NetBSD__)
+#if defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__) ||        \
+    defined(__GLIBC__) || defined(__NetBSD__)
 #if !defined(__ANDROID__) && !defined(__ANDROID_NDK__)
 // this method needs to be visible to macosx/Host.cpp and
 // common/Host.cpp.
 
-short
-Host::GetPosixspawnFlags(const ProcessLaunchInfo &launch_info)
-{
-    short flags = POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETSIGMASK;
+short Host::GetPosixspawnFlags(const ProcessLaunchInfo &launch_info) {
+  short flags = POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETSIGMASK;
+
+#if defined(__APPLE__)
+  if (launch_info.GetFlags().Test(eLaunchFlagExec))
+    flags |= POSIX_SPAWN_SETEXEC; // Darwin specific posix_spawn flag
+
+  if (launch_info.GetFlags().Test(eLaunchFlagDebug))
+    flags |= POSIX_SPAWN_START_SUSPENDED; // Darwin specific posix_spawn flag
+
+  if (launch_info.GetFlags().Test(eLaunchFlagDisableASLR))
+    flags |= _POSIX_SPAWN_DISABLE_ASLR; // Darwin specific posix_spawn flag
+
+  if (launch_info.GetLaunchInSeparateProcessGroup())
+    flags |= POSIX_SPAWN_SETPGROUP;
 
-#if defined (__APPLE__)
-    if (launch_info.GetFlags().Test (eLaunchFlagExec))
-        flags |= POSIX_SPAWN_SETEXEC;           // Darwin specific posix_spawn flag
-    
-    if (launch_info.GetFlags().Test (eLaunchFlagDebug))
-        flags |= POSIX_SPAWN_START_SUSPENDED;   // Darwin specific posix_spawn flag
-    
-    if (launch_info.GetFlags().Test (eLaunchFlagDisableASLR))
-        flags |= _POSIX_SPAWN_DISABLE_ASLR;     // Darwin specific posix_spawn flag
-        
-    if (launch_info.GetLaunchInSeparateProcessGroup())
-        flags |= POSIX_SPAWN_SETPGROUP;
-    
 #ifdef POSIX_SPAWN_CLOEXEC_DEFAULT
-#if defined (__APPLE__) && (defined (__x86_64__) || defined (__i386__))
-    static LazyBool g_use_close_on_exec_flag = eLazyBoolCalculate;
-    if (g_use_close_on_exec_flag == eLazyBoolCalculate)
-    {
-        g_use_close_on_exec_flag = eLazyBoolNo;
-        
-        uint32_t major, minor, update;
-        if (HostInfo::GetOSVersion(major, minor, update))
-        {
-            // Kernel panic if we use the POSIX_SPAWN_CLOEXEC_DEFAULT on 10.7 or earlier
-            if (major > 10 || (major == 10 && minor > 7))
-            {
-                // Only enable for 10.8 and later OS versions
-                g_use_close_on_exec_flag = eLazyBoolYes;
-            }
-        }
+#if defined(__APPLE__) && (defined(__x86_64__) || defined(__i386__))
+  static LazyBool g_use_close_on_exec_flag = eLazyBoolCalculate;
+  if (g_use_close_on_exec_flag == eLazyBoolCalculate) {
+    g_use_close_on_exec_flag = eLazyBoolNo;
+
+    uint32_t major, minor, update;
+    if (HostInfo::GetOSVersion(major, minor, update)) {
+      // Kernel panic if we use the POSIX_SPAWN_CLOEXEC_DEFAULT on 10.7 or
+      // earlier
+      if (major > 10 || (major == 10 && minor > 7)) {
+        // Only enable for 10.8 and later OS versions
+        g_use_close_on_exec_flag = eLazyBoolYes;
+      }
     }
+  }
 #else
-    static LazyBool g_use_close_on_exec_flag = eLazyBoolYes;
+  static LazyBool g_use_close_on_exec_flag = eLazyBoolYes;
 #endif
-    // Close all files exception those with file actions if this is supported.
-    if (g_use_close_on_exec_flag == eLazyBoolYes)
-        flags |= POSIX_SPAWN_CLOEXEC_DEFAULT;
+  // Close all files exception those with file actions if this is supported.
+  if (g_use_close_on_exec_flag == eLazyBoolYes)
+    flags |= POSIX_SPAWN_CLOEXEC_DEFAULT;
 #endif
 #endif // #if defined (__APPLE__)
-    return flags;
+  return flags;
 }
 
-Error
-Host::LaunchProcessPosixSpawn(const char *exe_path, const ProcessLaunchInfo &launch_info, lldb::pid_t &pid)
-{
-    Error error;
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_HOST | LIBLLDB_LOG_PROCESS));
-
-    posix_spawnattr_t attr;
-    error.SetError( ::posix_spawnattr_init (&attr), eErrorTypePOSIX);
-
-    if (error.Fail() || log)
-        error.PutToLog(log, "::posix_spawnattr_init ( &attr )");
-    if (error.Fail())
-        return error;
-
-    // Make a quick class that will cleanup the posix spawn attributes in case
-    // we return in the middle of this function.
-    lldb_utility::CleanUp <posix_spawnattr_t *, int> posix_spawnattr_cleanup(&attr, posix_spawnattr_destroy);
+Error Host::LaunchProcessPosixSpawn(const char *exe_path,
+                                    const ProcessLaunchInfo &launch_info,
+                                    lldb::pid_t &pid) {
+  Error error;
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST |
+                                                  LIBLLDB_LOG_PROCESS));
+
+  posix_spawnattr_t attr;
+  error.SetError(::posix_spawnattr_init(&attr), eErrorTypePOSIX);
+
+  if (error.Fail() || log)
+    error.PutToLog(log, "::posix_spawnattr_init ( &attr )");
+  if (error.Fail())
+    return error;
 
-    sigset_t no_signals;
-    sigset_t all_signals;
-    sigemptyset (&no_signals);
-    sigfillset (&all_signals);
-    ::posix_spawnattr_setsigmask(&attr, &no_signals);
-#if defined (__linux__)  || defined (__FreeBSD__)
-    ::posix_spawnattr_setsigdefault(&attr, &no_signals);
+  // Make a quick class that will cleanup the posix spawn attributes in case
+  // we return in the middle of this function.
+  lldb_utility::CleanUp<posix_spawnattr_t *, int> posix_spawnattr_cleanup(
+      &attr, posix_spawnattr_destroy);
+
+  sigset_t no_signals;
+  sigset_t all_signals;
+  sigemptyset(&no_signals);
+  sigfillset(&all_signals);
+  ::posix_spawnattr_setsigmask(&attr, &no_signals);
+#if defined(__linux__) || defined(__FreeBSD__)
+  ::posix_spawnattr_setsigdefault(&attr, &no_signals);
 #else
-    ::posix_spawnattr_setsigdefault(&attr, &all_signals);
+  ::posix_spawnattr_setsigdefault(&attr, &all_signals);
 #endif
 
-    short flags = GetPosixspawnFlags(launch_info);
+  short flags = GetPosixspawnFlags(launch_info);
 
-    error.SetError( ::posix_spawnattr_setflags (&attr, flags), eErrorTypePOSIX);
-    if (error.Fail() || log)
-        error.PutToLog(log, "::posix_spawnattr_setflags ( &attr, flags=0x%8.8x )", flags);
-    if (error.Fail())
-        return error;
+  error.SetError(::posix_spawnattr_setflags(&attr, flags), eErrorTypePOSIX);
+  if (error.Fail() || log)
+    error.PutToLog(log, "::posix_spawnattr_setflags ( &attr, flags=0x%8.8x )",
+                   flags);
+  if (error.Fail())
+    return error;
 
-    // posix_spawnattr_setbinpref_np appears to be an Apple extension per:
-    // http://www.unix.com/man-page/OSX/3/posix_spawnattr_setbinpref_np/
-#if defined (__APPLE__) && !defined (__arm__)
-    
-    // Don't set the binpref if a shell was provided.  After all, that's only going to affect what version of the shell
-    // is launched, not what fork of the binary is launched.  We insert "arch --arch <ARCH> as part of the shell invocation
-    // to do that job on OSX.
-    
-    if (launch_info.GetShell() == nullptr)
-    {
-        // We don't need to do this for ARM, and we really shouldn't now that we
-        // have multiple CPU subtypes and no posix_spawnattr call that allows us
-        // to set which CPU subtype to launch...
-        const ArchSpec &arch_spec = launch_info.GetArchitecture();
-        cpu_type_t cpu = arch_spec.GetMachOCPUType();
-        cpu_type_t sub = arch_spec.GetMachOCPUSubType();
-        if (cpu != 0 &&
-            cpu != static_cast<cpu_type_t>(UINT32_MAX) &&
-            cpu != static_cast<cpu_type_t>(LLDB_INVALID_CPUTYPE) &&
-            !(cpu == 0x01000007 && sub == 8)) // If haswell is specified, don't try to set the CPU type or we will fail 
-        {
-            size_t ocount = 0;
-            error.SetError( ::posix_spawnattr_setbinpref_np (&attr, 1, &cpu, &ocount), eErrorTypePOSIX);
-            if (error.Fail() || log)
-                error.PutToLog(log, "::posix_spawnattr_setbinpref_np ( &attr, 1, cpu_type = 0x%8.8x, count => %llu )", cpu, (uint64_t)ocount);
+// posix_spawnattr_setbinpref_np appears to be an Apple extension per:
+// http://www.unix.com/man-page/OSX/3/posix_spawnattr_setbinpref_np/
+#if defined(__APPLE__) && !defined(__arm__)
+
+  // Don't set the binpref if a shell was provided.  After all, that's only
+  // going to affect what version of the shell
+  // is launched, not what fork of the binary is launched.  We insert "arch
+  // --arch <ARCH> as part of the shell invocation
+  // to do that job on OSX.
+
+  if (launch_info.GetShell() == nullptr) {
+    // We don't need to do this for ARM, and we really shouldn't now that we
+    // have multiple CPU subtypes and no posix_spawnattr call that allows us
+    // to set which CPU subtype to launch...
+    const ArchSpec &arch_spec = launch_info.GetArchitecture();
+    cpu_type_t cpu = arch_spec.GetMachOCPUType();
+    cpu_type_t sub = arch_spec.GetMachOCPUSubType();
+    if (cpu != 0 && cpu != static_cast<cpu_type_t>(UINT32_MAX) &&
+        cpu != static_cast<cpu_type_t>(LLDB_INVALID_CPUTYPE) &&
+        !(cpu == 0x01000007 && sub == 8)) // If haswell is specified, don't try
+                                          // to set the CPU type or we will fail
+    {
+      size_t ocount = 0;
+      error.SetError(::posix_spawnattr_setbinpref_np(&attr, 1, &cpu, &ocount),
+                     eErrorTypePOSIX);
+      if (error.Fail() || log)
+        error.PutToLog(log, "::posix_spawnattr_setbinpref_np ( &attr, 1, "
+                            "cpu_type = 0x%8.8x, count => %llu )",
+                       cpu, (uint64_t)ocount);
 
-            if (error.Fail() || ocount != 1)
-                return error;
-        }
+      if (error.Fail() || ocount != 1)
+        return error;
     }
+  }
 
 #endif
 
-    const char *tmp_argv[2];
-    char * const *argv = const_cast<char * const*>(launch_info.GetArguments().GetConstArgumentVector());
-    char * const *envp = const_cast<char * const*>(launch_info.GetEnvironmentEntries().GetConstArgumentVector());
-    if (argv == NULL)
-    {
-        // posix_spawn gets very unhappy if it doesn't have at least the program
-        // name in argv[0]. One of the side affects I have noticed is the environment
-        // variables don't make it into the child process if "argv == NULL"!!!
-        tmp_argv[0] = exe_path;
-        tmp_argv[1] = NULL;
-        argv = const_cast<char * const*>(tmp_argv);
+  const char *tmp_argv[2];
+  char *const *argv = const_cast<char *const *>(
+      launch_info.GetArguments().GetConstArgumentVector());
+  char *const *envp = const_cast<char *const *>(
+      launch_info.GetEnvironmentEntries().GetConstArgumentVector());
+  if (argv == NULL) {
+    // posix_spawn gets very unhappy if it doesn't have at least the program
+    // name in argv[0]. One of the side affects I have noticed is the
+    // environment
+    // variables don't make it into the child process if "argv == NULL"!!!
+    tmp_argv[0] = exe_path;
+    tmp_argv[1] = NULL;
+    argv = const_cast<char *const *>(tmp_argv);
+  }
+
+#if !defined(__APPLE__)
+  // manage the working directory
+  char current_dir[PATH_MAX];
+  current_dir[0] = '\0';
+#endif
+
+  FileSpec working_dir{launch_info.GetWorkingDirectory()};
+  if (working_dir) {
+#if defined(__APPLE__)
+    // Set the working directory on this thread only
+    if (__pthread_chdir(working_dir.GetCString()) < 0) {
+      if (errno == ENOENT) {
+        error.SetErrorStringWithFormat("No such file or directory: %s",
+                                       working_dir.GetCString());
+      } else if (errno == ENOTDIR) {
+        error.SetErrorStringWithFormat("Path doesn't name a directory: %s",
+                                       working_dir.GetCString());
+      } else {
+        error.SetErrorStringWithFormat("An unknown error occurred when "
+                                       "changing directory for process "
+                                       "execution.");
+      }
+      return error;
     }
-
-#if !defined (__APPLE__)
-    // manage the working directory
-    char current_dir[PATH_MAX];
-    current_dir[0] = '\0';
-#endif
-
-    FileSpec working_dir{launch_info.GetWorkingDirectory()};
-    if (working_dir)
-    {
-#if defined (__APPLE__)
-        // Set the working directory on this thread only
-        if (__pthread_chdir(working_dir.GetCString()) < 0) {
-            if (errno == ENOENT) {
-                error.SetErrorStringWithFormat("No such file or directory: %s",
-                        working_dir.GetCString());
-            } else if (errno == ENOTDIR) {
-                error.SetErrorStringWithFormat("Path doesn't name a directory: %s",
-                        working_dir.GetCString());
-            } else {
-                error.SetErrorStringWithFormat("An unknown error occurred when changing directory for process execution.");
-            }
-            return error;
-        }
 #else
-        if (::getcwd(current_dir, sizeof(current_dir)) == NULL)
-        {
-            error.SetError(errno, eErrorTypePOSIX);
-            error.LogIfError(log, "unable to save the current directory");
-            return error;
-        }
-
-        if (::chdir(working_dir.GetCString()) == -1)
-        {
-            error.SetError(errno, eErrorTypePOSIX);
-            error.LogIfError(log, "unable to change working directory to %s",
-                    working_dir.GetCString());
-            return error;
-        }
-#endif
-    }
-
-    ::pid_t result_pid = LLDB_INVALID_PROCESS_ID;
-    const size_t num_file_actions = launch_info.GetNumFileActions ();
-    if (num_file_actions > 0)
-    {
-        posix_spawn_file_actions_t file_actions;
-        error.SetError( ::posix_spawn_file_actions_init (&file_actions), eErrorTypePOSIX);
-        if (error.Fail() || log)
-            error.PutToLog(log, "::posix_spawn_file_actions_init ( &file_actions )");
-        if (error.Fail())
-            return error;
-
-        // Make a quick class that will cleanup the posix spawn attributes in case
-        // we return in the middle of this function.
-        lldb_utility::CleanUp <posix_spawn_file_actions_t *, int> posix_spawn_file_actions_cleanup (&file_actions, posix_spawn_file_actions_destroy);
-
-        for (size_t i=0; i<num_file_actions; ++i)
-        {
-            const FileAction *launch_file_action = launch_info.GetFileActionAtIndex(i);
-            if (launch_file_action)
-            {
-                if (!AddPosixSpawnFileAction(&file_actions, launch_file_action, log, error))
-                    return error;
-            }
-        }
-
-        error.SetError(::posix_spawnp(&result_pid, exe_path, &file_actions, &attr, argv, envp), eErrorTypePOSIX);
-
-        if (error.Fail() || log)
-        {
-            error.PutToLog(log, "::posix_spawnp ( pid => %i, path = '%s', file_actions = %p, attr = %p, argv = %p, envp = %p )", result_pid,
-                           exe_path, static_cast<void *>(&file_actions), static_cast<void *>(&attr), reinterpret_cast<const void *>(argv),
-                           reinterpret_cast<const void *>(envp));
-            if (log)
-            {
-                for (int ii=0; argv[ii]; ++ii)
-                    log->Printf("argv[%i] = '%s'", ii, argv[ii]);
-            }
-        }
-
-    }
-    else
-    {
-        error.SetError(::posix_spawnp(&result_pid, exe_path, NULL, &attr, argv, envp), eErrorTypePOSIX);
-
-        if (error.Fail() || log)
-        {
-            error.PutToLog(log, "::posix_spawnp ( pid => %i, path = '%s', file_actions = NULL, attr = %p, argv = %p, envp = %p )",
-                           result_pid, exe_path, static_cast<void *>(&attr), reinterpret_cast<const void *>(argv),
-                           reinterpret_cast<const void *>(envp));
-            if (log)
-            {
-                for (int ii=0; argv[ii]; ++ii)
-                    log->Printf("argv[%i] = '%s'", ii, argv[ii]);
-            }
-        }
-    }
-    pid = result_pid;
+    if (::getcwd(current_dir, sizeof(current_dir)) == NULL) {
+      error.SetError(errno, eErrorTypePOSIX);
+      error.LogIfError(log, "unable to save the current directory");
+      return error;
+    }
+
+    if (::chdir(working_dir.GetCString()) == -1) {
+      error.SetError(errno, eErrorTypePOSIX);
+      error.LogIfError(log, "unable to change working directory to %s",
+                       working_dir.GetCString());
+      return error;
+    }
+#endif
+  }
+
+  ::pid_t result_pid = LLDB_INVALID_PROCESS_ID;
+  const size_t num_file_actions = launch_info.GetNumFileActions();
+  if (num_file_actions > 0) {
+    posix_spawn_file_actions_t file_actions;
+    error.SetError(::posix_spawn_file_actions_init(&file_actions),
+                   eErrorTypePOSIX);
+    if (error.Fail() || log)
+      error.PutToLog(log, "::posix_spawn_file_actions_init ( &file_actions )");
+    if (error.Fail())
+      return error;
 
-    if (working_dir)
-    {
-#if defined (__APPLE__)
-        // No more thread specific current working directory
-        __pthread_fchdir (-1);
+    // Make a quick class that will cleanup the posix spawn attributes in case
+    // we return in the middle of this function.
+    lldb_utility::CleanUp<posix_spawn_file_actions_t *, int>
+        posix_spawn_file_actions_cleanup(&file_actions,
+                                         posix_spawn_file_actions_destroy);
+
+    for (size_t i = 0; i < num_file_actions; ++i) {
+      const FileAction *launch_file_action =
+          launch_info.GetFileActionAtIndex(i);
+      if (launch_file_action) {
+        if (!AddPosixSpawnFileAction(&file_actions, launch_file_action, log,
+                                     error))
+          return error;
+      }
+    }
+
+    error.SetError(
+        ::posix_spawnp(&result_pid, exe_path, &file_actions, &attr, argv, envp),
+        eErrorTypePOSIX);
+
+    if (error.Fail() || log) {
+      error.PutToLog(
+          log, "::posix_spawnp ( pid => %i, path = '%s', file_actions = %p, "
+               "attr = %p, argv = %p, envp = %p )",
+          result_pid, exe_path, static_cast<void *>(&file_actions),
+          static_cast<void *>(&attr), reinterpret_cast<const void *>(argv),
+          reinterpret_cast<const void *>(envp));
+      if (log) {
+        for (int ii = 0; argv[ii]; ++ii)
+          log->Printf("argv[%i] = '%s'", ii, argv[ii]);
+      }
+    }
+
+  } else {
+    error.SetError(
+        ::posix_spawnp(&result_pid, exe_path, NULL, &attr, argv, envp),
+        eErrorTypePOSIX);
+
+    if (error.Fail() || log) {
+      error.PutToLog(log, "::posix_spawnp ( pid => %i, path = '%s', "
+                          "file_actions = NULL, attr = %p, argv = %p, envp = "
+                          "%p )",
+                     result_pid, exe_path, static_cast<void *>(&attr),
+                     reinterpret_cast<const void *>(argv),
+                     reinterpret_cast<const void *>(envp));
+      if (log) {
+        for (int ii = 0; argv[ii]; ++ii)
+          log->Printf("argv[%i] = '%s'", ii, argv[ii]);
+      }
+    }
+  }
+  pid = result_pid;
+
+  if (working_dir) {
+#if defined(__APPLE__)
+    // No more thread specific current working directory
+    __pthread_fchdir(-1);
 #else
-        if (::chdir(current_dir) == -1 && error.Success())
-        {
-            error.SetError(errno, eErrorTypePOSIX);
-            error.LogIfError(log, "unable to change current directory back to %s",
-                    current_dir);
-        }
-#endif
+    if (::chdir(current_dir) == -1 && error.Success()) {
+      error.SetError(errno, eErrorTypePOSIX);
+      error.LogIfError(log, "unable to change current directory back to %s",
+                       current_dir);
     }
+#endif
+  }
 
-    return error;
+  return error;
 }
 
-bool
-Host::AddPosixSpawnFileAction(void *_file_actions, const FileAction *info, Log *log, Error &error)
-{
-    if (info == NULL)
-        return false;
-
-    posix_spawn_file_actions_t *file_actions = reinterpret_cast<posix_spawn_file_actions_t *>(_file_actions);
-
-    switch (info->GetAction())
-    {
-        case FileAction::eFileActionNone:
-            error.Clear();
-            break;
-
-        case FileAction::eFileActionClose:
-            if (info->GetFD() == -1)
-                error.SetErrorString("invalid fd for posix_spawn_file_actions_addclose(...)");
-            else
-            {
-                error.SetError(::posix_spawn_file_actions_addclose(file_actions, info->GetFD()), eErrorTypePOSIX);
-                if (log && (error.Fail() || log))
-                    error.PutToLog(log, "posix_spawn_file_actions_addclose (action=%p, fd=%i)",
-                                   static_cast<void *>(file_actions), info->GetFD());
-            }
-            break;
+bool Host::AddPosixSpawnFileAction(void *_file_actions, const FileAction *info,
+                                   Log *log, Error &error) {
+  if (info == NULL)
+    return false;
 
-        case FileAction::eFileActionDuplicate:
-            if (info->GetFD() == -1)
-                error.SetErrorString("invalid fd for posix_spawn_file_actions_adddup2(...)");
-            else if (info->GetActionArgument() == -1)
-                error.SetErrorString("invalid duplicate fd for posix_spawn_file_actions_adddup2(...)");
-            else
-            {
-                error.SetError(
-                    ::posix_spawn_file_actions_adddup2(file_actions, info->GetFD(), info->GetActionArgument()),
-                    eErrorTypePOSIX);
-                if (log && (error.Fail() || log))
-                    error.PutToLog(log, "posix_spawn_file_actions_adddup2 (action=%p, fd=%i, dup_fd=%i)",
-                                   static_cast<void *>(file_actions), info->GetFD(), info->GetActionArgument());
-            }
-            break;
+  posix_spawn_file_actions_t *file_actions =
+      reinterpret_cast<posix_spawn_file_actions_t *>(_file_actions);
 
-        case FileAction::eFileActionOpen:
-            if (info->GetFD() == -1)
-                error.SetErrorString("invalid fd in posix_spawn_file_actions_addopen(...)");
-            else
-            {
-                int oflag = info->GetActionArgument();
-
-                mode_t mode = 0;
-
-                if (oflag & O_CREAT)
-                    mode = 0640;
-
-                error.SetError(
-                    ::posix_spawn_file_actions_addopen(file_actions, info->GetFD(), info->GetPath(), oflag, mode),
-                    eErrorTypePOSIX);
-                if (error.Fail() || log)
-                    error.PutToLog(log,
-                                   "posix_spawn_file_actions_addopen (action=%p, fd=%i, path='%s', oflag=%i, mode=%i)",
-                                   static_cast<void *>(file_actions), info->GetFD(), info->GetPath(), oflag, mode);
-            }
-            break;
-    }
-    return error.Success();
+  switch (info->GetAction()) {
+  case FileAction::eFileActionNone:
+    error.Clear();
+    break;
+
+  case FileAction::eFileActionClose:
+    if (info->GetFD() == -1)
+      error.SetErrorString(
+          "invalid fd for posix_spawn_file_actions_addclose(...)");
+    else {
+      error.SetError(
+          ::posix_spawn_file_actions_addclose(file_actions, info->GetFD()),
+          eErrorTypePOSIX);
+      if (log && (error.Fail() || log))
+        error.PutToLog(log,
+                       "posix_spawn_file_actions_addclose (action=%p, fd=%i)",
+                       static_cast<void *>(file_actions), info->GetFD());
+    }
+    break;
+
+  case FileAction::eFileActionDuplicate:
+    if (info->GetFD() == -1)
+      error.SetErrorString(
+          "invalid fd for posix_spawn_file_actions_adddup2(...)");
+    else if (info->GetActionArgument() == -1)
+      error.SetErrorString(
+          "invalid duplicate fd for posix_spawn_file_actions_adddup2(...)");
+    else {
+      error.SetError(
+          ::posix_spawn_file_actions_adddup2(file_actions, info->GetFD(),
+                                             info->GetActionArgument()),
+          eErrorTypePOSIX);
+      if (log && (error.Fail() || log))
+        error.PutToLog(
+            log,
+            "posix_spawn_file_actions_adddup2 (action=%p, fd=%i, dup_fd=%i)",
+            static_cast<void *>(file_actions), info->GetFD(),
+            info->GetActionArgument());
+    }
+    break;
+
+  case FileAction::eFileActionOpen:
+    if (info->GetFD() == -1)
+      error.SetErrorString(
+          "invalid fd in posix_spawn_file_actions_addopen(...)");
+    else {
+      int oflag = info->GetActionArgument();
+
+      mode_t mode = 0;
+
+      if (oflag & O_CREAT)
+        mode = 0640;
+
+      error.SetError(
+          ::posix_spawn_file_actions_addopen(file_actions, info->GetFD(),
+                                             info->GetPath(), oflag, mode),
+          eErrorTypePOSIX);
+      if (error.Fail() || log)
+        error.PutToLog(log, "posix_spawn_file_actions_addopen (action=%p, "
+                            "fd=%i, path='%s', oflag=%i, mode=%i)",
+                       static_cast<void *>(file_actions), info->GetFD(),
+                       info->GetPath(), oflag, mode);
+    }
+    break;
+  }
+  return error.Success();
 }
 #endif // !defined(__ANDROID__) && !defined(__ANDROID_NDK__)
-#endif // defined (__APPLE__) || defined (__linux__) || defined (__FreeBSD__) || defined (__GLIBC__) || defined(__NetBSD__)
+#endif // defined (__APPLE__) || defined (__linux__) || defined (__FreeBSD__) ||
+       // defined (__GLIBC__) || defined(__NetBSD__)
 
-#if defined(__linux__) || defined(__FreeBSD__) || defined(__GLIBC__) || defined(__NetBSD__) || defined(_WIN32)
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__GLIBC__) ||        \
+    defined(__NetBSD__) || defined(_WIN32)
 // The functions below implement process launching via posix_spawn() for Linux,
 // FreeBSD and NetBSD.
 
-Error
-Host::LaunchProcess (ProcessLaunchInfo &launch_info)
-{
-    std::unique_ptr<ProcessLauncher> delegate_launcher;
+Error Host::LaunchProcess(ProcessLaunchInfo &launch_info) {
+  std::unique_ptr<ProcessLauncher> delegate_launcher;
 #if defined(_WIN32)
-    delegate_launcher.reset(new ProcessLauncherWindows());
+  delegate_launcher.reset(new ProcessLauncherWindows());
 #elif defined(__linux__)
-    delegate_launcher.reset(new ProcessLauncherLinux());
+  delegate_launcher.reset(new ProcessLauncherLinux());
 #else
-    delegate_launcher.reset(new ProcessLauncherPosix());
+  delegate_launcher.reset(new ProcessLauncherPosix());
 #endif
-    MonitoringProcessLauncher launcher(std::move(delegate_launcher));
+  MonitoringProcessLauncher launcher(std::move(delegate_launcher));
 
-    Error error;
-    HostProcess process = launcher.LaunchProcess(launch_info, error);
+  Error error;
+  HostProcess process = launcher.LaunchProcess(launch_info, error);
 
-    // TODO(zturner): It would be better if the entire HostProcess were returned instead of writing
-    // it into this structure.
-    launch_info.SetProcessID(process.GetProcessId());
+  // TODO(zturner): It would be better if the entire HostProcess were returned
+  // instead of writing
+  // it into this structure.
+  launch_info.SetProcessID(process.GetProcessId());
 
-    return error;
+  return error;
 }
 #endif // defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
 
 #ifndef _WIN32
-void
-Host::Kill(lldb::pid_t pid, int signo)
-{
-    ::kill(pid, signo);
-}
+void Host::Kill(lldb::pid_t pid, int signo) { ::kill(pid, signo); }
 
 #endif
 
-#if !defined (__APPLE__)
-bool
-Host::OpenFileInExternalEditor (const FileSpec &file_spec, uint32_t line_no)
-{
-    return false;
+#if !defined(__APPLE__)
+bool Host::OpenFileInExternalEditor(const FileSpec &file_spec,
+                                    uint32_t line_no) {
+  return false;
 }
 
-void
-Host::SetCrashDescriptionWithFormat (const char *format, ...)
-{
-}
+void Host::SetCrashDescriptionWithFormat(const char *format, ...) {}
 
-void
-Host::SetCrashDescription (const char *description)
-{
-}
+void Host::SetCrashDescription(const char *description) {}
 
 #endif
 
-const UnixSignalsSP &
-Host::GetUnixSignals()
-{
-    static const auto s_unix_signals_sp = UnixSignals::Create(HostInfo::GetArchitecture());
-    return s_unix_signals_sp;
+const UnixSignalsSP &Host::GetUnixSignals() {
+  static const auto s_unix_signals_sp =
+      UnixSignals::Create(HostInfo::GetArchitecture());
+  return s_unix_signals_sp;
 }

Modified: lldb/trunk/source/Host/common/HostInfoBase.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/HostInfoBase.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/HostInfoBase.cpp (original)
+++ lldb/trunk/source/Host/common/HostInfoBase.cpp Tue Sep  6 15:57:50 2016
@@ -24,405 +24,372 @@
 #include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/raw_ostream.h"
 
-#include <thread>
 #include <mutex> // std::once
+#include <thread>
 
 using namespace lldb;
 using namespace lldb_private;
 
-namespace
-{
-    //----------------------------------------------------------------------
-    // The HostInfoBaseFields is a work around for windows not supporting
-    // static variables correctly in a thread safe way. Really each of the
-    // variables in HostInfoBaseFields should live in the functions in which
-    // they are used and each one should be static, but the work around is
-    // in place to avoid this restriction. Ick.
-    //----------------------------------------------------------------------
-
-    struct HostInfoBaseFields
-    {
-        ~HostInfoBaseFields()
-        {
-            if (m_lldb_process_tmp_dir.Exists())
-            {
-                // Remove the LLDB temporary directory if we have one. Set "recurse" to
-                // true to all files that were created for the LLDB process can be cleaned up.
-                FileSystem::DeleteDirectory(m_lldb_process_tmp_dir, true);
-            }
-        }
-
-        uint32_t m_number_cpus;
-        std::string m_vendor_string;
-        std::string m_os_string;
-        std::string m_host_triple;
-
-        ArchSpec m_host_arch_32;
-        ArchSpec m_host_arch_64;
-
-        FileSpec m_lldb_so_dir;
-        FileSpec m_lldb_support_exe_dir;
-        FileSpec m_lldb_headers_dir;
-        FileSpec m_lldb_python_dir;
-        FileSpec m_lldb_clang_resource_dir;
-        FileSpec m_lldb_system_plugin_dir;
-        FileSpec m_lldb_user_plugin_dir;
-        FileSpec m_lldb_process_tmp_dir;
-        FileSpec m_lldb_global_tmp_dir;
-    };
-    
-    HostInfoBaseFields *g_fields = nullptr;
-}
-
-void
-HostInfoBase::Initialize()
-{
-    g_fields = new HostInfoBaseFields();
-}
-
-void
-HostInfoBase::Terminate()
-{
-    delete g_fields;
-    g_fields = nullptr;
-}
-
-uint32_t
-HostInfoBase::GetNumberCPUS()
-{
-    static std::once_flag g_once_flag;
-    std::call_once(g_once_flag,  []() {
-        g_fields->m_number_cpus = std::thread::hardware_concurrency();
-    });
-    return g_fields->m_number_cpus;
-}
+namespace {
+//----------------------------------------------------------------------
+// The HostInfoBaseFields is a work around for windows not supporting
+// static variables correctly in a thread safe way. Really each of the
+// variables in HostInfoBaseFields should live in the functions in which
+// they are used and each one should be static, but the work around is
+// in place to avoid this restriction. Ick.
+//----------------------------------------------------------------------
+
+struct HostInfoBaseFields {
+  ~HostInfoBaseFields() {
+    if (m_lldb_process_tmp_dir.Exists()) {
+      // Remove the LLDB temporary directory if we have one. Set "recurse" to
+      // true to all files that were created for the LLDB process can be cleaned
+      // up.
+      FileSystem::DeleteDirectory(m_lldb_process_tmp_dir, true);
+    }
+  }
 
-uint32_t
-HostInfoBase::GetMaxThreadNameLength()
-{
-    return 0;
+  uint32_t m_number_cpus;
+  std::string m_vendor_string;
+  std::string m_os_string;
+  std::string m_host_triple;
+
+  ArchSpec m_host_arch_32;
+  ArchSpec m_host_arch_64;
+
+  FileSpec m_lldb_so_dir;
+  FileSpec m_lldb_support_exe_dir;
+  FileSpec m_lldb_headers_dir;
+  FileSpec m_lldb_python_dir;
+  FileSpec m_lldb_clang_resource_dir;
+  FileSpec m_lldb_system_plugin_dir;
+  FileSpec m_lldb_user_plugin_dir;
+  FileSpec m_lldb_process_tmp_dir;
+  FileSpec m_lldb_global_tmp_dir;
+};
+
+HostInfoBaseFields *g_fields = nullptr;
+}
+
+void HostInfoBase::Initialize() { g_fields = new HostInfoBaseFields(); }
+
+void HostInfoBase::Terminate() {
+  delete g_fields;
+  g_fields = nullptr;
+}
+
+uint32_t HostInfoBase::GetNumberCPUS() {
+  static std::once_flag g_once_flag;
+  std::call_once(g_once_flag, []() {
+    g_fields->m_number_cpus = std::thread::hardware_concurrency();
+  });
+  return g_fields->m_number_cpus;
+}
+
+uint32_t HostInfoBase::GetMaxThreadNameLength() { return 0; }
+
+llvm::StringRef HostInfoBase::GetVendorString() {
+  static std::once_flag g_once_flag;
+  std::call_once(g_once_flag, []() {
+    g_fields->m_vendor_string =
+        HostInfo::GetArchitecture().GetTriple().getVendorName().str();
+  });
+  return g_fields->m_vendor_string;
+}
+
+llvm::StringRef HostInfoBase::GetOSString() {
+  static std::once_flag g_once_flag;
+  std::call_once(g_once_flag, []() {
+    g_fields->m_os_string =
+        std::move(HostInfo::GetArchitecture().GetTriple().getOSName());
+  });
+  return g_fields->m_os_string;
+}
+
+llvm::StringRef HostInfoBase::GetTargetTriple() {
+  static std::once_flag g_once_flag;
+  std::call_once(g_once_flag, []() {
+    g_fields->m_host_triple =
+        HostInfo::GetArchitecture().GetTriple().getTriple();
+  });
+  return g_fields->m_host_triple;
+}
+
+const ArchSpec &HostInfoBase::GetArchitecture(ArchitectureKind arch_kind) {
+  static std::once_flag g_once_flag;
+  std::call_once(g_once_flag, []() {
+    HostInfo::ComputeHostArchitectureSupport(g_fields->m_host_arch_32,
+                                             g_fields->m_host_arch_64);
+  });
+
+  // If an explicit 32 or 64-bit architecture was requested, return that.
+  if (arch_kind == eArchKind32)
+    return g_fields->m_host_arch_32;
+  if (arch_kind == eArchKind64)
+    return g_fields->m_host_arch_64;
+
+  // Otherwise prefer the 64-bit architecture if it is valid.
+  return (g_fields->m_host_arch_64.IsValid()) ? g_fields->m_host_arch_64
+                                              : g_fields->m_host_arch_32;
 }
 
-llvm::StringRef
-HostInfoBase::GetVendorString()
-{
+bool HostInfoBase::GetLLDBPath(lldb::PathType type, FileSpec &file_spec) {
+  file_spec.Clear();
+
+#if defined(LLDB_DISABLE_PYTHON)
+  if (type == lldb::ePathTypePythonDir)
+    return false;
+#endif
+
+  FileSpec *result = nullptr;
+  switch (type) {
+  case lldb::ePathTypeLLDBShlibDir: {
     static std::once_flag g_once_flag;
-    std::call_once(g_once_flag,  []() {
-        g_fields->m_vendor_string = HostInfo::GetArchitecture().GetTriple().getVendorName().str();
+    static bool success = false;
+    std::call_once(g_once_flag, []() {
+      success =
+          HostInfo::ComputeSharedLibraryDirectory(g_fields->m_lldb_so_dir);
+      Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+      if (log)
+        log->Printf("HostInfoBase::GetLLDBPath(ePathTypeLLDBShlibDir) => '%s'",
+                    g_fields->m_lldb_so_dir.GetPath().c_str());
     });
-    return g_fields->m_vendor_string;
-}
-
-llvm::StringRef
-HostInfoBase::GetOSString()
-{
+    if (success)
+      result = &g_fields->m_lldb_so_dir;
+  } break;
+  case lldb::ePathTypeSupportExecutableDir: {
     static std::once_flag g_once_flag;
-    std::call_once(g_once_flag,  []() {
-        g_fields->m_os_string = std::move(HostInfo::GetArchitecture().GetTriple().getOSName());
+    static bool success = false;
+    std::call_once(g_once_flag, []() {
+      success = HostInfo::ComputeSupportExeDirectory(
+          g_fields->m_lldb_support_exe_dir);
+      Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+      if (log)
+        log->Printf(
+            "HostInfoBase::GetLLDBPath(ePathTypeSupportExecutableDir) => '%s'",
+            g_fields->m_lldb_support_exe_dir.GetPath().c_str());
     });
-    return g_fields->m_os_string;
-}
-
-llvm::StringRef
-HostInfoBase::GetTargetTriple()
-{
+    if (success)
+      result = &g_fields->m_lldb_support_exe_dir;
+  } break;
+  case lldb::ePathTypeHeaderDir: {
     static std::once_flag g_once_flag;
-    std::call_once(g_once_flag,  []() {
-        g_fields->m_host_triple = HostInfo::GetArchitecture().GetTriple().getTriple();
+    static bool success = false;
+    std::call_once(g_once_flag, []() {
+      success = HostInfo::ComputeHeaderDirectory(g_fields->m_lldb_headers_dir);
+      Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+      if (log)
+        log->Printf("HostInfoBase::GetLLDBPath(ePathTypeHeaderDir) => '%s'",
+                    g_fields->m_lldb_headers_dir.GetPath().c_str());
     });
-    return g_fields->m_host_triple;
-}
-
-const ArchSpec &
-HostInfoBase::GetArchitecture(ArchitectureKind arch_kind)
-{
+    if (success)
+      result = &g_fields->m_lldb_headers_dir;
+  } break;
+  case lldb::ePathTypePythonDir: {
+    static std::once_flag g_once_flag;
+    static bool success = false;
+    std::call_once(g_once_flag, []() {
+      success = HostInfo::ComputePythonDirectory(g_fields->m_lldb_python_dir);
+      Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+      if (log)
+        log->Printf("HostInfoBase::GetLLDBPath(ePathTypePythonDir) => '%s'",
+                    g_fields->m_lldb_python_dir.GetPath().c_str());
+    });
+    if (success)
+      result = &g_fields->m_lldb_python_dir;
+  } break;
+  case lldb::ePathTypeClangDir: {
+    static std::once_flag g_once_flag;
+    static bool success = false;
+    std::call_once(g_once_flag, []() {
+      success =
+          HostInfo::ComputeClangDirectory(g_fields->m_lldb_clang_resource_dir);
+      Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+      if (log)
+        log->Printf(
+            "HostInfoBase::GetLLDBPath(ePathTypeClangResourceDir) => '%s'",
+            g_fields->m_lldb_clang_resource_dir.GetPath().c_str());
+    });
+    if (success)
+      result = &g_fields->m_lldb_clang_resource_dir;
+  } break;
+  case lldb::ePathTypeLLDBSystemPlugins: {
     static std::once_flag g_once_flag;
-    std::call_once(g_once_flag,  []() {
-        HostInfo::ComputeHostArchitectureSupport(g_fields->m_host_arch_32, g_fields->m_host_arch_64);
+    static bool success = false;
+    std::call_once(g_once_flag, []() {
+      success = HostInfo::ComputeSystemPluginsDirectory(
+          g_fields->m_lldb_system_plugin_dir);
+      Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+      if (log)
+        log->Printf(
+            "HostInfoBase::GetLLDBPath(ePathTypeLLDBSystemPlugins) => '%s'",
+            g_fields->m_lldb_system_plugin_dir.GetPath().c_str());
     });
+    if (success)
+      result = &g_fields->m_lldb_system_plugin_dir;
+  } break;
+  case lldb::ePathTypeLLDBUserPlugins: {
+    static std::once_flag g_once_flag;
+    static bool success = false;
+    std::call_once(g_once_flag, []() {
+      success = HostInfo::ComputeUserPluginsDirectory(
+          g_fields->m_lldb_user_plugin_dir);
+      Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+      if (log)
+        log->Printf(
+            "HostInfoBase::GetLLDBPath(ePathTypeLLDBUserPlugins) => '%s'",
+            g_fields->m_lldb_user_plugin_dir.GetPath().c_str());
+    });
+    if (success)
+      result = &g_fields->m_lldb_user_plugin_dir;
+  } break;
+  case lldb::ePathTypeLLDBTempSystemDir: {
+    static std::once_flag g_once_flag;
+    static bool success = false;
+    std::call_once(g_once_flag, []() {
+      success = HostInfo::ComputeProcessTempFileDirectory(
+          g_fields->m_lldb_process_tmp_dir);
+      Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+      if (log)
+        log->Printf(
+            "HostInfoBase::GetLLDBPath(ePathTypeLLDBTempSystemDir) => '%s'",
+            g_fields->m_lldb_process_tmp_dir.GetPath().c_str());
+    });
+    if (success)
+      result = &g_fields->m_lldb_process_tmp_dir;
+  } break;
+  case lldb::ePathTypeGlobalLLDBTempSystemDir: {
+    static std::once_flag g_once_flag;
+    static bool success = false;
+    std::call_once(g_once_flag, []() {
+      success = HostInfo::ComputeGlobalTempFileDirectory(
+          g_fields->m_lldb_global_tmp_dir);
+      Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+      if (log)
+        log->Printf("HostInfoBase::GetLLDBPath("
+                    "ePathTypeGlobalLLDBTempSystemDir) => '%s'",
+                    g_fields->m_lldb_global_tmp_dir.GetPath().c_str());
+    });
+    if (success)
+      result = &g_fields->m_lldb_global_tmp_dir;
+  } break;
+  }
 
-    // If an explicit 32 or 64-bit architecture was requested, return that.
-    if (arch_kind == eArchKind32)
-        return g_fields->m_host_arch_32;
-    if (arch_kind == eArchKind64)
-        return g_fields->m_host_arch_64;
-
-    // Otherwise prefer the 64-bit architecture if it is valid.
-    return (g_fields->m_host_arch_64.IsValid()) ? g_fields->m_host_arch_64 : g_fields->m_host_arch_32;
+  if (!result)
+    return false;
+  file_spec = *result;
+  return true;
 }
 
-bool
-HostInfoBase::GetLLDBPath(lldb::PathType type, FileSpec &file_spec)
-{
-    file_spec.Clear();
+bool HostInfoBase::ComputeSharedLibraryDirectory(FileSpec &file_spec) {
+  // To get paths related to LLDB we get the path to the executable that
+  // contains this function. On MacOSX this will be "LLDB.framework/.../LLDB",
+  // on linux this is assumed to be the "lldb" main executable. If LLDB on
+  // linux is actually in a shared library (liblldb.so) then this function will
+  // need to be modified to "do the right thing".
 
-#if defined(LLDB_DISABLE_PYTHON)
-    if (type == lldb::ePathTypePythonDir)
-        return false;
-#endif
+  FileSpec lldb_file_spec(
+      Host::GetModuleFileSpecForHostAddress(reinterpret_cast<void *>(
+          reinterpret_cast<intptr_t>(HostInfoBase::GetLLDBPath))));
 
-    FileSpec *result = nullptr;
-    switch (type)
-    {
-        case lldb::ePathTypeLLDBShlibDir:
-            {
-                static std::once_flag g_once_flag;
-                static bool success = false;
-                std::call_once(g_once_flag,  []() {
-                    success = HostInfo::ComputeSharedLibraryDirectory (g_fields->m_lldb_so_dir);
-                    Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
-                    if (log)
-                        log->Printf("HostInfoBase::GetLLDBPath(ePathTypeLLDBShlibDir) => '%s'", g_fields->m_lldb_so_dir.GetPath().c_str());
-                });
-                if (success)
-                    result = &g_fields->m_lldb_so_dir;
-            }
-            break;
-        case lldb::ePathTypeSupportExecutableDir:
-            {
-                static std::once_flag g_once_flag;
-                static bool success = false;
-                std::call_once(g_once_flag,  []() {
-                    success = HostInfo::ComputeSupportExeDirectory (g_fields->m_lldb_support_exe_dir);
-                    Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
-                    if (log)
-                        log->Printf("HostInfoBase::GetLLDBPath(ePathTypeSupportExecutableDir) => '%s'",
-                                    g_fields->m_lldb_support_exe_dir.GetPath().c_str());
-                });
-                if (success)
-                    result = &g_fields->m_lldb_support_exe_dir;
-            }
-            break;
-        case lldb::ePathTypeHeaderDir:
-            {
-                static std::once_flag g_once_flag;
-                static bool success = false;
-                std::call_once(g_once_flag,  []() {
-                    success = HostInfo::ComputeHeaderDirectory (g_fields->m_lldb_headers_dir);
-                    Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
-                    if (log)
-                        log->Printf("HostInfoBase::GetLLDBPath(ePathTypeHeaderDir) => '%s'", g_fields->m_lldb_headers_dir.GetPath().c_str());
-                });
-                if (success)
-                    result = &g_fields->m_lldb_headers_dir;
-            }
-            break;
-        case lldb::ePathTypePythonDir:
-            {
-                static std::once_flag g_once_flag;
-                static bool success = false;
-                std::call_once(g_once_flag,  []() {
-                    success = HostInfo::ComputePythonDirectory (g_fields->m_lldb_python_dir);
-                    Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
-                    if (log)
-                        log->Printf("HostInfoBase::GetLLDBPath(ePathTypePythonDir) => '%s'", g_fields->m_lldb_python_dir.GetPath().c_str());
-                });
-                if (success)
-                    result = &g_fields->m_lldb_python_dir;
-            }
-            break;
-        case lldb::ePathTypeClangDir:
-            {
-                static std::once_flag g_once_flag;
-                static bool success = false;
-                std::call_once(g_once_flag,  []() {
-                    success = HostInfo::ComputeClangDirectory (g_fields->m_lldb_clang_resource_dir);
-                    Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
-                    if (log)
-                        log->Printf("HostInfoBase::GetLLDBPath(ePathTypeClangResourceDir) => '%s'", g_fields->m_lldb_clang_resource_dir.GetPath().c_str());
-                });
-                if (success)
-                    result = &g_fields->m_lldb_clang_resource_dir;
-            }
-            break;
-        case lldb::ePathTypeLLDBSystemPlugins:
-            {
-                static std::once_flag g_once_flag;
-                static bool success = false;
-                std::call_once(g_once_flag,  []() {
-                    success = HostInfo::ComputeSystemPluginsDirectory (g_fields->m_lldb_system_plugin_dir);
-                    Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
-                    if (log)
-                        log->Printf("HostInfoBase::GetLLDBPath(ePathTypeLLDBSystemPlugins) => '%s'",
-                                    g_fields->m_lldb_system_plugin_dir.GetPath().c_str());
-                });
-                if (success)
-                    result = &g_fields->m_lldb_system_plugin_dir;
-            }
-            break;
-        case lldb::ePathTypeLLDBUserPlugins:
-            {
-                static std::once_flag g_once_flag;
-                static bool success = false;
-                std::call_once(g_once_flag,  []() {
-                    success = HostInfo::ComputeUserPluginsDirectory (g_fields->m_lldb_user_plugin_dir);
-                    Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
-                    if (log)
-                        log->Printf("HostInfoBase::GetLLDBPath(ePathTypeLLDBUserPlugins) => '%s'",
-                                    g_fields->m_lldb_user_plugin_dir.GetPath().c_str());
-                });
-                if (success)
-                    result = &g_fields->m_lldb_user_plugin_dir;
-            }
-            break;
-        case lldb::ePathTypeLLDBTempSystemDir:
-            {
-                static std::once_flag g_once_flag;
-                static bool success = false;
-                std::call_once(g_once_flag,  []() {
-                    success = HostInfo::ComputeProcessTempFileDirectory (g_fields->m_lldb_process_tmp_dir);
-                    Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
-                    if (log)
-                        log->Printf("HostInfoBase::GetLLDBPath(ePathTypeLLDBTempSystemDir) => '%s'", g_fields->m_lldb_process_tmp_dir.GetPath().c_str());
-                });
-                if (success)
-                    result = &g_fields->m_lldb_process_tmp_dir;
-            }
-            break;
-        case lldb::ePathTypeGlobalLLDBTempSystemDir:
-            {
-                static std::once_flag g_once_flag;
-                static bool success = false;
-                std::call_once(g_once_flag,  []() {
-                    success = HostInfo::ComputeGlobalTempFileDirectory (g_fields->m_lldb_global_tmp_dir);
-                    Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
-                    if (log)
-                        log->Printf("HostInfoBase::GetLLDBPath(ePathTypeGlobalLLDBTempSystemDir) => '%s'", g_fields->m_lldb_global_tmp_dir.GetPath().c_str());
-                });
-                if (success)
-                    result = &g_fields->m_lldb_global_tmp_dir;
-            }
-            break;
-    }
+  // This is necessary because when running the testsuite the shlib might be a
+  // symbolic link inside the Python resource dir.
+  FileSystem::ResolveSymbolicLink(lldb_file_spec, lldb_file_spec);
 
-    if (!result)
-        return false;
-    file_spec = *result;
-    return true;
-}
-
-bool
-HostInfoBase::ComputeSharedLibraryDirectory(FileSpec &file_spec)
-{
-    // To get paths related to LLDB we get the path to the executable that
-    // contains this function. On MacOSX this will be "LLDB.framework/.../LLDB",
-    // on linux this is assumed to be the "lldb" main executable. If LLDB on
-    // linux is actually in a shared library (liblldb.so) then this function will
-    // need to be modified to "do the right thing".
-
-    FileSpec lldb_file_spec(
-        Host::GetModuleFileSpecForHostAddress(reinterpret_cast<void *>(reinterpret_cast<intptr_t>(HostInfoBase::GetLLDBPath))));
-    
-    // This is necessary because when running the testsuite the shlib might be a symbolic link inside the Python resource dir.
-    FileSystem::ResolveSymbolicLink(lldb_file_spec, lldb_file_spec);
-    
-    // Remove the filename so that this FileSpec only represents the directory.
-    file_spec.GetDirectory() = lldb_file_spec.GetDirectory();
-
-    return (bool)file_spec.GetDirectory();
-}
-
-bool
-HostInfoBase::ComputeSupportExeDirectory(FileSpec &file_spec)
-{
-    return GetLLDBPath(lldb::ePathTypeLLDBShlibDir, file_spec);
-}
-
-bool
-HostInfoBase::ComputeProcessTempFileDirectory(FileSpec &file_spec)
-{
-    FileSpec temp_file_spec;
-    if (!HostInfo::ComputeGlobalTempFileDirectory(temp_file_spec))
-        return false;
-
-    std::string pid_str{llvm::to_string(Host::GetCurrentProcessID())};
-    temp_file_spec.AppendPathComponent(pid_str);
-    if (!FileSystem::MakeDirectory(temp_file_spec, eFilePermissionsDirectoryDefault).Success())
-        return false;
-
-    file_spec.GetDirectory().SetCString(temp_file_spec.GetCString());
-    return true;
-}
-
-bool
-HostInfoBase::ComputeTempFileBaseDirectory(FileSpec &file_spec)
-{
-    llvm::SmallVector<char, 16> tmpdir;
-    llvm::sys::path::system_temp_directory(/*ErasedOnReboot*/ true, tmpdir);
-    file_spec = FileSpec(std::string(tmpdir.data(), tmpdir.size()), true);
-    return true;
-}
-
-bool
-HostInfoBase::ComputeGlobalTempFileDirectory(FileSpec &file_spec)
-{
-    file_spec.Clear();
-
-    FileSpec temp_file_spec;
-    if (!HostInfo::ComputeTempFileBaseDirectory(temp_file_spec))
-        return false;
-
-    temp_file_spec.AppendPathComponent("lldb");
-    if (!FileSystem::MakeDirectory(temp_file_spec, eFilePermissionsDirectoryDefault).Success())
-        return false;
-
-    file_spec.GetDirectory().SetCString(temp_file_spec.GetCString());
-    return true;
-}
-
-bool
-HostInfoBase::ComputeHeaderDirectory(FileSpec &file_spec)
-{
-    // TODO(zturner): Figure out how to compute the header directory for all platforms.
-    return false;
+  // Remove the filename so that this FileSpec only represents the directory.
+  file_spec.GetDirectory() = lldb_file_spec.GetDirectory();
+
+  return (bool)file_spec.GetDirectory();
 }
 
-bool
-HostInfoBase::ComputeSystemPluginsDirectory(FileSpec &file_spec)
-{
-    // TODO(zturner): Figure out how to compute the system plugins directory for all platforms.
-    return false;
+bool HostInfoBase::ComputeSupportExeDirectory(FileSpec &file_spec) {
+  return GetLLDBPath(lldb::ePathTypeLLDBShlibDir, file_spec);
 }
 
-bool
-HostInfoBase::ComputeClangDirectory(FileSpec &file_spec)
-{
+bool HostInfoBase::ComputeProcessTempFileDirectory(FileSpec &file_spec) {
+  FileSpec temp_file_spec;
+  if (!HostInfo::ComputeGlobalTempFileDirectory(temp_file_spec))
+    return false;
+
+  std::string pid_str{llvm::to_string(Host::GetCurrentProcessID())};
+  temp_file_spec.AppendPathComponent(pid_str);
+  if (!FileSystem::MakeDirectory(temp_file_spec,
+                                 eFilePermissionsDirectoryDefault)
+           .Success())
     return false;
+
+  file_spec.GetDirectory().SetCString(temp_file_spec.GetCString());
+  return true;
+}
+
+bool HostInfoBase::ComputeTempFileBaseDirectory(FileSpec &file_spec) {
+  llvm::SmallVector<char, 16> tmpdir;
+  llvm::sys::path::system_temp_directory(/*ErasedOnReboot*/ true, tmpdir);
+  file_spec = FileSpec(std::string(tmpdir.data(), tmpdir.size()), true);
+  return true;
 }
 
-bool
-HostInfoBase::ComputeUserPluginsDirectory(FileSpec &file_spec)
-{
-    // TODO(zturner): Figure out how to compute the user plugins directory for all platforms.
+bool HostInfoBase::ComputeGlobalTempFileDirectory(FileSpec &file_spec) {
+  file_spec.Clear();
+
+  FileSpec temp_file_spec;
+  if (!HostInfo::ComputeTempFileBaseDirectory(temp_file_spec))
+    return false;
+
+  temp_file_spec.AppendPathComponent("lldb");
+  if (!FileSystem::MakeDirectory(temp_file_spec,
+                                 eFilePermissionsDirectoryDefault)
+           .Success())
     return false;
+
+  file_spec.GetDirectory().SetCString(temp_file_spec.GetCString());
+  return true;
 }
 
-void
-HostInfoBase::ComputeHostArchitectureSupport(ArchSpec &arch_32, ArchSpec &arch_64)
-{
-    llvm::Triple triple(llvm::sys::getProcessTriple());
-
-    arch_32.Clear();
-    arch_64.Clear();
-
-    switch (triple.getArch())
-    {
-        default:
-            arch_32.SetTriple(triple);
-            break;
-
-        case llvm::Triple::aarch64:
-        case llvm::Triple::ppc64:
-        case llvm::Triple::x86_64:
-            arch_64.SetTriple(triple);
-            arch_32.SetTriple(triple.get32BitArchVariant());
-            break;
-
-        case llvm::Triple::mips64:
-        case llvm::Triple::mips64el:
-        case llvm::Triple::sparcv9:
-        case llvm::Triple::systemz:
-            arch_64.SetTriple(triple);
-            break;
-    }
+bool HostInfoBase::ComputeHeaderDirectory(FileSpec &file_spec) {
+  // TODO(zturner): Figure out how to compute the header directory for all
+  // platforms.
+  return false;
+}
+
+bool HostInfoBase::ComputeSystemPluginsDirectory(FileSpec &file_spec) {
+  // TODO(zturner): Figure out how to compute the system plugins directory for
+  // all platforms.
+  return false;
+}
+
+bool HostInfoBase::ComputeClangDirectory(FileSpec &file_spec) { return false; }
+
+bool HostInfoBase::ComputeUserPluginsDirectory(FileSpec &file_spec) {
+  // TODO(zturner): Figure out how to compute the user plugins directory for all
+  // platforms.
+  return false;
+}
+
+void HostInfoBase::ComputeHostArchitectureSupport(ArchSpec &arch_32,
+                                                  ArchSpec &arch_64) {
+  llvm::Triple triple(llvm::sys::getProcessTriple());
+
+  arch_32.Clear();
+  arch_64.Clear();
+
+  switch (triple.getArch()) {
+  default:
+    arch_32.SetTriple(triple);
+    break;
+
+  case llvm::Triple::aarch64:
+  case llvm::Triple::ppc64:
+  case llvm::Triple::x86_64:
+    arch_64.SetTriple(triple);
+    arch_32.SetTriple(triple.get32BitArchVariant());
+    break;
+
+  case llvm::Triple::mips64:
+  case llvm::Triple::mips64el:
+  case llvm::Triple::sparcv9:
+  case llvm::Triple::systemz:
+    arch_64.SetTriple(triple);
+    break;
+  }
 }

Modified: lldb/trunk/source/Host/common/HostNativeThreadBase.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/HostNativeThreadBase.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/HostNativeThreadBase.cpp (original)
+++ lldb/trunk/source/Host/common/HostNativeThreadBase.cpp Tue Sep  6 15:57:50 2016
@@ -7,9 +7,9 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/Host/HostNativeThreadBase.h"
 #include "lldb/Core/Log.h"
 #include "lldb/Host/HostInfo.h"
-#include "lldb/Host/HostNativeThreadBase.h"
 #include "lldb/Host/ThisThread.h"
 #include "lldb/Host/ThreadLauncher.h"
 #include "llvm/ADT/StringExtras.h"
@@ -18,65 +18,50 @@ using namespace lldb;
 using namespace lldb_private;
 
 HostNativeThreadBase::HostNativeThreadBase()
-    : m_thread(LLDB_INVALID_HOST_THREAD)
-    , m_result(0)
-{
-}
+    : m_thread(LLDB_INVALID_HOST_THREAD), m_result(0) {}
 
 HostNativeThreadBase::HostNativeThreadBase(thread_t thread)
-    : m_thread(thread)
-    , m_result(0)
-{
-}
+    : m_thread(thread), m_result(0) {}
 
-lldb::thread_t
-HostNativeThreadBase::GetSystemHandle() const
-{
-    return m_thread;
+lldb::thread_t HostNativeThreadBase::GetSystemHandle() const {
+  return m_thread;
 }
 
-lldb::thread_result_t
-HostNativeThreadBase::GetResult() const
-{
-    return m_result;
+lldb::thread_result_t HostNativeThreadBase::GetResult() const {
+  return m_result;
 }
 
-bool
-HostNativeThreadBase::IsJoinable() const
-{
-    return m_thread != LLDB_INVALID_HOST_THREAD;
+bool HostNativeThreadBase::IsJoinable() const {
+  return m_thread != LLDB_INVALID_HOST_THREAD;
 }
 
-void
-HostNativeThreadBase::Reset()
-{
-    m_thread = LLDB_INVALID_HOST_THREAD;
-    m_result = 0;
+void HostNativeThreadBase::Reset() {
+  m_thread = LLDB_INVALID_HOST_THREAD;
+  m_result = 0;
 }
 
-lldb::thread_t
-HostNativeThreadBase::Release()
-{
-    lldb::thread_t result = m_thread;
-    m_thread = LLDB_INVALID_HOST_THREAD;
-    m_result = 0;
+lldb::thread_t HostNativeThreadBase::Release() {
+  lldb::thread_t result = m_thread;
+  m_thread = LLDB_INVALID_HOST_THREAD;
+  m_result = 0;
 
-    return result;
+  return result;
 }
 
 lldb::thread_result_t
-HostNativeThreadBase::ThreadCreateTrampoline(lldb::thread_arg_t arg)
-{
-    ThreadLauncher::HostThreadCreateInfo *info = (ThreadLauncher::HostThreadCreateInfo *)arg;
-    ThisThread::SetName(info->thread_name.c_str(), HostInfo::GetMaxThreadNameLength());
-
-    thread_func_t thread_fptr = info->thread_fptr;
-    thread_arg_t thread_arg = info->thread_arg;
-
-    Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
-    if (log)
-        log->Printf("thread created");
+HostNativeThreadBase::ThreadCreateTrampoline(lldb::thread_arg_t arg) {
+  ThreadLauncher::HostThreadCreateInfo *info =
+      (ThreadLauncher::HostThreadCreateInfo *)arg;
+  ThisThread::SetName(info->thread_name.c_str(),
+                      HostInfo::GetMaxThreadNameLength());
+
+  thread_func_t thread_fptr = info->thread_fptr;
+  thread_arg_t thread_arg = info->thread_arg;
+
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
+  if (log)
+    log->Printf("thread created");
 
-    delete info;
-    return thread_fptr(thread_arg);
+  delete info;
+  return thread_fptr(thread_arg);
 }

Modified: lldb/trunk/source/Host/common/HostProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/HostProcess.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/HostProcess.cpp (original)
+++ lldb/trunk/source/Host/common/HostProcess.cpp Tue Sep  6 15:57:50 2016
@@ -7,59 +7,42 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "lldb/Host/HostNativeProcess.h"
 #include "lldb/Host/HostProcess.h"
+#include "lldb/Host/HostNativeProcess.h"
 #include "lldb/Host/HostThread.h"
 
 using namespace lldb;
 using namespace lldb_private;
 
-HostProcess::HostProcess()
-    : m_native_process(new HostNativeProcess)
-{
-}
+HostProcess::HostProcess() : m_native_process(new HostNativeProcess) {}
 
 HostProcess::HostProcess(lldb::process_t process)
-    : m_native_process(new HostNativeProcess(process))
-{
-}
+    : m_native_process(new HostNativeProcess(process)) {}
 
-HostProcess::~HostProcess()
-{
-}
+HostProcess::~HostProcess() {}
 
-Error HostProcess::Terminate()
-{
-    return m_native_process->Terminate();
-}
+Error HostProcess::Terminate() { return m_native_process->Terminate(); }
 
-Error HostProcess::GetMainModule(FileSpec &file_spec) const
-{
-    return m_native_process->GetMainModule(file_spec);
+Error HostProcess::GetMainModule(FileSpec &file_spec) const {
+  return m_native_process->GetMainModule(file_spec);
 }
 
-lldb::pid_t HostProcess::GetProcessId() const
-{
-    return m_native_process->GetProcessId();
+lldb::pid_t HostProcess::GetProcessId() const {
+  return m_native_process->GetProcessId();
 }
 
-bool HostProcess::IsRunning() const
-{
-    return m_native_process->IsRunning();
-}
+bool HostProcess::IsRunning() const { return m_native_process->IsRunning(); }
 
 HostThread
-HostProcess::StartMonitoring(const Host::MonitorChildProcessCallback &callback, bool monitor_signals)
-{
-    return m_native_process->StartMonitoring(callback, monitor_signals);
+HostProcess::StartMonitoring(const Host::MonitorChildProcessCallback &callback,
+                             bool monitor_signals) {
+  return m_native_process->StartMonitoring(callback, monitor_signals);
 }
 
-HostNativeProcessBase &HostProcess::GetNativeProcess()
-{
-    return *m_native_process;
+HostNativeProcessBase &HostProcess::GetNativeProcess() {
+  return *m_native_process;
 }
 
-const HostNativeProcessBase &HostProcess::GetNativeProcess() const
-{
-    return *m_native_process;
+const HostNativeProcessBase &HostProcess::GetNativeProcess() const {
+  return *m_native_process;
 }

Modified: lldb/trunk/source/Host/common/HostThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/HostThread.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/HostThread.cpp (original)
+++ lldb/trunk/source/Host/common/HostThread.cpp Tue Sep  6 15:57:50 2016
@@ -7,72 +7,41 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "lldb/Host/HostNativeThread.h"
 #include "lldb/Host/HostThread.h"
+#include "lldb/Host/HostNativeThread.h"
 
 using namespace lldb;
 using namespace lldb_private;
 
-HostThread::HostThread()
-    : m_native_thread(new HostNativeThread)
-{
-}
+HostThread::HostThread() : m_native_thread(new HostNativeThread) {}
 
 HostThread::HostThread(lldb::thread_t thread)
-    : m_native_thread(new HostNativeThread(thread))
-{
-}
+    : m_native_thread(new HostNativeThread(thread)) {}
 
-Error
-HostThread::Join(lldb::thread_result_t *result)
-{
-    return m_native_thread->Join(result);
+Error HostThread::Join(lldb::thread_result_t *result) {
+  return m_native_thread->Join(result);
 }
 
-Error
-HostThread::Cancel()
-{
-    return m_native_thread->Cancel();
-}
+Error HostThread::Cancel() { return m_native_thread->Cancel(); }
 
-void
-HostThread::Reset()
-{
-    return m_native_thread->Reset();
-}
+void HostThread::Reset() { return m_native_thread->Reset(); }
 
-lldb::thread_t
-HostThread::Release()
-{
-    return m_native_thread->Release();
-}
+lldb::thread_t HostThread::Release() { return m_native_thread->Release(); }
 
-bool
-HostThread::IsJoinable() const
-{
-    return m_native_thread->IsJoinable();
-}
+bool HostThread::IsJoinable() const { return m_native_thread->IsJoinable(); }
 
-HostNativeThread &
-HostThread::GetNativeThread()
-{
-    return static_cast<HostNativeThread &>(*m_native_thread);
+HostNativeThread &HostThread::GetNativeThread() {
+  return static_cast<HostNativeThread &>(*m_native_thread);
 }
 
-const HostNativeThread &
-HostThread::GetNativeThread() const
-{
-    return static_cast<const HostNativeThread &>(*m_native_thread);
+const HostNativeThread &HostThread::GetNativeThread() const {
+  return static_cast<const HostNativeThread &>(*m_native_thread);
 }
 
-lldb::thread_result_t
-HostThread::GetResult() const
-{
-    return m_native_thread->GetResult();
+lldb::thread_result_t HostThread::GetResult() const {
+  return m_native_thread->GetResult();
 }
 
-bool
-HostThread::EqualsThread(lldb::thread_t thread) const
-{
-    return m_native_thread->GetSystemHandle() == thread;
+bool HostThread::EqualsThread(lldb::thread_t thread) const {
+  return m_native_thread->GetSystemHandle() == thread;
 }

Modified: lldb/trunk/source/Host/common/LockFileBase.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/LockFileBase.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/LockFileBase.cpp (original)
+++ lldb/trunk/source/Host/common/LockFileBase.cpp Tue Sep  6 15:57:50 2016
@@ -12,113 +12,71 @@
 using namespace lldb;
 using namespace lldb_private;
 
-namespace
-{
+namespace {
 
-Error
-AlreadyLocked ()
-{
-    return Error ("Already locked");
-}
-
-Error
-NotLocked ()
-{
-    return Error ("Not locked");
-}
+Error AlreadyLocked() { return Error("Already locked"); }
 
+Error NotLocked() { return Error("Not locked"); }
 }
 
-LockFileBase::LockFileBase (int fd) :
-    m_fd (fd),
-    m_locked (false),
-    m_start (0),
-    m_len (0)
-{
-
-}
+LockFileBase::LockFileBase(int fd)
+    : m_fd(fd), m_locked(false), m_start(0), m_len(0) {}
 
-bool
-LockFileBase::IsLocked () const
-{
-    return m_locked;
-}
+bool LockFileBase::IsLocked() const { return m_locked; }
 
-Error
-LockFileBase::WriteLock (const uint64_t start, const uint64_t len)
-{
-    return DoLock ([&] (const uint64_t start, const uint64_t len)
-                   {
-                       return DoWriteLock (start, len);
-                   }, start, len);
+Error LockFileBase::WriteLock(const uint64_t start, const uint64_t len) {
+  return DoLock([&](const uint64_t start,
+                    const uint64_t len) { return DoWriteLock(start, len); },
+                start, len);
 }
 
-Error
-LockFileBase::TryWriteLock (const uint64_t start, const uint64_t len)
-{
-    return DoLock ([&] (const uint64_t start, const uint64_t len)
-                   {
-                        return DoTryWriteLock (start, len);
-                   }, start, len);
+Error LockFileBase::TryWriteLock(const uint64_t start, const uint64_t len) {
+  return DoLock([&](const uint64_t start,
+                    const uint64_t len) { return DoTryWriteLock(start, len); },
+                start, len);
 }
 
-Error
-LockFileBase::ReadLock (const uint64_t start, const uint64_t len)
-{
-    return DoLock ([&] (const uint64_t start, const uint64_t len)
-                   {
-                        return DoReadLock (start, len);
-                   }, start, len);
+Error LockFileBase::ReadLock(const uint64_t start, const uint64_t len) {
+  return DoLock([&](const uint64_t start,
+                    const uint64_t len) { return DoReadLock(start, len); },
+                start, len);
 }
 
-Error
-LockFileBase::TryReadLock (const uint64_t start, const uint64_t len)
-{
-    return DoLock ([&] (const uint64_t start, const uint64_t len)
-                   {
-                       return DoTryReadLock (start, len);
-                   }, start, len);
-
+Error LockFileBase::TryReadLock(const uint64_t start, const uint64_t len) {
+  return DoLock([&](const uint64_t start,
+                    const uint64_t len) { return DoTryReadLock(start, len); },
+                start, len);
 }
 
-Error
-LockFileBase::Unlock ()
-{
-    if (!IsLocked ())
-        return NotLocked ();
+Error LockFileBase::Unlock() {
+  if (!IsLocked())
+    return NotLocked();
 
-    const auto error = DoUnlock ();
-    if (error.Success ())
-    {
-        m_locked = false;
-        m_start = 0;
-        m_len = 0;
-    }
-    return error;
+  const auto error = DoUnlock();
+  if (error.Success()) {
+    m_locked = false;
+    m_start = 0;
+    m_len = 0;
+  }
+  return error;
 }
 
-bool
-LockFileBase::IsValidFile () const
-{
-    return m_fd != -1;
-}
+bool LockFileBase::IsValidFile() const { return m_fd != -1; }
 
-Error
-LockFileBase::DoLock (const Locker &locker, const uint64_t start, const uint64_t len)
-{
-    if (!IsValidFile ())
-        return Error("File is invalid");
+Error LockFileBase::DoLock(const Locker &locker, const uint64_t start,
+                           const uint64_t len) {
+  if (!IsValidFile())
+    return Error("File is invalid");
 
-    if (IsLocked ())
-        return AlreadyLocked ();
+  if (IsLocked())
+    return AlreadyLocked();
 
-    const auto error = locker (start, len);
-    if (error.Success ())
-    {
-        m_locked = true;
-        m_start = start;
-        m_len = len;
-    }
+  const auto error = locker(start, len);
+  if (error.Success()) {
+    m_locked = true;
+    m_start = start;
+    m_len = len;
+  }
 
-    return error;
+  return error;
 }

Modified: lldb/trunk/source/Host/common/MonitoringProcessLauncher.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/MonitoringProcessLauncher.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/MonitoringProcessLauncher.cpp (original)
+++ lldb/trunk/source/Host/common/MonitoringProcessLauncher.cpp Tue Sep  6 15:57:50 2016
@@ -7,12 +7,12 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/Host/MonitoringProcessLauncher.h"
 #include "lldb/Core/Error.h"
 #include "lldb/Core/Log.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleSpec.h"
 #include "lldb/Host/HostProcess.h"
-#include "lldb/Host/MonitoringProcessLauncher.h"
 #include "lldb/Target/Platform.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/ProcessLaunchInfo.h"
@@ -20,81 +20,73 @@
 using namespace lldb;
 using namespace lldb_private;
 
-MonitoringProcessLauncher::MonitoringProcessLauncher(std::unique_ptr<ProcessLauncher> delegate_launcher)
-    : m_delegate_launcher(std::move(delegate_launcher))
-{
-}
+MonitoringProcessLauncher::MonitoringProcessLauncher(
+    std::unique_ptr<ProcessLauncher> delegate_launcher)
+    : m_delegate_launcher(std::move(delegate_launcher)) {}
 
 HostProcess
-MonitoringProcessLauncher::LaunchProcess(const ProcessLaunchInfo &launch_info, Error &error)
-{
-    ProcessLaunchInfo resolved_info(launch_info);
-
-    error.Clear();
-    char exe_path[PATH_MAX];
-
-    PlatformSP host_platform_sp(Platform::GetHostPlatform());
-
-    const ArchSpec &arch_spec = resolved_info.GetArchitecture();
-
-    FileSpec exe_spec(resolved_info.GetExecutableFile());
-
-    FileSpec::FileType file_type = exe_spec.GetFileType();
-    if (file_type != FileSpec::eFileTypeRegular)
-    {
-        ModuleSpec module_spec(exe_spec, arch_spec);
-        lldb::ModuleSP exe_module_sp;
-        error = host_platform_sp->ResolveExecutable(module_spec, exe_module_sp, NULL);
-
-        if (error.Fail())
-            return HostProcess();
-
-        if (exe_module_sp)
-            exe_spec = exe_module_sp->GetFileSpec();
-    }
-
-    if (exe_spec.Exists())
-    {
-        exe_spec.GetPath(exe_path, sizeof(exe_path));
-    }
-    else
-    {
-        resolved_info.GetExecutableFile().GetPath(exe_path, sizeof(exe_path));
-        error.SetErrorStringWithFormat("executable doesn't exist: '%s'", exe_path);
-        return HostProcess();
+MonitoringProcessLauncher::LaunchProcess(const ProcessLaunchInfo &launch_info,
+                                         Error &error) {
+  ProcessLaunchInfo resolved_info(launch_info);
+
+  error.Clear();
+  char exe_path[PATH_MAX];
+
+  PlatformSP host_platform_sp(Platform::GetHostPlatform());
+
+  const ArchSpec &arch_spec = resolved_info.GetArchitecture();
+
+  FileSpec exe_spec(resolved_info.GetExecutableFile());
+
+  FileSpec::FileType file_type = exe_spec.GetFileType();
+  if (file_type != FileSpec::eFileTypeRegular) {
+    ModuleSpec module_spec(exe_spec, arch_spec);
+    lldb::ModuleSP exe_module_sp;
+    error =
+        host_platform_sp->ResolveExecutable(module_spec, exe_module_sp, NULL);
+
+    if (error.Fail())
+      return HostProcess();
+
+    if (exe_module_sp)
+      exe_spec = exe_module_sp->GetFileSpec();
+  }
+
+  if (exe_spec.Exists()) {
+    exe_spec.GetPath(exe_path, sizeof(exe_path));
+  } else {
+    resolved_info.GetExecutableFile().GetPath(exe_path, sizeof(exe_path));
+    error.SetErrorStringWithFormat("executable doesn't exist: '%s'", exe_path);
+    return HostProcess();
+  }
+
+  resolved_info.SetExecutableFile(exe_spec, false);
+  assert(!resolved_info.GetFlags().Test(eLaunchFlagLaunchInTTY));
+
+  HostProcess process =
+      m_delegate_launcher->LaunchProcess(resolved_info, error);
+
+  if (process.GetProcessId() != LLDB_INVALID_PROCESS_ID) {
+    Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+
+    Host::MonitorChildProcessCallback callback =
+        launch_info.GetMonitorProcessCallback();
+
+    bool monitor_signals = false;
+    if (callback) {
+      // If the ProcessLaunchInfo specified a callback, use that.
+      monitor_signals = launch_info.GetMonitorSignals();
+    } else {
+      callback = Process::SetProcessExitStatus;
     }
 
-    resolved_info.SetExecutableFile(exe_spec, false);
-    assert(!resolved_info.GetFlags().Test(eLaunchFlagLaunchInTTY));
-
-    HostProcess process = m_delegate_launcher->LaunchProcess(resolved_info, error);
-
-    if (process.GetProcessId() != LLDB_INVALID_PROCESS_ID)
-    {
-        Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
-
-        Host::MonitorChildProcessCallback callback = launch_info.GetMonitorProcessCallback();
-
-        bool monitor_signals = false;
-        if (callback)
-        {
-            // If the ProcessLaunchInfo specified a callback, use that.
-            monitor_signals = launch_info.GetMonitorSignals();
-        }
-        else
-        {
-            callback = Process::SetProcessExitStatus;
-        }
-
-        process.StartMonitoring(callback, monitor_signals);
-        if (log)
-            log->PutCString("started monitoring child process.");
-    }
-    else
-    {
-        // Invalid process ID, something didn't go well
-        if (error.Success())
-            error.SetErrorString("process launch failed for unknown reasons");
-    }
-    return process;
+    process.StartMonitoring(callback, monitor_signals);
+    if (log)
+      log->PutCString("started monitoring child process.");
+  } else {
+    // Invalid process ID, something didn't go well
+    if (error.Success())
+      error.SetErrorString("process launch failed for unknown reasons");
+  }
+  return process;
 }

Modified: lldb/trunk/source/Host/common/NativeBreakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/NativeBreakpoint.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/NativeBreakpoint.cpp (original)
+++ lldb/trunk/source/Host/common/NativeBreakpoint.cpp Tue Sep  6 15:57:50 2016
@@ -9,108 +9,101 @@
 
 #include "lldb/Host/common/NativeBreakpoint.h"
 
-#include "lldb/lldb-defines.h"
 #include "lldb/Core/Error.h"
 #include "lldb/Core/Log.h"
+#include "lldb/lldb-defines.h"
 
 using namespace lldb_private;
 
-NativeBreakpoint::NativeBreakpoint (lldb::addr_t addr) :
-    m_addr (addr),
-    m_ref_count (1),
-    m_enabled (true)
-{
-    assert (addr != LLDB_INVALID_ADDRESS && "breakpoint set for invalid address");
+NativeBreakpoint::NativeBreakpoint(lldb::addr_t addr)
+    : m_addr(addr), m_ref_count(1), m_enabled(true) {
+  assert(addr != LLDB_INVALID_ADDRESS && "breakpoint set for invalid address");
 }
 
-NativeBreakpoint::~NativeBreakpoint ()
-{
-}
+NativeBreakpoint::~NativeBreakpoint() {}
 
-void
-NativeBreakpoint::AddRef ()
-{
-    ++m_ref_count;
+void NativeBreakpoint::AddRef() {
+  ++m_ref_count;
 
-    Log *log (GetLogIfAnyCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
-    if (log)
-        log->Printf ("NativeBreakpoint::%s addr = 0x%" PRIx64 " bumped up, new ref count %" PRIu32, __FUNCTION__, m_addr, m_ref_count);  
+  Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
+  if (log)
+    log->Printf("NativeBreakpoint::%s addr = 0x%" PRIx64
+                " bumped up, new ref count %" PRIu32,
+                __FUNCTION__, m_addr, m_ref_count);
 }
 
-int32_t
-NativeBreakpoint::DecRef ()
-{
-    --m_ref_count;
+int32_t NativeBreakpoint::DecRef() {
+  --m_ref_count;
 
-    Log *log (GetLogIfAnyCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
-    if (log)
-        log->Printf ("NativeBreakpoint::%s addr = 0x%" PRIx64 " ref count decremented, new ref count %" PRIu32, __FUNCTION__, m_addr, m_ref_count);  
+  Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
+  if (log)
+    log->Printf("NativeBreakpoint::%s addr = 0x%" PRIx64
+                " ref count decremented, new ref count %" PRIu32,
+                __FUNCTION__, m_addr, m_ref_count);
 
-    return m_ref_count;
+  return m_ref_count;
 }
 
-Error
-NativeBreakpoint::Enable ()
-{
-    Log *log (GetLogIfAnyCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
-
-    if (m_enabled)
-    {
-        // We're already enabled. Just log and exit.
-        if (log)
-            log->Printf ("NativeBreakpoint::%s addr = 0x%" PRIx64 " already enabled, ignoring.", __FUNCTION__, m_addr);
-        return Error ();
-    }
-
-    // Log and enable.
-    if (log)
-        log->Printf ("NativeBreakpoint::%s addr = 0x%" PRIx64 " enabling...", __FUNCTION__, m_addr);
-
-    Error error = DoEnable ();
-    if (error.Success ())
-    {
-        m_enabled = true;
-        if (log)
-            log->Printf ("NativeBreakpoint::%s addr = 0x%" PRIx64 " enable SUCCESS.", __FUNCTION__, m_addr);  
-    }
-    else
-    {
-        if (log)
-            log->Printf ("NativeBreakpoint::%s addr = 0x%" PRIx64 " enable FAIL: %s", __FUNCTION__, m_addr, error.AsCString ());
-    }
+Error NativeBreakpoint::Enable() {
+  Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
 
-    return error;
+  if (m_enabled) {
+    // We're already enabled. Just log and exit.
+    if (log)
+      log->Printf("NativeBreakpoint::%s addr = 0x%" PRIx64
+                  " already enabled, ignoring.",
+                  __FUNCTION__, m_addr);
+    return Error();
+  }
+
+  // Log and enable.
+  if (log)
+    log->Printf("NativeBreakpoint::%s addr = 0x%" PRIx64 " enabling...",
+                __FUNCTION__, m_addr);
+
+  Error error = DoEnable();
+  if (error.Success()) {
+    m_enabled = true;
+    if (log)
+      log->Printf("NativeBreakpoint::%s addr = 0x%" PRIx64 " enable SUCCESS.",
+                  __FUNCTION__, m_addr);
+  } else {
+    if (log)
+      log->Printf("NativeBreakpoint::%s addr = 0x%" PRIx64 " enable FAIL: %s",
+                  __FUNCTION__, m_addr, error.AsCString());
+  }
+
+  return error;
 }
 
-Error
-NativeBreakpoint::Disable ()
-{
-    Log *log (GetLogIfAnyCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
-
-    if (!m_enabled)
-    {
-        // We're already disabled. Just log and exit.
-        if (log)
-            log->Printf ("NativeBreakpoint::%s addr = 0x%" PRIx64 " already disabled, ignoring.", __FUNCTION__, m_addr);
-        return Error ();
-    }
-
-    // Log and disable.
-    if (log)
-        log->Printf ("NativeBreakpoint::%s addr = 0x%" PRIx64 " disabling...", __FUNCTION__, m_addr);
-
-    Error error = DoDisable ();
-    if (error.Success ())
-    {
-        m_enabled = false;
-        if (log)
-            log->Printf ("NativeBreakpoint::%s addr = 0x%" PRIx64 " disable SUCCESS.", __FUNCTION__, m_addr);  
-    }
-    else
-    {
-        if (log)
-            log->Printf ("NativeBreakpoint::%s addr = 0x%" PRIx64 " disable FAIL: %s", __FUNCTION__, m_addr, error.AsCString ());
-    }
+Error NativeBreakpoint::Disable() {
+  Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
+
+  if (!m_enabled) {
+    // We're already disabled. Just log and exit.
+    if (log)
+      log->Printf("NativeBreakpoint::%s addr = 0x%" PRIx64
+                  " already disabled, ignoring.",
+                  __FUNCTION__, m_addr);
+    return Error();
+  }
+
+  // Log and disable.
+  if (log)
+    log->Printf("NativeBreakpoint::%s addr = 0x%" PRIx64 " disabling...",
+                __FUNCTION__, m_addr);
+
+  Error error = DoDisable();
+  if (error.Success()) {
+    m_enabled = false;
+    if (log)
+      log->Printf("NativeBreakpoint::%s addr = 0x%" PRIx64 " disable SUCCESS.",
+                  __FUNCTION__, m_addr);
+  } else {
+    if (log)
+      log->Printf("NativeBreakpoint::%s addr = 0x%" PRIx64 " disable FAIL: %s",
+                  __FUNCTION__, m_addr, error.AsCString());
+  }
 
-    return error;
+  return error;
 }

Modified: lldb/trunk/source/Host/common/NativeBreakpointList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/NativeBreakpointList.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/NativeBreakpointList.cpp (original)
+++ lldb/trunk/source/Host/common/NativeBreakpointList.cpp Tue Sep  6 15:57:50 2016
@@ -17,204 +17,213 @@
 using namespace lldb;
 using namespace lldb_private;
 
-NativeBreakpointList::NativeBreakpointList() : m_mutex()
-{
-}
-
-Error
-NativeBreakpointList::AddRef (lldb::addr_t addr, size_t size_hint, bool hardware, CreateBreakpointFunc create_func)
-{
-    Log *log (GetLogIfAnyCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
-    if (log)
-        log->Printf ("NativeBreakpointList::%s addr = 0x%" PRIx64 ", size_hint = %lu, hardware = %s", __FUNCTION__, addr, size_hint, hardware ? "true" : "false");
-
-    std::lock_guard<std::recursive_mutex> guard(m_mutex);
+NativeBreakpointList::NativeBreakpointList() : m_mutex() {}
 
-    // Check if the breakpoint is already set.
-    auto iter = m_breakpoints.find (addr);
-    if (iter != m_breakpoints.end ())
-    {
-        // Yes - bump up ref count.
-        if (log)
-            log->Printf ("NativeBreakpointList::%s addr = 0x%" PRIx64 " -- already enabled, upping ref count", __FUNCTION__, addr);
+Error NativeBreakpointList::AddRef(lldb::addr_t addr, size_t size_hint,
+                                   bool hardware,
+                                   CreateBreakpointFunc create_func) {
+  Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
+  if (log)
+    log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64
+                ", size_hint = %lu, hardware = %s",
+                __FUNCTION__, addr, size_hint, hardware ? "true" : "false");
+
+  std::lock_guard<std::recursive_mutex> guard(m_mutex);
+
+  // Check if the breakpoint is already set.
+  auto iter = m_breakpoints.find(addr);
+  if (iter != m_breakpoints.end()) {
+    // Yes - bump up ref count.
+    if (log)
+      log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64
+                  " -- already enabled, upping ref count",
+                  __FUNCTION__, addr);
 
-        iter->second->AddRef ();
-        return Error ();
-    }
-
-    // Create a new breakpoint using the given create func.
-    if (log)
-        log->Printf ("NativeBreakpointList::%s creating breakpoint for addr = 0x%" PRIx64 ", size_hint = %lu, hardware = %s", __FUNCTION__, addr, size_hint, hardware ? "true" : "false");
+    iter->second->AddRef();
+    return Error();
+  }
 
-    NativeBreakpointSP breakpoint_sp;
-    Error error = create_func (addr, size_hint, hardware, breakpoint_sp);
-    if (error.Fail ())
-    {
-        if (log)
-            log->Printf ("NativeBreakpointList::%s creating breakpoint for addr = 0x%" PRIx64 ", size_hint = %lu, hardware = %s -- FAILED: %s", __FUNCTION__, addr, size_hint, hardware ? "true" : "false", error.AsCString ());
-        return error;
-    }
+  // Create a new breakpoint using the given create func.
+  if (log)
+    log->Printf(
+        "NativeBreakpointList::%s creating breakpoint for addr = 0x%" PRIx64
+        ", size_hint = %lu, hardware = %s",
+        __FUNCTION__, addr, size_hint, hardware ? "true" : "false");
+
+  NativeBreakpointSP breakpoint_sp;
+  Error error = create_func(addr, size_hint, hardware, breakpoint_sp);
+  if (error.Fail()) {
+    if (log)
+      log->Printf(
+          "NativeBreakpointList::%s creating breakpoint for addr = 0x%" PRIx64
+          ", size_hint = %lu, hardware = %s -- FAILED: %s",
+          __FUNCTION__, addr, size_hint, hardware ? "true" : "false",
+          error.AsCString());
+    return error;
+  }
 
-    // Remember the breakpoint.
-    assert (breakpoint_sp && "NativeBreakpoint create function succeeded but returned NULL breakpoint");
-    m_breakpoints.insert (BreakpointMap::value_type (addr, breakpoint_sp));
+  // Remember the breakpoint.
+  assert(breakpoint_sp && "NativeBreakpoint create function succeeded but "
+                          "returned NULL breakpoint");
+  m_breakpoints.insert(BreakpointMap::value_type(addr, breakpoint_sp));
 
-    return error;
+  return error;
 }
 
-Error
-NativeBreakpointList::DecRef (lldb::addr_t addr)
-{
-    Error error;
-
-    Log *log (GetLogIfAnyCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
-    if (log)
-        log->Printf ("NativeBreakpointList::%s addr = 0x%" PRIx64, __FUNCTION__, addr);
-
-    std::lock_guard<std::recursive_mutex> guard(m_mutex);
-
-    // Check if the breakpoint is already set.
-    auto iter = m_breakpoints.find (addr);
-    if (iter == m_breakpoints.end ())
-    {
-        // Not found!
-        if (log)
-            log->Printf ("NativeBreakpointList::%s addr = 0x%" PRIx64 " -- NOT FOUND", __FUNCTION__, addr);
-        error.SetErrorString ("breakpoint not found");
-        return error;
-    }
+Error NativeBreakpointList::DecRef(lldb::addr_t addr) {
+  Error error;
 
-    // Decrement ref count.
-    const int32_t new_ref_count = iter->second->DecRef ();
-    assert (new_ref_count >= 0 && "NativeBreakpoint ref count went negative");
-
-    if (new_ref_count > 0)
-    {
-        // Still references to this breakpoint.  Leave it alone.
-        if (log)
-            log->Printf ("NativeBreakpointList::%s addr = 0x%" PRIx64 " -- new breakpoint ref count %" PRIu32, __FUNCTION__, addr, new_ref_count);
-        return error;
-    }
+  Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
+  if (log)
+    log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64, __FUNCTION__,
+                addr);
 
-    // Breakpoint has no more references.  Disable it if it's not
-    // already disabled.
-    if (log)
-        log->Printf ("NativeBreakpointList::%s addr = 0x%" PRIx64 " -- removing due to no remaining references", __FUNCTION__, addr);
+  std::lock_guard<std::recursive_mutex> guard(m_mutex);
 
-    // If it's enabled, we need to disable it.
-    if (iter->second->IsEnabled ())
-    {
-        if (log)
-            log->Printf ("NativeBreakpointList::%s addr = 0x%" PRIx64 " -- currently enabled, now disabling", __FUNCTION__, addr);
-        error = iter->second->Disable ();
-        if (error.Fail ())
-        {
-            if (log)
-                log->Printf ("NativeBreakpointList::%s addr = 0x%" PRIx64 " -- removal FAILED: %s", __FUNCTION__, addr, error.AsCString ());
-            // Continue since we still want to take it out of the breakpoint list.
-        }
-    }
-    else
-    {
-        if (log)
-            log->Printf ("NativeBreakpointList::%s addr = 0x%" PRIx64 " -- already disabled, nothing to do", __FUNCTION__, addr);
-    }
-
-    // Take the breakpoint out of the list.
+  // Check if the breakpoint is already set.
+  auto iter = m_breakpoints.find(addr);
+  if (iter == m_breakpoints.end()) {
+    // Not found!
     if (log)
-        log->Printf ("NativeBreakpointList::%s addr = 0x%" PRIx64 " -- removed from breakpoint map", __FUNCTION__, addr);
-
-    m_breakpoints.erase (iter);
+      log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64 " -- NOT FOUND",
+                  __FUNCTION__, addr);
+    error.SetErrorString("breakpoint not found");
     return error;
-}
-
-Error
-NativeBreakpointList::EnableBreakpoint (lldb::addr_t addr)
-{
-    Log *log (GetLogIfAnyCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
-    if (log)
-        log->Printf ("NativeBreakpointList::%s addr = 0x%" PRIx64, __FUNCTION__, addr);
-
-    std::lock_guard<std::recursive_mutex> guard(m_mutex);
-
-    // Ensure we have said breakpoint.
-    auto iter = m_breakpoints.find (addr);
-    if (iter == m_breakpoints.end ())
-    {
-        // Not found!
-        if (log)
-            log->Printf ("NativeBreakpointList::%s addr = 0x%" PRIx64 " -- NOT FOUND", __FUNCTION__, addr);
-        return Error ("breakpoint not found");
-    }
-
-    // Enable it.
-    return iter->second->Enable ();
-}
+  }
 
-Error
-NativeBreakpointList::DisableBreakpoint (lldb::addr_t addr)
-{
-    Log *log (GetLogIfAnyCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
-    if (log)
-        log->Printf ("NativeBreakpointList::%s addr = 0x%" PRIx64, __FUNCTION__, addr);
-
-    std::lock_guard<std::recursive_mutex> guard(m_mutex);
-
-    // Ensure we have said breakpoint.
-    auto iter = m_breakpoints.find (addr);
-    if (iter == m_breakpoints.end ())
-    {
-        // Not found!
-        if (log)
-            log->Printf ("NativeBreakpointList::%s addr = 0x%" PRIx64 " -- NOT FOUND", __FUNCTION__, addr);
-        return Error ("breakpoint not found");
-    }
-
-    // Disable it.
-    return iter->second->Disable ();
-}
-
-Error
-NativeBreakpointList::GetBreakpoint (lldb::addr_t addr, NativeBreakpointSP &breakpoint_sp)
-{
-    Log *log (GetLogIfAnyCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
-    if (log)
-        log->Printf ("NativeBreakpointList::%s addr = 0x%" PRIx64, __FUNCTION__, addr);
-
-    std::lock_guard<std::recursive_mutex> guard(m_mutex);
-
-    // Ensure we have said breakpoint.
-    auto iter = m_breakpoints.find (addr);
-    if (iter == m_breakpoints.end ())
-    {
-        // Not found!
-        breakpoint_sp.reset ();
-        return Error ("breakpoint not found");
-    }
+  // Decrement ref count.
+  const int32_t new_ref_count = iter->second->DecRef();
+  assert(new_ref_count >= 0 && "NativeBreakpoint ref count went negative");
+
+  if (new_ref_count > 0) {
+    // Still references to this breakpoint.  Leave it alone.
+    if (log)
+      log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64
+                  " -- new breakpoint ref count %" PRIu32,
+                  __FUNCTION__, addr, new_ref_count);
+    return error;
+  }
 
-    // Disable it.
-    breakpoint_sp = iter->second;
-    return Error ();
-}
-
-Error
-NativeBreakpointList::RemoveTrapsFromBuffer(lldb::addr_t addr, void *buf, size_t size) const
-{
-    for (const auto &map : m_breakpoints)
-    {
-        lldb::addr_t bp_addr = map.first;
-        // Breapoint not in range, ignore
-        if (bp_addr < addr || addr + size <= bp_addr)
-            continue;
-        const auto &bp_sp = map.second;
-        // Not software breakpoint, ignore
-        if (!bp_sp->IsSoftwareBreakpoint())
-            continue;
-        auto software_bp_sp = std::static_pointer_cast<SoftwareBreakpoint>(bp_sp);
-        auto opcode_addr = static_cast<char *>(buf) + bp_addr - addr;
-        auto saved_opcodes = software_bp_sp->m_saved_opcodes;
-        auto opcode_size = software_bp_sp->m_opcode_size;
-        ::memcpy(opcode_addr, saved_opcodes, opcode_size);
-    }
-    return Error();
+  // Breakpoint has no more references.  Disable it if it's not
+  // already disabled.
+  if (log)
+    log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64
+                " -- removing due to no remaining references",
+                __FUNCTION__, addr);
+
+  // If it's enabled, we need to disable it.
+  if (iter->second->IsEnabled()) {
+    if (log)
+      log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64
+                  " -- currently enabled, now disabling",
+                  __FUNCTION__, addr);
+    error = iter->second->Disable();
+    if (error.Fail()) {
+      if (log)
+        log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64
+                    " -- removal FAILED: %s",
+                    __FUNCTION__, addr, error.AsCString());
+      // Continue since we still want to take it out of the breakpoint list.
+    }
+  } else {
+    if (log)
+      log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64
+                  " -- already disabled, nothing to do",
+                  __FUNCTION__, addr);
+  }
+
+  // Take the breakpoint out of the list.
+  if (log)
+    log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64
+                " -- removed from breakpoint map",
+                __FUNCTION__, addr);
+
+  m_breakpoints.erase(iter);
+  return error;
+}
+
+Error NativeBreakpointList::EnableBreakpoint(lldb::addr_t addr) {
+  Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
+  if (log)
+    log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64, __FUNCTION__,
+                addr);
+
+  std::lock_guard<std::recursive_mutex> guard(m_mutex);
+
+  // Ensure we have said breakpoint.
+  auto iter = m_breakpoints.find(addr);
+  if (iter == m_breakpoints.end()) {
+    // Not found!
+    if (log)
+      log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64 " -- NOT FOUND",
+                  __FUNCTION__, addr);
+    return Error("breakpoint not found");
+  }
+
+  // Enable it.
+  return iter->second->Enable();
+}
+
+Error NativeBreakpointList::DisableBreakpoint(lldb::addr_t addr) {
+  Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
+  if (log)
+    log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64, __FUNCTION__,
+                addr);
+
+  std::lock_guard<std::recursive_mutex> guard(m_mutex);
+
+  // Ensure we have said breakpoint.
+  auto iter = m_breakpoints.find(addr);
+  if (iter == m_breakpoints.end()) {
+    // Not found!
+    if (log)
+      log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64 " -- NOT FOUND",
+                  __FUNCTION__, addr);
+    return Error("breakpoint not found");
+  }
+
+  // Disable it.
+  return iter->second->Disable();
+}
+
+Error NativeBreakpointList::GetBreakpoint(lldb::addr_t addr,
+                                          NativeBreakpointSP &breakpoint_sp) {
+  Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
+  if (log)
+    log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64, __FUNCTION__,
+                addr);
+
+  std::lock_guard<std::recursive_mutex> guard(m_mutex);
+
+  // Ensure we have said breakpoint.
+  auto iter = m_breakpoints.find(addr);
+  if (iter == m_breakpoints.end()) {
+    // Not found!
+    breakpoint_sp.reset();
+    return Error("breakpoint not found");
+  }
+
+  // Disable it.
+  breakpoint_sp = iter->second;
+  return Error();
+}
+
+Error NativeBreakpointList::RemoveTrapsFromBuffer(lldb::addr_t addr, void *buf,
+                                                  size_t size) const {
+  for (const auto &map : m_breakpoints) {
+    lldb::addr_t bp_addr = map.first;
+    // Breapoint not in range, ignore
+    if (bp_addr < addr || addr + size <= bp_addr)
+      continue;
+    const auto &bp_sp = map.second;
+    // Not software breakpoint, ignore
+    if (!bp_sp->IsSoftwareBreakpoint())
+      continue;
+    auto software_bp_sp = std::static_pointer_cast<SoftwareBreakpoint>(bp_sp);
+    auto opcode_addr = static_cast<char *>(buf) + bp_addr - addr;
+    auto saved_opcodes = software_bp_sp->m_saved_opcodes;
+    auto opcode_size = software_bp_sp->m_opcode_size;
+    ::memcpy(opcode_addr, saved_opcodes, opcode_size);
+  }
+  return Error();
 }

Modified: lldb/trunk/source/Host/common/NativeProcessProtocol.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/NativeProcessProtocol.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/NativeProcessProtocol.cpp (original)
+++ lldb/trunk/source/Host/common/NativeProcessProtocol.cpp Tue Sep  6 15:57:50 2016
@@ -9,7 +9,6 @@
 
 #include "lldb/Host/common/NativeProcessProtocol.h"
 
-#include "lldb/lldb-enumerations.h"
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/Log.h"
 #include "lldb/Core/ModuleSpec.h"
@@ -21,6 +20,7 @@
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Utility/LLDBAssert.h"
+#include "lldb/lldb-enumerations.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -30,458 +30,403 @@ using namespace lldb_private;
 // -----------------------------------------------------------------------------
 
 NativeProcessProtocol::NativeProcessProtocol(lldb::pid_t pid)
-    : m_pid(pid),
-      m_threads(),
-      m_current_thread_id(LLDB_INVALID_THREAD_ID),
-      m_threads_mutex(),
-      m_state(lldb::eStateInvalid),
-      m_state_mutex(),
-      m_exit_type(eExitTypeInvalid),
-      m_exit_status(0),
-      m_exit_description(),
-      m_delegates_mutex(),
-      m_delegates(),
-      m_breakpoint_list(),
-      m_watchpoint_list(),
-      m_terminal_fd(-1),
-      m_stop_id(0)
-{
-}
-
-lldb_private::Error
-NativeProcessProtocol::Interrupt ()
-{
-    Error error;
-#if !defined (SIGSTOP)
-    error.SetErrorString ("local host does not support signaling");
-    return error;
+    : m_pid(pid), m_threads(), m_current_thread_id(LLDB_INVALID_THREAD_ID),
+      m_threads_mutex(), m_state(lldb::eStateInvalid), m_state_mutex(),
+      m_exit_type(eExitTypeInvalid), m_exit_status(0), m_exit_description(),
+      m_delegates_mutex(), m_delegates(), m_breakpoint_list(),
+      m_watchpoint_list(), m_terminal_fd(-1), m_stop_id(0) {}
+
+lldb_private::Error NativeProcessProtocol::Interrupt() {
+  Error error;
+#if !defined(SIGSTOP)
+  error.SetErrorString("local host does not support signaling");
+  return error;
 #else
-    return Signal (SIGSTOP);
+  return Signal(SIGSTOP);
 #endif
 }
 
 lldb_private::Error
-NativeProcessProtocol::GetMemoryRegionInfo (lldb::addr_t load_addr, MemoryRegionInfo &range_info)
-{
-    // Default: not implemented.
-    return Error ("not implemented");
+NativeProcessProtocol::GetMemoryRegionInfo(lldb::addr_t load_addr,
+                                           MemoryRegionInfo &range_info) {
+  // Default: not implemented.
+  return Error("not implemented");
 }
 
-bool
-NativeProcessProtocol::GetExitStatus (ExitType *exit_type, int *status, std::string &exit_description)
-{
-    if (m_state == lldb::eStateExited)
-    {
-        *exit_type = m_exit_type;
-        *status = m_exit_status;
-        exit_description = m_exit_description;
-        return true;
-    }
+bool NativeProcessProtocol::GetExitStatus(ExitType *exit_type, int *status,
+                                          std::string &exit_description) {
+  if (m_state == lldb::eStateExited) {
+    *exit_type = m_exit_type;
+    *status = m_exit_status;
+    exit_description = m_exit_description;
+    return true;
+  }
 
-    *status = 0;
-    return false;
+  *status = 0;
+  return false;
 }
 
-bool
-NativeProcessProtocol::SetExitStatus (ExitType exit_type, int status, const char *exit_description, bool bNotifyStateChange)
-{
-    Log *log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
-    if (log)
-        log->Printf ("NativeProcessProtocol::%s(%d, %d, %s, %s) called",
-                __FUNCTION__,
-                exit_type,
-                status,
+bool NativeProcessProtocol::SetExitStatus(ExitType exit_type, int status,
+                                          const char *exit_description,
+                                          bool bNotifyStateChange) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+  if (log)
+    log->Printf("NativeProcessProtocol::%s(%d, %d, %s, %s) called",
+                __FUNCTION__, exit_type, status,
                 exit_description ? exit_description : "nullptr",
                 bNotifyStateChange ? "true" : "false");
 
-    // Exit status already set
-    if (m_state == lldb::eStateExited)
-    {
-        if (log)
-            log->Printf ("NativeProcessProtocol::%s exit status already set to %d, ignoring new set to %d", __FUNCTION__, m_exit_status, status);
-        return false;
-    }
+  // Exit status already set
+  if (m_state == lldb::eStateExited) {
+    if (log)
+      log->Printf("NativeProcessProtocol::%s exit status already set to %d, "
+                  "ignoring new set to %d",
+                  __FUNCTION__, m_exit_status, status);
+    return false;
+  }
 
-    m_state = lldb::eStateExited;
+  m_state = lldb::eStateExited;
 
-    m_exit_type = exit_type;
-    m_exit_status = status;
-    if (exit_description && exit_description[0])
-        m_exit_description = exit_description;
-    else
-        m_exit_description.clear();
+  m_exit_type = exit_type;
+  m_exit_status = status;
+  if (exit_description && exit_description[0])
+    m_exit_description = exit_description;
+  else
+    m_exit_description.clear();
 
-    if (bNotifyStateChange)
-        SynchronouslyNotifyProcessStateChanged (lldb::eStateExited);
+  if (bNotifyStateChange)
+    SynchronouslyNotifyProcessStateChanged(lldb::eStateExited);
 
-    return true;
+  return true;
 }
 
-NativeThreadProtocolSP
-NativeProcessProtocol::GetThreadAtIndex (uint32_t idx)
-{
-    std::lock_guard<std::recursive_mutex> guard(m_threads_mutex);
-    if (idx < m_threads.size ())
-        return m_threads[idx];
-    return NativeThreadProtocolSP ();
+NativeThreadProtocolSP NativeProcessProtocol::GetThreadAtIndex(uint32_t idx) {
+  std::lock_guard<std::recursive_mutex> guard(m_threads_mutex);
+  if (idx < m_threads.size())
+    return m_threads[idx];
+  return NativeThreadProtocolSP();
 }
 
 NativeThreadProtocolSP
-NativeProcessProtocol::GetThreadByIDUnlocked (lldb::tid_t tid)
-{
-    for (auto thread_sp : m_threads)
-    {
-        if (thread_sp->GetID() == tid)
-            return thread_sp;
-    }
-    return NativeThreadProtocolSP ();
+NativeProcessProtocol::GetThreadByIDUnlocked(lldb::tid_t tid) {
+  for (auto thread_sp : m_threads) {
+    if (thread_sp->GetID() == tid)
+      return thread_sp;
+  }
+  return NativeThreadProtocolSP();
 }
 
-NativeThreadProtocolSP
-NativeProcessProtocol::GetThreadByID (lldb::tid_t tid)
-{
-    std::lock_guard<std::recursive_mutex> guard(m_threads_mutex);
-    return GetThreadByIDUnlocked (tid);
-}
-
-bool
-NativeProcessProtocol::IsAlive () const
-{
-    return m_state != eStateDetached
-        && m_state != eStateExited
-        && m_state != eStateInvalid
-        && m_state != eStateUnloaded;
-}
-
-bool
-NativeProcessProtocol::GetByteOrder (lldb::ByteOrder &byte_order) const
-{
-    ArchSpec process_arch;
-    if (!GetArchitecture (process_arch))
-        return false;
-    byte_order = process_arch.GetByteOrder ();
-    return true;
+NativeThreadProtocolSP NativeProcessProtocol::GetThreadByID(lldb::tid_t tid) {
+  std::lock_guard<std::recursive_mutex> guard(m_threads_mutex);
+  return GetThreadByIDUnlocked(tid);
+}
+
+bool NativeProcessProtocol::IsAlive() const {
+  return m_state != eStateDetached && m_state != eStateExited &&
+         m_state != eStateInvalid && m_state != eStateUnloaded;
 }
 
-const NativeWatchpointList::WatchpointMap&
-NativeProcessProtocol::GetWatchpointMap () const
-{
-    return m_watchpoint_list.GetWatchpointMap();
-}
-
-uint32_t
-NativeProcessProtocol::GetMaxWatchpoints () const
-{
-    // This default implementation will return the number of
-    // *hardware* breakpoints available.  MacOSX and other OS
-    // implementations that support software breakpoints will want to
-    // override this correctly for their implementation.
-    Log *log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
+bool NativeProcessProtocol::GetByteOrder(lldb::ByteOrder &byte_order) const {
+  ArchSpec process_arch;
+  if (!GetArchitecture(process_arch))
+    return false;
+  byte_order = process_arch.GetByteOrder();
+  return true;
+}
+
+const NativeWatchpointList::WatchpointMap &
+NativeProcessProtocol::GetWatchpointMap() const {
+  return m_watchpoint_list.GetWatchpointMap();
+}
+
+uint32_t NativeProcessProtocol::GetMaxWatchpoints() const {
+  // This default implementation will return the number of
+  // *hardware* breakpoints available.  MacOSX and other OS
+  // implementations that support software breakpoints will want to
+  // override this correctly for their implementation.
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+
+  // get any thread
+  NativeThreadProtocolSP thread_sp(
+      const_cast<NativeProcessProtocol *>(this)->GetThreadAtIndex(0));
+  if (!thread_sp) {
+    if (log)
+      log->Warning("NativeProcessProtocol::%s (): failed to find a thread to "
+                   "grab a NativeRegisterContext!",
+                   __FUNCTION__);
+    return 0;
+  }
 
-    // get any thread
-    NativeThreadProtocolSP thread_sp (const_cast<NativeProcessProtocol*> (this)->GetThreadAtIndex (0));
+  NativeRegisterContextSP reg_ctx_sp(thread_sp->GetRegisterContext());
+  if (!reg_ctx_sp) {
+    if (log)
+      log->Warning("NativeProcessProtocol::%s (): failed to get a "
+                   "RegisterContextNativeProcess from the first thread!",
+                   __FUNCTION__);
+    return 0;
+  }
+
+  return reg_ctx_sp->NumSupportedHardwareWatchpoints();
+}
+
+Error NativeProcessProtocol::SetWatchpoint(lldb::addr_t addr, size_t size,
+                                           uint32_t watch_flags,
+                                           bool hardware) {
+  // This default implementation assumes setting the watchpoint for
+  // the process will require setting the watchpoint for each of the
+  // threads.  Furthermore, it will track watchpoints set for the
+  // process and will add them to each thread that is attached to
+  // via the (FIXME implement) OnThreadAttached () method.
+
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+
+  // Update the thread list
+  UpdateThreads();
+
+  // Keep track of the threads we successfully set the watchpoint
+  // for.  If one of the thread watchpoint setting operations fails,
+  // back off and remove the watchpoint for all the threads that
+  // were successfully set so we get back to a consistent state.
+  std::vector<NativeThreadProtocolSP> watchpoint_established_threads;
+
+  // Tell each thread to set a watchpoint.  In the event that
+  // hardware watchpoints are requested but the SetWatchpoint fails,
+  // try to set a software watchpoint as a fallback.  It's
+  // conceivable that if there are more threads than hardware
+  // watchpoints available, some of the threads will fail to set
+  // hardware watchpoints while software ones may be available.
+  std::lock_guard<std::recursive_mutex> guard(m_threads_mutex);
+  for (auto thread_sp : m_threads) {
+    assert(thread_sp && "thread list should not have a NULL thread!");
     if (!thread_sp)
-    {
-        if (log)
-            log->Warning ("NativeProcessProtocol::%s (): failed to find a thread to grab a NativeRegisterContext!", __FUNCTION__);
-        return 0;
-    }
+      continue;
 
-    NativeRegisterContextSP reg_ctx_sp (thread_sp->GetRegisterContext ());
-    if (!reg_ctx_sp)
-    {
+    Error thread_error =
+        thread_sp->SetWatchpoint(addr, size, watch_flags, hardware);
+    if (thread_error.Fail() && hardware) {
+      // Try software watchpoints since we failed on hardware watchpoint setting
+      // and we may have just run out of hardware watchpoints.
+      thread_error = thread_sp->SetWatchpoint(addr, size, watch_flags, false);
+      if (thread_error.Success()) {
         if (log)
-            log->Warning ("NativeProcessProtocol::%s (): failed to get a RegisterContextNativeProcess from the first thread!", __FUNCTION__);
-        return 0;
+          log->Warning(
+              "hardware watchpoint requested but software watchpoint set");
+      }
     }
 
-    return reg_ctx_sp->NumSupportedHardwareWatchpoints ();
-}
-
-Error
-NativeProcessProtocol::SetWatchpoint (lldb::addr_t addr, size_t size, uint32_t watch_flags, bool hardware)
-{
-    // This default implementation assumes setting the watchpoint for
-    // the process will require setting the watchpoint for each of the
-    // threads.  Furthermore, it will track watchpoints set for the
-    // process and will add them to each thread that is attached to
-    // via the (FIXME implement) OnThreadAttached () method.
-
-    Log *log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
-
-    // Update the thread list
-    UpdateThreads ();
-
-    // Keep track of the threads we successfully set the watchpoint
-    // for.  If one of the thread watchpoint setting operations fails,
-    // back off and remove the watchpoint for all the threads that
-    // were successfully set so we get back to a consistent state.
-    std::vector<NativeThreadProtocolSP> watchpoint_established_threads;
-
-    // Tell each thread to set a watchpoint.  In the event that
-    // hardware watchpoints are requested but the SetWatchpoint fails,
-    // try to set a software watchpoint as a fallback.  It's
-    // conceivable that if there are more threads than hardware
-    // watchpoints available, some of the threads will fail to set
-    // hardware watchpoints while software ones may be available.
-    std::lock_guard<std::recursive_mutex> guard(m_threads_mutex);
-    for (auto thread_sp : m_threads)
-    {
-        assert (thread_sp && "thread list should not have a NULL thread!");
-        if (!thread_sp)
-            continue;
-
-        Error thread_error = thread_sp->SetWatchpoint (addr, size, watch_flags, hardware);
-        if (thread_error.Fail () && hardware)
-        {
-            // Try software watchpoints since we failed on hardware watchpoint setting
-            // and we may have just run out of hardware watchpoints.
-            thread_error = thread_sp->SetWatchpoint (addr, size, watch_flags, false);
-            if (thread_error.Success ())
-            {
-                if (log)
-                    log->Warning ("hardware watchpoint requested but software watchpoint set"); 
-            }
-        }
-
-        if (thread_error.Success ())
-        {
-            // Remember that we set this watchpoint successfully in
-            // case we need to clear it later.
-            watchpoint_established_threads.push_back (thread_sp);
+    if (thread_error.Success()) {
+      // Remember that we set this watchpoint successfully in
+      // case we need to clear it later.
+      watchpoint_established_threads.push_back(thread_sp);
+    } else {
+      // Unset the watchpoint for each thread we successfully
+      // set so that we get back to a consistent state of "not
+      // set" for the watchpoint.
+      for (auto unwatch_thread_sp : watchpoint_established_threads) {
+        Error remove_error = unwatch_thread_sp->RemoveWatchpoint(addr);
+        if (remove_error.Fail() && log) {
+          log->Warning("NativeProcessProtocol::%s (): RemoveWatchpoint failed "
+                       "for pid=%" PRIu64 ", tid=%" PRIu64 ": %s",
+                       __FUNCTION__, GetID(), unwatch_thread_sp->GetID(),
+                       remove_error.AsCString());
         }
-        else
-        {
-            // Unset the watchpoint for each thread we successfully
-            // set so that we get back to a consistent state of "not
-            // set" for the watchpoint.
-            for (auto unwatch_thread_sp : watchpoint_established_threads)
-            {
-                Error remove_error = unwatch_thread_sp->RemoveWatchpoint (addr);
-                if (remove_error.Fail () && log)
-                {
-                    log->Warning ("NativeProcessProtocol::%s (): RemoveWatchpoint failed for pid=%" PRIu64 ", tid=%" PRIu64 ": %s",
-                            __FUNCTION__, GetID (), unwatch_thread_sp->GetID (), remove_error.AsCString ());
-                }
-            }
+      }
 
-            return thread_error;
-        }
+      return thread_error;
     }
-    return m_watchpoint_list.Add (addr, size, watch_flags, hardware);
+  }
+  return m_watchpoint_list.Add(addr, size, watch_flags, hardware);
 }
 
-Error
-NativeProcessProtocol::RemoveWatchpoint (lldb::addr_t addr)
-{
-    // Update the thread list
-    UpdateThreads ();
-
-    Error overall_error;
-
-    std::lock_guard<std::recursive_mutex> guard(m_threads_mutex);
-    for (auto thread_sp : m_threads)
-    {
-        assert (thread_sp && "thread list should not have a NULL thread!");
-        if (!thread_sp)
-            continue;
-
-        const Error thread_error = thread_sp->RemoveWatchpoint (addr);
-        if (thread_error.Fail ())
-        {
-            // Keep track of the first thread error if any threads
-            // fail. We want to try to remove the watchpoint from
-            // every thread, though, even if one or more have errors.
-            if (!overall_error.Fail ())
-                overall_error = thread_error;
-        }
+Error NativeProcessProtocol::RemoveWatchpoint(lldb::addr_t addr) {
+  // Update the thread list
+  UpdateThreads();
+
+  Error overall_error;
+
+  std::lock_guard<std::recursive_mutex> guard(m_threads_mutex);
+  for (auto thread_sp : m_threads) {
+    assert(thread_sp && "thread list should not have a NULL thread!");
+    if (!thread_sp)
+      continue;
+
+    const Error thread_error = thread_sp->RemoveWatchpoint(addr);
+    if (thread_error.Fail()) {
+      // Keep track of the first thread error if any threads
+      // fail. We want to try to remove the watchpoint from
+      // every thread, though, even if one or more have errors.
+      if (!overall_error.Fail())
+        overall_error = thread_error;
     }
-    const Error error = m_watchpoint_list.Remove(addr);
-    return overall_error.Fail() ? overall_error : error;
+  }
+  const Error error = m_watchpoint_list.Remove(addr);
+  return overall_error.Fail() ? overall_error : error;
 }
 
-bool
-NativeProcessProtocol::RegisterNativeDelegate (NativeDelegate &native_delegate)
-{
-    std::lock_guard<std::recursive_mutex> guard(m_delegates_mutex);
-    if (std::find (m_delegates.begin (), m_delegates.end (), &native_delegate) != m_delegates.end ())
-        return false;
+bool NativeProcessProtocol::RegisterNativeDelegate(
+    NativeDelegate &native_delegate) {
+  std::lock_guard<std::recursive_mutex> guard(m_delegates_mutex);
+  if (std::find(m_delegates.begin(), m_delegates.end(), &native_delegate) !=
+      m_delegates.end())
+    return false;
 
-    m_delegates.push_back (&native_delegate);
-    native_delegate.InitializeDelegate (this);
-    return true;
+  m_delegates.push_back(&native_delegate);
+  native_delegate.InitializeDelegate(this);
+  return true;
+}
+
+bool NativeProcessProtocol::UnregisterNativeDelegate(
+    NativeDelegate &native_delegate) {
+  std::lock_guard<std::recursive_mutex> guard(m_delegates_mutex);
+
+  const auto initial_size = m_delegates.size();
+  m_delegates.erase(
+      remove(m_delegates.begin(), m_delegates.end(), &native_delegate),
+      m_delegates.end());
+
+  // We removed the delegate if the count of delegates shrank after
+  // removing all copies of the given native_delegate from the vector.
+  return m_delegates.size() < initial_size;
+}
+
+void NativeProcessProtocol::SynchronouslyNotifyProcessStateChanged(
+    lldb::StateType state) {
+  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+
+  std::lock_guard<std::recursive_mutex> guard(m_delegates_mutex);
+  for (auto native_delegate : m_delegates)
+    native_delegate->ProcessStateChanged(this, state);
+
+  if (log) {
+    if (!m_delegates.empty()) {
+      log->Printf("NativeProcessProtocol::%s: sent state notification [%s] "
+                  "from process %" PRIu64,
+                  __FUNCTION__, lldb_private::StateAsCString(state), GetID());
+    } else {
+      log->Printf("NativeProcessProtocol::%s: would send state notification "
+                  "[%s] from process %" PRIu64 ", but no delegates",
+                  __FUNCTION__, lldb_private::StateAsCString(state), GetID());
+    }
+  }
 }
 
-bool
-NativeProcessProtocol::UnregisterNativeDelegate (NativeDelegate &native_delegate)
-{
+void NativeProcessProtocol::NotifyDidExec() {
+  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+  if (log)
+    log->Printf("NativeProcessProtocol::%s - preparing to call delegates",
+                __FUNCTION__);
+
+  {
     std::lock_guard<std::recursive_mutex> guard(m_delegates_mutex);
+    for (auto native_delegate : m_delegates)
+      native_delegate->DidExec(this);
+  }
+}
 
-    const auto initial_size = m_delegates.size ();
-    m_delegates.erase (remove (m_delegates.begin (), m_delegates.end (), &native_delegate), m_delegates.end ());
+Error NativeProcessProtocol::SetSoftwareBreakpoint(lldb::addr_t addr,
+                                                   uint32_t size_hint) {
+  Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
+  if (log)
+    log->Printf("NativeProcessProtocol::%s addr = 0x%" PRIx64, __FUNCTION__,
+                addr);
 
-    // We removed the delegate if the count of delegates shrank after
-    // removing all copies of the given native_delegate from the vector.
-    return m_delegates.size () < initial_size;
+  return m_breakpoint_list.AddRef(
+      addr, size_hint, false,
+      [this](lldb::addr_t addr, size_t size_hint, bool /* hardware */,
+             NativeBreakpointSP &breakpoint_sp) -> Error {
+        return SoftwareBreakpoint::CreateSoftwareBreakpoint(
+            *this, addr, size_hint, breakpoint_sp);
+      });
 }
 
-void
-NativeProcessProtocol::SynchronouslyNotifyProcessStateChanged (lldb::StateType state)
-{
-    Log *log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
-
-    std::lock_guard<std::recursive_mutex> guard(m_delegates_mutex);
-    for (auto native_delegate: m_delegates)
-        native_delegate->ProcessStateChanged (this, state);
+Error NativeProcessProtocol::RemoveBreakpoint(lldb::addr_t addr) {
+  return m_breakpoint_list.DecRef(addr);
+}
 
-    if (log)
-    {
-        if (!m_delegates.empty ())
-        {
-            log->Printf ("NativeProcessProtocol::%s: sent state notification [%s] from process %" PRIu64,
-                    __FUNCTION__, lldb_private::StateAsCString (state),  GetID ());
-        }
-        else
-        {
-            log->Printf ("NativeProcessProtocol::%s: would send state notification [%s] from process %" PRIu64 ", but no delegates",
-                    __FUNCTION__, lldb_private::StateAsCString (state),  GetID ());
-        }
-    }
+Error NativeProcessProtocol::EnableBreakpoint(lldb::addr_t addr) {
+  return m_breakpoint_list.EnableBreakpoint(addr);
 }
 
-void
-NativeProcessProtocol::NotifyDidExec ()
-{
-    Log *log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
-    if (log)
-        log->Printf ("NativeProcessProtocol::%s - preparing to call delegates", __FUNCTION__);
+Error NativeProcessProtocol::DisableBreakpoint(lldb::addr_t addr) {
+  return m_breakpoint_list.DisableBreakpoint(addr);
+}
 
-    {
-        std::lock_guard<std::recursive_mutex> guard(m_delegates_mutex);
-        for (auto native_delegate: m_delegates)
-            native_delegate->DidExec (this);
-    }
+lldb::StateType NativeProcessProtocol::GetState() const {
+  std::lock_guard<std::recursive_mutex> guard(m_state_mutex);
+  return m_state;
 }
 
+void NativeProcessProtocol::SetState(lldb::StateType state,
+                                     bool notify_delegates) {
+  std::lock_guard<std::recursive_mutex> guard(m_state_mutex);
 
-Error
-NativeProcessProtocol::SetSoftwareBreakpoint (lldb::addr_t addr, uint32_t size_hint)
-{
-    Log *log (GetLogIfAnyCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
-    if (log)
-        log->Printf ("NativeProcessProtocol::%s addr = 0x%" PRIx64, __FUNCTION__, addr);
+  if (state == m_state)
+    return;
 
-    return m_breakpoint_list.AddRef (addr, size_hint, false,
-            [this] (lldb::addr_t addr, size_t size_hint, bool /* hardware */, NativeBreakpointSP &breakpoint_sp)->Error
-            { return SoftwareBreakpoint::CreateSoftwareBreakpoint (*this, addr, size_hint, breakpoint_sp); });
-}
+  m_state = state;
 
-Error
-NativeProcessProtocol::RemoveBreakpoint (lldb::addr_t addr)
-{
-    return m_breakpoint_list.DecRef (addr);
-}
+  if (StateIsStoppedState(state, false)) {
+    ++m_stop_id;
 
-Error
-NativeProcessProtocol::EnableBreakpoint (lldb::addr_t addr)
-{
-    return m_breakpoint_list.EnableBreakpoint (addr);
-}
+    // Give process a chance to do any stop id bump processing, such as
+    // clearing cached data that is invalidated each time the process runs.
+    // Note if/when we support some threads running, we'll end up needing
+    // to manage this per thread and per process.
+    DoStopIDBumped(m_stop_id);
+  }
 
-Error
-NativeProcessProtocol::DisableBreakpoint (lldb::addr_t addr)
-{
-    return m_breakpoint_list.DisableBreakpoint (addr);
+  // Optionally notify delegates of the state change.
+  if (notify_delegates)
+    SynchronouslyNotifyProcessStateChanged(state);
 }
 
-lldb::StateType
-NativeProcessProtocol::GetState () const
-{
-    std::lock_guard<std::recursive_mutex> guard(m_state_mutex);
-    return m_state;
+uint32_t NativeProcessProtocol::GetStopID() const {
+  std::lock_guard<std::recursive_mutex> guard(m_state_mutex);
+  return m_stop_id;
 }
 
-void
-NativeProcessProtocol::SetState (lldb::StateType state, bool notify_delegates)
-{
-    std::lock_guard<std::recursive_mutex> guard(m_state_mutex);
-
-    if (state == m_state)
-        return;
+void NativeProcessProtocol::DoStopIDBumped(uint32_t /* newBumpId */) {
+  // Default implementation does nothing.
+}
 
-    m_state = state;
+Error NativeProcessProtocol::ResolveProcessArchitecture(lldb::pid_t pid,
+                                                        ArchSpec &arch) {
+  // Grab process info for the running process.
+  ProcessInstanceInfo process_info;
+  if (!Host::GetProcessInfo(pid, process_info))
+    return Error("failed to get process info");
 
-    if (StateIsStoppedState (state, false))
-    {
-        ++m_stop_id;
+  // Resolve the executable module.
+  ModuleSpecList module_specs;
+  if (!ObjectFile::GetModuleSpecifications(process_info.GetExecutableFile(), 0,
+                                           0, module_specs))
+    return Error("failed to get module specifications");
+  lldbassert(module_specs.GetSize() == 1);
 
-        // Give process a chance to do any stop id bump processing, such as
-        // clearing cached data that is invalidated each time the process runs.
-        // Note if/when we support some threads running, we'll end up needing
-        // to manage this per thread and per process.
-        DoStopIDBumped (m_stop_id);
-    }
-
-    // Optionally notify delegates of the state change.
-    if (notify_delegates)
-        SynchronouslyNotifyProcessStateChanged (state);
-}
-
-uint32_t NativeProcessProtocol::GetStopID () const
-{
-    std::lock_guard<std::recursive_mutex> guard(m_state_mutex);
-    return m_stop_id;
-}
-
-void
-NativeProcessProtocol::DoStopIDBumped (uint32_t /* newBumpId */)
-{
-    // Default implementation does nothing.
-}
-
-Error
-NativeProcessProtocol::ResolveProcessArchitecture(lldb::pid_t pid,
-                                                  ArchSpec &arch)
-{
-    // Grab process info for the running process.
-    ProcessInstanceInfo process_info;
-    if (!Host::GetProcessInfo(pid, process_info))
-        return Error("failed to get process info");
-
-    // Resolve the executable module.
-    ModuleSpecList module_specs;
-    if (!ObjectFile::GetModuleSpecifications(process_info.GetExecutableFile(),
-                                             0, 0, module_specs))
-        return Error("failed to get module specifications");
-    lldbassert(module_specs.GetSize() == 1);
-
-    arch = module_specs.GetModuleSpecRefAtIndex(0).GetArchitecture();
-    if (arch.IsValid())
-        return Error();
-    else
-        return Error("failed to retrieve a valid architecture from the exe module");
+  arch = module_specs.GetModuleSpecRefAtIndex(0).GetArchitecture();
+  if (arch.IsValid())
+    return Error();
+  else
+    return Error("failed to retrieve a valid architecture from the exe module");
 }
 
 #ifndef __linux__
-// These need to be implemented to support lldb-gdb-server on a given platform. Stubs are
+// These need to be implemented to support lldb-gdb-server on a given platform.
+// Stubs are
 // provided to make the rest of the code link on non-supported platforms.
 
-Error
-NativeProcessProtocol::Launch (ProcessLaunchInfo &launch_info,
-        NativeDelegate &native_delegate,
-        MainLoop &mainloop,
-        NativeProcessProtocolSP &process_sp)
-{
-    llvm_unreachable("Platform has no NativeProcessProtocol support");
-}
-
-Error
-NativeProcessProtocol::Attach (lldb::pid_t pid,
-        NativeDelegate &native_delegate,
-        MainLoop &mainloop,
-        NativeProcessProtocolSP &process_sp)
-{
-    llvm_unreachable("Platform has no NativeProcessProtocol support");
+Error NativeProcessProtocol::Launch(ProcessLaunchInfo &launch_info,
+                                    NativeDelegate &native_delegate,
+                                    MainLoop &mainloop,
+                                    NativeProcessProtocolSP &process_sp) {
+  llvm_unreachable("Platform has no NativeProcessProtocol support");
+}
+
+Error NativeProcessProtocol::Attach(lldb::pid_t pid,
+                                    NativeDelegate &native_delegate,
+                                    MainLoop &mainloop,
+                                    NativeProcessProtocolSP &process_sp) {
+  llvm_unreachable("Platform has no NativeProcessProtocol support");
 }
 
 #endif

Modified: lldb/trunk/source/Host/common/NativeRegisterContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/NativeRegisterContext.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/NativeRegisterContext.cpp (original)
+++ lldb/trunk/source/Host/common/NativeRegisterContext.cpp Tue Sep  6 15:57:50 2016
@@ -12,25 +12,21 @@
 #include "lldb/Core/Log.h"
 #include "lldb/Core/RegisterValue.h"
 
+#include "lldb/Host/PosixApi.h"
 #include "lldb/Host/common/NativeProcessProtocol.h"
 #include "lldb/Host/common/NativeThreadProtocol.h"
-#include "lldb/Host/PosixApi.h"
 
 using namespace lldb;
 using namespace lldb_private;
 
-NativeRegisterContext::NativeRegisterContext (NativeThreadProtocol &thread, uint32_t concrete_frame_idx) :
-    m_thread (thread),
-    m_concrete_frame_idx (concrete_frame_idx)
-{
-}
+NativeRegisterContext::NativeRegisterContext(NativeThreadProtocol &thread,
+                                             uint32_t concrete_frame_idx)
+    : m_thread(thread), m_concrete_frame_idx(concrete_frame_idx) {}
 
 //----------------------------------------------------------------------
 // Destructor
 //----------------------------------------------------------------------
-NativeRegisterContext::~NativeRegisterContext()
-{
-}
+NativeRegisterContext::~NativeRegisterContext() {}
 
 // FIXME revisit invalidation, process stop ids, etc.  Right now we don't
 // support caching in NativeRegisterContext.  We can do this later by
@@ -59,459 +55,385 @@ NativeRegisterContext::~NativeRegisterCo
 //     }
 // }
 
-
 const RegisterInfo *
-NativeRegisterContext::GetRegisterInfoByName (const char *reg_name, uint32_t start_idx)
-{
-    if (reg_name && reg_name[0])
-    {
-        const uint32_t num_registers = GetRegisterCount();
-        for (uint32_t reg = start_idx; reg < num_registers; ++reg)
-        {
-            const RegisterInfo * reg_info = GetRegisterInfoAtIndex(reg);
-
-            if ((reg_info->name != nullptr && ::strcasecmp (reg_info->name, reg_name) == 0) ||
-                (reg_info->alt_name != nullptr && ::strcasecmp (reg_info->alt_name, reg_name) == 0))
-            {
-                return reg_info;
-            }
-        }
-    }
+NativeRegisterContext::GetRegisterInfoByName(const char *reg_name,
+                                             uint32_t start_idx) {
+  if (reg_name && reg_name[0]) {
+    const uint32_t num_registers = GetRegisterCount();
+    for (uint32_t reg = start_idx; reg < num_registers; ++reg) {
+      const RegisterInfo *reg_info = GetRegisterInfoAtIndex(reg);
+
+      if ((reg_info->name != nullptr &&
+           ::strcasecmp(reg_info->name, reg_name) == 0) ||
+          (reg_info->alt_name != nullptr &&
+           ::strcasecmp(reg_info->alt_name, reg_name) == 0)) {
+        return reg_info;
+      }
+    }
+  }
+  return nullptr;
+}
+
+const RegisterInfo *NativeRegisterContext::GetRegisterInfo(uint32_t kind,
+                                                           uint32_t num) {
+  const uint32_t reg_num = ConvertRegisterKindToRegisterNumber(kind, num);
+  if (reg_num == LLDB_INVALID_REGNUM)
     return nullptr;
+  return GetRegisterInfoAtIndex(reg_num);
 }
 
-const RegisterInfo *
-NativeRegisterContext::GetRegisterInfo (uint32_t kind, uint32_t num)
-{
-    const uint32_t reg_num = ConvertRegisterKindToRegisterNumber(kind, num);
-    if (reg_num == LLDB_INVALID_REGNUM)
-        return nullptr;
-    return GetRegisterInfoAtIndex (reg_num);
+const char *NativeRegisterContext::GetRegisterName(uint32_t reg) {
+  const RegisterInfo *reg_info = GetRegisterInfoAtIndex(reg);
+  if (reg_info)
+    return reg_info->name;
+  return nullptr;
 }
 
-const char *
-NativeRegisterContext::GetRegisterName (uint32_t reg)
-{
-    const RegisterInfo * reg_info = GetRegisterInfoAtIndex(reg);
-    if (reg_info)
-        return reg_info->name;
+const char *NativeRegisterContext::GetRegisterSetNameForRegisterAtIndex(
+    uint32_t reg_index) const {
+  const RegisterInfo *const reg_info = GetRegisterInfoAtIndex(reg_index);
+  if (!reg_info)
     return nullptr;
-}
 
-const char*
-NativeRegisterContext::GetRegisterSetNameForRegisterAtIndex (uint32_t reg_index) const
-{
-    const RegisterInfo *const reg_info = GetRegisterInfoAtIndex(reg_index);
-    if (!reg_info)
-        return nullptr;
-
-    for (uint32_t set_index = 0; set_index < GetRegisterSetCount (); ++set_index)
-    {
-        const RegisterSet *const reg_set = GetRegisterSet (set_index);
-        if (!reg_set)
-            continue;
-
-        for (uint32_t reg_num_index = 0; reg_num_index < reg_set->num_registers; ++reg_num_index)
-        {
-            const uint32_t reg_num = reg_set->registers[reg_num_index];
-            // FIXME double check we're checking the right register kind here.
-            if (reg_info->kinds[RegisterKind::eRegisterKindLLDB] == reg_num)
-            {
-                // The given register is a member of this register set.  Return the register set name.
-                return reg_set->name;
-            }
-        }
-    }
+  for (uint32_t set_index = 0; set_index < GetRegisterSetCount(); ++set_index) {
+    const RegisterSet *const reg_set = GetRegisterSet(set_index);
+    if (!reg_set)
+      continue;
+
+    for (uint32_t reg_num_index = 0; reg_num_index < reg_set->num_registers;
+         ++reg_num_index) {
+      const uint32_t reg_num = reg_set->registers[reg_num_index];
+      // FIXME double check we're checking the right register kind here.
+      if (reg_info->kinds[RegisterKind::eRegisterKindLLDB] == reg_num) {
+        // The given register is a member of this register set.  Return the
+        // register set name.
+        return reg_set->name;
+      }
+    }
+  }
+
+  // Didn't find it.
+  return nullptr;
+}
+
+lldb::addr_t NativeRegisterContext::GetPC(lldb::addr_t fail_value) {
+  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
+
+  uint32_t reg = ConvertRegisterKindToRegisterNumber(eRegisterKindGeneric,
+                                                     LLDB_REGNUM_GENERIC_PC);
+  if (log)
+    log->Printf("NativeRegisterContext::%s using reg index %" PRIu32
+                " (default %" PRIu64 ")",
+                __FUNCTION__, reg, fail_value);
+
+  const uint64_t retval = ReadRegisterAsUnsigned(reg, fail_value);
+
+  if (log)
+    log->Printf("NativeRegisterContext::%s " PRIu32 " retval %" PRIu64,
+                __FUNCTION__, retval);
 
-    // Didn't find it.
-    return nullptr;
+  return retval;
 }
 
 lldb::addr_t
-NativeRegisterContext::GetPC (lldb::addr_t fail_value)
-{
-    Log *log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));
-
-    uint32_t reg = ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC);
-    if (log)
-        log->Printf ("NativeRegisterContext::%s using reg index %" PRIu32 " (default %" PRIu64 ")", __FUNCTION__, reg, fail_value);
-
-    const uint64_t retval = ReadRegisterAsUnsigned (reg, fail_value);
-
-    if (log)
-        log->Printf ("NativeRegisterContext::%s " PRIu32 " retval %" PRIu64, __FUNCTION__, retval);
-
-    return retval;
+NativeRegisterContext::GetPCfromBreakpointLocation(lldb::addr_t fail_value) {
+  return GetPC(fail_value);
 }
 
-lldb::addr_t
-NativeRegisterContext::GetPCfromBreakpointLocation (lldb::addr_t fail_value)
-{
-    return GetPC (fail_value);
+Error NativeRegisterContext::SetPC(lldb::addr_t pc) {
+  uint32_t reg = ConvertRegisterKindToRegisterNumber(eRegisterKindGeneric,
+                                                     LLDB_REGNUM_GENERIC_PC);
+  return WriteRegisterFromUnsigned(reg, pc);
 }
 
-Error
-NativeRegisterContext::SetPC (lldb::addr_t pc)
-{
-    uint32_t reg = ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC);
-    return WriteRegisterFromUnsigned (reg, pc);
+lldb::addr_t NativeRegisterContext::GetSP(lldb::addr_t fail_value) {
+  uint32_t reg = ConvertRegisterKindToRegisterNumber(eRegisterKindGeneric,
+                                                     LLDB_REGNUM_GENERIC_SP);
+  return ReadRegisterAsUnsigned(reg, fail_value);
 }
 
-lldb::addr_t
-NativeRegisterContext::GetSP (lldb::addr_t fail_value)
-{
-    uint32_t reg = ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP);
-    return ReadRegisterAsUnsigned (reg, fail_value);
+Error NativeRegisterContext::SetSP(lldb::addr_t sp) {
+  uint32_t reg = ConvertRegisterKindToRegisterNumber(eRegisterKindGeneric,
+                                                     LLDB_REGNUM_GENERIC_SP);
+  return WriteRegisterFromUnsigned(reg, sp);
 }
 
-Error
-NativeRegisterContext::SetSP (lldb::addr_t sp)
-{
-    uint32_t reg = ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP);
-    return WriteRegisterFromUnsigned (reg, sp);
+lldb::addr_t NativeRegisterContext::GetFP(lldb::addr_t fail_value) {
+  uint32_t reg = ConvertRegisterKindToRegisterNumber(eRegisterKindGeneric,
+                                                     LLDB_REGNUM_GENERIC_FP);
+  return ReadRegisterAsUnsigned(reg, fail_value);
 }
 
-lldb::addr_t
-NativeRegisterContext::GetFP (lldb::addr_t fail_value)
-{
-    uint32_t reg = ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FP);
-    return ReadRegisterAsUnsigned (reg, fail_value);
+Error NativeRegisterContext::SetFP(lldb::addr_t fp) {
+  uint32_t reg = ConvertRegisterKindToRegisterNumber(eRegisterKindGeneric,
+                                                     LLDB_REGNUM_GENERIC_FP);
+  return WriteRegisterFromUnsigned(reg, fp);
 }
 
-Error
-NativeRegisterContext::SetFP (lldb::addr_t fp)
-{
-    uint32_t reg = ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FP);
-    return WriteRegisterFromUnsigned (reg, fp);
+lldb::addr_t NativeRegisterContext::GetReturnAddress(lldb::addr_t fail_value) {
+  uint32_t reg = ConvertRegisterKindToRegisterNumber(eRegisterKindGeneric,
+                                                     LLDB_REGNUM_GENERIC_RA);
+  return ReadRegisterAsUnsigned(reg, fail_value);
 }
 
-lldb::addr_t
-NativeRegisterContext::GetReturnAddress (lldb::addr_t fail_value)
-{
-    uint32_t reg = ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_RA);
-    return ReadRegisterAsUnsigned (reg, fail_value);
+lldb::addr_t NativeRegisterContext::GetFlags(lldb::addr_t fail_value) {
+  uint32_t reg = ConvertRegisterKindToRegisterNumber(eRegisterKindGeneric,
+                                                     LLDB_REGNUM_GENERIC_FLAGS);
+  return ReadRegisterAsUnsigned(reg, fail_value);
 }
 
 lldb::addr_t
-NativeRegisterContext::GetFlags (lldb::addr_t fail_value)
-{
-    uint32_t reg = ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FLAGS);
-    return ReadRegisterAsUnsigned (reg, fail_value);
+NativeRegisterContext::ReadRegisterAsUnsigned(uint32_t reg,
+                                              lldb::addr_t fail_value) {
+  if (reg != LLDB_INVALID_REGNUM)
+    return ReadRegisterAsUnsigned(GetRegisterInfoAtIndex(reg), fail_value);
+  return fail_value;
 }
 
+uint64_t
+NativeRegisterContext::ReadRegisterAsUnsigned(const RegisterInfo *reg_info,
+                                              lldb::addr_t fail_value) {
+  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
 
-lldb::addr_t
-NativeRegisterContext::ReadRegisterAsUnsigned (uint32_t reg, lldb::addr_t fail_value)
-{
-    if (reg != LLDB_INVALID_REGNUM)
-        return ReadRegisterAsUnsigned (GetRegisterInfoAtIndex (reg), fail_value);
-    return fail_value;
+  if (reg_info) {
+    RegisterValue value;
+    Error error = ReadRegister(reg_info, value);
+    if (error.Success()) {
+      if (log)
+        log->Printf("NativeRegisterContext::%s ReadRegister() succeeded, value "
+                    "%" PRIu64,
+                    __FUNCTION__, value.GetAsUInt64());
+      return value.GetAsUInt64();
+    } else {
+      if (log)
+        log->Printf("NativeRegisterContext::%s ReadRegister() failed, error %s",
+                    __FUNCTION__, error.AsCString());
+    }
+  } else {
+    if (log)
+      log->Printf("NativeRegisterContext::%s ReadRegister() null reg_info",
+                  __FUNCTION__);
+  }
+  return fail_value;
 }
 
-uint64_t
-NativeRegisterContext::ReadRegisterAsUnsigned (const RegisterInfo *reg_info, lldb::addr_t fail_value)
-{
-    Log *log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));
-
-    if (reg_info)
-    {
-        RegisterValue value;
-        Error error = ReadRegister (reg_info, value);
-        if (error.Success ())
-        {
-            if (log)
-                log->Printf ("NativeRegisterContext::%s ReadRegister() succeeded, value %" PRIu64, __FUNCTION__, value.GetAsUInt64());
-            return value.GetAsUInt64();
-        }
-        else
-        {
-            if (log)
-                log->Printf ("NativeRegisterContext::%s ReadRegister() failed, error %s", __FUNCTION__, error.AsCString ());
-        }
-    }
-    else
-    {
-        if (log)
-            log->Printf ("NativeRegisterContext::%s ReadRegister() null reg_info", __FUNCTION__);
-    }
-    return fail_value;
+Error NativeRegisterContext::WriteRegisterFromUnsigned(uint32_t reg,
+                                                       uint64_t uval) {
+  if (reg == LLDB_INVALID_REGNUM)
+    return Error("NativeRegisterContext::%s (): reg is invalid", __FUNCTION__);
+  return WriteRegisterFromUnsigned(GetRegisterInfoAtIndex(reg), uval);
 }
 
-Error
-NativeRegisterContext::WriteRegisterFromUnsigned (uint32_t reg, uint64_t uval)
-{
-    if (reg == LLDB_INVALID_REGNUM)
-        return Error ("NativeRegisterContext::%s (): reg is invalid", __FUNCTION__);
-    return WriteRegisterFromUnsigned (GetRegisterInfoAtIndex (reg), uval);
-}
-
-Error
-NativeRegisterContext::WriteRegisterFromUnsigned (const RegisterInfo *reg_info, uint64_t uval)
-{
-    assert (reg_info);
-    if (!reg_info)
-        return Error ("reg_info is nullptr");
+Error NativeRegisterContext::WriteRegisterFromUnsigned(
+    const RegisterInfo *reg_info, uint64_t uval) {
+  assert(reg_info);
+  if (!reg_info)
+    return Error("reg_info is nullptr");
 
-    RegisterValue value;
-    if (!value.SetUInt(uval, reg_info->byte_size))
-        return Error ("RegisterValue::SetUInt () failed");
+  RegisterValue value;
+  if (!value.SetUInt(uval, reg_info->byte_size))
+    return Error("RegisterValue::SetUInt () failed");
 
-    return WriteRegister (reg_info, value);
+  return WriteRegister(reg_info, value);
 }
 
-lldb::tid_t
-NativeRegisterContext::GetThreadID() const
-{
-    return m_thread.GetID();
+lldb::tid_t NativeRegisterContext::GetThreadID() const {
+  return m_thread.GetID();
 }
 
-uint32_t
-NativeRegisterContext::NumSupportedHardwareBreakpoints ()
-{
-    return 0;
-}
+uint32_t NativeRegisterContext::NumSupportedHardwareBreakpoints() { return 0; }
 
-uint32_t
-NativeRegisterContext::SetHardwareBreakpoint (lldb::addr_t addr, size_t size)
-{
-    return LLDB_INVALID_INDEX32;
+uint32_t NativeRegisterContext::SetHardwareBreakpoint(lldb::addr_t addr,
+                                                      size_t size) {
+  return LLDB_INVALID_INDEX32;
 }
 
-bool
-NativeRegisterContext::ClearHardwareBreakpoint (uint32_t hw_idx)
-{
-    return false;
+bool NativeRegisterContext::ClearHardwareBreakpoint(uint32_t hw_idx) {
+  return false;
 }
 
+uint32_t NativeRegisterContext::NumSupportedHardwareWatchpoints() { return 0; }
 
-uint32_t
-NativeRegisterContext::NumSupportedHardwareWatchpoints ()
-{
-    return 0;
+uint32_t NativeRegisterContext::SetHardwareWatchpoint(lldb::addr_t addr,
+                                                      size_t size,
+                                                      uint32_t watch_flags) {
+  return LLDB_INVALID_INDEX32;
 }
 
-uint32_t
-NativeRegisterContext::SetHardwareWatchpoint (lldb::addr_t addr, size_t size, uint32_t watch_flags)
-{
-    return LLDB_INVALID_INDEX32;
+bool NativeRegisterContext::ClearHardwareWatchpoint(uint32_t hw_index) {
+  return false;
 }
 
-bool
-NativeRegisterContext::ClearHardwareWatchpoint (uint32_t hw_index)
-{
-    return false;
+Error NativeRegisterContext::ClearAllHardwareWatchpoints() {
+  return Error("not implemented");
 }
 
-Error
-NativeRegisterContext::ClearAllHardwareWatchpoints ()
-{
-    return Error ("not implemented");
+Error NativeRegisterContext::IsWatchpointHit(uint32_t wp_index, bool &is_hit) {
+  is_hit = false;
+  return Error("not implemented");
 }
 
-Error
-NativeRegisterContext::IsWatchpointHit(uint32_t wp_index, bool &is_hit)
-{
-    is_hit = false;
-    return Error ("not implemented");
+Error NativeRegisterContext::GetWatchpointHitIndex(uint32_t &wp_index,
+                                                   lldb::addr_t trap_addr) {
+  wp_index = LLDB_INVALID_INDEX32;
+  return Error("not implemented");
 }
 
-Error
-NativeRegisterContext::GetWatchpointHitIndex(uint32_t &wp_index, lldb::addr_t trap_addr)
-{
-    wp_index = LLDB_INVALID_INDEX32;
-    return Error ("not implemented");
+Error NativeRegisterContext::IsWatchpointVacant(uint32_t wp_index,
+                                                bool &is_vacant) {
+  is_vacant = false;
+  return Error("not implemented");
 }
 
-Error
-NativeRegisterContext::IsWatchpointVacant (uint32_t wp_index, bool &is_vacant)
-{
-    is_vacant = false;
-    return Error ("not implemented");
+lldb::addr_t NativeRegisterContext::GetWatchpointAddress(uint32_t wp_index) {
+  return LLDB_INVALID_ADDRESS;
 }
 
-lldb::addr_t
-NativeRegisterContext::GetWatchpointAddress (uint32_t wp_index)
-{
-    return LLDB_INVALID_ADDRESS;
+lldb::addr_t NativeRegisterContext::GetWatchpointHitAddress(uint32_t wp_index) {
+  return LLDB_INVALID_ADDRESS;
 }
 
-lldb::addr_t
-NativeRegisterContext::GetWatchpointHitAddress (uint32_t wp_index)
-{
-    return LLDB_INVALID_ADDRESS;
-}
-
-bool
-NativeRegisterContext::HardwareSingleStep (bool enable)
-{
-    return false;
-}
-
-Error
-NativeRegisterContext::ReadRegisterValueFromMemory (
-    const RegisterInfo *reg_info,
-    lldb::addr_t src_addr,
-    size_t src_len,
-    RegisterValue &reg_value)
-{
-    Error error;
-    if (reg_info == nullptr)
-    {
-        error.SetErrorString ("invalid register info argument.");
-        return error;
-    }
+bool NativeRegisterContext::HardwareSingleStep(bool enable) { return false; }
 
+Error NativeRegisterContext::ReadRegisterValueFromMemory(
+    const RegisterInfo *reg_info, lldb::addr_t src_addr, size_t src_len,
+    RegisterValue &reg_value) {
+  Error error;
+  if (reg_info == nullptr) {
+    error.SetErrorString("invalid register info argument.");
+    return error;
+  }
 
-    // Moving from addr into a register
-    //
-    // Case 1: src_len == dst_len
-    //
-    //   |AABBCCDD| Address contents
-    //   |AABBCCDD| Register contents
-    //
-    // Case 2: src_len > dst_len
-    //
-    //   Error!  (The register should always be big enough to hold the data)
-    //
-    // Case 3: src_len < dst_len
-    //
-    //   |AABB| Address contents
-    //   |AABB0000| Register contents [on little-endian hardware]
-    //   |0000AABB| Register contents [on big-endian hardware]
-    if (src_len > RegisterValue::kMaxRegisterByteSize)
-    {
-        error.SetErrorString ("register too small to receive memory data");
-        return error;
-    }
+  // Moving from addr into a register
+  //
+  // Case 1: src_len == dst_len
+  //
+  //   |AABBCCDD| Address contents
+  //   |AABBCCDD| Register contents
+  //
+  // Case 2: src_len > dst_len
+  //
+  //   Error!  (The register should always be big enough to hold the data)
+  //
+  // Case 3: src_len < dst_len
+  //
+  //   |AABB| Address contents
+  //   |AABB0000| Register contents [on little-endian hardware]
+  //   |0000AABB| Register contents [on big-endian hardware]
+  if (src_len > RegisterValue::kMaxRegisterByteSize) {
+    error.SetErrorString("register too small to receive memory data");
+    return error;
+  }
 
-    const size_t dst_len = reg_info->byte_size;
+  const size_t dst_len = reg_info->byte_size;
 
-    if (src_len > dst_len)
-    {
-        error.SetErrorStringWithFormat("%" PRIu64 " bytes is too big to store in register %s (%" PRIu64 " bytes)",
-                static_cast<uint64_t>(src_len), reg_info->name, static_cast<uint64_t>(dst_len));
-        return error;
-    }
+  if (src_len > dst_len) {
+    error.SetErrorStringWithFormat(
+        "%" PRIu64 " bytes is too big to store in register %s (%" PRIu64
+        " bytes)",
+        static_cast<uint64_t>(src_len), reg_info->name,
+        static_cast<uint64_t>(dst_len));
+    return error;
+  }
 
-    NativeProcessProtocolSP process_sp (m_thread.GetProcess ());
-    if (!process_sp)
-    {
-        error.SetErrorString("invalid process");
-        return error;
-    }
+  NativeProcessProtocolSP process_sp(m_thread.GetProcess());
+  if (!process_sp) {
+    error.SetErrorString("invalid process");
+    return error;
+  }
 
-    uint8_t src[RegisterValue::kMaxRegisterByteSize];
+  uint8_t src[RegisterValue::kMaxRegisterByteSize];
 
-    // Read the memory
-    size_t bytes_read;
-    error = process_sp->ReadMemory (src_addr, src, src_len, bytes_read);
-    if (error.Fail ())
-        return error;
-
-    // Make sure the memory read succeeded...
-    if (bytes_read != src_len)
-    {
-        // This might happen if we read _some_ bytes but not all
-        error.SetErrorStringWithFormat("read %" PRIu64 " of %" PRIu64 " bytes",
-                static_cast<uint64_t>(bytes_read), static_cast<uint64_t>(src_len));
-        return error;
-    }
+  // Read the memory
+  size_t bytes_read;
+  error = process_sp->ReadMemory(src_addr, src, src_len, bytes_read);
+  if (error.Fail())
+    return error;
+
+  // Make sure the memory read succeeded...
+  if (bytes_read != src_len) {
+    // This might happen if we read _some_ bytes but not all
+    error.SetErrorStringWithFormat("read %" PRIu64 " of %" PRIu64 " bytes",
+                                   static_cast<uint64_t>(bytes_read),
+                                   static_cast<uint64_t>(src_len));
+    return error;
+  }
+
+  // We now have a memory buffer that contains the part or all of the register
+  // value. Set the register value using this memory data.
+  // TODO: we might need to add a parameter to this function in case the byte
+  // order of the memory data doesn't match the process. For now we are assuming
+  // they are the same.
+  lldb::ByteOrder byte_order;
+  if (!process_sp->GetByteOrder(byte_order)) {
+    error.SetErrorString("NativeProcessProtocol::GetByteOrder () failed");
+    return error;
+  }
+
+  reg_value.SetFromMemoryData(reg_info, src, src_len, byte_order, error);
+
+  return error;
+}
+
+Error NativeRegisterContext::WriteRegisterValueToMemory(
+    const RegisterInfo *reg_info, lldb::addr_t dst_addr, size_t dst_len,
+    const RegisterValue &reg_value) {
+
+  uint8_t dst[RegisterValue::kMaxRegisterByteSize];
+
+  Error error;
+
+  NativeProcessProtocolSP process_sp(m_thread.GetProcess());
+  if (process_sp) {
 
-    // We now have a memory buffer that contains the part or all of the register
-    // value. Set the register value using this memory data.
     // TODO: we might need to add a parameter to this function in case the byte
-    // order of the memory data doesn't match the process. For now we are assuming
+    // order of the memory data doesn't match the process. For now we are
+    // assuming
     // they are the same.
     lldb::ByteOrder byte_order;
-    if (!process_sp->GetByteOrder (byte_order))
-    {
-        error.SetErrorString ( "NativeProcessProtocol::GetByteOrder () failed");
-        return error;
-    }
+    if (!process_sp->GetByteOrder(byte_order))
+      return Error("NativeProcessProtocol::GetByteOrder () failed");
 
-    reg_value.SetFromMemoryData (
-        reg_info,
-        src,
-        src_len,
-        byte_order,
-        error);
+    const size_t bytes_copied =
+        reg_value.GetAsMemoryData(reg_info, dst, dst_len, byte_order, error);
 
-    return error;
-}
-
-Error
-NativeRegisterContext::WriteRegisterValueToMemory (
-    const RegisterInfo *reg_info,
-    lldb::addr_t dst_addr,
-    size_t dst_len,
-    const RegisterValue &reg_value)
-{
-    
-    uint8_t dst[RegisterValue::kMaxRegisterByteSize];
-
-    Error error;
-
-    NativeProcessProtocolSP process_sp (m_thread.GetProcess ());
-    if (process_sp)
-    {
-
-        // TODO: we might need to add a parameter to this function in case the byte
-        // order of the memory data doesn't match the process. For now we are assuming
-        // they are the same.
-        lldb::ByteOrder byte_order;
-        if (!process_sp->GetByteOrder (byte_order))
-            return Error ("NativeProcessProtocol::GetByteOrder () failed");
-
-        const size_t bytes_copied = reg_value.GetAsMemoryData (
-            reg_info,
-            dst,
-            dst_len,
-            byte_order,
-            error);
-
-        if (error.Success())
-        {
-            if (bytes_copied == 0)
-            {
-                error.SetErrorString("byte copy failed.");
-            }
-            else
-            {
-                size_t bytes_written;
-                error = process_sp->WriteMemory(dst_addr, dst, bytes_copied, bytes_written);
-                if (error.Fail ())
-                    return error;
-
-                if (bytes_written != bytes_copied)
-                {
-                    // This might happen if we read _some_ bytes but not all
-                    error.SetErrorStringWithFormat("only wrote %" PRIu64 " of %" PRIu64 " bytes",
-                            static_cast<uint64_t>(bytes_written), static_cast<uint64_t>(bytes_copied));
-                }
-            }
+    if (error.Success()) {
+      if (bytes_copied == 0) {
+        error.SetErrorString("byte copy failed.");
+      } else {
+        size_t bytes_written;
+        error =
+            process_sp->WriteMemory(dst_addr, dst, bytes_copied, bytes_written);
+        if (error.Fail())
+          return error;
+
+        if (bytes_written != bytes_copied) {
+          // This might happen if we read _some_ bytes but not all
+          error.SetErrorStringWithFormat("only wrote %" PRIu64 " of %" PRIu64
+                                         " bytes",
+                                         static_cast<uint64_t>(bytes_written),
+                                         static_cast<uint64_t>(bytes_copied));
         }
+      }
     }
-    else
-        error.SetErrorString("invalid process");
+  } else
+    error.SetErrorString("invalid process");
 
-    return error;
+  return error;
 }
 
 uint32_t
-NativeRegisterContext::ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t num) const
-{
-    const uint32_t num_regs = GetRegisterCount();
-
-    assert (kind < kNumRegisterKinds);
-    for (uint32_t reg_idx = 0; reg_idx < num_regs; ++reg_idx)
-    {
-        const RegisterInfo *reg_info = GetRegisterInfoAtIndex (reg_idx);
+NativeRegisterContext::ConvertRegisterKindToRegisterNumber(uint32_t kind,
+                                                           uint32_t num) const {
+  const uint32_t num_regs = GetRegisterCount();
+
+  assert(kind < kNumRegisterKinds);
+  for (uint32_t reg_idx = 0; reg_idx < num_regs; ++reg_idx) {
+    const RegisterInfo *reg_info = GetRegisterInfoAtIndex(reg_idx);
+
+    if (reg_info->kinds[kind] == num)
+      return reg_idx;
+  }
 
-        if (reg_info->kinds[kind] == num)
-            return reg_idx;
-    }
-
-    return LLDB_INVALID_REGNUM;
+  return LLDB_INVALID_REGNUM;
 }
-
-

Modified: lldb/trunk/source/Host/common/NativeRegisterContextRegisterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/NativeRegisterContextRegisterInfo.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/NativeRegisterContextRegisterInfo.cpp (original)
+++ lldb/trunk/source/Host/common/NativeRegisterContextRegisterInfo.cpp Tue Sep  6 15:57:50 2016
@@ -7,44 +7,37 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "lldb/lldb-types.h"
-#include "lldb/lldb-private-forward.h"
 #include "lldb/Host/common/NativeRegisterContextRegisterInfo.h"
+#include "lldb/lldb-private-forward.h"
+#include "lldb/lldb-types.h"
 
 using namespace lldb_private;
 
-NativeRegisterContextRegisterInfo::NativeRegisterContextRegisterInfo (NativeThreadProtocol &thread,
-                                                                      uint32_t concrete_frame_idx,
-                                                                      RegisterInfoInterface *register_info_interface) :
-    NativeRegisterContext (thread, concrete_frame_idx),
-    m_register_info_interface_up (register_info_interface)
-{
-    assert (register_info_interface && "null register_info_interface");
+NativeRegisterContextRegisterInfo::NativeRegisterContextRegisterInfo(
+    NativeThreadProtocol &thread, uint32_t concrete_frame_idx,
+    RegisterInfoInterface *register_info_interface)
+    : NativeRegisterContext(thread, concrete_frame_idx),
+      m_register_info_interface_up(register_info_interface) {
+  assert(register_info_interface && "null register_info_interface");
 }
 
-uint32_t
-NativeRegisterContextRegisterInfo::GetRegisterCount () const
-{
-    return m_register_info_interface_up->GetRegisterCount ();
+uint32_t NativeRegisterContextRegisterInfo::GetRegisterCount() const {
+  return m_register_info_interface_up->GetRegisterCount();
 }
 
-uint32_t
-NativeRegisterContextRegisterInfo::GetUserRegisterCount () const
-{
-    return m_register_info_interface_up->GetUserRegisterCount ();
+uint32_t NativeRegisterContextRegisterInfo::GetUserRegisterCount() const {
+  return m_register_info_interface_up->GetUserRegisterCount();
 }
 
-const RegisterInfo *
-NativeRegisterContextRegisterInfo::GetRegisterInfoAtIndex (uint32_t reg_index) const
-{
-    if (reg_index <= GetRegisterCount ())
-        return m_register_info_interface_up->GetRegisterInfo () + reg_index;
-    else
-        return nullptr;
+const RegisterInfo *NativeRegisterContextRegisterInfo::GetRegisterInfoAtIndex(
+    uint32_t reg_index) const {
+  if (reg_index <= GetRegisterCount())
+    return m_register_info_interface_up->GetRegisterInfo() + reg_index;
+  else
+    return nullptr;
 }
 
-const RegisterInfoInterface&
-NativeRegisterContextRegisterInfo::GetRegisterInfoInterface () const
-{
-    return *m_register_info_interface_up;
+const RegisterInfoInterface &
+NativeRegisterContextRegisterInfo::GetRegisterInfoInterface() const {
+  return *m_register_info_interface_up;
 }

Modified: lldb/trunk/source/Host/common/NativeThreadProtocol.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/NativeThreadProtocol.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/NativeThreadProtocol.cpp (original)
+++ lldb/trunk/source/Host/common/NativeThreadProtocol.cpp Tue Sep  6 15:57:50 2016
@@ -16,60 +16,53 @@
 using namespace lldb;
 using namespace lldb_private;
 
-NativeThreadProtocol::NativeThreadProtocol (NativeProcessProtocol *process, lldb::tid_t tid) :
-    m_process_wp (process->shared_from_this ()),
-    m_tid (tid)
-{
-}
+NativeThreadProtocol::NativeThreadProtocol(NativeProcessProtocol *process,
+                                           lldb::tid_t tid)
+    : m_process_wp(process->shared_from_this()), m_tid(tid) {}
+
+Error NativeThreadProtocol::ReadRegister(uint32_t reg,
+                                         RegisterValue &reg_value) {
+  NativeRegisterContextSP register_context_sp = GetRegisterContext();
+  if (!register_context_sp)
+    return Error("no register context");
 
-Error
-NativeThreadProtocol::ReadRegister (uint32_t reg, RegisterValue &reg_value)
-{
-    NativeRegisterContextSP register_context_sp = GetRegisterContext ();
-    if (!register_context_sp)
-        return Error ("no register context");
-
-    const RegisterInfo *const reg_info = register_context_sp->GetRegisterInfoAtIndex (reg);
-    if (!reg_info)
-        return Error ("no register info for reg num %" PRIu32, reg);
+  const RegisterInfo *const reg_info =
+      register_context_sp->GetRegisterInfoAtIndex(reg);
+  if (!reg_info)
+    return Error("no register info for reg num %" PRIu32, reg);
 
-    return register_context_sp->ReadRegister (reg_info, reg_value);;
+  return register_context_sp->ReadRegister(reg_info, reg_value);
+  ;
 }
 
-Error
-NativeThreadProtocol::WriteRegister (uint32_t reg, const RegisterValue &reg_value)
-{
-    NativeRegisterContextSP register_context_sp = GetRegisterContext ();
-    if (!register_context_sp)
-        return Error ("no register context");
-
-    const RegisterInfo *const reg_info = register_context_sp->GetRegisterInfoAtIndex (reg);
-    if (!reg_info)
-        return Error ("no register info for reg num %" PRIu32, reg);
+Error NativeThreadProtocol::WriteRegister(uint32_t reg,
+                                          const RegisterValue &reg_value) {
+  NativeRegisterContextSP register_context_sp = GetRegisterContext();
+  if (!register_context_sp)
+    return Error("no register context");
+
+  const RegisterInfo *const reg_info =
+      register_context_sp->GetRegisterInfoAtIndex(reg);
+  if (!reg_info)
+    return Error("no register info for reg num %" PRIu32, reg);
 
-    return register_context_sp->WriteRegister (reg_info, reg_value);
+  return register_context_sp->WriteRegister(reg_info, reg_value);
 }
 
-Error
-NativeThreadProtocol::SaveAllRegisters (lldb::DataBufferSP &data_sp)
-{
-    NativeRegisterContextSP register_context_sp = GetRegisterContext ();
-    if (!register_context_sp)
-        return Error ("no register context");
-    return register_context_sp->WriteAllRegisterValues (data_sp);
+Error NativeThreadProtocol::SaveAllRegisters(lldb::DataBufferSP &data_sp) {
+  NativeRegisterContextSP register_context_sp = GetRegisterContext();
+  if (!register_context_sp)
+    return Error("no register context");
+  return register_context_sp->WriteAllRegisterValues(data_sp);
 }
 
-Error
-NativeThreadProtocol::RestoreAllRegisters (lldb::DataBufferSP &data_sp)
-{
-    NativeRegisterContextSP register_context_sp = GetRegisterContext ();
-    if (!register_context_sp)
-        return Error ("no register context");
-    return register_context_sp->ReadAllRegisterValues (data_sp);
+Error NativeThreadProtocol::RestoreAllRegisters(lldb::DataBufferSP &data_sp) {
+  NativeRegisterContextSP register_context_sp = GetRegisterContext();
+  if (!register_context_sp)
+    return Error("no register context");
+  return register_context_sp->ReadAllRegisterValues(data_sp);
 }
 
-NativeProcessProtocolSP
-NativeThreadProtocol::GetProcess ()
-{
-    return m_process_wp.lock ();
+NativeProcessProtocolSP NativeThreadProtocol::GetProcess() {
+  return m_process_wp.lock();
 }

Modified: lldb/trunk/source/Host/common/NativeWatchpointList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/NativeWatchpointList.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/NativeWatchpointList.cpp (original)
+++ lldb/trunk/source/Host/common/NativeWatchpointList.cpp Tue Sep  6 15:57:50 2016
@@ -14,22 +14,18 @@
 using namespace lldb;
 using namespace lldb_private;
 
-Error
-NativeWatchpointList::Add (addr_t addr, size_t size, uint32_t watch_flags, bool hardware)
-{
-    m_watchpoints[addr] = {addr, size, watch_flags, hardware};
-    return Error ();
+Error NativeWatchpointList::Add(addr_t addr, size_t size, uint32_t watch_flags,
+                                bool hardware) {
+  m_watchpoints[addr] = {addr, size, watch_flags, hardware};
+  return Error();
 }
 
-Error
-NativeWatchpointList::Remove (addr_t addr)
-{
-    m_watchpoints.erase(addr);
-    return Error ();
+Error NativeWatchpointList::Remove(addr_t addr) {
+  m_watchpoints.erase(addr);
+  return Error();
 }
 
-const NativeWatchpointList::WatchpointMap&
-NativeWatchpointList::GetWatchpointMap () const
-{
-    return m_watchpoints;
+const NativeWatchpointList::WatchpointMap &
+NativeWatchpointList::GetWatchpointMap() const {
+  return m_watchpoints;
 }

Modified: lldb/trunk/source/Host/common/OptionParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/OptionParser.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/OptionParser.cpp (original)
+++ lldb/trunk/source/Host/common/OptionParser.cpp Tue Sep  6 15:57:50 2016
@@ -15,102 +15,67 @@
 
 using namespace lldb_private;
 
-void
-OptionParser::Prepare(std::unique_lock<std::mutex> &lock)
-{
-    static std::mutex g_mutex;
-    lock = std::unique_lock<std::mutex>(g_mutex);
+void OptionParser::Prepare(std::unique_lock<std::mutex> &lock) {
+  static std::mutex g_mutex;
+  lock = std::unique_lock<std::mutex>(g_mutex);
 #ifdef __GLIBC__
-    optind = 0;
+  optind = 0;
 #else
-    optreset = 1;
-    optind = 1;
+  optreset = 1;
+  optind = 1;
 #endif
 }
 
-void
-OptionParser::EnableError(bool error)
-{
-    opterr = error ? 1 : 0;
-}
-
-int
-OptionParser::Parse (int argc,
-                     char * const argv [],
-                     const char *optstring,
-                     const Option *longopts,
-                     int *longindex)
-{
-    std::vector<option> opts;
-    while (longopts->definition != nullptr)
-    {
-        option opt;
-        opt.flag = longopts->flag;
-        opt.val = longopts->val;
-        opt.name = longopts->definition->long_option;
-        opt.has_arg = longopts->definition->option_has_arg;
-        opts.push_back(opt);
-        ++longopts;
-    }
-    opts.push_back(option());
-    return getopt_long_only(argc, argv, optstring, &opts[0], longindex);
-}
-
-char*
-OptionParser::GetOptionArgument()
-{
-    return optarg;
-}
+void OptionParser::EnableError(bool error) { opterr = error ? 1 : 0; }
 
-int
-OptionParser::GetOptionIndex()
-{
-    return optind;
-}
-
-int
-OptionParser::GetOptionErrorCause()
-{
-    return optopt;
-}
-
-std::string
-OptionParser::GetShortOptionString(struct option *long_options)
-{
-    std::string s;
-    int i=0;
-    bool done = false;
-    while (!done)
-    {
-        if (long_options[i].name    == 0 &&
-            long_options[i].has_arg == 0 &&
-            long_options[i].flag    == 0 &&
-            long_options[i].val     == 0)
-        {
-            done = true;
-        }
-        else
-        {
-            if (long_options[i].flag == NULL &&
-                isalpha(long_options[i].val))
-            {
-                s.append(1, (char)long_options[i].val);
-                switch (long_options[i].has_arg)
-                {
-                    default:
-                    case no_argument:
-                        break;
-                        
-                    case optional_argument:
-                        s.append(2, ':');
-                        break;
-                    case required_argument:
-                        s.append(1, ':');
-                        break;
-                }
-            }
-            ++i;
+int OptionParser::Parse(int argc, char *const argv[], const char *optstring,
+                        const Option *longopts, int *longindex) {
+  std::vector<option> opts;
+  while (longopts->definition != nullptr) {
+    option opt;
+    opt.flag = longopts->flag;
+    opt.val = longopts->val;
+    opt.name = longopts->definition->long_option;
+    opt.has_arg = longopts->definition->option_has_arg;
+    opts.push_back(opt);
+    ++longopts;
+  }
+  opts.push_back(option());
+  return getopt_long_only(argc, argv, optstring, &opts[0], longindex);
+}
+
+char *OptionParser::GetOptionArgument() { return optarg; }
+
+int OptionParser::GetOptionIndex() { return optind; }
+
+int OptionParser::GetOptionErrorCause() { return optopt; }
+
+std::string OptionParser::GetShortOptionString(struct option *long_options) {
+  std::string s;
+  int i = 0;
+  bool done = false;
+  while (!done) {
+    if (long_options[i].name == 0 && long_options[i].has_arg == 0 &&
+        long_options[i].flag == 0 && long_options[i].val == 0) {
+      done = true;
+    } else {
+      if (long_options[i].flag == NULL && isalpha(long_options[i].val)) {
+        s.append(1, (char)long_options[i].val);
+        switch (long_options[i].has_arg) {
+        default:
+        case no_argument:
+          break;
+
+        case optional_argument:
+          s.append(2, ':');
+          break;
+        case required_argument:
+          s.append(1, ':');
+          break;
         }
+      }
+      ++i;
     }
-    return s;
+  }
+  return s;
 }

Modified: lldb/trunk/source/Host/common/PipeBase.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/PipeBase.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/PipeBase.cpp (original)
+++ lldb/trunk/source/Host/common/PipeBase.cpp Tue Sep  6 15:57:50 2016
@@ -11,17 +11,14 @@
 
 using namespace lldb_private;
 
-
 PipeBase::~PipeBase() = default;
 
-Error
-PipeBase::OpenAsWriter(llvm::StringRef name, bool child_process_inherit)
-{
-    return OpenAsWriterWithTimeout(name, child_process_inherit, std::chrono::microseconds::zero());
+Error PipeBase::OpenAsWriter(llvm::StringRef name, bool child_process_inherit) {
+  return OpenAsWriterWithTimeout(name, child_process_inherit,
+                                 std::chrono::microseconds::zero());
 }
 
-Error
-PipeBase::Read(void *buf, size_t size, size_t &bytes_read)
-{
-    return ReadWithTimeout(buf, size, std::chrono::microseconds::zero(), bytes_read);
+Error PipeBase::Read(void *buf, size_t size, size_t &bytes_read) {
+  return ReadWithTimeout(buf, size, std::chrono::microseconds::zero(),
+                         bytes_read);
 }

Modified: lldb/trunk/source/Host/common/ProcessRunLock.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/ProcessRunLock.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/ProcessRunLock.cpp (original)
+++ lldb/trunk/source/Host/common/ProcessRunLock.cpp Tue Sep  6 15:57:50 2016
@@ -4,68 +4,60 @@
 
 namespace lldb_private {
 
-    ProcessRunLock::ProcessRunLock()
-        : m_running(false)
-    {
-        int err = ::pthread_rwlock_init(&m_rwlock, NULL); (void) err;
-        //#if LLDB_CONFIGURATION_DEBUG
-        //        assert(err == 0);
-        //#endif
-    }
-
-    ProcessRunLock::~ProcessRunLock()
-    {
-        int err = ::pthread_rwlock_destroy(&m_rwlock); (void) err;
-        //#if LLDB_CONFIGURATION_DEBUG
-        //        assert(err == 0);
-        //#endif
-    }
-
-    bool ProcessRunLock::ReadTryLock()
-    {
-        ::pthread_rwlock_rdlock(&m_rwlock);
-        if (m_running == false)
-        {
-            return true;
-        }
-        ::pthread_rwlock_unlock(&m_rwlock);
-        return false;
-    }
-
-    bool ProcessRunLock::ReadUnlock()
-    {
-        return ::pthread_rwlock_unlock(&m_rwlock) == 0;
-    }
-
-    bool ProcessRunLock::SetRunning()
-    {
-        ::pthread_rwlock_wrlock(&m_rwlock);
-        m_running = true;
-        ::pthread_rwlock_unlock(&m_rwlock);
-        return true;
-    }
-
-    bool ProcessRunLock::TrySetRunning()
-    {
-        bool r;
-
-        if (::pthread_rwlock_trywrlock(&m_rwlock) == 0)
-        {
-            r = !m_running;
-            m_running = true;
-            ::pthread_rwlock_unlock(&m_rwlock);
-            return r;
-        }
-        return false;
-    }
-
-    bool ProcessRunLock::SetStopped()
-    {
-        ::pthread_rwlock_wrlock(&m_rwlock);
-        m_running = false;
-        ::pthread_rwlock_unlock(&m_rwlock);
-        return true;
-    }
+ProcessRunLock::ProcessRunLock() : m_running(false) {
+  int err = ::pthread_rwlock_init(&m_rwlock, NULL);
+  (void)err;
+  //#if LLDB_CONFIGURATION_DEBUG
+  //        assert(err == 0);
+  //#endif
+}
+
+ProcessRunLock::~ProcessRunLock() {
+  int err = ::pthread_rwlock_destroy(&m_rwlock);
+  (void)err;
+  //#if LLDB_CONFIGURATION_DEBUG
+  //        assert(err == 0);
+  //#endif
+}
+
+bool ProcessRunLock::ReadTryLock() {
+  ::pthread_rwlock_rdlock(&m_rwlock);
+  if (m_running == false) {
+    return true;
+  }
+  ::pthread_rwlock_unlock(&m_rwlock);
+  return false;
+}
+
+bool ProcessRunLock::ReadUnlock() {
+  return ::pthread_rwlock_unlock(&m_rwlock) == 0;
+}
+
+bool ProcessRunLock::SetRunning() {
+  ::pthread_rwlock_wrlock(&m_rwlock);
+  m_running = true;
+  ::pthread_rwlock_unlock(&m_rwlock);
+  return true;
+}
+
+bool ProcessRunLock::TrySetRunning() {
+  bool r;
+
+  if (::pthread_rwlock_trywrlock(&m_rwlock) == 0) {
+    r = !m_running;
+    m_running = true;
+    ::pthread_rwlock_unlock(&m_rwlock);
+    return r;
+  }
+  return false;
+}
+
+bool ProcessRunLock::SetStopped() {
+  ::pthread_rwlock_wrlock(&m_rwlock);
+  m_running = false;
+  ::pthread_rwlock_unlock(&m_rwlock);
+  return true;
+}
 }
 
 #endif

Modified: lldb/trunk/source/Host/common/Socket.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Socket.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/Socket.cpp (original)
+++ lldb/trunk/source/Host/common/Socket.cpp Tue Sep  6 15:57:50 2016
@@ -35,15 +35,15 @@
 #endif
 
 #ifdef __ANDROID_NDK__
-#include <linux/tcp.h>
-#include <bits/error_constants.h>
+#include <arpa/inet.h>
 #include <asm-generic/errno-base.h>
+#include <bits/error_constants.h>
 #include <errno.h>
-#include <arpa/inet.h>
+#include <linux/tcp.h>
 #if defined(ANDROID_ARM_BUILD_STATIC) || defined(ANDROID_MIPS_BUILD_STATIC)
-#include <unistd.h>
-#include <sys/syscall.h>
 #include <fcntl.h>
+#include <sys/syscall.h>
+#include <unistd.h>
 #endif // ANDROID_ARM_BUILD_STATIC || ANDROID_MIPS_BUILD_STATIC
 #endif // __ANDROID_NDK__
 
@@ -51,439 +51,407 @@ using namespace lldb;
 using namespace lldb_private;
 
 #if defined(_WIN32)
-typedef const char * set_socket_option_arg_type;
-typedef char * get_socket_option_arg_type;
+typedef const char *set_socket_option_arg_type;
+typedef char *get_socket_option_arg_type;
 const NativeSocket Socket::kInvalidSocketValue = INVALID_SOCKET;
-#else // #if defined(_WIN32)
-typedef const void * set_socket_option_arg_type;
-typedef void * get_socket_option_arg_type;
+#else  // #if defined(_WIN32)
+typedef const void *set_socket_option_arg_type;
+typedef void *get_socket_option_arg_type;
 const NativeSocket Socket::kInvalidSocketValue = -1;
 #endif // #if defined(_WIN32)
 
 namespace {
 
-bool IsInterrupted()
-{
+bool IsInterrupted() {
 #if defined(_WIN32)
-    return ::WSAGetLastError() == WSAEINTR;
+  return ::WSAGetLastError() == WSAEINTR;
 #else
-    return errno == EINTR;
+  return errno == EINTR;
 #endif
 }
-
 }
 
 Socket::Socket(NativeSocket socket, SocketProtocol protocol, bool should_close)
-    : IOObject(eFDTypeSocket, should_close)
-    , m_protocol(protocol)
-    , m_socket(socket)
-{
+    : IOObject(eFDTypeSocket, should_close), m_protocol(protocol),
+      m_socket(socket) {}
 
-}
+Socket::~Socket() { Close(); }
 
-Socket::~Socket()
-{
-    Close();
-}
-
-std::unique_ptr<Socket> Socket::Create(const SocketProtocol protocol, bool child_processes_inherit, Error &error)
-{
-    error.Clear();
-
-    std::unique_ptr<Socket> socket_up;
-    switch (protocol)
-    {
-    case ProtocolTcp:
-        socket_up.reset(new TCPSocket(child_processes_inherit, error));
-        break;
-    case ProtocolUdp:
-        socket_up.reset(new UDPSocket(child_processes_inherit, error));
-        break;
-    case ProtocolUnixDomain:
+std::unique_ptr<Socket> Socket::Create(const SocketProtocol protocol,
+                                       bool child_processes_inherit,
+                                       Error &error) {
+  error.Clear();
+
+  std::unique_ptr<Socket> socket_up;
+  switch (protocol) {
+  case ProtocolTcp:
+    socket_up.reset(new TCPSocket(child_processes_inherit, error));
+    break;
+  case ProtocolUdp:
+    socket_up.reset(new UDPSocket(child_processes_inherit, error));
+    break;
+  case ProtocolUnixDomain:
 #ifndef LLDB_DISABLE_POSIX
-        socket_up.reset(new DomainSocket(child_processes_inherit, error));
+    socket_up.reset(new DomainSocket(child_processes_inherit, error));
 #else
-        error.SetErrorString("Unix domain sockets are not supported on this platform.");
+    error.SetErrorString(
+        "Unix domain sockets are not supported on this platform.");
 #endif
-        break;
-    case ProtocolUnixAbstract:
+    break;
+  case ProtocolUnixAbstract:
 #ifdef __linux__
-        socket_up.reset(new AbstractSocket(child_processes_inherit, error));
+    socket_up.reset(new AbstractSocket(child_processes_inherit, error));
 #else
-        error.SetErrorString("Abstract domain sockets are not supported on this platform.");
+    error.SetErrorString(
+        "Abstract domain sockets are not supported on this platform.");
 #endif
-        break;
-    }
+    break;
+  }
 
-    if (error.Fail())
-        socket_up.reset();
+  if (error.Fail())
+    socket_up.reset();
 
-    return socket_up;
+  return socket_up;
 }
 
-Error Socket::TcpConnect(llvm::StringRef host_and_port, bool child_processes_inherit, Socket *&socket)
-{
-    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION));
-    if (log)
-        log->Printf ("Socket::%s (host/port = %s)", __FUNCTION__, host_and_port.data());
-
-    Error error;
-    std::unique_ptr<Socket> connect_socket(Create(ProtocolTcp, child_processes_inherit, error));
-    if (error.Fail())
-        return error;
-
-    error = connect_socket->Connect(host_and_port);
-    if (error.Success())
-      socket = connect_socket.release();
-
+Error Socket::TcpConnect(llvm::StringRef host_and_port,
+                         bool child_processes_inherit, Socket *&socket) {
+  Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_COMMUNICATION));
+  if (log)
+    log->Printf("Socket::%s (host/port = %s)", __FUNCTION__,
+                host_and_port.data());
+
+  Error error;
+  std::unique_ptr<Socket> connect_socket(
+      Create(ProtocolTcp, child_processes_inherit, error));
+  if (error.Fail())
     return error;
-}
-
-Error
-Socket::TcpListen (llvm::StringRef host_and_port,
-                   bool child_processes_inherit,
-                   Socket *&socket,
-                   Predicate<uint16_t>* predicate,
-                   int backlog)
-{
-    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
-    if (log)
-        log->Printf ("Socket::%s (%s)", __FUNCTION__, host_and_port.data());
-
-    Error error;
-    std::string host_str;
-    std::string port_str;
-    int32_t port = INT32_MIN;
-    if (!DecodeHostAndPort (host_and_port, host_str, port_str, port, &error))
-        return error;
-
-    std::unique_ptr<TCPSocket> listen_socket(new TCPSocket(child_processes_inherit, error));
-    if (error.Fail())
-        return error;
-
-    error = listen_socket->Listen(host_and_port, backlog);
-    if (error.Success())
-    {
-        // We were asked to listen on port zero which means we
-        // must now read the actual port that was given to us
-        // as port zero is a special code for "find an open port
-        // for me".
-        if (port == 0)
-            port = listen_socket->GetLocalPortNumber();
-
-        // Set the port predicate since when doing a listen://<host>:<port>
-        // it often needs to accept the incoming connection which is a blocking
-        // system call. Allowing access to the bound port using a predicate allows
-        // us to wait for the port predicate to be set to a non-zero value from
-        // another thread in an efficient manor.
-        if (predicate)
-            predicate->SetValue (port, eBroadcastAlways);
-        socket = listen_socket.release();
-    }
 
+  error = connect_socket->Connect(host_and_port);
+  if (error.Success())
+    socket = connect_socket.release();
+
+  return error;
+}
+
+Error Socket::TcpListen(llvm::StringRef host_and_port,
+                        bool child_processes_inherit, Socket *&socket,
+                        Predicate<uint16_t> *predicate, int backlog) {
+  Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION));
+  if (log)
+    log->Printf("Socket::%s (%s)", __FUNCTION__, host_and_port.data());
+
+  Error error;
+  std::string host_str;
+  std::string port_str;
+  int32_t port = INT32_MIN;
+  if (!DecodeHostAndPort(host_and_port, host_str, port_str, port, &error))
     return error;
-}
-
-Error Socket::UdpConnect(llvm::StringRef host_and_port, bool child_processes_inherit, Socket *&send_socket, Socket *&recv_socket)
-{
-    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
-    if (log)
-        log->Printf ("Socket::%s (host/port = %s)", __FUNCTION__, host_and_port.data());
-
-    return UDPSocket::Connect(host_and_port, child_processes_inherit, send_socket, recv_socket);
-}
-
-Error Socket::UnixDomainConnect(llvm::StringRef name, bool child_processes_inherit, Socket *&socket)
-{
-    Error error;
-    std::unique_ptr<Socket> connect_socket(Create(ProtocolUnixDomain, child_processes_inherit, error));
-    if (error.Fail())
-        return error;
-
-    error = connect_socket->Connect(name);
-    if (error.Success())
-      socket = connect_socket.release();
 
+  std::unique_ptr<TCPSocket> listen_socket(
+      new TCPSocket(child_processes_inherit, error));
+  if (error.Fail())
     return error;
-}
 
-Error Socket::UnixDomainAccept(llvm::StringRef name, bool child_processes_inherit, Socket *&socket)
-{
-    Error error;
-    std::unique_ptr<Socket> listen_socket(Create(ProtocolUnixDomain, child_processes_inherit, error));
-    if (error.Fail())
-        return error;
-
-    error = listen_socket->Listen(name, 5);
-    if (error.Fail())
-        return error;
-
-    error = listen_socket->Accept(name, child_processes_inherit, socket);
+  error = listen_socket->Listen(host_and_port, backlog);
+  if (error.Success()) {
+    // We were asked to listen on port zero which means we
+    // must now read the actual port that was given to us
+    // as port zero is a special code for "find an open port
+    // for me".
+    if (port == 0)
+      port = listen_socket->GetLocalPortNumber();
+
+    // Set the port predicate since when doing a listen://<host>:<port>
+    // it often needs to accept the incoming connection which is a blocking
+    // system call. Allowing access to the bound port using a predicate allows
+    // us to wait for the port predicate to be set to a non-zero value from
+    // another thread in an efficient manor.
+    if (predicate)
+      predicate->SetValue(port, eBroadcastAlways);
+    socket = listen_socket.release();
+  }
+
+  return error;
+}
+
+Error Socket::UdpConnect(llvm::StringRef host_and_port,
+                         bool child_processes_inherit, Socket *&send_socket,
+                         Socket *&recv_socket) {
+  Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION));
+  if (log)
+    log->Printf("Socket::%s (host/port = %s)", __FUNCTION__,
+                host_and_port.data());
+
+  return UDPSocket::Connect(host_and_port, child_processes_inherit, send_socket,
+                            recv_socket);
+}
+
+Error Socket::UnixDomainConnect(llvm::StringRef name,
+                                bool child_processes_inherit, Socket *&socket) {
+  Error error;
+  std::unique_ptr<Socket> connect_socket(
+      Create(ProtocolUnixDomain, child_processes_inherit, error));
+  if (error.Fail())
     return error;
-}
 
-Error
-Socket::UnixAbstractConnect(llvm::StringRef name, bool child_processes_inherit, Socket *&socket)
-{
-    Error error;
-    std::unique_ptr<Socket> connect_socket(Create(ProtocolUnixAbstract, child_processes_inherit, error));
-    if (error.Fail())
-        return error;
-
-    error = connect_socket->Connect(name);
-    if (error.Success())
-      socket = connect_socket.release();
-    return error;
+  error = connect_socket->Connect(name);
+  if (error.Success())
+    socket = connect_socket.release();
+
+  return error;
 }
 
-Error
-Socket::UnixAbstractAccept(llvm::StringRef name, bool child_processes_inherit, Socket *&socket)
-{
-    Error error;
-    std::unique_ptr<Socket> listen_socket(Create(ProtocolUnixAbstract,child_processes_inherit, error));
-    if (error.Fail())
-        return error;
-
-    error = listen_socket->Listen(name, 5);
-    if (error.Fail())
-        return error;
-
-    error = listen_socket->Accept(name, child_processes_inherit, socket);
+Error Socket::UnixDomainAccept(llvm::StringRef name,
+                               bool child_processes_inherit, Socket *&socket) {
+  Error error;
+  std::unique_ptr<Socket> listen_socket(
+      Create(ProtocolUnixDomain, child_processes_inherit, error));
+  if (error.Fail())
     return error;
-}
-
-bool
-Socket::DecodeHostAndPort(llvm::StringRef host_and_port,
-                          std::string &host_str,
-                          std::string &port_str,
-                          int32_t& port,
-                          Error *error_ptr)
-{
-    static RegularExpression g_regex ("([^:]+):([0-9]+)");
-    RegularExpression::Match regex_match(2);
-    if (g_regex.Execute (host_and_port.data(), &regex_match))
-    {
-        if (regex_match.GetMatchAtIndex (host_and_port.data(), 1, host_str) &&
-            regex_match.GetMatchAtIndex (host_and_port.data(), 2, port_str))
-        {
-            bool ok = false;
-            port = StringConvert::ToUInt32 (port_str.c_str(), UINT32_MAX, 10, &ok);
-            if (ok && port <= UINT16_MAX)
-            {
-                if (error_ptr)
-                    error_ptr->Clear();
-                return true;
-            }
-            // port is too large
-            if (error_ptr)
-                error_ptr->SetErrorStringWithFormat("invalid host:port specification: '%s'", host_and_port.data());
-            return false;
-        }
-    }
 
-    // If this was unsuccessful, then check if it's simply a signed 32-bit integer, representing
-    // a port with an empty host.
-    host_str.clear();
-    port_str.clear();
-    bool ok = false;
-    port = StringConvert::ToUInt32 (host_and_port.data(), UINT32_MAX, 10, &ok);
-    if (ok && port < UINT16_MAX)
-    {
-        port_str = host_and_port;
-        if (error_ptr)
-            error_ptr->Clear();
-        return true;
-    }
+  error = listen_socket->Listen(name, 5);
+  if (error.Fail())
+    return error;
 
-    if (error_ptr)
-        error_ptr->SetErrorStringWithFormat("invalid host:port specification: '%s'", host_and_port.data());
-    return false;
+  error = listen_socket->Accept(name, child_processes_inherit, socket);
+  return error;
 }
 
-IOObject::WaitableHandle Socket::GetWaitableHandle()
-{
-    // TODO: On Windows, use WSAEventSelect
-    return m_socket;
-}
-
-Error Socket::Read (void *buf, size_t &num_bytes)
-{
-    Error error;
-    int bytes_received = 0;
-    do
-    {
-        bytes_received = ::recv (m_socket, static_cast<char *>(buf), num_bytes, 0);
-    } while (bytes_received < 0 && IsInterrupted ());
-
-    if (bytes_received < 0)
-    {
-        SetLastError (error);
-        num_bytes = 0;
-    }
-    else
-        num_bytes = bytes_received;
-
-    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION)); 
-    if (log)
-    {
-        log->Printf ("%p Socket::Read() (socket = %" PRIu64 ", src = %p, src_len = %" PRIu64 ", flags = 0) => %" PRIi64 " (error = %s)",
-                     static_cast<void*>(this), 
-                     static_cast<uint64_t>(m_socket),
-                     buf,
-                     static_cast<uint64_t>(num_bytes),
-                     static_cast<int64_t>(bytes_received),
-                     error.AsCString());
-    }
-
+Error Socket::UnixAbstractConnect(llvm::StringRef name,
+                                  bool child_processes_inherit,
+                                  Socket *&socket) {
+  Error error;
+  std::unique_ptr<Socket> connect_socket(
+      Create(ProtocolUnixAbstract, child_processes_inherit, error));
+  if (error.Fail())
     return error;
-}
 
-Error Socket::Write (const void *buf, size_t &num_bytes)
-{
-    Error error;
-    int bytes_sent = 0;
-    do
-    {
-        bytes_sent = Send(buf, num_bytes);
-    } while (bytes_sent < 0 && IsInterrupted ());
-
-    if (bytes_sent < 0)
-    {
-        SetLastError (error);
-        num_bytes = 0;
-    }
-    else
-        num_bytes = bytes_sent;
+  error = connect_socket->Connect(name);
+  if (error.Success())
+    socket = connect_socket.release();
+  return error;
+}
 
-    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION));
-    if (log)
-    {
-        log->Printf ("%p Socket::Write() (socket = %" PRIu64 ", src = %p, src_len = %" PRIu64 ", flags = 0) => %" PRIi64 " (error = %s)",
-                        static_cast<void*>(this), 
-                        static_cast<uint64_t>(m_socket),
-                        buf,
-                        static_cast<uint64_t>(num_bytes),
-                        static_cast<int64_t>(bytes_sent),
-                        error.AsCString());
-    }
+Error Socket::UnixAbstractAccept(llvm::StringRef name,
+                                 bool child_processes_inherit,
+                                 Socket *&socket) {
+  Error error;
+  std::unique_ptr<Socket> listen_socket(
+      Create(ProtocolUnixAbstract, child_processes_inherit, error));
+  if (error.Fail())
+    return error;
 
+  error = listen_socket->Listen(name, 5);
+  if (error.Fail())
     return error;
+
+  error = listen_socket->Accept(name, child_processes_inherit, socket);
+  return error;
 }
 
-Error Socket::PreDisconnect()
-{
-    Error error;
+bool Socket::DecodeHostAndPort(llvm::StringRef host_and_port,
+                               std::string &host_str, std::string &port_str,
+                               int32_t &port, Error *error_ptr) {
+  static RegularExpression g_regex("([^:]+):([0-9]+)");
+  RegularExpression::Match regex_match(2);
+  if (g_regex.Execute(host_and_port.data(), &regex_match)) {
+    if (regex_match.GetMatchAtIndex(host_and_port.data(), 1, host_str) &&
+        regex_match.GetMatchAtIndex(host_and_port.data(), 2, port_str)) {
+      bool ok = false;
+      port = StringConvert::ToUInt32(port_str.c_str(), UINT32_MAX, 10, &ok);
+      if (ok && port <= UINT16_MAX) {
+        if (error_ptr)
+          error_ptr->Clear();
+        return true;
+      }
+      // port is too large
+      if (error_ptr)
+        error_ptr->SetErrorStringWithFormat(
+            "invalid host:port specification: '%s'", host_and_port.data());
+      return false;
+    }
+  }
+
+  // If this was unsuccessful, then check if it's simply a signed 32-bit
+  // integer, representing
+  // a port with an empty host.
+  host_str.clear();
+  port_str.clear();
+  bool ok = false;
+  port = StringConvert::ToUInt32(host_and_port.data(), UINT32_MAX, 10, &ok);
+  if (ok && port < UINT16_MAX) {
+    port_str = host_and_port;
+    if (error_ptr)
+      error_ptr->Clear();
+    return true;
+  }
+
+  if (error_ptr)
+    error_ptr->SetErrorStringWithFormat("invalid host:port specification: '%s'",
+                                        host_and_port.data());
+  return false;
+}
+
+IOObject::WaitableHandle Socket::GetWaitableHandle() {
+  // TODO: On Windows, use WSAEventSelect
+  return m_socket;
+}
+
+Error Socket::Read(void *buf, size_t &num_bytes) {
+  Error error;
+  int bytes_received = 0;
+  do {
+    bytes_received = ::recv(m_socket, static_cast<char *>(buf), num_bytes, 0);
+  } while (bytes_received < 0 && IsInterrupted());
+
+  if (bytes_received < 0) {
+    SetLastError(error);
+    num_bytes = 0;
+  } else
+    num_bytes = bytes_received;
+
+  Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_COMMUNICATION));
+  if (log) {
+    log->Printf("%p Socket::Read() (socket = %" PRIu64
+                ", src = %p, src_len = %" PRIu64 ", flags = 0) => %" PRIi64
+                " (error = %s)",
+                static_cast<void *>(this), static_cast<uint64_t>(m_socket), buf,
+                static_cast<uint64_t>(num_bytes),
+                static_cast<int64_t>(bytes_received), error.AsCString());
+  }
+
+  return error;
+}
+
+Error Socket::Write(const void *buf, size_t &num_bytes) {
+  Error error;
+  int bytes_sent = 0;
+  do {
+    bytes_sent = Send(buf, num_bytes);
+  } while (bytes_sent < 0 && IsInterrupted());
+
+  if (bytes_sent < 0) {
+    SetLastError(error);
+    num_bytes = 0;
+  } else
+    num_bytes = bytes_sent;
+
+  Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_COMMUNICATION));
+  if (log) {
+    log->Printf("%p Socket::Write() (socket = %" PRIu64
+                ", src = %p, src_len = %" PRIu64 ", flags = 0) => %" PRIi64
+                " (error = %s)",
+                static_cast<void *>(this), static_cast<uint64_t>(m_socket), buf,
+                static_cast<uint64_t>(num_bytes),
+                static_cast<int64_t>(bytes_sent), error.AsCString());
+  }
+
+  return error;
+}
+
+Error Socket::PreDisconnect() {
+  Error error;
+  return error;
+}
+
+Error Socket::Close() {
+  Error error;
+  if (!IsValid() || !m_should_close_fd)
     return error;
-}
 
-Error Socket::Close()
-{
-    Error error;
-    if (!IsValid() || !m_should_close_fd)
-        return error;
-
-    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
-    if (log)
-        log->Printf ("%p Socket::Close (fd = %i)", static_cast<void*>(this), m_socket);
+  Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION));
+  if (log)
+    log->Printf("%p Socket::Close (fd = %i)", static_cast<void *>(this),
+                m_socket);
 
 #if defined(_WIN32)
-    bool success = !!closesocket(m_socket);
+  bool success = !!closesocket(m_socket);
 #else
-    bool success = !!::close (m_socket);
+  bool success = !!::close(m_socket);
 #endif
-    // A reference to a FD was passed in, set it to an invalid value
-    m_socket = kInvalidSocketValue;
-    if (!success)
-    {
-        SetLastError (error);
-    }
+  // A reference to a FD was passed in, set it to an invalid value
+  m_socket = kInvalidSocketValue;
+  if (!success) {
+    SetLastError(error);
+  }
 
-    return error;
+  return error;
 }
 
-
-int Socket::GetOption(int level, int option_name, int &option_value)
-{
-    get_socket_option_arg_type option_value_p = reinterpret_cast<get_socket_option_arg_type>(&option_value);
-    socklen_t option_value_size = sizeof(int);
-    return ::getsockopt(m_socket, level, option_name, option_value_p, &option_value_size);
+int Socket::GetOption(int level, int option_name, int &option_value) {
+  get_socket_option_arg_type option_value_p =
+      reinterpret_cast<get_socket_option_arg_type>(&option_value);
+  socklen_t option_value_size = sizeof(int);
+  return ::getsockopt(m_socket, level, option_name, option_value_p,
+                      &option_value_size);
 }
 
-int Socket::SetOption(int level, int option_name, int option_value)
-{
-    set_socket_option_arg_type option_value_p = reinterpret_cast<get_socket_option_arg_type>(&option_value);
-    return ::setsockopt(m_socket, level, option_name, option_value_p, sizeof(option_value));
+int Socket::SetOption(int level, int option_name, int option_value) {
+  set_socket_option_arg_type option_value_p =
+      reinterpret_cast<get_socket_option_arg_type>(&option_value);
+  return ::setsockopt(m_socket, level, option_name, option_value_p,
+                      sizeof(option_value));
 }
 
-size_t Socket::Send(const void *buf, const size_t num_bytes)
-{
-    return ::send (m_socket, static_cast<const char *>(buf), num_bytes, 0);
+size_t Socket::Send(const void *buf, const size_t num_bytes) {
+  return ::send(m_socket, static_cast<const char *>(buf), num_bytes, 0);
 }
 
-void Socket::SetLastError(Error &error)
-{
+void Socket::SetLastError(Error &error) {
 #if defined(_WIN32)
-    error.SetError(::WSAGetLastError(), lldb::eErrorTypeWin32);
+  error.SetError(::WSAGetLastError(), lldb::eErrorTypeWin32);
 #else
-    error.SetErrorToErrno();
+  error.SetErrorToErrno();
 #endif
 }
 
-NativeSocket
-Socket::CreateSocket(const int domain,
-                     const int type,
-                     const int protocol,
-                     bool child_processes_inherit,
-                     Error& error)
-{
-    error.Clear();
-    auto socketType = type;
+NativeSocket Socket::CreateSocket(const int domain, const int type,
+                                  const int protocol,
+                                  bool child_processes_inherit, Error &error) {
+  error.Clear();
+  auto socketType = type;
 #ifdef SOCK_CLOEXEC
-    if (!child_processes_inherit)
-        socketType |= SOCK_CLOEXEC;
+  if (!child_processes_inherit)
+    socketType |= SOCK_CLOEXEC;
 #endif
-    auto sock = ::socket (domain, socketType, protocol);
-    if (sock == kInvalidSocketValue)
-        SetLastError(error);
-
-    return sock;
+  auto sock = ::socket(domain, socketType, protocol);
+  if (sock == kInvalidSocketValue)
+    SetLastError(error);
+
+  return sock;
 }
 
-NativeSocket
-Socket::AcceptSocket(NativeSocket sockfd,
-                     struct sockaddr *addr,
-                     socklen_t *addrlen,
-                     bool child_processes_inherit,
-                     Error& error)
-{
-    error.Clear();
+NativeSocket Socket::AcceptSocket(NativeSocket sockfd, struct sockaddr *addr,
+                                  socklen_t *addrlen,
+                                  bool child_processes_inherit, Error &error) {
+  error.Clear();
 #if defined(ANDROID_ARM_BUILD_STATIC) || defined(ANDROID_MIPS_BUILD_STATIC)
-    // Temporary workaround for statically linking Android lldb-server with the
-    // latest API.
-    int fd = syscall(__NR_accept, sockfd, addr, addrlen);
-    if (fd >= 0 && !child_processes_inherit)
-    {
-        int flags = ::fcntl(fd, F_GETFD);
-        if (flags != -1 && ::fcntl(fd, F_SETFD, flags | FD_CLOEXEC) != -1)
-            return fd;
-        SetLastError(error);
-        close(fd);
-    }
-    return fd;
+  // Temporary workaround for statically linking Android lldb-server with the
+  // latest API.
+  int fd = syscall(__NR_accept, sockfd, addr, addrlen);
+  if (fd >= 0 && !child_processes_inherit) {
+    int flags = ::fcntl(fd, F_GETFD);
+    if (flags != -1 && ::fcntl(fd, F_SETFD, flags | FD_CLOEXEC) != -1)
+      return fd;
+    SetLastError(error);
+    close(fd);
+  }
+  return fd;
 #elif defined(SOCK_CLOEXEC)
-    int flags = 0;
-    if (!child_processes_inherit) {
-        flags |= SOCK_CLOEXEC;
-    }
+  int flags = 0;
+  if (!child_processes_inherit) {
+    flags |= SOCK_CLOEXEC;
+  }
 #if defined(__NetBSD__)
-    NativeSocket fd = ::paccept (sockfd, addr, addrlen, nullptr, flags);
+  NativeSocket fd = ::paccept(sockfd, addr, addrlen, nullptr, flags);
 #else
-    NativeSocket fd = ::accept4 (sockfd, addr, addrlen, flags);
+  NativeSocket fd = ::accept4(sockfd, addr, addrlen, flags);
 #endif
 #else
-    NativeSocket fd = ::accept (sockfd, addr, addrlen);
+  NativeSocket fd = ::accept(sockfd, addr, addrlen);
 #endif
-    if (fd == kInvalidSocketValue)
-        SetLastError(error);
-    return fd;
+  if (fd == kInvalidSocketValue)
+    SetLastError(error);
+  return fd;
 }

Modified: lldb/trunk/source/Host/common/SocketAddress.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/SocketAddress.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/SocketAddress.cpp (original)
+++ lldb/trunk/source/Host/common/SocketAddress.cpp Tue Sep  6 15:57:50 2016
@@ -32,336 +32,254 @@
 #endif
 
 // TODO: implement shortened form "::" for runs of zeros
-const char* inet_ntop(int af, const void * src,
-                      char * dst, socklen_t size)
-{
-    if (size==0)
+const char *inet_ntop(int af, const void *src, char *dst, socklen_t size) {
+  if (size == 0) {
+    return nullptr;
+  }
+
+  switch (af) {
+  case AF_INET: {
     {
-        return nullptr;
+      const char *formatted = inet_ntoa(*static_cast<const in_addr *>(src));
+      if (formatted && strlen(formatted) < size) {
+        return ::strcpy(dst, formatted);
+      }
     }
-    
-    switch (af)
-    {
-        case AF_INET:
-        {
-            {
-                const char* formatted = inet_ntoa(*static_cast<const in_addr*>(src));
-                if (formatted && strlen(formatted) < size)
-                {
-                    return ::strcpy(dst, formatted);
-                }
-            }
-            return nullptr;
-        case AF_INET6:
-            {
-                char tmp[INET6_ADDRSTRLEN] = {0};
-                const uint16_t* src16 = static_cast<const uint16_t*>(src);
-                int full_size = ::snprintf(tmp, sizeof(tmp),
-                                          "%x:%x:%x:%x:%x:%x:%x:%x",
-                                          ntohs(src16[0]), ntohs(src16[1]), ntohs(src16[2]), ntohs(src16[3]),
-                                          ntohs(src16[4]), ntohs(src16[5]), ntohs(src16[6]), ntohs(src16[7])
-                                          );
-                if (full_size < static_cast<int>(size))
-                {
-                    return ::strcpy(dst, tmp);
-                }
-                return nullptr;
-            }
-        }
+    return nullptr;
+  case AF_INET6: {
+    char tmp[INET6_ADDRSTRLEN] = {0};
+    const uint16_t *src16 = static_cast<const uint16_t *>(src);
+    int full_size = ::snprintf(
+        tmp, sizeof(tmp), "%x:%x:%x:%x:%x:%x:%x:%x", ntohs(src16[0]),
+        ntohs(src16[1]), ntohs(src16[2]), ntohs(src16[3]), ntohs(src16[4]),
+        ntohs(src16[5]), ntohs(src16[6]), ntohs(src16[7]));
+    if (full_size < static_cast<int>(size)) {
+      return ::strcpy(dst, tmp);
     }
     return nullptr;
-} 
+  }
+  }
+  }
+  return nullptr;
+}
 #endif
-    
 
 using namespace lldb_private;
 
 //----------------------------------------------------------------------
 // SocketAddress constructor
 //----------------------------------------------------------------------
-SocketAddress::SocketAddress ()
-{
-    Clear ();
-}
-
-SocketAddress::SocketAddress (const struct sockaddr &s)
-{
-    m_socket_addr.sa = s;
-}
+SocketAddress::SocketAddress() { Clear(); }
 
+SocketAddress::SocketAddress(const struct sockaddr &s) { m_socket_addr.sa = s; }
 
-SocketAddress::SocketAddress (const struct sockaddr_in &s)
-{
-    m_socket_addr.sa_ipv4 = s;
+SocketAddress::SocketAddress(const struct sockaddr_in &s) {
+  m_socket_addr.sa_ipv4 = s;
 }
 
-
-SocketAddress::SocketAddress (const struct sockaddr_in6 &s)
-{
-    m_socket_addr.sa_ipv6 = s;
+SocketAddress::SocketAddress(const struct sockaddr_in6 &s) {
+  m_socket_addr.sa_ipv6 = s;
 }
 
-
-SocketAddress::SocketAddress (const struct sockaddr_storage &s)
-{
-    m_socket_addr.sa_storage = s;
+SocketAddress::SocketAddress(const struct sockaddr_storage &s) {
+  m_socket_addr.sa_storage = s;
 }
 
 //----------------------------------------------------------------------
 // SocketAddress copy constructor
 //----------------------------------------------------------------------
-SocketAddress::SocketAddress (const SocketAddress& rhs) :
-    m_socket_addr (rhs.m_socket_addr)
-{
-}
+SocketAddress::SocketAddress(const SocketAddress &rhs)
+    : m_socket_addr(rhs.m_socket_addr) {}
 
 //----------------------------------------------------------------------
 // Destructor
 //----------------------------------------------------------------------
-SocketAddress::~SocketAddress()
-{
-}
+SocketAddress::~SocketAddress() {}
 
-void
-SocketAddress::Clear ()
-{
-    memset (&m_socket_addr, 0, sizeof(m_socket_addr));
+void SocketAddress::Clear() {
+  memset(&m_socket_addr, 0, sizeof(m_socket_addr));
 }
 
-bool
-SocketAddress::IsValid () const
-{
-    return GetLength () != 0;
-}
+bool SocketAddress::IsValid() const { return GetLength() != 0; }
 
-static socklen_t 
-GetFamilyLength (sa_family_t family)
-{
-    switch (family)
-    {
-        case AF_INET:  return sizeof(struct sockaddr_in);
-        case AF_INET6: return sizeof(struct sockaddr_in6);
-    }
-    assert(0 && "Unsupported address family");
-    return 0;
+static socklen_t GetFamilyLength(sa_family_t family) {
+  switch (family) {
+  case AF_INET:
+    return sizeof(struct sockaddr_in);
+  case AF_INET6:
+    return sizeof(struct sockaddr_in6);
+  }
+  assert(0 && "Unsupported address family");
+  return 0;
 }
 
-socklen_t
-SocketAddress::GetLength () const
-{
+socklen_t SocketAddress::GetLength() const {
 #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
-    return m_socket_addr.sa.sa_len;
+  return m_socket_addr.sa.sa_len;
 #else
-    return GetFamilyLength (GetFamily());
+  return GetFamilyLength(GetFamily());
 #endif
 }
 
-socklen_t
-SocketAddress::GetMaxLength ()
-{
-    return sizeof (sockaddr_t);
-}
-
-sa_family_t
-SocketAddress::GetFamily () const
-{
-    return m_socket_addr.sa.sa_family;
-}
-
-void
-SocketAddress::SetFamily (sa_family_t family)
-{
-    m_socket_addr.sa.sa_family = family;
-#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
-    m_socket_addr.sa.sa_len = GetFamilyLength (family);
-#endif
-}
+socklen_t SocketAddress::GetMaxLength() { return sizeof(sockaddr_t); }
 
-std::string
-SocketAddress::GetIPAddress () const
-{
-    char str[INET6_ADDRSTRLEN] = {0};
-    switch (GetFamily())
-    {
-        case AF_INET:
-            if (inet_ntop(GetFamily(), &m_socket_addr.sa_ipv4.sin_addr, str, sizeof(str)))
-                return str;
-            break;
-        case AF_INET6:
-            if (inet_ntop(GetFamily(), &m_socket_addr.sa_ipv6.sin6_addr, str, sizeof(str)))
-                return str;
-            break;
-    }
-    return "";
+sa_family_t SocketAddress::GetFamily() const {
+  return m_socket_addr.sa.sa_family;
 }
 
-uint16_t
-SocketAddress::GetPort () const
-{
-    switch (GetFamily())
-    {
-        case AF_INET:   return ntohs(m_socket_addr.sa_ipv4.sin_port);
-        case AF_INET6:  return ntohs(m_socket_addr.sa_ipv6.sin6_port);
-    }
-    return 0;
+void SocketAddress::SetFamily(sa_family_t family) {
+  m_socket_addr.sa.sa_family = family;
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
+  m_socket_addr.sa.sa_len = GetFamilyLength(family);
+#endif
 }
 
-bool
-SocketAddress::SetPort (uint16_t port)
-{
-    switch (GetFamily())
-    {
-        case AF_INET:   
-            m_socket_addr.sa_ipv4.sin_port = htons(port);
-            return true;
-
-        case AF_INET6:  
-            m_socket_addr.sa_ipv6.sin6_port = htons(port);
-            return true;
-    }
-    return false;
+std::string SocketAddress::GetIPAddress() const {
+  char str[INET6_ADDRSTRLEN] = {0};
+  switch (GetFamily()) {
+  case AF_INET:
+    if (inet_ntop(GetFamily(), &m_socket_addr.sa_ipv4.sin_addr, str,
+                  sizeof(str)))
+      return str;
+    break;
+  case AF_INET6:
+    if (inet_ntop(GetFamily(), &m_socket_addr.sa_ipv6.sin6_addr, str,
+                  sizeof(str)))
+      return str;
+    break;
+  }
+  return "";
+}
+
+uint16_t SocketAddress::GetPort() const {
+  switch (GetFamily()) {
+  case AF_INET:
+    return ntohs(m_socket_addr.sa_ipv4.sin_port);
+  case AF_INET6:
+    return ntohs(m_socket_addr.sa_ipv6.sin6_port);
+  }
+  return 0;
+}
+
+bool SocketAddress::SetPort(uint16_t port) {
+  switch (GetFamily()) {
+  case AF_INET:
+    m_socket_addr.sa_ipv4.sin_port = htons(port);
+    return true;
+
+  case AF_INET6:
+    m_socket_addr.sa_ipv6.sin6_port = htons(port);
+    return true;
+  }
+  return false;
 }
 
 //----------------------------------------------------------------------
 // SocketAddress assignment operator
 //----------------------------------------------------------------------
-const SocketAddress&
-SocketAddress::operator=(const SocketAddress& rhs)
-{
-    if (this != &rhs)
-        m_socket_addr = rhs.m_socket_addr;
-    return *this;
-}
-
-const SocketAddress&
-SocketAddress::operator=(const struct addrinfo *addr_info)
-{
-    Clear();
-    if (addr_info && 
-        addr_info->ai_addr &&
-        addr_info->ai_addrlen > 0&& 
-        addr_info->ai_addrlen <= sizeof m_socket_addr)
-    {
-        ::memcpy (&m_socket_addr, 
-                  addr_info->ai_addr, 
-                  addr_info->ai_addrlen);
-    }
-    return *this;
-}
-
-const SocketAddress&
-SocketAddress::operator=(const struct sockaddr &s)
-{
-    m_socket_addr.sa = s;
-    return *this;
-}
-
-const SocketAddress&
-SocketAddress::operator=(const struct sockaddr_in &s)
-{
-    m_socket_addr.sa_ipv4 = s;
-    return *this;
-}
-
-const SocketAddress&
-SocketAddress::operator=(const struct sockaddr_in6 &s)
-{
-    m_socket_addr.sa_ipv6 = s;
-    return *this;
-}
-
-const SocketAddress&
-SocketAddress::operator=(const struct sockaddr_storage &s)
-{
-    m_socket_addr.sa_storage = s;
-    return *this;
-}
-
-bool
-SocketAddress::getaddrinfo (const char *host,
-                            const char *service,
-                            int ai_family,
-                            int ai_socktype,
-                            int ai_protocol,
-                            int ai_flags)
-{
-    Clear ();
-
-    struct addrinfo hints;
-    memset(&hints, 0, sizeof(hints));
-    hints.ai_family = ai_family;
-    hints.ai_socktype = ai_socktype;
-    hints.ai_protocol = ai_protocol;
-    hints.ai_flags = ai_flags;
-
-    bool result = false;
-    struct addrinfo *service_info_list = NULL;
-    int err = ::getaddrinfo (host, service, &hints, &service_info_list);
-    if (err == 0 && service_info_list)
-    {
-        *this = service_info_list;
-        result = IsValid ();
-    }
-
-    if (service_info_list)
-        ::freeaddrinfo(service_info_list);
-
-    return result;
-}
-
-
-bool
-SocketAddress::SetToLocalhost (sa_family_t family, uint16_t port)
-{
-    switch (family)
-    {
-        case AF_INET:   
-            SetFamily (AF_INET);
-            if (SetPort (port))
-            {
-                m_socket_addr.sa_ipv4.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
-                return true;
-            }
-            break;
-
-        case AF_INET6:  
-            SetFamily (AF_INET6);
-            if (SetPort (port))
-            {
-                m_socket_addr.sa_ipv6.sin6_addr = in6addr_loopback;
-                return true;
-            }            
-            break;
-
-    }
-    Clear();
-    return false;
-}
-
-bool
-SocketAddress::SetToAnyAddress (sa_family_t family, uint16_t port)
-{
-    switch (family)
-    {
-        case AF_INET:
-            SetFamily (AF_INET);
-            if (SetPort (port))
-            {
-                m_socket_addr.sa_ipv4.sin_addr.s_addr = htonl (INADDR_ANY);
-                return true;
-            }
-            break;
-            
-        case AF_INET6:
-            SetFamily (AF_INET6);
-            if (SetPort (port))
-            {
-                m_socket_addr.sa_ipv6.sin6_addr = in6addr_any;
-                return true;
-            }
-            break;
-            
-    }
-    Clear();
-    return false;
+const SocketAddress &SocketAddress::operator=(const SocketAddress &rhs) {
+  if (this != &rhs)
+    m_socket_addr = rhs.m_socket_addr;
+  return *this;
+}
+
+const SocketAddress &SocketAddress::
+operator=(const struct addrinfo *addr_info) {
+  Clear();
+  if (addr_info && addr_info->ai_addr && addr_info->ai_addrlen > 0 &&
+      addr_info->ai_addrlen <= sizeof m_socket_addr) {
+    ::memcpy(&m_socket_addr, addr_info->ai_addr, addr_info->ai_addrlen);
+  }
+  return *this;
+}
+
+const SocketAddress &SocketAddress::operator=(const struct sockaddr &s) {
+  m_socket_addr.sa = s;
+  return *this;
+}
+
+const SocketAddress &SocketAddress::operator=(const struct sockaddr_in &s) {
+  m_socket_addr.sa_ipv4 = s;
+  return *this;
+}
+
+const SocketAddress &SocketAddress::operator=(const struct sockaddr_in6 &s) {
+  m_socket_addr.sa_ipv6 = s;
+  return *this;
+}
+
+const SocketAddress &SocketAddress::
+operator=(const struct sockaddr_storage &s) {
+  m_socket_addr.sa_storage = s;
+  return *this;
+}
+
+bool SocketAddress::getaddrinfo(const char *host, const char *service,
+                                int ai_family, int ai_socktype, int ai_protocol,
+                                int ai_flags) {
+  Clear();
+
+  struct addrinfo hints;
+  memset(&hints, 0, sizeof(hints));
+  hints.ai_family = ai_family;
+  hints.ai_socktype = ai_socktype;
+  hints.ai_protocol = ai_protocol;
+  hints.ai_flags = ai_flags;
+
+  bool result = false;
+  struct addrinfo *service_info_list = NULL;
+  int err = ::getaddrinfo(host, service, &hints, &service_info_list);
+  if (err == 0 && service_info_list) {
+    *this = service_info_list;
+    result = IsValid();
+  }
+
+  if (service_info_list)
+    ::freeaddrinfo(service_info_list);
+
+  return result;
+}
+
+bool SocketAddress::SetToLocalhost(sa_family_t family, uint16_t port) {
+  switch (family) {
+  case AF_INET:
+    SetFamily(AF_INET);
+    if (SetPort(port)) {
+      m_socket_addr.sa_ipv4.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+      return true;
+    }
+    break;
+
+  case AF_INET6:
+    SetFamily(AF_INET6);
+    if (SetPort(port)) {
+      m_socket_addr.sa_ipv6.sin6_addr = in6addr_loopback;
+      return true;
+    }
+    break;
+  }
+  Clear();
+  return false;
+}
+
+bool SocketAddress::SetToAnyAddress(sa_family_t family, uint16_t port) {
+  switch (family) {
+  case AF_INET:
+    SetFamily(AF_INET);
+    if (SetPort(port)) {
+      m_socket_addr.sa_ipv4.sin_addr.s_addr = htonl(INADDR_ANY);
+      return true;
+    }
+    break;
+
+  case AF_INET6:
+    SetFamily(AF_INET6);
+    if (SetPort(port)) {
+      m_socket_addr.sa_ipv6.sin6_addr = in6addr_any;
+      return true;
+    }
+    break;
+  }
+  Clear();
+  return false;
 }

Modified: lldb/trunk/source/Host/common/SoftwareBreakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/SoftwareBreakpoint.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/SoftwareBreakpoint.cpp (original)
+++ lldb/trunk/source/Host/common/SoftwareBreakpoint.cpp Tue Sep  6 15:57:50 2016
@@ -21,296 +21,332 @@ using namespace lldb_private;
 // static members
 // -------------------------------------------------------------------
 
-Error
-SoftwareBreakpoint::CreateSoftwareBreakpoint (NativeProcessProtocol &process, lldb::addr_t addr, size_t size_hint, NativeBreakpointSP &breakpoint_sp)
-{
-    Log *log (GetLogIfAnyCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
-    if (log)
-        log->Printf ("SoftwareBreakpoint::%s addr = 0x%" PRIx64, __FUNCTION__, addr);
-
-    // Validate the address.
-    if (addr == LLDB_INVALID_ADDRESS)
-        return Error ("SoftwareBreakpoint::%s invalid load address specified.", __FUNCTION__);
-
-    // Ask the NativeProcessProtocol subclass to fill in the correct software breakpoint
-    // trap for the breakpoint site.
-    size_t bp_opcode_size = 0;
-    const uint8_t *bp_opcode_bytes = NULL;
-    Error error = process.GetSoftwareBreakpointTrapOpcode (size_hint, bp_opcode_size, bp_opcode_bytes);
-
-    if (error.Fail ())
-    {
-        if (log)
-            log->Printf ("SoftwareBreakpoint::%s failed to retrieve software breakpoint trap opcode: %s", __FUNCTION__, error.AsCString ());
-        return error;
-    }
-
-    // Validate size of trap opcode.
-    if (bp_opcode_size == 0)
-    {
-        if (log)
-            log->Printf ("SoftwareBreakpoint::%s failed to retrieve any trap opcodes", __FUNCTION__);
-        return Error ("SoftwareBreakpoint::GetSoftwareBreakpointTrapOpcode() returned zero, unable to get breakpoint trap for address 0x%" PRIx64, addr);
-    }
+Error SoftwareBreakpoint::CreateSoftwareBreakpoint(
+    NativeProcessProtocol &process, lldb::addr_t addr, size_t size_hint,
+    NativeBreakpointSP &breakpoint_sp) {
+  Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
+  if (log)
+    log->Printf("SoftwareBreakpoint::%s addr = 0x%" PRIx64, __FUNCTION__, addr);
+
+  // Validate the address.
+  if (addr == LLDB_INVALID_ADDRESS)
+    return Error("SoftwareBreakpoint::%s invalid load address specified.",
+                 __FUNCTION__);
+
+  // Ask the NativeProcessProtocol subclass to fill in the correct software
+  // breakpoint
+  // trap for the breakpoint site.
+  size_t bp_opcode_size = 0;
+  const uint8_t *bp_opcode_bytes = NULL;
+  Error error = process.GetSoftwareBreakpointTrapOpcode(
+      size_hint, bp_opcode_size, bp_opcode_bytes);
 
-    if (bp_opcode_size > MAX_TRAP_OPCODE_SIZE)
-    {
-        if (log)
-            log->Printf ("SoftwareBreakpoint::%s cannot support %lu trapcode bytes, max size is %lu", __FUNCTION__, bp_opcode_size, MAX_TRAP_OPCODE_SIZE);
-        return Error ("SoftwareBreakpoint::GetSoftwareBreakpointTrapOpcode() returned too many trap opcode bytes: requires %lu but we only support a max of %lu", bp_opcode_size, MAX_TRAP_OPCODE_SIZE);
-    }
+  if (error.Fail()) {
+    if (log)
+      log->Printf("SoftwareBreakpoint::%s failed to retrieve software "
+                  "breakpoint trap opcode: %s",
+                  __FUNCTION__, error.AsCString());
+    return error;
+  }
 
-    // Validate that we received opcodes.
-    if (!bp_opcode_bytes)
-    {
-        if (log)
-            log->Printf ("SoftwareBreakpoint::%s failed to retrieve trap opcode bytes", __FUNCTION__);
-        return Error ("SoftwareBreakpoint::GetSoftwareBreakpointTrapOpcode() returned NULL trap opcode bytes, unable to get breakpoint trap for address 0x%" PRIx64, addr);
-    }
+  // Validate size of trap opcode.
+  if (bp_opcode_size == 0) {
+    if (log)
+      log->Printf("SoftwareBreakpoint::%s failed to retrieve any trap opcodes",
+                  __FUNCTION__);
+    return Error("SoftwareBreakpoint::GetSoftwareBreakpointTrapOpcode() "
+                 "returned zero, unable to get breakpoint trap for address "
+                 "0x%" PRIx64,
+                 addr);
+  }
 
-    // Enable the breakpoint.
-    uint8_t saved_opcode_bytes [MAX_TRAP_OPCODE_SIZE];
-    error = EnableSoftwareBreakpoint (process, addr, bp_opcode_size, bp_opcode_bytes, saved_opcode_bytes);
-    if (error.Fail ())
-    {
-        if (log)
-            log->Printf ("SoftwareBreakpoint::%s: failed to enable new breakpoint at 0x%" PRIx64 ": %s", __FUNCTION__, addr, error.AsCString ());
-        return error;
-    }
+  if (bp_opcode_size > MAX_TRAP_OPCODE_SIZE) {
+    if (log)
+      log->Printf("SoftwareBreakpoint::%s cannot support %lu trapcode bytes, "
+                  "max size is %lu",
+                  __FUNCTION__, bp_opcode_size, MAX_TRAP_OPCODE_SIZE);
+    return Error("SoftwareBreakpoint::GetSoftwareBreakpointTrapOpcode() "
+                 "returned too many trap opcode bytes: requires %lu but we "
+                 "only support a max of %lu",
+                 bp_opcode_size, MAX_TRAP_OPCODE_SIZE);
+  }
 
+  // Validate that we received opcodes.
+  if (!bp_opcode_bytes) {
     if (log)
-        log->Printf ("SoftwareBreakpoint::%s addr = 0x%" PRIx64 " -- SUCCESS", __FUNCTION__, addr);
+      log->Printf("SoftwareBreakpoint::%s failed to retrieve trap opcode bytes",
+                  __FUNCTION__);
+    return Error("SoftwareBreakpoint::GetSoftwareBreakpointTrapOpcode() "
+                 "returned NULL trap opcode bytes, unable to get breakpoint "
+                 "trap for address 0x%" PRIx64,
+                 addr);
+  }
+
+  // Enable the breakpoint.
+  uint8_t saved_opcode_bytes[MAX_TRAP_OPCODE_SIZE];
+  error = EnableSoftwareBreakpoint(process, addr, bp_opcode_size,
+                                   bp_opcode_bytes, saved_opcode_bytes);
+  if (error.Fail()) {
+    if (log)
+      log->Printf("SoftwareBreakpoint::%s: failed to enable new breakpoint at "
+                  "0x%" PRIx64 ": %s",
+                  __FUNCTION__, addr, error.AsCString());
+    return error;
+  }
 
-    // Set the breakpoint and verified it was written properly.  Now
-    // create a breakpoint remover that understands how to undo this
-    // breakpoint.
-    breakpoint_sp.reset (new SoftwareBreakpoint (process, addr, saved_opcode_bytes, bp_opcode_bytes, bp_opcode_size));
-    return Error ();
+  if (log)
+    log->Printf("SoftwareBreakpoint::%s addr = 0x%" PRIx64 " -- SUCCESS",
+                __FUNCTION__, addr);
+
+  // Set the breakpoint and verified it was written properly.  Now
+  // create a breakpoint remover that understands how to undo this
+  // breakpoint.
+  breakpoint_sp.reset(new SoftwareBreakpoint(process, addr, saved_opcode_bytes,
+                                             bp_opcode_bytes, bp_opcode_size));
+  return Error();
 }
 
-Error
-SoftwareBreakpoint::EnableSoftwareBreakpoint (NativeProcessProtocol &process, lldb::addr_t addr, size_t bp_opcode_size, const uint8_t *bp_opcode_bytes, uint8_t *saved_opcode_bytes)
-{
-    assert (bp_opcode_size <= MAX_TRAP_OPCODE_SIZE && "bp_opcode_size out of valid range");
-    assert (bp_opcode_bytes && "bp_opcode_bytes is NULL");
-    assert (saved_opcode_bytes && "saved_opcode_bytes is NULL");
-
-    Log *log (GetLogIfAnyCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
+Error SoftwareBreakpoint::EnableSoftwareBreakpoint(
+    NativeProcessProtocol &process, lldb::addr_t addr, size_t bp_opcode_size,
+    const uint8_t *bp_opcode_bytes, uint8_t *saved_opcode_bytes) {
+  assert(bp_opcode_size <= MAX_TRAP_OPCODE_SIZE &&
+         "bp_opcode_size out of valid range");
+  assert(bp_opcode_bytes && "bp_opcode_bytes is NULL");
+  assert(saved_opcode_bytes && "saved_opcode_bytes is NULL");
+
+  Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
+  if (log)
+    log->Printf("SoftwareBreakpoint::%s addr = 0x%" PRIx64, __FUNCTION__, addr);
+
+  // Save the original opcodes by reading them so we can restore later.
+  size_t bytes_read = 0;
+
+  Error error =
+      process.ReadMemory(addr, saved_opcode_bytes, bp_opcode_size, bytes_read);
+  if (error.Fail()) {
     if (log)
-        log->Printf ("SoftwareBreakpoint::%s addr = 0x%" PRIx64, __FUNCTION__, addr);
-
-    // Save the original opcodes by reading them so we can restore later.
-    size_t bytes_read = 0;
-
-    Error error = process.ReadMemory(addr, saved_opcode_bytes, bp_opcode_size, bytes_read);
-    if (error.Fail ())
-    {
-        if (log)
-            log->Printf ("SoftwareBreakpoint::%s failed to read memory while attempting to set breakpoint: %s", __FUNCTION__, error.AsCString ());
-        return error;
-    }
-
-    // Ensure we read as many bytes as we expected.
-    if (bytes_read != bp_opcode_size)
-    {
-        if (log)
-            log->Printf ("SoftwareBreakpoint::%s failed to read memory while attempting to set breakpoint: attempted to read %lu bytes but only read %" PRIu64, __FUNCTION__, bp_opcode_size, (uint64_t)bytes_read);
-        return Error ("SoftwareBreakpoint::%s failed to read memory while attempting to set breakpoint: attempted to read %lu bytes but only read %" PRIu64, __FUNCTION__, bp_opcode_size, (uint64_t)bytes_read);
-    }
+      log->Printf("SoftwareBreakpoint::%s failed to read memory while "
+                  "attempting to set breakpoint: %s",
+                  __FUNCTION__, error.AsCString());
+    return error;
+  }
 
-    // Log what we read.
+  // Ensure we read as many bytes as we expected.
+  if (bytes_read != bp_opcode_size) {
     if (log)
-    {
-        int i = 0;
-        for (const uint8_t *read_byte = saved_opcode_bytes; read_byte < saved_opcode_bytes + bp_opcode_size; ++read_byte)
-        {
-            log->Printf("SoftwareBreakpoint::%s addr = 0x%" PRIx64
-                    " ovewriting byte index %d (was 0x%hhx)",
-                    __FUNCTION__, addr, i++, *read_byte);
-        }
-    }
-
-    // Write a software breakpoint in place of the original opcode.
-    size_t bytes_written = 0;
-    error = process.WriteMemory(addr, bp_opcode_bytes, bp_opcode_size, bytes_written);
-    if (error.Fail ())
-    {
-        if (log)
-            log->Printf ("SoftwareBreakpoint::%s failed to write memory while attempting to set breakpoint: %s", __FUNCTION__, error.AsCString ());
-        return error;
-    }
-
-    // Ensure we wrote as many bytes as we expected.
-    if (bytes_written != bp_opcode_size)
-    {
-        error.SetErrorStringWithFormat("SoftwareBreakpoint::%s failed write memory while attempting to set breakpoint: attempted to write %lu bytes but only wrote %" PRIu64, __FUNCTION__, bp_opcode_size, (uint64_t)bytes_written);
-        if (log)
-            log->PutCString (error.AsCString ());
-        return error;
-    }
+      log->Printf("SoftwareBreakpoint::%s failed to read memory while "
+                  "attempting to set breakpoint: attempted to read %lu bytes "
+                  "but only read %" PRIu64,
+                  __FUNCTION__, bp_opcode_size, (uint64_t)bytes_read);
+    return Error("SoftwareBreakpoint::%s failed to read memory while "
+                 "attempting to set breakpoint: attempted to read %lu bytes "
+                 "but only read %" PRIu64,
+                 __FUNCTION__, bp_opcode_size, (uint64_t)bytes_read);
+  }
+
+  // Log what we read.
+  if (log) {
+    int i = 0;
+    for (const uint8_t *read_byte = saved_opcode_bytes;
+         read_byte < saved_opcode_bytes + bp_opcode_size; ++read_byte) {
+      log->Printf("SoftwareBreakpoint::%s addr = 0x%" PRIx64
+                  " ovewriting byte index %d (was 0x%hhx)",
+                  __FUNCTION__, addr, i++, *read_byte);
+    }
+  }
+
+  // Write a software breakpoint in place of the original opcode.
+  size_t bytes_written = 0;
+  error =
+      process.WriteMemory(addr, bp_opcode_bytes, bp_opcode_size, bytes_written);
+  if (error.Fail()) {
+    if (log)
+      log->Printf("SoftwareBreakpoint::%s failed to write memory while "
+                  "attempting to set breakpoint: %s",
+                  __FUNCTION__, error.AsCString());
+    return error;
+  }
 
-    uint8_t verify_bp_opcode_bytes [MAX_TRAP_OPCODE_SIZE];
-    size_t verify_bytes_read = 0;
-    error = process.ReadMemory(addr, verify_bp_opcode_bytes, bp_opcode_size, verify_bytes_read);
-    if (error.Fail ())
-    {
-        if (log)
-            log->Printf ("SoftwareBreakpoint::%s failed to read memory while attempting to verify the breakpoint set: %s", __FUNCTION__, error.AsCString ());
-        return error;
-    }
+  // Ensure we wrote as many bytes as we expected.
+  if (bytes_written != bp_opcode_size) {
+    error.SetErrorStringWithFormat(
+        "SoftwareBreakpoint::%s failed write memory while attempting to set "
+        "breakpoint: attempted to write %lu bytes but only wrote %" PRIu64,
+        __FUNCTION__, bp_opcode_size, (uint64_t)bytes_written);
+    if (log)
+      log->PutCString(error.AsCString());
+    return error;
+  }
 
-    // Ensure we read as many verification bytes as we expected.
-    if (verify_bytes_read != bp_opcode_size)
-    {
-        if (log)
-            log->Printf ("SoftwareBreakpoint::%s failed to read memory while attempting to verify breakpoint: attempted to read %lu bytes but only read %" PRIu64, __FUNCTION__, bp_opcode_size, (uint64_t)verify_bytes_read);
-        return Error ("SoftwareBreakpoint::%s failed to read memory while attempting to verify breakpoint: attempted to read %lu bytes but only read %" PRIu64, __FUNCTION__, bp_opcode_size, (uint64_t)verify_bytes_read);
-    }
+  uint8_t verify_bp_opcode_bytes[MAX_TRAP_OPCODE_SIZE];
+  size_t verify_bytes_read = 0;
+  error = process.ReadMemory(addr, verify_bp_opcode_bytes, bp_opcode_size,
+                             verify_bytes_read);
+  if (error.Fail()) {
+    if (log)
+      log->Printf("SoftwareBreakpoint::%s failed to read memory while "
+                  "attempting to verify the breakpoint set: %s",
+                  __FUNCTION__, error.AsCString());
+    return error;
+  }
 
-    if (::memcmp(bp_opcode_bytes, verify_bp_opcode_bytes, bp_opcode_size) != 0)
-    {
-        if (log)
-            log->Printf ("SoftwareBreakpoint::%s: verification of software breakpoint writing failed - trap opcodes not successfully read back after writing when setting breakpoint at 0x%" PRIx64, __FUNCTION__, addr);
-        return Error ("SoftwareBreakpoint::%s: verification of software breakpoint writing failed - trap opcodes not successfully read back after writing when setting breakpoint at 0x%" PRIx64, __FUNCTION__, addr);
-    }
+  // Ensure we read as many verification bytes as we expected.
+  if (verify_bytes_read != bp_opcode_size) {
+    if (log)
+      log->Printf("SoftwareBreakpoint::%s failed to read memory while "
+                  "attempting to verify breakpoint: attempted to read %lu "
+                  "bytes but only read %" PRIu64,
+                  __FUNCTION__, bp_opcode_size, (uint64_t)verify_bytes_read);
+    return Error("SoftwareBreakpoint::%s failed to read memory while "
+                 "attempting to verify breakpoint: attempted to read %lu bytes "
+                 "but only read %" PRIu64,
+                 __FUNCTION__, bp_opcode_size, (uint64_t)verify_bytes_read);
+  }
 
+  if (::memcmp(bp_opcode_bytes, verify_bp_opcode_bytes, bp_opcode_size) != 0) {
     if (log)
-        log->Printf ("SoftwareBreakpoint::%s addr = 0x%" PRIx64 " -- SUCCESS", __FUNCTION__, addr);
+      log->Printf("SoftwareBreakpoint::%s: verification of software breakpoint "
+                  "writing failed - trap opcodes not successfully read back "
+                  "after writing when setting breakpoint at 0x%" PRIx64,
+                  __FUNCTION__, addr);
+    return Error("SoftwareBreakpoint::%s: verification of software breakpoint "
+                 "writing failed - trap opcodes not successfully read back "
+                 "after writing when setting breakpoint at 0x%" PRIx64,
+                 __FUNCTION__, addr);
+  }
+
+  if (log)
+    log->Printf("SoftwareBreakpoint::%s addr = 0x%" PRIx64 " -- SUCCESS",
+                __FUNCTION__, addr);
 
-    return Error ();
+  return Error();
 }
 
 // -------------------------------------------------------------------
 // instance-level members
 // -------------------------------------------------------------------
 
-SoftwareBreakpoint::SoftwareBreakpoint (NativeProcessProtocol &process, lldb::addr_t addr, const uint8_t *saved_opcodes, const uint8_t *trap_opcodes, size_t opcode_size) :
-    NativeBreakpoint (addr),
-    m_process (process),
-    m_saved_opcodes (),
-    m_trap_opcodes (),
-    m_opcode_size (opcode_size)
-{
-    assert ( opcode_size > 0 && "setting software breakpoint with no trap opcodes");
-    assert ( opcode_size <= MAX_TRAP_OPCODE_SIZE  && "trap opcode size too large");
+SoftwareBreakpoint::SoftwareBreakpoint(NativeProcessProtocol &process,
+                                       lldb::addr_t addr,
+                                       const uint8_t *saved_opcodes,
+                                       const uint8_t *trap_opcodes,
+                                       size_t opcode_size)
+    : NativeBreakpoint(addr), m_process(process), m_saved_opcodes(),
+      m_trap_opcodes(), m_opcode_size(opcode_size) {
+  assert(opcode_size > 0 && "setting software breakpoint with no trap opcodes");
+  assert(opcode_size <= MAX_TRAP_OPCODE_SIZE && "trap opcode size too large");
 
-    ::memcpy (m_saved_opcodes, saved_opcodes, opcode_size);
-    ::memcpy (m_trap_opcodes, trap_opcodes, opcode_size);
+  ::memcpy(m_saved_opcodes, saved_opcodes, opcode_size);
+  ::memcpy(m_trap_opcodes, trap_opcodes, opcode_size);
 }
 
-Error
-SoftwareBreakpoint::DoEnable ()
-{
-    return EnableSoftwareBreakpoint (m_process, m_addr, m_opcode_size, m_trap_opcodes, m_saved_opcodes);
+Error SoftwareBreakpoint::DoEnable() {
+  return EnableSoftwareBreakpoint(m_process, m_addr, m_opcode_size,
+                                  m_trap_opcodes, m_saved_opcodes);
 }
 
-Error
-SoftwareBreakpoint::DoDisable ()
-{
-    Error error;
-    assert (m_addr && (m_addr != LLDB_INVALID_ADDRESS) && "can't remove a software breakpoint for an invalid address");
-
-    Log *log (GetLogIfAnyCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
-    if (log)
-        log->Printf ("SoftwareBreakpoint::%s addr = 0x%" PRIx64, __FUNCTION__, m_addr);
-
-    assert ( (m_opcode_size > 0) && "cannot restore opcodes when there are no opcodes");
-
-    if (m_opcode_size > 0)
-    {
-        // Clear a software breakpoint instruction
-        uint8_t curr_break_op [MAX_TRAP_OPCODE_SIZE];
-        bool break_op_found = false;
-        assert (m_opcode_size <= sizeof (curr_break_op));
-
-        // Read the breakpoint opcode
-        size_t bytes_read = 0;
-        error = m_process.ReadMemory (m_addr, curr_break_op, m_opcode_size, bytes_read);
-        if (error.Success() && bytes_read < m_opcode_size)
-        {
-            error.SetErrorStringWithFormat ("SoftwareBreakpointr::%s addr=0x%" PRIx64 ": tried to read %lu bytes but only read %" PRIu64, __FUNCTION__, m_addr, m_opcode_size, (uint64_t)bytes_read);
-        }
-        if (error.Success ())
-        {
-            bool verify = false;
-            // Make sure the breakpoint opcode exists at this address
-            if (::memcmp (curr_break_op, m_trap_opcodes, m_opcode_size) == 0)
-            {
-                break_op_found = true;
-                // We found a valid breakpoint opcode at this address, now restore
-                // the saved opcode.
-                size_t bytes_written = 0;
-                error = m_process.WriteMemory (m_addr, m_saved_opcodes, m_opcode_size, bytes_written);
-                if (error.Success() && bytes_written < m_opcode_size)
-                {
-                    error.SetErrorStringWithFormat ("SoftwareBreakpoint::%s addr=0x%" PRIx64 ": tried to write %lu bytes but only wrote %" PRIu64, __FUNCTION__, m_addr, m_opcode_size, (uint64_t)bytes_written);
-                }
-                if (error.Success ())
-                {
-                    verify = true;
-                }
-            }
-            else
-            {
-                error.SetErrorString("Original breakpoint trap is no longer in memory.");
-                // Set verify to true and so we can check if the original opcode has already been restored
-                verify = true;
-            }
+Error SoftwareBreakpoint::DoDisable() {
+  Error error;
+  assert(m_addr && (m_addr != LLDB_INVALID_ADDRESS) &&
+         "can't remove a software breakpoint for an invalid address");
+
+  Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
+  if (log)
+    log->Printf("SoftwareBreakpoint::%s addr = 0x%" PRIx64, __FUNCTION__,
+                m_addr);
+
+  assert((m_opcode_size > 0) &&
+         "cannot restore opcodes when there are no opcodes");
+
+  if (m_opcode_size > 0) {
+    // Clear a software breakpoint instruction
+    uint8_t curr_break_op[MAX_TRAP_OPCODE_SIZE];
+    bool break_op_found = false;
+    assert(m_opcode_size <= sizeof(curr_break_op));
 
-            if (verify)
-            {
-                uint8_t verify_opcode [MAX_TRAP_OPCODE_SIZE];
-                assert (m_opcode_size <= sizeof (verify_opcode));
-                // Verify that our original opcode made it back to the inferior
-
-                size_t verify_bytes_read = 0;
-                error = m_process.ReadMemory (m_addr, verify_opcode, m_opcode_size, verify_bytes_read);
-                if (error.Success() && verify_bytes_read < m_opcode_size)
-                {
-                    error.SetErrorStringWithFormat ("SoftwareBreakpoint::%s addr=0x%" PRIx64 ": tried to read %lu verification bytes but only read %" PRIu64, __FUNCTION__, m_addr, m_opcode_size, (uint64_t)verify_bytes_read);
-                }
-                if (error.Success ())
-                {
-                    // compare the memory we just read with the original opcode
-                    if (::memcmp (m_saved_opcodes, verify_opcode, m_opcode_size) == 0)
-                    {
-                        // SUCCESS
-                        if (log)
-                        {
-                            int i = 0;
-                            for (const uint8_t *verify_byte = verify_opcode; verify_byte < verify_opcode + m_opcode_size; ++verify_byte)
-                            {
-                                log->Printf("SoftwareBreakpoint::%s addr = 0x%" PRIx64
-                                        " replaced byte index %d with 0x%hhx",
-                                        __FUNCTION__, m_addr, i++, *verify_byte);
-                            }
-                            log->Printf ("SoftwareBreakpoint::%s addr = 0x%" PRIx64 " -- SUCCESS", __FUNCTION__, m_addr);
-                        }
-                        return error;
-                    }
-                    else
-                    {
-                        if (break_op_found)
-                            error.SetErrorString("Failed to restore original opcode.");
-                    }
-                }
-                else
-                    error.SetErrorString("Failed to read memory to verify that breakpoint trap was restored.");
-            }
+    // Read the breakpoint opcode
+    size_t bytes_read = 0;
+    error =
+        m_process.ReadMemory(m_addr, curr_break_op, m_opcode_size, bytes_read);
+    if (error.Success() && bytes_read < m_opcode_size) {
+      error.SetErrorStringWithFormat(
+          "SoftwareBreakpointr::%s addr=0x%" PRIx64
+          ": tried to read %lu bytes but only read %" PRIu64,
+          __FUNCTION__, m_addr, m_opcode_size, (uint64_t)bytes_read);
+    }
+    if (error.Success()) {
+      bool verify = false;
+      // Make sure the breakpoint opcode exists at this address
+      if (::memcmp(curr_break_op, m_trap_opcodes, m_opcode_size) == 0) {
+        break_op_found = true;
+        // We found a valid breakpoint opcode at this address, now restore
+        // the saved opcode.
+        size_t bytes_written = 0;
+        error = m_process.WriteMemory(m_addr, m_saved_opcodes, m_opcode_size,
+                                      bytes_written);
+        if (error.Success() && bytes_written < m_opcode_size) {
+          error.SetErrorStringWithFormat(
+              "SoftwareBreakpoint::%s addr=0x%" PRIx64
+              ": tried to write %lu bytes but only wrote %" PRIu64,
+              __FUNCTION__, m_addr, m_opcode_size, (uint64_t)bytes_written);
         }
-    }
-
-    if (log && error.Fail ())
-        log->Printf ("SoftwareBreakpoint::%s addr = 0x%" PRIx64 " -- FAILED: %s",
-                __FUNCTION__,
-                m_addr,
-                error.AsCString());
-    return error;
-}
-
-bool
-SoftwareBreakpoint::IsSoftwareBreakpoint () const
-{
-    return true;
+        if (error.Success()) {
+          verify = true;
+        }
+      } else {
+        error.SetErrorString(
+            "Original breakpoint trap is no longer in memory.");
+        // Set verify to true and so we can check if the original opcode has
+        // already been restored
+        verify = true;
+      }
+
+      if (verify) {
+        uint8_t verify_opcode[MAX_TRAP_OPCODE_SIZE];
+        assert(m_opcode_size <= sizeof(verify_opcode));
+        // Verify that our original opcode made it back to the inferior
+
+        size_t verify_bytes_read = 0;
+        error = m_process.ReadMemory(m_addr, verify_opcode, m_opcode_size,
+                                     verify_bytes_read);
+        if (error.Success() && verify_bytes_read < m_opcode_size) {
+          error.SetErrorStringWithFormat(
+              "SoftwareBreakpoint::%s addr=0x%" PRIx64
+              ": tried to read %lu verification bytes but only read %" PRIu64,
+              __FUNCTION__, m_addr, m_opcode_size, (uint64_t)verify_bytes_read);
+        }
+        if (error.Success()) {
+          // compare the memory we just read with the original opcode
+          if (::memcmp(m_saved_opcodes, verify_opcode, m_opcode_size) == 0) {
+            // SUCCESS
+            if (log) {
+              int i = 0;
+              for (const uint8_t *verify_byte = verify_opcode;
+                   verify_byte < verify_opcode + m_opcode_size; ++verify_byte) {
+                log->Printf("SoftwareBreakpoint::%s addr = 0x%" PRIx64
+                            " replaced byte index %d with 0x%hhx",
+                            __FUNCTION__, m_addr, i++, *verify_byte);
+              }
+              log->Printf("SoftwareBreakpoint::%s addr = 0x%" PRIx64
+                          " -- SUCCESS",
+                          __FUNCTION__, m_addr);
+            }
+            return error;
+          } else {
+            if (break_op_found)
+              error.SetErrorString("Failed to restore original opcode.");
+          }
+        } else
+          error.SetErrorString("Failed to read memory to verify that "
+                               "breakpoint trap was restored.");
+      }
+    }
+  }
+
+  if (log && error.Fail())
+    log->Printf("SoftwareBreakpoint::%s addr = 0x%" PRIx64 " -- FAILED: %s",
+                __FUNCTION__, m_addr, error.AsCString());
+  return error;
 }
 
+bool SoftwareBreakpoint::IsSoftwareBreakpoint() const { return true; }

Modified: lldb/trunk/source/Host/common/StringConvert.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/StringConvert.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/StringConvert.cpp (original)
+++ lldb/trunk/source/Host/common/StringConvert.cpp Tue Sep  6 15:57:50 2016
@@ -15,103 +15,86 @@
 // Project includes
 #include "lldb/Host/StringConvert.h"
 
-namespace lldb_private
-{
-    namespace StringConvert
-    {
-
-        int32_t
-        ToSInt32 (const char *s, int32_t fail_value, int base, bool *success_ptr)
-        {
-            if (s && s[0])
-            {
-                char *end = nullptr;
-                const long sval = ::strtol (s, &end, base);
-                if (*end == '\0')
-                {
-                    if (success_ptr)
-                        *success_ptr = ((sval <= INT32_MAX) && (sval >= INT32_MIN));
-                    return (int32_t)sval; // All characters were used, return the result
-                }
-            }
-            if (success_ptr)
-                *success_ptr = false;
-            return fail_value;
-        }
-
-        uint32_t
-        ToUInt32 (const char *s, uint32_t fail_value, int base, bool *success_ptr)
-        {
-            if (s && s[0])
-            {
-                char *end = nullptr;
-                const unsigned long uval = ::strtoul (s, &end, base);
-                if (*end == '\0')
-                {
-                    if (success_ptr)
-                        *success_ptr = (uval <= UINT32_MAX);
-                    return (uint32_t)uval; // All characters were used, return the result
-                }
-            }
-            if (success_ptr)
-                *success_ptr = false;
-            return fail_value;
-        }
-
-        int64_t
-        ToSInt64 (const char *s, int64_t fail_value, int base, bool *success_ptr)
-        {
-            if (s && s[0])
-            {
-                char *end = nullptr;
-                int64_t uval = ::strtoll (s, &end, base);
-                if (*end == '\0')
-                {
-                    if (success_ptr)
-                        *success_ptr = true;
-                    return uval; // All characters were used, return the result
-                }
-            }
-            if (success_ptr)
-                *success_ptr = false;
-            return fail_value;
-        }
-
-        uint64_t
-        ToUInt64 (const char *s, uint64_t fail_value, int base, bool *success_ptr)
-        {
-            if (s && s[0])
-            {
-                char *end = nullptr;
-                uint64_t uval = ::strtoull (s, &end, base);
-                if (*end == '\0')
-                {
-                    if (success_ptr)
-                        *success_ptr = true;
-                    return uval; // All characters were used, return the result
-                }
-            }
-            if (success_ptr) *success_ptr = false;
-            return fail_value;
-        }
-
-        double
-        ToDouble (const char *s, double fail_value, bool *success_ptr)
-        {
-            if (s && s[0])
-            {
-                char *end = nullptr;
-                double val = strtod (s, &end);
-                if (*end == '\0')
-                {
-                    if (success_ptr)
-                        *success_ptr = true;
-                    return val; // All characters were used, return the result
-                }
-            }
-            if (success_ptr)
-                *success_ptr = false;
-            return fail_value;
-        }
+namespace lldb_private {
+namespace StringConvert {
+
+int32_t ToSInt32(const char *s, int32_t fail_value, int base,
+                 bool *success_ptr) {
+  if (s && s[0]) {
+    char *end = nullptr;
+    const long sval = ::strtol(s, &end, base);
+    if (*end == '\0') {
+      if (success_ptr)
+        *success_ptr = ((sval <= INT32_MAX) && (sval >= INT32_MIN));
+      return (int32_t)sval; // All characters were used, return the result
+    }
+  }
+  if (success_ptr)
+    *success_ptr = false;
+  return fail_value;
+}
+
+uint32_t ToUInt32(const char *s, uint32_t fail_value, int base,
+                  bool *success_ptr) {
+  if (s && s[0]) {
+    char *end = nullptr;
+    const unsigned long uval = ::strtoul(s, &end, base);
+    if (*end == '\0') {
+      if (success_ptr)
+        *success_ptr = (uval <= UINT32_MAX);
+      return (uint32_t)uval; // All characters were used, return the result
     }
+  }
+  if (success_ptr)
+    *success_ptr = false;
+  return fail_value;
+}
+
+int64_t ToSInt64(const char *s, int64_t fail_value, int base,
+                 bool *success_ptr) {
+  if (s && s[0]) {
+    char *end = nullptr;
+    int64_t uval = ::strtoll(s, &end, base);
+    if (*end == '\0') {
+      if (success_ptr)
+        *success_ptr = true;
+      return uval; // All characters were used, return the result
+    }
+  }
+  if (success_ptr)
+    *success_ptr = false;
+  return fail_value;
+}
+
+uint64_t ToUInt64(const char *s, uint64_t fail_value, int base,
+                  bool *success_ptr) {
+  if (s && s[0]) {
+    char *end = nullptr;
+    uint64_t uval = ::strtoull(s, &end, base);
+    if (*end == '\0') {
+      if (success_ptr)
+        *success_ptr = true;
+      return uval; // All characters were used, return the result
+    }
+  }
+  if (success_ptr)
+    *success_ptr = false;
+  return fail_value;
+}
+
+double ToDouble(const char *s, double fail_value, bool *success_ptr) {
+  if (s && s[0]) {
+    char *end = nullptr;
+    double val = strtod(s, &end);
+    if (*end == '\0') {
+      if (success_ptr)
+        *success_ptr = true;
+      return val; // All characters were used, return the result
+    }
+  }
+  if (success_ptr)
+    *success_ptr = false;
+  return fail_value;
+}
+}
 }

Modified: lldb/trunk/source/Host/common/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Symbols.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/Symbols.cpp (original)
+++ lldb/trunk/source/Host/common/Symbols.cpp Tue Sep  6 15:57:50 2016
@@ -34,294 +34,259 @@ using namespace llvm::MachO;
 #if defined(__APPLE__)
 
 // Forward declaration of method defined in source/Host/macosx/Symbols.cpp
-int
-LocateMacOSXFilesUsingDebugSymbols
-(
-    const ModuleSpec &module_spec,
-    ModuleSpec &return_module_spec
-);
+int LocateMacOSXFilesUsingDebugSymbols(const ModuleSpec &module_spec,
+                                       ModuleSpec &return_module_spec);
 
 #else
 
-int
-LocateMacOSXFilesUsingDebugSymbols
-(
-    const ModuleSpec &module_spec,
-    ModuleSpec &return_module_spec
-) {
-    // Cannot find MacOSX files using debug symbols on non MacOSX.
-    return 0;
+int LocateMacOSXFilesUsingDebugSymbols(const ModuleSpec &module_spec,
+                                       ModuleSpec &return_module_spec) {
+  // Cannot find MacOSX files using debug symbols on non MacOSX.
+  return 0;
 }
 
 #endif
 
-static bool
-FileAtPathContainsArchAndUUID (const FileSpec &file_fspec, const ArchSpec *arch, const lldb_private::UUID *uuid)
-{
-    ModuleSpecList module_specs;
-    if (ObjectFile::GetModuleSpecifications(file_fspec, 0, 0, module_specs))
-    {
-        ModuleSpec spec;
-        for (size_t i = 0; i < module_specs.GetSize(); ++i)
-        {
-            assert(module_specs.GetModuleSpecAtIndex(i, spec));
-            if ((uuid == NULL || (spec.GetUUIDPtr() && spec.GetUUID() == *uuid)) &&
-                (arch == NULL || (spec.GetArchitecturePtr() && spec.GetArchitecture().IsCompatibleMatch(*arch))))
-            {
-                return true;
-            }
-        }
+static bool FileAtPathContainsArchAndUUID(const FileSpec &file_fspec,
+                                          const ArchSpec *arch,
+                                          const lldb_private::UUID *uuid) {
+  ModuleSpecList module_specs;
+  if (ObjectFile::GetModuleSpecifications(file_fspec, 0, 0, module_specs)) {
+    ModuleSpec spec;
+    for (size_t i = 0; i < module_specs.GetSize(); ++i) {
+      assert(module_specs.GetModuleSpecAtIndex(i, spec));
+      if ((uuid == NULL || (spec.GetUUIDPtr() && spec.GetUUID() == *uuid)) &&
+          (arch == NULL || (spec.GetArchitecturePtr() &&
+                            spec.GetArchitecture().IsCompatibleMatch(*arch)))) {
+        return true;
+      }
     }
-    return false;
+  }
+  return false;
 }
 
-static bool
-LocateDSYMInVincinityOfExecutable (const ModuleSpec &module_spec, FileSpec &dsym_fspec)
-{
-    Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
-    const FileSpec *exec_fspec = module_spec.GetFileSpecPtr();
-    if (exec_fspec)
-    {
-        char path[PATH_MAX];
-        if (exec_fspec->GetPath(path, sizeof(path)))
-        {
-            // Make sure the module isn't already just a dSYM file...
-            if (strcasestr(path, ".dSYM/Contents/Resources/DWARF") == NULL)
-            {
-                if (log)
-                {
-                    if (module_spec.GetUUIDPtr() && module_spec.GetUUIDPtr()->IsValid())
-                    {
-                        log->Printf ("Searching for dSYM bundle next to executable %s, UUID %s", path, module_spec.GetUUIDPtr()->GetAsString().c_str());
-                    }
-                    else
-                    {
-                        log->Printf ("Searching for dSYM bundle next to executable %s", path);
-                    }
-                }
-                size_t obj_file_path_length = strlen(path);
-                ::strncat(path, ".dSYM/Contents/Resources/DWARF/", sizeof(path) - strlen(path) - 1);
-                ::strncat(path, exec_fspec->GetFilename().AsCString(), sizeof(path) - strlen(path) - 1);
-
-                dsym_fspec.SetFile(path, false);
-
-                ModuleSpecList module_specs;
-                ModuleSpec matched_module_spec;
-                if (dsym_fspec.Exists() &&
-                    FileAtPathContainsArchAndUUID(dsym_fspec, module_spec.GetArchitecturePtr(), module_spec.GetUUIDPtr()))
-                {
-                    if (log)
-                    {
-                        log->Printf ("dSYM with matching UUID & arch found at %s", path);
-                    }
-                    return true;
+static bool LocateDSYMInVincinityOfExecutable(const ModuleSpec &module_spec,
+                                              FileSpec &dsym_fspec) {
+  Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+  const FileSpec *exec_fspec = module_spec.GetFileSpecPtr();
+  if (exec_fspec) {
+    char path[PATH_MAX];
+    if (exec_fspec->GetPath(path, sizeof(path))) {
+      // Make sure the module isn't already just a dSYM file...
+      if (strcasestr(path, ".dSYM/Contents/Resources/DWARF") == NULL) {
+        if (log) {
+          if (module_spec.GetUUIDPtr() && module_spec.GetUUIDPtr()->IsValid()) {
+            log->Printf(
+                "Searching for dSYM bundle next to executable %s, UUID %s",
+                path, module_spec.GetUUIDPtr()->GetAsString().c_str());
+          } else {
+            log->Printf("Searching for dSYM bundle next to executable %s",
+                        path);
+          }
+        }
+        size_t obj_file_path_length = strlen(path);
+        ::strncat(path, ".dSYM/Contents/Resources/DWARF/",
+                  sizeof(path) - strlen(path) - 1);
+        ::strncat(path, exec_fspec->GetFilename().AsCString(),
+                  sizeof(path) - strlen(path) - 1);
+
+        dsym_fspec.SetFile(path, false);
+
+        ModuleSpecList module_specs;
+        ModuleSpec matched_module_spec;
+        if (dsym_fspec.Exists() &&
+            FileAtPathContainsArchAndUUID(dsym_fspec,
+                                          module_spec.GetArchitecturePtr(),
+                                          module_spec.GetUUIDPtr())) {
+          if (log) {
+            log->Printf("dSYM with matching UUID & arch found at %s", path);
+          }
+          return true;
+        } else {
+          path[obj_file_path_length] = '\0';
+
+          char *last_dot = strrchr(path, '.');
+          while (last_dot != NULL && last_dot[0]) {
+            char *next_slash = strchr(last_dot, '/');
+            if (next_slash != NULL) {
+              *next_slash = '\0';
+              ::strncat(path, ".dSYM/Contents/Resources/DWARF/",
+                        sizeof(path) - strlen(path) - 1);
+              ::strncat(path, exec_fspec->GetFilename().AsCString(),
+                        sizeof(path) - strlen(path) - 1);
+              dsym_fspec.SetFile(path, false);
+              if (dsym_fspec.Exists() &&
+                  FileAtPathContainsArchAndUUID(
+                      dsym_fspec, module_spec.GetArchitecturePtr(),
+                      module_spec.GetUUIDPtr())) {
+                if (log) {
+                  log->Printf("dSYM with matching UUID & arch found at %s",
+                              path);
                 }
+                return true;
+              } else {
+                *last_dot = '\0';
+                char *prev_slash = strrchr(path, '/');
+                if (prev_slash != NULL)
+                  *prev_slash = '\0';
                 else
-                {
-                    path[obj_file_path_length] = '\0';
-
-                    char *last_dot = strrchr(path, '.');
-                    while (last_dot != NULL && last_dot[0])
-                    {
-                        char *next_slash = strchr(last_dot, '/');
-                        if (next_slash != NULL)
-                        {
-                            *next_slash = '\0';
-                            ::strncat(path, ".dSYM/Contents/Resources/DWARF/", sizeof(path) - strlen(path) - 1);
-                            ::strncat(path, exec_fspec->GetFilename().AsCString(), sizeof(path) - strlen(path) - 1);
-                            dsym_fspec.SetFile(path, false);
-                            if (dsym_fspec.Exists() &&
-                                FileAtPathContainsArchAndUUID(dsym_fspec, module_spec.GetArchitecturePtr(), module_spec.GetUUIDPtr()))
-                            {
-                                if (log)
-                                {
-                                    log->Printf ("dSYM with matching UUID & arch found at %s", path);
-                                }
-                                return true;
-                            }
-                            else
-                            {
-                                *last_dot = '\0';
-                                char *prev_slash = strrchr(path, '/');
-                                if (prev_slash != NULL)
-                                    *prev_slash = '\0';
-                                else
-                                    break;
-                            }
-                        }
-                        else
-                        {
-                            break;
-                        }
-                    }
-                }
+                  break;
+              }
+            } else {
+              break;
             }
+          }
         }
+      }
     }
-    dsym_fspec.Clear();
-    return false;
+  }
+  dsym_fspec.Clear();
+  return false;
 }
 
-FileSpec
-LocateExecutableSymbolFileDsym (const ModuleSpec &module_spec)
-{
-    const FileSpec *exec_fspec = module_spec.GetFileSpecPtr();
-    const ArchSpec *arch = module_spec.GetArchitecturePtr();
-    const UUID *uuid = module_spec.GetUUIDPtr();
-
-    Timer scoped_timer (LLVM_PRETTY_FUNCTION,
-                        "LocateExecutableSymbolFileDsym (file = %s, arch = %s, uuid = %p)",
-                        exec_fspec ? exec_fspec->GetFilename().AsCString ("<NULL>") : "<NULL>",
-                        arch ? arch->GetArchitectureName() : "<NULL>",
-                        (const void*)uuid);
-
-    FileSpec symbol_fspec;
-    ModuleSpec dsym_module_spec;
-    // First try and find the dSYM in the same directory as the executable or in
-    // an appropriate parent directory
-    if (LocateDSYMInVincinityOfExecutable (module_spec, symbol_fspec) == false)
-    {
-        // We failed to easily find the dSYM above, so use DebugSymbols
-        LocateMacOSXFilesUsingDebugSymbols (module_spec, dsym_module_spec);
-    }
-    else
-    {
-        dsym_module_spec.GetSymbolFileSpec() = symbol_fspec;
-    }
-    return dsym_module_spec.GetSymbolFileSpec();
+FileSpec LocateExecutableSymbolFileDsym(const ModuleSpec &module_spec) {
+  const FileSpec *exec_fspec = module_spec.GetFileSpecPtr();
+  const ArchSpec *arch = module_spec.GetArchitecturePtr();
+  const UUID *uuid = module_spec.GetUUIDPtr();
+
+  Timer scoped_timer(
+      LLVM_PRETTY_FUNCTION,
+      "LocateExecutableSymbolFileDsym (file = %s, arch = %s, uuid = %p)",
+      exec_fspec ? exec_fspec->GetFilename().AsCString("<NULL>") : "<NULL>",
+      arch ? arch->GetArchitectureName() : "<NULL>", (const void *)uuid);
+
+  FileSpec symbol_fspec;
+  ModuleSpec dsym_module_spec;
+  // First try and find the dSYM in the same directory as the executable or in
+  // an appropriate parent directory
+  if (LocateDSYMInVincinityOfExecutable(module_spec, symbol_fspec) == false) {
+    // We failed to easily find the dSYM above, so use DebugSymbols
+    LocateMacOSXFilesUsingDebugSymbols(module_spec, dsym_module_spec);
+  } else {
+    dsym_module_spec.GetSymbolFileSpec() = symbol_fspec;
+  }
+  return dsym_module_spec.GetSymbolFileSpec();
 }
 
-ModuleSpec
-Symbols::LocateExecutableObjectFile (const ModuleSpec &module_spec)
-{
-    ModuleSpec result;
-    const FileSpec *exec_fspec = module_spec.GetFileSpecPtr();
-    const ArchSpec *arch = module_spec.GetArchitecturePtr();
-    const UUID *uuid = module_spec.GetUUIDPtr();
-    Timer scoped_timer (LLVM_PRETTY_FUNCTION,
-                        "LocateExecutableObjectFile (file = %s, arch = %s, uuid = %p)",
-                        exec_fspec ? exec_fspec->GetFilename().AsCString ("<NULL>") : "<NULL>",
-                        arch ? arch->GetArchitectureName() : "<NULL>",
-                        (const void*)uuid);
-
-    ModuleSpecList module_specs;
-    ModuleSpec matched_module_spec;
-    if (exec_fspec &&
-        ObjectFile::GetModuleSpecifications(*exec_fspec, 0, 0, module_specs) &&
-        module_specs.FindMatchingModuleSpec(module_spec, matched_module_spec))
-    {
-        result.GetFileSpec() = exec_fspec;
-    }
-    else
-    {
-        LocateMacOSXFilesUsingDebugSymbols (module_spec, result);
-    }
-    return result;
+ModuleSpec Symbols::LocateExecutableObjectFile(const ModuleSpec &module_spec) {
+  ModuleSpec result;
+  const FileSpec *exec_fspec = module_spec.GetFileSpecPtr();
+  const ArchSpec *arch = module_spec.GetArchitecturePtr();
+  const UUID *uuid = module_spec.GetUUIDPtr();
+  Timer scoped_timer(
+      LLVM_PRETTY_FUNCTION,
+      "LocateExecutableObjectFile (file = %s, arch = %s, uuid = %p)",
+      exec_fspec ? exec_fspec->GetFilename().AsCString("<NULL>") : "<NULL>",
+      arch ? arch->GetArchitectureName() : "<NULL>", (const void *)uuid);
+
+  ModuleSpecList module_specs;
+  ModuleSpec matched_module_spec;
+  if (exec_fspec &&
+      ObjectFile::GetModuleSpecifications(*exec_fspec, 0, 0, module_specs) &&
+      module_specs.FindMatchingModuleSpec(module_spec, matched_module_spec)) {
+    result.GetFileSpec() = exec_fspec;
+  } else {
+    LocateMacOSXFilesUsingDebugSymbols(module_spec, result);
+  }
+  return result;
 }
 
-FileSpec
-Symbols::LocateExecutableSymbolFile (const ModuleSpec &module_spec)
-{
-    FileSpec symbol_file_spec = module_spec.GetSymbolFileSpec();
-    if (symbol_file_spec.IsAbsolute() && symbol_file_spec.Exists())
-        return symbol_file_spec;
-
-    const char *symbol_filename = symbol_file_spec.GetFilename().AsCString();
-    if (symbol_filename && symbol_filename[0])
-    {
-        FileSpecList debug_file_search_paths (Target::GetDefaultDebugFileSearchPaths());
-
-        // Add module directory.
-        const ConstString &file_dir = module_spec.GetFileSpec().GetDirectory();
-        debug_file_search_paths.AppendIfUnique (FileSpec(file_dir.AsCString("."), true));
+FileSpec Symbols::LocateExecutableSymbolFile(const ModuleSpec &module_spec) {
+  FileSpec symbol_file_spec = module_spec.GetSymbolFileSpec();
+  if (symbol_file_spec.IsAbsolute() && symbol_file_spec.Exists())
+    return symbol_file_spec;
+
+  const char *symbol_filename = symbol_file_spec.GetFilename().AsCString();
+  if (symbol_filename && symbol_filename[0]) {
+    FileSpecList debug_file_search_paths(
+        Target::GetDefaultDebugFileSearchPaths());
+
+    // Add module directory.
+    const ConstString &file_dir = module_spec.GetFileSpec().GetDirectory();
+    debug_file_search_paths.AppendIfUnique(
+        FileSpec(file_dir.AsCString("."), true));
 
-        // Add current working directory.
-        debug_file_search_paths.AppendIfUnique (FileSpec(".", true));
+    // Add current working directory.
+    debug_file_search_paths.AppendIfUnique(FileSpec(".", true));
 
 #ifndef LLVM_ON_WIN32
-        // Add /usr/lib/debug directory.
-        debug_file_search_paths.AppendIfUnique (FileSpec("/usr/lib/debug", true));
+    // Add /usr/lib/debug directory.
+    debug_file_search_paths.AppendIfUnique(FileSpec("/usr/lib/debug", true));
 #endif // LLVM_ON_WIN32
 
-        std::string uuid_str;
-        const UUID &module_uuid = module_spec.GetUUID();
-        if (module_uuid.IsValid())
-        {
-            // Some debug files are stored in the .build-id directory like this:
-            //   /usr/lib/debug/.build-id/ff/e7fe727889ad82bb153de2ad065b2189693315.debug
-            uuid_str = module_uuid.GetAsString("");
-            uuid_str.insert (2, 1, '/');
-            uuid_str = uuid_str + ".debug";
-        }
+    std::string uuid_str;
+    const UUID &module_uuid = module_spec.GetUUID();
+    if (module_uuid.IsValid()) {
+      // Some debug files are stored in the .build-id directory like this:
+      //   /usr/lib/debug/.build-id/ff/e7fe727889ad82bb153de2ad065b2189693315.debug
+      uuid_str = module_uuid.GetAsString("");
+      uuid_str.insert(2, 1, '/');
+      uuid_str = uuid_str + ".debug";
+    }
 
-        size_t num_directories = debug_file_search_paths.GetSize();
-        for (size_t idx = 0; idx < num_directories; ++idx)
-        {
-            FileSpec dirspec = debug_file_search_paths.GetFileSpecAtIndex (idx);
-            dirspec.ResolvePath();
-            if (!dirspec.Exists() || !dirspec.IsDirectory())
-                continue;
-
-            std::vector<std::string> files;
-            std::string dirname = dirspec.GetPath();
-
-            files.push_back (dirname + "/" + symbol_filename);
-            files.push_back (dirname + "/.debug/" + symbol_filename);
-            files.push_back (dirname + "/.build-id/" + uuid_str);
-
-            // Some debug files may stored in the module directory like this:
-            //   /usr/lib/debug/usr/lib/library.so.debug
-            if (!file_dir.IsEmpty())
-                files.push_back (dirname + file_dir.AsCString() + "/" + symbol_filename);
-
-            const uint32_t num_files = files.size();
-            for (size_t idx_file = 0; idx_file < num_files; ++idx_file)
-            {
-                const std::string &filename = files[idx_file];
-                FileSpec file_spec (filename.c_str(), true);
-
-                if (llvm::sys::fs::equivalent (file_spec.GetPath(), module_spec.GetFileSpec().GetPath()))
-                    continue;
-
-                if (file_spec.Exists())
-                {
-                    lldb_private::ModuleSpecList specs;
-                    const size_t num_specs = ObjectFile::GetModuleSpecifications (file_spec, 0, 0, specs);
-                    assert (num_specs <= 1 && "Symbol Vendor supports only a single architecture");
-                    if (num_specs == 1)
-                    {
-                        ModuleSpec mspec;
-                        if (specs.GetModuleSpecAtIndex (0, mspec))
-                        {
-                            if (mspec.GetUUID() == module_uuid)
-                                return file_spec;
-                        }
-                    }
-                }
+    size_t num_directories = debug_file_search_paths.GetSize();
+    for (size_t idx = 0; idx < num_directories; ++idx) {
+      FileSpec dirspec = debug_file_search_paths.GetFileSpecAtIndex(idx);
+      dirspec.ResolvePath();
+      if (!dirspec.Exists() || !dirspec.IsDirectory())
+        continue;
+
+      std::vector<std::string> files;
+      std::string dirname = dirspec.GetPath();
+
+      files.push_back(dirname + "/" + symbol_filename);
+      files.push_back(dirname + "/.debug/" + symbol_filename);
+      files.push_back(dirname + "/.build-id/" + uuid_str);
+
+      // Some debug files may stored in the module directory like this:
+      //   /usr/lib/debug/usr/lib/library.so.debug
+      if (!file_dir.IsEmpty())
+        files.push_back(dirname + file_dir.AsCString() + "/" + symbol_filename);
+
+      const uint32_t num_files = files.size();
+      for (size_t idx_file = 0; idx_file < num_files; ++idx_file) {
+        const std::string &filename = files[idx_file];
+        FileSpec file_spec(filename.c_str(), true);
+
+        if (llvm::sys::fs::equivalent(file_spec.GetPath(),
+                                      module_spec.GetFileSpec().GetPath()))
+          continue;
+
+        if (file_spec.Exists()) {
+          lldb_private::ModuleSpecList specs;
+          const size_t num_specs =
+              ObjectFile::GetModuleSpecifications(file_spec, 0, 0, specs);
+          assert(num_specs <= 1 &&
+                 "Symbol Vendor supports only a single architecture");
+          if (num_specs == 1) {
+            ModuleSpec mspec;
+            if (specs.GetModuleSpecAtIndex(0, mspec)) {
+              if (mspec.GetUUID() == module_uuid)
+                return file_spec;
             }
+          }
         }
+      }
     }
+  }
 
-    return LocateExecutableSymbolFileDsym(module_spec);
+  return LocateExecutableSymbolFileDsym(module_spec);
 }
 
-#if !defined (__APPLE__)
+#if !defined(__APPLE__)
 
-FileSpec
-Symbols::FindSymbolFileInBundle (const FileSpec& symfile_bundle,
-                                 const lldb_private::UUID *uuid,
-                                 const ArchSpec *arch)
-{
-    // FIXME
-    return FileSpec();
+FileSpec Symbols::FindSymbolFileInBundle(const FileSpec &symfile_bundle,
+                                         const lldb_private::UUID *uuid,
+                                         const ArchSpec *arch) {
+  // FIXME
+  return FileSpec();
 }
 
-bool
-Symbols::DownloadObjectAndSymbolFile (ModuleSpec &module_spec, bool force_lookup)
-{
-    // Fill in the module_spec.GetFileSpec() for the object file and/or the
-    // module_spec.GetSymbolFileSpec() for the debug symbols file.
-    return false;
+bool Symbols::DownloadObjectAndSymbolFile(ModuleSpec &module_spec,
+                                          bool force_lookup) {
+  // Fill in the module_spec.GetFileSpec() for the object file and/or the
+  // module_spec.GetSymbolFileSpec() for the debug symbols file.
+  return false;
 }
 
 #endif

Modified: lldb/trunk/source/Host/common/TCPSocket.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/TCPSocket.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/TCPSocket.cpp (original)
+++ lldb/trunk/source/Host/common/TCPSocket.cpp Tue Sep  6 15:57:50 2016
@@ -24,262 +24,233 @@ using namespace lldb_private;
 namespace {
 
 const int kDomain = AF_INET;
-const int kType   = SOCK_STREAM;
-
+const int kType = SOCK_STREAM;
 }
 
 TCPSocket::TCPSocket(NativeSocket socket, bool should_close)
-    : Socket(socket, ProtocolTcp, should_close)
-{
-
-}
+    : Socket(socket, ProtocolTcp, should_close) {}
 
 TCPSocket::TCPSocket(bool child_processes_inherit, Error &error)
-    : TCPSocket(CreateSocket(kDomain, kType, IPPROTO_TCP, child_processes_inherit, error), true)
-{
-}
-
+    : TCPSocket(CreateSocket(kDomain, kType, IPPROTO_TCP,
+                             child_processes_inherit, error),
+                true) {}
 
 // Return the port number that is being used by the socket.
-uint16_t
-TCPSocket::GetLocalPortNumber() const
-{
-    if (m_socket != kInvalidSocketValue)
-    {
-        SocketAddress sock_addr;
-        socklen_t sock_addr_len = sock_addr.GetMaxLength ();
-        if (::getsockname (m_socket, sock_addr, &sock_addr_len) == 0)
-            return sock_addr.GetPort ();
-    }
-    return 0;
-}
+uint16_t TCPSocket::GetLocalPortNumber() const {
+  if (m_socket != kInvalidSocketValue) {
+    SocketAddress sock_addr;
+    socklen_t sock_addr_len = sock_addr.GetMaxLength();
+    if (::getsockname(m_socket, sock_addr, &sock_addr_len) == 0)
+      return sock_addr.GetPort();
+  }
+  return 0;
+}
+
+std::string TCPSocket::GetLocalIPAddress() const {
+  // We bound to port zero, so we need to figure out which port we actually
+  // bound to
+  if (m_socket != kInvalidSocketValue) {
+    SocketAddress sock_addr;
+    socklen_t sock_addr_len = sock_addr.GetMaxLength();
+    if (::getsockname(m_socket, sock_addr, &sock_addr_len) == 0)
+      return sock_addr.GetIPAddress();
+  }
+  return "";
+}
+
+uint16_t TCPSocket::GetRemotePortNumber() const {
+  if (m_socket != kInvalidSocketValue) {
+    SocketAddress sock_addr;
+    socklen_t sock_addr_len = sock_addr.GetMaxLength();
+    if (::getpeername(m_socket, sock_addr, &sock_addr_len) == 0)
+      return sock_addr.GetPort();
+  }
+  return 0;
+}
+
+std::string TCPSocket::GetRemoteIPAddress() const {
+  // We bound to port zero, so we need to figure out which port we actually
+  // bound to
+  if (m_socket != kInvalidSocketValue) {
+    SocketAddress sock_addr;
+    socklen_t sock_addr_len = sock_addr.GetMaxLength();
+    if (::getpeername(m_socket, sock_addr, &sock_addr_len) == 0)
+      return sock_addr.GetIPAddress();
+  }
+  return "";
+}
+
+Error TCPSocket::Connect(llvm::StringRef name) {
+  if (m_socket == kInvalidSocketValue)
+    return Error("Invalid socket");
+
+  Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_COMMUNICATION));
+  if (log)
+    log->Printf("TCPSocket::%s (host/port = %s)", __FUNCTION__, name.data());
+
+  Error error;
+  std::string host_str;
+  std::string port_str;
+  int32_t port = INT32_MIN;
+  if (!DecodeHostAndPort(name, host_str, port_str, port, &error))
+    return error;
 
-std::string
-TCPSocket::GetLocalIPAddress() const
-{
-    // We bound to port zero, so we need to figure out which port we actually bound to
-    if (m_socket != kInvalidSocketValue)
-    {
-        SocketAddress sock_addr;
-        socklen_t sock_addr_len = sock_addr.GetMaxLength ();
-        if (::getsockname (m_socket, sock_addr, &sock_addr_len) == 0)
-            return sock_addr.GetIPAddress ();
-    }
-    return "";
-}
+  struct sockaddr_in sa;
+  ::memset(&sa, 0, sizeof(sa));
+  sa.sin_family = kDomain;
+  sa.sin_port = htons(port);
+
+  int inet_pton_result = ::inet_pton(kDomain, host_str.c_str(), &sa.sin_addr);
+
+  if (inet_pton_result <= 0) {
+    struct hostent *host_entry = gethostbyname(host_str.c_str());
+    if (host_entry)
+      host_str = ::inet_ntoa(*(struct in_addr *)*host_entry->h_addr_list);
+    inet_pton_result = ::inet_pton(kDomain, host_str.c_str(), &sa.sin_addr);
+    if (inet_pton_result <= 0) {
+      if (inet_pton_result == -1)
+        SetLastError(error);
+      else
+        error.SetErrorStringWithFormat("invalid host string: '%s'",
+                                       host_str.c_str());
+
+      return error;
+    }
+  }
+
+  if (-1 ==
+      ::connect(GetNativeSocket(), (const struct sockaddr *)&sa, sizeof(sa))) {
+    SetLastError(error);
+    return error;
+  }
 
-uint16_t
-TCPSocket::GetRemotePortNumber() const
-{
-    if (m_socket != kInvalidSocketValue)
-    {
-        SocketAddress sock_addr;
-        socklen_t sock_addr_len = sock_addr.GetMaxLength ();
-        if (::getpeername (m_socket, sock_addr, &sock_addr_len) == 0)
-            return sock_addr.GetPort ();
-    }
-    return 0;
+  // Keep our TCP packets coming without any delays.
+  SetOptionNoDelay();
+  error.Clear();
+  return error;
 }
 
-std::string
-TCPSocket::GetRemoteIPAddress () const
-{
-    // We bound to port zero, so we need to figure out which port we actually bound to
-    if (m_socket != kInvalidSocketValue)
-    {
-        SocketAddress sock_addr;
-        socklen_t sock_addr_len = sock_addr.GetMaxLength ();
-        if (::getpeername (m_socket, sock_addr, &sock_addr_len) == 0)
-            return sock_addr.GetIPAddress ();
-    }
-    return "";
-}
+Error TCPSocket::Listen(llvm::StringRef name, int backlog) {
+  Error error;
 
-Error
-TCPSocket::Connect(llvm::StringRef name)
-{
-    if (m_socket == kInvalidSocketValue)
-        return Error("Invalid socket");
-
-    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION));
-    if (log)
-        log->Printf ("TCPSocket::%s (host/port = %s)", __FUNCTION__, name.data());
-
-    Error error;
-    std::string host_str;
-    std::string port_str;
-    int32_t port = INT32_MIN;
-    if (!DecodeHostAndPort (name, host_str, port_str, port, &error))
-        return error;
-
-    struct sockaddr_in sa;
-    ::memset (&sa, 0, sizeof (sa));
-    sa.sin_family = kDomain;
-    sa.sin_port = htons (port);
-
-    int inet_pton_result = ::inet_pton (kDomain, host_str.c_str(), &sa.sin_addr);
-
-    if (inet_pton_result <= 0)
-    {
-        struct hostent *host_entry = gethostbyname (host_str.c_str());
-        if (host_entry)
-            host_str = ::inet_ntoa (*(struct in_addr *)*host_entry->h_addr_list);
-        inet_pton_result = ::inet_pton (kDomain, host_str.c_str(), &sa.sin_addr);
-        if (inet_pton_result <= 0)
-        {
-            if (inet_pton_result == -1)
-                SetLastError(error);
-            else
-                error.SetErrorStringWithFormat("invalid host string: '%s'", host_str.c_str());
+  // enable local address reuse
+  SetOptionReuseAddress();
 
-            return error;
-        }
-    }
+  Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION));
+  if (log)
+    log->Printf("TCPSocket::%s (%s)", __FUNCTION__, name.data());
 
-    if (-1 == ::connect (GetNativeSocket(), (const struct sockaddr *)&sa, sizeof(sa)))
-    {
-        SetLastError (error);
-        return error;
-    }
-
-    // Keep our TCP packets coming without any delays.
-    SetOptionNoDelay();
-    error.Clear();
+  std::string host_str;
+  std::string port_str;
+  int32_t port = INT32_MIN;
+  if (!DecodeHostAndPort(name, host_str, port_str, port, &error))
     return error;
-}
 
-Error
-TCPSocket::Listen(llvm::StringRef name, int backlog)
-{
-    Error error;
-
-    // enable local address reuse
-    SetOptionReuseAddress();
-
-    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
-    if (log)
-        log->Printf ("TCPSocket::%s (%s)", __FUNCTION__, name.data());
-
-    std::string host_str;
-    std::string port_str;
-    int32_t port = INT32_MIN;
-    if (!DecodeHostAndPort (name, host_str, port_str, port, &error))
-        return error;
-
-    SocketAddress bind_addr;
-
-    // Only bind to the loopback address if we are expecting a connection from
-    // localhost to avoid any firewall issues.
-    const bool bind_addr_success = (host_str == "127.0.0.1") ?
-                                    bind_addr.SetToLocalhost (kDomain, port) :
-                                    bind_addr.SetToAnyAddress (kDomain, port);
-
-    if (!bind_addr_success)
-    {
-        error.SetErrorString("Failed to bind port");
-        return error;
-    }
+  SocketAddress bind_addr;
 
-    int err = ::bind (GetNativeSocket(), bind_addr, bind_addr.GetLength());
-    if (err != -1)
-        err = ::listen (GetNativeSocket(), backlog);
-
-    if (err == -1)
-        SetLastError (error);
+  // Only bind to the loopback address if we are expecting a connection from
+  // localhost to avoid any firewall issues.
+  const bool bind_addr_success = (host_str == "127.0.0.1")
+                                     ? bind_addr.SetToLocalhost(kDomain, port)
+                                     : bind_addr.SetToAnyAddress(kDomain, port);
 
+  if (!bind_addr_success) {
+    error.SetErrorString("Failed to bind port");
     return error;
-}
+  }
 
-Error
-TCPSocket::Accept(llvm::StringRef name, bool child_processes_inherit, Socket *&conn_socket)
-{
-    Error error;
-    std::string host_str;
-    std::string port_str;
-    int32_t port;
-    if (!DecodeHostAndPort(name, host_str, port_str, port, &error))
-        return error;
-
-    const sa_family_t family = kDomain;
-    const int socktype = kType;
-    const int protocol = IPPROTO_TCP;
-    SocketAddress listen_addr;
-    if (host_str.empty())
-        listen_addr.SetToLocalhost(family, port);
-    else if (host_str.compare("*") == 0)
-        listen_addr.SetToAnyAddress(family, port);
-    else
-    {
-        if (!listen_addr.getaddrinfo(host_str.c_str(), port_str.c_str(), family, socktype, protocol))
-        {
-            error.SetErrorStringWithFormat("unable to resolve hostname '%s'", host_str.c_str());
-            return error;
-        }
-    }
+  int err = ::bind(GetNativeSocket(), bind_addr, bind_addr.GetLength());
+  if (err != -1)
+    err = ::listen(GetNativeSocket(), backlog);
 
-    bool accept_connection = false;
-    std::unique_ptr<TCPSocket> accepted_socket;
+  if (err == -1)
+    SetLastError(error);
 
-    // Loop until we are happy with our connection
-    while (!accept_connection)
-    {
-        struct sockaddr_in accept_addr;
-        ::memset (&accept_addr, 0, sizeof accept_addr);
-#if !(defined (__linux__) || defined(_WIN32))
-        accept_addr.sin_len = sizeof accept_addr;
+  return error;
+}
+
+Error TCPSocket::Accept(llvm::StringRef name, bool child_processes_inherit,
+                        Socket *&conn_socket) {
+  Error error;
+  std::string host_str;
+  std::string port_str;
+  int32_t port;
+  if (!DecodeHostAndPort(name, host_str, port_str, port, &error))
+    return error;
+
+  const sa_family_t family = kDomain;
+  const int socktype = kType;
+  const int protocol = IPPROTO_TCP;
+  SocketAddress listen_addr;
+  if (host_str.empty())
+    listen_addr.SetToLocalhost(family, port);
+  else if (host_str.compare("*") == 0)
+    listen_addr.SetToAnyAddress(family, port);
+  else {
+    if (!listen_addr.getaddrinfo(host_str.c_str(), port_str.c_str(), family,
+                                 socktype, protocol)) {
+      error.SetErrorStringWithFormat("unable to resolve hostname '%s'",
+                                     host_str.c_str());
+      return error;
+    }
+  }
+
+  bool accept_connection = false;
+  std::unique_ptr<TCPSocket> accepted_socket;
+
+  // Loop until we are happy with our connection
+  while (!accept_connection) {
+    struct sockaddr_in accept_addr;
+    ::memset(&accept_addr, 0, sizeof accept_addr);
+#if !(defined(__linux__) || defined(_WIN32))
+    accept_addr.sin_len = sizeof accept_addr;
 #endif
-        socklen_t accept_addr_len = sizeof accept_addr;
+    socklen_t accept_addr_len = sizeof accept_addr;
 
-        int sock = AcceptSocket (GetNativeSocket(),
-                                 (struct sockaddr *)&accept_addr,
-                                 &accept_addr_len,
-                                 child_processes_inherit,
-                                 error);
+    int sock = AcceptSocket(GetNativeSocket(), (struct sockaddr *)&accept_addr,
+                            &accept_addr_len, child_processes_inherit, error);
 
-        if (error.Fail())
-            break;
+    if (error.Fail())
+      break;
 
-        bool is_same_addr = true;
+    bool is_same_addr = true;
 #if !(defined(__linux__) || (defined(_WIN32)))
-        is_same_addr = (accept_addr_len == listen_addr.sockaddr_in().sin_len);
+    is_same_addr = (accept_addr_len == listen_addr.sockaddr_in().sin_len);
 #endif
-        if (is_same_addr)
-            is_same_addr = (accept_addr.sin_addr.s_addr == listen_addr.sockaddr_in().sin_addr.s_addr);
-
-        if (is_same_addr || (listen_addr.sockaddr_in().sin_addr.s_addr == INADDR_ANY))
-        {
-            accept_connection = true;
-            accepted_socket.reset(new TCPSocket(sock, true));
-        }
-        else
-        {
-            const uint8_t *accept_ip = (const uint8_t *)&accept_addr.sin_addr.s_addr;
-            const uint8_t *listen_ip = (const uint8_t *)&listen_addr.sockaddr_in().sin_addr.s_addr;
-            ::fprintf (stderr, "error: rejecting incoming connection from %u.%u.%u.%u (expecting %u.%u.%u.%u)\n",
-                        accept_ip[0], accept_ip[1], accept_ip[2], accept_ip[3],
-                        listen_ip[0], listen_ip[1], listen_ip[2], listen_ip[3]);
-            accepted_socket.reset();
-        }
+    if (is_same_addr)
+      is_same_addr = (accept_addr.sin_addr.s_addr ==
+                      listen_addr.sockaddr_in().sin_addr.s_addr);
+
+    if (is_same_addr ||
+        (listen_addr.sockaddr_in().sin_addr.s_addr == INADDR_ANY)) {
+      accept_connection = true;
+      accepted_socket.reset(new TCPSocket(sock, true));
+    } else {
+      const uint8_t *accept_ip = (const uint8_t *)&accept_addr.sin_addr.s_addr;
+      const uint8_t *listen_ip =
+          (const uint8_t *)&listen_addr.sockaddr_in().sin_addr.s_addr;
+      ::fprintf(stderr, "error: rejecting incoming connection from %u.%u.%u.%u "
+                        "(expecting %u.%u.%u.%u)\n",
+                accept_ip[0], accept_ip[1], accept_ip[2], accept_ip[3],
+                listen_ip[0], listen_ip[1], listen_ip[2], listen_ip[3]);
+      accepted_socket.reset();
     }
+  }
 
-    if (!accepted_socket)
-        return error;
-
-    // Keep our TCP packets coming without any delays.
-    accepted_socket->SetOptionNoDelay();
-    error.Clear();
-    conn_socket = accepted_socket.release();
+  if (!accepted_socket)
     return error;
+
+  // Keep our TCP packets coming without any delays.
+  accepted_socket->SetOptionNoDelay();
+  error.Clear();
+  conn_socket = accepted_socket.release();
+  return error;
 }
 
-int
-TCPSocket::SetOptionNoDelay()
-{
-    return SetOption (IPPROTO_TCP, TCP_NODELAY, 1);
+int TCPSocket::SetOptionNoDelay() {
+  return SetOption(IPPROTO_TCP, TCP_NODELAY, 1);
 }
 
-int
-TCPSocket::SetOptionReuseAddress()
-{
-    return SetOption(SOL_SOCKET, SO_REUSEADDR, 1);
+int TCPSocket::SetOptionReuseAddress() {
+  return SetOption(SOL_SOCKET, SO_REUSEADDR, 1);
 }

Modified: lldb/trunk/source/Host/common/Terminal.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Terminal.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/Terminal.cpp (original)
+++ lldb/trunk/source/Host/common/Terminal.cpp Tue Sep  6 15:57:50 2016
@@ -19,120 +19,91 @@
 #include <termios.h>
 #endif
 
-
 using namespace lldb_private;
 
-bool
-Terminal::IsATerminal () const
-{
-
-    return m_fd >= 0 && ::isatty (m_fd);
-}
-    
-
-bool
-Terminal::SetEcho (bool enabled)
-{
-    if (FileDescriptorIsValid())
-    {
+bool Terminal::IsATerminal() const { return m_fd >= 0 && ::isatty(m_fd); }
+
+bool Terminal::SetEcho(bool enabled) {
+  if (FileDescriptorIsValid()) {
 #ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
-        if (IsATerminal ())
-        {
-            struct termios fd_termios;
-            if (::tcgetattr(m_fd, &fd_termios) == 0)
-            {    
-                bool set_corectly = false;
-                if (enabled)
-                {
-                    if (fd_termios.c_lflag & ECHO)
-                        set_corectly = true;
-                    else
-                        fd_termios.c_lflag |= ECHO;
-                }
-                else
-                {
-                    if (fd_termios.c_lflag & ECHO)
-                        fd_termios.c_lflag &= ~ECHO;
-                    else
-                        set_corectly = true;
-                }
-                
-                if (set_corectly)
-                    return true;
-                return ::tcsetattr (m_fd, TCSANOW, &fd_termios) == 0;
-            }
+    if (IsATerminal()) {
+      struct termios fd_termios;
+      if (::tcgetattr(m_fd, &fd_termios) == 0) {
+        bool set_corectly = false;
+        if (enabled) {
+          if (fd_termios.c_lflag & ECHO)
+            set_corectly = true;
+          else
+            fd_termios.c_lflag |= ECHO;
+        } else {
+          if (fd_termios.c_lflag & ECHO)
+            fd_termios.c_lflag &= ~ECHO;
+          else
+            set_corectly = true;
         }
-#endif // #ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
+
+        if (set_corectly)
+          return true;
+        return ::tcsetattr(m_fd, TCSANOW, &fd_termios) == 0;
+      }
     }
-    return false;
+#endif // #ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
+  }
+  return false;
 }
 
-bool
-Terminal::SetCanonical (bool enabled)
-{
-    if (FileDescriptorIsValid())
-    {
+bool Terminal::SetCanonical(bool enabled) {
+  if (FileDescriptorIsValid()) {
 #ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
-        if (IsATerminal ())
-        {
-            struct termios fd_termios;
-            if (::tcgetattr(m_fd, &fd_termios) == 0)
-            {    
-                bool set_corectly = false;
-                if (enabled)
-                {
-                    if (fd_termios.c_lflag & ICANON)
-                        set_corectly = true;
-                    else
-                        fd_termios.c_lflag |= ICANON;
-                }
-                else
-                {
-                    if (fd_termios.c_lflag & ICANON)
-                        fd_termios.c_lflag &= ~ICANON;
-                    else
-                        set_corectly = true;
-                }
-                
-                if (set_corectly)
-                    return true;
-                return ::tcsetattr (m_fd, TCSANOW, &fd_termios) == 0;
-            }
+    if (IsATerminal()) {
+      struct termios fd_termios;
+      if (::tcgetattr(m_fd, &fd_termios) == 0) {
+        bool set_corectly = false;
+        if (enabled) {
+          if (fd_termios.c_lflag & ICANON)
+            set_corectly = true;
+          else
+            fd_termios.c_lflag |= ICANON;
+        } else {
+          if (fd_termios.c_lflag & ICANON)
+            fd_termios.c_lflag &= ~ICANON;
+          else
+            set_corectly = true;
         }
-#endif // #ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
+
+        if (set_corectly)
+          return true;
+        return ::tcsetattr(m_fd, TCSANOW, &fd_termios) == 0;
+      }
     }
-    return false;
+#endif // #ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
+  }
+  return false;
 }
 
 //----------------------------------------------------------------------
 // Default constructor
 //----------------------------------------------------------------------
-TerminalState::TerminalState() :
-    m_tty(),
-    m_tflags(-1),
+TerminalState::TerminalState()
+    : m_tty(), m_tflags(-1),
 #ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
-    m_termios_ap(),
+      m_termios_ap(),
 #endif
-    m_process_group(-1)
-{
+      m_process_group(-1) {
 }
 
 //----------------------------------------------------------------------
 // Destructor
 //----------------------------------------------------------------------
-TerminalState::~TerminalState()
-{
-}
+TerminalState::~TerminalState() {}
 
-void
-TerminalState::Clear ()
-{
-    m_tty.Clear();
-    m_tflags = -1;
+void TerminalState::Clear() {
+  m_tty.Clear();
+  m_tflags = -1;
 #ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
-    m_termios_ap.reset();
+  m_termios_ap.reset();
 #endif
-    m_process_group = -1;
+  m_process_group = -1;
 }
 
 //----------------------------------------------------------------------
@@ -140,142 +111,114 @@ TerminalState::Clear ()
 // and if "save_process_group" is true, attempt to save the process
 // group info for the TTY.
 //----------------------------------------------------------------------
-bool
-TerminalState::Save (int fd, bool save_process_group)
-{
-    m_tty.SetFileDescriptor(fd);
-    if (m_tty.IsATerminal())
-    {
+bool TerminalState::Save(int fd, bool save_process_group) {
+  m_tty.SetFileDescriptor(fd);
+  if (m_tty.IsATerminal()) {
 #ifndef LLDB_DISABLE_POSIX
-        m_tflags = ::fcntl (fd, F_GETFL, 0);
+    m_tflags = ::fcntl(fd, F_GETFL, 0);
 #endif
 #ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
-        if (m_termios_ap.get() == NULL)
-            m_termios_ap.reset (new struct termios);
-        int err = ::tcgetattr (fd, m_termios_ap.get());
-        if (err != 0)
-            m_termios_ap.reset();
+    if (m_termios_ap.get() == NULL)
+      m_termios_ap.reset(new struct termios);
+    int err = ::tcgetattr(fd, m_termios_ap.get());
+    if (err != 0)
+      m_termios_ap.reset();
 #endif // #ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
 #ifndef LLDB_DISABLE_POSIX
-        if (save_process_group)
-            m_process_group = ::tcgetpgrp (0);
-        else
-            m_process_group = -1;
-#endif
-    }
+    if (save_process_group)
+      m_process_group = ::tcgetpgrp(0);
     else
-    {
-        m_tty.Clear();
-        m_tflags = -1;
+      m_process_group = -1;
+#endif
+  } else {
+    m_tty.Clear();
+    m_tflags = -1;
 #ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
-        m_termios_ap.reset();
+    m_termios_ap.reset();
 #endif
-        m_process_group = -1;
-    }
-    return IsValid();
+    m_process_group = -1;
+  }
+  return IsValid();
 }
 
 //----------------------------------------------------------------------
 // Restore the state of the TTY using the cached values from a
 // previous call to Save().
 //----------------------------------------------------------------------
-bool
-TerminalState::Restore () const
-{
+bool TerminalState::Restore() const {
 #ifndef LLDB_DISABLE_POSIX
-    if (IsValid())
-    {
-        const int fd = m_tty.GetFileDescriptor();
-        if (TFlagsIsValid())
-            fcntl (fd, F_SETFL, m_tflags);
+  if (IsValid()) {
+    const int fd = m_tty.GetFileDescriptor();
+    if (TFlagsIsValid())
+      fcntl(fd, F_SETFL, m_tflags);
 
 #ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
-        if (TTYStateIsValid())
-            tcsetattr (fd, TCSANOW, m_termios_ap.get());
+    if (TTYStateIsValid())
+      tcsetattr(fd, TCSANOW, m_termios_ap.get());
 #endif // #ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
 
-        if (ProcessGroupIsValid())
-        {
-            // Save the original signal handler.
-            void (*saved_sigttou_callback) (int) = NULL;
-            saved_sigttou_callback = (void (*)(int)) signal (SIGTTOU, SIG_IGN);
-            // Set the process group
-            tcsetpgrp (fd, m_process_group);
-            // Restore the original signal handler.
-            signal (SIGTTOU, saved_sigttou_callback);
-        }
-        return true;
+    if (ProcessGroupIsValid()) {
+      // Save the original signal handler.
+      void (*saved_sigttou_callback)(int) = NULL;
+      saved_sigttou_callback = (void (*)(int))signal(SIGTTOU, SIG_IGN);
+      // Set the process group
+      tcsetpgrp(fd, m_process_group);
+      // Restore the original signal handler.
+      signal(SIGTTOU, saved_sigttou_callback);
     }
+    return true;
+  }
 #endif
-    return false;
+  return false;
 }
 
-
-
-
 //----------------------------------------------------------------------
 // Returns true if this object has valid saved TTY state settings
 // that can be used to restore a previous state.
 //----------------------------------------------------------------------
-bool
-TerminalState::IsValid() const
-{
-    return m_tty.FileDescriptorIsValid () && (TFlagsIsValid() || TTYStateIsValid());
+bool TerminalState::IsValid() const {
+  return m_tty.FileDescriptorIsValid() &&
+         (TFlagsIsValid() || TTYStateIsValid());
 }
 
 //----------------------------------------------------------------------
 // Returns true if m_tflags is valid
 //----------------------------------------------------------------------
-bool
-TerminalState::TFlagsIsValid() const
-{
-    return m_tflags != -1;
-}
+bool TerminalState::TFlagsIsValid() const { return m_tflags != -1; }
 
 //----------------------------------------------------------------------
 // Returns true if m_ttystate is valid
 //----------------------------------------------------------------------
-bool
-TerminalState::TTYStateIsValid() const
-{
+bool TerminalState::TTYStateIsValid() const {
 #ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
-    return m_termios_ap.get() != 0;
+  return m_termios_ap.get() != 0;
 #else
-    return false;
+  return false;
 #endif
 }
 
 //----------------------------------------------------------------------
 // Returns true if m_process_group is valid
 //----------------------------------------------------------------------
-bool
-TerminalState::ProcessGroupIsValid() const
-{
-    return static_cast<int32_t>(m_process_group) != -1;
+bool TerminalState::ProcessGroupIsValid() const {
+  return static_cast<int32_t>(m_process_group) != -1;
 }
 
 //------------------------------------------------------------------
 // Constructor
 //------------------------------------------------------------------
-TerminalStateSwitcher::TerminalStateSwitcher () :
-    m_currentState(UINT32_MAX)
-{
-}
+TerminalStateSwitcher::TerminalStateSwitcher() : m_currentState(UINT32_MAX) {}
 
 //------------------------------------------------------------------
 // Destructor
 //------------------------------------------------------------------
-TerminalStateSwitcher::~TerminalStateSwitcher ()
-{
-}
+TerminalStateSwitcher::~TerminalStateSwitcher() {}
 
 //------------------------------------------------------------------
 // Returns the number of states that this switcher contains
 //------------------------------------------------------------------
-uint32_t
-TerminalStateSwitcher::GetNumberOfStates() const
-{
-    return llvm::array_lengthof(m_ttystates);
+uint32_t TerminalStateSwitcher::GetNumberOfStates() const {
+  return llvm::array_lengthof(m_ttystates);
 }
 
 //------------------------------------------------------------------
@@ -283,28 +226,26 @@ TerminalStateSwitcher::GetNumberOfStates
 //
 // Returns true if the restore was successful, false otherwise.
 //------------------------------------------------------------------
-bool
-TerminalStateSwitcher::Restore (uint32_t idx) const
-{
-    const uint32_t num_states = GetNumberOfStates();
-    if (idx >= num_states)
-        return false;
-
-    // See if we already are in this state?
-    if (m_currentState < num_states && (idx == m_currentState) && m_ttystates[idx].IsValid())
-        return true;
-
-    // Set the state to match the index passed in and only update the
-    // current state if there are no errors.
-    if (m_ttystates[idx].Restore())
-    {
-        m_currentState = idx;
-        return true;
-    }
-
-    // We failed to set the state. The tty state was invalid or not
-    // initialized.
-    return false;
+bool TerminalStateSwitcher::Restore(uint32_t idx) const {
+  const uint32_t num_states = GetNumberOfStates();
+  if (idx >= num_states)
+    return false;
+
+  // See if we already are in this state?
+  if (m_currentState < num_states && (idx == m_currentState) &&
+      m_ttystates[idx].IsValid())
+    return true;
+
+  // Set the state to match the index passed in and only update the
+  // current state if there are no errors.
+  if (m_ttystates[idx].Restore()) {
+    m_currentState = idx;
+    return true;
+  }
+
+  // We failed to set the state. The tty state was invalid or not
+  // initialized.
+  return false;
 }
 
 //------------------------------------------------------------------
@@ -313,13 +254,10 @@ TerminalStateSwitcher::Restore (uint32_t
 //
 // Returns true if the restore was successful, false otherwise.
 //------------------------------------------------------------------
-bool
-TerminalStateSwitcher::Save (uint32_t idx, int fd, bool save_process_group)
-{
-    const uint32_t num_states = GetNumberOfStates();
-    if (idx < num_states)
-        return m_ttystates[idx].Save(fd, save_process_group);
-    return false;
+bool TerminalStateSwitcher::Save(uint32_t idx, int fd,
+                                 bool save_process_group) {
+  const uint32_t num_states = GetNumberOfStates();
+  if (idx < num_states)
+    return m_ttystates[idx].Save(fd, save_process_group);
+  return false;
 }
-
-

Modified: lldb/trunk/source/Host/common/ThisThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/ThisThread.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/ThisThread.cpp (original)
+++ lldb/trunk/source/Host/common/ThisThread.cpp Tue Sep  6 15:57:50 2016
@@ -7,9 +7,9 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/Host/ThisThread.h"
 #include "lldb/Core/Error.h"
 #include "lldb/Host/HostInfo.h"
-#include "lldb/Host/ThisThread.h"
 
 #include "llvm/ADT/STLExtras.h"
 
@@ -18,35 +18,33 @@
 using namespace lldb;
 using namespace lldb_private;
 
-void
-ThisThread::SetName(llvm::StringRef name, int max_length)
-{
-    std::string truncated_name(name.data());
-
-    // Thread names are coming in like '<lldb.comm.debugger.edit>' and
-    // '<lldb.comm.debugger.editline>'.  So just chopping the end of the string
-    // off leads to a lot of similar named threads.  Go through the thread name
-    // and search for the last dot and use that.
-
-    if (max_length > 0 && truncated_name.length() > static_cast<size_t>(max_length))
-    {
-        // First see if we can get lucky by removing any initial or final braces.
-        std::string::size_type begin = truncated_name.find_first_not_of("(<");
-        std::string::size_type end = truncated_name.find_last_not_of(")>.");
-        if (end - begin > static_cast<size_t>(max_length))
-        {
-            // We're still too long.  Since this is a dotted component, use everything after the last
-            // dot, up to a maximum of |length| characters.
-            std::string::size_type last_dot = truncated_name.rfind('.');
-            if (last_dot != std::string::npos)
-                begin = last_dot + 1;
+void ThisThread::SetName(llvm::StringRef name, int max_length) {
+  std::string truncated_name(name.data());
 
-            end = std::min(end, begin + max_length);
-        }
+  // Thread names are coming in like '<lldb.comm.debugger.edit>' and
+  // '<lldb.comm.debugger.editline>'.  So just chopping the end of the string
+  // off leads to a lot of similar named threads.  Go through the thread name
+  // and search for the last dot and use that.
+
+  if (max_length > 0 &&
+      truncated_name.length() > static_cast<size_t>(max_length)) {
+    // First see if we can get lucky by removing any initial or final braces.
+    std::string::size_type begin = truncated_name.find_first_not_of("(<");
+    std::string::size_type end = truncated_name.find_last_not_of(")>.");
+    if (end - begin > static_cast<size_t>(max_length)) {
+      // We're still too long.  Since this is a dotted component, use everything
+      // after the last
+      // dot, up to a maximum of |length| characters.
+      std::string::size_type last_dot = truncated_name.rfind('.');
+      if (last_dot != std::string::npos)
+        begin = last_dot + 1;
 
-        std::string::size_type count = end - begin + 1;
-        truncated_name = truncated_name.substr(begin, count);
+      end = std::min(end, begin + max_length);
     }
 
-    SetName(truncated_name.c_str());
+    std::string::size_type count = end - begin + 1;
+    truncated_name = truncated_name.substr(begin, count);
+  }
+
+  SetName(truncated_name.c_str());
 }

Modified: lldb/trunk/source/Host/common/ThreadLauncher.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/ThreadLauncher.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/ThreadLauncher.cpp (original)
+++ lldb/trunk/source/Host/common/ThreadLauncher.cpp Tue Sep  6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- ThreadLauncher.cpp ---------------------------------------*- C++ -*-===//
+//===-- ThreadLauncher.cpp ---------------------------------------*- C++
+//-*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -8,11 +9,11 @@
 //===----------------------------------------------------------------------===//
 
 // lldb Includes
+#include "lldb/Host/ThreadLauncher.h"
 #include "lldb/Core/Log.h"
 #include "lldb/Host/HostNativeThread.h"
 #include "lldb/Host/HostThread.h"
 #include "lldb/Host/ThisThread.h"
-#include "lldb/Host/ThreadLauncher.h"
 
 #if defined(_WIN32)
 #include "lldb/Host/windows/windows.h"
@@ -21,64 +22,65 @@
 using namespace lldb;
 using namespace lldb_private;
 
-HostThread
-ThreadLauncher::LaunchThread(llvm::StringRef name, lldb::thread_func_t thread_function, lldb::thread_arg_t thread_arg, Error *error_ptr, size_t min_stack_byte_size)
-{
-    Error error;
-    if (error_ptr)
-        error_ptr->Clear();
-
-    // Host::ThreadCreateTrampoline will delete this pointer for us.
-    HostThreadCreateInfo *info_ptr = new HostThreadCreateInfo(name.data(), thread_function, thread_arg);
-    lldb::thread_t thread;
+HostThread ThreadLauncher::LaunchThread(llvm::StringRef name,
+                                        lldb::thread_func_t thread_function,
+                                        lldb::thread_arg_t thread_arg,
+                                        Error *error_ptr,
+                                        size_t min_stack_byte_size) {
+  Error error;
+  if (error_ptr)
+    error_ptr->Clear();
+
+  // Host::ThreadCreateTrampoline will delete this pointer for us.
+  HostThreadCreateInfo *info_ptr =
+      new HostThreadCreateInfo(name.data(), thread_function, thread_arg);
+  lldb::thread_t thread;
 #ifdef _WIN32
-    thread =
-        (lldb::thread_t)::_beginthreadex(0, (unsigned)min_stack_byte_size, HostNativeThread::ThreadCreateTrampoline, info_ptr, 0, NULL);
-    if (thread == (lldb::thread_t)(-1L))
-        error.SetError(::GetLastError(), eErrorTypeWin32);
+  thread = (lldb::thread_t)::_beginthreadex(
+      0, (unsigned)min_stack_byte_size,
+      HostNativeThread::ThreadCreateTrampoline, info_ptr, 0, NULL);
+  if (thread == (lldb::thread_t)(-1L))
+    error.SetError(::GetLastError(), eErrorTypeWin32);
 #else
 
-
-    // ASAN instrumentation adds a lot of bookkeeping overhead on stack frames.
+// ASAN instrumentation adds a lot of bookkeeping overhead on stack frames.
 #if __has_feature(address_sanitizer)
-    const size_t eight_megabytes = 8 * 1024 * 1024;
-    if (min_stack_byte_size < eight_megabytes)
-    {
-        min_stack_byte_size += eight_megabytes;
-    }
+  const size_t eight_megabytes = 8 * 1024 * 1024;
+  if (min_stack_byte_size < eight_megabytes) {
+    min_stack_byte_size += eight_megabytes;
+  }
 #endif
 
-    pthread_attr_t *thread_attr_ptr = NULL;
-    pthread_attr_t thread_attr;
-    bool destroy_attr = false;
-    if (min_stack_byte_size > 0)
-    {
-        if (::pthread_attr_init (&thread_attr) == 0)
-        {
-            destroy_attr = true;
-            size_t default_min_stack_byte_size = 0;
-            if (::pthread_attr_getstacksize(&thread_attr, &default_min_stack_byte_size) == 0)
-            {
-                if (default_min_stack_byte_size < min_stack_byte_size)
-                {
-                    if (::pthread_attr_setstacksize (&thread_attr, min_stack_byte_size) == 0)
-                        thread_attr_ptr = &thread_attr;
-                }
-            }
-
+  pthread_attr_t *thread_attr_ptr = NULL;
+  pthread_attr_t thread_attr;
+  bool destroy_attr = false;
+  if (min_stack_byte_size > 0) {
+    if (::pthread_attr_init(&thread_attr) == 0) {
+      destroy_attr = true;
+      size_t default_min_stack_byte_size = 0;
+      if (::pthread_attr_getstacksize(&thread_attr,
+                                      &default_min_stack_byte_size) == 0) {
+        if (default_min_stack_byte_size < min_stack_byte_size) {
+          if (::pthread_attr_setstacksize(&thread_attr, min_stack_byte_size) ==
+              0)
+            thread_attr_ptr = &thread_attr;
         }
+      }
     }
-    int err = ::pthread_create(&thread, thread_attr_ptr, HostNativeThread::ThreadCreateTrampoline, info_ptr);
+  }
+  int err =
+      ::pthread_create(&thread, thread_attr_ptr,
+                       HostNativeThread::ThreadCreateTrampoline, info_ptr);
 
-    if (destroy_attr)
-        ::pthread_attr_destroy(&thread_attr);
+  if (destroy_attr)
+    ::pthread_attr_destroy(&thread_attr);
 
-    error.SetError(err, eErrorTypePOSIX);
+  error.SetError(err, eErrorTypePOSIX);
 #endif
-    if (error_ptr)
-        *error_ptr = error;
-    if (!error.Success())
-        thread = LLDB_INVALID_HOST_THREAD;
+  if (error_ptr)
+    *error_ptr = error;
+  if (!error.Success())
+    thread = LLDB_INVALID_HOST_THREAD;
 
-    return HostThread(thread);
+  return HostThread(thread);
 }

Modified: lldb/trunk/source/Host/common/TimeValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/TimeValue.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/TimeValue.cpp (original)
+++ lldb/trunk/source/Host/common/TimeValue.cpp Tue Sep  6 15:57:50 2016
@@ -11,9 +11,9 @@
 #include "lldb/Host/Config.h"
 
 // C Includes
+#include <cstring>
 #include <stddef.h>
 #include <time.h>
-#include <cstring>
 
 #ifdef _MSC_VER
 #include "lldb/Host/windows/windows.h"
@@ -26,108 +26,68 @@
 // Project includes
 #include "lldb/Core/Stream.h"
 
-
 using namespace lldb_private;
 
 //----------------------------------------------------------------------
 // TimeValue constructor
 //----------------------------------------------------------------------
-TimeValue::TimeValue() :
-    m_nano_seconds (0)
-{
-}
+TimeValue::TimeValue() : m_nano_seconds(0) {}
 
 //----------------------------------------------------------------------
 // TimeValue copy constructor
 //----------------------------------------------------------------------
-TimeValue::TimeValue(const TimeValue& rhs) :
-    m_nano_seconds (rhs.m_nano_seconds)
-{
-}
+TimeValue::TimeValue(const TimeValue &rhs)
+    : m_nano_seconds(rhs.m_nano_seconds) {}
 
-TimeValue::TimeValue(const struct timespec& ts) :
-    m_nano_seconds ((uint64_t) ts.tv_sec * NanoSecPerSec + ts.tv_nsec)
-{
-}
+TimeValue::TimeValue(const struct timespec &ts)
+    : m_nano_seconds((uint64_t)ts.tv_sec * NanoSecPerSec + ts.tv_nsec) {}
 
-TimeValue::TimeValue(uint32_t seconds, uint64_t nanos) :
-    m_nano_seconds((uint64_t) seconds * NanoSecPerSec + nanos)
-{
-}
+TimeValue::TimeValue(uint32_t seconds, uint64_t nanos)
+    : m_nano_seconds((uint64_t)seconds * NanoSecPerSec + nanos) {}
 
 //----------------------------------------------------------------------
 // Destructor
 //----------------------------------------------------------------------
-TimeValue::~TimeValue()
-{
-}
+TimeValue::~TimeValue() {}
 
-
-uint64_t
-TimeValue::GetAsNanoSecondsSinceJan1_1970() const
-{
-    return m_nano_seconds;
+uint64_t TimeValue::GetAsNanoSecondsSinceJan1_1970() const {
+  return m_nano_seconds;
 }
 
-uint64_t
-TimeValue::GetAsMicroSecondsSinceJan1_1970() const
-{
-    return m_nano_seconds / NanoSecPerMicroSec;
+uint64_t TimeValue::GetAsMicroSecondsSinceJan1_1970() const {
+  return m_nano_seconds / NanoSecPerMicroSec;
 }
 
-uint64_t
-TimeValue::GetAsSecondsSinceJan1_1970() const
-{
-    return m_nano_seconds / NanoSecPerSec;
+uint64_t TimeValue::GetAsSecondsSinceJan1_1970() const {
+  return m_nano_seconds / NanoSecPerSec;
 }
 
-
-
-struct timespec
-TimeValue::GetAsTimeSpec () const
-{
-    struct timespec ts;
-    ts.tv_sec = m_nano_seconds / NanoSecPerSec;
-    ts.tv_nsec = m_nano_seconds % NanoSecPerSec;
-    return ts;
+struct timespec TimeValue::GetAsTimeSpec() const {
+  struct timespec ts;
+  ts.tv_sec = m_nano_seconds / NanoSecPerSec;
+  ts.tv_nsec = m_nano_seconds % NanoSecPerSec;
+  return ts;
 }
 
-void
-TimeValue::Clear ()
-{
-    m_nano_seconds = 0;
-}
+void TimeValue::Clear() { m_nano_seconds = 0; }
 
-bool
-TimeValue::IsValid () const
-{
-    return m_nano_seconds != 0;
-}
+bool TimeValue::IsValid() const { return m_nano_seconds != 0; }
 
-void
-TimeValue::OffsetWithSeconds (uint64_t sec)
-{
-    m_nano_seconds += sec * NanoSecPerSec;
+void TimeValue::OffsetWithSeconds(uint64_t sec) {
+  m_nano_seconds += sec * NanoSecPerSec;
 }
 
-void
-TimeValue::OffsetWithMicroSeconds (uint64_t usec)
-{
-    m_nano_seconds += usec * NanoSecPerMicroSec;
+void TimeValue::OffsetWithMicroSeconds(uint64_t usec) {
+  m_nano_seconds += usec * NanoSecPerMicroSec;
 }
 
-void
-TimeValue::OffsetWithNanoSeconds (uint64_t nsec)
-{
-    m_nano_seconds += nsec;
-}
+void TimeValue::OffsetWithNanoSeconds(uint64_t nsec) { m_nano_seconds += nsec; }
 
-TimeValue
-TimeValue::Now()
-{
+TimeValue TimeValue::Now() {
   using namespace std::chrono;
   auto now = system_clock::now();
-  auto ns_since_epoch = duration_cast<std::chrono::nanoseconds>(now.time_since_epoch()).count();
+  auto ns_since_epoch =
+      duration_cast<std::chrono::nanoseconds>(now.time_since_epoch()).count();
 
   return TimeValue(0, ns_since_epoch);
 }
@@ -135,78 +95,63 @@ TimeValue::Now()
 //----------------------------------------------------------------------
 // TimeValue assignment operator
 //----------------------------------------------------------------------
-const TimeValue&
-TimeValue::operator=(const TimeValue& rhs)
-{
-    m_nano_seconds = rhs.m_nano_seconds;
-    return *this;
+const TimeValue &TimeValue::operator=(const TimeValue &rhs) {
+  m_nano_seconds = rhs.m_nano_seconds;
+  return *this;
 }
 
-void
-TimeValue::Dump (Stream *s, uint32_t width) const
-{
-    if (s == NULL)
-        return;
+void TimeValue::Dump(Stream *s, uint32_t width) const {
+  if (s == NULL)
+    return;
 
 #ifndef LLDB_DISABLE_POSIX
-    char time_buf[32];
-    time_t time = GetAsSecondsSinceJan1_1970();
-    char *time_cstr = ::ctime_r(&time, time_buf);
-    if (time_cstr)
-    {
-        char *newline = ::strpbrk(time_cstr, "\n\r");
-        if (newline)
-            *newline = '\0';
-        if (width > 0)
-            s->Printf("%-*s", width, time_cstr);
-        else
-            s->PutCString(time_cstr);
-    }
-    else if (width > 0)
-        s->Printf("%-*s", width, "");
+  char time_buf[32];
+  time_t time = GetAsSecondsSinceJan1_1970();
+  char *time_cstr = ::ctime_r(&time, time_buf);
+  if (time_cstr) {
+    char *newline = ::strpbrk(time_cstr, "\n\r");
+    if (newline)
+      *newline = '\0';
+    if (width > 0)
+      s->Printf("%-*s", width, time_cstr);
+    else
+      s->PutCString(time_cstr);
+  } else if (width > 0)
+    s->Printf("%-*s", width, "");
 #endif
 }
 
-bool
-lldb_private::operator == (const TimeValue &lhs, const TimeValue &rhs)
-{
-    return lhs.GetAsNanoSecondsSinceJan1_1970() == rhs.GetAsNanoSecondsSinceJan1_1970();
+bool lldb_private::operator==(const TimeValue &lhs, const TimeValue &rhs) {
+  return lhs.GetAsNanoSecondsSinceJan1_1970() ==
+         rhs.GetAsNanoSecondsSinceJan1_1970();
 }
 
-bool
-lldb_private::operator != (const TimeValue &lhs, const TimeValue &rhs)
-{
-    return lhs.GetAsNanoSecondsSinceJan1_1970() != rhs.GetAsNanoSecondsSinceJan1_1970();
+bool lldb_private::operator!=(const TimeValue &lhs, const TimeValue &rhs) {
+  return lhs.GetAsNanoSecondsSinceJan1_1970() !=
+         rhs.GetAsNanoSecondsSinceJan1_1970();
 }
 
-bool
-lldb_private::operator <  (const TimeValue &lhs, const TimeValue &rhs)
-{
-    return lhs.GetAsNanoSecondsSinceJan1_1970() < rhs.GetAsNanoSecondsSinceJan1_1970();
+bool lldb_private::operator<(const TimeValue &lhs, const TimeValue &rhs) {
+  return lhs.GetAsNanoSecondsSinceJan1_1970() <
+         rhs.GetAsNanoSecondsSinceJan1_1970();
 }
 
-bool
-lldb_private::operator <= (const TimeValue &lhs, const TimeValue &rhs)
-{
-    return lhs.GetAsNanoSecondsSinceJan1_1970() <= rhs.GetAsNanoSecondsSinceJan1_1970();
+bool lldb_private::operator<=(const TimeValue &lhs, const TimeValue &rhs) {
+  return lhs.GetAsNanoSecondsSinceJan1_1970() <=
+         rhs.GetAsNanoSecondsSinceJan1_1970();
 }
 
-bool
-lldb_private::operator >  (const TimeValue &lhs, const TimeValue &rhs)
-{
-    return lhs.GetAsNanoSecondsSinceJan1_1970() > rhs.GetAsNanoSecondsSinceJan1_1970();
+bool lldb_private::operator>(const TimeValue &lhs, const TimeValue &rhs) {
+  return lhs.GetAsNanoSecondsSinceJan1_1970() >
+         rhs.GetAsNanoSecondsSinceJan1_1970();
 }
 
-bool
-lldb_private::operator >= (const TimeValue &lhs, const TimeValue &rhs)
-{
-    return lhs.GetAsNanoSecondsSinceJan1_1970() >= rhs.GetAsNanoSecondsSinceJan1_1970();
+bool lldb_private::operator>=(const TimeValue &lhs, const TimeValue &rhs) {
+  return lhs.GetAsNanoSecondsSinceJan1_1970() >=
+         rhs.GetAsNanoSecondsSinceJan1_1970();
 }
 
-uint64_t
-lldb_private::operator - (const TimeValue &lhs, const TimeValue &rhs)
-{
-    return lhs.GetAsNanoSecondsSinceJan1_1970() - rhs.GetAsNanoSecondsSinceJan1_1970();
+uint64_t lldb_private::operator-(const TimeValue &lhs, const TimeValue &rhs) {
+  return lhs.GetAsNanoSecondsSinceJan1_1970() -
+         rhs.GetAsNanoSecondsSinceJan1_1970();
 }
-
-

Modified: lldb/trunk/source/Host/common/UDPSocket.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/UDPSocket.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/UDPSocket.cpp (original)
+++ lldb/trunk/source/Host/common/UDPSocket.cpp Tue Sep  6 15:57:50 2016
@@ -25,134 +25,109 @@ using namespace lldb_private;
 namespace {
 
 const int kDomain = AF_INET;
-const int kType   = SOCK_DGRAM;
+const int kType = SOCK_DGRAM;
 
 static const char *g_not_supported_error = "Not supported";
+}
+
+UDPSocket::UDPSocket(NativeSocket socket) : Socket(socket, ProtocolUdp, true) {}
 
+UDPSocket::UDPSocket(bool child_processes_inherit, Error &error)
+    : UDPSocket(
+          CreateSocket(kDomain, kType, 0, child_processes_inherit, error)) {}
+
+size_t UDPSocket::Send(const void *buf, const size_t num_bytes) {
+  return ::sendto(m_socket, static_cast<const char *>(buf), num_bytes, 0,
+                  m_send_sockaddr, m_send_sockaddr.GetLength());
 }
 
-UDPSocket::UDPSocket(NativeSocket socket)
-    : Socket(socket, ProtocolUdp, true)
-{
+Error UDPSocket::Connect(llvm::StringRef name) {
+  return Error("%s", g_not_supported_error);
 }
 
-UDPSocket::UDPSocket(bool child_processes_inherit, Error &error)
-    : UDPSocket(CreateSocket(kDomain, kType, 0, child_processes_inherit, error))
-{
+Error UDPSocket::Listen(llvm::StringRef name, int backlog) {
+  return Error("%s", g_not_supported_error);
 }
 
-size_t
-UDPSocket::Send(const void *buf, const size_t num_bytes)
-{
-    return ::sendto (m_socket,
-                     static_cast<const char*>(buf),
-                     num_bytes,
-                     0,
-                     m_send_sockaddr,
-                     m_send_sockaddr.GetLength());
-}
-
-Error
-UDPSocket::Connect(llvm::StringRef name)
-{
-    return Error("%s", g_not_supported_error);
-}
-
-Error
-UDPSocket::Listen(llvm::StringRef name, int backlog)
-{
-    return Error("%s", g_not_supported_error);
-}
-
-Error
-UDPSocket::Accept(llvm::StringRef name, bool child_processes_inherit, Socket *&socket)
-{
-    return Error("%s", g_not_supported_error);
-}
-
-Error
-UDPSocket::Connect(llvm::StringRef name, bool child_processes_inherit, Socket *&send_socket, Socket *&recv_socket)
-{
-    std::unique_ptr<UDPSocket> final_send_socket;
-    std::unique_ptr<UDPSocket> final_recv_socket;
-
-    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
-    if (log)
-        log->Printf ("UDPSocket::%s (host/port = %s)", __FUNCTION__, name.data());
-
-    Error error;
-    std::string host_str;
-    std::string port_str;
-    int32_t port = INT32_MIN;
-    if (!DecodeHostAndPort (name, host_str, port_str, port, &error))
-        return error;
-
-    // Setup the receiving end of the UDP connection on this localhost
-    // on port zero. After we bind to port zero we can read the port.
-    final_recv_socket.reset(new UDPSocket(child_processes_inherit, error));
-    if (error.Success())
-    {
-        // Socket was created, now lets bind to the requested port
-        SocketAddress addr;
-        addr.SetToAnyAddress (AF_INET, 0);
-
-        if (::bind (final_recv_socket->GetNativeSocket(), addr, addr.GetLength()) == -1)
-        {
-            // Bind failed...
-            SetLastError (error);
-        }
-    }
+Error UDPSocket::Accept(llvm::StringRef name, bool child_processes_inherit,
+                        Socket *&socket) {
+  return Error("%s", g_not_supported_error);
+}
 
-    assert(error.Fail() == !(final_recv_socket && final_recv_socket->IsValid()));
-    if (error.Fail())
-        return error;
-
-    // At this point we have setup the receive port, now we need to
-    // setup the UDP send socket
-
-    struct addrinfo hints;
-    struct addrinfo *service_info_list = nullptr;
-
-    ::memset (&hints, 0, sizeof(hints));
-    hints.ai_family = kDomain;
-    hints.ai_socktype = kType;
-    int err = ::getaddrinfo (host_str.c_str(), port_str.c_str(), &hints, &service_info_list);
-    if (err != 0)
-    {
-        error.SetErrorStringWithFormat("getaddrinfo(%s, %s, &hints, &info) returned error %i (%s)",
-                                       host_str.c_str(),
-                                       port_str.c_str(),
-                                       err,
-                                       gai_strerror(err));
-        return error;
-    }
+Error UDPSocket::Connect(llvm::StringRef name, bool child_processes_inherit,
+                         Socket *&send_socket, Socket *&recv_socket) {
+  std::unique_ptr<UDPSocket> final_send_socket;
+  std::unique_ptr<UDPSocket> final_recv_socket;
+
+  Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION));
+  if (log)
+    log->Printf("UDPSocket::%s (host/port = %s)", __FUNCTION__, name.data());
 
-    for (struct addrinfo *service_info_ptr = service_info_list;
-         service_info_ptr != nullptr;
-         service_info_ptr = service_info_ptr->ai_next)
-    {
-        auto send_fd = CreateSocket (service_info_ptr->ai_family,
-                                     service_info_ptr->ai_socktype,
-                                     service_info_ptr->ai_protocol,
-                                     child_processes_inherit,
-                                     error);
-        if (error.Success())
-        {
-            final_send_socket.reset(new UDPSocket(send_fd));
-            final_send_socket->m_send_sockaddr = service_info_ptr;
-            break;
-        }
-        else
-            continue;
+  Error error;
+  std::string host_str;
+  std::string port_str;
+  int32_t port = INT32_MIN;
+  if (!DecodeHostAndPort(name, host_str, port_str, port, &error))
+    return error;
+
+  // Setup the receiving end of the UDP connection on this localhost
+  // on port zero. After we bind to port zero we can read the port.
+  final_recv_socket.reset(new UDPSocket(child_processes_inherit, error));
+  if (error.Success()) {
+    // Socket was created, now lets bind to the requested port
+    SocketAddress addr;
+    addr.SetToAnyAddress(AF_INET, 0);
+
+    if (::bind(final_recv_socket->GetNativeSocket(), addr, addr.GetLength()) ==
+        -1) {
+      // Bind failed...
+      SetLastError(error);
     }
+  }
 
-    :: freeaddrinfo (service_info_list);
+  assert(error.Fail() == !(final_recv_socket && final_recv_socket->IsValid()));
+  if (error.Fail())
+    return error;
 
-    if (!final_send_socket)
-        return error;
+  // At this point we have setup the receive port, now we need to
+  // setup the UDP send socket
 
-    send_socket = final_send_socket.release();
-    recv_socket = final_recv_socket.release();
-    error.Clear();
+  struct addrinfo hints;
+  struct addrinfo *service_info_list = nullptr;
+
+  ::memset(&hints, 0, sizeof(hints));
+  hints.ai_family = kDomain;
+  hints.ai_socktype = kType;
+  int err = ::getaddrinfo(host_str.c_str(), port_str.c_str(), &hints,
+                          &service_info_list);
+  if (err != 0) {
+    error.SetErrorStringWithFormat(
+        "getaddrinfo(%s, %s, &hints, &info) returned error %i (%s)",
+        host_str.c_str(), port_str.c_str(), err, gai_strerror(err));
     return error;
+  }
+
+  for (struct addrinfo *service_info_ptr = service_info_list;
+       service_info_ptr != nullptr;
+       service_info_ptr = service_info_ptr->ai_next) {
+    auto send_fd = CreateSocket(
+        service_info_ptr->ai_family, service_info_ptr->ai_socktype,
+        service_info_ptr->ai_protocol, child_processes_inherit, error);
+    if (error.Success()) {
+      final_send_socket.reset(new UDPSocket(send_fd));
+      final_send_socket->m_send_sockaddr = service_info_ptr;
+      break;
+    } else
+      continue;
+  }
+
+  ::freeaddrinfo(service_info_list);
+
+  if (!final_send_socket)
+    return error;
+
+  send_socket = final_send_socket.release();
+  recv_socket = final_recv_socket.release();
+  error.Clear();
+  return error;
 }

Modified: lldb/trunk/source/Host/common/XML.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/XML.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/XML.cpp (original)
+++ lldb/trunk/source/Host/common/XML.cpp Tue Sep  6 15:57:50 2016
@@ -7,685 +7,527 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include <stdlib.h>     /* atof */
+#include <stdlib.h> /* atof */
 
-#include "lldb/Host/XML.h"
 #include "lldb/Host/StringConvert.h"
+#include "lldb/Host/XML.h"
 
 using namespace lldb;
 using namespace lldb_private;
 
+#pragma mark-- XMLDocument
 
-#pragma mark -- XMLDocument
+XMLDocument::XMLDocument() : m_document(nullptr) {}
 
-XMLDocument::XMLDocument () :
-    m_document (nullptr)
-{
-}
-
-XMLDocument::~XMLDocument ()
-{
-    Clear();
-}
-
-void
-XMLDocument::Clear()
-{
-#if defined( LIBXML2_DEFINED )
-    if (m_document)
-    {
-        xmlDocPtr doc = m_document;
-        m_document = nullptr;
-        xmlFreeDoc(doc);
-    }
+XMLDocument::~XMLDocument() { Clear(); }
+
+void XMLDocument::Clear() {
+#if defined(LIBXML2_DEFINED)
+  if (m_document) {
+    xmlDocPtr doc = m_document;
+    m_document = nullptr;
+    xmlFreeDoc(doc);
+  }
 #endif
 }
 
-bool
-XMLDocument::IsValid() const
-{
-    return m_document != nullptr;
-}
-
-void
-XMLDocument::ErrorCallback (void *ctx, const char *format, ...)
-{
-    XMLDocument *document = (XMLDocument *)ctx;
-    va_list args;
-    va_start (args, format);
-    document->m_errors.PrintfVarArg(format, args);
-    document->m_errors.EOL();
-    va_end (args);
-}
-
-bool
-XMLDocument::ParseFile (const char *path)
-{
-#if defined( LIBXML2_DEFINED )
-    Clear();
-    xmlSetGenericErrorFunc( (void *)this, XMLDocument::ErrorCallback );
-    m_document = xmlParseFile(path);
-    xmlSetGenericErrorFunc(nullptr, nullptr);
-#endif
-    return IsValid();
-}
-
-bool
-XMLDocument::ParseMemory (const char *xml, size_t xml_length, const char *url)
-{
-#if defined( LIBXML2_DEFINED )
-    Clear();
-    xmlSetGenericErrorFunc( (void *)this, XMLDocument::ErrorCallback );
-    m_document = xmlReadMemory(xml, (int)xml_length, url, nullptr, 0);
-    xmlSetGenericErrorFunc(nullptr, nullptr);
-#endif
-    return IsValid();
-    
-}
-
-XMLNode
-XMLDocument::GetRootElement(const char *required_name)
-{
-#if defined( LIBXML2_DEFINED )
-    if (IsValid())
-    {
-        XMLNode root_node(xmlDocGetRootElement(m_document));
-        if (required_name)
-        {
-            llvm::StringRef actual_name = root_node.GetName();
-            if (actual_name == required_name)
-                return root_node;
-        }
-        else
-        {
-            return root_node;
-        }
+bool XMLDocument::IsValid() const { return m_document != nullptr; }
+
+void XMLDocument::ErrorCallback(void *ctx, const char *format, ...) {
+  XMLDocument *document = (XMLDocument *)ctx;
+  va_list args;
+  va_start(args, format);
+  document->m_errors.PrintfVarArg(format, args);
+  document->m_errors.EOL();
+  va_end(args);
+}
+
+bool XMLDocument::ParseFile(const char *path) {
+#if defined(LIBXML2_DEFINED)
+  Clear();
+  xmlSetGenericErrorFunc((void *)this, XMLDocument::ErrorCallback);
+  m_document = xmlParseFile(path);
+  xmlSetGenericErrorFunc(nullptr, nullptr);
+#endif
+  return IsValid();
+}
+
+bool XMLDocument::ParseMemory(const char *xml, size_t xml_length,
+                              const char *url) {
+#if defined(LIBXML2_DEFINED)
+  Clear();
+  xmlSetGenericErrorFunc((void *)this, XMLDocument::ErrorCallback);
+  m_document = xmlReadMemory(xml, (int)xml_length, url, nullptr, 0);
+  xmlSetGenericErrorFunc(nullptr, nullptr);
+#endif
+  return IsValid();
+}
+
+XMLNode XMLDocument::GetRootElement(const char *required_name) {
+#if defined(LIBXML2_DEFINED)
+  if (IsValid()) {
+    XMLNode root_node(xmlDocGetRootElement(m_document));
+    if (required_name) {
+      llvm::StringRef actual_name = root_node.GetName();
+      if (actual_name == required_name)
+        return root_node;
+    } else {
+      return root_node;
     }
+  }
 #endif
-    return XMLNode();
+  return XMLNode();
 }
 
-const std::string &
-XMLDocument::GetErrors() const
-{
-    return m_errors.GetString();
+const std::string &XMLDocument::GetErrors() const {
+  return m_errors.GetString();
 }
 
-bool
-XMLDocument::XMLEnabled ()
-{
-#if defined( LIBXML2_DEFINED )
-    return true;
+bool XMLDocument::XMLEnabled() {
+#if defined(LIBXML2_DEFINED)
+  return true;
 #else
-    return false;
+  return false;
 #endif
 }
 
-#pragma mark -- XMLNode
+#pragma mark-- XMLNode
 
-XMLNode::XMLNode() :
-    m_node(nullptr)
-{
-}
+XMLNode::XMLNode() : m_node(nullptr) {}
 
-XMLNode::XMLNode(XMLNodeImpl node) :
-    m_node(node)
-{
-}
+XMLNode::XMLNode(XMLNodeImpl node) : m_node(node) {}
 
-XMLNode::~XMLNode()
-{
-    
-}
+XMLNode::~XMLNode() {}
 
-void
-XMLNode::Clear()
-{
-    m_node = nullptr;
-}
+void XMLNode::Clear() { m_node = nullptr; }
 
-XMLNode
-XMLNode::GetParent() const
-{
-#if defined( LIBXML2_DEFINED )
-    if (IsValid())
-        return XMLNode(m_node->parent);
-    else
-        return XMLNode();
-#else
+XMLNode XMLNode::GetParent() const {
+#if defined(LIBXML2_DEFINED)
+  if (IsValid())
+    return XMLNode(m_node->parent);
+  else
     return XMLNode();
+#else
+  return XMLNode();
 #endif
-
 }
 
-XMLNode
-XMLNode::GetSibling() const
-{
-#if defined( LIBXML2_DEFINED )
-    if (IsValid())
-        return XMLNode(m_node->next);
-    else
-        return XMLNode();
-#else
+XMLNode XMLNode::GetSibling() const {
+#if defined(LIBXML2_DEFINED)
+  if (IsValid())
+    return XMLNode(m_node->next);
+  else
     return XMLNode();
+#else
+  return XMLNode();
 #endif
-
 }
 
-XMLNode
-XMLNode::GetChild () const
-{
-#if defined( LIBXML2_DEFINED )
+XMLNode XMLNode::GetChild() const {
+#if defined(LIBXML2_DEFINED)
 
-    if (IsValid())
-        return XMLNode(m_node->children);
-    else
-        return XMLNode();
-#else
+  if (IsValid())
+    return XMLNode(m_node->children);
+  else
     return XMLNode();
+#else
+  return XMLNode();
 #endif
-
 }
 
-llvm::StringRef
-XMLNode::GetAttributeValue(const char *name, const char *fail_value) const
-{
-    const char *attr_value = NULL;
-#if defined( LIBXML2_DEFINED )
+llvm::StringRef XMLNode::GetAttributeValue(const char *name,
+                                           const char *fail_value) const {
+  const char *attr_value = NULL;
+#if defined(LIBXML2_DEFINED)
 
-    if (IsValid())
-        attr_value = (const char *)xmlGetProp(m_node, (const xmlChar *)name);
-    else
-        attr_value = fail_value;
-#else
+  if (IsValid())
+    attr_value = (const char *)xmlGetProp(m_node, (const xmlChar *)name);
+  else
     attr_value = fail_value;
+#else
+  attr_value = fail_value;
 #endif
-    if (attr_value)
-        return llvm::StringRef(attr_value);
-    else
-        return llvm::StringRef();
+  if (attr_value)
+    return llvm::StringRef(attr_value);
+  else
+    return llvm::StringRef();
 }
 
-
-
-
-void
-XMLNode::ForEachChildNode (NodeCallback const &callback) const
-{
-#if defined( LIBXML2_DEFINED )
-    if (IsValid())
-        GetChild().ForEachSiblingNode(callback);
+void XMLNode::ForEachChildNode(NodeCallback const &callback) const {
+#if defined(LIBXML2_DEFINED)
+  if (IsValid())
+    GetChild().ForEachSiblingNode(callback);
 #endif
 }
 
-void
-XMLNode::ForEachChildElement (NodeCallback const &callback) const
-{
-#if defined( LIBXML2_DEFINED )
-    XMLNode child = GetChild();
-    if (child)
-        child.ForEachSiblingElement(callback);
+void XMLNode::ForEachChildElement(NodeCallback const &callback) const {
+#if defined(LIBXML2_DEFINED)
+  XMLNode child = GetChild();
+  if (child)
+    child.ForEachSiblingElement(callback);
 #endif
 }
 
-void
-XMLNode::ForEachChildElementWithName (const char *name, NodeCallback const &callback) const
-{
-#if defined( LIBXML2_DEFINED )
-    XMLNode child = GetChild();
-    if (child)
-        child.ForEachSiblingElementWithName(name, callback);
+void XMLNode::ForEachChildElementWithName(const char *name,
+                                          NodeCallback const &callback) const {
+#if defined(LIBXML2_DEFINED)
+  XMLNode child = GetChild();
+  if (child)
+    child.ForEachSiblingElementWithName(name, callback);
 #endif
 }
 
-void
-XMLNode::ForEachAttribute (AttributeCallback const &callback) const
-{
-#if defined( LIBXML2_DEFINED )
+void XMLNode::ForEachAttribute(AttributeCallback const &callback) const {
+#if defined(LIBXML2_DEFINED)
 
-    if (IsValid())
-    {
-        for (xmlAttrPtr attr = m_node->properties; attr != nullptr; attr=attr->next)
-        {
-            // check if name matches
-            if (attr->name)
-            {
-                // check child is a text node
-                xmlNodePtr child = attr->children;
-                if (child->type == XML_TEXT_NODE)
-                {
-                    llvm::StringRef attr_value;
-                    if (child->content)
-                        attr_value = llvm::StringRef((const char *)child->content);
-                    if (callback(llvm::StringRef((const char *)attr->name), attr_value) == false)
-                        return;
-                }
-            }
+  if (IsValid()) {
+    for (xmlAttrPtr attr = m_node->properties; attr != nullptr;
+         attr = attr->next) {
+      // check if name matches
+      if (attr->name) {
+        // check child is a text node
+        xmlNodePtr child = attr->children;
+        if (child->type == XML_TEXT_NODE) {
+          llvm::StringRef attr_value;
+          if (child->content)
+            attr_value = llvm::StringRef((const char *)child->content);
+          if (callback(llvm::StringRef((const char *)attr->name), attr_value) ==
+              false)
+            return;
         }
+      }
     }
+  }
 #endif
 }
 
+void XMLNode::ForEachSiblingNode(NodeCallback const &callback) const {
+#if defined(LIBXML2_DEFINED)
 
-void
-XMLNode::ForEachSiblingNode (NodeCallback const &callback) const
-{
-#if defined( LIBXML2_DEFINED )
-
-    if (IsValid())
-    {
-        // iterate through all siblings
-        for (xmlNodePtr node = m_node; node; node=node->next)
-        {
-            if (callback(XMLNode(node)) == false)
-                return;
-        }
+  if (IsValid()) {
+    // iterate through all siblings
+    for (xmlNodePtr node = m_node; node; node = node->next) {
+      if (callback(XMLNode(node)) == false)
+        return;
     }
+  }
 #endif
 }
 
-void
-XMLNode::ForEachSiblingElement (NodeCallback const &callback) const
-{
-#if defined( LIBXML2_DEFINED )
-    
-    if (IsValid())
-    {
-        // iterate through all siblings
-        for (xmlNodePtr node = m_node; node; node=node->next)
-        {
-            // we are looking for element nodes only
-            if (node->type != XML_ELEMENT_NODE)
-                continue;
-            
-            if (callback(XMLNode(node)) == false)
-                return;
-        }
+void XMLNode::ForEachSiblingElement(NodeCallback const &callback) const {
+#if defined(LIBXML2_DEFINED)
+
+  if (IsValid()) {
+    // iterate through all siblings
+    for (xmlNodePtr node = m_node; node; node = node->next) {
+      // we are looking for element nodes only
+      if (node->type != XML_ELEMENT_NODE)
+        continue;
+
+      if (callback(XMLNode(node)) == false)
+        return;
     }
+  }
 #endif
 }
 
-void
-XMLNode::ForEachSiblingElementWithName (const char *name, NodeCallback const &callback) const
-{
-#if defined( LIBXML2_DEFINED )
-    
-    if (IsValid())
-    {
-        // iterate through all siblings
-        for (xmlNodePtr node = m_node; node; node=node->next)
-        {
-            // we are looking for element nodes only
-            if (node->type != XML_ELEMENT_NODE)
-                continue;
-            
-            // If name is nullptr, we take all nodes of type "t", else
-            // just the ones whose name matches
-            if (name)
-            {
-                if (strcmp((const char *)node->name, name) != 0)
-                    continue; // Name mismatch, ignore this one
-            }
-            else
-            {
-                if (node->name)
-                    continue; // nullptr name specified and this element has a name, ignore this one
-            }
-            
-            if (callback(XMLNode(node)) == false)
-                return;
-        }
+void XMLNode::ForEachSiblingElementWithName(
+    const char *name, NodeCallback const &callback) const {
+#if defined(LIBXML2_DEFINED)
+
+  if (IsValid()) {
+    // iterate through all siblings
+    for (xmlNodePtr node = m_node; node; node = node->next) {
+      // we are looking for element nodes only
+      if (node->type != XML_ELEMENT_NODE)
+        continue;
+
+      // If name is nullptr, we take all nodes of type "t", else
+      // just the ones whose name matches
+      if (name) {
+        if (strcmp((const char *)node->name, name) != 0)
+          continue; // Name mismatch, ignore this one
+      } else {
+        if (node->name)
+          continue; // nullptr name specified and this element has a name,
+                    // ignore this one
+      }
+
+      if (callback(XMLNode(node)) == false)
+        return;
     }
+  }
 #endif
 }
 
-llvm::StringRef
-XMLNode::GetName() const
-{
-#if defined( LIBXML2_DEFINED )
-    if (IsValid())
-    {
-        if (m_node->name)
-            return llvm::StringRef((const char *)m_node->name);
-    }
+llvm::StringRef XMLNode::GetName() const {
+#if defined(LIBXML2_DEFINED)
+  if (IsValid()) {
+    if (m_node->name)
+      return llvm::StringRef((const char *)m_node->name);
+  }
 #endif
-    return llvm::StringRef();
+  return llvm::StringRef();
 }
 
-bool
-XMLNode::GetElementText (std::string &text) const
-{
-    text.clear();
-#if defined( LIBXML2_DEFINED )
-    if (IsValid())
-    {
-        bool success = false;
-        if (m_node->type == XML_ELEMENT_NODE)
-        {
-            // check child is a text node
-            for (xmlNodePtr node = m_node->children;
-                 node != nullptr;
-                 node = node->next)
-            {
-                if (node->type == XML_TEXT_NODE)
-                {
-                    text.append((const char *)node->content);
-                    success = true;
-                }
-            }
+bool XMLNode::GetElementText(std::string &text) const {
+  text.clear();
+#if defined(LIBXML2_DEFINED)
+  if (IsValid()) {
+    bool success = false;
+    if (m_node->type == XML_ELEMENT_NODE) {
+      // check child is a text node
+      for (xmlNodePtr node = m_node->children; node != nullptr;
+           node = node->next) {
+        if (node->type == XML_TEXT_NODE) {
+          text.append((const char *)node->content);
+          success = true;
         }
-        return success;
+      }
     }
+    return success;
+  }
 #endif
-    return false;
+  return false;
 }
 
-
-bool
-XMLNode::GetElementTextAsUnsigned (uint64_t &value, uint64_t fail_value, int base) const
-{
-    bool success = false;
-#if defined( LIBXML2_DEFINED )
-    if (IsValid())
-    {
-        std::string text;
-        if (GetElementText(text))
-            value = StringConvert::ToUInt64(text.c_str(), fail_value, base, &success);
-    }
+bool XMLNode::GetElementTextAsUnsigned(uint64_t &value, uint64_t fail_value,
+                                       int base) const {
+  bool success = false;
+#if defined(LIBXML2_DEFINED)
+  if (IsValid()) {
+    std::string text;
+    if (GetElementText(text))
+      value = StringConvert::ToUInt64(text.c_str(), fail_value, base, &success);
+  }
 #endif
-    if (!success)
-        value = fail_value;
-    return success;
+  if (!success)
+    value = fail_value;
+  return success;
 }
 
-bool
-XMLNode::GetElementTextAsFloat (double &value, double fail_value) const
-{
-    bool success = false;
-#if defined( LIBXML2_DEFINED )
-    if (IsValid())
-    {
-        std::string text;
-        if (GetElementText(text))
-        {
-            value = atof(text.c_str());
-            success = true;
-        }
+bool XMLNode::GetElementTextAsFloat(double &value, double fail_value) const {
+  bool success = false;
+#if defined(LIBXML2_DEFINED)
+  if (IsValid()) {
+    std::string text;
+    if (GetElementText(text)) {
+      value = atof(text.c_str());
+      success = true;
     }
+  }
 #endif
-    if (!success)
-        value = fail_value;
-    return success;
+  if (!success)
+    value = fail_value;
+  return success;
 }
 
+bool XMLNode::NameIs(const char *name) const {
+#if defined(LIBXML2_DEFINED)
 
-
-bool
-XMLNode::NameIs (const char *name) const
-{
-#if defined( LIBXML2_DEFINED )
-
-    if (IsValid())
-    {
-        // In case we are looking for a nullptr name or an exact pointer match
-        if (m_node->name == (const xmlChar *)name)
-            return true;
-        if (m_node->name)
-            return strcmp((const char *)m_node->name, name) == 0;
-    }
+  if (IsValid()) {
+    // In case we are looking for a nullptr name or an exact pointer match
+    if (m_node->name == (const xmlChar *)name)
+      return true;
+    if (m_node->name)
+      return strcmp((const char *)m_node->name, name) == 0;
+  }
 #endif
-    return false;
+  return false;
 }
 
-XMLNode
-XMLNode::FindFirstChildElementWithName (const char *name) const
-{
-    XMLNode result_node;
+XMLNode XMLNode::FindFirstChildElementWithName(const char *name) const {
+  XMLNode result_node;
 
-#if defined( LIBXML2_DEFINED )
-    ForEachChildElementWithName(name, [&result_node, name](const XMLNode& node) -> bool {
+#if defined(LIBXML2_DEFINED)
+  ForEachChildElementWithName(
+      name, [&result_node, name](const XMLNode &node) -> bool {
         result_node = node;
         // Stop iterating, we found the node we wanted
         return false;
-    });
+      });
 #endif
 
-    return result_node;
+  return result_node;
 }
 
-bool
-XMLNode::IsValid() const
-{
-    return m_node != nullptr;
-}
-
-bool
-XMLNode::IsElement () const
-{
-#if defined( LIBXML2_DEFINED )
-    if (IsValid())
-        return m_node->type == XML_ELEMENT_NODE;
-#endif
-    return false;
+bool XMLNode::IsValid() const { return m_node != nullptr; }
+
+bool XMLNode::IsElement() const {
+#if defined(LIBXML2_DEFINED)
+  if (IsValid())
+    return m_node->type == XML_ELEMENT_NODE;
+#endif
+  return false;
 }
 
+XMLNode XMLNode::GetElementForPath(const NamePath &path) {
+#if defined(LIBXML2_DEFINED)
 
-XMLNode
-XMLNode::GetElementForPath (const NamePath &path)
-{
-#if defined( LIBXML2_DEFINED )
-
-    if (IsValid())
-    {
-        if (path.empty())
-            return *this;
-        else
-        {
-            XMLNode node = FindFirstChildElementWithName(path[0].c_str());
-            const size_t n = path.size();
-            for (size_t i=1; node && i<n; ++i)
-                node = node.FindFirstChildElementWithName(path[i].c_str());
-            return node;
-        }
+  if (IsValid()) {
+    if (path.empty())
+      return *this;
+    else {
+      XMLNode node = FindFirstChildElementWithName(path[0].c_str());
+      const size_t n = path.size();
+      for (size_t i = 1; node && i < n; ++i)
+        node = node.FindFirstChildElementWithName(path[i].c_str());
+      return node;
     }
+  }
 #endif
 
-    return XMLNode();
+  return XMLNode();
 }
 
+#pragma mark-- ApplePropertyList
 
-#pragma mark -- ApplePropertyList
+ApplePropertyList::ApplePropertyList() : m_xml_doc(), m_dict_node() {}
 
-ApplePropertyList::ApplePropertyList() :
-    m_xml_doc(),
-    m_dict_node()
-{
-    
-}
-
-ApplePropertyList::ApplePropertyList (const char *path) :
-    m_xml_doc(),
-    m_dict_node()
-{
-    ParseFile(path);
-}
-
-ApplePropertyList::~ApplePropertyList()
-{
-}
-
-const std::string &
-ApplePropertyList::GetErrors() const
-{
-    return m_xml_doc.GetErrors();
+ApplePropertyList::ApplePropertyList(const char *path)
+    : m_xml_doc(), m_dict_node() {
+  ParseFile(path);
 }
 
+ApplePropertyList::~ApplePropertyList() {}
 
-bool
-ApplePropertyList::ParseFile (const char *path)
-{
-    if (m_xml_doc.ParseFile(path))
-    {
-        XMLNode plist = m_xml_doc.GetRootElement("plist");
-        if (plist)
-        {
-            plist.ForEachChildElementWithName("dict", [this](const XMLNode &dict) -> bool {
-                this->m_dict_node = dict;
-                return false; // Stop iterating
-            });
-            return (bool)m_dict_node;
-        }
+const std::string &ApplePropertyList::GetErrors() const {
+  return m_xml_doc.GetErrors();
+}
+
+bool ApplePropertyList::ParseFile(const char *path) {
+  if (m_xml_doc.ParseFile(path)) {
+    XMLNode plist = m_xml_doc.GetRootElement("plist");
+    if (plist) {
+      plist.ForEachChildElementWithName("dict",
+                                        [this](const XMLNode &dict) -> bool {
+                                          this->m_dict_node = dict;
+                                          return false; // Stop iterating
+                                        });
+      return (bool)m_dict_node;
     }
-    return false;
+  }
+  return false;
+}
+
+bool ApplePropertyList::IsValid() const { return (bool)m_dict_node; }
+
+bool ApplePropertyList::GetValueAsString(const char *key,
+                                         std::string &value) const {
+  XMLNode value_node = GetValueNode(key);
+  if (value_node)
+    return ApplePropertyList::ExtractStringFromValueNode(value_node, value);
+  return false;
 }
 
-bool
-ApplePropertyList::IsValid() const
-{
-    return (bool)m_dict_node;
-}
-
-bool
-ApplePropertyList::GetValueAsString (const char *key, std::string &value) const
-{
-    XMLNode value_node = GetValueNode (key);
-    if (value_node)
-        return ApplePropertyList::ExtractStringFromValueNode(value_node, value);
-    return false;
-}
-
-XMLNode
-ApplePropertyList::GetValueNode (const char *key) const
-{
-    XMLNode value_node;
-#if defined( LIBXML2_DEFINED )
-    
-    if (IsValid())
-    {
-        m_dict_node.ForEachChildElementWithName("key", [key, &value_node](const XMLNode &key_node) -> bool {
-            std::string key_name;
-            if (key_node.GetElementText(key_name))
-            {
-                if (key_name.compare(key) == 0)
-                {
-                    value_node = key_node.GetSibling();
-                    while (value_node && !value_node.IsElement())
-                        value_node = value_node.GetSibling();
-                    return false; // Stop iterating
-                }
+XMLNode ApplePropertyList::GetValueNode(const char *key) const {
+  XMLNode value_node;
+#if defined(LIBXML2_DEFINED)
+
+  if (IsValid()) {
+    m_dict_node.ForEachChildElementWithName(
+        "key", [key, &value_node](const XMLNode &key_node) -> bool {
+          std::string key_name;
+          if (key_node.GetElementText(key_name)) {
+            if (key_name.compare(key) == 0) {
+              value_node = key_node.GetSibling();
+              while (value_node && !value_node.IsElement())
+                value_node = value_node.GetSibling();
+              return false; // Stop iterating
             }
-            return true; // Keep iterating
+          }
+          return true; // Keep iterating
         });
-    }
+  }
 #endif
-    return value_node;
+  return value_node;
 }
 
-bool
-ApplePropertyList::ExtractStringFromValueNode (const XMLNode &node, std::string &value)
-{
-    value.clear();
-#if defined( LIBXML2_DEFINED )
-    if (node.IsValid())
-    {
-        llvm::StringRef element_name = node.GetName();
-        if (element_name == "true" || element_name == "false")
-        {
-            // The text value _is_ the element name itself...
-            value = element_name.str();
-            return true;
-        }
-        else if (element_name == "dict" || element_name == "array")
-            return false; // dictionaries and arrays have no text value, so we fail
-        else
-            return node.GetElementText(value);
-    }
+bool ApplePropertyList::ExtractStringFromValueNode(const XMLNode &node,
+                                                   std::string &value) {
+  value.clear();
+#if defined(LIBXML2_DEFINED)
+  if (node.IsValid()) {
+    llvm::StringRef element_name = node.GetName();
+    if (element_name == "true" || element_name == "false") {
+      // The text value _is_ the element name itself...
+      value = element_name.str();
+      return true;
+    } else if (element_name == "dict" || element_name == "array")
+      return false; // dictionaries and arrays have no text value, so we fail
+    else
+      return node.GetElementText(value);
+  }
 #endif
-    return false;
+  return false;
 }
 
-#if defined( LIBXML2_DEFINED )
+#if defined(LIBXML2_DEFINED)
 
 namespace {
 
-    StructuredData::ObjectSP
-    CreatePlistValue (XMLNode node)
-    {
-        llvm::StringRef element_name = node.GetName();
-        if (element_name == "array")
-        {
-            std::shared_ptr<StructuredData::Array> array_sp(new StructuredData::Array());
-            node.ForEachChildElement([&array_sp](const XMLNode &node) -> bool {
-                array_sp->AddItem(CreatePlistValue(node));
-                return true; // Keep iterating through all child elements of the array
-            });
-            return array_sp;
-        }
-        else if (element_name == "dict")
-        {
-            XMLNode key_node;
-            std::shared_ptr<StructuredData::Dictionary> dict_sp(new StructuredData::Dictionary());
-            node.ForEachChildElement([&key_node, &dict_sp](const XMLNode &node) -> bool {
-                if (node.NameIs("key"))
-                {
-                    // This is a "key" element node
-                    key_node = node;
-                }
-                else
-                {
-                    // This is a value node
-                    if (key_node)
-                    {
-                        std::string key_name;
-                        key_node.GetElementText(key_name);
-                        dict_sp->AddItem(key_name, CreatePlistValue(node));
-                        key_node.Clear();
-                    }
-                }
-                return true; // Keep iterating through all child elements of the dictionary
-            });
-            return dict_sp;
-        }
-        else if (element_name == "real")
-        {
-            double value = 0.0;
-            node.GetElementTextAsFloat(value);
-            return StructuredData::ObjectSP(new StructuredData::Float(value));
-        }
-        else if (element_name == "integer")
-        {
-            uint64_t value = 0;
-            node.GetElementTextAsUnsigned(value, 0, 0);
-            return StructuredData::ObjectSP(new StructuredData::Integer(value));
-        }
-        else if ((element_name == "string") || (element_name == "data") || (element_name == "date"))
-        {
-            std::string text;
-            node.GetElementText(text);
-            return StructuredData::ObjectSP(new StructuredData::String(std::move(text)));
-        }
-        else if (element_name == "true")
-        {
-            return StructuredData::ObjectSP(new StructuredData::Boolean(true));
-        }
-        else if (element_name == "false")
-        {
-            return StructuredData::ObjectSP(new StructuredData::Boolean(false));
-        }
-        return StructuredData::ObjectSP(new StructuredData::Null());
-    }
+StructuredData::ObjectSP CreatePlistValue(XMLNode node) {
+  llvm::StringRef element_name = node.GetName();
+  if (element_name == "array") {
+    std::shared_ptr<StructuredData::Array> array_sp(
+        new StructuredData::Array());
+    node.ForEachChildElement([&array_sp](const XMLNode &node) -> bool {
+      array_sp->AddItem(CreatePlistValue(node));
+      return true; // Keep iterating through all child elements of the array
+    });
+    return array_sp;
+  } else if (element_name == "dict") {
+    XMLNode key_node;
+    std::shared_ptr<StructuredData::Dictionary> dict_sp(
+        new StructuredData::Dictionary());
+    node.ForEachChildElement(
+        [&key_node, &dict_sp](const XMLNode &node) -> bool {
+          if (node.NameIs("key")) {
+            // This is a "key" element node
+            key_node = node;
+          } else {
+            // This is a value node
+            if (key_node) {
+              std::string key_name;
+              key_node.GetElementText(key_name);
+              dict_sp->AddItem(key_name, CreatePlistValue(node));
+              key_node.Clear();
+            }
+          }
+          return true; // Keep iterating through all child elements of the
+                       // dictionary
+        });
+    return dict_sp;
+  } else if (element_name == "real") {
+    double value = 0.0;
+    node.GetElementTextAsFloat(value);
+    return StructuredData::ObjectSP(new StructuredData::Float(value));
+  } else if (element_name == "integer") {
+    uint64_t value = 0;
+    node.GetElementTextAsUnsigned(value, 0, 0);
+    return StructuredData::ObjectSP(new StructuredData::Integer(value));
+  } else if ((element_name == "string") || (element_name == "data") ||
+             (element_name == "date")) {
+    std::string text;
+    node.GetElementText(text);
+    return StructuredData::ObjectSP(
+        new StructuredData::String(std::move(text)));
+  } else if (element_name == "true") {
+    return StructuredData::ObjectSP(new StructuredData::Boolean(true));
+  } else if (element_name == "false") {
+    return StructuredData::ObjectSP(new StructuredData::Boolean(false));
+  }
+  return StructuredData::ObjectSP(new StructuredData::Null());
+}
 }
 #endif
 
-StructuredData::ObjectSP
-ApplePropertyList::GetStructuredData()
-{
-    StructuredData::ObjectSP root_sp;
-#if defined( LIBXML2_DEFINED )
-    if (IsValid())
-    {
-        return CreatePlistValue(m_dict_node);
-    }
+StructuredData::ObjectSP ApplePropertyList::GetStructuredData() {
+  StructuredData::ObjectSP root_sp;
+#if defined(LIBXML2_DEFINED)
+  if (IsValid()) {
+    return CreatePlistValue(m_dict_node);
+  }
 #endif
-    return root_sp;
+  return root_sp;
 }

Modified: lldb/trunk/source/Host/freebsd/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/freebsd/Host.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/freebsd/Host.cpp (original)
+++ lldb/trunk/source/Host/freebsd/Host.cpp Tue Sep  6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- source/Host/freebsd/Host.cpp ------------------------------*- C++ -*-===//
+//===-- source/Host/freebsd/Host.cpp ------------------------------*- C++
+//-*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -8,32 +9,32 @@
 //===----------------------------------------------------------------------===//
 
 // C Includes
-#include <stdio.h>
 #include <dlfcn.h>
 #include <execinfo.h>
+#include <stdio.h>
+#include <sys/proc.h>
+#include <sys/sysctl.h>
 #include <sys/types.h>
 #include <sys/user.h>
-#include <sys/sysctl.h>
-#include <sys/proc.h>
 
-#include <sys/ptrace.h>
-#include <sys/exec.h>
 #include <machine/elf.h>
+#include <sys/exec.h>
+#include <sys/ptrace.h>
 
 // C++ Includes
 // Other libraries and framework includes
 // Project includes
+#include "lldb/Core/DataExtractor.h"
 #include "lldb/Core/Error.h"
-#include "lldb/Host/Endian.h"
-#include "lldb/Host/Host.h"
-#include "lldb/Host/HostInfo.h"
+#include "lldb/Core/Log.h"
 #include "lldb/Core/Module.h"
-#include "lldb/Core/DataExtractor.h"
 #include "lldb/Core/StreamFile.h"
 #include "lldb/Core/StreamString.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Target/Process.h"
+#include "lldb/Host/Endian.h"
+#include "lldb/Host/Host.h"
+#include "lldb/Host/HostInfo.h"
 #include "lldb/Target/Platform.h"
+#include "lldb/Target/Process.h"
 
 #include "lldb/Core/DataBufferHeap.h"
 #include "lldb/Core/DataExtractor.h"
@@ -43,241 +44,220 @@
 #include "llvm/Support/Host.h"
 
 extern "C" {
-    extern char **environ;
+extern char **environ;
 }
 
 using namespace lldb;
 using namespace lldb_private;
 
-size_t
-Host::GetEnvironment (StringList &env)
-{
-    char *v;
-    char **var = environ;
-    for (; var != NULL && *var != NULL; ++var)
-    {
-        v = strchr(*var, (int)'-');
-        if (v == NULL)
-            continue;
-        env.AppendString(v);
-    }
-    return env.GetSize();
+size_t Host::GetEnvironment(StringList &env) {
+  char *v;
+  char **var = environ;
+  for (; var != NULL && *var != NULL; ++var) {
+    v = strchr(*var, (int)'-');
+    if (v == NULL)
+      continue;
+    env.AppendString(v);
+  }
+  return env.GetSize();
 }
 
 static bool
-GetFreeBSDProcessArgs (const ProcessInstanceInfoMatch *match_info_ptr,
-                      ProcessInstanceInfo &process_info)
-{
-    if (process_info.ProcessIDIsValid())
-    {
-        int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_ARGS, (int)process_info.GetProcessID() };
-
-        char arg_data[8192];
-        size_t arg_data_size = sizeof(arg_data);
-        if (::sysctl (mib, 4, arg_data, &arg_data_size , NULL, 0) == 0)
-        {
-            DataExtractor data (arg_data, arg_data_size, endian::InlHostByteOrder(), sizeof(void *));
-            lldb::offset_t offset = 0;
-            const char *cstr;
-
-            cstr = data.GetCStr (&offset);
-            if (cstr)
-            {
-                process_info.GetExecutableFile().SetFile(cstr, false);
-
-                if (!(match_info_ptr == NULL ||
-                    NameMatches (process_info.GetExecutableFile().GetFilename().GetCString(),
-                                 match_info_ptr->GetNameMatchType(),
-                                 match_info_ptr->GetProcessInfo().GetName())))
-                    return false;
-
-                Args &proc_args = process_info.GetArguments();
-                while (1)
-                {
-                    const uint8_t *p = data.PeekData(offset, 1);
-                    while ((p != NULL) && (*p == '\0') && offset < arg_data_size)
-                    {
-                        ++offset;
-                        p = data.PeekData(offset, 1);
-                    }
-                    if (p == NULL || offset >= arg_data_size)
-                        return true;
-
-                    cstr = data.GetCStr(&offset);
-                    if (cstr)
-                        proc_args.AppendArgument(cstr);
-                    else
-                        return true;
-                }
-            }
+GetFreeBSDProcessArgs(const ProcessInstanceInfoMatch *match_info_ptr,
+                      ProcessInstanceInfo &process_info) {
+  if (process_info.ProcessIDIsValid()) {
+    int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_ARGS,
+                  (int)process_info.GetProcessID()};
+
+    char arg_data[8192];
+    size_t arg_data_size = sizeof(arg_data);
+    if (::sysctl(mib, 4, arg_data, &arg_data_size, NULL, 0) == 0) {
+      DataExtractor data(arg_data, arg_data_size, endian::InlHostByteOrder(),
+                         sizeof(void *));
+      lldb::offset_t offset = 0;
+      const char *cstr;
+
+      cstr = data.GetCStr(&offset);
+      if (cstr) {
+        process_info.GetExecutableFile().SetFile(cstr, false);
+
+        if (!(match_info_ptr == NULL ||
+              NameMatches(
+                  process_info.GetExecutableFile().GetFilename().GetCString(),
+                  match_info_ptr->GetNameMatchType(),
+                  match_info_ptr->GetProcessInfo().GetName())))
+          return false;
+
+        Args &proc_args = process_info.GetArguments();
+        while (1) {
+          const uint8_t *p = data.PeekData(offset, 1);
+          while ((p != NULL) && (*p == '\0') && offset < arg_data_size) {
+            ++offset;
+            p = data.PeekData(offset, 1);
+          }
+          if (p == NULL || offset >= arg_data_size)
+            return true;
+
+          cstr = data.GetCStr(&offset);
+          if (cstr)
+            proc_args.AppendArgument(cstr);
+          else
+            return true;
         }
+      }
     }
-    return false;
+  }
+  return false;
 }
 
-static bool
-GetFreeBSDProcessCPUType (ProcessInstanceInfo &process_info)
-{
-    if (process_info.ProcessIDIsValid())
-    {
-        process_info.GetArchitecture() = HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
-        return true;
-    }
-    process_info.GetArchitecture().Clear();
-    return false;
+static bool GetFreeBSDProcessCPUType(ProcessInstanceInfo &process_info) {
+  if (process_info.ProcessIDIsValid()) {
+    process_info.GetArchitecture() =
+        HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
+    return true;
+  }
+  process_info.GetArchitecture().Clear();
+  return false;
 }
 
-static bool
-GetFreeBSDProcessUserAndGroup(ProcessInstanceInfo &process_info)
-{
-    struct kinfo_proc proc_kinfo;
-    size_t proc_kinfo_size;
-
-    if (process_info.ProcessIDIsValid())
-    {
-        int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID,
-            (int)process_info.GetProcessID() };
-        proc_kinfo_size = sizeof(struct kinfo_proc);
-
-        if (::sysctl (mib, 4, &proc_kinfo, &proc_kinfo_size, NULL, 0) == 0)
-        {
-            if (proc_kinfo_size > 0)
-            {
-                process_info.SetParentProcessID (proc_kinfo.ki_ppid);
-                process_info.SetUserID (proc_kinfo.ki_ruid);
-                process_info.SetGroupID (proc_kinfo.ki_rgid);
-                process_info.SetEffectiveUserID (proc_kinfo.ki_uid);
-                if (proc_kinfo.ki_ngroups > 0)
-                    process_info.SetEffectiveGroupID (proc_kinfo.ki_groups[0]);
-                else
-                    process_info.SetEffectiveGroupID (UINT32_MAX);
-                return true;
-            }
-        }
+static bool GetFreeBSDProcessUserAndGroup(ProcessInstanceInfo &process_info) {
+  struct kinfo_proc proc_kinfo;
+  size_t proc_kinfo_size;
+
+  if (process_info.ProcessIDIsValid()) {
+    int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID,
+                  (int)process_info.GetProcessID()};
+    proc_kinfo_size = sizeof(struct kinfo_proc);
+
+    if (::sysctl(mib, 4, &proc_kinfo, &proc_kinfo_size, NULL, 0) == 0) {
+      if (proc_kinfo_size > 0) {
+        process_info.SetParentProcessID(proc_kinfo.ki_ppid);
+        process_info.SetUserID(proc_kinfo.ki_ruid);
+        process_info.SetGroupID(proc_kinfo.ki_rgid);
+        process_info.SetEffectiveUserID(proc_kinfo.ki_uid);
+        if (proc_kinfo.ki_ngroups > 0)
+          process_info.SetEffectiveGroupID(proc_kinfo.ki_groups[0]);
+        else
+          process_info.SetEffectiveGroupID(UINT32_MAX);
+        return true;
+      }
     }
-    process_info.SetParentProcessID (LLDB_INVALID_PROCESS_ID);
-    process_info.SetUserID (UINT32_MAX);
-    process_info.SetGroupID (UINT32_MAX);
-    process_info.SetEffectiveUserID (UINT32_MAX);
-    process_info.SetEffectiveGroupID (UINT32_MAX);
-    return false;
+  }
+  process_info.SetParentProcessID(LLDB_INVALID_PROCESS_ID);
+  process_info.SetUserID(UINT32_MAX);
+  process_info.SetGroupID(UINT32_MAX);
+  process_info.SetEffectiveUserID(UINT32_MAX);
+  process_info.SetEffectiveGroupID(UINT32_MAX);
+  return false;
 }
 
-uint32_t
-Host::FindProcesses (const ProcessInstanceInfoMatch &match_info, ProcessInstanceInfoList &process_infos)
-{
-    std::vector<struct kinfo_proc> kinfos;
-
-    int mib[3] = { CTL_KERN, KERN_PROC, KERN_PROC_ALL };
-
-    size_t pid_data_size = 0;
-    if (::sysctl (mib, 3, NULL, &pid_data_size, NULL, 0) != 0)
-        return 0;
-
-    // Add a few extra in case a few more show up
-    const size_t estimated_pid_count = (pid_data_size / sizeof(struct kinfo_proc)) + 10;
-
-    kinfos.resize (estimated_pid_count);
-    pid_data_size = kinfos.size() * sizeof(struct kinfo_proc);
-
-    if (::sysctl (mib, 3, &kinfos[0], &pid_data_size, NULL, 0) != 0)
-        return 0;
-
-    const size_t actual_pid_count = (pid_data_size / sizeof(struct kinfo_proc));
-
-    bool all_users = match_info.GetMatchAllUsers();
-    const ::pid_t our_pid = getpid();
-    const uid_t our_uid = getuid();
-    for (size_t i = 0; i < actual_pid_count; i++)
-    {
-        const struct kinfo_proc &kinfo = kinfos[i];
-        const bool kinfo_user_matches = (all_users ||
-                                         (kinfo.ki_ruid == our_uid) ||
-                                         // Special case, if lldb is being run as root we can attach to anything.
-                                         (our_uid == 0)
-                                         );
-
-        if (kinfo_user_matches == false      || // Make sure the user is acceptable
-            kinfo.ki_pid == our_pid          || // Skip this process
-            kinfo.ki_pid == 0                || // Skip kernel (kernel pid is zero)
-            kinfo.ki_stat == SZOMB    || // Zombies are bad, they like brains...
-            kinfo.ki_flag & P_TRACED  || // Being debugged?
-            kinfo.ki_flag & P_WEXIT)     // Working on exiting
-            continue;
-
-        // Every thread is a process in FreeBSD, but all the threads of a single process
-        // have the same pid. Do not store the process info in the result list if a process
-        // with given identifier is already registered there.
-        bool already_registered = false;
-        for (uint32_t pi = 0;
-             !already_registered &&
-             (const int)kinfo.ki_numthreads > 1 &&
-             pi < (const uint32_t)process_infos.GetSize(); pi++)
-            already_registered = (process_infos.GetProcessIDAtIndex(pi) == (uint32_t)kinfo.ki_pid);
-
-        if (already_registered)
-            continue;
-
-        ProcessInstanceInfo process_info;
-        process_info.SetProcessID (kinfo.ki_pid);
-        process_info.SetParentProcessID (kinfo.ki_ppid);
-        process_info.SetUserID (kinfo.ki_ruid);
-        process_info.SetGroupID (kinfo.ki_rgid);
-        process_info.SetEffectiveUserID (kinfo.ki_svuid);
-        process_info.SetEffectiveGroupID (kinfo.ki_svgid);
-
-        // Make sure our info matches before we go fetch the name and cpu type
-        if (match_info.Matches (process_info) &&
-            GetFreeBSDProcessArgs (&match_info, process_info))
-        {
-            GetFreeBSDProcessCPUType (process_info);
-            if (match_info.Matches (process_info))
-                process_infos.Append (process_info);
-        }
+uint32_t Host::FindProcesses(const ProcessInstanceInfoMatch &match_info,
+                             ProcessInstanceInfoList &process_infos) {
+  std::vector<struct kinfo_proc> kinfos;
+
+  int mib[3] = {CTL_KERN, KERN_PROC, KERN_PROC_ALL};
+
+  size_t pid_data_size = 0;
+  if (::sysctl(mib, 3, NULL, &pid_data_size, NULL, 0) != 0)
+    return 0;
+
+  // Add a few extra in case a few more show up
+  const size_t estimated_pid_count =
+      (pid_data_size / sizeof(struct kinfo_proc)) + 10;
+
+  kinfos.resize(estimated_pid_count);
+  pid_data_size = kinfos.size() * sizeof(struct kinfo_proc);
+
+  if (::sysctl(mib, 3, &kinfos[0], &pid_data_size, NULL, 0) != 0)
+    return 0;
+
+  const size_t actual_pid_count = (pid_data_size / sizeof(struct kinfo_proc));
+
+  bool all_users = match_info.GetMatchAllUsers();
+  const ::pid_t our_pid = getpid();
+  const uid_t our_uid = getuid();
+  for (size_t i = 0; i < actual_pid_count; i++) {
+    const struct kinfo_proc &kinfo = kinfos[i];
+    const bool kinfo_user_matches = (all_users || (kinfo.ki_ruid == our_uid) ||
+                                     // Special case, if lldb is being run as
+                                     // root we can attach to anything.
+                                     (our_uid == 0));
+
+    if (kinfo_user_matches == false || // Make sure the user is acceptable
+        kinfo.ki_pid == our_pid ||     // Skip this process
+        kinfo.ki_pid == 0 ||           // Skip kernel (kernel pid is zero)
+        kinfo.ki_stat == SZOMB ||      // Zombies are bad, they like brains...
+        kinfo.ki_flag & P_TRACED ||    // Being debugged?
+        kinfo.ki_flag & P_WEXIT)       // Working on exiting
+      continue;
+
+    // Every thread is a process in FreeBSD, but all the threads of a single
+    // process
+    // have the same pid. Do not store the process info in the result list if a
+    // process
+    // with given identifier is already registered there.
+    bool already_registered = false;
+    for (uint32_t pi = 0;
+         !already_registered && (const int)kinfo.ki_numthreads > 1 &&
+         pi < (const uint32_t)process_infos.GetSize();
+         pi++)
+      already_registered =
+          (process_infos.GetProcessIDAtIndex(pi) == (uint32_t)kinfo.ki_pid);
+
+    if (already_registered)
+      continue;
+
+    ProcessInstanceInfo process_info;
+    process_info.SetProcessID(kinfo.ki_pid);
+    process_info.SetParentProcessID(kinfo.ki_ppid);
+    process_info.SetUserID(kinfo.ki_ruid);
+    process_info.SetGroupID(kinfo.ki_rgid);
+    process_info.SetEffectiveUserID(kinfo.ki_svuid);
+    process_info.SetEffectiveGroupID(kinfo.ki_svgid);
+
+    // Make sure our info matches before we go fetch the name and cpu type
+    if (match_info.Matches(process_info) &&
+        GetFreeBSDProcessArgs(&match_info, process_info)) {
+      GetFreeBSDProcessCPUType(process_info);
+      if (match_info.Matches(process_info))
+        process_infos.Append(process_info);
     }
+  }
 
-    return process_infos.GetSize();
+  return process_infos.GetSize();
 }
 
-bool
-Host::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info)
-{
-    process_info.SetProcessID(pid);
-
-    if (GetFreeBSDProcessArgs(NULL, process_info))
-    {
-        // should use libprocstat instead of going right into sysctl?
-        GetFreeBSDProcessCPUType(process_info);
-        GetFreeBSDProcessUserAndGroup(process_info);
-        return true;
-    }
+bool Host::GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &process_info) {
+  process_info.SetProcessID(pid);
 
-    process_info.Clear();
-    return false;
+  if (GetFreeBSDProcessArgs(NULL, process_info)) {
+    // should use libprocstat instead of going right into sysctl?
+    GetFreeBSDProcessCPUType(process_info);
+    GetFreeBSDProcessUserAndGroup(process_info);
+    return true;
+  }
+
+  process_info.Clear();
+  return false;
 }
 
-lldb::DataBufferSP
-Host::GetAuxvData(lldb_private::Process *process)
-{
-   int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_AUXV, 0 };
-   size_t auxv_size = AT_COUNT * sizeof(Elf_Auxinfo);
-   DataBufferSP buf_sp;
-
-   std::unique_ptr<DataBufferHeap> buf_ap(new DataBufferHeap(auxv_size, 0));
-
-   mib[3] = process->GetID();
-   if (::sysctl(mib, 4, buf_ap->GetBytes(), &auxv_size, NULL, 0) == 0) {
-           buf_sp.reset(buf_ap.release());
-   } else {
-           perror("sysctl failed on auxv");
-   }
+lldb::DataBufferSP Host::GetAuxvData(lldb_private::Process *process) {
+  int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_AUXV, 0};
+  size_t auxv_size = AT_COUNT * sizeof(Elf_Auxinfo);
+  DataBufferSP buf_sp;
+
+  std::unique_ptr<DataBufferHeap> buf_ap(new DataBufferHeap(auxv_size, 0));
+
+  mib[3] = process->GetID();
+  if (::sysctl(mib, 4, buf_ap->GetBytes(), &auxv_size, NULL, 0) == 0) {
+    buf_sp.reset(buf_ap.release());
+  } else {
+    perror("sysctl failed on auxv");
+  }
 
-   return buf_sp;
+  return buf_sp;
 }
 
-Error
-Host::ShellExpandArguments (ProcessLaunchInfo &launch_info)
-{
-    return Error("unimplemented");
+Error Host::ShellExpandArguments(ProcessLaunchInfo &launch_info) {
+  return Error("unimplemented");
 }
-

Modified: lldb/trunk/source/Host/freebsd/HostInfoFreeBSD.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/freebsd/HostInfoFreeBSD.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/freebsd/HostInfoFreeBSD.cpp (original)
+++ lldb/trunk/source/Host/freebsd/HostInfoFreeBSD.cpp Tue Sep  6 15:57:50 2016
@@ -11,81 +11,67 @@
 
 #include <stdio.h>
 #include <string.h>
-#include <sys/types.h>
 #include <sys/sysctl.h>
+#include <sys/types.h>
 #include <sys/utsname.h>
 
 using namespace lldb_private;
 
-uint32_t
-HostInfoFreeBSD::GetMaxThreadNameLength()
-{
-    return 16;
-}
+uint32_t HostInfoFreeBSD::GetMaxThreadNameLength() { return 16; }
 
-bool
-HostInfoFreeBSD::GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update)
-{
-    struct utsname un;
-
-    ::memset(&un, 0, sizeof(utsname));
-    if (uname(&un) < 0)
-        return false;
+bool HostInfoFreeBSD::GetOSVersion(uint32_t &major, uint32_t &minor,
+                                   uint32_t &update) {
+  struct utsname un;
+
+  ::memset(&un, 0, sizeof(utsname));
+  if (uname(&un) < 0)
+    return false;
 
-    int status = sscanf(un.release, "%u.%u", &major, &minor);
-    return status == 2;
+  int status = sscanf(un.release, "%u.%u", &major, &minor);
+  return status == 2;
 }
 
-bool
-HostInfoFreeBSD::GetOSBuildString(std::string &s)
-{
-    int mib[2] = {CTL_KERN, KERN_OSREV};
-    char osrev_str[12];
-    uint32_t osrev = 0;
-    size_t osrev_len = sizeof(osrev);
-
-    if (::sysctl(mib, 2, &osrev, &osrev_len, NULL, 0) == 0)
-    {
-        ::snprintf(osrev_str, sizeof(osrev_str), "%-8.8u", osrev);
-        s.assign(osrev_str);
-        return true;
-    }
+bool HostInfoFreeBSD::GetOSBuildString(std::string &s) {
+  int mib[2] = {CTL_KERN, KERN_OSREV};
+  char osrev_str[12];
+  uint32_t osrev = 0;
+  size_t osrev_len = sizeof(osrev);
+
+  if (::sysctl(mib, 2, &osrev, &osrev_len, NULL, 0) == 0) {
+    ::snprintf(osrev_str, sizeof(osrev_str), "%-8.8u", osrev);
+    s.assign(osrev_str);
+    return true;
+  }
 
-    s.clear();
-    return false;
+  s.clear();
+  return false;
 }
 
-bool
-HostInfoFreeBSD::GetOSKernelDescription(std::string &s)
-{
-    struct utsname un;
+bool HostInfoFreeBSD::GetOSKernelDescription(std::string &s) {
+  struct utsname un;
 
-    ::memset(&un, 0, sizeof(utsname));
-    s.clear();
+  ::memset(&un, 0, sizeof(utsname));
+  s.clear();
 
-    if (uname(&un) < 0)
-        return false;
+  if (uname(&un) < 0)
+    return false;
 
-    s.assign(un.version);
+  s.assign(un.version);
 
-    return true;
+  return true;
 }
 
-FileSpec
-HostInfoFreeBSD::GetProgramFileSpec()
-{
-    static FileSpec g_program_filespec;
-    if (!g_program_filespec)
-    {
-        int exe_path_mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, getpid()};
-        size_t exe_path_size;
-        if (sysctl(exe_path_mib, 4, NULL, &exe_path_size, NULL, 0) == 0)
-        {
-            char *exe_path = new char[exe_path_size];
-            if (sysctl(exe_path_mib, 4, exe_path, &exe_path_size, NULL, 0) == 0)
-                g_program_filespec.SetFile(exe_path, false);
-            delete[] exe_path;
-        }
+FileSpec HostInfoFreeBSD::GetProgramFileSpec() {
+  static FileSpec g_program_filespec;
+  if (!g_program_filespec) {
+    int exe_path_mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, getpid()};
+    size_t exe_path_size;
+    if (sysctl(exe_path_mib, 4, NULL, &exe_path_size, NULL, 0) == 0) {
+      char *exe_path = new char[exe_path_size];
+      if (sysctl(exe_path_mib, 4, exe_path, &exe_path_size, NULL, 0) == 0)
+        g_program_filespec.SetFile(exe_path, false);
+      delete[] exe_path;
     }
-    return g_program_filespec;
+  }
+  return g_program_filespec;
 }
\ No newline at end of file

Modified: lldb/trunk/source/Host/freebsd/HostThreadFreeBSD.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/freebsd/HostThreadFreeBSD.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/freebsd/HostThreadFreeBSD.cpp (original)
+++ lldb/trunk/source/Host/freebsd/HostThreadFreeBSD.cpp Tue Sep  6 15:57:50 2016
@@ -14,7 +14,7 @@
 // C includes
 #include <errno.h>
 #include <pthread.h>
-#if defined (__FreeBSD__)
+#if defined(__FreeBSD__)
 #include <pthread_np.h>
 #endif
 #include <stdlib.h>
@@ -26,54 +26,45 @@
 
 using namespace lldb_private;
 
-HostThreadFreeBSD::HostThreadFreeBSD()
-{
-}
+HostThreadFreeBSD::HostThreadFreeBSD() {}
 
 HostThreadFreeBSD::HostThreadFreeBSD(lldb::thread_t thread)
-    : HostThreadPosix(thread)
-{
-}
+    : HostThreadPosix(thread) {}
 
-void
-HostThreadFreeBSD::GetName(lldb::tid_t tid, llvm::SmallVectorImpl<char> &name)
-{
-    name.clear();
-    int pid = Host::GetCurrentProcessID();
-
-    struct kinfo_proc *kp = nullptr, *nkp;
-    size_t len = 0;
-    int error;
-    int ctl[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID | KERN_PROC_INC_THREAD, (int)pid};
-
-    while (1)
-    {
-        error = sysctl(ctl, 4, kp, &len, nullptr, 0);
-        if (kp == nullptr || (error != 0 && errno == ENOMEM))
-        {
-            // Add extra space in case threads are added before next call.
-            len += sizeof(*kp) + len / 10;
-            nkp = (struct kinfo_proc *)realloc(kp, len);
-            if (nkp == nullptr)
-            {
-                free(kp);
-                return;
-            }
-            kp = nkp;
-            continue;
-        }
-        if (error != 0)
-            len = 0;
-        break;
+void HostThreadFreeBSD::GetName(lldb::tid_t tid,
+                                llvm::SmallVectorImpl<char> &name) {
+  name.clear();
+  int pid = Host::GetCurrentProcessID();
+
+  struct kinfo_proc *kp = nullptr, *nkp;
+  size_t len = 0;
+  int error;
+  int ctl[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID | KERN_PROC_INC_THREAD,
+                (int)pid};
+
+  while (1) {
+    error = sysctl(ctl, 4, kp, &len, nullptr, 0);
+    if (kp == nullptr || (error != 0 && errno == ENOMEM)) {
+      // Add extra space in case threads are added before next call.
+      len += sizeof(*kp) + len / 10;
+      nkp = (struct kinfo_proc *)realloc(kp, len);
+      if (nkp == nullptr) {
+        free(kp);
+        return;
+      }
+      kp = nkp;
+      continue;
     }
-
-    for (size_t i = 0; i < len / sizeof(*kp); i++)
-    {
-        if (kp[i].ki_tid == (lwpid_t)tid)
-        {
-            name.append(kp[i].ki_tdname, kp[i].ki_tdname + strlen(kp[i].ki_tdname));
-            break;
-        }
+    if (error != 0)
+      len = 0;
+    break;
+  }
+
+  for (size_t i = 0; i < len / sizeof(*kp); i++) {
+    if (kp[i].ki_tid == (lwpid_t)tid) {
+      name.append(kp[i].ki_tdname, kp[i].ki_tdname + strlen(kp[i].ki_tdname));
+      break;
     }
-    free(kp);
+  }
+  free(kp);
 }

Modified: lldb/trunk/source/Host/freebsd/ThisThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/freebsd/ThisThread.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/freebsd/ThisThread.cpp (original)
+++ lldb/trunk/source/Host/freebsd/ThisThread.cpp Tue Sep  6 15:57:50 2016
@@ -7,33 +7,29 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "lldb/Host/HostNativeThread.h"
 #include "lldb/Host/ThisThread.h"
+#include "lldb/Host/HostNativeThread.h"
 
 #include "llvm/ADT/SmallVector.h"
 
 #include <pthread.h>
-#if defined (__FreeBSD__)
+#if defined(__FreeBSD__)
 #include <pthread_np.h>
 #endif
 
 using namespace lldb_private;
 
-void
-ThisThread::SetName(llvm::StringRef name)
-{
-#if defined (__FreeBSD__) // Kfreebsd does not have a simple alternative
-    ::pthread_set_name_np(::pthread_self(), name.data());
+void ThisThread::SetName(llvm::StringRef name) {
+#if defined(__FreeBSD__) // Kfreebsd does not have a simple alternative
+  ::pthread_set_name_np(::pthread_self(), name.data());
 #endif
 }
 
-void
-ThisThread::GetName(llvm::SmallVectorImpl<char> &name)
-{
-#if defined (__FreeBSD__)
-    HostNativeThread::GetName(::pthread_getthreadid_np(), name);
+void ThisThread::GetName(llvm::SmallVectorImpl<char> &name) {
+#if defined(__FreeBSD__)
+  HostNativeThread::GetName(::pthread_getthreadid_np(), name);
 #else
-// Kfreebsd
-    HostNativeThread::GetName((unsigned)pthread_self(), name);
+  // Kfreebsd
+  HostNativeThread::GetName((unsigned)pthread_self(), name);
 #endif
 }

Modified: lldb/trunk/source/Host/linux/AbstractSocket.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/linux/AbstractSocket.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/linux/AbstractSocket.cpp (original)
+++ lldb/trunk/source/Host/linux/AbstractSocket.cpp Tue Sep  6 15:57:50 2016
@@ -15,17 +15,8 @@ using namespace lldb;
 using namespace lldb_private;
 
 AbstractSocket::AbstractSocket(bool child_processes_inherit, Error &error)
-    : DomainSocket(ProtocolUnixAbstract, child_processes_inherit, error)
-{
-}
+    : DomainSocket(ProtocolUnixAbstract, child_processes_inherit, error) {}
 
-size_t
-AbstractSocket::GetNameOffset() const
-{
-    return 1;
-}
+size_t AbstractSocket::GetNameOffset() const { return 1; }
 
-void
-AbstractSocket::DeleteSocketFile(llvm::StringRef name)
-{
-}
+void AbstractSocket::DeleteSocketFile(llvm::StringRef name) {}

Modified: lldb/trunk/source/Host/linux/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/linux/Host.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/linux/Host.cpp (original)
+++ lldb/trunk/source/Host/linux/Host.cpp Tue Sep  6 15:57:50 2016
@@ -25,379 +25,353 @@
 #include "lldb/Core/Log.h"
 #include "lldb/Target/Process.h"
 
-#include "lldb/Host/Host.h"
-#include "lldb/Host/HostInfo.h"
 #include "lldb/Core/DataBufferHeap.h"
 #include "lldb/Core/DataExtractor.h"
+#include "lldb/Host/Host.h"
+#include "lldb/Host/HostInfo.h"
 
+#include "Plugins/Process/Linux/ProcFileReader.h"
 #include "lldb/Core/ModuleSpec.h"
 #include "lldb/Symbol/ObjectFile.h"
-#include "Plugins/Process/Linux/ProcFileReader.h"
 
 using namespace lldb;
 using namespace lldb_private;
 
-typedef enum ProcessStateFlags
-{
-    eProcessStateRunning           = (1u << 0), // Running
-    eProcessStateSleeping          = (1u << 1), // Sleeping in an interruptible wait
-    eProcessStateWaiting           = (1u << 2), // Waiting in an uninterruptible disk sleep
-    eProcessStateZombie            = (1u << 3), // Zombie
-    eProcessStateTracedOrStopped   = (1u << 4), // Traced or stopped (on a signal)
-    eProcessStatePaging            = (1u << 5)  // Paging
+typedef enum ProcessStateFlags {
+  eProcessStateRunning = (1u << 0),  // Running
+  eProcessStateSleeping = (1u << 1), // Sleeping in an interruptible wait
+  eProcessStateWaiting = (1u << 2),  // Waiting in an uninterruptible disk sleep
+  eProcessStateZombie = (1u << 3),   // Zombie
+  eProcessStateTracedOrStopped = (1u << 4), // Traced or stopped (on a signal)
+  eProcessStatePaging = (1u << 5)           // Paging
 } ProcessStateFlags;
 
-typedef struct ProcessStatInfo
-{
-    lldb::pid_t ppid;           // Parent Process ID
-    uint32_t fProcessState;     // ProcessStateFlags
+typedef struct ProcessStatInfo {
+  lldb::pid_t ppid;       // Parent Process ID
+  uint32_t fProcessState; // ProcessStateFlags
 } ProcessStatInfo;
 
-// Get the process info with additional information from /proc/$PID/stat (like process state, and tracer pid).
-static bool GetProcessAndStatInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info, ProcessStatInfo &stat_info, lldb::pid_t &tracerpid);
-
-static bool
-ReadProcPseudoFileStat (lldb::pid_t pid, ProcessStatInfo& stat_info)
-{
-    // Read the /proc/$PID/stat file.
-    lldb::DataBufferSP buf_sp = process_linux::ProcFileReader::ReadIntoDataBuffer (pid, "stat");
-
-    // The filename of the executable is stored in parenthesis right after the pid. We look for the closing
-    // parenthesis for the filename and work from there in case the name has something funky like ')' in it.
-    const char *filename_end = strrchr ((const char *)buf_sp->GetBytes(), ')');
-    if (filename_end)
-    {
-        char state = '\0';
-        int ppid = LLDB_INVALID_PROCESS_ID;
-
-        // Read state and ppid.
-        sscanf (filename_end + 1, " %c %d", &state, &ppid);
-
-        stat_info.ppid = ppid;
-
-        switch (state)
-        {
-            case 'R':
-                stat_info.fProcessState |= eProcessStateRunning;
-                break;
-            case 'S':
-                stat_info.fProcessState |= eProcessStateSleeping;
-                break;
-            case 'D':
-                stat_info.fProcessState |= eProcessStateWaiting;
-                break;
-            case 'Z':
-                stat_info.fProcessState |= eProcessStateZombie;
-                break;
-            case 'T':
-                stat_info.fProcessState |= eProcessStateTracedOrStopped;
-                break;
-            case 'W':
-                stat_info.fProcessState |= eProcessStatePaging;
-                break;
-        }
-
-        return true;
-    }
-
-    return false;
-}
-
-static void
-GetLinuxProcessUserAndGroup (lldb::pid_t pid, ProcessInstanceInfo &process_info, lldb::pid_t &tracerpid)
-{
-    tracerpid = 0;
-    uint32_t rUid = UINT32_MAX;     // Real User ID
-    uint32_t eUid = UINT32_MAX;     // Effective User ID
-    uint32_t rGid = UINT32_MAX;     // Real Group ID
-    uint32_t eGid = UINT32_MAX;     // Effective Group ID
-
-    // Read the /proc/$PID/status file and parse the Uid:, Gid:, and TracerPid: fields.
-    lldb::DataBufferSP buf_sp = process_linux::ProcFileReader::ReadIntoDataBuffer (pid, "status");
-
-    static const char uid_token[] = "Uid:";
-    char *buf_uid = strstr ((char *)buf_sp->GetBytes(), uid_token);
-    if (buf_uid)
-    {
-        // Real, effective, saved set, and file system UIDs. Read the first two.
-        buf_uid += sizeof(uid_token);
-        rUid = strtol (buf_uid, &buf_uid, 10);
-        eUid = strtol (buf_uid, &buf_uid, 10);
-    }
-
-    static const char gid_token[] = "Gid:";
-    char *buf_gid = strstr ((char *)buf_sp->GetBytes(), gid_token);
-    if (buf_gid)
-    {
-        // Real, effective, saved set, and file system GIDs. Read the first two.
-        buf_gid += sizeof(gid_token);
-        rGid = strtol (buf_gid, &buf_gid, 10);
-        eGid = strtol (buf_gid, &buf_gid, 10);
-    }
-
-    static const char tracerpid_token[] = "TracerPid:";
-    char *buf_tracerpid = strstr((char *)buf_sp->GetBytes(), tracerpid_token);
-    if (buf_tracerpid)
-    {
-        // Tracer PID. 0 if we're not being debugged.
-        buf_tracerpid += sizeof(tracerpid_token);
-        tracerpid = strtol (buf_tracerpid, &buf_tracerpid, 10);
+// Get the process info with additional information from /proc/$PID/stat (like
+// process state, and tracer pid).
+static bool GetProcessAndStatInfo(lldb::pid_t pid,
+                                  ProcessInstanceInfo &process_info,
+                                  ProcessStatInfo &stat_info,
+                                  lldb::pid_t &tracerpid);
+
+static bool ReadProcPseudoFileStat(lldb::pid_t pid,
+                                   ProcessStatInfo &stat_info) {
+  // Read the /proc/$PID/stat file.
+  lldb::DataBufferSP buf_sp =
+      process_linux::ProcFileReader::ReadIntoDataBuffer(pid, "stat");
+
+  // The filename of the executable is stored in parenthesis right after the
+  // pid. We look for the closing
+  // parenthesis for the filename and work from there in case the name has
+  // something funky like ')' in it.
+  const char *filename_end = strrchr((const char *)buf_sp->GetBytes(), ')');
+  if (filename_end) {
+    char state = '\0';
+    int ppid = LLDB_INVALID_PROCESS_ID;
+
+    // Read state and ppid.
+    sscanf(filename_end + 1, " %c %d", &state, &ppid);
+
+    stat_info.ppid = ppid;
+
+    switch (state) {
+    case 'R':
+      stat_info.fProcessState |= eProcessStateRunning;
+      break;
+    case 'S':
+      stat_info.fProcessState |= eProcessStateSleeping;
+      break;
+    case 'D':
+      stat_info.fProcessState |= eProcessStateWaiting;
+      break;
+    case 'Z':
+      stat_info.fProcessState |= eProcessStateZombie;
+      break;
+    case 'T':
+      stat_info.fProcessState |= eProcessStateTracedOrStopped;
+      break;
+    case 'W':
+      stat_info.fProcessState |= eProcessStatePaging;
+      break;
     }
 
-    process_info.SetUserID (rUid);
-    process_info.SetEffectiveUserID (eUid);
-    process_info.SetGroupID (rGid);
-    process_info.SetEffectiveGroupID (eGid);
-}
-
-lldb::DataBufferSP
-Host::GetAuxvData(lldb_private::Process *process)
-{
-    return process_linux::ProcFileReader::ReadIntoDataBuffer (process->GetID(), "auxv");
-}
-
-lldb::DataBufferSP
-Host::GetAuxvData (lldb::pid_t pid)
-{
-    return process_linux::ProcFileReader::ReadIntoDataBuffer (pid, "auxv");
-}
-
-static bool
-IsDirNumeric(const char *dname)
-{
-    for (; *dname; dname++)
-    {
-        if (!isdigit (*dname))
-            return false;
-    }
     return true;
-}
-
-uint32_t
-Host::FindProcesses (const ProcessInstanceInfoMatch &match_info, ProcessInstanceInfoList &process_infos)
-{
-    static const char procdir[] = "/proc/";
-
-    DIR *dirproc = opendir (procdir);
-    if (dirproc)
-    {
-        struct dirent *direntry = NULL;
-        const uid_t our_uid = getuid();
-        const lldb::pid_t our_pid = getpid();
-        bool all_users = match_info.GetMatchAllUsers();
-
-        while ((direntry = readdir (dirproc)) != NULL)
-        {
-            if (direntry->d_type != DT_DIR || !IsDirNumeric (direntry->d_name))
-                continue;
-
-            lldb::pid_t pid = atoi (direntry->d_name);
-
-            // Skip this process.
-            if (pid == our_pid)
-                continue;
-
-            lldb::pid_t tracerpid;
-            ProcessStatInfo stat_info;
-            ProcessInstanceInfo process_info;
-
-            if (!GetProcessAndStatInfo (pid, process_info, stat_info, tracerpid))
-                continue;
-
-            // Skip if process is being debugged.
-            if (tracerpid != 0)
-                continue;
-
-            // Skip zombies.
-            if (stat_info.fProcessState & eProcessStateZombie)
-                continue;
-
-            // Check for user match if we're not matching all users and not running as root.
-            if (!all_users && (our_uid != 0) && (process_info.GetUserID() != our_uid))
-                continue;
-
-            if (match_info.Matches (process_info))
-            {
-                process_infos.Append (process_info);
-            }
-        }
-
-        closedir (dirproc);
-    }
+  }
 
-    return process_infos.GetSize();
+  return false;
 }
 
-bool
-Host::FindProcessThreads (const lldb::pid_t pid, TidMap &tids_to_attach)
-{
-    bool tids_changed = false;
-    static const char procdir[] = "/proc/";
-    static const char taskdir[] = "/task/";
-    std::string process_task_dir = procdir + llvm::to_string(pid) + taskdir;
-    DIR *dirproc = opendir (process_task_dir.c_str());
-
-    if (dirproc)
-    {
-        struct dirent *direntry = NULL;
-        while ((direntry = readdir (dirproc)) != NULL)
-        {
-            if (direntry->d_type != DT_DIR || !IsDirNumeric (direntry->d_name))
-                continue;
-
-            lldb::tid_t tid = atoi(direntry->d_name);
-            TidMap::iterator it = tids_to_attach.find(tid);
-            if (it == tids_to_attach.end())
-            {
-                tids_to_attach.insert(TidPair(tid, false));
-                tids_changed = true;
-            }
-        }
-        closedir (dirproc);
-    }
-
-    return tids_changed;
-}
-
-static bool
-GetELFProcessCPUType (const char *exe_path, ProcessInstanceInfo &process_info)
-{
-    // Clear the architecture.
-    process_info.GetArchitecture().Clear();
-
-    ModuleSpecList specs;
-    FileSpec filespec (exe_path, false);
-    const size_t num_specs = ObjectFile::GetModuleSpecifications (filespec, 0, 0, specs);
-    // GetModuleSpecifications() could fail if the executable has been deleted or is locked.
-    // But it shouldn't return more than 1 architecture.
-    assert(num_specs <= 1 && "Linux plugin supports only a single architecture");
-    if (num_specs == 1)
-    {
-        ModuleSpec module_spec;
-        if (specs.GetModuleSpecAtIndex (0, module_spec) && module_spec.GetArchitecture().IsValid())
-        {
-            process_info.GetArchitecture () = module_spec.GetArchitecture();
-            return true;
-        }
-    }
+static void GetLinuxProcessUserAndGroup(lldb::pid_t pid,
+                                        ProcessInstanceInfo &process_info,
+                                        lldb::pid_t &tracerpid) {
+  tracerpid = 0;
+  uint32_t rUid = UINT32_MAX; // Real User ID
+  uint32_t eUid = UINT32_MAX; // Effective User ID
+  uint32_t rGid = UINT32_MAX; // Real Group ID
+  uint32_t eGid = UINT32_MAX; // Effective Group ID
+
+  // Read the /proc/$PID/status file and parse the Uid:, Gid:, and TracerPid:
+  // fields.
+  lldb::DataBufferSP buf_sp =
+      process_linux::ProcFileReader::ReadIntoDataBuffer(pid, "status");
+
+  static const char uid_token[] = "Uid:";
+  char *buf_uid = strstr((char *)buf_sp->GetBytes(), uid_token);
+  if (buf_uid) {
+    // Real, effective, saved set, and file system UIDs. Read the first two.
+    buf_uid += sizeof(uid_token);
+    rUid = strtol(buf_uid, &buf_uid, 10);
+    eUid = strtol(buf_uid, &buf_uid, 10);
+  }
+
+  static const char gid_token[] = "Gid:";
+  char *buf_gid = strstr((char *)buf_sp->GetBytes(), gid_token);
+  if (buf_gid) {
+    // Real, effective, saved set, and file system GIDs. Read the first two.
+    buf_gid += sizeof(gid_token);
+    rGid = strtol(buf_gid, &buf_gid, 10);
+    eGid = strtol(buf_gid, &buf_gid, 10);
+  }
+
+  static const char tracerpid_token[] = "TracerPid:";
+  char *buf_tracerpid = strstr((char *)buf_sp->GetBytes(), tracerpid_token);
+  if (buf_tracerpid) {
+    // Tracer PID. 0 if we're not being debugged.
+    buf_tracerpid += sizeof(tracerpid_token);
+    tracerpid = strtol(buf_tracerpid, &buf_tracerpid, 10);
+  }
+
+  process_info.SetUserID(rUid);
+  process_info.SetEffectiveUserID(eUid);
+  process_info.SetGroupID(rGid);
+  process_info.SetEffectiveGroupID(eGid);
+}
+
+lldb::DataBufferSP Host::GetAuxvData(lldb_private::Process *process) {
+  return process_linux::ProcFileReader::ReadIntoDataBuffer(process->GetID(),
+                                                           "auxv");
+}
+
+lldb::DataBufferSP Host::GetAuxvData(lldb::pid_t pid) {
+  return process_linux::ProcFileReader::ReadIntoDataBuffer(pid, "auxv");
+}
+
+static bool IsDirNumeric(const char *dname) {
+  for (; *dname; dname++) {
+    if (!isdigit(*dname))
+      return false;
+  }
+  return true;
+}
+
+uint32_t Host::FindProcesses(const ProcessInstanceInfoMatch &match_info,
+                             ProcessInstanceInfoList &process_infos) {
+  static const char procdir[] = "/proc/";
+
+  DIR *dirproc = opendir(procdir);
+  if (dirproc) {
+    struct dirent *direntry = NULL;
+    const uid_t our_uid = getuid();
+    const lldb::pid_t our_pid = getpid();
+    bool all_users = match_info.GetMatchAllUsers();
+
+    while ((direntry = readdir(dirproc)) != NULL) {
+      if (direntry->d_type != DT_DIR || !IsDirNumeric(direntry->d_name))
+        continue;
+
+      lldb::pid_t pid = atoi(direntry->d_name);
+
+      // Skip this process.
+      if (pid == our_pid)
+        continue;
+
+      lldb::pid_t tracerpid;
+      ProcessStatInfo stat_info;
+      ProcessInstanceInfo process_info;
+
+      if (!GetProcessAndStatInfo(pid, process_info, stat_info, tracerpid))
+        continue;
+
+      // Skip if process is being debugged.
+      if (tracerpid != 0)
+        continue;
+
+      // Skip zombies.
+      if (stat_info.fProcessState & eProcessStateZombie)
+        continue;
+
+      // Check for user match if we're not matching all users and not running as
+      // root.
+      if (!all_users && (our_uid != 0) && (process_info.GetUserID() != our_uid))
+        continue;
+
+      if (match_info.Matches(process_info)) {
+        process_infos.Append(process_info);
+      }
+    }
+
+    closedir(dirproc);
+  }
+
+  return process_infos.GetSize();
+}
+
+bool Host::FindProcessThreads(const lldb::pid_t pid, TidMap &tids_to_attach) {
+  bool tids_changed = false;
+  static const char procdir[] = "/proc/";
+  static const char taskdir[] = "/task/";
+  std::string process_task_dir = procdir + llvm::to_string(pid) + taskdir;
+  DIR *dirproc = opendir(process_task_dir.c_str());
+
+  if (dirproc) {
+    struct dirent *direntry = NULL;
+    while ((direntry = readdir(dirproc)) != NULL) {
+      if (direntry->d_type != DT_DIR || !IsDirNumeric(direntry->d_name))
+        continue;
+
+      lldb::tid_t tid = atoi(direntry->d_name);
+      TidMap::iterator it = tids_to_attach.find(tid);
+      if (it == tids_to_attach.end()) {
+        tids_to_attach.insert(TidPair(tid, false));
+        tids_changed = true;
+      }
+    }
+    closedir(dirproc);
+  }
+
+  return tids_changed;
+}
+
+static bool GetELFProcessCPUType(const char *exe_path,
+                                 ProcessInstanceInfo &process_info) {
+  // Clear the architecture.
+  process_info.GetArchitecture().Clear();
+
+  ModuleSpecList specs;
+  FileSpec filespec(exe_path, false);
+  const size_t num_specs =
+      ObjectFile::GetModuleSpecifications(filespec, 0, 0, specs);
+  // GetModuleSpecifications() could fail if the executable has been deleted or
+  // is locked.
+  // But it shouldn't return more than 1 architecture.
+  assert(num_specs <= 1 && "Linux plugin supports only a single architecture");
+  if (num_specs == 1) {
+    ModuleSpec module_spec;
+    if (specs.GetModuleSpecAtIndex(0, module_spec) &&
+        module_spec.GetArchitecture().IsValid()) {
+      process_info.GetArchitecture() = module_spec.GetArchitecture();
+      return true;
+    }
+  }
+  return false;
+}
+
+static bool GetProcessAndStatInfo(lldb::pid_t pid,
+                                  ProcessInstanceInfo &process_info,
+                                  ProcessStatInfo &stat_info,
+                                  lldb::pid_t &tracerpid) {
+  tracerpid = 0;
+  process_info.Clear();
+  ::memset(&stat_info, 0, sizeof(stat_info));
+  stat_info.ppid = LLDB_INVALID_PROCESS_ID;
+
+  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+
+  // Use special code here because proc/[pid]/exe is a symbolic link.
+  char link_path[PATH_MAX];
+  char exe_path[PATH_MAX] = "";
+  if (snprintf(link_path, PATH_MAX, "/proc/%" PRIu64 "/exe", pid) <= 0) {
+    if (log)
+      log->Printf("%s: failed to sprintf pid %" PRIu64, __FUNCTION__, pid);
     return false;
-}
-
-static bool
-GetProcessAndStatInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info, ProcessStatInfo &stat_info, lldb::pid_t &tracerpid)
-{
-    tracerpid = 0;
-    process_info.Clear();
-    ::memset (&stat_info, 0, sizeof(stat_info));
-    stat_info.ppid = LLDB_INVALID_PROCESS_ID;
-
-    Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
-
-    // Use special code here because proc/[pid]/exe is a symbolic link.
-    char link_path[PATH_MAX];
-    char exe_path[PATH_MAX] = "";
-    if (snprintf (link_path, PATH_MAX, "/proc/%" PRIu64 "/exe", pid) <= 0)
-    {
-        if (log)
-            log->Printf("%s: failed to sprintf pid %" PRIu64, __FUNCTION__, pid);
-        return false;
-    }
-
-    ssize_t len = readlink (link_path, exe_path, sizeof(exe_path) - 1);
-    if (len <= 0)
-    {
-        if (log)
-            log->Printf("%s: failed to read link %s: %s", __FUNCTION__, link_path, strerror(errno));
-        return false;
-    }
-
-    // readlink does not append a null byte.
-    exe_path[len] = 0;
+  }
 
-    // If the binary has been deleted, the link name has " (deleted)" appended.
-    //  Remove if there.
-    static const ssize_t deleted_len = strlen(" (deleted)");
-    if (len > deleted_len &&
-        !strcmp(exe_path + len - deleted_len, " (deleted)"))
-    {
-        exe_path[len - deleted_len] = 0;
-    }
-    else
-    {
-        GetELFProcessCPUType (exe_path, process_info);
-    }
-
-    process_info.SetProcessID(pid);
-    process_info.GetExecutableFile().SetFile(exe_path, false);
-    process_info.GetArchitecture().MergeFrom(HostInfo::GetArchitecture());
-
-    lldb::DataBufferSP buf_sp;
-
-    // Get the process environment.
-    buf_sp = process_linux::ProcFileReader::ReadIntoDataBuffer(pid, "environ");
-    Args &info_env = process_info.GetEnvironmentEntries();
-    char *next_var = (char *)buf_sp->GetBytes();
-    char *end_buf = next_var + buf_sp->GetByteSize();
-    while (next_var < end_buf && 0 != *next_var)
-    {
-        info_env.AppendArgument(next_var);
-        next_var += strlen(next_var) + 1;
-    }
-
-    // Get the command line used to start the process.
-    buf_sp = process_linux::ProcFileReader::ReadIntoDataBuffer(pid, "cmdline");
-
-    // Grab Arg0 first, if there is one.
-    char *cmd = (char *)buf_sp->GetBytes();
-    if (cmd)
-    {
-        process_info.SetArg0(cmd);
-
-        // Now process any remaining arguments.
-        Args &info_args = process_info.GetArguments();
-        char *next_arg = cmd + strlen(cmd) + 1;
-        end_buf = cmd + buf_sp->GetByteSize();
-        while (next_arg < end_buf && 0 != *next_arg)
-        {
-            info_args.AppendArgument(next_arg);
-            next_arg += strlen(next_arg) + 1;
-        }
-    }
-
-    // Read /proc/$PID/stat to get our parent pid.
-    if (ReadProcPseudoFileStat (pid, stat_info))
-    {
-        process_info.SetParentProcessID (stat_info.ppid);
-    }
+  ssize_t len = readlink(link_path, exe_path, sizeof(exe_path) - 1);
+  if (len <= 0) {
+    if (log)
+      log->Printf("%s: failed to read link %s: %s", __FUNCTION__, link_path,
+                  strerror(errno));
+    return false;
+  }
 
-    // Get User and Group IDs and get tracer pid.
-    GetLinuxProcessUserAndGroup (pid, process_info, tracerpid);
+  // readlink does not append a null byte.
+  exe_path[len] = 0;
 
-    return true;
+  // If the binary has been deleted, the link name has " (deleted)" appended.
+  //  Remove if there.
+  static const ssize_t deleted_len = strlen(" (deleted)");
+  if (len > deleted_len &&
+      !strcmp(exe_path + len - deleted_len, " (deleted)")) {
+    exe_path[len - deleted_len] = 0;
+  } else {
+    GetELFProcessCPUType(exe_path, process_info);
+  }
+
+  process_info.SetProcessID(pid);
+  process_info.GetExecutableFile().SetFile(exe_path, false);
+  process_info.GetArchitecture().MergeFrom(HostInfo::GetArchitecture());
+
+  lldb::DataBufferSP buf_sp;
+
+  // Get the process environment.
+  buf_sp = process_linux::ProcFileReader::ReadIntoDataBuffer(pid, "environ");
+  Args &info_env = process_info.GetEnvironmentEntries();
+  char *next_var = (char *)buf_sp->GetBytes();
+  char *end_buf = next_var + buf_sp->GetByteSize();
+  while (next_var < end_buf && 0 != *next_var) {
+    info_env.AppendArgument(next_var);
+    next_var += strlen(next_var) + 1;
+  }
+
+  // Get the command line used to start the process.
+  buf_sp = process_linux::ProcFileReader::ReadIntoDataBuffer(pid, "cmdline");
+
+  // Grab Arg0 first, if there is one.
+  char *cmd = (char *)buf_sp->GetBytes();
+  if (cmd) {
+    process_info.SetArg0(cmd);
+
+    // Now process any remaining arguments.
+    Args &info_args = process_info.GetArguments();
+    char *next_arg = cmd + strlen(cmd) + 1;
+    end_buf = cmd + buf_sp->GetByteSize();
+    while (next_arg < end_buf && 0 != *next_arg) {
+      info_args.AppendArgument(next_arg);
+      next_arg += strlen(next_arg) + 1;
+    }
+  }
+
+  // Read /proc/$PID/stat to get our parent pid.
+  if (ReadProcPseudoFileStat(pid, stat_info)) {
+    process_info.SetParentProcessID(stat_info.ppid);
+  }
+
+  // Get User and Group IDs and get tracer pid.
+  GetLinuxProcessUserAndGroup(pid, process_info, tracerpid);
+
+  return true;
+}
+
+bool Host::GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &process_info) {
+  lldb::pid_t tracerpid;
+  ProcessStatInfo stat_info;
+
+  return GetProcessAndStatInfo(pid, process_info, stat_info, tracerpid);
+}
+
+size_t Host::GetEnvironment(StringList &env) {
+  char **host_env = environ;
+  char *env_entry;
+  size_t i;
+  for (i = 0; (env_entry = host_env[i]) != NULL; ++i)
+    env.AppendString(env_entry);
+  return i;
 }
 
-bool
-Host::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info)
-{
-    lldb::pid_t tracerpid;
-    ProcessStatInfo stat_info;
-
-    return GetProcessAndStatInfo (pid, process_info, stat_info, tracerpid);
-}
-
-size_t
-Host::GetEnvironment (StringList &env)
-{
-    char **host_env = environ;
-    char *env_entry;
-    size_t i;
-    for (i=0; (env_entry = host_env[i]) != NULL; ++i)
-        env.AppendString(env_entry);
-    return i;
-}
-
-Error
-Host::ShellExpandArguments (ProcessLaunchInfo &launch_info)
-{
-    return Error("unimplemented");
+Error Host::ShellExpandArguments(ProcessLaunchInfo &launch_info) {
+  return Error("unimplemented");
 }

Modified: lldb/trunk/source/Host/linux/HostInfoLinux.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/linux/HostInfoLinux.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/linux/HostInfoLinux.cpp (original)
+++ lldb/trunk/source/Host/linux/HostInfoLinux.cpp Tue Sep  6 15:57:50 2016
@@ -7,8 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "lldb/Core/Log.h"
 #include "lldb/Host/linux/HostInfoLinux.h"
+#include "lldb/Core/Log.h"
 
 #include <limits.h>
 #include <stdio.h>
@@ -20,263 +20,224 @@
 
 using namespace lldb_private;
 
-namespace
-{
-struct HostInfoLinuxFields
-{
-    HostInfoLinuxFields()
-        : m_os_major(0)
-        , m_os_minor(0)
-        , m_os_update(0)
-    {
-    }
-
-    std::string m_distribution_id;
-    uint32_t m_os_major;
-    uint32_t m_os_minor;
-    uint32_t m_os_update;
+namespace {
+struct HostInfoLinuxFields {
+  HostInfoLinuxFields() : m_os_major(0), m_os_minor(0), m_os_update(0) {}
+
+  std::string m_distribution_id;
+  uint32_t m_os_major;
+  uint32_t m_os_minor;
+  uint32_t m_os_update;
 };
 
 HostInfoLinuxFields *g_fields = nullptr;
 }
 
-void
-HostInfoLinux::Initialize()
-{
-    HostInfoPosix::Initialize();
-
-    g_fields = new HostInfoLinuxFields();
-}
-
-uint32_t
-HostInfoLinux::GetMaxThreadNameLength()
-{
-    return 16;
-}
-
-bool
-HostInfoLinux::GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update)
-{
-    static bool success = false;
-    static std::once_flag g_once_flag;
-    std::call_once(g_once_flag,  []() {
-
-        struct utsname un;
-        if (uname(&un) == 0)
-        {
-            int status = sscanf(un.release, "%u.%u.%u", &g_fields->m_os_major, &g_fields->m_os_minor, &g_fields->m_os_update);
-            if (status == 3)
-                success = true;
-            else
-            {
-                // Some kernels omit the update version, so try looking for just "X.Y" and
-                // set update to 0.
-                g_fields->m_os_update = 0;
-                status = sscanf(un.release, "%u.%u", &g_fields->m_os_major, &g_fields->m_os_minor);
-                if (status == 2)
-                    success = true;
-            }
-        }
-    });
-
+void HostInfoLinux::Initialize() {
+  HostInfoPosix::Initialize();
 
-    major = g_fields->m_os_major;
-    minor = g_fields->m_os_minor;
-    update = g_fields->m_os_update;
-    return success;
+  g_fields = new HostInfoLinuxFields();
 }
 
-bool
-HostInfoLinux::GetOSBuildString(std::string &s)
-{
+uint32_t HostInfoLinux::GetMaxThreadNameLength() { return 16; }
+
+bool HostInfoLinux::GetOSVersion(uint32_t &major, uint32_t &minor,
+                                 uint32_t &update) {
+  static bool success = false;
+  static std::once_flag g_once_flag;
+  std::call_once(g_once_flag, []() {
+
     struct utsname un;
-    ::memset(&un, 0, sizeof(utsname));
-    s.clear();
+    if (uname(&un) == 0) {
+      int status = sscanf(un.release, "%u.%u.%u", &g_fields->m_os_major,
+                          &g_fields->m_os_minor, &g_fields->m_os_update);
+      if (status == 3)
+        success = true;
+      else {
+        // Some kernels omit the update version, so try looking for just "X.Y"
+        // and
+        // set update to 0.
+        g_fields->m_os_update = 0;
+        status = sscanf(un.release, "%u.%u", &g_fields->m_os_major,
+                        &g_fields->m_os_minor);
+        if (status == 2)
+          success = true;
+      }
+    }
+  });
+
+  major = g_fields->m_os_major;
+  minor = g_fields->m_os_minor;
+  update = g_fields->m_os_update;
+  return success;
+}
 
-    if (uname(&un) < 0)
-        return false;
+bool HostInfoLinux::GetOSBuildString(std::string &s) {
+  struct utsname un;
+  ::memset(&un, 0, sizeof(utsname));
+  s.clear();
 
-    s.assign(un.release);
-    return true;
+  if (uname(&un) < 0)
+    return false;
+
+  s.assign(un.release);
+  return true;
 }
 
-bool
-HostInfoLinux::GetOSKernelDescription(std::string &s)
-{
-    struct utsname un;
+bool HostInfoLinux::GetOSKernelDescription(std::string &s) {
+  struct utsname un;
 
-    ::memset(&un, 0, sizeof(utsname));
-    s.clear();
+  ::memset(&un, 0, sizeof(utsname));
+  s.clear();
 
-    if (uname(&un) < 0)
-        return false;
+  if (uname(&un) < 0)
+    return false;
 
-    s.assign(un.version);
-    return true;
+  s.assign(un.version);
+  return true;
 }
 
-llvm::StringRef
-HostInfoLinux::GetDistributionId()
-{
-    // Try to run 'lbs_release -i', and use that response
-    // for the distribution id.
-    static std::once_flag g_once_flag;
-    std::call_once(g_once_flag,  []() {
+llvm::StringRef HostInfoLinux::GetDistributionId() {
+  // Try to run 'lbs_release -i', and use that response
+  // for the distribution id.
+  static std::once_flag g_once_flag;
+  std::call_once(g_once_flag, []() {
 
-        Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST));
-        if (log)
-            log->Printf("attempting to determine Linux distribution...");
+    Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST));
+    if (log)
+      log->Printf("attempting to determine Linux distribution...");
 
-        // check if the lsb_release command exists at one of the
-        // following paths
-        const char *const exe_paths[] = {"/bin/lsb_release", "/usr/bin/lsb_release"};
-
-        for (size_t exe_index = 0; exe_index < sizeof(exe_paths) / sizeof(exe_paths[0]); ++exe_index)
-        {
-            const char *const get_distribution_info_exe = exe_paths[exe_index];
-            if (access(get_distribution_info_exe, F_OK))
-            {
-                // this exe doesn't exist, move on to next exe
-                if (log)
-                    log->Printf("executable doesn't exist: %s", get_distribution_info_exe);
-                continue;
-            }
-
-            // execute the distribution-retrieval command, read output
-            std::string get_distribution_id_command(get_distribution_info_exe);
-            get_distribution_id_command += " -i";
-
-            FILE *file = popen(get_distribution_id_command.c_str(), "r");
-            if (!file)
-            {
-                if (log)
-                    log->Printf("failed to run command: \"%s\", cannot retrieve "
-                                "platform information",
-                                get_distribution_id_command.c_str());
-                break;
-            }
-
-            // retrieve the distribution id string.
-            char distribution_id[256] = {'\0'};
-            if (fgets(distribution_id, sizeof(distribution_id) - 1, file) != NULL)
-            {
-                if (log)
-                    log->Printf("distribution id command returned \"%s\"", distribution_id);
-
-                const char *const distributor_id_key = "Distributor ID:\t";
-                if (strstr(distribution_id, distributor_id_key))
-                {
-                    // strip newlines
-                    std::string id_string(distribution_id + strlen(distributor_id_key));
-                    id_string.erase(std::remove(id_string.begin(), id_string.end(), '\n'), id_string.end());
-
-                    // lower case it and convert whitespace to underscores
-                    std::transform(id_string.begin(), id_string.end(), id_string.begin(), [](char ch)
-                                   {
-                        return tolower(isspace(ch) ? '_' : ch);
-                    });
-
-                    g_fields->m_distribution_id = id_string;
-                    if (log)
-                        log->Printf("distribution id set to \"%s\"", g_fields->m_distribution_id.c_str());
-                }
-                else
-                {
-                    if (log)
-                        log->Printf("failed to find \"%s\" field in \"%s\"", distributor_id_key, distribution_id);
-                }
-            }
-            else
-            {
-                if (log)
-                    log->Printf("failed to retrieve distribution id, \"%s\" returned no"
-                                " lines",
-                                get_distribution_id_command.c_str());
-            }
+    // check if the lsb_release command exists at one of the
+    // following paths
+    const char *const exe_paths[] = {"/bin/lsb_release",
+                                     "/usr/bin/lsb_release"};
 
-            // clean up the file
-            pclose(file);
-        }
-    });
+    for (size_t exe_index = 0;
+         exe_index < sizeof(exe_paths) / sizeof(exe_paths[0]); ++exe_index) {
+      const char *const get_distribution_info_exe = exe_paths[exe_index];
+      if (access(get_distribution_info_exe, F_OK)) {
+        // this exe doesn't exist, move on to next exe
+        if (log)
+          log->Printf("executable doesn't exist: %s",
+                      get_distribution_info_exe);
+        continue;
+      }
+
+      // execute the distribution-retrieval command, read output
+      std::string get_distribution_id_command(get_distribution_info_exe);
+      get_distribution_id_command += " -i";
 
-    return g_fields->m_distribution_id.c_str();
-}
+      FILE *file = popen(get_distribution_id_command.c_str(), "r");
+      if (!file) {
+        if (log)
+          log->Printf("failed to run command: \"%s\", cannot retrieve "
+                      "platform information",
+                      get_distribution_id_command.c_str());
+        break;
+      }
+
+      // retrieve the distribution id string.
+      char distribution_id[256] = {'\0'};
+      if (fgets(distribution_id, sizeof(distribution_id) - 1, file) != NULL) {
+        if (log)
+          log->Printf("distribution id command returned \"%s\"",
+                      distribution_id);
 
-FileSpec
-HostInfoLinux::GetProgramFileSpec()
-{
-    static FileSpec g_program_filespec;
-
-    if (!g_program_filespec)
-    {
-        char exe_path[PATH_MAX];
-        ssize_t len = readlink("/proc/self/exe", exe_path, sizeof(exe_path) - 1);
-        if (len > 0)
-        {
-            exe_path[len] = 0;
-            g_program_filespec.SetFile(exe_path, false);
+        const char *const distributor_id_key = "Distributor ID:\t";
+        if (strstr(distribution_id, distributor_id_key)) {
+          // strip newlines
+          std::string id_string(distribution_id + strlen(distributor_id_key));
+          id_string.erase(std::remove(id_string.begin(), id_string.end(), '\n'),
+                          id_string.end());
+
+          // lower case it and convert whitespace to underscores
+          std::transform(
+              id_string.begin(), id_string.end(), id_string.begin(),
+              [](char ch) { return tolower(isspace(ch) ? '_' : ch); });
+
+          g_fields->m_distribution_id = id_string;
+          if (log)
+            log->Printf("distribution id set to \"%s\"",
+                        g_fields->m_distribution_id.c_str());
+        } else {
+          if (log)
+            log->Printf("failed to find \"%s\" field in \"%s\"",
+                        distributor_id_key, distribution_id);
         }
+      } else {
+        if (log)
+          log->Printf("failed to retrieve distribution id, \"%s\" returned no"
+                      " lines",
+                      get_distribution_id_command.c_str());
+      }
+
+      // clean up the file
+      pclose(file);
     }
+  });
 
-    return g_program_filespec;
+  return g_fields->m_distribution_id.c_str();
 }
 
-bool
-HostInfoLinux::ComputeSupportExeDirectory(FileSpec &file_spec)
-{
-    if (HostInfoPosix::ComputeSupportExeDirectory(file_spec) &&
-            file_spec.IsAbsolute() &&
-            file_spec.Exists())
-        return true;
-    file_spec.GetDirectory() = GetProgramFileSpec().GetDirectory();
-    return !file_spec.GetDirectory().IsEmpty();
-}
-
-bool
-HostInfoLinux::ComputeSystemPluginsDirectory(FileSpec &file_spec)
-{
-    FileSpec temp_file("/usr/lib/lldb/plugins", true);
-    file_spec.GetDirectory().SetCString(temp_file.GetPath().c_str());
-    return true;
-}
+FileSpec HostInfoLinux::GetProgramFileSpec() {
+  static FileSpec g_program_filespec;
 
-bool
-HostInfoLinux::ComputeUserPluginsDirectory(FileSpec &file_spec)
-{
-    // XDG Base Directory Specification
-    // http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
-    // If XDG_DATA_HOME exists, use that, otherwise use ~/.local/share/lldb.
-    const char *xdg_data_home = getenv("XDG_DATA_HOME");
-    if (xdg_data_home && xdg_data_home[0])
-    {
-        std::string user_plugin_dir(xdg_data_home);
-        user_plugin_dir += "/lldb";
-        file_spec.GetDirectory().SetCString(user_plugin_dir.c_str());
+  if (!g_program_filespec) {
+    char exe_path[PATH_MAX];
+    ssize_t len = readlink("/proc/self/exe", exe_path, sizeof(exe_path) - 1);
+    if (len > 0) {
+      exe_path[len] = 0;
+      g_program_filespec.SetFile(exe_path, false);
     }
-    else
-        file_spec.GetDirectory().SetCString("~/.local/share/lldb");
+  }
+
+  return g_program_filespec;
+}
+
+bool HostInfoLinux::ComputeSupportExeDirectory(FileSpec &file_spec) {
+  if (HostInfoPosix::ComputeSupportExeDirectory(file_spec) &&
+      file_spec.IsAbsolute() && file_spec.Exists())
     return true;
+  file_spec.GetDirectory() = GetProgramFileSpec().GetDirectory();
+  return !file_spec.GetDirectory().IsEmpty();
 }
 
-void
-HostInfoLinux::ComputeHostArchitectureSupport(ArchSpec &arch_32, ArchSpec &arch_64)
-{
-    HostInfoPosix::ComputeHostArchitectureSupport(arch_32, arch_64);
-
-    const char *distribution_id = GetDistributionId().data();
-
-    // On Linux, "unknown" in the vendor slot isn't what we want for the default
-    // triple.  It's probably an artifact of config.guess.
-    if (arch_32.IsValid())
-    {
-        arch_32.SetDistributionId(distribution_id);
-        if (arch_32.GetTriple().getVendor() == llvm::Triple::UnknownVendor)
-            arch_32.GetTriple().setVendorName(llvm::StringRef());
-    }
-    if (arch_64.IsValid())
-    {
-        arch_64.SetDistributionId(distribution_id);
-        if (arch_64.GetTriple().getVendor() == llvm::Triple::UnknownVendor)
-            arch_64.GetTriple().setVendorName(llvm::StringRef());
-    }
+bool HostInfoLinux::ComputeSystemPluginsDirectory(FileSpec &file_spec) {
+  FileSpec temp_file("/usr/lib/lldb/plugins", true);
+  file_spec.GetDirectory().SetCString(temp_file.GetPath().c_str());
+  return true;
+}
+
+bool HostInfoLinux::ComputeUserPluginsDirectory(FileSpec &file_spec) {
+  // XDG Base Directory Specification
+  // http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
+  // If XDG_DATA_HOME exists, use that, otherwise use ~/.local/share/lldb.
+  const char *xdg_data_home = getenv("XDG_DATA_HOME");
+  if (xdg_data_home && xdg_data_home[0]) {
+    std::string user_plugin_dir(xdg_data_home);
+    user_plugin_dir += "/lldb";
+    file_spec.GetDirectory().SetCString(user_plugin_dir.c_str());
+  } else
+    file_spec.GetDirectory().SetCString("~/.local/share/lldb");
+  return true;
+}
+
+void HostInfoLinux::ComputeHostArchitectureSupport(ArchSpec &arch_32,
+                                                   ArchSpec &arch_64) {
+  HostInfoPosix::ComputeHostArchitectureSupport(arch_32, arch_64);
+
+  const char *distribution_id = GetDistributionId().data();
+
+  // On Linux, "unknown" in the vendor slot isn't what we want for the default
+  // triple.  It's probably an artifact of config.guess.
+  if (arch_32.IsValid()) {
+    arch_32.SetDistributionId(distribution_id);
+    if (arch_32.GetTriple().getVendor() == llvm::Triple::UnknownVendor)
+      arch_32.GetTriple().setVendorName(llvm::StringRef());
+  }
+  if (arch_64.IsValid()) {
+    arch_64.SetDistributionId(distribution_id);
+    if (arch_64.GetTriple().getVendor() == llvm::Triple::UnknownVendor)
+      arch_64.GetTriple().setVendorName(llvm::StringRef());
+  }
 }

Modified: lldb/trunk/source/Host/linux/HostThreadLinux.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/linux/HostThreadLinux.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/linux/HostThreadLinux.cpp (original)
+++ lldb/trunk/source/Host/linux/HostThreadLinux.cpp Tue Sep  6 15:57:50 2016
@@ -7,9 +7,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "lldb/Core/DataBuffer.h"
 #include "lldb/Host/linux/HostThreadLinux.h"
 #include "Plugins/Process/Linux/ProcFileReader.h"
+#include "lldb/Core/DataBuffer.h"
 
 #include "llvm/ADT/SmallVector.h"
 
@@ -17,36 +17,29 @@
 
 using namespace lldb_private;
 
-HostThreadLinux::HostThreadLinux()
-    : HostThreadPosix()
-{
-}
+HostThreadLinux::HostThreadLinux() : HostThreadPosix() {}
 
 HostThreadLinux::HostThreadLinux(lldb::thread_t thread)
-    : HostThreadPosix(thread)
-{
-}
+    : HostThreadPosix(thread) {}
 
-void
-HostThreadLinux::SetName(lldb::thread_t thread, llvm::StringRef name)
-{
+void HostThreadLinux::SetName(lldb::thread_t thread, llvm::StringRef name) {
 #if (defined(__GLIBC__) && defined(_GNU_SOURCE)) || defined(__ANDROID__)
-    ::pthread_setname_np(thread, name.data());
+  ::pthread_setname_np(thread, name.data());
 #else
-    (void) thread;
-    (void) name;
+  (void)thread;
+  (void)name;
 #endif
 }
 
-void
-HostThreadLinux::GetName(lldb::thread_t thread, llvm::SmallVectorImpl<char> &name)
-{
-    // Read /proc/$TID/comm file.
-    lldb::DataBufferSP buf_sp = process_linux::ProcFileReader::ReadIntoDataBuffer(thread, "comm");
-    const char *comm_str = (const char *)buf_sp->GetBytes();
-    const char *cr_str = ::strchr(comm_str, '\n');
-    size_t length = cr_str ? (cr_str - comm_str) : strlen(comm_str);
+void HostThreadLinux::GetName(lldb::thread_t thread,
+                              llvm::SmallVectorImpl<char> &name) {
+  // Read /proc/$TID/comm file.
+  lldb::DataBufferSP buf_sp =
+      process_linux::ProcFileReader::ReadIntoDataBuffer(thread, "comm");
+  const char *comm_str = (const char *)buf_sp->GetBytes();
+  const char *cr_str = ::strchr(comm_str, '\n');
+  size_t length = cr_str ? (cr_str - comm_str) : strlen(comm_str);
 
-    name.clear();
-    name.append(comm_str, comm_str + length);
+  name.clear();
+  name.append(comm_str, comm_str + length);
 }

Modified: lldb/trunk/source/Host/linux/LibcGlue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/linux/LibcGlue.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/linux/LibcGlue.cpp (original)
+++ lldb/trunk/source/Host/linux/LibcGlue.cpp Tue Sep  6 15:57:50 2016
@@ -9,22 +9,23 @@
 
 // This file adds functions missing from libc on older versions of linux
 
-#include <unistd.h>
-#include <sys/syscall.h>
-#include <lldb/Host/linux/Uio.h>
 #include <cerrno>
+#include <lldb/Host/linux/Uio.h>
+#include <sys/syscall.h>
+#include <unistd.h>
 
-#ifndef HAVE_PROCESS_VM_READV // If the syscall wrapper is not available, provide one.
-ssize_t process_vm_readv(::pid_t pid,
-			 const struct iovec *local_iov, unsigned long liovcnt,
-			 const struct iovec *remote_iov, unsigned long riovcnt,
-			 unsigned long flags)
-{
-#ifdef HAVE_NR_PROCESS_VM_READV // If we have the syscall number, we can issue the syscall ourselves.
-    return syscall(__NR_process_vm_readv, pid, local_iov, liovcnt, remote_iov, riovcnt, flags);
+#ifndef HAVE_PROCESS_VM_READV // If the syscall wrapper is not available,
+                              // provide one.
+ssize_t process_vm_readv(::pid_t pid, const struct iovec *local_iov,
+                         unsigned long liovcnt, const struct iovec *remote_iov,
+                         unsigned long riovcnt, unsigned long flags) {
+#ifdef HAVE_NR_PROCESS_VM_READV // If we have the syscall number, we can issue
+                                // the syscall ourselves.
+  return syscall(__NR_process_vm_readv, pid, local_iov, liovcnt, remote_iov,
+                 riovcnt, flags);
 #else // If not, let's pretend the syscall is not present.
-    errno = ENOSYS;
-    return -1;
+  errno = ENOSYS;
+  return -1;
 #endif
 }
 #endif

Modified: lldb/trunk/source/Host/linux/ProcessLauncherLinux.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/linux/ProcessLauncherLinux.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/linux/ProcessLauncherLinux.cpp (original)
+++ lldb/trunk/source/Host/linux/ProcessLauncherLinux.cpp Tue Sep  6 15:57:50 2016
@@ -25,189 +25,193 @@
 using namespace lldb;
 using namespace lldb_private;
 
-static void
-FixupEnvironment(Args &env)
-{
+static void FixupEnvironment(Args &env) {
 #ifdef __ANDROID_NDK__
-    // If there is no PATH variable specified inside the environment then set the path to /system/bin.
-    // It is required because the default path used by execve() is wrong on android.
-    static const char *path = "PATH=";
-    static const int path_len = ::strlen(path);
-    for (const char **args = env.GetConstArgumentVector(); *args; ++args)
-        if (::strncmp(path, *args, path_len) == 0)
-            return;
-    env.AppendArgument("PATH=/system/bin");
+  // If there is no PATH variable specified inside the environment then set the
+  // path to /system/bin.
+  // It is required because the default path used by execve() is wrong on
+  // android.
+  static const char *path = "PATH=";
+  static const int path_len = ::strlen(path);
+  for (const char **args = env.GetConstArgumentVector(); *args; ++args)
+    if (::strncmp(path, *args, path_len) == 0)
+      return;
+  env.AppendArgument("PATH=/system/bin");
 #endif
 }
 
-static void LLVM_ATTRIBUTE_NORETURN
-ExitWithError(int error_fd, const char *operation)
-{
-    std::ostringstream os;
-    os << operation << " failed: " << strerror(errno);
-    write(error_fd, os.str().data(), os.str().size());
-    close(error_fd);
-    _exit(1);
+static void LLVM_ATTRIBUTE_NORETURN ExitWithError(int error_fd,
+                                                  const char *operation) {
+  std::ostringstream os;
+  os << operation << " failed: " << strerror(errno);
+  write(error_fd, os.str().data(), os.str().size());
+  close(error_fd);
+  _exit(1);
 }
 
-static void
-DupDescriptor(int error_fd, const FileSpec &file_spec, int fd, int flags)
-{
-    int target_fd = ::open(file_spec.GetCString(), flags, 0666);
+static void DupDescriptor(int error_fd, const FileSpec &file_spec, int fd,
+                          int flags) {
+  int target_fd = ::open(file_spec.GetCString(), flags, 0666);
 
-    if (target_fd == -1)
-        ExitWithError(error_fd, "DupDescriptor-open");
+  if (target_fd == -1)
+    ExitWithError(error_fd, "DupDescriptor-open");
 
-    if (target_fd == fd)
-        return;
-
-    if (::dup2(target_fd, fd) == -1)
-        ExitWithError(error_fd, "DupDescriptor-dup2");
-
-    ::close(target_fd);
+  if (target_fd == fd)
     return;
-}
-
-static void LLVM_ATTRIBUTE_NORETURN
-ChildFunc(int error_fd, const ProcessLaunchInfo &info)
-{
-    // First, make sure we disable all logging. If we are logging to stdout, our logs can be
-    // mistaken for inferior output.
-    Log::DisableAllLogChannels(nullptr);
-
-    // Do not inherit setgid powers.
-    if (setgid(getgid()) != 0)
-        ExitWithError(error_fd, "setgid");
-
-    if (info.GetFlags().Test(eLaunchFlagLaunchInSeparateProcessGroup))
-    {
-        if (setpgid(0, 0) != 0)
-            ExitWithError(error_fd, "setpgid");
-    }
 
-    for (size_t i = 0; i < info.GetNumFileActions(); ++i)
-    {
-        const FileAction &action = *info.GetFileActionAtIndex(i);
-        switch (action.GetAction())
-        {
-            case FileAction::eFileActionClose:
-                if (close(action.GetFD()) != 0)
-                    ExitWithError(error_fd, "close");
-                break;
-            case FileAction::eFileActionDuplicate:
-                if (dup2(action.GetFD(), action.GetActionArgument()) == -1)
-                    ExitWithError(error_fd, "dup2");
-                break;
-            case FileAction::eFileActionOpen:
-                DupDescriptor(error_fd, action.GetFileSpec(), action.GetFD(), action.GetActionArgument());
-                break;
-            case FileAction::eFileActionNone:
-                break;
-        }
-    }
-
-    const char **argv = info.GetArguments().GetConstArgumentVector();
+  if (::dup2(target_fd, fd) == -1)
+    ExitWithError(error_fd, "DupDescriptor-dup2");
 
-    // Change working directory
-    if (info.GetWorkingDirectory() && 0 != ::chdir(info.GetWorkingDirectory().GetCString()))
-        ExitWithError(error_fd, "chdir");
-
-    // Disable ASLR if requested.
-    if (info.GetFlags().Test(lldb::eLaunchFlagDisableASLR))
-    {
-        const unsigned long personality_get_current = 0xffffffff;
-        int value = personality(personality_get_current);
-        if (value == -1)
-            ExitWithError(error_fd, "personality get");
-
-        value = personality(ADDR_NO_RANDOMIZE | value);
-        if (value == -1)
-            ExitWithError(error_fd, "personality set");
-    }
-
-    Args env = info.GetEnvironmentEntries();
-    FixupEnvironment(env);
-    const char **envp = env.GetConstArgumentVector();
-
-    // Clear the signal mask to prevent the child from being affected by
-    // any masking done by the parent.
-    sigset_t set;
-    if (sigemptyset(&set) != 0 || pthread_sigmask(SIG_SETMASK, &set, nullptr) != 0)
-        ExitWithError(error_fd, "pthread_sigmask");
-
-    if (info.GetFlags().Test(eLaunchFlagDebug))
-    {
-        // HACK:
-        // Close everything besides stdin, stdout, and stderr that has no file
-        // action to avoid leaking. Only do this when debugging, as elsewhere we actually rely on
-        // passing open descriptors to child processes.
-        for (int fd = 3; fd < sysconf(_SC_OPEN_MAX); ++fd)
-            if (!info.GetFileActionForFD(fd) && fd != error_fd)
-                close(fd);
-
-        // Start tracing this child that is about to exec.
-        if (ptrace(PTRACE_TRACEME, 0, nullptr, nullptr) == -1)
-            ExitWithError(error_fd, "ptrace");
-    }
-
-    // Execute.  We should never return...
-    execve(argv[0], const_cast<char *const *>(argv), const_cast<char *const *>(envp));
-
-    if (errno == ETXTBSY)
-    {
-        // On android M and earlier we can get this error because the adb deamon can hold a write
-        // handle on the executable even after it has finished uploading it. This state lasts
-        // only a short time and happens only when there are many concurrent adb commands being
-        // issued, such as when running the test suite. (The file remains open when someone does
-        // an "adb shell" command in the fork() child before it has had a chance to exec.) Since
-        // this state should clear up quickly, wait a while and then give it one more go.
-        usleep(50000);
-        execve(argv[0], const_cast<char *const *>(argv), const_cast<char *const *>(envp));
-    }
+  ::close(target_fd);
+  return;
+}
 
-    // ...unless exec fails.  In which case we definitely need to end the child here.
-    ExitWithError(error_fd, "execve");
+static void LLVM_ATTRIBUTE_NORETURN ChildFunc(int error_fd,
+                                              const ProcessLaunchInfo &info) {
+  // First, make sure we disable all logging. If we are logging to stdout, our
+  // logs can be
+  // mistaken for inferior output.
+  Log::DisableAllLogChannels(nullptr);
+
+  // Do not inherit setgid powers.
+  if (setgid(getgid()) != 0)
+    ExitWithError(error_fd, "setgid");
+
+  if (info.GetFlags().Test(eLaunchFlagLaunchInSeparateProcessGroup)) {
+    if (setpgid(0, 0) != 0)
+      ExitWithError(error_fd, "setpgid");
+  }
+
+  for (size_t i = 0; i < info.GetNumFileActions(); ++i) {
+    const FileAction &action = *info.GetFileActionAtIndex(i);
+    switch (action.GetAction()) {
+    case FileAction::eFileActionClose:
+      if (close(action.GetFD()) != 0)
+        ExitWithError(error_fd, "close");
+      break;
+    case FileAction::eFileActionDuplicate:
+      if (dup2(action.GetFD(), action.GetActionArgument()) == -1)
+        ExitWithError(error_fd, "dup2");
+      break;
+    case FileAction::eFileActionOpen:
+      DupDescriptor(error_fd, action.GetFileSpec(), action.GetFD(),
+                    action.GetActionArgument());
+      break;
+    case FileAction::eFileActionNone:
+      break;
+    }
+  }
+
+  const char **argv = info.GetArguments().GetConstArgumentVector();
+
+  // Change working directory
+  if (info.GetWorkingDirectory() &&
+      0 != ::chdir(info.GetWorkingDirectory().GetCString()))
+    ExitWithError(error_fd, "chdir");
+
+  // Disable ASLR if requested.
+  if (info.GetFlags().Test(lldb::eLaunchFlagDisableASLR)) {
+    const unsigned long personality_get_current = 0xffffffff;
+    int value = personality(personality_get_current);
+    if (value == -1)
+      ExitWithError(error_fd, "personality get");
+
+    value = personality(ADDR_NO_RANDOMIZE | value);
+    if (value == -1)
+      ExitWithError(error_fd, "personality set");
+  }
+
+  Args env = info.GetEnvironmentEntries();
+  FixupEnvironment(env);
+  const char **envp = env.GetConstArgumentVector();
+
+  // Clear the signal mask to prevent the child from being affected by
+  // any masking done by the parent.
+  sigset_t set;
+  if (sigemptyset(&set) != 0 ||
+      pthread_sigmask(SIG_SETMASK, &set, nullptr) != 0)
+    ExitWithError(error_fd, "pthread_sigmask");
+
+  if (info.GetFlags().Test(eLaunchFlagDebug)) {
+    // HACK:
+    // Close everything besides stdin, stdout, and stderr that has no file
+    // action to avoid leaking. Only do this when debugging, as elsewhere we
+    // actually rely on
+    // passing open descriptors to child processes.
+    for (int fd = 3; fd < sysconf(_SC_OPEN_MAX); ++fd)
+      if (!info.GetFileActionForFD(fd) && fd != error_fd)
+        close(fd);
+
+    // Start tracing this child that is about to exec.
+    if (ptrace(PTRACE_TRACEME, 0, nullptr, nullptr) == -1)
+      ExitWithError(error_fd, "ptrace");
+  }
+
+  // Execute.  We should never return...
+  execve(argv[0], const_cast<char *const *>(argv),
+         const_cast<char *const *>(envp));
+
+  if (errno == ETXTBSY) {
+    // On android M and earlier we can get this error because the adb deamon can
+    // hold a write
+    // handle on the executable even after it has finished uploading it. This
+    // state lasts
+    // only a short time and happens only when there are many concurrent adb
+    // commands being
+    // issued, such as when running the test suite. (The file remains open when
+    // someone does
+    // an "adb shell" command in the fork() child before it has had a chance to
+    // exec.) Since
+    // this state should clear up quickly, wait a while and then give it one
+    // more go.
+    usleep(50000);
+    execve(argv[0], const_cast<char *const *>(argv),
+           const_cast<char *const *>(envp));
+  }
+
+  // ...unless exec fails.  In which case we definitely need to end the child
+  // here.
+  ExitWithError(error_fd, "execve");
 }
 
 HostProcess
-ProcessLauncherLinux::LaunchProcess(const ProcessLaunchInfo &launch_info, Error &error)
-{
-    char exe_path[PATH_MAX];
-    launch_info.GetExecutableFile().GetPath(exe_path, sizeof(exe_path));
-
-    // A pipe used by the child process to report errors.
-    PipePosix pipe;
-    const bool child_processes_inherit = false;
-    error = pipe.CreateNew(child_processes_inherit);
-    if (error.Fail())
-        return HostProcess();
-
-    ::pid_t pid = ::fork();
-    if (pid == -1)
-    {
-        // Fork failed
-        error.SetErrorStringWithFormat("Fork failed with error message: %s", strerror(errno));
-        return HostProcess(LLDB_INVALID_PROCESS_ID);
-    }
-    if (pid == 0)
-    {
-        // child process
-        pipe.CloseReadFileDescriptor();
-        ChildFunc(pipe.ReleaseWriteFileDescriptor(), launch_info);
-    }
-
-    // parent process
+ProcessLauncherLinux::LaunchProcess(const ProcessLaunchInfo &launch_info,
+                                    Error &error) {
+  char exe_path[PATH_MAX];
+  launch_info.GetExecutableFile().GetPath(exe_path, sizeof(exe_path));
+
+  // A pipe used by the child process to report errors.
+  PipePosix pipe;
+  const bool child_processes_inherit = false;
+  error = pipe.CreateNew(child_processes_inherit);
+  if (error.Fail())
+    return HostProcess();
 
-    pipe.CloseWriteFileDescriptor();
-    char buf[1000];
-    int r = read(pipe.GetReadFileDescriptor(), buf, sizeof buf);
+  ::pid_t pid = ::fork();
+  if (pid == -1) {
+    // Fork failed
+    error.SetErrorStringWithFormat("Fork failed with error message: %s",
+                                   strerror(errno));
+    return HostProcess(LLDB_INVALID_PROCESS_ID);
+  }
+  if (pid == 0) {
+    // child process
+    pipe.CloseReadFileDescriptor();
+    ChildFunc(pipe.ReleaseWriteFileDescriptor(), launch_info);
+  }
+
+  // parent process
+
+  pipe.CloseWriteFileDescriptor();
+  char buf[1000];
+  int r = read(pipe.GetReadFileDescriptor(), buf, sizeof buf);
 
-    if (r == 0)
-        return HostProcess(pid); // No error. We're done.
+  if (r == 0)
+    return HostProcess(pid); // No error. We're done.
 
-    error.SetErrorString(buf);
+  error.SetErrorString(buf);
 
-    waitpid(pid, nullptr, 0);
+  waitpid(pid, nullptr, 0);
 
-    return HostProcess();
+  return HostProcess();
 }

Modified: lldb/trunk/source/Host/linux/ThisThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/linux/ThisThread.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/linux/ThisThread.cpp (original)
+++ lldb/trunk/source/Host/linux/ThisThread.cpp Tue Sep  6 15:57:50 2016
@@ -7,8 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "lldb/Host/HostNativeThread.h"
 #include "lldb/Host/ThisThread.h"
+#include "lldb/Host/HostNativeThread.h"
 
 #include "llvm/ADT/SmallVector.h"
 
@@ -16,14 +16,10 @@
 
 using namespace lldb_private;
 
-void
-ThisThread::SetName(llvm::StringRef name)
-{
-    HostNativeThread::SetName(::pthread_self(), name);
+void ThisThread::SetName(llvm::StringRef name) {
+  HostNativeThread::SetName(::pthread_self(), name);
 }
 
-void
-ThisThread::GetName(llvm::SmallVectorImpl<char> &name)
-{
-    HostNativeThread::GetName(::pthread_self(), name);
+void ThisThread::GetName(llvm::SmallVectorImpl<char> &name) {
+  HostNativeThread::GetName(::pthread_self(), name);
 }

Modified: lldb/trunk/source/Host/macosx/Host.mm
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/Host.mm (original)
+++ lldb/trunk/source/Host/macosx/Host.mm Tue Sep  6 15:57:50 2016
@@ -11,8 +11,9 @@
 
 #include <AvailabilityMacros.h>
 
-#if !defined(MAC_OS_X_VERSION_10_7) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
-#define NO_XPC_SERVICES 1 
+#if !defined(MAC_OS_X_VERSION_10_7) ||                                         \
+    MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
+#define NO_XPC_SERVICES 1
 #endif
 
 #if !defined(NO_XPC_SERVICES)
@@ -21,18 +22,19 @@
 
 #define LaunchUsingXPCRightName "com.apple.dt.Xcode.RootDebuggingXPCService"
 
-// These XPC messaging keys are used for communication between Host.mm and the XPC service.
-#define LauncherXPCServiceAuthKey               "auth-key"
-#define LauncherXPCServiceArgPrefxKey           "arg"
-#define LauncherXPCServiceEnvPrefxKey           "env"
-#define LauncherXPCServiceCPUTypeKey            "cpuType"
-#define LauncherXPCServicePosixspawnFlagsKey    "posixspawnFlags"
-#define LauncherXPCServiceStdInPathKeyKey       "stdInPath"
-#define LauncherXPCServiceStdOutPathKeyKey      "stdOutPath"
-#define LauncherXPCServiceStdErrPathKeyKey      "stdErrPath"
-#define LauncherXPCServiceChildPIDKey           "childPID"
-#define LauncherXPCServiceErrorTypeKey          "errorType"
-#define LauncherXPCServiceCodeTypeKey           "errorCode"
+// These XPC messaging keys are used for communication between Host.mm and the
+// XPC service.
+#define LauncherXPCServiceAuthKey "auth-key"
+#define LauncherXPCServiceArgPrefxKey "arg"
+#define LauncherXPCServiceEnvPrefxKey "env"
+#define LauncherXPCServiceCPUTypeKey "cpuType"
+#define LauncherXPCServicePosixspawnFlagsKey "posixspawnFlags"
+#define LauncherXPCServiceStdInPathKeyKey "stdInPath"
+#define LauncherXPCServiceStdOutPathKeyKey "stdOutPath"
+#define LauncherXPCServiceStdErrPathKeyKey "stdErrPath"
+#define LauncherXPCServiceChildPIDKey "childPID"
+#define LauncherXPCServiceErrorTypeKey "errorType"
+#define LauncherXPCServiceCodeTypeKey "errorCode"
 
 #endif
 
@@ -79,132 +81,112 @@
 #include "cfcpp/CFCReleaser.h"
 #include "cfcpp/CFCString.h"
 
-
 #include <objc/objc-auto.h>
 
 #include <CoreFoundation/CoreFoundation.h>
 #include <Foundation/Foundation.h>
 
 #ifndef _POSIX_SPAWN_DISABLE_ASLR
-#define _POSIX_SPAWN_DISABLE_ASLR       0x0100
+#define _POSIX_SPAWN_DISABLE_ASLR 0x0100
 #endif
 
-extern "C" 
-{
-    int __pthread_chdir(const char *path);
-    int __pthread_fchdir (int fildes);
+extern "C" {
+int __pthread_chdir(const char *path);
+int __pthread_fchdir(int fildes);
 }
 
 using namespace lldb;
 using namespace lldb_private;
 
-bool
-Host::GetBundleDirectory (const FileSpec &file, FileSpec &bundle_directory)
-{
-#if defined (__APPLE__)
-    if (file.GetFileType () == FileSpec::eFileTypeDirectory)
-    {
-        char path[PATH_MAX];
-        if (file.GetPath(path, sizeof(path)))
-        {
-            CFCBundle bundle (path);
-            if (bundle.GetPath (path, sizeof(path)))
-            {
-                bundle_directory.SetFile (path, false);
-                return true;
-            }
-        }
+bool Host::GetBundleDirectory(const FileSpec &file,
+                              FileSpec &bundle_directory) {
+#if defined(__APPLE__)
+  if (file.GetFileType() == FileSpec::eFileTypeDirectory) {
+    char path[PATH_MAX];
+    if (file.GetPath(path, sizeof(path))) {
+      CFCBundle bundle(path);
+      if (bundle.GetPath(path, sizeof(path))) {
+        bundle_directory.SetFile(path, false);
+        return true;
+      }
     }
+  }
 #endif
-    bundle_directory.Clear();
-    return false;
+  bundle_directory.Clear();
+  return false;
 }
 
-
-bool
-Host::ResolveExecutableInBundle (FileSpec &file)
-{
-#if defined (__APPLE__)
-    if (file.GetFileType () == FileSpec::eFileTypeDirectory)
-    {
-        char path[PATH_MAX];
-        if (file.GetPath(path, sizeof(path)))
-        {
-            CFCBundle bundle (path);
-            CFCReleaser<CFURLRef> url(bundle.CopyExecutableURL ());
-            if (url.get())
-            {
-                if (::CFURLGetFileSystemRepresentation (url.get(), YES, (UInt8*)path, sizeof(path)))
-                {
-                    file.SetFile(path, false);
-                    return true;
-                }
-            }
+bool Host::ResolveExecutableInBundle(FileSpec &file) {
+#if defined(__APPLE__)
+  if (file.GetFileType() == FileSpec::eFileTypeDirectory) {
+    char path[PATH_MAX];
+    if (file.GetPath(path, sizeof(path))) {
+      CFCBundle bundle(path);
+      CFCReleaser<CFURLRef> url(bundle.CopyExecutableURL());
+      if (url.get()) {
+        if (::CFURLGetFileSystemRepresentation(url.get(), YES, (UInt8 *)path,
+                                               sizeof(path))) {
+          file.SetFile(path, false);
+          return true;
         }
+      }
     }
+  }
 #endif
   return false;
 }
 
-static void *
-AcceptPIDFromInferior (void *arg)
-{
-    const char *connect_url = (const char *)arg;
-    ConnectionFileDescriptor file_conn;
-    Error error;
-    if (file_conn.Connect (connect_url, &error) == eConnectionStatusSuccess)
-    {
-        char pid_str[256];
-        ::memset (pid_str, 0, sizeof(pid_str));
-        ConnectionStatus status;
-        const size_t pid_str_len = file_conn.Read (pid_str, sizeof(pid_str), 0, status, NULL);
-        if (pid_str_len > 0)
-        {
-            int pid = atoi (pid_str);
-            return (void *)(intptr_t)pid;
-        }
-    }
-    return NULL;
-}
+static void *AcceptPIDFromInferior(void *arg) {
+  const char *connect_url = (const char *)arg;
+  ConnectionFileDescriptor file_conn;
+  Error error;
+  if (file_conn.Connect(connect_url, &error) == eConnectionStatusSuccess) {
+    char pid_str[256];
+    ::memset(pid_str, 0, sizeof(pid_str));
+    ConnectionStatus status;
+    const size_t pid_str_len =
+        file_conn.Read(pid_str, sizeof(pid_str), 0, status, NULL);
+    if (pid_str_len > 0) {
+      int pid = atoi(pid_str);
+      return (void *)(intptr_t)pid;
+    }
+  }
+  return NULL;
+}
+
+static bool WaitForProcessToSIGSTOP(const lldb::pid_t pid,
+                                    const int timeout_in_seconds) {
+  const int time_delta_usecs = 100000;
+  const int num_retries = timeout_in_seconds / time_delta_usecs;
+  for (int i = 0; i < num_retries; i++) {
+    struct proc_bsdinfo bsd_info;
+    int error = ::proc_pidinfo(pid, PROC_PIDTBSDINFO, (uint64_t)0, &bsd_info,
+                               PROC_PIDTBSDINFO_SIZE);
+
+    switch (error) {
+    case EINVAL:
+    case ENOTSUP:
+    case ESRCH:
+    case EPERM:
+      return false;
 
-static bool
-WaitForProcessToSIGSTOP (const lldb::pid_t pid, const int timeout_in_seconds)
-{
-    const int time_delta_usecs = 100000;
-    const int num_retries = timeout_in_seconds/time_delta_usecs;
-    for (int i=0; i<num_retries; i++)
-    {
-        struct proc_bsdinfo bsd_info;
-        int error = ::proc_pidinfo (pid, PROC_PIDTBSDINFO, 
-                                    (uint64_t) 0, 
-                                    &bsd_info, 
-                                    PROC_PIDTBSDINFO_SIZE);
-        
-        switch (error)
-        {
-        case EINVAL:
-        case ENOTSUP:
-        case ESRCH:
-        case EPERM:
-            return false;
-        
-        default:
-            break;
-
-        case 0:
-            if (bsd_info.pbi_status == SSTOP)
-                return true;
-        }
-        ::usleep (time_delta_usecs);
+    default:
+      break;
+
+    case 0:
+      if (bsd_info.pbi_status == SSTOP)
+        return true;
     }
-    return false;
+    ::usleep(time_delta_usecs);
+  }
+  return false;
 }
 #if !defined(__arm__) && !defined(__arm64__) && !defined(__aarch64__)
 
-//static lldb::pid_t
-//LaunchInNewTerminalWithCommandFile 
+// static lldb::pid_t
+// LaunchInNewTerminalWithCommandFile
 //(
-//    const char **argv, 
+//    const char **argv,
 //    const char **envp,
 //    const char *working_dir,
 //    const ArchSpec *arch_spec,
@@ -216,18 +198,19 @@ WaitForProcessToSIGSTOP (const lldb::pid
 //        return LLDB_INVALID_PROCESS_ID;
 //
 //    OSStatus error = 0;
-//    
+//
 //    FileSpec program (argv[0], false);
-//    
-//    
+//
+//
 //    std::string unix_socket_name;
 //
 //    char temp_file_path[PATH_MAX];
 //    const char *tmpdir = ::getenv ("TMPDIR");
 //    if (tmpdir == NULL)
 //        tmpdir = "/tmp/";
-//    ::snprintf (temp_file_path, sizeof(temp_file_path), "%s%s-XXXXXX", tmpdir, program.GetFilename().AsCString());
-//    
+//    ::snprintf (temp_file_path, sizeof(temp_file_path), "%s%s-XXXXXX", tmpdir,
+//    program.GetFilename().AsCString());
+//
 //    if (::mktemp (temp_file_path) == NULL)
 //        return LLDB_INVALID_PROCESS_ID;
 //
@@ -236,15 +219,17 @@ WaitForProcessToSIGSTOP (const lldb::pid
 //    ::strlcat (temp_file_path, ".command", sizeof (temp_file_path));
 //
 //    StreamFile command_file;
-//    command_file.GetFile().Open (temp_file_path, 
-//                                 File::eOpenOptionWrite | File::eOpenOptionCanCreate,
+//    command_file.GetFile().Open (temp_file_path,
+//                                 File::eOpenOptionWrite |
+//                                 File::eOpenOptionCanCreate,
 //                                 lldb::eFilePermissionsDefault);
-//    
+//
 //    if (!command_file.GetFile().IsValid())
 //        return LLDB_INVALID_PROCESS_ID;
-//    
+//
 //    FileSpec darwin_debug_file_spec;
-//    if (!HostInfo::GetLLDBPath (ePathTypeSupportExecutableDir, darwin_debug_file_spec))
+//    if (!HostInfo::GetLLDBPath (ePathTypeSupportExecutableDir,
+//    darwin_debug_file_spec))
 //        return LLDB_INVALID_PROCESS_ID;
 //    darwin_debug_file_spec.GetFilename().SetCString("darwin-debug");
 //
@@ -296,7 +281,8 @@ WaitForProcessToSIGSTOP (const lldb::pid
 //                std::string env_val (equal_pos + 1);
 //                CFCString cf_env_key (env_key.c_str(), kCFStringEncodingUTF8);
 //                CFCString cf_env_val (env_val.c_str(), kCFStringEncodingUTF8);
-//                cf_env_dict.AddValue (cf_env_key.get(), cf_env_val.get(), can_create);
+//                cf_env_dict.AddValue (cf_env_key.get(), cf_env_val.get(),
+//                can_create);
 //            }
 //        }
 //    }
@@ -307,7 +293,8 @@ WaitForProcessToSIGSTOP (const lldb::pid
 //    app_params.argv = NULL;
 //    app_params.environment = (CFDictionaryRef)cf_env_dict.get();
 //
-//    CFCReleaser<CFURLRef> command_file_url (::CFURLCreateFromFileSystemRepresentation (NULL,
+//    CFCReleaser<CFURLRef> command_file_url
+//    (::CFURLCreateFromFileSystemRepresentation (NULL,
 //                                                                                       (const UInt8 *)temp_file_path,
 //                                                                                       strlen(temp_file_path),
 //                                                                                       false));
@@ -325,28 +312,33 @@ WaitForProcessToSIGSTOP (const lldb::pid
 //    Error lldb_error;
 //    // Sleep and wait a bit for debugserver to start to listen...
 //    char connect_url[128];
-//    ::snprintf (connect_url, sizeof(connect_url), "unix-accept://%s", unix_socket_name.c_str());
+//    ::snprintf (connect_url, sizeof(connect_url), "unix-accept://%s",
+//    unix_socket_name.c_str());
 //
 //    // Spawn a new thread to accept incoming connection on the connect_url
 //    // so we can grab the pid from the inferior
-//    lldb::thread_t accept_thread = Host::ThreadCreate (unix_socket_name.c_str(),
+//    lldb::thread_t accept_thread = Host::ThreadCreate
+//    (unix_socket_name.c_str(),
 //                                                       AcceptPIDFromInferior,
 //                                                       connect_url,
 //                                                       &lldb_error);
 //
 //    ProcessSerialNumber psn;
-//    error = LSOpenURLsWithRole(urls.get(), kLSRolesShell, NULL, &app_params, &psn, 1);
+//    error = LSOpenURLsWithRole(urls.get(), kLSRolesShell, NULL, &app_params,
+//    &psn, 1);
 //    if (error == noErr)
 //    {
 //        thread_result_t accept_thread_result = NULL;
-//        if (Host::ThreadJoin (accept_thread, &accept_thread_result, &lldb_error))
+//        if (Host::ThreadJoin (accept_thread, &accept_thread_result,
+//        &lldb_error))
 //        {
 //            if (accept_thread_result)
 //            {
 //                pid = (intptr_t)accept_thread_result;
 //
 //                // Wait for process to be stopped the entry point by watching
-//                // for the process status to be set to SSTOP which indicates it it
+//                // for the process status to be set to SSTOP which indicates
+//                it it
 //                // SIGSTOP'ed at the entry point
 //                WaitForProcessToSIGSTOP (pid, 5);
 //            }
@@ -360,12 +352,10 @@ WaitForProcessToSIGSTOP (const lldb::pid
 //    return pid;
 //}
 
-const char *applscript_in_new_tty = 
-"tell application \"Terminal\"\n"
-"   activate\n"
-"	do script \"%s\"\n"
-"end tell\n";
-
+const char *applscript_in_new_tty = "tell application \"Terminal\"\n"
+                                    "   activate\n"
+                                    "	do script \"%s\"\n"
+                                    "end tell\n";
 
 const char *applscript_in_existing_tty = "\
 set the_shell_script to \"%s\"\n\
@@ -386,1202 +376,1128 @@ tell application \"Terminal\"\n\
 	do script the_shell_script\n\
 end tell\n";
 
-
 static Error
-LaunchInNewTerminalWithAppleScript (const char *exe_path, ProcessLaunchInfo &launch_info)
-{
-    Error error;
-    char unix_socket_name[PATH_MAX] = "/tmp/XXXXXX";    
-    if (::mktemp (unix_socket_name) == NULL)
-    {
-        error.SetErrorString ("failed to make temporary path for a unix socket");
-        return error;
-    }
-    
-    StreamString command;
-    FileSpec darwin_debug_file_spec;
-    if (!HostInfo::GetLLDBPath(ePathTypeSupportExecutableDir, darwin_debug_file_spec))
-    {
-        error.SetErrorString ("can't locate the 'darwin-debug' executable");
-        return error;
-    }
-
-    darwin_debug_file_spec.GetFilename().SetCString("darwin-debug");
-        
-    if (!darwin_debug_file_spec.Exists())
-    {
-        error.SetErrorStringWithFormat ("the 'darwin-debug' executable doesn't exists at '%s'", 
-                                        darwin_debug_file_spec.GetPath().c_str());
-        return error;
-    }
-    
-    char launcher_path[PATH_MAX];
-    darwin_debug_file_spec.GetPath(launcher_path, sizeof(launcher_path));
-
-    const ArchSpec &arch_spec = launch_info.GetArchitecture();
-    // Only set the architecture if it is valid and if it isn't Haswell (x86_64h).
-    if (arch_spec.IsValid() && arch_spec.GetCore() != ArchSpec::eCore_x86_64_x86_64h)
-        command.Printf("arch -arch %s ", arch_spec.GetArchitectureName());
-
-    command.Printf("'%s' --unix-socket=%s", launcher_path, unix_socket_name);
-
-    if (arch_spec.IsValid())
-        command.Printf(" --arch=%s", arch_spec.GetArchitectureName());
-
-    FileSpec working_dir{launch_info.GetWorkingDirectory()};
-    if (working_dir)
-        command.Printf(" --working-dir '%s'", working_dir.GetCString());
-    else
-    {
-        char cwd[PATH_MAX];
-        if (getcwd(cwd, PATH_MAX))
-            command.Printf(" --working-dir '%s'", cwd);
-    }
-    
-    if (launch_info.GetFlags().Test (eLaunchFlagDisableASLR))
-        command.PutCString(" --disable-aslr");
-    
-    // We are launching on this host in a terminal. So compare the environment on the host
-    // to what is supplied in the launch_info. Any items that aren't in the host environment
-    // need to be sent to darwin-debug. If we send all environment entries, we might blow the
-    // max command line length, so we only send user modified entries.
-    const char **envp = launch_info.GetEnvironmentEntries().GetConstArgumentVector ();
-
-    StringList host_env;
-    const size_t host_env_count = Host::GetEnvironment (host_env);
-
-    if (envp && envp[0])
-    {
-        const char *env_entry;
-        for (size_t env_idx = 0; (env_entry = envp[env_idx]) != NULL; ++env_idx)
-        {
-            bool add_entry = true;
-            for (size_t i=0; i<host_env_count; ++i)
-            {
-                const char *host_env_entry = host_env.GetStringAtIndex(i);
-                if (strcmp(env_entry, host_env_entry) == 0)
-                {
-                    add_entry = false;
-                    break;
-                }
-            }
-            if (add_entry)
-            {
-                command.Printf(" --env='%s'", env_entry);
-            }
-        }
-    }
+LaunchInNewTerminalWithAppleScript(const char *exe_path,
+                                   ProcessLaunchInfo &launch_info) {
+  Error error;
+  char unix_socket_name[PATH_MAX] = "/tmp/XXXXXX";
+  if (::mktemp(unix_socket_name) == NULL) {
+    error.SetErrorString("failed to make temporary path for a unix socket");
+    return error;
+  }
 
-    command.PutCString(" -- ");
+  StreamString command;
+  FileSpec darwin_debug_file_spec;
+  if (!HostInfo::GetLLDBPath(ePathTypeSupportExecutableDir,
+                             darwin_debug_file_spec)) {
+    error.SetErrorString("can't locate the 'darwin-debug' executable");
+    return error;
+  }
 
-    const char **argv = launch_info.GetArguments().GetConstArgumentVector ();
-    if (argv)
-    {
-        for (size_t i=0; argv[i] != NULL; ++i)
-        {
-            if (i==0)
-                command.Printf(" '%s'", exe_path);
-            else
-                command.Printf(" '%s'", argv[i]);
-        }
-    }
-    else
-    {
-        command.Printf(" '%s'", exe_path);
-    }
-    command.PutCString (" ; echo Process exited with status $?");
-    if (launch_info.GetFlags().Test(lldb::eLaunchFlagCloseTTYOnExit))
-        command.PutCString (" ; exit");
-    
-    StreamString applescript_source;
+  darwin_debug_file_spec.GetFilename().SetCString("darwin-debug");
 
-    const char *tty_command = command.GetString().c_str();
-//    if (tty_name && tty_name[0])
-//    {
-//        applescript_source.Printf (applscript_in_existing_tty, 
-//                                   tty_command,
-//                                   tty_name);
-//    }
-//    else
-//    {
-        applescript_source.Printf (applscript_in_new_tty, 
-                                   tty_command);
-//    }
+  if (!darwin_debug_file_spec.Exists()) {
+    error.SetErrorStringWithFormat(
+        "the 'darwin-debug' executable doesn't exists at '%s'",
+        darwin_debug_file_spec.GetPath().c_str());
+    return error;
+  }
 
-    
+  char launcher_path[PATH_MAX];
+  darwin_debug_file_spec.GetPath(launcher_path, sizeof(launcher_path));
 
-    const char *script_source = applescript_source.GetString().c_str();
-    //puts (script_source);
-    NSAppleScript* applescript = [[NSAppleScript alloc] initWithSource:[NSString stringWithCString:script_source encoding:NSUTF8StringEncoding]];
-
-    lldb::pid_t pid = LLDB_INVALID_PROCESS_ID;
-
-    Error lldb_error;
-    // Sleep and wait a bit for debugserver to start to listen...
-    ConnectionFileDescriptor file_conn;
-    char connect_url[128];
-    ::snprintf (connect_url, sizeof(connect_url), "unix-accept://%s", unix_socket_name);
-
-    // Spawn a new thread to accept incoming connection on the connect_url
-    // so we can grab the pid from the inferior. We have to do this because we
-    // are sending an AppleScript that will launch a process in Terminal.app,
-    // in a shell and the shell will fork/exec a couple of times before we get
-    // to the process that we wanted to launch. So when our process actually
-    // gets launched, we will handshake with it and get the process ID for it.
-    HostThread accept_thread = ThreadLauncher::LaunchThread(unix_socket_name, AcceptPIDFromInferior, connect_url, &lldb_error);
-
-    [applescript executeAndReturnError:nil];
-    
-    thread_result_t accept_thread_result = NULL;
-    lldb_error = accept_thread.Join(&accept_thread_result);
-    if (lldb_error.Success() && accept_thread_result)
-    {
-        pid = (intptr_t)accept_thread_result;
-
-        // Wait for process to be stopped at the entry point by watching
-        // for the process status to be set to SSTOP which indicates it it
-        // SIGSTOP'ed at the entry point
-        WaitForProcessToSIGSTOP(pid, 5);
-    }
-
-    FileSystem::Unlink(FileSpec{unix_socket_name, false});
-    [applescript release];
-    if (pid != LLDB_INVALID_PROCESS_ID)
-        launch_info.SetProcessID (pid);
-    return error;
+  const ArchSpec &arch_spec = launch_info.GetArchitecture();
+  // Only set the architecture if it is valid and if it isn't Haswell (x86_64h).
+  if (arch_spec.IsValid() &&
+      arch_spec.GetCore() != ArchSpec::eCore_x86_64_x86_64h)
+    command.Printf("arch -arch %s ", arch_spec.GetArchitectureName());
+
+  command.Printf("'%s' --unix-socket=%s", launcher_path, unix_socket_name);
+
+  if (arch_spec.IsValid())
+    command.Printf(" --arch=%s", arch_spec.GetArchitectureName());
+
+  FileSpec working_dir{launch_info.GetWorkingDirectory()};
+  if (working_dir)
+    command.Printf(" --working-dir '%s'", working_dir.GetCString());
+  else {
+    char cwd[PATH_MAX];
+    if (getcwd(cwd, PATH_MAX))
+      command.Printf(" --working-dir '%s'", cwd);
+  }
+
+  if (launch_info.GetFlags().Test(eLaunchFlagDisableASLR))
+    command.PutCString(" --disable-aslr");
+
+  // We are launching on this host in a terminal. So compare the environment on
+  // the host
+  // to what is supplied in the launch_info. Any items that aren't in the host
+  // environment
+  // need to be sent to darwin-debug. If we send all environment entries, we
+  // might blow the
+  // max command line length, so we only send user modified entries.
+  const char **envp =
+      launch_info.GetEnvironmentEntries().GetConstArgumentVector();
+
+  StringList host_env;
+  const size_t host_env_count = Host::GetEnvironment(host_env);
+
+  if (envp && envp[0]) {
+    const char *env_entry;
+    for (size_t env_idx = 0; (env_entry = envp[env_idx]) != NULL; ++env_idx) {
+      bool add_entry = true;
+      for (size_t i = 0; i < host_env_count; ++i) {
+        const char *host_env_entry = host_env.GetStringAtIndex(i);
+        if (strcmp(env_entry, host_env_entry) == 0) {
+          add_entry = false;
+          break;
+        }
+      }
+      if (add_entry) {
+        command.Printf(" --env='%s'", env_entry);
+      }
+    }
+  }
+
+  command.PutCString(" -- ");
+
+  const char **argv = launch_info.GetArguments().GetConstArgumentVector();
+  if (argv) {
+    for (size_t i = 0; argv[i] != NULL; ++i) {
+      if (i == 0)
+        command.Printf(" '%s'", exe_path);
+      else
+        command.Printf(" '%s'", argv[i]);
+    }
+  } else {
+    command.Printf(" '%s'", exe_path);
+  }
+  command.PutCString(" ; echo Process exited with status $?");
+  if (launch_info.GetFlags().Test(lldb::eLaunchFlagCloseTTYOnExit))
+    command.PutCString(" ; exit");
+
+  StreamString applescript_source;
+
+  const char *tty_command = command.GetString().c_str();
+  //    if (tty_name && tty_name[0])
+  //    {
+  //        applescript_source.Printf (applscript_in_existing_tty,
+  //                                   tty_command,
+  //                                   tty_name);
+  //    }
+  //    else
+  //    {
+  applescript_source.Printf(applscript_in_new_tty, tty_command);
+  //    }
+
+  const char *script_source = applescript_source.GetString().c_str();
+  // puts (script_source);
+  NSAppleScript *applescript = [[NSAppleScript alloc]
+      initWithSource:[NSString stringWithCString:script_source
+                                        encoding:NSUTF8StringEncoding]];
+
+  lldb::pid_t pid = LLDB_INVALID_PROCESS_ID;
+
+  Error lldb_error;
+  // Sleep and wait a bit for debugserver to start to listen...
+  ConnectionFileDescriptor file_conn;
+  char connect_url[128];
+  ::snprintf(connect_url, sizeof(connect_url), "unix-accept://%s",
+             unix_socket_name);
+
+  // Spawn a new thread to accept incoming connection on the connect_url
+  // so we can grab the pid from the inferior. We have to do this because we
+  // are sending an AppleScript that will launch a process in Terminal.app,
+  // in a shell and the shell will fork/exec a couple of times before we get
+  // to the process that we wanted to launch. So when our process actually
+  // gets launched, we will handshake with it and get the process ID for it.
+  HostThread accept_thread = ThreadLauncher::LaunchThread(
+      unix_socket_name, AcceptPIDFromInferior, connect_url, &lldb_error);
+
+  [applescript executeAndReturnError:nil];
+
+  thread_result_t accept_thread_result = NULL;
+  lldb_error = accept_thread.Join(&accept_thread_result);
+  if (lldb_error.Success() && accept_thread_result) {
+    pid = (intptr_t)accept_thread_result;
+
+    // Wait for process to be stopped at the entry point by watching
+    // for the process status to be set to SSTOP which indicates it it
+    // SIGSTOP'ed at the entry point
+    WaitForProcessToSIGSTOP(pid, 5);
+  }
+
+  FileSystem::Unlink(FileSpec{unix_socket_name, false});
+  [applescript release];
+  if (pid != LLDB_INVALID_PROCESS_ID)
+    launch_info.SetProcessID(pid);
+  return error;
 }
 
 #endif // #if !defined(__arm__) && !defined(__arm64__) && !defined(__aarch64__)
 
-
 // On MacOSX CrashReporter will display a string for each shared library if
 // the shared library has an exported symbol named "__crashreporter_info__".
 
-static std::mutex &
-GetCrashReporterMutex()
-{
-    static std::mutex g_mutex;
-    return g_mutex;
+static std::mutex &GetCrashReporterMutex() {
+  static std::mutex g_mutex;
+  return g_mutex;
 }
 
 extern "C" {
-    const char *__crashreporter_info__ = NULL;
+const char *__crashreporter_info__ = NULL;
 }
 
 asm(".desc ___crashreporter_info__, 0x10");
 
-void
-Host::SetCrashDescriptionWithFormat (const char *format, ...)
-{
-    static StreamString g_crash_description;
-    std::lock_guard<std::mutex> guard(GetCrashReporterMutex());
-
-    if (format)
-    {
-        va_list args;
-        va_start (args, format);
-        g_crash_description.GetString().clear();
-        g_crash_description.PrintfVarArg(format, args);
-        va_end (args);
-        __crashreporter_info__ = g_crash_description.GetData();
-    }
-    else
-    {
-        __crashreporter_info__ = NULL;
-    }
+void Host::SetCrashDescriptionWithFormat(const char *format, ...) {
+  static StreamString g_crash_description;
+  std::lock_guard<std::mutex> guard(GetCrashReporterMutex());
+
+  if (format) {
+    va_list args;
+    va_start(args, format);
+    g_crash_description.GetString().clear();
+    g_crash_description.PrintfVarArg(format, args);
+    va_end(args);
+    __crashreporter_info__ = g_crash_description.GetData();
+  } else {
+    __crashreporter_info__ = NULL;
+  }
+}
+
+void Host::SetCrashDescription(const char *cstr) {
+  std::lock_guard<std::mutex> guard(GetCrashReporterMutex());
+  static std::string g_crash_description;
+  if (cstr) {
+    g_crash_description.assign(cstr);
+    __crashreporter_info__ = g_crash_description.c_str();
+  } else {
+    __crashreporter_info__ = NULL;
+  }
 }
 
-void
-Host::SetCrashDescription (const char *cstr)
-{
-    std::lock_guard<std::mutex> guard(GetCrashReporterMutex());
-    static std::string g_crash_description;
-    if (cstr)
-    {
-        g_crash_description.assign (cstr);
-        __crashreporter_info__ = g_crash_description.c_str();
-    }
-    else
-    {
-        __crashreporter_info__ = NULL;
-    }
-}
-
-bool
-Host::OpenFileInExternalEditor (const FileSpec &file_spec, uint32_t line_no)
-{
+bool Host::OpenFileInExternalEditor(const FileSpec &file_spec,
+                                    uint32_t line_no) {
 #if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
-    return false;
+  return false;
 #else
-    // We attach this to an 'odoc' event to specify a particular selection
-    typedef struct {
-        int16_t   reserved0;  // must be zero
-        int16_t   fLineNumber;
-        int32_t   fSelStart;
-        int32_t   fSelEnd;
-        uint32_t  reserved1;  // must be zero
-        uint32_t  reserved2;  // must be zero
-    } BabelAESelInfo;
-    
-    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_HOST));
-    char file_path[PATH_MAX];
-    file_spec.GetPath(file_path, PATH_MAX);
-    CFCString file_cfstr (file_path, kCFStringEncodingUTF8);
-    CFCReleaser<CFURLRef> file_URL (::CFURLCreateWithFileSystemPath (NULL, 
-                                                                     file_cfstr.get(), 
-                                                                     kCFURLPOSIXPathStyle, 
-                                                                     false));
-                                                                     
+  // We attach this to an 'odoc' event to specify a particular selection
+  typedef struct {
+    int16_t reserved0; // must be zero
+    int16_t fLineNumber;
+    int32_t fSelStart;
+    int32_t fSelEnd;
+    uint32_t reserved1; // must be zero
+    uint32_t reserved2; // must be zero
+  } BabelAESelInfo;
+
+  Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_HOST));
+  char file_path[PATH_MAX];
+  file_spec.GetPath(file_path, PATH_MAX);
+  CFCString file_cfstr(file_path, kCFStringEncodingUTF8);
+  CFCReleaser<CFURLRef> file_URL(::CFURLCreateWithFileSystemPath(
+      NULL, file_cfstr.get(), kCFURLPOSIXPathStyle, false));
+
+  if (log)
+    log->Printf(
+        "Sending source file: \"%s\" and line: %d to external editor.\n",
+        file_path, line_no);
+
+  long error;
+  BabelAESelInfo file_and_line_info = {
+      0,                      // reserved0
+      (int16_t)(line_no - 1), // fLineNumber (zero based line number)
+      1,                      // fSelStart
+      1024,                   // fSelEnd
+      0,                      // reserved1
+      0                       // reserved2
+  };
+
+  AEKeyDesc file_and_line_desc;
+
+  error = ::AECreateDesc(typeUTF8Text, &file_and_line_info,
+                         sizeof(file_and_line_info),
+                         &(file_and_line_desc.descContent));
+
+  if (error != noErr) {
     if (log)
-        log->Printf("Sending source file: \"%s\" and line: %d to external editor.\n", file_path, line_no);
-    
-    long error;	
-    BabelAESelInfo file_and_line_info = 
-    {
-        0,                         // reserved0
-        (int16_t)(line_no - 1),    // fLineNumber (zero based line number)
-        1,                         // fSelStart
-        1024,                      // fSelEnd
-        0,                         // reserved1
-        0                          // reserved2
-    };
+      log->Printf("Error creating AEDesc: %ld.\n", error);
+    return false;
+  }
+
+  file_and_line_desc.descKey = keyAEPosition;
+
+  static std::string g_app_name;
+  static FSRef g_app_fsref;
+
+  LSApplicationParameters app_params;
+  ::memset(&app_params, 0, sizeof(app_params));
+  app_params.flags =
+      kLSLaunchDefaults | kLSLaunchDontAddToRecents | kLSLaunchDontSwitch;
+
+  char *external_editor = ::getenv("LLDB_EXTERNAL_EDITOR");
 
-    AEKeyDesc file_and_line_desc;
-    
-    error = ::AECreateDesc (typeUTF8Text, 
-                            &file_and_line_info, 
-                            sizeof (file_and_line_info), 
-                            &(file_and_line_desc.descContent));
-    
-    if (error != noErr)
-    {
+  if (external_editor) {
+    if (log)
+      log->Printf("Looking for external editor \"%s\".\n", external_editor);
+
+    if (g_app_name.empty() ||
+        strcmp(g_app_name.c_str(), external_editor) != 0) {
+      CFCString editor_name(external_editor, kCFStringEncodingUTF8);
+      error = ::LSFindApplicationForInfo(kLSUnknownCreator, NULL,
+                                         editor_name.get(), &g_app_fsref, NULL);
+
+      // If we found the app, then store away the name so we don't have to
+      // re-look it up.
+      if (error != noErr) {
         if (log)
-            log->Printf("Error creating AEDesc: %ld.\n", error);
+          log->Printf(
+              "Could not find External Editor application, error: %ld.\n",
+              error);
         return false;
+      }
     }
-    
-    file_and_line_desc.descKey = keyAEPosition;
-    
-    static std::string g_app_name;
-    static FSRef g_app_fsref;
-
-    LSApplicationParameters app_params;
-    ::memset (&app_params, 0, sizeof (app_params));
-    app_params.flags = kLSLaunchDefaults | 
-                       kLSLaunchDontAddToRecents | 
-                       kLSLaunchDontSwitch;
-    
-    char *external_editor = ::getenv ("LLDB_EXTERNAL_EDITOR");
-    
-    if (external_editor)
-    {
-        if (log)
-            log->Printf("Looking for external editor \"%s\".\n", external_editor);
+    app_params.application = &g_app_fsref;
+  }
 
-        if (g_app_name.empty() || strcmp (g_app_name.c_str(), external_editor) != 0)
-        {
-            CFCString editor_name (external_editor, kCFStringEncodingUTF8);
-            error = ::LSFindApplicationForInfo (kLSUnknownCreator, 
-                                                NULL, 
-                                                editor_name.get(), 
-                                                &g_app_fsref, 
-                                                NULL);
-            
-            // If we found the app, then store away the name so we don't have to re-look it up.
-            if (error != noErr)
-            {
-                if (log)
-                    log->Printf("Could not find External Editor application, error: %ld.\n", error);
-                return false;
-            }
-                
-        }
-        app_params.application = &g_app_fsref;
-    }
+  ProcessSerialNumber psn;
+  CFCReleaser<CFArrayRef> file_array(
+      CFArrayCreate(NULL, (const void **)file_URL.ptr_address(false), 1, NULL));
+  error = ::LSOpenURLsWithRole(file_array.get(), kLSRolesAll,
+                               &file_and_line_desc, &app_params, &psn, 1);
 
-    ProcessSerialNumber psn;
-    CFCReleaser<CFArrayRef> file_array(CFArrayCreate (NULL, (const void **) file_URL.ptr_address(false), 1, NULL));
-    error = ::LSOpenURLsWithRole (file_array.get(), 
-                                  kLSRolesAll, 
-                                  &file_and_line_desc, 
-                                  &app_params, 
-                                  &psn, 
-                                  1);
-    
-    AEDisposeDesc (&(file_and_line_desc.descContent));
+  AEDisposeDesc(&(file_and_line_desc.descContent));
 
-    if (error != noErr)
-    {
-        if (log)
-            log->Printf("LSOpenURLsWithRole failed, error: %ld.\n", error);
+  if (error != noErr) {
+    if (log)
+      log->Printf("LSOpenURLsWithRole failed, error: %ld.\n", error);
 
-        return false;
-    }
+    return false;
+  }
 
-    return true;
+  return true;
 #endif // #if !defined(__arm__) && !defined(__arm64__) && !defined(__aarch64__)
 }
 
-size_t
-Host::GetEnvironment (StringList &env)
-{
-    char **host_env = *_NSGetEnviron();
-    char *env_entry;
-    size_t i;
-    for (i=0; (env_entry = host_env[i]) != NULL; ++i)
-        env.AppendString(env_entry);
-    return i;
-        
-}
-
-static bool
-GetMacOSXProcessCPUType (ProcessInstanceInfo &process_info)
-{
-    if (process_info.ProcessIDIsValid())
-    {
-        // Make a new mib to stay thread safe
-        int mib[CTL_MAXNAME]={0,};
-        size_t mib_len = CTL_MAXNAME;
-        if (::sysctlnametomib("sysctl.proc_cputype", mib, &mib_len)) 
-            return false;
-    
-        mib[mib_len] = process_info.GetProcessID();
-        mib_len++;
-
-        cpu_type_t cpu, sub = 0;
-        size_t len = sizeof(cpu);
-        if (::sysctl (mib, mib_len, &cpu, &len, 0, 0) == 0)
-        {
-            switch (cpu)
-            {
-                case CPU_TYPE_I386:      sub = CPU_SUBTYPE_I386_ALL;     break;
-                case CPU_TYPE_X86_64:    sub = CPU_SUBTYPE_X86_64_ALL;   break;
+size_t Host::GetEnvironment(StringList &env) {
+  char **host_env = *_NSGetEnviron();
+  char *env_entry;
+  size_t i;
+  for (i = 0; (env_entry = host_env[i]) != NULL; ++i)
+    env.AppendString(env_entry);
+  return i;
+}
 
-#if defined (CPU_TYPE_ARM64) && defined (CPU_SUBTYPE_ARM64_ALL)
-                case CPU_TYPE_ARM64:     sub = CPU_SUBTYPE_ARM64_ALL;      break;
+static bool GetMacOSXProcessCPUType(ProcessInstanceInfo &process_info) {
+  if (process_info.ProcessIDIsValid()) {
+    // Make a new mib to stay thread safe
+    int mib[CTL_MAXNAME] = {
+        0,
+    };
+    size_t mib_len = CTL_MAXNAME;
+    if (::sysctlnametomib("sysctl.proc_cputype", mib, &mib_len))
+      return false;
+
+    mib[mib_len] = process_info.GetProcessID();
+    mib_len++;
+
+    cpu_type_t cpu, sub = 0;
+    size_t len = sizeof(cpu);
+    if (::sysctl(mib, mib_len, &cpu, &len, 0, 0) == 0) {
+      switch (cpu) {
+      case CPU_TYPE_I386:
+        sub = CPU_SUBTYPE_I386_ALL;
+        break;
+      case CPU_TYPE_X86_64:
+        sub = CPU_SUBTYPE_X86_64_ALL;
+        break;
+
+#if defined(CPU_TYPE_ARM64) && defined(CPU_SUBTYPE_ARM64_ALL)
+      case CPU_TYPE_ARM64:
+        sub = CPU_SUBTYPE_ARM64_ALL;
+        break;
 #endif
 
-                case CPU_TYPE_ARM:
-                    {
-                        // Note that we fetched the cpu type from the PROCESS but we can't get a cpusubtype of the 
-                        // process -- we can only get the host's cpu subtype.
-                        uint32_t cpusubtype = 0;
-                        len = sizeof(cpusubtype);
-                        if (::sysctlbyname("hw.cpusubtype", &cpusubtype, &len, NULL, 0) == 0)
-                            sub = cpusubtype;
-
-                        bool host_cpu_is_64bit;
-                        uint32_t is64bit_capable;
-                        size_t is64bit_capable_len = sizeof (is64bit_capable);
-                        if (sysctlbyname("hw.cpu64bit_capable", &is64bit_capable, &is64bit_capable_len, NULL, 0) == 0)
-                            host_cpu_is_64bit = true;
-                        else
-                            host_cpu_is_64bit = false;
-
-                        // if the host is an armv8 device, its cpusubtype will be in CPU_SUBTYPE_ARM64 numbering
-                        // and we need to rewrite it to a reasonable CPU_SUBTYPE_ARM value instead.
-
-                        if (host_cpu_is_64bit)
-                        {
-                            sub = CPU_SUBTYPE_ARM_V7;
-                        }
-                    }
-                    break;
+      case CPU_TYPE_ARM: {
+        // Note that we fetched the cpu type from the PROCESS but we can't get a
+        // cpusubtype of the
+        // process -- we can only get the host's cpu subtype.
+        uint32_t cpusubtype = 0;
+        len = sizeof(cpusubtype);
+        if (::sysctlbyname("hw.cpusubtype", &cpusubtype, &len, NULL, 0) == 0)
+          sub = cpusubtype;
+
+        bool host_cpu_is_64bit;
+        uint32_t is64bit_capable;
+        size_t is64bit_capable_len = sizeof(is64bit_capable);
+        if (sysctlbyname("hw.cpu64bit_capable", &is64bit_capable,
+                         &is64bit_capable_len, NULL, 0) == 0)
+          host_cpu_is_64bit = true;
+        else
+          host_cpu_is_64bit = false;
 
-                default:
-                    break;
-            }
-            process_info.GetArchitecture ().SetArchitecture (eArchTypeMachO, cpu, sub);
-            return true;
-        }
+        // if the host is an armv8 device, its cpusubtype will be in
+        // CPU_SUBTYPE_ARM64 numbering
+        // and we need to rewrite it to a reasonable CPU_SUBTYPE_ARM value
+        // instead.
+
+        if (host_cpu_is_64bit) {
+          sub = CPU_SUBTYPE_ARM_V7;
+        }
+      } break;
+
+      default:
+        break;
+      }
+      process_info.GetArchitecture().SetArchitecture(eArchTypeMachO, cpu, sub);
+      return true;
     }
-    process_info.GetArchitecture().Clear();
-    return false;
+  }
+  process_info.GetArchitecture().Clear();
+  return false;
 }
 
-static bool
-GetMacOSXProcessArgs (const ProcessInstanceInfoMatch *match_info_ptr,
-                      ProcessInstanceInfo &process_info)
-{
-    if (process_info.ProcessIDIsValid())
-    {
-        int proc_args_mib[3] = { CTL_KERN, KERN_PROCARGS2, (int)process_info.GetProcessID() };
-
-        size_t arg_data_size = 0;
-        if (::sysctl (proc_args_mib, 3, nullptr, &arg_data_size, NULL, 0) || arg_data_size == 0)
-            arg_data_size = 8192;
-
-        // Add a few bytes to the calculated length, I know we need to add at least one byte
-        // to this number otherwise we get junk back, so add 128 just in case...
-        DataBufferHeap arg_data(arg_data_size+128, 0);
-        arg_data_size = arg_data.GetByteSize();
-        if (::sysctl (proc_args_mib, 3, arg_data.GetBytes(), &arg_data_size , NULL, 0) == 0)
-        {
-            DataExtractor data (arg_data.GetBytes(), arg_data_size, endian::InlHostByteOrder(), sizeof(void *));
-            lldb::offset_t offset = 0;
-            uint32_t argc = data.GetU32 (&offset);
-            llvm::Triple &triple = process_info.GetArchitecture().GetTriple();
-            const llvm::Triple::ArchType triple_arch = triple.getArch();
-            const bool check_for_ios_simulator = (triple_arch == llvm::Triple::x86 || triple_arch == llvm::Triple::x86_64);
-            const char *cstr = data.GetCStr (&offset);
+static bool GetMacOSXProcessArgs(const ProcessInstanceInfoMatch *match_info_ptr,
+                                 ProcessInstanceInfo &process_info) {
+  if (process_info.ProcessIDIsValid()) {
+    int proc_args_mib[3] = {CTL_KERN, KERN_PROCARGS2,
+                            (int)process_info.GetProcessID()};
+
+    size_t arg_data_size = 0;
+    if (::sysctl(proc_args_mib, 3, nullptr, &arg_data_size, NULL, 0) ||
+        arg_data_size == 0)
+      arg_data_size = 8192;
+
+    // Add a few bytes to the calculated length, I know we need to add at least
+    // one byte
+    // to this number otherwise we get junk back, so add 128 just in case...
+    DataBufferHeap arg_data(arg_data_size + 128, 0);
+    arg_data_size = arg_data.GetByteSize();
+    if (::sysctl(proc_args_mib, 3, arg_data.GetBytes(), &arg_data_size, NULL,
+                 0) == 0) {
+      DataExtractor data(arg_data.GetBytes(), arg_data_size,
+                         endian::InlHostByteOrder(), sizeof(void *));
+      lldb::offset_t offset = 0;
+      uint32_t argc = data.GetU32(&offset);
+      llvm::Triple &triple = process_info.GetArchitecture().GetTriple();
+      const llvm::Triple::ArchType triple_arch = triple.getArch();
+      const bool check_for_ios_simulator =
+          (triple_arch == llvm::Triple::x86 ||
+           triple_arch == llvm::Triple::x86_64);
+      const char *cstr = data.GetCStr(&offset);
+      if (cstr) {
+        process_info.GetExecutableFile().SetFile(cstr, false);
+
+        if (match_info_ptr == NULL ||
+            NameMatches(
+                process_info.GetExecutableFile().GetFilename().GetCString(),
+                match_info_ptr->GetNameMatchType(),
+                match_info_ptr->GetProcessInfo().GetName())) {
+          // Skip NULLs
+          while (1) {
+            const uint8_t *p = data.PeekData(offset, 1);
+            if ((p == NULL) || (*p != '\0'))
+              break;
+            ++offset;
+          }
+          // Now extract all arguments
+          Args &proc_args = process_info.GetArguments();
+          for (int i = 0; i < static_cast<int>(argc); ++i) {
+            cstr = data.GetCStr(&offset);
             if (cstr)
-            {
-                process_info.GetExecutableFile().SetFile(cstr, false);
+              proc_args.AppendArgument(cstr);
+          }
 
-                if (match_info_ptr == NULL || 
-                    NameMatches (process_info.GetExecutableFile().GetFilename().GetCString(),
-                                 match_info_ptr->GetNameMatchType(),
-                                 match_info_ptr->GetProcessInfo().GetName()))
-                {
-                    // Skip NULLs
-                    while (1)
-                    {
-                        const uint8_t *p = data.PeekData(offset, 1);
-                        if ((p == NULL) || (*p != '\0'))
-                            break;
-                        ++offset;
-                    }
-                    // Now extract all arguments
-                    Args &proc_args = process_info.GetArguments();
-                    for (int i=0; i<static_cast<int>(argc); ++i)
-                    {
-                        cstr = data.GetCStr(&offset);
-                        if (cstr)
-                            proc_args.AppendArgument(cstr);
-                    }
-                    
-                    Args &proc_env = process_info.GetEnvironmentEntries ();
-                    while ((cstr = data.GetCStr(&offset)))
-                    {
-                        if (cstr[0] == '\0')
-                            break;
-                        
-                        if (check_for_ios_simulator)
-                        {
-                            if (strncmp(cstr, "SIMULATOR_UDID=", strlen("SIMULATOR_UDID=")) == 0)
-                                process_info.GetArchitecture().GetTriple().setOS(llvm::Triple::IOS);
-                            else
-                                process_info.GetArchitecture().GetTriple().setOS(llvm::Triple::MacOSX);
-                        }
-
-                        proc_env.AppendArgument(cstr);
-                    }
-                    return true;
-                }
+          Args &proc_env = process_info.GetEnvironmentEntries();
+          while ((cstr = data.GetCStr(&offset))) {
+            if (cstr[0] == '\0')
+              break;
+
+            if (check_for_ios_simulator) {
+              if (strncmp(cstr, "SIMULATOR_UDID=", strlen("SIMULATOR_UDID=")) ==
+                  0)
+                process_info.GetArchitecture().GetTriple().setOS(
+                    llvm::Triple::IOS);
+              else
+                process_info.GetArchitecture().GetTriple().setOS(
+                    llvm::Triple::MacOSX);
             }
+
+            proc_env.AppendArgument(cstr);
+          }
+          return true;
         }
+      }
     }
-    return false;
+  }
+  return false;
 }
 
-static bool
-GetMacOSXProcessUserAndGroup (ProcessInstanceInfo &process_info)
-{
-    if (process_info.ProcessIDIsValid())
-    {
-        int mib[4];
-        mib[0] = CTL_KERN;
-        mib[1] = KERN_PROC;
-        mib[2] = KERN_PROC_PID;
-        mib[3] = process_info.GetProcessID();
-        struct kinfo_proc proc_kinfo;
-        size_t proc_kinfo_size = sizeof(struct kinfo_proc);
-
-        if (::sysctl (mib, 4, &proc_kinfo, &proc_kinfo_size, NULL, 0) == 0)
-        {
-            if (proc_kinfo_size > 0)
-            {
-                process_info.SetParentProcessID (proc_kinfo.kp_eproc.e_ppid);
-                process_info.SetUserID (proc_kinfo.kp_eproc.e_pcred.p_ruid);
-                process_info.SetGroupID (proc_kinfo.kp_eproc.e_pcred.p_rgid);
-                process_info.SetEffectiveUserID (proc_kinfo.kp_eproc.e_ucred.cr_uid);
-                if (proc_kinfo.kp_eproc.e_ucred.cr_ngroups > 0)
-                    process_info.SetEffectiveGroupID (proc_kinfo.kp_eproc.e_ucred.cr_groups[0]);
-                else
-                    process_info.SetEffectiveGroupID (UINT32_MAX);            
-                return true;
-            }
-        }
+static bool GetMacOSXProcessUserAndGroup(ProcessInstanceInfo &process_info) {
+  if (process_info.ProcessIDIsValid()) {
+    int mib[4];
+    mib[0] = CTL_KERN;
+    mib[1] = KERN_PROC;
+    mib[2] = KERN_PROC_PID;
+    mib[3] = process_info.GetProcessID();
+    struct kinfo_proc proc_kinfo;
+    size_t proc_kinfo_size = sizeof(struct kinfo_proc);
+
+    if (::sysctl(mib, 4, &proc_kinfo, &proc_kinfo_size, NULL, 0) == 0) {
+      if (proc_kinfo_size > 0) {
+        process_info.SetParentProcessID(proc_kinfo.kp_eproc.e_ppid);
+        process_info.SetUserID(proc_kinfo.kp_eproc.e_pcred.p_ruid);
+        process_info.SetGroupID(proc_kinfo.kp_eproc.e_pcred.p_rgid);
+        process_info.SetEffectiveUserID(proc_kinfo.kp_eproc.e_ucred.cr_uid);
+        if (proc_kinfo.kp_eproc.e_ucred.cr_ngroups > 0)
+          process_info.SetEffectiveGroupID(
+              proc_kinfo.kp_eproc.e_ucred.cr_groups[0]);
+        else
+          process_info.SetEffectiveGroupID(UINT32_MAX);
+        return true;
+      }
     }
-    process_info.SetParentProcessID (LLDB_INVALID_PROCESS_ID);
-    process_info.SetUserID (UINT32_MAX);
-    process_info.SetGroupID (UINT32_MAX);
-    process_info.SetEffectiveUserID (UINT32_MAX);
-    process_info.SetEffectiveGroupID (UINT32_MAX);            
-    return false;
+  }
+  process_info.SetParentProcessID(LLDB_INVALID_PROCESS_ID);
+  process_info.SetUserID(UINT32_MAX);
+  process_info.SetGroupID(UINT32_MAX);
+  process_info.SetEffectiveUserID(UINT32_MAX);
+  process_info.SetEffectiveGroupID(UINT32_MAX);
+  return false;
 }
 
+uint32_t Host::FindProcesses(const ProcessInstanceInfoMatch &match_info,
+                             ProcessInstanceInfoList &process_infos) {
+  std::vector<struct kinfo_proc> kinfos;
 
-uint32_t
-Host::FindProcesses (const ProcessInstanceInfoMatch &match_info, ProcessInstanceInfoList &process_infos)
-{
-    std::vector<struct kinfo_proc> kinfos;
-    
-    int mib[3] = { CTL_KERN, KERN_PROC, KERN_PROC_ALL };
-    
-    size_t pid_data_size = 0;
-    if (::sysctl (mib, 4, NULL, &pid_data_size, NULL, 0) != 0)
-        return 0;
-    
-    // Add a few extra in case a few more show up
-    const size_t estimated_pid_count = (pid_data_size / sizeof(struct kinfo_proc)) + 10;
-
-    kinfos.resize (estimated_pid_count);
-    pid_data_size = kinfos.size() * sizeof(struct kinfo_proc);
-    
-    if (::sysctl (mib, 4, &kinfos[0], &pid_data_size, NULL, 0) != 0)
-        return 0;
-
-    const size_t actual_pid_count = (pid_data_size / sizeof(struct kinfo_proc));
-
-    bool all_users = match_info.GetMatchAllUsers();
-    const lldb::pid_t our_pid = getpid();
-    const uid_t our_uid = getuid();
-    for (size_t i = 0; i < actual_pid_count; i++)
-    {
-        const struct kinfo_proc &kinfo = kinfos[i];
-        
-        bool kinfo_user_matches = false;
-        if (all_users)
-            kinfo_user_matches = true;
-        else
-            kinfo_user_matches = kinfo.kp_eproc.e_pcred.p_ruid == our_uid;
+  int mib[3] = {CTL_KERN, KERN_PROC, KERN_PROC_ALL};
 
-        // Special case, if lldb is being run as root we can attach to anything.
-        if (our_uid == 0)
-          kinfo_user_matches = true;
-
-        if (kinfo_user_matches == false         || // Make sure the user is acceptable
-            static_cast<lldb::pid_t>(kinfo.kp_proc.p_pid) == our_pid || // Skip this process
-            kinfo.kp_proc.p_pid == 0            || // Skip kernel (kernel pid is zero)
-            kinfo.kp_proc.p_stat == SZOMB       || // Zombies are bad, they like brains...
-            kinfo.kp_proc.p_flag & P_TRACED     || // Being debugged?
-            kinfo.kp_proc.p_flag & P_WEXIT      || // Working on exiting?
-            kinfo.kp_proc.p_flag & P_TRANSLATED)   // Skip translated ppc (Rosetta)
-            continue;
-
-        ProcessInstanceInfo process_info;
-        process_info.SetProcessID (kinfo.kp_proc.p_pid);
-        process_info.SetParentProcessID (kinfo.kp_eproc.e_ppid);
-        process_info.SetUserID (kinfo.kp_eproc.e_pcred.p_ruid);
-        process_info.SetGroupID (kinfo.kp_eproc.e_pcred.p_rgid);
-        process_info.SetEffectiveUserID (kinfo.kp_eproc.e_ucred.cr_uid);
-        if (kinfo.kp_eproc.e_ucred.cr_ngroups > 0)
-            process_info.SetEffectiveGroupID (kinfo.kp_eproc.e_ucred.cr_groups[0]);
-        else
-            process_info.SetEffectiveGroupID (UINT32_MAX);            
+  size_t pid_data_size = 0;
+  if (::sysctl(mib, 4, NULL, &pid_data_size, NULL, 0) != 0)
+    return 0;
 
-        // Make sure our info matches before we go fetch the name and cpu type
-        if (match_info.Matches (process_info))
-        {
-            // Get CPU type first so we can know to look for iOS simulator is we have x86 or x86_64
-            if (GetMacOSXProcessCPUType (process_info))
-            {
-                if (GetMacOSXProcessArgs (&match_info, process_info))
-                {
-                    if (match_info.Matches (process_info))
-                        process_infos.Append (process_info);
-                }
-            }
+  // Add a few extra in case a few more show up
+  const size_t estimated_pid_count =
+      (pid_data_size / sizeof(struct kinfo_proc)) + 10;
+
+  kinfos.resize(estimated_pid_count);
+  pid_data_size = kinfos.size() * sizeof(struct kinfo_proc);
+
+  if (::sysctl(mib, 4, &kinfos[0], &pid_data_size, NULL, 0) != 0)
+    return 0;
+
+  const size_t actual_pid_count = (pid_data_size / sizeof(struct kinfo_proc));
+
+  bool all_users = match_info.GetMatchAllUsers();
+  const lldb::pid_t our_pid = getpid();
+  const uid_t our_uid = getuid();
+  for (size_t i = 0; i < actual_pid_count; i++) {
+    const struct kinfo_proc &kinfo = kinfos[i];
+
+    bool kinfo_user_matches = false;
+    if (all_users)
+      kinfo_user_matches = true;
+    else
+      kinfo_user_matches = kinfo.kp_eproc.e_pcred.p_ruid == our_uid;
+
+    // Special case, if lldb is being run as root we can attach to anything.
+    if (our_uid == 0)
+      kinfo_user_matches = true;
+
+    if (kinfo_user_matches == false || // Make sure the user is acceptable
+        static_cast<lldb::pid_t>(kinfo.kp_proc.p_pid) ==
+            our_pid ||                   // Skip this process
+        kinfo.kp_proc.p_pid == 0 ||      // Skip kernel (kernel pid is zero)
+        kinfo.kp_proc.p_stat == SZOMB || // Zombies are bad, they like brains...
+        kinfo.kp_proc.p_flag & P_TRACED ||   // Being debugged?
+        kinfo.kp_proc.p_flag & P_WEXIT ||    // Working on exiting?
+        kinfo.kp_proc.p_flag & P_TRANSLATED) // Skip translated ppc (Rosetta)
+      continue;
+
+    ProcessInstanceInfo process_info;
+    process_info.SetProcessID(kinfo.kp_proc.p_pid);
+    process_info.SetParentProcessID(kinfo.kp_eproc.e_ppid);
+    process_info.SetUserID(kinfo.kp_eproc.e_pcred.p_ruid);
+    process_info.SetGroupID(kinfo.kp_eproc.e_pcred.p_rgid);
+    process_info.SetEffectiveUserID(kinfo.kp_eproc.e_ucred.cr_uid);
+    if (kinfo.kp_eproc.e_ucred.cr_ngroups > 0)
+      process_info.SetEffectiveGroupID(kinfo.kp_eproc.e_ucred.cr_groups[0]);
+    else
+      process_info.SetEffectiveGroupID(UINT32_MAX);
+
+    // Make sure our info matches before we go fetch the name and cpu type
+    if (match_info.Matches(process_info)) {
+      // Get CPU type first so we can know to look for iOS simulator is we have
+      // x86 or x86_64
+      if (GetMacOSXProcessCPUType(process_info)) {
+        if (GetMacOSXProcessArgs(&match_info, process_info)) {
+          if (match_info.Matches(process_info))
+            process_infos.Append(process_info);
         }
-    }    
-    return process_infos.GetSize();
+      }
+    }
+  }
+  return process_infos.GetSize();
 }
 
-bool
-Host::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info)
-{
-    process_info.SetProcessID(pid);
-    bool success = false;
-
-    // Get CPU type first so we can know to look for iOS simulator is we have x86 or x86_64
-    if (GetMacOSXProcessCPUType (process_info))
-        success = true;
-    
-    if (GetMacOSXProcessArgs (NULL, process_info))
-        success = true;
-    
-    if (GetMacOSXProcessUserAndGroup (process_info))
-        success = true;
-    
-    if (success)
-        return true;
-    
-    process_info.Clear();
-    return false;
+bool Host::GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &process_info) {
+  process_info.SetProcessID(pid);
+  bool success = false;
+
+  // Get CPU type first so we can know to look for iOS simulator is we have x86
+  // or x86_64
+  if (GetMacOSXProcessCPUType(process_info))
+    success = true;
+
+  if (GetMacOSXProcessArgs(NULL, process_info))
+    success = true;
+
+  if (GetMacOSXProcessUserAndGroup(process_info))
+    success = true;
+
+  if (success)
+    return true;
+
+  process_info.Clear();
+  return false;
 }
 
 #if !NO_XPC_SERVICES
-static void
-PackageXPCArguments (xpc_object_t message, const char *prefix, const Args& args)
-{
-    size_t count = args.GetArgumentCount();
-    char buf[50]; // long enough for 'argXXX'
+static void PackageXPCArguments(xpc_object_t message, const char *prefix,
+                                const Args &args) {
+  size_t count = args.GetArgumentCount();
+  char buf[50]; // long enough for 'argXXX'
+  memset(buf, 0, 50);
+  sprintf(buf, "%sCount", prefix);
+  xpc_dictionary_set_int64(message, buf, count);
+  for (size_t i = 0; i < count; i++) {
     memset(buf, 0, 50);
-    sprintf(buf, "%sCount", prefix);
-	xpc_dictionary_set_int64(message, buf, count);
-    for (size_t i=0; i<count; i++) {
-        memset(buf, 0, 50);
-        sprintf(buf, "%s%zi", prefix, i);
-        xpc_dictionary_set_string(message, buf, args.GetArgumentAtIndex(i));
-    }
+    sprintf(buf, "%s%zi", prefix, i);
+    xpc_dictionary_set_string(message, buf, args.GetArgumentAtIndex(i));
+  }
 }
 
 /*
- A valid authorizationRef means that 
+ A valid authorizationRef means that
     - there is the LaunchUsingXPCRightName rights in the /etc/authorization
     - we have successfully copied the rights to be send over the XPC wire
  Once obtained, it will be valid for as long as the process lives.
  */
 static AuthorizationRef authorizationRef = NULL;
-static Error
-getXPCAuthorization (ProcessLaunchInfo &launch_info)
-{
-    Error error;
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_HOST | LIBLLDB_LOG_PROCESS));
-    
-    if ((launch_info.GetUserID() == 0) && !authorizationRef)
-    {
-        OSStatus createStatus = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &authorizationRef);
-        if (createStatus != errAuthorizationSuccess)
-        {
-            error.SetError(1, eErrorTypeGeneric);
-            error.SetErrorString("Can't create authorizationRef.");
-            if (log)
-            {
-                error.PutToLog(log, "%s", error.AsCString());
-            }
-            return error;
-        }
-        
-        OSStatus rightsStatus = AuthorizationRightGet(LaunchUsingXPCRightName, NULL);
-        if (rightsStatus != errAuthorizationSuccess)
-        {
-            // No rights in the security database, Create it with the right prompt.
-            CFStringRef prompt = CFSTR("Xcode is trying to take control of a root process.");
-            CFStringRef keys[] = { CFSTR("en") };
-            CFTypeRef values[] = { prompt };
-            CFDictionaryRef promptDict = CFDictionaryCreate(kCFAllocatorDefault, (const void **)keys, (const void **)values, 1, &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
-            
-            CFStringRef keys1[] = { CFSTR("class"), CFSTR("group"), CFSTR("comment"),               CFSTR("default-prompt"), CFSTR("shared") };
-            CFTypeRef values1[] = { CFSTR("user"),  CFSTR("admin"), CFSTR(LaunchUsingXPCRightName), promptDict,              kCFBooleanFalse };
-            CFDictionaryRef dict = CFDictionaryCreate(kCFAllocatorDefault, (const void **)keys1, (const void **)values1, 5, &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
-            rightsStatus = AuthorizationRightSet(authorizationRef, LaunchUsingXPCRightName, dict, NULL, NULL, NULL);
-            CFRelease(promptDict);
-            CFRelease(dict);
-        }
-            
-        OSStatus copyRightStatus = errAuthorizationDenied;
-        if (rightsStatus == errAuthorizationSuccess)
-        {
-            AuthorizationItem item1 = { LaunchUsingXPCRightName, 0, NULL, 0 };
-            AuthorizationItem items[] = {item1};
-            AuthorizationRights requestedRights = {1, items };
-            AuthorizationFlags authorizationFlags = kAuthorizationFlagInteractionAllowed | kAuthorizationFlagExtendRights;
-            copyRightStatus = AuthorizationCopyRights(authorizationRef, &requestedRights, kAuthorizationEmptyEnvironment, authorizationFlags, NULL);
-        }
-        
-        if (copyRightStatus != errAuthorizationSuccess)
-        {
-            // Eventually when the commandline supports running as root and the user is not
-            // logged in in the current audit session, we will need the trick in gdb where
-            // we ask the user to type in the root passwd in the terminal.
-            error.SetError(2, eErrorTypeGeneric);
-            error.SetErrorStringWithFormat("Launching as root needs root authorization.");
-            if (log)
-            {
-                error.PutToLog(log, "%s", error.AsCString());
-            }
-            
-            if (authorizationRef)
-            {
-                AuthorizationFree(authorizationRef, kAuthorizationFlagDefaults);
-                authorizationRef = NULL;
-            }
-        }
+static Error getXPCAuthorization(ProcessLaunchInfo &launch_info) {
+  Error error;
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST |
+                                                  LIBLLDB_LOG_PROCESS));
+
+  if ((launch_info.GetUserID() == 0) && !authorizationRef) {
+    OSStatus createStatus =
+        AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment,
+                            kAuthorizationFlagDefaults, &authorizationRef);
+    if (createStatus != errAuthorizationSuccess) {
+      error.SetError(1, eErrorTypeGeneric);
+      error.SetErrorString("Can't create authorizationRef.");
+      if (log) {
+        error.PutToLog(log, "%s", error.AsCString());
+      }
+      return error;
+    }
+
+    OSStatus rightsStatus =
+        AuthorizationRightGet(LaunchUsingXPCRightName, NULL);
+    if (rightsStatus != errAuthorizationSuccess) {
+      // No rights in the security database, Create it with the right prompt.
+      CFStringRef prompt =
+          CFSTR("Xcode is trying to take control of a root process.");
+      CFStringRef keys[] = {CFSTR("en")};
+      CFTypeRef values[] = {prompt};
+      CFDictionaryRef promptDict = CFDictionaryCreate(
+          kCFAllocatorDefault, (const void **)keys, (const void **)values, 1,
+          &kCFCopyStringDictionaryKeyCallBacks,
+          &kCFTypeDictionaryValueCallBacks);
+
+      CFStringRef keys1[] = {CFSTR("class"), CFSTR("group"), CFSTR("comment"),
+                             CFSTR("default-prompt"), CFSTR("shared")};
+      CFTypeRef values1[] = {CFSTR("user"), CFSTR("admin"),
+                             CFSTR(LaunchUsingXPCRightName), promptDict,
+                             kCFBooleanFalse};
+      CFDictionaryRef dict = CFDictionaryCreate(
+          kCFAllocatorDefault, (const void **)keys1, (const void **)values1, 5,
+          &kCFCopyStringDictionaryKeyCallBacks,
+          &kCFTypeDictionaryValueCallBacks);
+      rightsStatus = AuthorizationRightSet(
+          authorizationRef, LaunchUsingXPCRightName, dict, NULL, NULL, NULL);
+      CFRelease(promptDict);
+      CFRelease(dict);
+    }
+
+    OSStatus copyRightStatus = errAuthorizationDenied;
+    if (rightsStatus == errAuthorizationSuccess) {
+      AuthorizationItem item1 = {LaunchUsingXPCRightName, 0, NULL, 0};
+      AuthorizationItem items[] = {item1};
+      AuthorizationRights requestedRights = {1, items};
+      AuthorizationFlags authorizationFlags =
+          kAuthorizationFlagInteractionAllowed | kAuthorizationFlagExtendRights;
+      copyRightStatus = AuthorizationCopyRights(
+          authorizationRef, &requestedRights, kAuthorizationEmptyEnvironment,
+          authorizationFlags, NULL);
+    }
+
+    if (copyRightStatus != errAuthorizationSuccess) {
+      // Eventually when the commandline supports running as root and the user
+      // is not
+      // logged in in the current audit session, we will need the trick in gdb
+      // where
+      // we ask the user to type in the root passwd in the terminal.
+      error.SetError(2, eErrorTypeGeneric);
+      error.SetErrorStringWithFormat(
+          "Launching as root needs root authorization.");
+      if (log) {
+        error.PutToLog(log, "%s", error.AsCString());
+      }
+
+      if (authorizationRef) {
+        AuthorizationFree(authorizationRef, kAuthorizationFlagDefaults);
+        authorizationRef = NULL;
+      }
     }
+  }
 
-    return error;
+  return error;
 }
 #endif
 
-static Error
-LaunchProcessXPC(const char *exe_path, ProcessLaunchInfo &launch_info, lldb::pid_t &pid)
-{
+static Error LaunchProcessXPC(const char *exe_path,
+                              ProcessLaunchInfo &launch_info,
+                              lldb::pid_t &pid) {
 #if !NO_XPC_SERVICES
-    Error error = getXPCAuthorization(launch_info);
-    if (error.Fail())
-        return error;
-    
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_HOST | LIBLLDB_LOG_PROCESS));
-    
-    uid_t requested_uid = launch_info.GetUserID();
-    const char *xpc_service  = nil;
-    bool send_auth = false;
-    AuthorizationExternalForm extForm;
-    if (requested_uid == 0)
-    {
-        if (AuthorizationMakeExternalForm(authorizationRef, &extForm) == errAuthorizationSuccess)
-        {
-            send_auth = true;
-        }
-        else
-        {
-            error.SetError(3, eErrorTypeGeneric);
-            error.SetErrorStringWithFormat("Launching root via XPC needs to externalize authorization reference.");
-            if (log)
-            {
-                error.PutToLog(log, "%s", error.AsCString());
-            }
-            return error;
-        }
-        xpc_service = LaunchUsingXPCRightName;
-    }
-    else
-    {
-        error.SetError(4, eErrorTypeGeneric);
-        error.SetErrorStringWithFormat("Launching via XPC is only currently available for root.");
-        if (log)
-        {
-            error.PutToLog(log, "%s", error.AsCString());
-        }
-        return error;
-    }
-    
-    xpc_connection_t conn = xpc_connection_create(xpc_service, NULL);
-    
-	xpc_connection_set_event_handler(conn, ^(xpc_object_t event) {
-        xpc_type_t	type = xpc_get_type(event);
-        
-        if (type == XPC_TYPE_ERROR) {
-            if (event == XPC_ERROR_CONNECTION_INTERRUPTED) {
-                // The service has either canceled itself, crashed, or been terminated.
-                // The XPC connection is still valid and sending a message to it will re-launch the service.
-                // If the service is state-full, this is the time to initialize the new service.
-                return;
-            } else if (event == XPC_ERROR_CONNECTION_INVALID) {
-                // The service is invalid. Either the service name supplied to xpc_connection_create() is incorrect
-                // or we (this process) have canceled the service; we can do any cleanup of application state at this point.
-                // printf("Service disconnected");
-                return;
-            } else {
-                // printf("Unexpected error from service: %s", xpc_dictionary_get_string(event, XPC_ERROR_KEY_DESCRIPTION));
-            }
-            
-        } else {
-            // printf("Received unexpected event in handler");
-        }
-    });
-    
-    xpc_connection_set_finalizer_f (conn, xpc_finalizer_t(xpc_release));
-	xpc_connection_resume (conn);
-    xpc_object_t message = xpc_dictionary_create (nil, nil, 0);
-    
-    if (send_auth)
-    {
-        xpc_dictionary_set_data(message, LauncherXPCServiceAuthKey, extForm.bytes, sizeof(AuthorizationExternalForm));
-    }
-    
-    PackageXPCArguments(message, LauncherXPCServiceArgPrefxKey, launch_info.GetArguments());
-    PackageXPCArguments(message, LauncherXPCServiceEnvPrefxKey, launch_info.GetEnvironmentEntries());
-    
-    // Posix spawn stuff.
-    xpc_dictionary_set_int64(message, LauncherXPCServiceCPUTypeKey, launch_info.GetArchitecture().GetMachOCPUType());
-    xpc_dictionary_set_int64(message, LauncherXPCServicePosixspawnFlagsKey, Host::GetPosixspawnFlags(launch_info));
-    const FileAction *file_action = launch_info.GetFileActionForFD(STDIN_FILENO);
-    if (file_action && file_action->GetPath())
-    {
-        xpc_dictionary_set_string(message, LauncherXPCServiceStdInPathKeyKey, file_action->GetPath());
-    }
-    file_action = launch_info.GetFileActionForFD(STDOUT_FILENO);
-    if (file_action && file_action->GetPath())
-    {
-        xpc_dictionary_set_string(message, LauncherXPCServiceStdOutPathKeyKey, file_action->GetPath());
-    }
-    file_action = launch_info.GetFileActionForFD(STDERR_FILENO);
-    if (file_action && file_action->GetPath())
-    {
-        xpc_dictionary_set_string(message, LauncherXPCServiceStdErrPathKeyKey, file_action->GetPath());
-    }
-    
-    xpc_object_t reply = xpc_connection_send_message_with_reply_sync(conn, message);
-    xpc_type_t returnType = xpc_get_type(reply);
-    if (returnType == XPC_TYPE_DICTIONARY)
-    {
-        pid = xpc_dictionary_get_int64(reply, LauncherXPCServiceChildPIDKey);
-        if (pid == 0)
-        {
-            int errorType = xpc_dictionary_get_int64(reply, LauncherXPCServiceErrorTypeKey);
-            int errorCode = xpc_dictionary_get_int64(reply, LauncherXPCServiceCodeTypeKey);
-            
-            error.SetError(errorCode, eErrorTypeGeneric);
-            error.SetErrorStringWithFormat("Problems with launching via XPC. Error type : %i, code : %i", errorType, errorCode);
-            if (log)
-            {
-                error.PutToLog(log, "%s", error.AsCString());
-            }
-            
-            if (authorizationRef)
-            {
-                AuthorizationFree(authorizationRef, kAuthorizationFlagDefaults);
-                authorizationRef = NULL;
-            }
-        }
-    }
-    else if (returnType == XPC_TYPE_ERROR)
-    {
-        error.SetError(5, eErrorTypeGeneric);
-        error.SetErrorStringWithFormat("Problems with launching via XPC. XPC error : %s", xpc_dictionary_get_string(reply, XPC_ERROR_KEY_DESCRIPTION));
-        if (log)
-        {
-            error.PutToLog(log, "%s", error.AsCString());
-        }
+  Error error = getXPCAuthorization(launch_info);
+  if (error.Fail())
+    return error;
+
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST |
+                                                  LIBLLDB_LOG_PROCESS));
+
+  uid_t requested_uid = launch_info.GetUserID();
+  const char *xpc_service = nil;
+  bool send_auth = false;
+  AuthorizationExternalForm extForm;
+  if (requested_uid == 0) {
+    if (AuthorizationMakeExternalForm(authorizationRef, &extForm) ==
+        errAuthorizationSuccess) {
+      send_auth = true;
+    } else {
+      error.SetError(3, eErrorTypeGeneric);
+      error.SetErrorStringWithFormat("Launching root via XPC needs to "
+                                     "externalize authorization reference.");
+      if (log) {
+        error.PutToLog(log, "%s", error.AsCString());
+      }
+      return error;
+    }
+    xpc_service = LaunchUsingXPCRightName;
+  } else {
+    error.SetError(4, eErrorTypeGeneric);
+    error.SetErrorStringWithFormat(
+        "Launching via XPC is only currently available for root.");
+    if (log) {
+      error.PutToLog(log, "%s", error.AsCString());
     }
-    
     return error;
+  }
+
+  xpc_connection_t conn = xpc_connection_create(xpc_service, NULL);
+
+  xpc_connection_set_event_handler(conn, ^(xpc_object_t event) {
+    xpc_type_t type = xpc_get_type(event);
+
+    if (type == XPC_TYPE_ERROR) {
+      if (event == XPC_ERROR_CONNECTION_INTERRUPTED) {
+        // The service has either canceled itself, crashed, or been terminated.
+        // The XPC connection is still valid and sending a message to it will
+        // re-launch the service.
+        // If the service is state-full, this is the time to initialize the new
+        // service.
+        return;
+      } else if (event == XPC_ERROR_CONNECTION_INVALID) {
+        // The service is invalid. Either the service name supplied to
+        // xpc_connection_create() is incorrect
+        // or we (this process) have canceled the service; we can do any cleanup
+        // of application state at this point.
+        // printf("Service disconnected");
+        return;
+      } else {
+        // printf("Unexpected error from service: %s",
+        // xpc_dictionary_get_string(event, XPC_ERROR_KEY_DESCRIPTION));
+      }
+
+    } else {
+      // printf("Received unexpected event in handler");
+    }
+  });
+
+  xpc_connection_set_finalizer_f(conn, xpc_finalizer_t(xpc_release));
+  xpc_connection_resume(conn);
+  xpc_object_t message = xpc_dictionary_create(nil, nil, 0);
+
+  if (send_auth) {
+    xpc_dictionary_set_data(message, LauncherXPCServiceAuthKey, extForm.bytes,
+                            sizeof(AuthorizationExternalForm));
+  }
+
+  PackageXPCArguments(message, LauncherXPCServiceArgPrefxKey,
+                      launch_info.GetArguments());
+  PackageXPCArguments(message, LauncherXPCServiceEnvPrefxKey,
+                      launch_info.GetEnvironmentEntries());
+
+  // Posix spawn stuff.
+  xpc_dictionary_set_int64(message, LauncherXPCServiceCPUTypeKey,
+                           launch_info.GetArchitecture().GetMachOCPUType());
+  xpc_dictionary_set_int64(message, LauncherXPCServicePosixspawnFlagsKey,
+                           Host::GetPosixspawnFlags(launch_info));
+  const FileAction *file_action = launch_info.GetFileActionForFD(STDIN_FILENO);
+  if (file_action && file_action->GetPath()) {
+    xpc_dictionary_set_string(message, LauncherXPCServiceStdInPathKeyKey,
+                              file_action->GetPath());
+  }
+  file_action = launch_info.GetFileActionForFD(STDOUT_FILENO);
+  if (file_action && file_action->GetPath()) {
+    xpc_dictionary_set_string(message, LauncherXPCServiceStdOutPathKeyKey,
+                              file_action->GetPath());
+  }
+  file_action = launch_info.GetFileActionForFD(STDERR_FILENO);
+  if (file_action && file_action->GetPath()) {
+    xpc_dictionary_set_string(message, LauncherXPCServiceStdErrPathKeyKey,
+                              file_action->GetPath());
+  }
+
+  xpc_object_t reply =
+      xpc_connection_send_message_with_reply_sync(conn, message);
+  xpc_type_t returnType = xpc_get_type(reply);
+  if (returnType == XPC_TYPE_DICTIONARY) {
+    pid = xpc_dictionary_get_int64(reply, LauncherXPCServiceChildPIDKey);
+    if (pid == 0) {
+      int errorType =
+          xpc_dictionary_get_int64(reply, LauncherXPCServiceErrorTypeKey);
+      int errorCode =
+          xpc_dictionary_get_int64(reply, LauncherXPCServiceCodeTypeKey);
+
+      error.SetError(errorCode, eErrorTypeGeneric);
+      error.SetErrorStringWithFormat(
+          "Problems with launching via XPC. Error type : %i, code : %i",
+          errorType, errorCode);
+      if (log) {
+        error.PutToLog(log, "%s", error.AsCString());
+      }
+
+      if (authorizationRef) {
+        AuthorizationFree(authorizationRef, kAuthorizationFlagDefaults);
+        authorizationRef = NULL;
+      }
+    }
+  } else if (returnType == XPC_TYPE_ERROR) {
+    error.SetError(5, eErrorTypeGeneric);
+    error.SetErrorStringWithFormat(
+        "Problems with launching via XPC. XPC error : %s",
+        xpc_dictionary_get_string(reply, XPC_ERROR_KEY_DESCRIPTION));
+    if (log) {
+      error.PutToLog(log, "%s", error.AsCString());
+    }
+  }
+
+  return error;
 #else
-    Error error;
-    return error;
+  Error error;
+  return error;
 #endif
 }
 
-static bool
-ShouldLaunchUsingXPC(ProcessLaunchInfo &launch_info)
-{
-    bool result = false;
-
-#if !NO_XPC_SERVICES    
-    bool launchingAsRoot = launch_info.GetUserID() == 0;
-    bool currentUserIsRoot = HostInfo::GetEffectiveUserID() == 0;
-    
-    if (launchingAsRoot && !currentUserIsRoot)
-    {
-        // If current user is already root, we don't need XPC's help.
-        result = true;
-    }
+static bool ShouldLaunchUsingXPC(ProcessLaunchInfo &launch_info) {
+  bool result = false;
+
+#if !NO_XPC_SERVICES
+  bool launchingAsRoot = launch_info.GetUserID() == 0;
+  bool currentUserIsRoot = HostInfo::GetEffectiveUserID() == 0;
+
+  if (launchingAsRoot && !currentUserIsRoot) {
+    // If current user is already root, we don't need XPC's help.
+    result = true;
+  }
 #endif
-    
-    return result;
+
+  return result;
 }
 
-Error
-Host::LaunchProcess (ProcessLaunchInfo &launch_info)
-{
-    Error error;
-    char exe_path[PATH_MAX];
-    PlatformSP host_platform_sp (Platform::GetHostPlatform ());
-
-    ModuleSpec exe_module_spec(launch_info.GetExecutableFile(), launch_info.GetArchitecture());
-
-    FileSpec::FileType file_type = exe_module_spec.GetFileSpec().GetFileType();
-    if (file_type != FileSpec::eFileTypeRegular)
-    {
-        lldb::ModuleSP exe_module_sp;
-        error = host_platform_sp->ResolveExecutable (exe_module_spec,
-                                                     exe_module_sp,
-                                                     NULL);
-        
-        if (error.Fail())
-            return error;
-        
-        if (exe_module_sp)
-            exe_module_spec.GetFileSpec() = exe_module_sp->GetFileSpec();
-    }
-    
-    if (exe_module_spec.GetFileSpec().Exists())
-    {
-        exe_module_spec.GetFileSpec().GetPath (exe_path, sizeof(exe_path));
-    }
-    else
-    {
-        launch_info.GetExecutableFile().GetPath (exe_path, sizeof(exe_path));
-        error.SetErrorStringWithFormat ("executable doesn't exist: '%s'", exe_path);
-        return error;
-    }
-    
-    if (launch_info.GetFlags().Test (eLaunchFlagLaunchInTTY))
-    {
+Error Host::LaunchProcess(ProcessLaunchInfo &launch_info) {
+  Error error;
+  char exe_path[PATH_MAX];
+  PlatformSP host_platform_sp(Platform::GetHostPlatform());
+
+  ModuleSpec exe_module_spec(launch_info.GetExecutableFile(),
+                             launch_info.GetArchitecture());
+
+  FileSpec::FileType file_type = exe_module_spec.GetFileSpec().GetFileType();
+  if (file_type != FileSpec::eFileTypeRegular) {
+    lldb::ModuleSP exe_module_sp;
+    error = host_platform_sp->ResolveExecutable(exe_module_spec, exe_module_sp,
+                                                NULL);
+
+    if (error.Fail())
+      return error;
+
+    if (exe_module_sp)
+      exe_module_spec.GetFileSpec() = exe_module_sp->GetFileSpec();
+  }
+
+  if (exe_module_spec.GetFileSpec().Exists()) {
+    exe_module_spec.GetFileSpec().GetPath(exe_path, sizeof(exe_path));
+  } else {
+    launch_info.GetExecutableFile().GetPath(exe_path, sizeof(exe_path));
+    error.SetErrorStringWithFormat("executable doesn't exist: '%s'", exe_path);
+    return error;
+  }
+
+  if (launch_info.GetFlags().Test(eLaunchFlagLaunchInTTY)) {
 #if !defined(__arm__) && !defined(__arm64__) && !defined(__aarch64__)
-        return LaunchInNewTerminalWithAppleScript (exe_path, launch_info);
+    return LaunchInNewTerminalWithAppleScript(exe_path, launch_info);
 #else
-        error.SetErrorString ("launching a process in a new terminal is not supported on iOS devices");
-        return error;
+    error.SetErrorString("launching a process in a new terminal is not "
+                         "supported on iOS devices");
+    return error;
 #endif
+  }
+
+  lldb::pid_t pid = LLDB_INVALID_PROCESS_ID;
+
+  if (ShouldLaunchUsingXPC(launch_info)) {
+    error = LaunchProcessXPC(exe_path, launch_info, pid);
+  } else {
+    error = LaunchProcessPosixSpawn(exe_path, launch_info, pid);
+  }
+
+  if (pid != LLDB_INVALID_PROCESS_ID) {
+    // If all went well, then set the process ID into the launch info
+    launch_info.SetProcessID(pid);
+
+    // Make sure we reap any processes we spawn or we will have zombies.
+    if (!launch_info.MonitorProcess()) {
+      const bool monitor_signals = false;
+      Host::MonitorChildProcessCallback callback = nullptr;
+
+      if (!launch_info.GetFlags().Test(lldb::eLaunchFlagDontSetExitStatus))
+        callback = Process::SetProcessExitStatus;
+
+      StartMonitoringChildProcess(callback, pid, monitor_signals);
+    }
+  } else {
+    // Invalid process ID, something didn't go well
+    if (error.Success())
+      error.SetErrorString("process launch failed for unknown reasons");
+  }
+  return error;
+}
+
+Error Host::ShellExpandArguments(ProcessLaunchInfo &launch_info) {
+  Error error;
+  if (launch_info.GetFlags().Test(eLaunchFlagShellExpandArguments)) {
+    FileSpec expand_tool_spec;
+    if (!HostInfo::GetLLDBPath(lldb::ePathTypeSupportExecutableDir,
+                               expand_tool_spec)) {
+      error.SetErrorString(
+          "could not get support executable directory for lldb-argdumper tool");
+      return error;
+    }
+    expand_tool_spec.AppendPathComponent("lldb-argdumper");
+    if (!expand_tool_spec.Exists()) {
+      error.SetErrorStringWithFormat(
+          "could not find the lldb-argdumper tool: %s",
+          expand_tool_spec.GetPath().c_str());
+      return error;
+    }
+
+    StreamString expand_tool_spec_stream;
+    expand_tool_spec_stream.Printf("\"%s\"",
+                                   expand_tool_spec.GetPath().c_str());
+
+    Args expand_command(expand_tool_spec_stream.GetData());
+    expand_command.AppendArguments(launch_info.GetArguments());
+
+    int status;
+    std::string output;
+    FileSpec cwd(launch_info.GetWorkingDirectory());
+    if (!cwd.Exists()) {
+      char *wd = getcwd(nullptr, 0);
+      if (wd == nullptr) {
+        error.SetErrorStringWithFormat(
+            "cwd does not exist; cannot launch with shell argument expansion");
+        return error;
+      } else {
+        FileSpec working_dir(wd, false);
+        free(wd);
+        launch_info.SetWorkingDirectory(working_dir);
+      }
     }
+    RunShellCommand(expand_command, cwd, &status, nullptr, &output, 10);
 
-    lldb::pid_t pid = LLDB_INVALID_PROCESS_ID;
+    if (status != 0) {
+      error.SetErrorStringWithFormat("lldb-argdumper exited with error %d",
+                                     status);
+      return error;
+    }
 
-    if (ShouldLaunchUsingXPC(launch_info))
-    {
-        error = LaunchProcessXPC(exe_path, launch_info, pid);
+    auto data_sp = StructuredData::ParseJSON(output);
+    if (!data_sp) {
+      error.SetErrorString("invalid JSON");
+      return error;
     }
-    else
-    {
-        error = LaunchProcessPosixSpawn(exe_path, launch_info, pid);
+
+    auto dict_sp = data_sp->GetAsDictionary();
+    if (!data_sp) {
+      error.SetErrorString("invalid JSON");
+      return error;
     }
-    
-    if (pid != LLDB_INVALID_PROCESS_ID)
-    {
-        // If all went well, then set the process ID into the launch info
-        launch_info.SetProcessID(pid);
-        
-        // Make sure we reap any processes we spawn or we will have zombies.
-        if (!launch_info.MonitorProcess())
-        {
-            const bool monitor_signals = false;
-            Host::MonitorChildProcessCallback callback = nullptr;
-            
-            if (!launch_info.GetFlags().Test(lldb::eLaunchFlagDontSetExitStatus))
-                callback = Process::SetProcessExitStatus;
-
-            StartMonitoringChildProcess (callback,
-                                         pid, 
-                                         monitor_signals);
-        }
+
+    auto args_sp = dict_sp->GetObjectForDotSeparatedPath("arguments");
+    if (!args_sp) {
+      error.SetErrorString("invalid JSON");
+      return error;
     }
-    else
-    {
-        // Invalid process ID, something didn't go well
-        if (error.Success())
-            error.SetErrorString ("process launch failed for unknown reasons");
+
+    auto args_array_sp = args_sp->GetAsArray();
+    if (!args_array_sp) {
+      error.SetErrorString("invalid JSON");
+      return error;
     }
-    return error;
-}
 
-Error
-Host::ShellExpandArguments (ProcessLaunchInfo &launch_info)
-{
-    Error error;
-    if (launch_info.GetFlags().Test(eLaunchFlagShellExpandArguments))
-    {
-        FileSpec expand_tool_spec;
-        if (!HostInfo::GetLLDBPath(lldb::ePathTypeSupportExecutableDir, expand_tool_spec))
-        {
-            error.SetErrorString("could not get support executable directory for lldb-argdumper tool");
-            return error;
-        }
-        expand_tool_spec.AppendPathComponent("lldb-argdumper");
-        if (!expand_tool_spec.Exists())
-        {
-            error.SetErrorStringWithFormat("could not find the lldb-argdumper tool: %s", expand_tool_spec.GetPath().c_str());
-            return error;
-        }
-        
-        StreamString expand_tool_spec_stream;
-        expand_tool_spec_stream.Printf("\"%s\"",expand_tool_spec.GetPath().c_str());
-
-        Args expand_command(expand_tool_spec_stream.GetData());
-        expand_command.AppendArguments (launch_info.GetArguments());
-        
-        int status;
-        std::string output;
-        FileSpec cwd(launch_info.GetWorkingDirectory());
-        if (!cwd.Exists())
-        {
-            char *wd = getcwd(nullptr, 0);
-            if (wd == nullptr)
-            {
-                error.SetErrorStringWithFormat("cwd does not exist; cannot launch with shell argument expansion");
-                return error;
-            }
-            else
-            {
-                FileSpec working_dir(wd, false);
-                free(wd);
-                launch_info.SetWorkingDirectory(working_dir);
+    launch_info.GetArguments().Clear();
 
-            }
-        }
-        RunShellCommand(expand_command, cwd, &status, nullptr, &output, 10);
-        
-        if (status != 0)
-        {
-            error.SetErrorStringWithFormat("lldb-argdumper exited with error %d", status);
-            return error;
-        }
-        
-        auto data_sp = StructuredData::ParseJSON(output);
-        if (!data_sp)
-        {
-            error.SetErrorString("invalid JSON");
-            return error;
-        }
-        
-        auto dict_sp = data_sp->GetAsDictionary();
-        if (!data_sp)
-        {
-            error.SetErrorString("invalid JSON");
-            return error;
-        }
-        
-        auto args_sp = dict_sp->GetObjectForDotSeparatedPath("arguments");
-        if (!args_sp)
-        {
-            error.SetErrorString("invalid JSON");
-            return error;
-        }
+    for (size_t i = 0; i < args_array_sp->GetSize(); i++) {
+      auto item_sp = args_array_sp->GetItemAtIndex(i);
+      if (!item_sp)
+        continue;
+      auto str_sp = item_sp->GetAsString();
+      if (!str_sp)
+        continue;
 
-        auto args_array_sp = args_sp->GetAsArray();
-        if (!args_array_sp)
-        {
-            error.SetErrorString("invalid JSON");
-            return error;
-        }
-        
-        launch_info.GetArguments().Clear();
-        
-        for (size_t i = 0;
-             i < args_array_sp->GetSize();
-             i++)
-        {
-            auto item_sp = args_array_sp->GetItemAtIndex(i);
-            if (!item_sp)
-                continue;
-            auto str_sp = item_sp->GetAsString();
-            if (!str_sp)
-                continue;
-            
-            launch_info.GetArguments().AppendArgument(str_sp->GetValue().c_str());
-        }
+      launch_info.GetArguments().AppendArgument(str_sp->GetValue().c_str());
     }
-    
-    return error;
+  }
+
+  return error;
 }
 
-HostThread
-Host::StartMonitoringChildProcess(const Host::MonitorChildProcessCallback &callback, lldb::pid_t pid,
-                                  bool monitor_signals)
-{
-    unsigned long mask = DISPATCH_PROC_EXIT;
-    if (monitor_signals)
-        mask |= DISPATCH_PROC_SIGNAL;
-
-    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_HOST | LIBLLDB_LOG_PROCESS));
+HostThread Host::StartMonitoringChildProcess(
+    const Host::MonitorChildProcessCallback &callback, lldb::pid_t pid,
+    bool monitor_signals) {
+  unsigned long mask = DISPATCH_PROC_EXIT;
+  if (monitor_signals)
+    mask |= DISPATCH_PROC_SIGNAL;
 
+  Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_HOST |
+                                                  LIBLLDB_LOG_PROCESS));
 
-    dispatch_source_t source = ::dispatch_source_create (DISPATCH_SOURCE_TYPE_PROC,
-                                                         pid,
-                                                         mask,
-                                                         ::dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_DEFAULT,0));
+  dispatch_source_t source = ::dispatch_source_create(
+      DISPATCH_SOURCE_TYPE_PROC, pid, mask,
+      ::dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0));
 
-    if (log)
-        log->Printf("Host::StartMonitoringChildProcess "
-                    "(callback, pid=%i, monitor_signals=%i) "
-                    "source = %p\n",
-                    static_cast<int>(pid), monitor_signals, reinterpret_cast<void *>(source));
-
-    if (source)
-    {
-        Host::MonitorChildProcessCallback callback_copy = callback;
-        ::dispatch_source_set_cancel_handler (source, ^{
-            ::dispatch_release (source);
-        });
-        ::dispatch_source_set_event_handler (source, ^{
-
-            int status= 0;
-            int wait_pid = 0;
-            bool cancel = false;
-            bool exited = false;
-            do
-            {
-                wait_pid = ::waitpid (pid, &status, 0);
-            } while (wait_pid < 0 && errno == EINTR);
-
-            if (wait_pid >= 0)
-            {
-                int signal = 0;
-                int exit_status = 0;
-                const char *status_cstr = NULL;
-                if (WIFSTOPPED(status))
-                {
-                    signal = WSTOPSIG(status);
-                    status_cstr = "STOPPED";
-                }
-                else if (WIFEXITED(status))
-                {
-                    exit_status = WEXITSTATUS(status);
-                    status_cstr = "EXITED";
-                    exited = true;
-                }
-                else if (WIFSIGNALED(status))
-                {
-                    signal = WTERMSIG(status);
-                    status_cstr = "SIGNALED";
-                    exited = true;
-                    exit_status = -1;
-                }
-                else
-                {
-                    status_cstr = "???";
-                }
-
-                if (log)
-                    log->Printf ("::waitpid (pid = %llu, &status, 0) => pid = %i, status = 0x%8.8x (%s), signal = %i, exit_status = %i",
-                                 pid,
-                                 wait_pid,
-                                 status,
-                                 status_cstr,
-                                 signal,
-                                 exit_status);
-
-                if (callback_copy)
-                    cancel = callback_copy(pid, exited, signal, exit_status);
-
-                if (exited || cancel)
-                {
-                    ::dispatch_source_cancel(source);
-                }
-            }
-        });
+  if (log)
+    log->Printf("Host::StartMonitoringChildProcess "
+                "(callback, pid=%i, monitor_signals=%i) "
+                "source = %p\n",
+                static_cast<int>(pid), monitor_signals,
+                reinterpret_cast<void *>(source));
 
-        ::dispatch_resume (source);
-    }
-    return HostThread();
+  if (source) {
+    Host::MonitorChildProcessCallback callback_copy = callback;
+    ::dispatch_source_set_cancel_handler(source, ^{
+      ::dispatch_release(source);
+    });
+    ::dispatch_source_set_event_handler(source, ^{
+
+      int status = 0;
+      int wait_pid = 0;
+      bool cancel = false;
+      bool exited = false;
+      do {
+        wait_pid = ::waitpid(pid, &status, 0);
+      } while (wait_pid < 0 && errno == EINTR);
+
+      if (wait_pid >= 0) {
+        int signal = 0;
+        int exit_status = 0;
+        const char *status_cstr = NULL;
+        if (WIFSTOPPED(status)) {
+          signal = WSTOPSIG(status);
+          status_cstr = "STOPPED";
+        } else if (WIFEXITED(status)) {
+          exit_status = WEXITSTATUS(status);
+          status_cstr = "EXITED";
+          exited = true;
+        } else if (WIFSIGNALED(status)) {
+          signal = WTERMSIG(status);
+          status_cstr = "SIGNALED";
+          exited = true;
+          exit_status = -1;
+        } else {
+          status_cstr = "???";
+        }
+
+        if (log)
+          log->Printf("::waitpid (pid = %llu, &status, 0) => pid = %i, status "
+                      "= 0x%8.8x (%s), signal = %i, exit_status = %i",
+                      pid, wait_pid, status, status_cstr, signal, exit_status);
+
+        if (callback_copy)
+          cancel = callback_copy(pid, exited, signal, exit_status);
+
+        if (exited || cancel) {
+          ::dispatch_source_cancel(source);
+        }
+      }
+    });
+
+    ::dispatch_resume(source);
+  }
+  return HostThread();
 }
 
 //----------------------------------------------------------------------
 // Log to both stderr and to ASL Logging when running on MacOSX.
 //----------------------------------------------------------------------
-void
-Host::SystemLog (SystemLogType type, const char *format, va_list args)
-{
-    if (format && format[0])
-    {
-        static aslmsg g_aslmsg = NULL;
-        if (g_aslmsg == NULL)
-        {
-            g_aslmsg = ::asl_new (ASL_TYPE_MSG);
-            char asl_key_sender[PATH_MAX];
-            snprintf(asl_key_sender, sizeof(asl_key_sender), "com.apple.LLDB.framework");
-            ::asl_set (g_aslmsg, ASL_KEY_SENDER, asl_key_sender);
-        }
-        
-        // Copy the va_list so we can log this message twice
-        va_list copy_args;
-        va_copy (copy_args, args);
-        // Log to stderr
-        ::vfprintf (stderr, format, copy_args);
-        va_end (copy_args);
-
-        int asl_level;
-        switch (type)
-        {
-            case eSystemLogError:
-                asl_level = ASL_LEVEL_ERR;
-                break;
-                
-            case eSystemLogWarning:
-                asl_level = ASL_LEVEL_WARNING;
-                break;
-        }
-        
-        // Log to ASL
-        ::asl_vlog (NULL, g_aslmsg, asl_level, format, args);
-    }
+void Host::SystemLog(SystemLogType type, const char *format, va_list args) {
+  if (format && format[0]) {
+    static aslmsg g_aslmsg = NULL;
+    if (g_aslmsg == NULL) {
+      g_aslmsg = ::asl_new(ASL_TYPE_MSG);
+      char asl_key_sender[PATH_MAX];
+      snprintf(asl_key_sender, sizeof(asl_key_sender),
+               "com.apple.LLDB.framework");
+      ::asl_set(g_aslmsg, ASL_KEY_SENDER, asl_key_sender);
+    }
+
+    // Copy the va_list so we can log this message twice
+    va_list copy_args;
+    va_copy(copy_args, args);
+    // Log to stderr
+    ::vfprintf(stderr, format, copy_args);
+    va_end(copy_args);
+
+    int asl_level;
+    switch (type) {
+    case eSystemLogError:
+      asl_level = ASL_LEVEL_ERR;
+      break;
+
+    case eSystemLogWarning:
+      asl_level = ASL_LEVEL_WARNING;
+      break;
+    }
+
+    // Log to ASL
+    ::asl_vlog(NULL, g_aslmsg, asl_level, format, args);
+  }
 }
 
-lldb::DataBufferSP
-Host::GetAuxvData(lldb_private::Process *process)
-{
-    return lldb::DataBufferSP();
+lldb::DataBufferSP Host::GetAuxvData(lldb_private::Process *process) {
+  return lldb::DataBufferSP();
 }

Modified: lldb/trunk/source/Host/macosx/HostInfoMacOSX.mm
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/HostInfoMacOSX.mm?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/HostInfoMacOSX.mm (original)
+++ lldb/trunk/source/Host/macosx/HostInfoMacOSX.mm Tue Sep  6 15:57:50 2016
@@ -11,9 +11,9 @@
 #include "Plugins/ScriptInterpreter/Python/lldb-python.h"
 #endif
 
+#include "lldb/Core/Log.h"
 #include "lldb/Host/HostInfo.h"
 #include "lldb/Host/macosx/HostInfoMacOSX.h"
-#include "lldb/Core/Log.h"
 #include "lldb/Interpreter/Args.h"
 #include "lldb/Utility/SafeMachO.h"
 
@@ -42,337 +42,294 @@
 #define CPU_SUBTYPE_X86_64_H ((cpu_subtype_t)8)
 #endif
 #ifndef CPU_TYPE_ARM64
-#define CPU_TYPE_ARM64 (CPU_TYPE_ARM|CPU_ARCH_ABI64)
+#define CPU_TYPE_ARM64 (CPU_TYPE_ARM | CPU_ARCH_ABI64)
 #endif
 
 #include <TargetConditionals.h> // for TARGET_OS_TV, TARGET_OS_WATCH
 
 using namespace lldb_private;
 
-bool
-HostInfoMacOSX::GetOSBuildString(std::string &s)
-{
-    int mib[2] = {CTL_KERN, KERN_OSVERSION};
-    char cstr[PATH_MAX];
-    size_t cstr_len = sizeof(cstr);
-    if (::sysctl(mib, 2, cstr, &cstr_len, NULL, 0) == 0)
-    {
-        s.assign(cstr, cstr_len);
-        return true;
-    }
+bool HostInfoMacOSX::GetOSBuildString(std::string &s) {
+  int mib[2] = {CTL_KERN, KERN_OSVERSION};
+  char cstr[PATH_MAX];
+  size_t cstr_len = sizeof(cstr);
+  if (::sysctl(mib, 2, cstr, &cstr_len, NULL, 0) == 0) {
+    s.assign(cstr, cstr_len);
+    return true;
+  }
 
-    s.clear();
-    return false;
+  s.clear();
+  return false;
 }
 
-bool
-HostInfoMacOSX::GetOSKernelDescription(std::string &s)
-{
-    int mib[2] = {CTL_KERN, KERN_VERSION};
-    char cstr[PATH_MAX];
-    size_t cstr_len = sizeof(cstr);
-    if (::sysctl(mib, 2, cstr, &cstr_len, NULL, 0) == 0)
-    {
-        s.assign(cstr, cstr_len);
-        return true;
-    }
-    s.clear();
-    return false;
+bool HostInfoMacOSX::GetOSKernelDescription(std::string &s) {
+  int mib[2] = {CTL_KERN, KERN_VERSION};
+  char cstr[PATH_MAX];
+  size_t cstr_len = sizeof(cstr);
+  if (::sysctl(mib, 2, cstr, &cstr_len, NULL, 0) == 0) {
+    s.assign(cstr, cstr_len);
+    return true;
+  }
+  s.clear();
+  return false;
+}
+
+bool HostInfoMacOSX::GetOSVersion(uint32_t &major, uint32_t &minor,
+                                  uint32_t &update) {
+  static uint32_t g_major = 0;
+  static uint32_t g_minor = 0;
+  static uint32_t g_update = 0;
+
+  if (g_major == 0) {
+    @autoreleasepool {
+      NSDictionary *version_info = [NSDictionary
+          dictionaryWithContentsOfFile:
+              @"/System/Library/CoreServices/SystemVersion.plist"];
+      NSString *version_value = [version_info objectForKey:@"ProductVersion"];
+      const char *version_str = [version_value UTF8String];
+      if (version_str)
+        Args::StringToVersion(version_str, g_major, g_minor, g_update);
+    }
+  }
+
+  if (g_major != 0) {
+    major = g_major;
+    minor = g_minor;
+    update = g_update;
+    return true;
+  }
+  return false;
 }
 
-bool
-HostInfoMacOSX::GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update)
-{
-    static uint32_t g_major = 0;
-    static uint32_t g_minor = 0;
-    static uint32_t g_update = 0;
-
-    if (g_major == 0)
-    {
-        @autoreleasepool
-        {
-            NSDictionary *version_info = [NSDictionary dictionaryWithContentsOfFile:@"/System/Library/CoreServices/SystemVersion.plist"];
-            NSString *version_value = [version_info objectForKey:@"ProductVersion"];
-            const char *version_str = [version_value UTF8String];
-            if (version_str)
-                Args::StringToVersion(version_str, g_major, g_minor, g_update);
-        }
-    }
-
-    if (g_major != 0)
-    {
-        major = g_major;
-        minor = g_minor;
-        update = g_update;
-        return true;
-    }
+FileSpec HostInfoMacOSX::GetProgramFileSpec() {
+  static FileSpec g_program_filespec;
+  if (!g_program_filespec) {
+    char program_fullpath[PATH_MAX];
+    // If DST is NULL, then return the number of bytes needed.
+    uint32_t len = sizeof(program_fullpath);
+    int err = _NSGetExecutablePath(program_fullpath, &len);
+    if (err == 0)
+      g_program_filespec.SetFile(program_fullpath, false);
+    else if (err == -1) {
+      char *large_program_fullpath = (char *)::malloc(len + 1);
+
+      err = _NSGetExecutablePath(large_program_fullpath, &len);
+      if (err == 0)
+        g_program_filespec.SetFile(large_program_fullpath, false);
+
+      ::free(large_program_fullpath);
+    }
+  }
+  return g_program_filespec;
+}
+
+bool HostInfoMacOSX::ComputeSupportExeDirectory(FileSpec &file_spec) {
+  FileSpec lldb_file_spec;
+  if (!GetLLDBPath(lldb::ePathTypeLLDBShlibDir, lldb_file_spec))
     return false;
-}
-
-FileSpec
-HostInfoMacOSX::GetProgramFileSpec()
-{
-    static FileSpec g_program_filespec;
-    if (!g_program_filespec)
-    {
-        char program_fullpath[PATH_MAX];
-        // If DST is NULL, then return the number of bytes needed.
-        uint32_t len = sizeof(program_fullpath);
-        int err = _NSGetExecutablePath(program_fullpath, &len);
-        if (err == 0)
-            g_program_filespec.SetFile(program_fullpath, false);
-        else if (err == -1)
-        {
-            char *large_program_fullpath = (char *)::malloc(len + 1);
-
-            err = _NSGetExecutablePath(large_program_fullpath, &len);
-            if (err == 0)
-                g_program_filespec.SetFile(large_program_fullpath, false);
 
-            ::free(large_program_fullpath);
-        }
-    }
-    return g_program_filespec;
-}
+  std::string raw_path = lldb_file_spec.GetPath();
 
-bool
-HostInfoMacOSX::ComputeSupportExeDirectory(FileSpec &file_spec)
-{
-    FileSpec lldb_file_spec;
-    if (!GetLLDBPath(lldb::ePathTypeLLDBShlibDir, lldb_file_spec))
-        return false;
-
-    std::string raw_path = lldb_file_spec.GetPath();
-
-    size_t framework_pos = raw_path.find("LLDB.framework");
-    if (framework_pos != std::string::npos)
-    {
-        framework_pos += strlen("LLDB.framework");
+  size_t framework_pos = raw_path.find("LLDB.framework");
+  if (framework_pos != std::string::npos) {
+    framework_pos += strlen("LLDB.framework");
 #if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
-        // Shallow bundle
-        raw_path.resize(framework_pos);
+    // Shallow bundle
+    raw_path.resize(framework_pos);
 #else
-        // Normal bundle
-        raw_path.resize(framework_pos);
-        raw_path.append("/Resources");
+    // Normal bundle
+    raw_path.resize(framework_pos);
+    raw_path.append("/Resources");
 #endif
-    }
-    else
-    {
-        // Find the bin path relative to the lib path where the cmake-based
-        // OS X .dylib lives.  This is not going to work if the bin and lib
-        // dir are not both in the same dir.
-        //
-        // It is not going to work to do it by the executable path either,
-        // as in the case of a python script, the executable is python, not
-        // the lldb driver.
-        raw_path.append("/../bin");
-        FileSpec support_dir_spec(raw_path, true);
-        if (!support_dir_spec.Exists() || !support_dir_spec.IsDirectory())
-        {
-            Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
-            if (log)
-                log->Printf("HostInfoMacOSX::%s(): failed to find support directory",
-                            __FUNCTION__);
-            return false;
-        }
-
-        // Get normalization from support_dir_spec.  Note the FileSpec resolve
-        // does not remove '..' in the path.
-        char *const dir_realpath = realpath(support_dir_spec.GetPath().c_str(), NULL);
-        if (dir_realpath)
-        {
-            raw_path = dir_realpath;
-            free(dir_realpath);
-        }
-        else
-        {
-            raw_path = support_dir_spec.GetPath();
-        }
-    }
+  } else {
+    // Find the bin path relative to the lib path where the cmake-based
+    // OS X .dylib lives.  This is not going to work if the bin and lib
+    // dir are not both in the same dir.
+    //
+    // It is not going to work to do it by the executable path either,
+    // as in the case of a python script, the executable is python, not
+    // the lldb driver.
+    raw_path.append("/../bin");
+    FileSpec support_dir_spec(raw_path, true);
+    if (!support_dir_spec.Exists() || !support_dir_spec.IsDirectory()) {
+      Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+      if (log)
+        log->Printf("HostInfoMacOSX::%s(): failed to find support directory",
+                    __FUNCTION__);
+      return false;
+    }
+
+    // Get normalization from support_dir_spec.  Note the FileSpec resolve
+    // does not remove '..' in the path.
+    char *const dir_realpath =
+        realpath(support_dir_spec.GetPath().c_str(), NULL);
+    if (dir_realpath) {
+      raw_path = dir_realpath;
+      free(dir_realpath);
+    } else {
+      raw_path = support_dir_spec.GetPath();
+    }
+  }
+
+  file_spec.GetDirectory().SetString(
+      llvm::StringRef(raw_path.c_str(), raw_path.size()));
+  return (bool)file_spec.GetDirectory();
+}
+
+bool HostInfoMacOSX::ComputeHeaderDirectory(FileSpec &file_spec) {
+  FileSpec lldb_file_spec;
+  if (!HostInfo::GetLLDBPath(lldb::ePathTypeLLDBShlibDir, lldb_file_spec))
+    return false;
 
-    file_spec.GetDirectory().SetString(llvm::StringRef(raw_path.c_str(), raw_path.size()));
-    return (bool)file_spec.GetDirectory();
-}
+  std::string raw_path = lldb_file_spec.GetPath();
 
-bool
-HostInfoMacOSX::ComputeHeaderDirectory(FileSpec &file_spec)
-{
-    FileSpec lldb_file_spec;
-    if (!HostInfo::GetLLDBPath(lldb::ePathTypeLLDBShlibDir, lldb_file_spec))
-        return false;
-
-    std::string raw_path = lldb_file_spec.GetPath();
-
-    size_t framework_pos = raw_path.find("LLDB.framework");
-    if (framework_pos != std::string::npos)
-    {
-        framework_pos += strlen("LLDB.framework");
-        raw_path.resize(framework_pos);
-        raw_path.append("/Headers");
-    }
-    file_spec.GetDirectory().SetString(llvm::StringRef(raw_path.c_str(), raw_path.size()));
-    return true;
+  size_t framework_pos = raw_path.find("LLDB.framework");
+  if (framework_pos != std::string::npos) {
+    framework_pos += strlen("LLDB.framework");
+    raw_path.resize(framework_pos);
+    raw_path.append("/Headers");
+  }
+  file_spec.GetDirectory().SetString(
+      llvm::StringRef(raw_path.c_str(), raw_path.size()));
+  return true;
 }
 
-bool
-HostInfoMacOSX::ComputePythonDirectory(FileSpec &file_spec)
-{
+bool HostInfoMacOSX::ComputePythonDirectory(FileSpec &file_spec) {
 #ifndef LLDB_DISABLE_PYTHON
-    FileSpec lldb_file_spec;
-    if (!GetLLDBPath(lldb::ePathTypeLLDBShlibDir, lldb_file_spec))
-        return false;
-
-    std::string raw_path = lldb_file_spec.GetPath();
-
-    size_t framework_pos = raw_path.find("LLDB.framework");
-    if (framework_pos != std::string::npos)
-    {
-        framework_pos += strlen("LLDB.framework");
-        raw_path.resize(framework_pos);
-        raw_path.append("/Resources/Python");
-    }
-    else
-    {
-        llvm::SmallString<256> python_version_dir;
-        llvm::raw_svector_ostream os(python_version_dir);
-        os << "/python" << PY_MAJOR_VERSION << '.' << PY_MINOR_VERSION << "/site-packages";
+  FileSpec lldb_file_spec;
+  if (!GetLLDBPath(lldb::ePathTypeLLDBShlibDir, lldb_file_spec))
+    return false;
 
-        // We may get our string truncated. Should we protect this with an assert?
-        raw_path.append(python_version_dir.c_str());
-    }
-    file_spec.GetDirectory().SetString(llvm::StringRef(raw_path.c_str(), raw_path.size()));
-    return true;
+  std::string raw_path = lldb_file_spec.GetPath();
+
+  size_t framework_pos = raw_path.find("LLDB.framework");
+  if (framework_pos != std::string::npos) {
+    framework_pos += strlen("LLDB.framework");
+    raw_path.resize(framework_pos);
+    raw_path.append("/Resources/Python");
+  } else {
+    llvm::SmallString<256> python_version_dir;
+    llvm::raw_svector_ostream os(python_version_dir);
+    os << "/python" << PY_MAJOR_VERSION << '.' << PY_MINOR_VERSION
+       << "/site-packages";
+
+    // We may get our string truncated. Should we protect this with an assert?
+    raw_path.append(python_version_dir.c_str());
+  }
+  file_spec.GetDirectory().SetString(
+      llvm::StringRef(raw_path.c_str(), raw_path.size()));
+  return true;
 #else
-    return false;
+  return false;
 #endif
 }
 
-bool
-HostInfoMacOSX::ComputeClangDirectory(FileSpec &file_spec)
-{
-    FileSpec lldb_file_spec;
-    if (!GetLLDBPath (lldb::ePathTypeLLDBShlibDir, lldb_file_spec))
-        return false;
-    
-    std::string raw_path = lldb_file_spec.GetPath();
-    
-    size_t framework_pos = raw_path.find("LLDB.framework");
-    if (framework_pos != std::string::npos)
-    {
-        framework_pos += strlen("LLDB.framework");
-        raw_path.resize(framework_pos);
-        raw_path.append("/Resources/Clang");
-    }
-    file_spec.SetFile (raw_path.c_str(), true);
-    return true;
-}
+bool HostInfoMacOSX::ComputeClangDirectory(FileSpec &file_spec) {
+  FileSpec lldb_file_spec;
+  if (!GetLLDBPath(lldb::ePathTypeLLDBShlibDir, lldb_file_spec))
+    return false;
 
-bool
-HostInfoMacOSX::ComputeSystemPluginsDirectory(FileSpec &file_spec)
-{
-    FileSpec lldb_file_spec;
-    if (!GetLLDBPath(lldb::ePathTypeLLDBShlibDir, lldb_file_spec))
-        return false;
-
-    std::string raw_path = lldb_file_spec.GetPath();
-
-    size_t framework_pos = raw_path.find("LLDB.framework");
-    if (framework_pos == std::string::npos)
-        return false;
+  std::string raw_path = lldb_file_spec.GetPath();
 
+  size_t framework_pos = raw_path.find("LLDB.framework");
+  if (framework_pos != std::string::npos) {
     framework_pos += strlen("LLDB.framework");
     raw_path.resize(framework_pos);
-    raw_path.append("/Resources/PlugIns");
-    file_spec.GetDirectory().SetString(llvm::StringRef(raw_path.c_str(), raw_path.size()));
-    return true;
+    raw_path.append("/Resources/Clang");
+  }
+  file_spec.SetFile(raw_path.c_str(), true);
+  return true;
 }
 
-bool
-HostInfoMacOSX::ComputeUserPluginsDirectory(FileSpec &file_spec)
-{
-    FileSpec temp_file("~/Library/Application Support/LLDB/PlugIns", true);
-    file_spec.GetDirectory().SetCString(temp_file.GetPath().c_str());
-    return true;
-}
+bool HostInfoMacOSX::ComputeSystemPluginsDirectory(FileSpec &file_spec) {
+  FileSpec lldb_file_spec;
+  if (!GetLLDBPath(lldb::ePathTypeLLDBShlibDir, lldb_file_spec))
+    return false;
+
+  std::string raw_path = lldb_file_spec.GetPath();
 
-void
-HostInfoMacOSX::ComputeHostArchitectureSupport(ArchSpec &arch_32, ArchSpec &arch_64)
-{
-    // All apple systems support 32 bit execution.
-    uint32_t cputype, cpusubtype;
-    uint32_t is_64_bit_capable = false;
-    size_t len = sizeof(cputype);
-    ArchSpec host_arch;
-    // These will tell us about the kernel architecture, which even on a 64
-    // bit machine can be 32 bit...
-    if (::sysctlbyname("hw.cputype", &cputype, &len, NULL, 0) == 0)
-    {
-        len = sizeof(cpusubtype);
-        if (::sysctlbyname("hw.cpusubtype", &cpusubtype, &len, NULL, 0) != 0)
-            cpusubtype = CPU_TYPE_ANY;
-
-        len = sizeof(is_64_bit_capable);
-        ::sysctlbyname("hw.cpu64bit_capable", &is_64_bit_capable, &len, NULL, 0);
-
-        if (is_64_bit_capable)
-        {
-            if (cputype & CPU_ARCH_ABI64)
-            {
-                // We have a 64 bit kernel on a 64 bit system
-                arch_64.SetArchitecture(eArchTypeMachO, cputype, cpusubtype);
-            }
-            else
-            {
-                // We have a 64 bit kernel that is returning a 32 bit cputype, the
-                // cpusubtype will be correct as if it were for a 64 bit architecture
-                arch_64.SetArchitecture(eArchTypeMachO, cputype | CPU_ARCH_ABI64, cpusubtype);
-            }
+  size_t framework_pos = raw_path.find("LLDB.framework");
+  if (framework_pos == std::string::npos)
+    return false;
 
-            // Now we need modify the cpusubtype for the 32 bit slices.
-            uint32_t cpusubtype32 = cpusubtype;
+  framework_pos += strlen("LLDB.framework");
+  raw_path.resize(framework_pos);
+  raw_path.append("/Resources/PlugIns");
+  file_spec.GetDirectory().SetString(
+      llvm::StringRef(raw_path.c_str(), raw_path.size()));
+  return true;
+}
+
+bool HostInfoMacOSX::ComputeUserPluginsDirectory(FileSpec &file_spec) {
+  FileSpec temp_file("~/Library/Application Support/LLDB/PlugIns", true);
+  file_spec.GetDirectory().SetCString(temp_file.GetPath().c_str());
+  return true;
+}
+
+void HostInfoMacOSX::ComputeHostArchitectureSupport(ArchSpec &arch_32,
+                                                    ArchSpec &arch_64) {
+  // All apple systems support 32 bit execution.
+  uint32_t cputype, cpusubtype;
+  uint32_t is_64_bit_capable = false;
+  size_t len = sizeof(cputype);
+  ArchSpec host_arch;
+  // These will tell us about the kernel architecture, which even on a 64
+  // bit machine can be 32 bit...
+  if (::sysctlbyname("hw.cputype", &cputype, &len, NULL, 0) == 0) {
+    len = sizeof(cpusubtype);
+    if (::sysctlbyname("hw.cpusubtype", &cpusubtype, &len, NULL, 0) != 0)
+      cpusubtype = CPU_TYPE_ANY;
+
+    len = sizeof(is_64_bit_capable);
+    ::sysctlbyname("hw.cpu64bit_capable", &is_64_bit_capable, &len, NULL, 0);
+
+    if (is_64_bit_capable) {
+      if (cputype & CPU_ARCH_ABI64) {
+        // We have a 64 bit kernel on a 64 bit system
+        arch_64.SetArchitecture(eArchTypeMachO, cputype, cpusubtype);
+      } else {
+        // We have a 64 bit kernel that is returning a 32 bit cputype, the
+        // cpusubtype will be correct as if it were for a 64 bit architecture
+        arch_64.SetArchitecture(eArchTypeMachO, cputype | CPU_ARCH_ABI64,
+                                cpusubtype);
+      }
+
+      // Now we need modify the cpusubtype for the 32 bit slices.
+      uint32_t cpusubtype32 = cpusubtype;
 #if defined(__i386__) || defined(__x86_64__)
-            if (cpusubtype == CPU_SUBTYPE_486 || cpusubtype == CPU_SUBTYPE_X86_64_H)
-                cpusubtype32 = CPU_SUBTYPE_I386_ALL;
+      if (cpusubtype == CPU_SUBTYPE_486 || cpusubtype == CPU_SUBTYPE_X86_64_H)
+        cpusubtype32 = CPU_SUBTYPE_I386_ALL;
 #elif defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
-            if (cputype == CPU_TYPE_ARM || cputype == CPU_TYPE_ARM64)
-                cpusubtype32 = CPU_SUBTYPE_ARM_V7S;
+      if (cputype == CPU_TYPE_ARM || cputype == CPU_TYPE_ARM64)
+        cpusubtype32 = CPU_SUBTYPE_ARM_V7S;
 #endif
-            arch_32.SetArchitecture(eArchTypeMachO, cputype & ~(CPU_ARCH_MASK), cpusubtype32);
+      arch_32.SetArchitecture(eArchTypeMachO, cputype & ~(CPU_ARCH_MASK),
+                              cpusubtype32);
 
-            if (cputype == CPU_TYPE_ARM || cputype == CPU_TYPE_ARM64)
-            {
-                // When running on a watch or tv, report the host os correctly
-#if defined (TARGET_OS_TV) && TARGET_OS_TV == 1
-                arch_32.GetTriple().setOS(llvm::Triple::TvOS);
-                arch_64.GetTriple().setOS(llvm::Triple::TvOS);
+      if (cputype == CPU_TYPE_ARM || cputype == CPU_TYPE_ARM64) {
+// When running on a watch or tv, report the host os correctly
+#if defined(TARGET_OS_TV) && TARGET_OS_TV == 1
+        arch_32.GetTriple().setOS(llvm::Triple::TvOS);
+        arch_64.GetTriple().setOS(llvm::Triple::TvOS);
 #else
-                arch_32.GetTriple().setOS(llvm::Triple::IOS);
-                arch_64.GetTriple().setOS(llvm::Triple::IOS);
+        arch_32.GetTriple().setOS(llvm::Triple::IOS);
+        arch_64.GetTriple().setOS(llvm::Triple::IOS);
 #endif
-            }
-            else
-            {
-                arch_32.GetTriple().setOS(llvm::Triple::MacOSX);
-                arch_64.GetTriple().setOS(llvm::Triple::MacOSX);
-            }
-        }
-        else
-        {
-            // We have a 32 bit kernel on a 32 bit system
-            arch_32.SetArchitecture(eArchTypeMachO, cputype, cpusubtype);
-#if defined (TARGET_OS_WATCH) && TARGET_OS_WATCH == 1
-            arch_32.GetTriple().setOS(llvm::Triple::WatchOS);
+      } else {
+        arch_32.GetTriple().setOS(llvm::Triple::MacOSX);
+        arch_64.GetTriple().setOS(llvm::Triple::MacOSX);
+      }
+    } else {
+      // We have a 32 bit kernel on a 32 bit system
+      arch_32.SetArchitecture(eArchTypeMachO, cputype, cpusubtype);
+#if defined(TARGET_OS_WATCH) && TARGET_OS_WATCH == 1
+      arch_32.GetTriple().setOS(llvm::Triple::WatchOS);
 #else
-            arch_32.GetTriple().setOS(llvm::Triple::IOS);
+      arch_32.GetTriple().setOS(llvm::Triple::IOS);
 #endif
-            arch_64.Clear();
-        }
+      arch_64.Clear();
     }
+  }
 }
 
-uint32_t
-HostInfoMacOSX::GetMaxThreadNameLength()
-{
-    return 64;
-}
+uint32_t HostInfoMacOSX::GetMaxThreadNameLength() { return 64; }

Modified: lldb/trunk/source/Host/macosx/HostThreadMacOSX.mm
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/HostThreadMacOSX.mm?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/HostThreadMacOSX.mm (original)
+++ lldb/trunk/source/Host/macosx/HostThreadMacOSX.mm Tue Sep  6 15:57:50 2016
@@ -17,70 +17,54 @@
 
 using namespace lldb_private;
 
-namespace
-{
+namespace {
 
 pthread_once_t g_thread_create_once = PTHREAD_ONCE_INIT;
 pthread_key_t g_thread_create_key = 0;
 
-class MacOSXDarwinThread
-{
-  public:
-    MacOSXDarwinThread()
-        : m_pool(nil)
-    {
-        m_pool = [[NSAutoreleasePool alloc] init];
+class MacOSXDarwinThread {
+public:
+  MacOSXDarwinThread() : m_pool(nil) {
+    m_pool = [[NSAutoreleasePool alloc] init];
+  }
+
+  ~MacOSXDarwinThread() {
+    if (m_pool) {
+      [m_pool drain];
+      m_pool = nil;
     }
+  }
 
-    ~MacOSXDarwinThread()
-    {
-        if (m_pool)
-        {
-            [m_pool drain];
-            m_pool = nil;
-        }
-    }
-
-    static void
-    PThreadDestructor(void *v)
-    {
-        if (v)
-            delete static_cast<MacOSXDarwinThread *>(v);
-        ::pthread_setspecific(g_thread_create_key, NULL);
-    }
+  static void PThreadDestructor(void *v) {
+    if (v)
+      delete static_cast<MacOSXDarwinThread *>(v);
+    ::pthread_setspecific(g_thread_create_key, NULL);
+  }
 
-  protected:
-    NSAutoreleasePool *m_pool;
+protected:
+  NSAutoreleasePool *m_pool;
 
-  private:
-    DISALLOW_COPY_AND_ASSIGN(MacOSXDarwinThread);
+private:
+  DISALLOW_COPY_AND_ASSIGN(MacOSXDarwinThread);
 };
 
-void
-InitThreadCreated()
-{
-    ::pthread_key_create(&g_thread_create_key, MacOSXDarwinThread::PThreadDestructor);
+void InitThreadCreated() {
+  ::pthread_key_create(&g_thread_create_key,
+                       MacOSXDarwinThread::PThreadDestructor);
 }
 } // namespace
 
-HostThreadMacOSX::HostThreadMacOSX()
-    : HostThreadPosix()
-{
-}
+HostThreadMacOSX::HostThreadMacOSX() : HostThreadPosix() {}
 
 HostThreadMacOSX::HostThreadMacOSX(lldb::thread_t thread)
-    : HostThreadPosix(thread)
-{
-}
+    : HostThreadPosix(thread) {}
 
 lldb::thread_result_t
-HostThreadMacOSX::ThreadCreateTrampoline(lldb::thread_arg_t arg)
-{
-    ::pthread_once(&g_thread_create_once, InitThreadCreated);
-    if (g_thread_create_key)
-    {
-        ::pthread_setspecific(g_thread_create_key, new MacOSXDarwinThread());
-    }
+HostThreadMacOSX::ThreadCreateTrampoline(lldb::thread_arg_t arg) {
+  ::pthread_once(&g_thread_create_once, InitThreadCreated);
+  if (g_thread_create_key) {
+    ::pthread_setspecific(g_thread_create_key, new MacOSXDarwinThread());
+  }
 
-    return HostThreadPosix::ThreadCreateTrampoline(arg);
+  return HostThreadPosix::ThreadCreateTrampoline(arg);
 }

Modified: lldb/trunk/source/Host/macosx/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Symbols.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/Symbols.cpp (original)
+++ lldb/trunk/source/Host/macosx/Symbols.cpp Tue Sep  6 15:57:50 2016
@@ -10,15 +10,19 @@
 #include "lldb/Host/Symbols.h"
 
 // C Includes
+#include "lldb/Utility/SafeMachO.h"
 #include <dirent.h>
 #include <pwd.h>
-#include "lldb/Utility/SafeMachO.h"
 
 // C++ Includes
 // Other libraries and framework includes
 #include <CoreFoundation/CoreFoundation.h>
 
 // Project includes
+#include "Host/macosx/cfcpp/CFCBundle.h"
+#include "Host/macosx/cfcpp/CFCData.h"
+#include "Host/macosx/cfcpp/CFCReleaser.h"
+#include "Host/macosx/cfcpp/CFCString.h"
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/DataBuffer.h"
 #include "lldb/Core/DataExtractor.h"
@@ -32,590 +36,554 @@
 #include "lldb/Host/Host.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Utility/CleanUp.h"
-#include "Host/macosx/cfcpp/CFCBundle.h"
-#include "Host/macosx/cfcpp/CFCData.h"
-#include "Host/macosx/cfcpp/CFCReleaser.h"
-#include "Host/macosx/cfcpp/CFCString.h"
 #include "mach/machine.h"
 
 using namespace lldb;
 using namespace lldb_private;
 using namespace llvm::MachO;
 
-#if !defined (__arm__) && !defined (__arm64__) && !defined (__aarch64__) // No DebugSymbols on the iOS devices
+#if !defined(__arm__) && !defined(__arm64__) &&                                \
+    !defined(__aarch64__) // No DebugSymbols on the iOS devices
 extern "C" {
 
-CFURLRef DBGCopyFullDSYMURLForUUID (CFUUIDRef uuid, CFURLRef exec_url);
-CFDictionaryRef DBGCopyDSYMPropertyLists (CFURLRef dsym_url);
-
+CFURLRef DBGCopyFullDSYMURLForUUID(CFUUIDRef uuid, CFURLRef exec_url);
+CFDictionaryRef DBGCopyDSYMPropertyLists(CFURLRef dsym_url);
 }
 #endif
 
-int
-LocateMacOSXFilesUsingDebugSymbols
-(
-    const ModuleSpec &module_spec,
-    ModuleSpec &return_module_spec
-)
-{
-    return_module_spec = module_spec;
-    return_module_spec.GetFileSpec().Clear();
-    return_module_spec.GetSymbolFileSpec().Clear();
-
-    int items_found = 0;
-
-#if !defined (__arm__) && !defined (__arm64__) && !defined (__aarch64__) // No DebugSymbols on the iOS devices
-
-    const UUID *uuid = module_spec.GetUUIDPtr();
-    const ArchSpec *arch = module_spec.GetArchitecturePtr();
-
-    if (uuid && uuid->IsValid())
-    {
-        // Try and locate the dSYM file using DebugSymbols first
-        const UInt8 *module_uuid = (const UInt8 *)uuid->GetBytes();
-        if (module_uuid != NULL)
-        {
-            CFCReleaser<CFUUIDRef> module_uuid_ref(::CFUUIDCreateWithBytes (NULL,
-                                                                            module_uuid[0],
-                                                                            module_uuid[1],
-                                                                            module_uuid[2],
-                                                                            module_uuid[3],
-                                                                            module_uuid[4],
-                                                                            module_uuid[5],
-                                                                            module_uuid[6],
-                                                                            module_uuid[7],
-                                                                            module_uuid[8],
-                                                                            module_uuid[9],
-                                                                            module_uuid[10],
-                                                                            module_uuid[11],
-                                                                            module_uuid[12],
-                                                                            module_uuid[13],
-                                                                            module_uuid[14],
-                                                                            module_uuid[15]));
-
-            if (module_uuid_ref.get())
-            {
-                CFCReleaser<CFURLRef> exec_url;
-                const FileSpec *exec_fspec = module_spec.GetFileSpecPtr();
-                Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
-                if (exec_fspec)
-                {
-                    char exec_cf_path[PATH_MAX];
-                    if (exec_fspec->GetPath(exec_cf_path, sizeof(exec_cf_path)))
-                        exec_url.reset(::CFURLCreateFromFileSystemRepresentation (NULL,
-                                                                                  (const UInt8 *)exec_cf_path,
-                                                                                  strlen(exec_cf_path),
-                                                                                  FALSE));
-                }
-
-                CFCReleaser<CFURLRef> dsym_url (::DBGCopyFullDSYMURLForUUID(module_uuid_ref.get(), exec_url.get()));
-                char path[PATH_MAX];
-
-                if (dsym_url.get())
-                {
-                    if (::CFURLGetFileSystemRepresentation (dsym_url.get(), true, (UInt8*)path, sizeof(path)-1))
-                    {
-                        if (log)
-                        {
-                            log->Printf ("DebugSymbols framework returned dSYM path of %s for UUID %s -- looking for the dSYM", path, uuid->GetAsString().c_str());
-                        }
-                        FileSpec dsym_filespec(path, path[0] == '~');
-
-                        if (dsym_filespec.GetFileType () == FileSpec::eFileTypeDirectory)
-                        {
-                            dsym_filespec = Symbols::FindSymbolFileInBundle (dsym_filespec, uuid, arch);
-                            ++items_found;
-                        }
-                        else
-                        {
-                            ++items_found;
-                        }
-                        return_module_spec.GetSymbolFileSpec() = dsym_filespec;
-                    }
-
-                    bool success = false;
-                    if (log)
-                    {
-                        if (::CFURLGetFileSystemRepresentation (dsym_url.get(), true, (UInt8*)path, sizeof(path)-1))
-                        {
-                            log->Printf ("DebugSymbols framework returned dSYM path of %s for UUID %s -- looking for an exec file", path, uuid->GetAsString().c_str());
-                        }
-
-                    }
-
-                    CFCReleaser<CFDictionaryRef> dict(::DBGCopyDSYMPropertyLists (dsym_url.get()));
-                    CFDictionaryRef uuid_dict = NULL;
-                    if (dict.get())
-                    {
-                        CFCString uuid_cfstr (uuid->GetAsString().c_str());
-                        uuid_dict = static_cast<CFDictionaryRef>(::CFDictionaryGetValue (dict.get(), uuid_cfstr.get()));
-                    }
-                    if (uuid_dict)
-                    {
-                        CFStringRef exec_cf_path = static_cast<CFStringRef>(::CFDictionaryGetValue (uuid_dict, CFSTR("DBGSymbolRichExecutable")));
-                        if (exec_cf_path && ::CFStringGetFileSystemRepresentation (exec_cf_path, path, sizeof(path)))
-                        {
-                            if (log)
-                            {
-                                log->Printf ("plist bundle has exec path of %s for UUID %s", path, uuid->GetAsString().c_str());
-                            }
-                            ++items_found;
-                            FileSpec exec_filespec (path, path[0] == '~');
-                            if (exec_filespec.Exists())
-                            {
-                                success = true;
-                                return_module_spec.GetFileSpec() = exec_filespec;
-                            }
-                        }
-                    }
+int LocateMacOSXFilesUsingDebugSymbols(const ModuleSpec &module_spec,
+                                       ModuleSpec &return_module_spec) {
+  return_module_spec = module_spec;
+  return_module_spec.GetFileSpec().Clear();
+  return_module_spec.GetSymbolFileSpec().Clear();
+
+  int items_found = 0;
+
+#if !defined(__arm__) && !defined(__arm64__) &&                                \
+    !defined(__aarch64__) // No DebugSymbols on the iOS devices
+
+  const UUID *uuid = module_spec.GetUUIDPtr();
+  const ArchSpec *arch = module_spec.GetArchitecturePtr();
+
+  if (uuid && uuid->IsValid()) {
+    // Try and locate the dSYM file using DebugSymbols first
+    const UInt8 *module_uuid = (const UInt8 *)uuid->GetBytes();
+    if (module_uuid != NULL) {
+      CFCReleaser<CFUUIDRef> module_uuid_ref(::CFUUIDCreateWithBytes(
+          NULL, module_uuid[0], module_uuid[1], module_uuid[2], module_uuid[3],
+          module_uuid[4], module_uuid[5], module_uuid[6], module_uuid[7],
+          module_uuid[8], module_uuid[9], module_uuid[10], module_uuid[11],
+          module_uuid[12], module_uuid[13], module_uuid[14], module_uuid[15]));
+
+      if (module_uuid_ref.get()) {
+        CFCReleaser<CFURLRef> exec_url;
+        const FileSpec *exec_fspec = module_spec.GetFileSpecPtr();
+        Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+        if (exec_fspec) {
+          char exec_cf_path[PATH_MAX];
+          if (exec_fspec->GetPath(exec_cf_path, sizeof(exec_cf_path)))
+            exec_url.reset(::CFURLCreateFromFileSystemRepresentation(
+                NULL, (const UInt8 *)exec_cf_path, strlen(exec_cf_path),
+                FALSE));
+        }
+
+        CFCReleaser<CFURLRef> dsym_url(
+            ::DBGCopyFullDSYMURLForUUID(module_uuid_ref.get(), exec_url.get()));
+        char path[PATH_MAX];
+
+        if (dsym_url.get()) {
+          if (::CFURLGetFileSystemRepresentation(
+                  dsym_url.get(), true, (UInt8 *)path, sizeof(path) - 1)) {
+            if (log) {
+              log->Printf("DebugSymbols framework returned dSYM path of %s for "
+                          "UUID %s -- looking for the dSYM",
+                          path, uuid->GetAsString().c_str());
+            }
+            FileSpec dsym_filespec(path, path[0] == '~');
+
+            if (dsym_filespec.GetFileType() == FileSpec::eFileTypeDirectory) {
+              dsym_filespec =
+                  Symbols::FindSymbolFileInBundle(dsym_filespec, uuid, arch);
+              ++items_found;
+            } else {
+              ++items_found;
+            }
+            return_module_spec.GetSymbolFileSpec() = dsym_filespec;
+          }
+
+          bool success = false;
+          if (log) {
+            if (::CFURLGetFileSystemRepresentation(
+                    dsym_url.get(), true, (UInt8 *)path, sizeof(path) - 1)) {
+              log->Printf("DebugSymbols framework returned dSYM path of %s for "
+                          "UUID %s -- looking for an exec file",
+                          path, uuid->GetAsString().c_str());
+            }
+          }
+
+          CFCReleaser<CFDictionaryRef> dict(
+              ::DBGCopyDSYMPropertyLists(dsym_url.get()));
+          CFDictionaryRef uuid_dict = NULL;
+          if (dict.get()) {
+            CFCString uuid_cfstr(uuid->GetAsString().c_str());
+            uuid_dict = static_cast<CFDictionaryRef>(
+                ::CFDictionaryGetValue(dict.get(), uuid_cfstr.get()));
+          }
+          if (uuid_dict) {
+            CFStringRef exec_cf_path =
+                static_cast<CFStringRef>(::CFDictionaryGetValue(
+                    uuid_dict, CFSTR("DBGSymbolRichExecutable")));
+            if (exec_cf_path && ::CFStringGetFileSystemRepresentation(
+                                    exec_cf_path, path, sizeof(path))) {
+              if (log) {
+                log->Printf("plist bundle has exec path of %s for UUID %s",
+                            path, uuid->GetAsString().c_str());
+              }
+              ++items_found;
+              FileSpec exec_filespec(path, path[0] == '~');
+              if (exec_filespec.Exists()) {
+                success = true;
+                return_module_spec.GetFileSpec() = exec_filespec;
+              }
+            }
+          }
 
-                    if (!success)
-                    {
-                        // No dictionary, check near the dSYM bundle for an executable that matches...
-                        if (::CFURLGetFileSystemRepresentation (dsym_url.get(), true, (UInt8*)path, sizeof(path)-1))
-                        {
-                            char *dsym_extension_pos = ::strstr (path, ".dSYM");
-                            if (dsym_extension_pos)
-                            {
-                                *dsym_extension_pos = '\0';
-                                if (log)
-                                {
-                                    log->Printf ("Looking for executable binary next to dSYM bundle with name with name %s", path);
-                                }
-                                FileSpec file_spec (path, true);
-                                ModuleSpecList module_specs;
-                                ModuleSpec matched_module_spec;
-                                switch (file_spec.GetFileType())
-                                {
-                                    case FileSpec::eFileTypeDirectory:  // Bundle directory?
-                                        {
-                                            CFCBundle bundle (path);
-                                            CFCReleaser<CFURLRef> bundle_exe_url (bundle.CopyExecutableURL ());
-                                            if (bundle_exe_url.get())
-                                            {
-                                                if (::CFURLGetFileSystemRepresentation (bundle_exe_url.get(), true, (UInt8*)path, sizeof(path)-1))
-                                                {
-                                                    FileSpec bundle_exe_file_spec (path, true);
-                                                    if (ObjectFile::GetModuleSpecifications(bundle_exe_file_spec, 0, 0, module_specs) &&
-                                                        module_specs.FindMatchingModuleSpec(module_spec, matched_module_spec))
-
-                                                    {
-                                                        ++items_found;
-                                                        return_module_spec.GetFileSpec() = bundle_exe_file_spec;
-                                                        if (log)
-                                                        {
-                                                            log->Printf ("Executable binary %s next to dSYM is compatible; using", path);
-                                                        }
-                                                    }
-                                                }
-                                            }
-                                        }
-                                        break;
-
-                                    case FileSpec::eFileTypePipe:       // Forget pipes
-                                    case FileSpec::eFileTypeSocket:     // We can't process socket files
-                                    case FileSpec::eFileTypeInvalid:    // File doesn't exist...
-                                        break;
-
-                                    case FileSpec::eFileTypeUnknown:
-                                    case FileSpec::eFileTypeRegular:
-                                    case FileSpec::eFileTypeSymbolicLink:
-                                    case FileSpec::eFileTypeOther:
-                                        if (ObjectFile::GetModuleSpecifications(file_spec, 0, 0, module_specs) &&
-                                            module_specs.FindMatchingModuleSpec(module_spec, matched_module_spec))
-
-                                        {
-                                            ++items_found;
-                                            return_module_spec.GetFileSpec() = file_spec;
-                                            if (log)
-                                            {
-                                                log->Printf ("Executable binary %s next to dSYM is compatible; using", path);
-                                            }
-                                        }
-                                        break;
-                                }
-                            }
-                        }
+          if (!success) {
+            // No dictionary, check near the dSYM bundle for an executable that
+            // matches...
+            if (::CFURLGetFileSystemRepresentation(
+                    dsym_url.get(), true, (UInt8 *)path, sizeof(path) - 1)) {
+              char *dsym_extension_pos = ::strstr(path, ".dSYM");
+              if (dsym_extension_pos) {
+                *dsym_extension_pos = '\0';
+                if (log) {
+                  log->Printf("Looking for executable binary next to dSYM "
+                              "bundle with name with name %s",
+                              path);
+                }
+                FileSpec file_spec(path, true);
+                ModuleSpecList module_specs;
+                ModuleSpec matched_module_spec;
+                switch (file_spec.GetFileType()) {
+                case FileSpec::eFileTypeDirectory: // Bundle directory?
+                {
+                  CFCBundle bundle(path);
+                  CFCReleaser<CFURLRef> bundle_exe_url(
+                      bundle.CopyExecutableURL());
+                  if (bundle_exe_url.get()) {
+                    if (::CFURLGetFileSystemRepresentation(bundle_exe_url.get(),
+                                                           true, (UInt8 *)path,
+                                                           sizeof(path) - 1)) {
+                      FileSpec bundle_exe_file_spec(path, true);
+                      if (ObjectFile::GetModuleSpecifications(
+                              bundle_exe_file_spec, 0, 0, module_specs) &&
+                          module_specs.FindMatchingModuleSpec(
+                              module_spec, matched_module_spec))
+
+                      {
+                        ++items_found;
+                        return_module_spec.GetFileSpec() = bundle_exe_file_spec;
+                        if (log) {
+                          log->Printf("Executable binary %s next to dSYM is "
+                                      "compatible; using",
+                                      path);
+                        }
+                      }
+                    }
+                  }
+                } break;
+
+                case FileSpec::eFileTypePipe:   // Forget pipes
+                case FileSpec::eFileTypeSocket: // We can't process socket files
+                case FileSpec::eFileTypeInvalid: // File doesn't exist...
+                  break;
+
+                case FileSpec::eFileTypeUnknown:
+                case FileSpec::eFileTypeRegular:
+                case FileSpec::eFileTypeSymbolicLink:
+                case FileSpec::eFileTypeOther:
+                  if (ObjectFile::GetModuleSpecifications(file_spec, 0, 0,
+                                                          module_specs) &&
+                      module_specs.FindMatchingModuleSpec(module_spec,
+                                                          matched_module_spec))
+
+                  {
+                    ++items_found;
+                    return_module_spec.GetFileSpec() = file_spec;
+                    if (log) {
+                      log->Printf("Executable binary %s next to dSYM is "
+                                  "compatible; using",
+                                  path);
                     }
+                  }
+                  break;
                 }
+              }
             }
+          }
         }
+      }
     }
-#endif // #if !defined (__arm__) && !defined (__arm64__) && !defined (__aarch64__)
+  }
+#endif // #if !defined (__arm__) && !defined (__arm64__) && !defined
+       // (__aarch64__)
 
-    return items_found;
+  return items_found;
 }
 
-FileSpec
-Symbols::FindSymbolFileInBundle (const FileSpec& dsym_bundle_fspec,
-                                 const lldb_private::UUID *uuid,
-                                 const ArchSpec *arch)
-{
-    char path[PATH_MAX];
-
-    FileSpec dsym_fspec;
-
-    if (dsym_bundle_fspec.GetPath(path, sizeof(path)))
-    {
-        ::strncat (path, "/Contents/Resources/DWARF", sizeof(path) - strlen(path) - 1);
-
-        lldb_utility::CleanUp <DIR *, int> dirp (opendir(path), NULL, closedir);
-        if (dirp.is_valid())
-        {
-            dsym_fspec.GetDirectory().SetCString(path);
-            struct dirent* dp;
-            while ((dp = readdir(dirp.get())) != NULL)
-            {
-                // Only search directories
-                if (dp->d_type == DT_DIR || dp->d_type == DT_UNKNOWN)
-                {
-                    if (dp->d_namlen == 1 && dp->d_name[0] == '.')
-                        continue;
-
-                    if (dp->d_namlen == 2 && dp->d_name[0] == '.' && dp->d_name[1] == '.')
-                        continue;
-                }
-
-                if (dp->d_type == DT_REG || dp->d_type == DT_UNKNOWN)
-                {
-                    dsym_fspec.GetFilename().SetCString(dp->d_name);
-                    ModuleSpecList module_specs;
-                    if (ObjectFile::GetModuleSpecifications(dsym_fspec, 0, 0, module_specs))
-                    {
-                        ModuleSpec spec;
-                        for (size_t i = 0; i < module_specs.GetSize(); ++i)
-                        {
-                            assert(module_specs.GetModuleSpecAtIndex(i, spec));
-                            if ((uuid == NULL || (spec.GetUUIDPtr() && spec.GetUUID() == *uuid)) &&
-                                (arch == NULL || (spec.GetArchitecturePtr() && spec.GetArchitecture().IsCompatibleMatch(*arch))))
-                            {
-                                return dsym_fspec;
-                            }
-                        }
-                    }
-                }
+FileSpec Symbols::FindSymbolFileInBundle(const FileSpec &dsym_bundle_fspec,
+                                         const lldb_private::UUID *uuid,
+                                         const ArchSpec *arch) {
+  char path[PATH_MAX];
+
+  FileSpec dsym_fspec;
+
+  if (dsym_bundle_fspec.GetPath(path, sizeof(path))) {
+    ::strncat(path, "/Contents/Resources/DWARF",
+              sizeof(path) - strlen(path) - 1);
+
+    lldb_utility::CleanUp<DIR *, int> dirp(opendir(path), NULL, closedir);
+    if (dirp.is_valid()) {
+      dsym_fspec.GetDirectory().SetCString(path);
+      struct dirent *dp;
+      while ((dp = readdir(dirp.get())) != NULL) {
+        // Only search directories
+        if (dp->d_type == DT_DIR || dp->d_type == DT_UNKNOWN) {
+          if (dp->d_namlen == 1 && dp->d_name[0] == '.')
+            continue;
+
+          if (dp->d_namlen == 2 && dp->d_name[0] == '.' && dp->d_name[1] == '.')
+            continue;
+        }
+
+        if (dp->d_type == DT_REG || dp->d_type == DT_UNKNOWN) {
+          dsym_fspec.GetFilename().SetCString(dp->d_name);
+          ModuleSpecList module_specs;
+          if (ObjectFile::GetModuleSpecifications(dsym_fspec, 0, 0,
+                                                  module_specs)) {
+            ModuleSpec spec;
+            for (size_t i = 0; i < module_specs.GetSize(); ++i) {
+              assert(module_specs.GetModuleSpecAtIndex(i, spec));
+              if ((uuid == NULL ||
+                   (spec.GetUUIDPtr() && spec.GetUUID() == *uuid)) &&
+                  (arch == NULL ||
+                   (spec.GetArchitecturePtr() &&
+                    spec.GetArchitecture().IsCompatibleMatch(*arch)))) {
+                return dsym_fspec;
+              }
             }
+          }
         }
+      }
     }
-    dsym_fspec.Clear();
-    return dsym_fspec;
+  }
+  dsym_fspec.Clear();
+  return dsym_fspec;
 }
 
-static bool
-GetModuleSpecInfoFromUUIDDictionary (CFDictionaryRef uuid_dict, ModuleSpec &module_spec)
-{
-    Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
-    bool success = false;
-    if (uuid_dict != NULL && CFGetTypeID (uuid_dict) == CFDictionaryGetTypeID ())
-    {
-        std::string str;
-        CFStringRef cf_str;
-        CFDictionaryRef cf_dict;
-        
-        cf_str = (CFStringRef)CFDictionaryGetValue ((CFDictionaryRef) uuid_dict, CFSTR("DBGSymbolRichExecutable"));
-        if (cf_str && CFGetTypeID (cf_str) == CFStringGetTypeID ())
-        {
-            if (CFCString::FileSystemRepresentation(cf_str, str))
-            {
-                module_spec.GetFileSpec().SetFile (str.c_str(), true);
-                if (log)
-                {
-                    log->Printf ("From dsymForUUID plist: Symbol rich executable is at '%s'", str.c_str());
-                }
-            }
-        }
-        
-        cf_str = (CFStringRef)CFDictionaryGetValue ((CFDictionaryRef) uuid_dict, CFSTR("DBGDSYMPath"));
-        if (cf_str && CFGetTypeID (cf_str) == CFStringGetTypeID ())
-        {
-            if (CFCString::FileSystemRepresentation(cf_str, str))
-            {
-                module_spec.GetSymbolFileSpec().SetFile (str.c_str(), true);
-                success = true;
-                if (log)
-                {
-                    log->Printf ("From dsymForUUID plist: dSYM is at '%s'", str.c_str());
-                }
-            }
-        }
-        
-        cf_str = (CFStringRef)CFDictionaryGetValue ((CFDictionaryRef) uuid_dict, CFSTR("DBGArchitecture"));
-        if (cf_str && CFGetTypeID (cf_str) == CFStringGetTypeID ())
-        {
-            if (CFCString::FileSystemRepresentation(cf_str, str))
-                module_spec.GetArchitecture().SetTriple(str.c_str());
-        }
-
-        std::string DBGBuildSourcePath;
-        std::string DBGSourcePath;
-
-        cf_str = (CFStringRef)CFDictionaryGetValue ((CFDictionaryRef) uuid_dict, CFSTR("DBGBuildSourcePath"));
-        if (cf_str && CFGetTypeID (cf_str) == CFStringGetTypeID ())
-        {
-            CFCString::FileSystemRepresentation(cf_str, DBGBuildSourcePath);
-        }
-
-        cf_str = (CFStringRef)CFDictionaryGetValue ((CFDictionaryRef) uuid_dict, CFSTR("DBGSourcePath"));
-        if (cf_str && CFGetTypeID (cf_str) == CFStringGetTypeID ())
-        {
-            CFCString::FileSystemRepresentation(cf_str, DBGSourcePath);
-        }
-        
-        if (!DBGBuildSourcePath.empty() && !DBGSourcePath.empty())
-        {
-            if (DBGSourcePath[0] == '~')
-            {
-                FileSpec resolved_source_path(DBGSourcePath.c_str(), true);
-                DBGSourcePath = resolved_source_path.GetPath();
-            }
-            module_spec.GetSourceMappingList().Append (ConstString(DBGBuildSourcePath.c_str()), ConstString(DBGSourcePath.c_str()), true);
+static bool GetModuleSpecInfoFromUUIDDictionary(CFDictionaryRef uuid_dict,
+                                                ModuleSpec &module_spec) {
+  Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+  bool success = false;
+  if (uuid_dict != NULL && CFGetTypeID(uuid_dict) == CFDictionaryGetTypeID()) {
+    std::string str;
+    CFStringRef cf_str;
+    CFDictionaryRef cf_dict;
+
+    cf_str = (CFStringRef)CFDictionaryGetValue(
+        (CFDictionaryRef)uuid_dict, CFSTR("DBGSymbolRichExecutable"));
+    if (cf_str && CFGetTypeID(cf_str) == CFStringGetTypeID()) {
+      if (CFCString::FileSystemRepresentation(cf_str, str)) {
+        module_spec.GetFileSpec().SetFile(str.c_str(), true);
+        if (log) {
+          log->Printf(
+              "From dsymForUUID plist: Symbol rich executable is at '%s'",
+              str.c_str());
         }
+      }
+    }
 
-        cf_dict = (CFDictionaryRef)CFDictionaryGetValue ((CFDictionaryRef) uuid_dict, CFSTR("DBGSourcePathRemapping"));
-        if (cf_dict && CFGetTypeID (cf_dict) == CFDictionaryGetTypeID ())
-        {
-            // If we see DBGVersion with any kind of value, this is a new style DBGSourcePathRemapping dictionary
-            bool new_style_source_remapping_dictionary = false;
-            std::string original_DBGSourcePath_value = DBGSourcePath;
-            const void *version_value;
-            version_value = CFDictionaryGetValue ((CFDictionaryRef) uuid_dict, CFSTR("DBGVersion"));
-            if (version_value)
-                new_style_source_remapping_dictionary = true;
-
-            CFIndex kv_pair_count = CFDictionaryGetCount ((CFDictionaryRef) uuid_dict);
-            if (kv_pair_count > 0)
-            {
-                CFStringRef *keys = (CFStringRef *) malloc (kv_pair_count * sizeof (CFStringRef));
-                CFStringRef *values = (CFStringRef *) malloc (kv_pair_count * sizeof (CFStringRef));
-                if (keys != nullptr && values != nullptr)
-                {
-                    CFDictionaryGetKeysAndValues ((CFDictionaryRef) uuid_dict, (const void**)keys, (const void**)values);
-                }
-                for (CFIndex i = 0; i < kv_pair_count; i++)
-                {
-                    DBGBuildSourcePath.clear();
-                    DBGSourcePath.clear();
-                    if (keys[i] && CFGetTypeID (keys[i]) == CFStringGetTypeID ())
-                    {
-                        CFCString::FileSystemRepresentation(keys[i], DBGBuildSourcePath);
-                    }
-                    if (values[i] && CFGetTypeID (values[i]) == CFStringGetTypeID ())
-                    {
-                        CFCString::FileSystemRepresentation(values[i], DBGSourcePath);
-                    }
-                    if (!DBGBuildSourcePath.empty() && !DBGSourcePath.empty())
-                    {
-                        // In the "old style" DBGSourcePathRemapping dictionary, the DBGSourcePath values
-                        // (the "values" half of key-value path pairs) were wrong.  Ignore them and use the
-                        // universal DBGSourcePath string from earlier.
-                        if (new_style_source_remapping_dictionary == true && !original_DBGSourcePath_value.empty())
-                        {
-                            DBGSourcePath = original_DBGSourcePath_value;
-                        }
-                        if (DBGSourcePath[0] == '~')
-                        {
-                            FileSpec resolved_source_path(DBGSourcePath.c_str(), true);
-                            DBGSourcePath = resolved_source_path.GetPath();
-                        }
-                        module_spec.GetSourceMappingList().Append (ConstString(DBGBuildSourcePath.c_str()), ConstString(DBGSourcePath.c_str()), true);
-                    }
-                }
-                if (keys)
-                    free (keys);
-                if (values)
-                    free (values);
-            }
+    cf_str = (CFStringRef)CFDictionaryGetValue((CFDictionaryRef)uuid_dict,
+                                               CFSTR("DBGDSYMPath"));
+    if (cf_str && CFGetTypeID(cf_str) == CFStringGetTypeID()) {
+      if (CFCString::FileSystemRepresentation(cf_str, str)) {
+        module_spec.GetSymbolFileSpec().SetFile(str.c_str(), true);
+        success = true;
+        if (log) {
+          log->Printf("From dsymForUUID plist: dSYM is at '%s'", str.c_str());
         }
+      }
     }
-    return success;
-}
 
+    cf_str = (CFStringRef)CFDictionaryGetValue((CFDictionaryRef)uuid_dict,
+                                               CFSTR("DBGArchitecture"));
+    if (cf_str && CFGetTypeID(cf_str) == CFStringGetTypeID()) {
+      if (CFCString::FileSystemRepresentation(cf_str, str))
+        module_spec.GetArchitecture().SetTriple(str.c_str());
+    }
 
-bool
-Symbols::DownloadObjectAndSymbolFile (ModuleSpec &module_spec, bool force_lookup)
-{
-    bool success = false;
-    const UUID *uuid_ptr = module_spec.GetUUIDPtr();
-    const FileSpec *file_spec_ptr = module_spec.GetFileSpecPtr();
-
-    // It's expensive to check for the DBGShellCommands defaults setting, only do it once per
-    // lldb run and cache the result.  
-    static bool g_have_checked_for_dbgshell_command = false;
-    static const char *g_dbgshell_command = NULL;
-    if (g_have_checked_for_dbgshell_command == false)
-    {
-        g_have_checked_for_dbgshell_command = true;
-        CFTypeRef defaults_setting = CFPreferencesCopyAppValue (CFSTR ("DBGShellCommands"), CFSTR ("com.apple.DebugSymbols"));
-        if (defaults_setting && CFGetTypeID (defaults_setting) == CFStringGetTypeID())
-        { 
-            char cstr_buf[PATH_MAX];
-            if (CFStringGetCString ((CFStringRef) defaults_setting, cstr_buf, sizeof (cstr_buf), kCFStringEncodingUTF8))
-            {
-                g_dbgshell_command = strdup (cstr_buf);  // this malloc'ed memory will never be freed
-            }
-        }
-        if (defaults_setting)
-        {
-            CFRelease (defaults_setting);
-        }
+    std::string DBGBuildSourcePath;
+    std::string DBGSourcePath;
+
+    cf_str = (CFStringRef)CFDictionaryGetValue((CFDictionaryRef)uuid_dict,
+                                               CFSTR("DBGBuildSourcePath"));
+    if (cf_str && CFGetTypeID(cf_str) == CFStringGetTypeID()) {
+      CFCString::FileSystemRepresentation(cf_str, DBGBuildSourcePath);
     }
 
-    // When g_dbgshell_command is NULL, the user has not enabled the use of an external program
-    // to find the symbols, don't run it for them.
-    if (force_lookup == false && g_dbgshell_command == NULL)
-    {
-        return false;
-    }
-
-    if (uuid_ptr || (file_spec_ptr && file_spec_ptr->Exists()))
-    {
-        static bool g_located_dsym_for_uuid_exe = false;
-        static bool g_dsym_for_uuid_exe_exists = false;
-        static char g_dsym_for_uuid_exe_path[PATH_MAX];
-        if (!g_located_dsym_for_uuid_exe)
-        {
-            g_located_dsym_for_uuid_exe = true;
-            const char *dsym_for_uuid_exe_path_cstr = getenv("LLDB_APPLE_DSYMFORUUID_EXECUTABLE");
-            FileSpec dsym_for_uuid_exe_spec;
-            if (dsym_for_uuid_exe_path_cstr)
-            {
-                dsym_for_uuid_exe_spec.SetFile(dsym_for_uuid_exe_path_cstr, true);
-                g_dsym_for_uuid_exe_exists = dsym_for_uuid_exe_spec.Exists();
-            }
-            
-            if (!g_dsym_for_uuid_exe_exists)
-            {
-                dsym_for_uuid_exe_spec.SetFile("/usr/local/bin/dsymForUUID", false);
-                g_dsym_for_uuid_exe_exists = dsym_for_uuid_exe_spec.Exists();
-                if (!g_dsym_for_uuid_exe_exists)
-                {
-                    long bufsize;
-                    if ((bufsize = sysconf(_SC_GETPW_R_SIZE_MAX)) != -1)
-                    {
-                        char buffer[bufsize];
-                        struct passwd pwd;
-                        struct passwd *tilde_rc = NULL;
-                        // we are a library so we need to use the reentrant version of getpwnam()
-                        if (getpwnam_r ("rc", &pwd, buffer, bufsize, &tilde_rc) == 0 
-                            && tilde_rc 
-                            && tilde_rc->pw_dir)
-                        {
-                            std::string dsymforuuid_path(tilde_rc->pw_dir);
-                            dsymforuuid_path += "/bin/dsymForUUID";
-                            dsym_for_uuid_exe_spec.SetFile(dsymforuuid_path.c_str(), false);
-                            g_dsym_for_uuid_exe_exists = dsym_for_uuid_exe_spec.Exists();
-                        }
-                    }
-                }
-            }
-            if (!g_dsym_for_uuid_exe_exists && g_dbgshell_command != NULL)
-            {
-                dsym_for_uuid_exe_spec.SetFile(g_dbgshell_command, true);
-                g_dsym_for_uuid_exe_exists = dsym_for_uuid_exe_spec.Exists();
-            }
+    cf_str = (CFStringRef)CFDictionaryGetValue((CFDictionaryRef)uuid_dict,
+                                               CFSTR("DBGSourcePath"));
+    if (cf_str && CFGetTypeID(cf_str) == CFStringGetTypeID()) {
+      CFCString::FileSystemRepresentation(cf_str, DBGSourcePath);
+    }
 
-            if (g_dsym_for_uuid_exe_exists)
-                dsym_for_uuid_exe_spec.GetPath (g_dsym_for_uuid_exe_path, sizeof(g_dsym_for_uuid_exe_path));
-        }
-        if (g_dsym_for_uuid_exe_exists)
-        {
-            std::string uuid_str;
-            char file_path[PATH_MAX];
-            file_path[0] = '\0';
-
-            if (uuid_ptr)
-                uuid_str = uuid_ptr->GetAsString();
-
-            if (file_spec_ptr)
-                file_spec_ptr->GetPath(file_path, sizeof(file_path));
-            
-            StreamString command;
+    if (!DBGBuildSourcePath.empty() && !DBGSourcePath.empty()) {
+      if (DBGSourcePath[0] == '~') {
+        FileSpec resolved_source_path(DBGSourcePath.c_str(), true);
+        DBGSourcePath = resolved_source_path.GetPath();
+      }
+      module_spec.GetSourceMappingList().Append(
+          ConstString(DBGBuildSourcePath.c_str()),
+          ConstString(DBGSourcePath.c_str()), true);
+    }
+
+    cf_dict = (CFDictionaryRef)CFDictionaryGetValue(
+        (CFDictionaryRef)uuid_dict, CFSTR("DBGSourcePathRemapping"));
+    if (cf_dict && CFGetTypeID(cf_dict) == CFDictionaryGetTypeID()) {
+      // If we see DBGVersion with any kind of value, this is a new style
+      // DBGSourcePathRemapping dictionary
+      bool new_style_source_remapping_dictionary = false;
+      std::string original_DBGSourcePath_value = DBGSourcePath;
+      const void *version_value;
+      version_value =
+          CFDictionaryGetValue((CFDictionaryRef)uuid_dict, CFSTR("DBGVersion"));
+      if (version_value)
+        new_style_source_remapping_dictionary = true;
+
+      CFIndex kv_pair_count = CFDictionaryGetCount((CFDictionaryRef)uuid_dict);
+      if (kv_pair_count > 0) {
+        CFStringRef *keys =
+            (CFStringRef *)malloc(kv_pair_count * sizeof(CFStringRef));
+        CFStringRef *values =
+            (CFStringRef *)malloc(kv_pair_count * sizeof(CFStringRef));
+        if (keys != nullptr && values != nullptr) {
+          CFDictionaryGetKeysAndValues((CFDictionaryRef)uuid_dict,
+                                       (const void **)keys,
+                                       (const void **)values);
+        }
+        for (CFIndex i = 0; i < kv_pair_count; i++) {
+          DBGBuildSourcePath.clear();
+          DBGSourcePath.clear();
+          if (keys[i] && CFGetTypeID(keys[i]) == CFStringGetTypeID()) {
+            CFCString::FileSystemRepresentation(keys[i], DBGBuildSourcePath);
+          }
+          if (values[i] && CFGetTypeID(values[i]) == CFStringGetTypeID()) {
+            CFCString::FileSystemRepresentation(values[i], DBGSourcePath);
+          }
+          if (!DBGBuildSourcePath.empty() && !DBGSourcePath.empty()) {
+            // In the "old style" DBGSourcePathRemapping dictionary, the
+            // DBGSourcePath values
+            // (the "values" half of key-value path pairs) were wrong.  Ignore
+            // them and use the
+            // universal DBGSourcePath string from earlier.
+            if (new_style_source_remapping_dictionary == true &&
+                !original_DBGSourcePath_value.empty()) {
+              DBGSourcePath = original_DBGSourcePath_value;
+            }
+            if (DBGSourcePath[0] == '~') {
+              FileSpec resolved_source_path(DBGSourcePath.c_str(), true);
+              DBGSourcePath = resolved_source_path.GetPath();
+            }
+            module_spec.GetSourceMappingList().Append(
+                ConstString(DBGBuildSourcePath.c_str()),
+                ConstString(DBGSourcePath.c_str()), true);
+          }
+        }
+        if (keys)
+          free(keys);
+        if (values)
+          free(values);
+      }
+    }
+  }
+  return success;
+}
+
+bool Symbols::DownloadObjectAndSymbolFile(ModuleSpec &module_spec,
+                                          bool force_lookup) {
+  bool success = false;
+  const UUID *uuid_ptr = module_spec.GetUUIDPtr();
+  const FileSpec *file_spec_ptr = module_spec.GetFileSpecPtr();
+
+  // It's expensive to check for the DBGShellCommands defaults setting, only do
+  // it once per
+  // lldb run and cache the result.
+  static bool g_have_checked_for_dbgshell_command = false;
+  static const char *g_dbgshell_command = NULL;
+  if (g_have_checked_for_dbgshell_command == false) {
+    g_have_checked_for_dbgshell_command = true;
+    CFTypeRef defaults_setting = CFPreferencesCopyAppValue(
+        CFSTR("DBGShellCommands"), CFSTR("com.apple.DebugSymbols"));
+    if (defaults_setting &&
+        CFGetTypeID(defaults_setting) == CFStringGetTypeID()) {
+      char cstr_buf[PATH_MAX];
+      if (CFStringGetCString((CFStringRef)defaults_setting, cstr_buf,
+                             sizeof(cstr_buf), kCFStringEncodingUTF8)) {
+        g_dbgshell_command =
+            strdup(cstr_buf); // this malloc'ed memory will never be freed
+      }
+    }
+    if (defaults_setting) {
+      CFRelease(defaults_setting);
+    }
+  }
+
+  // When g_dbgshell_command is NULL, the user has not enabled the use of an
+  // external program
+  // to find the symbols, don't run it for them.
+  if (force_lookup == false && g_dbgshell_command == NULL) {
+    return false;
+  }
+
+  if (uuid_ptr || (file_spec_ptr && file_spec_ptr->Exists())) {
+    static bool g_located_dsym_for_uuid_exe = false;
+    static bool g_dsym_for_uuid_exe_exists = false;
+    static char g_dsym_for_uuid_exe_path[PATH_MAX];
+    if (!g_located_dsym_for_uuid_exe) {
+      g_located_dsym_for_uuid_exe = true;
+      const char *dsym_for_uuid_exe_path_cstr =
+          getenv("LLDB_APPLE_DSYMFORUUID_EXECUTABLE");
+      FileSpec dsym_for_uuid_exe_spec;
+      if (dsym_for_uuid_exe_path_cstr) {
+        dsym_for_uuid_exe_spec.SetFile(dsym_for_uuid_exe_path_cstr, true);
+        g_dsym_for_uuid_exe_exists = dsym_for_uuid_exe_spec.Exists();
+      }
+
+      if (!g_dsym_for_uuid_exe_exists) {
+        dsym_for_uuid_exe_spec.SetFile("/usr/local/bin/dsymForUUID", false);
+        g_dsym_for_uuid_exe_exists = dsym_for_uuid_exe_spec.Exists();
+        if (!g_dsym_for_uuid_exe_exists) {
+          long bufsize;
+          if ((bufsize = sysconf(_SC_GETPW_R_SIZE_MAX)) != -1) {
+            char buffer[bufsize];
+            struct passwd pwd;
+            struct passwd *tilde_rc = NULL;
+            // we are a library so we need to use the reentrant version of
+            // getpwnam()
+            if (getpwnam_r("rc", &pwd, buffer, bufsize, &tilde_rc) == 0 &&
+                tilde_rc && tilde_rc->pw_dir) {
+              std::string dsymforuuid_path(tilde_rc->pw_dir);
+              dsymforuuid_path += "/bin/dsymForUUID";
+              dsym_for_uuid_exe_spec.SetFile(dsymforuuid_path.c_str(), false);
+              g_dsym_for_uuid_exe_exists = dsym_for_uuid_exe_spec.Exists();
+            }
+          }
+        }
+      }
+      if (!g_dsym_for_uuid_exe_exists && g_dbgshell_command != NULL) {
+        dsym_for_uuid_exe_spec.SetFile(g_dbgshell_command, true);
+        g_dsym_for_uuid_exe_exists = dsym_for_uuid_exe_spec.Exists();
+      }
+
+      if (g_dsym_for_uuid_exe_exists)
+        dsym_for_uuid_exe_spec.GetPath(g_dsym_for_uuid_exe_path,
+                                       sizeof(g_dsym_for_uuid_exe_path));
+    }
+    if (g_dsym_for_uuid_exe_exists) {
+      std::string uuid_str;
+      char file_path[PATH_MAX];
+      file_path[0] = '\0';
+
+      if (uuid_ptr)
+        uuid_str = uuid_ptr->GetAsString();
+
+      if (file_spec_ptr)
+        file_spec_ptr->GetPath(file_path, sizeof(file_path));
+
+      StreamString command;
+      if (!uuid_str.empty())
+        command.Printf("%s --ignoreNegativeCache --copyExecutable %s",
+                       g_dsym_for_uuid_exe_path, uuid_str.c_str());
+      else if (file_path[0] != '\0')
+        command.Printf("%s --ignoreNegativeCache --copyExecutable %s",
+                       g_dsym_for_uuid_exe_path, file_path);
+
+      if (!command.GetString().empty()) {
+        Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+        int exit_status = -1;
+        int signo = -1;
+        std::string command_output;
+        if (log) {
+          if (!uuid_str.empty())
+            log->Printf("Calling %s with UUID %s to find dSYM",
+                        g_dsym_for_uuid_exe_path, uuid_str.c_str());
+          else if (file_path[0] != '\0')
+            log->Printf("Calling %s with file %s to find dSYM",
+                        g_dsym_for_uuid_exe_path, file_path);
+        }
+        Error error = Host::RunShellCommand(
+            command.GetData(),
+            NULL,            // current working directory
+            &exit_status,    // Exit status
+            &signo,          // Signal int *
+            &command_output, // Command output
+            30,     // Large timeout to allow for long dsym download times
+            false); // Don't run in a shell (we don't need shell expansion)
+        if (error.Success() && exit_status == 0 && !command_output.empty()) {
+          CFCData data(CFDataCreateWithBytesNoCopy(
+              NULL, (const UInt8 *)command_output.data(), command_output.size(),
+              kCFAllocatorNull));
+
+          CFCReleaser<CFDictionaryRef> plist(
+              (CFDictionaryRef)::CFPropertyListCreateFromXMLData(
+                  NULL, data.get(), kCFPropertyListImmutable, NULL));
+
+          if (plist.get() &&
+              CFGetTypeID(plist.get()) == CFDictionaryGetTypeID()) {
+            if (!uuid_str.empty()) {
+              CFCString uuid_cfstr(uuid_str.c_str());
+              CFDictionaryRef uuid_dict = (CFDictionaryRef)CFDictionaryGetValue(
+                  plist.get(), uuid_cfstr.get());
+              success =
+                  GetModuleSpecInfoFromUUIDDictionary(uuid_dict, module_spec);
+            } else {
+              const CFIndex num_values = ::CFDictionaryGetCount(plist.get());
+              if (num_values > 0) {
+                std::vector<CFStringRef> keys(num_values, NULL);
+                std::vector<CFDictionaryRef> values(num_values, NULL);
+                ::CFDictionaryGetKeysAndValues(plist.get(), NULL,
+                                               (const void **)&values[0]);
+                if (num_values == 1) {
+                  return GetModuleSpecInfoFromUUIDDictionary(values[0],
+                                                             module_spec);
+                } else {
+                  for (CFIndex i = 0; i < num_values; ++i) {
+                    ModuleSpec curr_module_spec;
+                    if (GetModuleSpecInfoFromUUIDDictionary(values[i],
+                                                            curr_module_spec)) {
+                      if (module_spec.GetArchitecture().IsCompatibleMatch(
+                              curr_module_spec.GetArchitecture())) {
+                        module_spec = curr_module_spec;
+                        return true;
+                      }
+                    }
+                  }
+                }
+              }
+            }
+          }
+        } else {
+          if (log) {
             if (!uuid_str.empty())
-                command.Printf("%s --ignoreNegativeCache --copyExecutable %s", g_dsym_for_uuid_exe_path, uuid_str.c_str());
+              log->Printf("Called %s on %s, no matches",
+                          g_dsym_for_uuid_exe_path, uuid_str.c_str());
             else if (file_path[0] != '\0')
-                command.Printf("%s --ignoreNegativeCache --copyExecutable %s", g_dsym_for_uuid_exe_path, file_path);
-            
-            if (!command.GetString().empty())
-            {
-                Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
-                int exit_status = -1;
-                int signo = -1;
-                std::string command_output;
-                if (log)
-                {
-                    if (!uuid_str.empty())
-                        log->Printf("Calling %s with UUID %s to find dSYM", g_dsym_for_uuid_exe_path, uuid_str.c_str());
-                    else if (file_path[0] != '\0')
-                        log->Printf("Calling %s with file %s to find dSYM", g_dsym_for_uuid_exe_path, file_path);
-                }
-                Error error = Host::RunShellCommand (command.GetData(),
-                                                     NULL,              // current working directory
-                                                     &exit_status,      // Exit status
-                                                     &signo,            // Signal int *
-                                                     &command_output,   // Command output
-                                                     30,                // Large timeout to allow for long dsym download times
-                                                     false);            // Don't run in a shell (we don't need shell expansion)
-                if (error.Success() && exit_status == 0 && !command_output.empty())
-                {
-                    CFCData data (CFDataCreateWithBytesNoCopy (NULL,
-                                                               (const UInt8 *)command_output.data(),
-                                                               command_output.size(),
-                                                               kCFAllocatorNull));
-                    
-                    CFCReleaser<CFDictionaryRef> plist((CFDictionaryRef)::CFPropertyListCreateFromXMLData (NULL, data.get(), kCFPropertyListImmutable, NULL));
-                    
-                    if (plist.get() && CFGetTypeID (plist.get()) == CFDictionaryGetTypeID ())
-                    {
-                        if (!uuid_str.empty())
-                        {
-                            CFCString uuid_cfstr(uuid_str.c_str());
-                            CFDictionaryRef uuid_dict = (CFDictionaryRef)CFDictionaryGetValue (plist.get(), uuid_cfstr.get());
-                            success = GetModuleSpecInfoFromUUIDDictionary (uuid_dict, module_spec);
-                        }
-                        else
-                        {
-                            const CFIndex num_values = ::CFDictionaryGetCount(plist.get());
-                            if (num_values > 0)
-                            {
-                                std::vector<CFStringRef> keys (num_values, NULL);
-                                std::vector<CFDictionaryRef> values (num_values, NULL);
-                                ::CFDictionaryGetKeysAndValues(plist.get(), NULL, (const void **)&values[0]);
-                                if (num_values == 1)
-                                {
-                                    return GetModuleSpecInfoFromUUIDDictionary (values[0], module_spec);
-                                }
-                                else
-                                {
-                                    for (CFIndex i=0; i<num_values; ++i)
-                                    {
-                                        ModuleSpec curr_module_spec;
-                                        if (GetModuleSpecInfoFromUUIDDictionary (values[i], curr_module_spec))
-                                        {
-                                            if (module_spec.GetArchitecture().IsCompatibleMatch(curr_module_spec.GetArchitecture()))
-                                            {
-                                                module_spec = curr_module_spec;
-                                                return true;
-                                            }
-                                        }
-                                    }
-                                }
-                            }
-                        }
-                    }
-                }
-                else
-                {
-                    if (log)
-                    {
-                        if (!uuid_str.empty())
-                            log->Printf("Called %s on %s, no matches", g_dsym_for_uuid_exe_path, uuid_str.c_str());
-                        else if (file_path[0] != '\0')
-                            log->Printf("Called %s on %s, no matches", g_dsym_for_uuid_exe_path, file_path);
-                    }
-                }
-            }
+              log->Printf("Called %s on %s, no matches",
+                          g_dsym_for_uuid_exe_path, file_path);
+          }
         }
+      }
     }
-    return success;
+  }
+  return success;
 }
-

Modified: lldb/trunk/source/Host/macosx/ThisThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/ThisThread.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/ThisThread.cpp (original)
+++ lldb/trunk/source/Host/macosx/ThisThread.cpp Tue Sep  6 15:57:50 2016
@@ -9,21 +9,17 @@
 
 #include "lldb/Host/ThisThread.h"
 
-#include <pthread.h>
 #include "llvm/ADT/SmallVector.h"
+#include <pthread.h>
 
 using namespace lldb_private;
 
-void
-ThisThread::SetName(llvm::StringRef name)
-{
-#if defined (__APPLE__)
-    ::pthread_setname_np(name.str().c_str());
+void ThisThread::SetName(llvm::StringRef name) {
+#if defined(__APPLE__)
+  ::pthread_setname_np(name.str().c_str());
 #endif
 }
 
-void
-ThisThread::GetName(llvm::SmallVectorImpl<char> &name)
-{
-    // FIXME - implement this.
+void ThisThread::GetName(llvm::SmallVectorImpl<char> &name) {
+  // FIXME - implement this.
 }

Modified: lldb/trunk/source/Host/macosx/cfcpp/CFCBundle.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/cfcpp/CFCBundle.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/cfcpp/CFCBundle.cpp (original)
+++ lldb/trunk/source/Host/macosx/cfcpp/CFCBundle.cpp Tue Sep  6 15:57:50 2016
@@ -13,87 +13,71 @@
 //----------------------------------------------------------------------
 // CFCBundle constructor
 //----------------------------------------------------------------------
-CFCBundle::CFCBundle(const char *path) :
-    CFCReleaser<CFBundleRef>()
-{
-    if (path && path[0])
-        SetPath(path);
+CFCBundle::CFCBundle(const char *path) : CFCReleaser<CFBundleRef>() {
+  if (path && path[0])
+    SetPath(path);
 }
 
-CFCBundle::CFCBundle(CFURLRef url) :
-    CFCReleaser<CFBundleRef>(url ? CFBundleCreate(NULL, url) : NULL)
-{
-}
+CFCBundle::CFCBundle(CFURLRef url)
+    : CFCReleaser<CFBundleRef>(url ? CFBundleCreate(NULL, url) : NULL) {}
 
 //----------------------------------------------------------------------
 // Destructor
 //----------------------------------------------------------------------
-CFCBundle::~CFCBundle()
-{
-}
+CFCBundle::~CFCBundle() {}
 
 //----------------------------------------------------------------------
 // Set the path for a bundle by supplying a
 //----------------------------------------------------------------------
-bool
-CFCBundle::SetPath (const char *path)
-{
-    CFAllocatorRef alloc = kCFAllocatorDefault;
-    // Release our old bundle and URL
-    reset();
-
-    // Make a CFStringRef from the supplied path
-    CFCString cf_path;
-    cf_path.SetFileSystemRepresentation(path);
-    if (cf_path.get())
-    {
-        // Make our Bundle URL
-        CFCReleaser<CFURLRef> bundle_url (::CFURLCreateWithFileSystemPath (alloc, cf_path.get(), kCFURLPOSIXPathStyle, true));
-        if (bundle_url.get())
-            reset (::CFBundleCreate (alloc, bundle_url.get()));
+bool CFCBundle::SetPath(const char *path) {
+  CFAllocatorRef alloc = kCFAllocatorDefault;
+  // Release our old bundle and URL
+  reset();
+
+  // Make a CFStringRef from the supplied path
+  CFCString cf_path;
+  cf_path.SetFileSystemRepresentation(path);
+  if (cf_path.get()) {
+    // Make our Bundle URL
+    CFCReleaser<CFURLRef> bundle_url(::CFURLCreateWithFileSystemPath(
+        alloc, cf_path.get(), kCFURLPOSIXPathStyle, true));
+    if (bundle_url.get())
+      reset(::CFBundleCreate(alloc, bundle_url.get()));
+  }
+  return get() != NULL;
+}
+
+bool CFCBundle::GetPath(char *dst, size_t dst_len) {
+  CFBundleRef bundle = get();
+  if (bundle) {
+    CFCReleaser<CFURLRef> bundle_url(CFBundleCopyBundleURL(bundle));
+    if (bundle_url.get()) {
+      Boolean resolveAgainstBase = 0;
+      return ::CFURLGetFileSystemRepresentation(bundle_url.get(),
+                                                resolveAgainstBase,
+                                                (UInt8 *)dst, dst_len) != 0;
     }
-    return get() != NULL;
+  }
+  return false;
 }
 
-bool
-CFCBundle::GetPath (char *dst, size_t dst_len)
-{
-    CFBundleRef bundle = get();
-    if (bundle)
-    {
-        CFCReleaser<CFURLRef> bundle_url (CFBundleCopyBundleURL (bundle));
-        if (bundle_url.get())
-        {
-            Boolean resolveAgainstBase = 0;
-            return ::CFURLGetFileSystemRepresentation (bundle_url.get(), resolveAgainstBase, (UInt8 *)dst, dst_len) != 0;
-        }
-    }
-    return false;
-}   
+CFStringRef CFCBundle::GetIdentifier() const {
+  CFBundleRef bundle = get();
+  if (bundle != NULL)
+    return ::CFBundleGetIdentifier(bundle);
+  return NULL;
+}
+
+CFTypeRef CFCBundle::GetValueForInfoDictionaryKey(CFStringRef key) const {
+  CFBundleRef bundle = get();
+  if (bundle != NULL)
+    return ::CFBundleGetValueForInfoDictionaryKey(bundle, key);
+  return NULL;
+}
 
-CFStringRef
-CFCBundle::GetIdentifier () const
-{
-    CFBundleRef bundle = get();
-    if (bundle != NULL)
-        return ::CFBundleGetIdentifier (bundle);
-    return NULL;
-}
-
-CFTypeRef
-CFCBundle::GetValueForInfoDictionaryKey(CFStringRef key) const
-{
-    CFBundleRef bundle = get();
-    if (bundle != NULL)
-        return ::CFBundleGetValueForInfoDictionaryKey(bundle, key);
-    return NULL;
-}
-
-CFURLRef
-CFCBundle::CopyExecutableURL () const
-{
-    CFBundleRef bundle = get();
-    if (bundle != NULL)
-        return CFBundleCopyExecutableURL(bundle);
-    return NULL;
+CFURLRef CFCBundle::CopyExecutableURL() const {
+  CFBundleRef bundle = get();
+  if (bundle != NULL)
+    return CFBundleCopyExecutableURL(bundle);
+  return NULL;
 }

Modified: lldb/trunk/source/Host/macosx/cfcpp/CFCBundle.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/cfcpp/CFCBundle.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/cfcpp/CFCBundle.h (original)
+++ lldb/trunk/source/Host/macosx/cfcpp/CFCBundle.h Tue Sep  6 15:57:50 2016
@@ -12,39 +12,31 @@
 
 #include "CFCReleaser.h"
 
-class CFCBundle : public CFCReleaser<CFBundleRef>
-{
+class CFCBundle : public CFCReleaser<CFBundleRef> {
 public:
-    //------------------------------------------------------------------
-    // Constructors and Destructors
-    //------------------------------------------------------------------
-    CFCBundle (const char *path = NULL);
-    CFCBundle (CFURLRef url);
+  //------------------------------------------------------------------
+  // Constructors and Destructors
+  //------------------------------------------------------------------
+  CFCBundle(const char *path = NULL);
+  CFCBundle(CFURLRef url);
 
-    virtual
-    ~CFCBundle();
+  virtual ~CFCBundle();
 
-    CFURLRef
-    CopyExecutableURL () const;
+  CFURLRef CopyExecutableURL() const;
 
-    CFStringRef
-    GetIdentifier () const;
+  CFStringRef GetIdentifier() const;
 
-    CFTypeRef
-    GetValueForInfoDictionaryKey(CFStringRef key) const;
+  CFTypeRef GetValueForInfoDictionaryKey(CFStringRef key) const;
 
-    bool
-    GetPath (char *dst, size_t dst_len);
+  bool GetPath(char *dst, size_t dst_len);
 
-    bool
-    SetPath (const char *path);
+  bool SetPath(const char *path);
 
 private:
-    // Disallow copy and assignment constructors
-    CFCBundle(const CFCBundle&);
+  // Disallow copy and assignment constructors
+  CFCBundle(const CFCBundle &);
 
-    const CFCBundle&
-    operator=(const CFCBundle&);
+  const CFCBundle &operator=(const CFCBundle &);
 };
 
 #endif // #ifndef CoreFoundationCPP_CFBundle_h_

Modified: lldb/trunk/source/Host/macosx/cfcpp/CFCData.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/cfcpp/CFCData.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/cfcpp/CFCData.cpp (original)
+++ lldb/trunk/source/Host/macosx/cfcpp/CFCData.cpp Tue Sep  6 15:57:50 2016
@@ -12,71 +12,55 @@
 //----------------------------------------------------------------------
 // CFCData constructor
 //----------------------------------------------------------------------
-CFCData::CFCData(CFDataRef data) :
-    CFCReleaser<CFDataRef>(data)
-{
-
-}
+CFCData::CFCData(CFDataRef data) : CFCReleaser<CFDataRef>(data) {}
 
 //----------------------------------------------------------------------
 // CFCData copy constructor
 //----------------------------------------------------------------------
-CFCData::CFCData(const CFCData& rhs) :
-    CFCReleaser<CFDataRef>(rhs)
-{
-
-}
+CFCData::CFCData(const CFCData &rhs) : CFCReleaser<CFDataRef>(rhs) {}
 
 //----------------------------------------------------------------------
 // CFCData copy constructor
 //----------------------------------------------------------------------
-CFCData&
-CFCData::operator=(const CFCData& rhs)
+CFCData &CFCData::operator=(const CFCData &rhs)
 
 {
-    if (this != &rhs)
-        *this = rhs;
-    return *this;
+  if (this != &rhs)
+    *this = rhs;
+  return *this;
 }
 
 //----------------------------------------------------------------------
 // Destructor
 //----------------------------------------------------------------------
-CFCData::~CFCData()
-{
-}
-
+CFCData::~CFCData() {}
 
-CFIndex
-CFCData::GetLength() const
-{
-    CFDataRef data = get();
-    if (data)
-        return CFDataGetLength (data);
-    return 0;
-}
-
-
-const uint8_t*
-CFCData::GetBytePtr() const
-{
-    CFDataRef data = get();
-    if (data)
-        return CFDataGetBytePtr (data);
-    return NULL;
+CFIndex CFCData::GetLength() const {
+  CFDataRef data = get();
+  if (data)
+    return CFDataGetLength(data);
+  return 0;
+}
+
+const uint8_t *CFCData::GetBytePtr() const {
+  CFDataRef data = get();
+  if (data)
+    return CFDataGetBytePtr(data);
+  return NULL;
+}
+
+CFDataRef CFCData::Serialize(CFPropertyListRef plist,
+                             CFPropertyListFormat format) {
+  CFAllocatorRef alloc = kCFAllocatorDefault;
+  reset();
+  CFCReleaser<CFWriteStreamRef> stream(
+      ::CFWriteStreamCreateWithAllocatedBuffers(alloc, alloc));
+  ::CFWriteStreamOpen(stream.get());
+  CFIndex len =
+      ::CFPropertyListWriteToStream(plist, stream.get(), format, NULL);
+  if (len > 0)
+    reset((CFDataRef)::CFWriteStreamCopyProperty(stream.get(),
+                                                 kCFStreamPropertyDataWritten));
+  ::CFWriteStreamClose(stream.get());
+  return get();
 }
-
-CFDataRef
-CFCData::Serialize(CFPropertyListRef plist, CFPropertyListFormat format)
-{
-    CFAllocatorRef alloc = kCFAllocatorDefault;
-    reset();
-    CFCReleaser<CFWriteStreamRef> stream (::CFWriteStreamCreateWithAllocatedBuffers (alloc, alloc));
-    ::CFWriteStreamOpen (stream.get());
-    CFIndex len = ::CFPropertyListWriteToStream (plist, stream.get(), format, NULL);
-    if (len > 0)
-        reset((CFDataRef)::CFWriteStreamCopyProperty (stream.get(), kCFStreamPropertyDataWritten));
-    ::CFWriteStreamClose (stream.get());
-    return get();
-}
-

Modified: lldb/trunk/source/Host/macosx/cfcpp/CFCData.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/cfcpp/CFCData.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/cfcpp/CFCData.h (original)
+++ lldb/trunk/source/Host/macosx/cfcpp/CFCData.h Tue Sep  6 15:57:50 2016
@@ -12,24 +12,24 @@
 
 #include "CFCReleaser.h"
 
-class CFCData : public CFCReleaser<CFDataRef>
-{
+class CFCData : public CFCReleaser<CFDataRef> {
 public:
-    //------------------------------------------------------------------
-    // Constructors and Destructors
-    //------------------------------------------------------------------
-    CFCData(CFDataRef data = NULL);
-    CFCData(const CFCData& rhs);
-    CFCData& operator=(const CFCData& rhs);
-    virtual ~CFCData();
+  //------------------------------------------------------------------
+  // Constructors and Destructors
+  //------------------------------------------------------------------
+  CFCData(CFDataRef data = NULL);
+  CFCData(const CFCData &rhs);
+  CFCData &operator=(const CFCData &rhs);
+  virtual ~CFCData();
+
+  CFDataRef Serialize(CFPropertyListRef plist, CFPropertyListFormat format);
+  const uint8_t *GetBytePtr() const;
+  CFIndex GetLength() const;
 
-        CFDataRef Serialize(CFPropertyListRef plist, CFPropertyListFormat format);
-        const uint8_t* GetBytePtr () const;
-        CFIndex GetLength () const;
 protected:
-    //------------------------------------------------------------------
-    // Classes that inherit from CFCData can see and modify these
-    //------------------------------------------------------------------
+  //------------------------------------------------------------------
+  // Classes that inherit from CFCData can see and modify these
+  //------------------------------------------------------------------
 };
 
 #endif // #ifndef CoreFoundationCPP_CFData_h_

Modified: lldb/trunk/source/Host/macosx/cfcpp/CFCMutableArray.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/cfcpp/CFCMutableArray.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/cfcpp/CFCMutableArray.cpp (original)
+++ lldb/trunk/source/Host/macosx/cfcpp/CFCMutableArray.cpp Tue Sep  6 15:57:50 2016
@@ -13,154 +13,128 @@
 //----------------------------------------------------------------------
 // CFCString constructor
 //----------------------------------------------------------------------
-CFCMutableArray::CFCMutableArray(CFMutableArrayRef s) :
-    CFCReleaser<CFMutableArrayRef> (s)
-{
-}
+CFCMutableArray::CFCMutableArray(CFMutableArrayRef s)
+    : CFCReleaser<CFMutableArrayRef>(s) {}
 
 //----------------------------------------------------------------------
 // CFCMutableArray copy constructor
 //----------------------------------------------------------------------
-CFCMutableArray::CFCMutableArray(const CFCMutableArray& rhs) :
-    CFCReleaser<CFMutableArrayRef> (rhs)    // NOTE: this won't make a copy of the array, just add a new reference to it
-{
-}
+CFCMutableArray::CFCMutableArray(const CFCMutableArray &rhs)
+    : CFCReleaser<CFMutableArrayRef>(rhs) // NOTE: this won't make a copy of the
+                                          // array, just add a new reference to
+                                          // it
+{}
 
 //----------------------------------------------------------------------
 // CFCMutableArray copy constructor
 //----------------------------------------------------------------------
-CFCMutableArray&
-CFCMutableArray::operator=(const CFCMutableArray& rhs)
-{
-    if (this != &rhs)
-        *this = rhs;    // NOTE: this operator won't make a copy of the array, just add a new reference to it
-    return *this;
+CFCMutableArray &CFCMutableArray::operator=(const CFCMutableArray &rhs) {
+  if (this != &rhs)
+    *this = rhs; // NOTE: this operator won't make a copy of the array, just add
+                 // a new reference to it
+  return *this;
 }
 
 //----------------------------------------------------------------------
 // Destructor
 //----------------------------------------------------------------------
-CFCMutableArray::~CFCMutableArray()
-{
-}
-
-
-CFIndex
-CFCMutableArray::GetCount() const
-{
-    CFMutableArrayRef array = get();
-    if (array)
-        return ::CFArrayGetCount (array);
-    return 0;
-}
-
-CFIndex
-CFCMutableArray::GetCountOfValue(CFRange range, const void *value) const
-{
-    CFMutableArrayRef array = get();
-    if (array)
-        return ::CFArrayGetCountOfValue (array, range, value);
-    return 0;
-}
-
-CFIndex
-CFCMutableArray::GetCountOfValue(const void *value) const
-{
-    CFMutableArrayRef array = get();
-    if (array)
-        return ::CFArrayGetCountOfValue (array, CFRangeMake(0, GetCount()), value);
-    return 0;
-}
-
-const void *
-CFCMutableArray::GetValueAtIndex(CFIndex idx) const
-{
-    CFMutableArrayRef array = get();
-    if (array)
-    {
-        const CFIndex num_array_items = ::CFArrayGetCount (array);
-        if (0 <= idx && idx < num_array_items)
-        {
-            return ::CFArrayGetValueAtIndex (array, idx);
-        }
-    }
-    return NULL;
-}
-
-bool
-CFCMutableArray::SetValueAtIndex(CFIndex idx, const void *value)
-{
-    CFMutableArrayRef array = get();
-    if (array != NULL)
-    {
-        const CFIndex num_array_items = ::CFArrayGetCount (array);
-        if (0 <= idx && idx < num_array_items)
-        {
-            ::CFArraySetValueAtIndex (array, idx, value);
-            return true;
-        }
-    }
-    return false;
-}
-
+CFCMutableArray::~CFCMutableArray() {}
 
-bool
-CFCMutableArray::AppendValue(const void *value, bool can_create)
-{
-    CFMutableArrayRef array = get();
-    if (array == NULL)
-    {
-        if (can_create == false)
-            return false;
-        array = ::CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
-        reset ( array );
-    }
-    if (array != NULL)
-    {
-        ::CFArrayAppendValue(array, value);
-        return true;
-    }
-    return false;
-}
-
-
-bool
-CFCMutableArray::AppendCStringAsCFString (const char *s, CFStringEncoding encoding, bool can_create)
-{
-    CFMutableArrayRef array = get();
-    if (array == NULL)
-    {
-        if (can_create == false)
-            return false;
-        array = ::CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
-        reset ( array );
-    }
-    if (array != NULL)
-    {
-        CFCString cf_str (s, encoding);
-        ::CFArrayAppendValue (array, cf_str.get());
-        return true;
-    }
-    return false;
-}
-
-bool
-CFCMutableArray::AppendFileSystemRepresentationAsCFString (const char *s, bool can_create)
-{
-    CFMutableArrayRef array = get();
-    if (array == NULL)
-    {
-        if (can_create == false)
-            return false;
-        array = ::CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
-        reset ( array );
-    }
-    if (array != NULL)
-    {
-        CFCString cf_path;
-        cf_path.SetFileSystemRepresentation(s);
-        ::CFArrayAppendValue (array, cf_path.get());
-        return true;
-    }
-    return false;
+CFIndex CFCMutableArray::GetCount() const {
+  CFMutableArrayRef array = get();
+  if (array)
+    return ::CFArrayGetCount(array);
+  return 0;
+}
+
+CFIndex CFCMutableArray::GetCountOfValue(CFRange range,
+                                         const void *value) const {
+  CFMutableArrayRef array = get();
+  if (array)
+    return ::CFArrayGetCountOfValue(array, range, value);
+  return 0;
+}
+
+CFIndex CFCMutableArray::GetCountOfValue(const void *value) const {
+  CFMutableArrayRef array = get();
+  if (array)
+    return ::CFArrayGetCountOfValue(array, CFRangeMake(0, GetCount()), value);
+  return 0;
+}
+
+const void *CFCMutableArray::GetValueAtIndex(CFIndex idx) const {
+  CFMutableArrayRef array = get();
+  if (array) {
+    const CFIndex num_array_items = ::CFArrayGetCount(array);
+    if (0 <= idx && idx < num_array_items) {
+      return ::CFArrayGetValueAtIndex(array, idx);
+    }
+  }
+  return NULL;
+}
+
+bool CFCMutableArray::SetValueAtIndex(CFIndex idx, const void *value) {
+  CFMutableArrayRef array = get();
+  if (array != NULL) {
+    const CFIndex num_array_items = ::CFArrayGetCount(array);
+    if (0 <= idx && idx < num_array_items) {
+      ::CFArraySetValueAtIndex(array, idx, value);
+      return true;
+    }
+  }
+  return false;
+}
+
+bool CFCMutableArray::AppendValue(const void *value, bool can_create) {
+  CFMutableArrayRef array = get();
+  if (array == NULL) {
+    if (can_create == false)
+      return false;
+    array =
+        ::CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
+    reset(array);
+  }
+  if (array != NULL) {
+    ::CFArrayAppendValue(array, value);
+    return true;
+  }
+  return false;
+}
+
+bool CFCMutableArray::AppendCStringAsCFString(const char *s,
+                                              CFStringEncoding encoding,
+                                              bool can_create) {
+  CFMutableArrayRef array = get();
+  if (array == NULL) {
+    if (can_create == false)
+      return false;
+    array =
+        ::CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
+    reset(array);
+  }
+  if (array != NULL) {
+    CFCString cf_str(s, encoding);
+    ::CFArrayAppendValue(array, cf_str.get());
+    return true;
+  }
+  return false;
+}
+
+bool CFCMutableArray::AppendFileSystemRepresentationAsCFString(
+    const char *s, bool can_create) {
+  CFMutableArrayRef array = get();
+  if (array == NULL) {
+    if (can_create == false)
+      return false;
+    array =
+        ::CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
+    reset(array);
+  }
+  if (array != NULL) {
+    CFCString cf_path;
+    cf_path.SetFileSystemRepresentation(s);
+    ::CFArrayAppendValue(array, cf_path.get());
+    return true;
+  }
+  return false;
 }

Modified: lldb/trunk/source/Host/macosx/cfcpp/CFCMutableArray.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/cfcpp/CFCMutableArray.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/cfcpp/CFCMutableArray.h (original)
+++ lldb/trunk/source/Host/macosx/cfcpp/CFCMutableArray.h Tue Sep  6 15:57:50 2016
@@ -12,28 +12,35 @@
 
 #include "CFCReleaser.h"
 
-class CFCMutableArray : public CFCReleaser<CFMutableArrayRef>
-{
+class CFCMutableArray : public CFCReleaser<CFMutableArrayRef> {
 public:
-    //------------------------------------------------------------------
-    // Constructors and Destructors
-    //------------------------------------------------------------------
-    CFCMutableArray(CFMutableArrayRef array = NULL);
-    CFCMutableArray(const CFCMutableArray& rhs);                // This will copy the array contents into a new array
-    CFCMutableArray& operator=(const CFCMutableArray& rhs); // This will re-use the same array and just bump the ref count
-    virtual ~CFCMutableArray();
+  //------------------------------------------------------------------
+  // Constructors and Destructors
+  //------------------------------------------------------------------
+  CFCMutableArray(CFMutableArrayRef array = NULL);
+  CFCMutableArray(const CFCMutableArray &rhs); // This will copy the array
+                                               // contents into a new array
+  CFCMutableArray &operator=(const CFCMutableArray &rhs); // This will re-use
+                                                          // the same array and
+                                                          // just bump the ref
+                                                          // count
+  virtual ~CFCMutableArray();
 
-    CFIndex         GetCount() const;
-    CFIndex         GetCountOfValue(const void *value) const;
-    CFIndex         GetCountOfValue(CFRange range, const void *value) const;
-    const void *    GetValueAtIndex(CFIndex idx) const;
-    bool            SetValueAtIndex(CFIndex idx, const void *value);
-    bool            AppendValue(const void *value, bool can_create = true); // Appends value and optionally creates a CFCMutableArray if this class doesn't contain one
-    bool            AppendCStringAsCFString (const char *cstr, 
-                                             CFStringEncoding encoding = kCFStringEncodingUTF8, 
-                                             bool can_create = true);
-    bool            AppendFileSystemRepresentationAsCFString (const char *s, 
-                                                              bool can_create = true);
+  CFIndex GetCount() const;
+  CFIndex GetCountOfValue(const void *value) const;
+  CFIndex GetCountOfValue(CFRange range, const void *value) const;
+  const void *GetValueAtIndex(CFIndex idx) const;
+  bool SetValueAtIndex(CFIndex idx, const void *value);
+  bool AppendValue(const void *value,
+                   bool can_create = true); // Appends value and optionally
+                                            // creates a CFCMutableArray if this
+                                            // class doesn't contain one
+  bool
+  AppendCStringAsCFString(const char *cstr,
+                          CFStringEncoding encoding = kCFStringEncodingUTF8,
+                          bool can_create = true);
+  bool AppendFileSystemRepresentationAsCFString(const char *s,
+                                                bool can_create = true);
 };
 
 #endif // #ifndef CoreFoundationCPP_CFMutableArray_h_

Modified: lldb/trunk/source/Host/macosx/cfcpp/CFCMutableDictionary.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/cfcpp/CFCMutableDictionary.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/cfcpp/CFCMutableDictionary.cpp (original)
+++ lldb/trunk/source/Host/macosx/cfcpp/CFCMutableDictionary.cpp Tue Sep  6 15:57:50 2016
@@ -12,518 +12,458 @@
 //----------------------------------------------------------------------
 // CFCString constructor
 //----------------------------------------------------------------------
-CFCMutableDictionary::CFCMutableDictionary(CFMutableDictionaryRef s) :
-    CFCReleaser<CFMutableDictionaryRef> (s)
-{
-}
+CFCMutableDictionary::CFCMutableDictionary(CFMutableDictionaryRef s)
+    : CFCReleaser<CFMutableDictionaryRef>(s) {}
 
 //----------------------------------------------------------------------
 // CFCMutableDictionary copy constructor
 //----------------------------------------------------------------------
-CFCMutableDictionary::CFCMutableDictionary(const CFCMutableDictionary& rhs) :
-    CFCReleaser<CFMutableDictionaryRef> (rhs)
-{
-}
+CFCMutableDictionary::CFCMutableDictionary(const CFCMutableDictionary &rhs)
+    : CFCReleaser<CFMutableDictionaryRef>(rhs) {}
 
 //----------------------------------------------------------------------
 // CFCMutableDictionary copy constructor
 //----------------------------------------------------------------------
-const CFCMutableDictionary&
-CFCMutableDictionary::operator=(const CFCMutableDictionary& rhs)
-{
-    if (this != &rhs)
-        *this = rhs;
-    return *this;
+const CFCMutableDictionary &CFCMutableDictionary::
+operator=(const CFCMutableDictionary &rhs) {
+  if (this != &rhs)
+    *this = rhs;
+  return *this;
 }
 
 //----------------------------------------------------------------------
 // Destructor
 //----------------------------------------------------------------------
-CFCMutableDictionary::~CFCMutableDictionary()
-{
-}
-
+CFCMutableDictionary::~CFCMutableDictionary() {}
 
-CFIndex
-CFCMutableDictionary::GetCount() const
-{
-    CFMutableDictionaryRef dict = get();
-    if (dict)
-        return ::CFDictionaryGetCount (dict);
-    return 0;
+CFIndex CFCMutableDictionary::GetCount() const {
+  CFMutableDictionaryRef dict = get();
+  if (dict)
+    return ::CFDictionaryGetCount(dict);
+  return 0;
 }
 
-CFIndex
-CFCMutableDictionary::GetCountOfKey(const void *key) const
+CFIndex CFCMutableDictionary::GetCountOfKey(const void *key) const
 
 {
-    CFMutableDictionaryRef dict = get();
-    if (dict)
-        return ::CFDictionaryGetCountOfKey (dict, key);
-    return 0;
+  CFMutableDictionaryRef dict = get();
+  if (dict)
+    return ::CFDictionaryGetCountOfKey(dict, key);
+  return 0;
 }
 
-CFIndex
-CFCMutableDictionary::GetCountOfValue(const void *value) const
+CFIndex CFCMutableDictionary::GetCountOfValue(const void *value) const
 
 {
-    CFMutableDictionaryRef dict = get();
-    if (dict)
-        return ::CFDictionaryGetCountOfValue (dict, value);
-    return 0;
+  CFMutableDictionaryRef dict = get();
+  if (dict)
+    return ::CFDictionaryGetCountOfValue(dict, value);
+  return 0;
 }
 
-void
-CFCMutableDictionary::GetKeysAndValues(const void **keys, const void **values) const
-{
-    CFMutableDictionaryRef dict = get();
-    if (dict)
-        ::CFDictionaryGetKeysAndValues (dict, keys, values);
+void CFCMutableDictionary::GetKeysAndValues(const void **keys,
+                                            const void **values) const {
+  CFMutableDictionaryRef dict = get();
+  if (dict)
+    ::CFDictionaryGetKeysAndValues(dict, keys, values);
 }
 
-
-const void *
-CFCMutableDictionary::GetValue(const void *key) const
+const void *CFCMutableDictionary::GetValue(const void *key) const
 
 {
-    CFMutableDictionaryRef dict = get();
-    if (dict)
-        return ::CFDictionaryGetValue (dict, key);
-    return NULL;
+  CFMutableDictionaryRef dict = get();
+  if (dict)
+    return ::CFDictionaryGetValue(dict, key);
+  return NULL;
 }
 
 Boolean
-CFCMutableDictionary::GetValueIfPresent(const void *key, const void **value_handle) const
-{
-    CFMutableDictionaryRef dict = get();
-    if (dict)
-        return ::CFDictionaryGetValueIfPresent (dict, key, value_handle);
-    return false;
-}
-
-
-CFMutableDictionaryRef
-CFCMutableDictionary::Dictionary(bool can_create)
-{
-    CFMutableDictionaryRef dict = get();
-    if (can_create && dict == NULL)
-    {
-        dict = ::CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
-        reset ( dict );
-    }
-    return dict;
-}
-
-bool
-CFCMutableDictionary::AddValue(CFStringRef key, const void *value, bool can_create)
-{
-    CFMutableDictionaryRef dict = Dictionary(can_create);
-    if (dict != NULL)
-    {
-        // Let the dictionary own the CFNumber
-        ::CFDictionaryAddValue (dict, key, value);
-        return true;
-    }
-    return false;
-}
-
-bool
-CFCMutableDictionary::SetValue(CFStringRef key, const void *value, bool can_create)
-{
-    CFMutableDictionaryRef dict = Dictionary(can_create);
-    if (dict != NULL)
-    {
-        // Let the dictionary own the CFNumber
-        ::CFDictionarySetValue (dict, key, value);
-        return true;
-    }
-    return false;
-}
-
-bool
-CFCMutableDictionary::AddValueSInt8(CFStringRef key, int8_t value, bool can_create)
-{
-    CFMutableDictionaryRef dict = Dictionary(can_create);
-    if (dict != NULL)
-    {
-        CFCReleaser<CFNumberRef> cf_number(::CFNumberCreate (kCFAllocatorDefault, kCFNumberSInt8Type, &value));
-        if (cf_number.get())
-        {
-            // Let the dictionary own the CFNumber
-            ::CFDictionaryAddValue (dict, key, cf_number.get());
-            return true;
-        }
-    }
-    return false;
-}
-
-bool
-CFCMutableDictionary::SetValueSInt8(CFStringRef key, int8_t value, bool can_create)
-{
-    CFMutableDictionaryRef dict = Dictionary(can_create);
-    if (dict != NULL)
-    {
-        CFCReleaser<CFNumberRef> cf_number(::CFNumberCreate (kCFAllocatorDefault, kCFNumberSInt8Type, &value));
-        if (cf_number.get())
-        {
-            // Let the dictionary own the CFNumber
-            ::CFDictionarySetValue (dict, key, cf_number.get());
-            return true;
-        }
-    }
-    return false;
-}
-
-bool
-CFCMutableDictionary::AddValueSInt16(CFStringRef key, int16_t value, bool can_create)
-{
-    CFMutableDictionaryRef dict = Dictionary(can_create);
-    if (dict != NULL)
-    {
-        CFCReleaser<CFNumberRef> cf_number(::CFNumberCreate (kCFAllocatorDefault, kCFNumberSInt16Type, &value));
-        if (cf_number.get())
-        {
-            // Let the dictionary own the CFNumber
-            ::CFDictionaryAddValue (dict, key, cf_number.get());
-            return true;
-        }
-    }
-    return false;
-}
-
-bool
-CFCMutableDictionary::SetValueSInt16(CFStringRef key, int16_t value, bool can_create)
-{
-    CFMutableDictionaryRef dict = Dictionary(can_create);
-    if (dict != NULL)
-    {
-        CFCReleaser<CFNumberRef> cf_number(::CFNumberCreate (kCFAllocatorDefault, kCFNumberSInt16Type, &value));
-        if (cf_number.get())
-        {
-            // Let the dictionary own the CFNumber
-            ::CFDictionarySetValue (dict, key, cf_number.get());
-            return true;
-        }
-    }
-    return false;
-}
-
-bool
-CFCMutableDictionary::AddValueSInt32(CFStringRef key, int32_t value, bool can_create)
-{
-    CFMutableDictionaryRef dict = Dictionary(can_create);
-    if (dict != NULL)
-    {
-        CFCReleaser<CFNumberRef> cf_number(::CFNumberCreate (kCFAllocatorDefault, kCFNumberSInt32Type, &value));
-        if (cf_number.get())
-        {
-            // Let the dictionary own the CFNumber
-            ::CFDictionaryAddValue (dict, key, cf_number.get());
-            return true;
-        }
-    }
-    return false;
-}
-
-bool
-CFCMutableDictionary::SetValueSInt32(CFStringRef key, int32_t value, bool can_create)
-{
-    CFMutableDictionaryRef dict = Dictionary(can_create);
-    if (dict != NULL)
-    {
-        CFCReleaser<CFNumberRef> cf_number(::CFNumberCreate (kCFAllocatorDefault, kCFNumberSInt32Type, &value));
-        if (cf_number.get())
-        {
-            // Let the dictionary own the CFNumber
-            ::CFDictionarySetValue (dict, key, cf_number.get());
-            return true;
-        }
-    }
-    return false;
-}
-
-bool
-CFCMutableDictionary::AddValueSInt64(CFStringRef key, int64_t value, bool can_create)
-{
-    CFMutableDictionaryRef dict = Dictionary(can_create);
-    if (dict != NULL)
-    {
-        CFCReleaser<CFNumberRef> cf_number(::CFNumberCreate (kCFAllocatorDefault, kCFNumberSInt64Type, &value));
-        if (cf_number.get())
-        {
-            // Let the dictionary own the CFNumber
-            ::CFDictionaryAddValue (dict, key, cf_number.get());
-            return true;
-        }
-    }
-    return false;
-}
-
-bool
-CFCMutableDictionary::SetValueSInt64(CFStringRef key, int64_t value, bool can_create)
-{
-    CFMutableDictionaryRef dict = Dictionary(can_create);
-    if (dict != NULL)
-    {
-        CFCReleaser<CFNumberRef> cf_number(::CFNumberCreate (kCFAllocatorDefault, kCFNumberSInt64Type, &value));
-        if (cf_number.get())
-        {
-            // Let the dictionary own the CFNumber
-            ::CFDictionarySetValue (dict, key, cf_number.get());
-            return true;
-        }
-    }
-    return false;
-}
-
-bool
-CFCMutableDictionary::AddValueUInt8(CFStringRef key, uint8_t value, bool can_create)
-{
-    CFMutableDictionaryRef dict = Dictionary(can_create);
-    if (dict != NULL)
-    {
-        // Have to promote to the next size type so things don't appear negative of the MSBit is set...
-        int16_t sval = value;
-        CFCReleaser<CFNumberRef> cf_number(::CFNumberCreate (kCFAllocatorDefault, kCFNumberSInt16Type, &sval));
-        if (cf_number.get())
-        {
-            // Let the dictionary own the CFNumber
-            ::CFDictionaryAddValue (dict, key, cf_number.get());
-            return true;
-        }
-    }
-    return false;
-}
-
-bool
-CFCMutableDictionary::SetValueUInt8(CFStringRef key, uint8_t value, bool can_create)
-{
-    CFMutableDictionaryRef dict = Dictionary(can_create);
-    if (dict != NULL)
-    {
-        // Have to promote to the next size type so things don't appear negative of the MSBit is set...
-        int16_t sval = value;
-        CFCReleaser<CFNumberRef> cf_number(::CFNumberCreate (kCFAllocatorDefault, kCFNumberSInt16Type, &sval));
-        if (cf_number.get())
-        {
-            // Let the dictionary own the CFNumber
-            ::CFDictionarySetValue (dict, key, cf_number.get());
-            return true;
-        }
-    }
-    return false;
-}
-
-
-bool
-CFCMutableDictionary::AddValueUInt16(CFStringRef key, uint16_t value, bool can_create)
-{
-    CFMutableDictionaryRef dict = Dictionary(can_create);
-    if (dict != NULL)
-    {
-        // Have to promote to the next size type so things don't appear negative of the MSBit is set...
-        int32_t sval = value;
-        CFCReleaser<CFNumberRef> cf_number(::CFNumberCreate (kCFAllocatorDefault, kCFNumberSInt32Type, &sval));
-        if (cf_number.get())
-        {
-            // Let the dictionary own the CFNumber
-            ::CFDictionaryAddValue (dict, key, cf_number.get());
-            return true;
-        }
-    }
-    return false;
-}
-
-bool
-CFCMutableDictionary::SetValueUInt16(CFStringRef key, uint16_t value, bool can_create)
-{
-    CFMutableDictionaryRef dict = Dictionary(can_create);
-    if (dict != NULL)
-    {
-        // Have to promote to the next size type so things don't appear negative of the MSBit is set...
-        int32_t sval = value;
-        CFCReleaser<CFNumberRef> cf_number(::CFNumberCreate (kCFAllocatorDefault, kCFNumberSInt32Type, &sval));
-        if (cf_number.get())
-        {
-            // Let the dictionary own the CFNumber
-            ::CFDictionarySetValue (dict, key, cf_number.get());
-            return true;
-        }
-    }
-    return false;
+CFCMutableDictionary::GetValueIfPresent(const void *key,
+                                        const void **value_handle) const {
+  CFMutableDictionaryRef dict = get();
+  if (dict)
+    return ::CFDictionaryGetValueIfPresent(dict, key, value_handle);
+  return false;
+}
+
+CFMutableDictionaryRef CFCMutableDictionary::Dictionary(bool can_create) {
+  CFMutableDictionaryRef dict = get();
+  if (can_create && dict == NULL) {
+    dict = ::CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
+                                       &kCFTypeDictionaryKeyCallBacks,
+                                       &kCFTypeDictionaryValueCallBacks);
+    reset(dict);
+  }
+  return dict;
+}
+
+bool CFCMutableDictionary::AddValue(CFStringRef key, const void *value,
+                                    bool can_create) {
+  CFMutableDictionaryRef dict = Dictionary(can_create);
+  if (dict != NULL) {
+    // Let the dictionary own the CFNumber
+    ::CFDictionaryAddValue(dict, key, value);
+    return true;
+  }
+  return false;
+}
+
+bool CFCMutableDictionary::SetValue(CFStringRef key, const void *value,
+                                    bool can_create) {
+  CFMutableDictionaryRef dict = Dictionary(can_create);
+  if (dict != NULL) {
+    // Let the dictionary own the CFNumber
+    ::CFDictionarySetValue(dict, key, value);
+    return true;
+  }
+  return false;
+}
+
+bool CFCMutableDictionary::AddValueSInt8(CFStringRef key, int8_t value,
+                                         bool can_create) {
+  CFMutableDictionaryRef dict = Dictionary(can_create);
+  if (dict != NULL) {
+    CFCReleaser<CFNumberRef> cf_number(
+        ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt8Type, &value));
+    if (cf_number.get()) {
+      // Let the dictionary own the CFNumber
+      ::CFDictionaryAddValue(dict, key, cf_number.get());
+      return true;
+    }
+  }
+  return false;
+}
+
+bool CFCMutableDictionary::SetValueSInt8(CFStringRef key, int8_t value,
+                                         bool can_create) {
+  CFMutableDictionaryRef dict = Dictionary(can_create);
+  if (dict != NULL) {
+    CFCReleaser<CFNumberRef> cf_number(
+        ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt8Type, &value));
+    if (cf_number.get()) {
+      // Let the dictionary own the CFNumber
+      ::CFDictionarySetValue(dict, key, cf_number.get());
+      return true;
+    }
+  }
+  return false;
+}
+
+bool CFCMutableDictionary::AddValueSInt16(CFStringRef key, int16_t value,
+                                          bool can_create) {
+  CFMutableDictionaryRef dict = Dictionary(can_create);
+  if (dict != NULL) {
+    CFCReleaser<CFNumberRef> cf_number(
+        ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt16Type, &value));
+    if (cf_number.get()) {
+      // Let the dictionary own the CFNumber
+      ::CFDictionaryAddValue(dict, key, cf_number.get());
+      return true;
+    }
+  }
+  return false;
+}
+
+bool CFCMutableDictionary::SetValueSInt16(CFStringRef key, int16_t value,
+                                          bool can_create) {
+  CFMutableDictionaryRef dict = Dictionary(can_create);
+  if (dict != NULL) {
+    CFCReleaser<CFNumberRef> cf_number(
+        ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt16Type, &value));
+    if (cf_number.get()) {
+      // Let the dictionary own the CFNumber
+      ::CFDictionarySetValue(dict, key, cf_number.get());
+      return true;
+    }
+  }
+  return false;
+}
+
+bool CFCMutableDictionary::AddValueSInt32(CFStringRef key, int32_t value,
+                                          bool can_create) {
+  CFMutableDictionaryRef dict = Dictionary(can_create);
+  if (dict != NULL) {
+    CFCReleaser<CFNumberRef> cf_number(
+        ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &value));
+    if (cf_number.get()) {
+      // Let the dictionary own the CFNumber
+      ::CFDictionaryAddValue(dict, key, cf_number.get());
+      return true;
+    }
+  }
+  return false;
+}
+
+bool CFCMutableDictionary::SetValueSInt32(CFStringRef key, int32_t value,
+                                          bool can_create) {
+  CFMutableDictionaryRef dict = Dictionary(can_create);
+  if (dict != NULL) {
+    CFCReleaser<CFNumberRef> cf_number(
+        ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &value));
+    if (cf_number.get()) {
+      // Let the dictionary own the CFNumber
+      ::CFDictionarySetValue(dict, key, cf_number.get());
+      return true;
+    }
+  }
+  return false;
+}
+
+bool CFCMutableDictionary::AddValueSInt64(CFStringRef key, int64_t value,
+                                          bool can_create) {
+  CFMutableDictionaryRef dict = Dictionary(can_create);
+  if (dict != NULL) {
+    CFCReleaser<CFNumberRef> cf_number(
+        ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &value));
+    if (cf_number.get()) {
+      // Let the dictionary own the CFNumber
+      ::CFDictionaryAddValue(dict, key, cf_number.get());
+      return true;
+    }
+  }
+  return false;
+}
+
+bool CFCMutableDictionary::SetValueSInt64(CFStringRef key, int64_t value,
+                                          bool can_create) {
+  CFMutableDictionaryRef dict = Dictionary(can_create);
+  if (dict != NULL) {
+    CFCReleaser<CFNumberRef> cf_number(
+        ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &value));
+    if (cf_number.get()) {
+      // Let the dictionary own the CFNumber
+      ::CFDictionarySetValue(dict, key, cf_number.get());
+      return true;
+    }
+  }
+  return false;
+}
+
+bool CFCMutableDictionary::AddValueUInt8(CFStringRef key, uint8_t value,
+                                         bool can_create) {
+  CFMutableDictionaryRef dict = Dictionary(can_create);
+  if (dict != NULL) {
+    // Have to promote to the next size type so things don't appear negative of
+    // the MSBit is set...
+    int16_t sval = value;
+    CFCReleaser<CFNumberRef> cf_number(
+        ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt16Type, &sval));
+    if (cf_number.get()) {
+      // Let the dictionary own the CFNumber
+      ::CFDictionaryAddValue(dict, key, cf_number.get());
+      return true;
+    }
+  }
+  return false;
+}
+
+bool CFCMutableDictionary::SetValueUInt8(CFStringRef key, uint8_t value,
+                                         bool can_create) {
+  CFMutableDictionaryRef dict = Dictionary(can_create);
+  if (dict != NULL) {
+    // Have to promote to the next size type so things don't appear negative of
+    // the MSBit is set...
+    int16_t sval = value;
+    CFCReleaser<CFNumberRef> cf_number(
+        ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt16Type, &sval));
+    if (cf_number.get()) {
+      // Let the dictionary own the CFNumber
+      ::CFDictionarySetValue(dict, key, cf_number.get());
+      return true;
+    }
+  }
+  return false;
+}
+
+bool CFCMutableDictionary::AddValueUInt16(CFStringRef key, uint16_t value,
+                                          bool can_create) {
+  CFMutableDictionaryRef dict = Dictionary(can_create);
+  if (dict != NULL) {
+    // Have to promote to the next size type so things don't appear negative of
+    // the MSBit is set...
+    int32_t sval = value;
+    CFCReleaser<CFNumberRef> cf_number(
+        ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &sval));
+    if (cf_number.get()) {
+      // Let the dictionary own the CFNumber
+      ::CFDictionaryAddValue(dict, key, cf_number.get());
+      return true;
+    }
+  }
+  return false;
+}
+
+bool CFCMutableDictionary::SetValueUInt16(CFStringRef key, uint16_t value,
+                                          bool can_create) {
+  CFMutableDictionaryRef dict = Dictionary(can_create);
+  if (dict != NULL) {
+    // Have to promote to the next size type so things don't appear negative of
+    // the MSBit is set...
+    int32_t sval = value;
+    CFCReleaser<CFNumberRef> cf_number(
+        ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &sval));
+    if (cf_number.get()) {
+      // Let the dictionary own the CFNumber
+      ::CFDictionarySetValue(dict, key, cf_number.get());
+      return true;
+    }
+  }
+  return false;
+}
+
+bool CFCMutableDictionary::AddValueUInt32(CFStringRef key, uint32_t value,
+                                          bool can_create) {
+  CFMutableDictionaryRef dict = Dictionary(can_create);
+  if (dict != NULL) {
+    // Have to promote to the next size type so things don't appear negative of
+    // the MSBit is set...
+    int64_t sval = value;
+    CFCReleaser<CFNumberRef> cf_number(
+        ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &sval));
+    if (cf_number.get()) {
+      // Let the dictionary own the CFNumber
+      ::CFDictionaryAddValue(dict, key, cf_number.get());
+      return true;
+    }
+  }
+  return false;
+}
+
+bool CFCMutableDictionary::SetValueUInt32(CFStringRef key, uint32_t value,
+                                          bool can_create) {
+  CFMutableDictionaryRef dict = Dictionary(can_create);
+  if (dict != NULL) {
+    // Have to promote to the next size type so things don't appear negative of
+    // the MSBit is set...
+    int64_t sval = value;
+    CFCReleaser<CFNumberRef> cf_number(
+        ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &sval));
+    if (cf_number.get()) {
+      // Let the dictionary own the CFNumber
+      ::CFDictionarySetValue(dict, key, cf_number.get());
+      return true;
+    }
+  }
+  return false;
+}
+
+bool CFCMutableDictionary::AddValueUInt64(CFStringRef key, uint64_t value,
+                                          bool can_create) {
+  CFMutableDictionaryRef dict = Dictionary(can_create);
+  if (dict != NULL) {
+    // The number may appear negative if the MSBit is set in "value". Due to a
+    // limitation of
+    // CFNumber, there isn't a way to have it show up otherwise as of this
+    // writing.
+    CFCReleaser<CFNumberRef> cf_number(
+        ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &value));
+    if (cf_number.get()) {
+      // Let the dictionary own the CFNumber
+      ::CFDictionaryAddValue(dict, key, cf_number.get());
+      return true;
+    }
+  }
+  return false;
+}
+
+bool CFCMutableDictionary::SetValueUInt64(CFStringRef key, uint64_t value,
+                                          bool can_create) {
+  CFMutableDictionaryRef dict = Dictionary(can_create);
+  if (dict != NULL) {
+    // The number may appear negative if the MSBit is set in "value". Due to a
+    // limitation of
+    // CFNumber, there isn't a way to have it show up otherwise as of this
+    // writing.
+    CFCReleaser<CFNumberRef> cf_number(
+        ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &value));
+    if (cf_number.get()) {
+      // Let the dictionary own the CFNumber
+      ::CFDictionarySetValue(dict, key, cf_number.get());
+      return true;
+    }
+  }
+  return false;
+}
+
+bool CFCMutableDictionary::AddValueDouble(CFStringRef key, double value,
+                                          bool can_create) {
+  CFMutableDictionaryRef dict = Dictionary(can_create);
+  if (dict != NULL) {
+    // The number may appear negative if the MSBit is set in "value". Due to a
+    // limitation of
+    // CFNumber, there isn't a way to have it show up otherwise as of this
+    // writing.
+    CFCReleaser<CFNumberRef> cf_number(
+        ::CFNumberCreate(kCFAllocatorDefault, kCFNumberDoubleType, &value));
+    if (cf_number.get()) {
+      // Let the dictionary own the CFNumber
+      ::CFDictionaryAddValue(dict, key, cf_number.get());
+      return true;
+    }
+  }
+  return false;
+}
+
+bool CFCMutableDictionary::SetValueDouble(CFStringRef key, double value,
+                                          bool can_create) {
+  CFMutableDictionaryRef dict = Dictionary(can_create);
+  if (dict != NULL) {
+    // The number may appear negative if the MSBit is set in "value". Due to a
+    // limitation of
+    // CFNumber, there isn't a way to have it show up otherwise as of this
+    // writing.
+    CFCReleaser<CFNumberRef> cf_number(
+        ::CFNumberCreate(kCFAllocatorDefault, kCFNumberDoubleType, &value));
+    if (cf_number.get()) {
+      // Let the dictionary own the CFNumber
+      ::CFDictionarySetValue(dict, key, cf_number.get());
+      return true;
+    }
+  }
+  return false;
+}
+
+bool CFCMutableDictionary::AddValueCString(CFStringRef key, const char *cstr,
+                                           bool can_create) {
+  CFMutableDictionaryRef dict = Dictionary(can_create);
+  if (dict != NULL) {
+    CFCString cf_str(cstr, kCFStringEncodingUTF8);
+    if (cf_str.get()) {
+      // Let the dictionary own the CFNumber
+      ::CFDictionaryAddValue(dict, key, cf_str.get());
+      return true;
+    }
+  }
+  return false;
+}
+
+bool CFCMutableDictionary::SetValueCString(CFStringRef key, const char *cstr,
+                                           bool can_create) {
+  CFMutableDictionaryRef dict = Dictionary(can_create);
+  if (dict != NULL) {
+    CFCString cf_str(cstr, kCFStringEncodingUTF8);
+    if (cf_str.get()) {
+      // Let the dictionary own the CFNumber
+      ::CFDictionarySetValue(dict, key, cf_str.get());
+      return true;
+    }
+  }
+  return false;
+}
+
+void CFCMutableDictionary::RemoveAllValues() {
+  CFMutableDictionaryRef dict = get();
+  if (dict)
+    ::CFDictionaryRemoveAllValues(dict);
+}
+
+void CFCMutableDictionary::RemoveValue(const void *value) {
+  CFMutableDictionaryRef dict = get();
+  if (dict)
+    ::CFDictionaryRemoveValue(dict, value);
+}
+void CFCMutableDictionary::ReplaceValue(const void *key, const void *value) {
+  CFMutableDictionaryRef dict = get();
+  if (dict)
+    ::CFDictionaryReplaceValue(dict, key, value);
 }
-
-bool
-CFCMutableDictionary::AddValueUInt32(CFStringRef key, uint32_t value, bool can_create)
-{
-    CFMutableDictionaryRef dict = Dictionary(can_create);
-    if (dict != NULL)
-    {
-        // Have to promote to the next size type so things don't appear negative of the MSBit is set...
-        int64_t sval = value;
-        CFCReleaser<CFNumberRef> cf_number(::CFNumberCreate (kCFAllocatorDefault, kCFNumberSInt64Type, &sval));
-        if (cf_number.get())
-        {
-            // Let the dictionary own the CFNumber
-            ::CFDictionaryAddValue (dict, key, cf_number.get());
-            return true;
-        }
-    }
-    return false;
-}
-
-bool
-CFCMutableDictionary::SetValueUInt32(CFStringRef key, uint32_t value, bool can_create)
-{
-    CFMutableDictionaryRef dict = Dictionary(can_create);
-    if (dict != NULL)
-    {
-        // Have to promote to the next size type so things don't appear negative of the MSBit is set...
-        int64_t sval = value;
-        CFCReleaser<CFNumberRef> cf_number(::CFNumberCreate (kCFAllocatorDefault, kCFNumberSInt64Type, &sval));
-        if (cf_number.get())
-        {
-            // Let the dictionary own the CFNumber
-            ::CFDictionarySetValue (dict, key, cf_number.get());
-            return true;
-        }
-    }
-    return false;
-}
-
-
-bool
-CFCMutableDictionary::AddValueUInt64(CFStringRef key, uint64_t value, bool can_create)
-{
-    CFMutableDictionaryRef dict = Dictionary(can_create);
-    if (dict != NULL)
-    {
-        // The number may appear negative if the MSBit is set in "value". Due to a limitation of
-        // CFNumber, there isn't a way to have it show up otherwise as of this writing.
-        CFCReleaser<CFNumberRef> cf_number(::CFNumberCreate (kCFAllocatorDefault, kCFNumberSInt64Type, &value));
-        if (cf_number.get())
-        {
-            // Let the dictionary own the CFNumber
-            ::CFDictionaryAddValue (dict, key, cf_number.get());
-            return true;
-        }
-    }
-    return false;
-}
-
-
-bool
-CFCMutableDictionary::SetValueUInt64(CFStringRef key, uint64_t value, bool can_create)
-{
-    CFMutableDictionaryRef dict = Dictionary(can_create);
-    if (dict != NULL)
-    {
-        // The number may appear negative if the MSBit is set in "value". Due to a limitation of
-        // CFNumber, there isn't a way to have it show up otherwise as of this writing.
-        CFCReleaser<CFNumberRef> cf_number(::CFNumberCreate (kCFAllocatorDefault, kCFNumberSInt64Type, &value));
-        if (cf_number.get())
-        {
-            // Let the dictionary own the CFNumber
-            ::CFDictionarySetValue (dict, key, cf_number.get());
-            return true;
-        }
-    }
-    return false;
-}
-
-bool
-CFCMutableDictionary::AddValueDouble(CFStringRef key, double value, bool can_create)
-{
-    CFMutableDictionaryRef dict = Dictionary(can_create);
-    if (dict != NULL)
-    {
-        // The number may appear negative if the MSBit is set in "value". Due to a limitation of
-        // CFNumber, there isn't a way to have it show up otherwise as of this writing.
-        CFCReleaser<CFNumberRef> cf_number(::CFNumberCreate (kCFAllocatorDefault, kCFNumberDoubleType, &value));
-        if (cf_number.get())
-        {
-            // Let the dictionary own the CFNumber
-            ::CFDictionaryAddValue (dict, key, cf_number.get());
-            return true;
-        }
-    }
-    return false;
-}
-
-bool
-CFCMutableDictionary::SetValueDouble(CFStringRef key, double value, bool can_create)
-{
-    CFMutableDictionaryRef dict = Dictionary(can_create);
-    if (dict != NULL)
-    {
-        // The number may appear negative if the MSBit is set in "value". Due to a limitation of
-        // CFNumber, there isn't a way to have it show up otherwise as of this writing.
-        CFCReleaser<CFNumberRef> cf_number(::CFNumberCreate (kCFAllocatorDefault, kCFNumberDoubleType, &value));
-        if (cf_number.get())
-        {
-            // Let the dictionary own the CFNumber
-            ::CFDictionarySetValue (dict, key, cf_number.get());
-            return true;
-        }
-    }
-    return false;
-}
-
-bool
-CFCMutableDictionary::AddValueCString(CFStringRef key, const char *cstr, bool can_create)
-{
-    CFMutableDictionaryRef dict = Dictionary(can_create);
-    if (dict != NULL)
-    {
-        CFCString cf_str(cstr, kCFStringEncodingUTF8);
-        if (cf_str.get())
-        {
-            // Let the dictionary own the CFNumber
-            ::CFDictionaryAddValue (dict, key, cf_str.get());
-            return true;
-        }
-    }
-    return false;
-}
-
-bool
-CFCMutableDictionary::SetValueCString(CFStringRef key, const char *cstr, bool can_create)
-{
-    CFMutableDictionaryRef dict = Dictionary(can_create);
-    if (dict != NULL)
-    {
-        CFCString cf_str(cstr, kCFStringEncodingUTF8);
-        if (cf_str.get())
-        {
-            // Let the dictionary own the CFNumber
-            ::CFDictionarySetValue (dict, key, cf_str.get());
-            return true;
-        }
-    }
-    return false;
-}
-
-
-void
-CFCMutableDictionary::RemoveAllValues()
-{
-    CFMutableDictionaryRef dict = get();
-    if (dict)
-        ::CFDictionaryRemoveAllValues(dict);
-}
-
-void
-CFCMutableDictionary::RemoveValue(const void *value)
-{
-    CFMutableDictionaryRef dict = get();
-    if (dict)
-        ::CFDictionaryRemoveValue(dict, value);
-}
-void
-CFCMutableDictionary::ReplaceValue(const void *key, const void *value)
-{
-    CFMutableDictionaryRef dict = get();
-    if (dict)
-        ::CFDictionaryReplaceValue (dict, key, value);
-}
-

Modified: lldb/trunk/source/Host/macosx/cfcpp/CFCMutableDictionary.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/cfcpp/CFCMutableDictionary.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/cfcpp/CFCMutableDictionary.h (original)
+++ lldb/trunk/source/Host/macosx/cfcpp/CFCMutableDictionary.h Tue Sep  6 15:57:50 2016
@@ -12,68 +12,64 @@
 
 #include "CFCReleaser.h"
 
-class CFCMutableDictionary : public CFCReleaser<CFMutableDictionaryRef>
-{
+class CFCMutableDictionary : public CFCReleaser<CFMutableDictionaryRef> {
 public:
-    //------------------------------------------------------------------
-    // Constructors and Destructors
-    //------------------------------------------------------------------
-    CFCMutableDictionary(CFMutableDictionaryRef s = NULL);
-    CFCMutableDictionary(const CFCMutableDictionary& rhs);
-    virtual ~CFCMutableDictionary();
-
-    //------------------------------------------------------------------
-    // Operators
-    //------------------------------------------------------------------
-    const CFCMutableDictionary&
-    operator=(const CFCMutableDictionary& rhs);
-
-
-    CFIndex GetCount() const;
-    CFIndex GetCountOfKey(const void *value) const;
-    CFIndex GetCountOfValue(const void *value) const;
-    void    GetKeysAndValues(const void **keys, const void **values) const;
-    const void * GetValue(const void *key) const;
-    Boolean GetValueIfPresent(const void *key, const void **value_handle) const;
-    bool    AddValue(CFStringRef key, const void *value, bool can_create = false);
-    bool    SetValue(CFStringRef key, const void *value, bool can_create = false);
-    bool    AddValueSInt8(CFStringRef key, int8_t value, bool can_create = false);
-    bool    SetValueSInt8(CFStringRef key, int8_t value, bool can_create = false);
-    bool    AddValueSInt16(CFStringRef key, int16_t value, bool can_create = false);
-    bool    SetValueSInt16(CFStringRef key, int16_t value, bool can_create = false);
-    bool    AddValueSInt32(CFStringRef key, int32_t value, bool can_create = false);
-    bool    SetValueSInt32(CFStringRef key, int32_t value, bool can_create = false);
-    bool    AddValueSInt64(CFStringRef key, int64_t value, bool can_create = false);
-    bool    SetValueSInt64(CFStringRef key, int64_t value, bool can_create = false);
-    bool    AddValueUInt8(CFStringRef key, uint8_t value, bool can_create = false);
-    bool    SetValueUInt8(CFStringRef key, uint8_t value, bool can_create = false);
-    bool    AddValueUInt16(CFStringRef key, uint16_t value, bool can_create = false);
-    bool    SetValueUInt16(CFStringRef key, uint16_t value, bool can_create = false);
-    bool    AddValueUInt32(CFStringRef key, uint32_t value, bool can_create = false);
-    bool    SetValueUInt32(CFStringRef key, uint32_t value, bool can_create = false);
-    bool    AddValueUInt64(CFStringRef key, uint64_t value, bool can_create = false);
-    bool    SetValueUInt64(CFStringRef key, uint64_t value, bool can_create = false);
-    bool    AddValueDouble(CFStringRef key, double value, bool can_create = false);
-    bool    SetValueDouble(CFStringRef key, double value, bool can_create = false);
-    bool    AddValueCString(CFStringRef key, const char *cstr, bool can_create = false);
-    bool    SetValueCString(CFStringRef key, const char *cstr, bool can_create = false);
-    void    RemoveValue(const void *value);
-    void    ReplaceValue(const void *key, const void *value);
-    void    RemoveAllValues();
-    CFMutableDictionaryRef Dictionary(bool can_create);
-
+  //------------------------------------------------------------------
+  // Constructors and Destructors
+  //------------------------------------------------------------------
+  CFCMutableDictionary(CFMutableDictionaryRef s = NULL);
+  CFCMutableDictionary(const CFCMutableDictionary &rhs);
+  virtual ~CFCMutableDictionary();
+
+  //------------------------------------------------------------------
+  // Operators
+  //------------------------------------------------------------------
+  const CFCMutableDictionary &operator=(const CFCMutableDictionary &rhs);
+
+  CFIndex GetCount() const;
+  CFIndex GetCountOfKey(const void *value) const;
+  CFIndex GetCountOfValue(const void *value) const;
+  void GetKeysAndValues(const void **keys, const void **values) const;
+  const void *GetValue(const void *key) const;
+  Boolean GetValueIfPresent(const void *key, const void **value_handle) const;
+  bool AddValue(CFStringRef key, const void *value, bool can_create = false);
+  bool SetValue(CFStringRef key, const void *value, bool can_create = false);
+  bool AddValueSInt8(CFStringRef key, int8_t value, bool can_create = false);
+  bool SetValueSInt8(CFStringRef key, int8_t value, bool can_create = false);
+  bool AddValueSInt16(CFStringRef key, int16_t value, bool can_create = false);
+  bool SetValueSInt16(CFStringRef key, int16_t value, bool can_create = false);
+  bool AddValueSInt32(CFStringRef key, int32_t value, bool can_create = false);
+  bool SetValueSInt32(CFStringRef key, int32_t value, bool can_create = false);
+  bool AddValueSInt64(CFStringRef key, int64_t value, bool can_create = false);
+  bool SetValueSInt64(CFStringRef key, int64_t value, bool can_create = false);
+  bool AddValueUInt8(CFStringRef key, uint8_t value, bool can_create = false);
+  bool SetValueUInt8(CFStringRef key, uint8_t value, bool can_create = false);
+  bool AddValueUInt16(CFStringRef key, uint16_t value, bool can_create = false);
+  bool SetValueUInt16(CFStringRef key, uint16_t value, bool can_create = false);
+  bool AddValueUInt32(CFStringRef key, uint32_t value, bool can_create = false);
+  bool SetValueUInt32(CFStringRef key, uint32_t value, bool can_create = false);
+  bool AddValueUInt64(CFStringRef key, uint64_t value, bool can_create = false);
+  bool SetValueUInt64(CFStringRef key, uint64_t value, bool can_create = false);
+  bool AddValueDouble(CFStringRef key, double value, bool can_create = false);
+  bool SetValueDouble(CFStringRef key, double value, bool can_create = false);
+  bool AddValueCString(CFStringRef key, const char *cstr,
+                       bool can_create = false);
+  bool SetValueCString(CFStringRef key, const char *cstr,
+                       bool can_create = false);
+  void RemoveValue(const void *value);
+  void ReplaceValue(const void *key, const void *value);
+  void RemoveAllValues();
+  CFMutableDictionaryRef Dictionary(bool can_create);
 
 protected:
-    //------------------------------------------------------------------
-    // Classes that inherit from CFCMutableDictionary can see and modify these
-    //------------------------------------------------------------------
+  //------------------------------------------------------------------
+  // Classes that inherit from CFCMutableDictionary can see and modify these
+  //------------------------------------------------------------------
 
 private:
-    //------------------------------------------------------------------
-    // For CFCMutableDictionary only
-    //------------------------------------------------------------------
-
+  //------------------------------------------------------------------
+  // For CFCMutableDictionary only
+  //------------------------------------------------------------------
 };
 
-
-#endif  // CoreFoundationCPP_CFMutableDictionary_h_
+#endif // CoreFoundationCPP_CFMutableDictionary_h_

Modified: lldb/trunk/source/Host/macosx/cfcpp/CFCMutableSet.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/cfcpp/CFCMutableSet.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/cfcpp/CFCMutableSet.cpp (original)
+++ lldb/trunk/source/Host/macosx/cfcpp/CFCMutableSet.cpp Tue Sep  6 15:57:50 2016
@@ -17,98 +17,73 @@
 //----------------------------------------------------------------------
 // CFCString constructor
 //----------------------------------------------------------------------
-CFCMutableSet::CFCMutableSet(CFMutableSetRef s) :
-    CFCReleaser<CFMutableSetRef> (s)
-{
-}
+CFCMutableSet::CFCMutableSet(CFMutableSetRef s)
+    : CFCReleaser<CFMutableSetRef>(s) {}
 
 //----------------------------------------------------------------------
 // CFCMutableSet copy constructor
 //----------------------------------------------------------------------
-CFCMutableSet::CFCMutableSet(const CFCMutableSet& rhs) :
-    CFCReleaser<CFMutableSetRef> (rhs)
-{
-}
+CFCMutableSet::CFCMutableSet(const CFCMutableSet &rhs)
+    : CFCReleaser<CFMutableSetRef>(rhs) {}
 
 //----------------------------------------------------------------------
 // CFCMutableSet copy constructor
 //----------------------------------------------------------------------
-const CFCMutableSet&
-CFCMutableSet::operator=(const CFCMutableSet& rhs)
-{
-    if (this != &rhs)
-        *this = rhs;
-    return *this;
+const CFCMutableSet &CFCMutableSet::operator=(const CFCMutableSet &rhs) {
+  if (this != &rhs)
+    *this = rhs;
+  return *this;
 }
 
 //----------------------------------------------------------------------
 // Destructor
 //----------------------------------------------------------------------
-CFCMutableSet::~CFCMutableSet()
-{
-}
+CFCMutableSet::~CFCMutableSet() {}
 
-
-CFIndex
-CFCMutableSet::GetCount() const
-{
-    CFMutableSetRef set = get();
-    if (set)
-        return ::CFSetGetCount (set);
-    return 0;
-}
-
-CFIndex
-CFCMutableSet::GetCountOfValue(const void *value) const
-{
-    CFMutableSetRef set = get();
-    if (set)
-        return ::CFSetGetCountOfValue (set, value);
-    return 0;
-}
-
-const void *
-CFCMutableSet::GetValue(const void *value) const
-{
-    CFMutableSetRef set = get();
-    if (set)
-        return ::CFSetGetValue(set, value);
-    return NULL;
-}
-
-
-const void *
-CFCMutableSet::AddValue(const void *value, bool can_create)
-{
-    CFMutableSetRef set = get();
-    if (set == NULL)
-    {
-        if (can_create == false)
-            return NULL;
-        set = ::CFSetCreateMutable(kCFAllocatorDefault, 0, &kCFTypeSetCallBacks);
-        reset ( set );
-    }
-    if (set != NULL)
-    {
-        ::CFSetAddValue(set, value);
-        return value;
-    }
-    return NULL;
-}
-
-void
-CFCMutableSet::RemoveValue(const void *value)
-{
-    CFMutableSetRef set = get();
-    if (set)
-        ::CFSetRemoveValue(set, value);
-}
-
-void
-CFCMutableSet::RemoveAllValues()
-{
-    CFMutableSetRef set = get();
-    if (set)
-        ::CFSetRemoveAllValues(set);
+CFIndex CFCMutableSet::GetCount() const {
+  CFMutableSetRef set = get();
+  if (set)
+    return ::CFSetGetCount(set);
+  return 0;
+}
+
+CFIndex CFCMutableSet::GetCountOfValue(const void *value) const {
+  CFMutableSetRef set = get();
+  if (set)
+    return ::CFSetGetCountOfValue(set, value);
+  return 0;
+}
+
+const void *CFCMutableSet::GetValue(const void *value) const {
+  CFMutableSetRef set = get();
+  if (set)
+    return ::CFSetGetValue(set, value);
+  return NULL;
+}
+
+const void *CFCMutableSet::AddValue(const void *value, bool can_create) {
+  CFMutableSetRef set = get();
+  if (set == NULL) {
+    if (can_create == false)
+      return NULL;
+    set = ::CFSetCreateMutable(kCFAllocatorDefault, 0, &kCFTypeSetCallBacks);
+    reset(set);
+  }
+  if (set != NULL) {
+    ::CFSetAddValue(set, value);
+    return value;
+  }
+  return NULL;
+}
+
+void CFCMutableSet::RemoveValue(const void *value) {
+  CFMutableSetRef set = get();
+  if (set)
+    ::CFSetRemoveValue(set, value);
+}
+
+void CFCMutableSet::RemoveAllValues() {
+  CFMutableSetRef set = get();
+  if (set)
+    ::CFSetRemoveAllValues(set);
 }
-

Modified: lldb/trunk/source/Host/macosx/cfcpp/CFCMutableSet.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/cfcpp/CFCMutableSet.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/cfcpp/CFCMutableSet.h (original)
+++ lldb/trunk/source/Host/macosx/cfcpp/CFCMutableSet.h Tue Sep  6 15:57:50 2016
@@ -12,42 +12,36 @@
 
 #include "CFCReleaser.h"
 
-class CFCMutableSet : public CFCReleaser<CFMutableSetRef>
-{
+class CFCMutableSet : public CFCReleaser<CFMutableSetRef> {
 public:
-    //------------------------------------------------------------------
-    // Constructors and Destructors
-    //------------------------------------------------------------------
-    CFCMutableSet(CFMutableSetRef s = NULL);
-    CFCMutableSet(const CFCMutableSet& rhs);
-    virtual ~CFCMutableSet();
-
-    //------------------------------------------------------------------
-    // Operators
-    //------------------------------------------------------------------
-    const CFCMutableSet&
-    operator=(const CFCMutableSet& rhs);
-
-
-    CFIndex GetCount() const;
-    CFIndex GetCountOfValue(const void *value) const;
-    const void * GetValue(const void *value) const;
-    const void * AddValue(const void *value, bool can_create);
-    void RemoveValue(const void *value);
-    void RemoveAllValues();
-
-
+  //------------------------------------------------------------------
+  // Constructors and Destructors
+  //------------------------------------------------------------------
+  CFCMutableSet(CFMutableSetRef s = NULL);
+  CFCMutableSet(const CFCMutableSet &rhs);
+  virtual ~CFCMutableSet();
+
+  //------------------------------------------------------------------
+  // Operators
+  //------------------------------------------------------------------
+  const CFCMutableSet &operator=(const CFCMutableSet &rhs);
+
+  CFIndex GetCount() const;
+  CFIndex GetCountOfValue(const void *value) const;
+  const void *GetValue(const void *value) const;
+  const void *AddValue(const void *value, bool can_create);
+  void RemoveValue(const void *value);
+  void RemoveAllValues();
 
 protected:
-    //------------------------------------------------------------------
-    // Classes that inherit from CFCMutableSet can see and modify these
-    //------------------------------------------------------------------
+  //------------------------------------------------------------------
+  // Classes that inherit from CFCMutableSet can see and modify these
+  //------------------------------------------------------------------
 
 private:
-    //------------------------------------------------------------------
-    // For CFCMutableSet only
-    //------------------------------------------------------------------
-
+  //------------------------------------------------------------------
+  // For CFCMutableSet only
+  //------------------------------------------------------------------
 };
 
-#endif  // CoreFoundationCPP_CFMutableSet_h_
+#endif // CoreFoundationCPP_CFMutableSet_h_

Modified: lldb/trunk/source/Host/macosx/cfcpp/CFCReleaser.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/cfcpp/CFCReleaser.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/cfcpp/CFCReleaser.h (original)
+++ lldb/trunk/source/Host/macosx/cfcpp/CFCReleaser.h Tue Sep  6 15:57:50 2016
@@ -26,133 +26,103 @@
 // pointer, it is designed to relinquish ownership of the pointer just
 // like std:auto_ptr<T>::release() does.
 //----------------------------------------------------------------------
-template <class T>
-class CFCReleaser
-{
+template <class T> class CFCReleaser {
 public:
-    //----------------------------------------------------------
-    // Constructor that takes a pointer to a CF object that is
-    // to be released when this object goes out of scope
-    //----------------------------------------------------------
-    CFCReleaser(T ptr = NULL) :
-        _ptr(ptr)
-    {
-    }
-
-    //----------------------------------------------------------
-    // Copy constructor
-    //
-    // Note that copying a CFCReleaser will not transfer
-    // ownership of the contained pointer, but it will bump its
-    // reference count. This is where this class differs from
-    // std::auto_ptr.
-    //----------------------------------------------------------
-    CFCReleaser(const CFCReleaser& rhs) :
-        _ptr(rhs.get())
-    {
-        if (get())
-            ::CFRetain(get());
-    }
-
-
-    //----------------------------------------------------------
-    // The destructor will release the pointer that it contains
-    // if it has a valid pointer.
-    //----------------------------------------------------------
-    virtual ~CFCReleaser()
-    {
-        reset();
-    }
-
-    //----------------------------------------------------------
-    // Assignment operator.
-    //
-    // Note that assigning one CFCReleaser to another will
-    // not transfer ownership of the contained pointer, but it
-    // will bump its reference count. This is where this class
-    // differs from std::auto_ptr.
-    //----------------------------------------------------------
-    CFCReleaser&
-    operator= (const CFCReleaser<T>& rhs)
-    {
-        if (this != &rhs)
-        {
-            // Replace our owned pointer with the new one
-            reset(rhs.get());
-            // Retain the current pointer that we own
-            if (get())
-                ::CFRetain(get());
-        }
-        return *this;
-    }
-
-    //----------------------------------------------------------
-    // Get the address of the contained type in case it needs
-    // to be passed to a function that will fill in a pointer
-    // value. The function currently will assert if _ptr is not
-    // NULL because the only time this method should be used is
-    // if another function will modify the contents, and we
-    // could leak a pointer if this is not NULL. If the
-    // assertion fires, check the offending code, or call
-    // reset() prior to using the "ptr_address()" member to make
-    // sure any owned objects has CFRelease called on it.
-    // I had to add the "enforce_null" bool here because some
-    // API's require the pointer address even though they don't change it.
-    //----------------------------------------------------------
-    T*
-    ptr_address(bool enforce_null = true)
-    {
-        if (enforce_null)
-            assert (_ptr == NULL);
-        return &_ptr;
-    }
-
-    //----------------------------------------------------------
-    // Access the pointer itself
-    //----------------------------------------------------------
-    T
-    get()
-    {
-        return _ptr;
-    }
-
-    const T
-    get() const
-    {
-        return _ptr;
-    }
-
-
-    //----------------------------------------------------------
-    // Set a new value for the pointer and CFRelease our old
-    // value if we had a valid one.
-    //----------------------------------------------------------
-    void
-    reset(T ptr = NULL)
-    {
-        if ((_ptr != NULL) && (ptr != _ptr))
-            ::CFRelease(_ptr);
-        _ptr = ptr;
-    }
-
-    //----------------------------------------------------------
-    // Release ownership without calling CFRelease. This class
-    // is designed to mimic std::auto_ptr<T>, so the release
-    // method releases ownership of the contained pointer
-    // and does NOT call CFRelease.
-    //----------------------------------------------------------
-    T
-    release()
-    {
-        T tmp = _ptr;
-        _ptr = NULL;
-        return tmp;
-    }
+  //----------------------------------------------------------
+  // Constructor that takes a pointer to a CF object that is
+  // to be released when this object goes out of scope
+  //----------------------------------------------------------
+  CFCReleaser(T ptr = NULL) : _ptr(ptr) {}
+
+  //----------------------------------------------------------
+  // Copy constructor
+  //
+  // Note that copying a CFCReleaser will not transfer
+  // ownership of the contained pointer, but it will bump its
+  // reference count. This is where this class differs from
+  // std::auto_ptr.
+  //----------------------------------------------------------
+  CFCReleaser(const CFCReleaser &rhs) : _ptr(rhs.get()) {
+    if (get())
+      ::CFRetain(get());
+  }
+
+  //----------------------------------------------------------
+  // The destructor will release the pointer that it contains
+  // if it has a valid pointer.
+  //----------------------------------------------------------
+  virtual ~CFCReleaser() { reset(); }
+
+  //----------------------------------------------------------
+  // Assignment operator.
+  //
+  // Note that assigning one CFCReleaser to another will
+  // not transfer ownership of the contained pointer, but it
+  // will bump its reference count. This is where this class
+  // differs from std::auto_ptr.
+  //----------------------------------------------------------
+  CFCReleaser &operator=(const CFCReleaser<T> &rhs) {
+    if (this != &rhs) {
+      // Replace our owned pointer with the new one
+      reset(rhs.get());
+      // Retain the current pointer that we own
+      if (get())
+        ::CFRetain(get());
+    }
+    return *this;
+  }
+
+  //----------------------------------------------------------
+  // Get the address of the contained type in case it needs
+  // to be passed to a function that will fill in a pointer
+  // value. The function currently will assert if _ptr is not
+  // NULL because the only time this method should be used is
+  // if another function will modify the contents, and we
+  // could leak a pointer if this is not NULL. If the
+  // assertion fires, check the offending code, or call
+  // reset() prior to using the "ptr_address()" member to make
+  // sure any owned objects has CFRelease called on it.
+  // I had to add the "enforce_null" bool here because some
+  // API's require the pointer address even though they don't change it.
+  //----------------------------------------------------------
+  T *ptr_address(bool enforce_null = true) {
+    if (enforce_null)
+      assert(_ptr == NULL);
+    return &_ptr;
+  }
+
+  //----------------------------------------------------------
+  // Access the pointer itself
+  //----------------------------------------------------------
+  T get() { return _ptr; }
+
+  const T get() const { return _ptr; }
+
+  //----------------------------------------------------------
+  // Set a new value for the pointer and CFRelease our old
+  // value if we had a valid one.
+  //----------------------------------------------------------
+  void reset(T ptr = NULL) {
+    if ((_ptr != NULL) && (ptr != _ptr))
+      ::CFRelease(_ptr);
+    _ptr = ptr;
+  }
+
+  //----------------------------------------------------------
+  // Release ownership without calling CFRelease. This class
+  // is designed to mimic std::auto_ptr<T>, so the release
+  // method releases ownership of the contained pointer
+  // and does NOT call CFRelease.
+  //----------------------------------------------------------
+  T release() {
+    T tmp = _ptr;
+    _ptr = NULL;
+    return tmp;
+  }
 
 private:
-    T _ptr;
+  T _ptr;
 };
 
-#endif  // #ifdef __cplusplus
-#endif  // #ifndef CoreFoundationCPP_CFReleaser_h_
-
+#endif // #ifdef __cplusplus
+#endif // #ifndef CoreFoundationCPP_CFReleaser_h_

Modified: lldb/trunk/source/Host/macosx/cfcpp/CFCString.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/cfcpp/CFCString.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/cfcpp/CFCString.cpp (original)
+++ lldb/trunk/source/Host/macosx/cfcpp/CFCString.cpp Tue Sep  6 15:57:50 2016
@@ -8,151 +8,123 @@
 //===----------------------------------------------------------------------===//
 
 #include "CFCString.h"
-#include <string>
 #include <glob.h>
+#include <string>
 
 //----------------------------------------------------------------------
 // CFCString constructor
 //----------------------------------------------------------------------
-CFCString::CFCString(CFStringRef s) :
-    CFCReleaser<CFStringRef> (s)
-{
-}
+CFCString::CFCString(CFStringRef s) : CFCReleaser<CFStringRef>(s) {}
 
 //----------------------------------------------------------------------
 // CFCString copy constructor
 //----------------------------------------------------------------------
-CFCString::CFCString(const CFCString& rhs) :
-    CFCReleaser<CFStringRef> (rhs)
-{
-
-}
+CFCString::CFCString(const CFCString &rhs) : CFCReleaser<CFStringRef>(rhs) {}
 
 //----------------------------------------------------------------------
 // CFCString copy constructor
 //----------------------------------------------------------------------
-CFCString&
-CFCString::operator=(const CFCString& rhs)
-{
-    if (this != &rhs)
-        *this = rhs;
-    return *this;
+CFCString &CFCString::operator=(const CFCString &rhs) {
+  if (this != &rhs)
+    *this = rhs;
+  return *this;
 }
 
-CFCString::CFCString (const char *cstr, CFStringEncoding cstr_encoding) :
-    CFCReleaser<CFStringRef> ()
-{
-    if (cstr && cstr[0])
-    {
-        reset(::CFStringCreateWithCString(kCFAllocatorDefault, cstr, cstr_encoding));
-    }
+CFCString::CFCString(const char *cstr, CFStringEncoding cstr_encoding)
+    : CFCReleaser<CFStringRef>() {
+  if (cstr && cstr[0]) {
+    reset(
+        ::CFStringCreateWithCString(kCFAllocatorDefault, cstr, cstr_encoding));
+  }
 }
 
 //----------------------------------------------------------------------
 // Destructor
 //----------------------------------------------------------------------
-CFCString::~CFCString()
-{
-}
+CFCString::~CFCString() {}
 
-const char *
-CFCString::GetFileSystemRepresentation(std::string& s)
-{
-    return CFCString::FileSystemRepresentation(get(), s);
+const char *CFCString::GetFileSystemRepresentation(std::string &s) {
+  return CFCString::FileSystemRepresentation(get(), s);
 }
 
-CFStringRef
-CFCString::SetFileSystemRepresentation (const char *path)
-{
-    CFStringRef new_value = NULL;
-    if (path && path[0])
-        new_value = ::CFStringCreateWithFileSystemRepresentation (kCFAllocatorDefault, path);
-    reset(new_value);
-    return get();
+CFStringRef CFCString::SetFileSystemRepresentation(const char *path) {
+  CFStringRef new_value = NULL;
+  if (path && path[0])
+    new_value =
+        ::CFStringCreateWithFileSystemRepresentation(kCFAllocatorDefault, path);
+  reset(new_value);
+  return get();
 }
 
-
 CFStringRef
-CFCString::SetFileSystemRepresentationFromCFType (CFTypeRef cf_type)
-{
-    CFStringRef new_value = NULL;
-    if (cf_type != NULL)
-    {
-        CFTypeID cf_type_id = ::CFGetTypeID(cf_type);
-
-        if (cf_type_id == ::CFStringGetTypeID())
-        {
-            // Retain since we are using the existing object
-            new_value = (CFStringRef)::CFRetain(cf_type);
-        }
-        else if (cf_type_id == ::CFURLGetTypeID())
-        {
-            new_value = ::CFURLCopyFileSystemPath((CFURLRef)cf_type, kCFURLPOSIXPathStyle);
-        }
+CFCString::SetFileSystemRepresentationFromCFType(CFTypeRef cf_type) {
+  CFStringRef new_value = NULL;
+  if (cf_type != NULL) {
+    CFTypeID cf_type_id = ::CFGetTypeID(cf_type);
+
+    if (cf_type_id == ::CFStringGetTypeID()) {
+      // Retain since we are using the existing object
+      new_value = (CFStringRef)::CFRetain(cf_type);
+    } else if (cf_type_id == ::CFURLGetTypeID()) {
+      new_value =
+          ::CFURLCopyFileSystemPath((CFURLRef)cf_type, kCFURLPOSIXPathStyle);
     }
-    reset(new_value);
-    return get();
+  }
+  reset(new_value);
+  return get();
 }
 
 CFStringRef
-CFCString::SetFileSystemRepresentationAndExpandTilde (const char *path)
-{
-    std::string expanded_path;
-    if (CFCString::ExpandTildeInPath(path, expanded_path))
-        SetFileSystemRepresentation(expanded_path.c_str());
-    else
-        reset();
-    return get();
+CFCString::SetFileSystemRepresentationAndExpandTilde(const char *path) {
+  std::string expanded_path;
+  if (CFCString::ExpandTildeInPath(path, expanded_path))
+    SetFileSystemRepresentation(expanded_path.c_str());
+  else
+    reset();
+  return get();
 }
 
-const char *
-CFCString::UTF8(std::string& str)
-{
-    return CFCString::UTF8(get(), str);
+const char *CFCString::UTF8(std::string &str) {
+  return CFCString::UTF8(get(), str);
 }
 
 // Static function that puts a copy of the UTF8 contents of CF_STR into STR
-// and returns the C string pointer that is contained in STR when successful, else
-// NULL is returned. This allows the std::string parameter to own the extracted string,
-// and also allows that string to be returned as a C string pointer that can be used.
-
-const char *
-CFCString::UTF8 (CFStringRef cf_str, std::string& str)
-{
-    if (cf_str)
-    {
-        const CFStringEncoding encoding = kCFStringEncodingUTF8;
-        CFIndex max_utf8_str_len = CFStringGetLength (cf_str);
-        max_utf8_str_len = CFStringGetMaximumSizeForEncoding (max_utf8_str_len, encoding);
-        if (max_utf8_str_len > 0)
-        {
-            str.resize(max_utf8_str_len);
-            if (!str.empty())
-            {
-                if (CFStringGetCString (cf_str, &str[0], str.size(), encoding))
-                {
-                    str.resize(strlen(str.c_str()));
-                    return str.c_str();
-                }
-            }
+// and returns the C string pointer that is contained in STR when successful,
+// else
+// NULL is returned. This allows the std::string parameter to own the extracted
+// string,
+// and also allows that string to be returned as a C string pointer that can be
+// used.
+
+const char *CFCString::UTF8(CFStringRef cf_str, std::string &str) {
+  if (cf_str) {
+    const CFStringEncoding encoding = kCFStringEncodingUTF8;
+    CFIndex max_utf8_str_len = CFStringGetLength(cf_str);
+    max_utf8_str_len =
+        CFStringGetMaximumSizeForEncoding(max_utf8_str_len, encoding);
+    if (max_utf8_str_len > 0) {
+      str.resize(max_utf8_str_len);
+      if (!str.empty()) {
+        if (CFStringGetCString(cf_str, &str[0], str.size(), encoding)) {
+          str.resize(strlen(str.c_str()));
+          return str.c_str();
         }
+      }
     }
-    return NULL;
+  }
+  return NULL;
 }
 
-const char*
-CFCString::ExpandTildeInPath(const char* path, std::string &expanded_path)
-{
-    glob_t globbuf;
-    if (::glob (path, GLOB_TILDE, NULL, &globbuf) == 0)
-    {
-        expanded_path = globbuf.gl_pathv[0];
-        ::globfree (&globbuf);
-    }
-    else
-        expanded_path.clear();
+const char *CFCString::ExpandTildeInPath(const char *path,
+                                         std::string &expanded_path) {
+  glob_t globbuf;
+  if (::glob(path, GLOB_TILDE, NULL, &globbuf) == 0) {
+    expanded_path = globbuf.gl_pathv[0];
+    ::globfree(&globbuf);
+  } else
+    expanded_path.clear();
 
-    return expanded_path.c_str();
+  return expanded_path.c_str();
 }
 
 // Static function that puts a copy of the file system representation of CF_STR
@@ -161,35 +133,29 @@ CFCString::ExpandTildeInPath(const char*
 // to own the extracted string, and also allows that string to be returned as
 // a C string pointer that can be used.
 
-const char *
-CFCString::FileSystemRepresentation (CFStringRef cf_str, std::string& str)
-{
-    if (cf_str)
-    {
-        CFIndex max_length = ::CFStringGetMaximumSizeOfFileSystemRepresentation (cf_str);
-        if (max_length > 0)
-        {
-            str.resize(max_length);
-            if (!str.empty())
-            {
-                if (::CFStringGetFileSystemRepresentation (cf_str, &str[0], str.size()))
-                {
-                    str.erase(::strlen(str.c_str()));
-                    return str.c_str();
-                }
-            }
+const char *CFCString::FileSystemRepresentation(CFStringRef cf_str,
+                                                std::string &str) {
+  if (cf_str) {
+    CFIndex max_length =
+        ::CFStringGetMaximumSizeOfFileSystemRepresentation(cf_str);
+    if (max_length > 0) {
+      str.resize(max_length);
+      if (!str.empty()) {
+        if (::CFStringGetFileSystemRepresentation(cf_str, &str[0],
+                                                  str.size())) {
+          str.erase(::strlen(str.c_str()));
+          return str.c_str();
         }
+      }
     }
-    str.erase();
-    return NULL;
+  }
+  str.erase();
+  return NULL;
 }
 
-
-CFIndex
-CFCString::GetLength() const
-{
-    CFStringRef str = get();
-    if (str)
-        return CFStringGetLength (str);
-    return 0;
+CFIndex CFCString::GetLength() const {
+  CFStringRef str = get();
+  if (str)
+    return CFStringGetLength(str);
+  return 0;
 }

Modified: lldb/trunk/source/Host/macosx/cfcpp/CFCString.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/cfcpp/CFCString.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/cfcpp/CFCString.h (original)
+++ lldb/trunk/source/Host/macosx/cfcpp/CFCString.h Tue Sep  6 15:57:50 2016
@@ -14,28 +14,28 @@
 
 #include "CFCReleaser.h"
 
-class CFCString : public CFCReleaser<CFStringRef>
-{
+class CFCString : public CFCReleaser<CFStringRef> {
 public:
-    //------------------------------------------------------------------
-    // Constructors and Destructors
-    //------------------------------------------------------------------
-                        CFCString (CFStringRef cf_str = NULL);
-                        CFCString (const char *s, CFStringEncoding encoding = kCFStringEncodingUTF8);
-                        CFCString (const CFCString& rhs);
-                        CFCString& operator= (const CFCString& rhs);
-                        virtual ~CFCString ();
-
-        const char *    GetFileSystemRepresentation (std::string& str);
-        CFStringRef     SetFileSystemRepresentation (const char *path);
-        CFStringRef     SetFileSystemRepresentationFromCFType (CFTypeRef cf_type);
-        CFStringRef     SetFileSystemRepresentationAndExpandTilde (const char *path);
-        const char *    UTF8 (std::string& str);
-        CFIndex         GetLength() const;
-        static const char *UTF8 (CFStringRef cf_str, std::string& str);
-        static const char *FileSystemRepresentation (CFStringRef cf_str, std::string& str);
-        static const char *ExpandTildeInPath(const char* path, std::string &expanded_path);
+  //------------------------------------------------------------------
+  // Constructors and Destructors
+  //------------------------------------------------------------------
+  CFCString(CFStringRef cf_str = NULL);
+  CFCString(const char *s, CFStringEncoding encoding = kCFStringEncodingUTF8);
+  CFCString(const CFCString &rhs);
+  CFCString &operator=(const CFCString &rhs);
+  virtual ~CFCString();
 
+  const char *GetFileSystemRepresentation(std::string &str);
+  CFStringRef SetFileSystemRepresentation(const char *path);
+  CFStringRef SetFileSystemRepresentationFromCFType(CFTypeRef cf_type);
+  CFStringRef SetFileSystemRepresentationAndExpandTilde(const char *path);
+  const char *UTF8(std::string &str);
+  CFIndex GetLength() const;
+  static const char *UTF8(CFStringRef cf_str, std::string &str);
+  static const char *FileSystemRepresentation(CFStringRef cf_str,
+                                              std::string &str);
+  static const char *ExpandTildeInPath(const char *path,
+                                       std::string &expanded_path);
 };
 
 #endif // #ifndef CoreFoundationCPP_CFString_h_

Modified: lldb/trunk/source/Host/macosx/cfcpp/CoreFoundationCPP.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/cfcpp/CoreFoundationCPP.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/cfcpp/CoreFoundationCPP.h (original)
+++ lldb/trunk/source/Host/macosx/cfcpp/CoreFoundationCPP.h Tue Sep  6 15:57:50 2016
@@ -21,10 +21,10 @@
 
 #include <CoreFoundationCPP/CFCBundle.h>
 #include <CoreFoundationCPP/CFCData.h>
-#include <CoreFoundationCPP/CFCReleaser.h>
 #include <CoreFoundationCPP/CFCMutableArray.h>
 #include <CoreFoundationCPP/CFCMutableDictionary.h>
 #include <CoreFoundationCPP/CFCMutableSet.h>
+#include <CoreFoundationCPP/CFCReleaser.h>
 #include <CoreFoundationCPP/CFCString.h>
 
-#endif  // CoreFoundationCPP_CoreFoundationCPP_H_
+#endif // CoreFoundationCPP_CoreFoundationCPP_H_

Modified: lldb/trunk/source/Host/netbsd/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/netbsd/Host.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/netbsd/Host.cpp (original)
+++ lldb/trunk/source/Host/netbsd/Host.cpp Tue Sep  6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- source/Host/netbsd/Host.cpp ------------------------------*- C++ -*-===//
+//===-- source/Host/netbsd/Host.cpp ------------------------------*- C++
+//-*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -8,35 +9,35 @@
 //===----------------------------------------------------------------------===//
 
 // C Includes
-#include <stdio.h>
 #include <dlfcn.h>
 #include <execinfo.h>
+#include <stdio.h>
+#include <sys/proc.h>
+#include <sys/sysctl.h>
 #include <sys/types.h>
 #include <sys/user.h>
-#include <sys/sysctl.h>
-#include <sys/proc.h>
 
 #include <limits.h>
 
-#include <sys/ptrace.h>
-#include <sys/exec.h>
 #include <elf.h>
 #include <kvm.h>
+#include <sys/exec.h>
+#include <sys/ptrace.h>
 
 // C++ Includes
 // Other libraries and framework includes
 // Project includes
+#include "lldb/Core/DataExtractor.h"
 #include "lldb/Core/Error.h"
-#include "lldb/Host/Endian.h"
-#include "lldb/Host/Host.h"
-#include "lldb/Host/HostInfo.h"
+#include "lldb/Core/Log.h"
 #include "lldb/Core/Module.h"
-#include "lldb/Core/DataExtractor.h"
 #include "lldb/Core/StreamFile.h"
 #include "lldb/Core/StreamString.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Target/Process.h"
+#include "lldb/Host/Endian.h"
+#include "lldb/Host/Host.h"
+#include "lldb/Host/HostInfo.h"
 #include "lldb/Target/Platform.h"
+#include "lldb/Target/Process.h"
 
 #include "lldb/Core/DataBufferHeap.h"
 #include "lldb/Core/DataExtractor.h"
@@ -46,242 +47,222 @@
 #include "llvm/Support/Host.h"
 
 extern "C" {
-    extern char **environ;
+extern char **environ;
 }
 
 using namespace lldb;
 using namespace lldb_private;
 
-size_t
-Host::GetEnvironment (StringList &env)
-{
-    char *v;
-    char **var = environ;
-    for (; var != NULL && *var != NULL; ++var)
-    {
-        v = ::strchr(*var, (int)'-');
-        if (v == NULL)
-            continue;
-        env.AppendString(v);
-    }
-    return env.GetSize();
+size_t Host::GetEnvironment(StringList &env) {
+  char *v;
+  char **var = environ;
+  for (; var != NULL && *var != NULL; ++var) {
+    v = ::strchr(*var, (int)'-');
+    if (v == NULL)
+      continue;
+    env.AppendString(v);
+  }
+  return env.GetSize();
 }
 
-static bool
-GetNetBSDProcessArgs (const ProcessInstanceInfoMatch *match_info_ptr,
-                      ProcessInstanceInfo &process_info)
-{
-    if (!process_info.ProcessIDIsValid())
-        return false;
-
-    int pid = process_info.GetProcessID();
-
-    int mib[4] = { CTL_KERN, KERN_PROC_ARGS, pid, KERN_PROC_ARGV };
-
-    char arg_data[8192];
-    size_t arg_data_size = sizeof(arg_data);
-    if (::sysctl (mib, 4, arg_data, &arg_data_size , NULL, 0) != 0)
-        return false;
-
-    DataExtractor data (arg_data, arg_data_size, endian::InlHostByteOrder(), sizeof(void *));
-    lldb::offset_t offset = 0;
-    const char *cstr;
+static bool GetNetBSDProcessArgs(const ProcessInstanceInfoMatch *match_info_ptr,
+                                 ProcessInstanceInfo &process_info) {
+  if (!process_info.ProcessIDIsValid())
+    return false;
 
-    cstr = data.GetCStr (&offset);
-    if (!cstr)
-        return false;
+  int pid = process_info.GetProcessID();
 
-    process_info.GetExecutableFile().SetFile(cstr, false);
+  int mib[4] = {CTL_KERN, KERN_PROC_ARGS, pid, KERN_PROC_ARGV};
 
-    if (!(match_info_ptr == NULL ||
-        NameMatches (process_info.GetExecutableFile().GetFilename().GetCString(),
-                     match_info_ptr->GetNameMatchType(),
-                     match_info_ptr->GetProcessInfo().GetName())))
-        return false;
-
-    Args &proc_args = process_info.GetArguments();
-    while (1)
-    {
-        const uint8_t *p = data.PeekData(offset, 1);
-        while ((p != NULL) && (*p == '\0') && offset < arg_data_size)
-        {
-            ++offset;
-            p = data.PeekData(offset, 1);
-        }
-        if (p == NULL || offset >= arg_data_size)
-            break;
+  char arg_data[8192];
+  size_t arg_data_size = sizeof(arg_data);
+  if (::sysctl(mib, 4, arg_data, &arg_data_size, NULL, 0) != 0)
+    return false;
 
-        cstr = data.GetCStr(&offset);
-        if (!cstr)
-            break;
+  DataExtractor data(arg_data, arg_data_size, endian::InlHostByteOrder(),
+                     sizeof(void *));
+  lldb::offset_t offset = 0;
+  const char *cstr;
 
-        proc_args.AppendArgument(cstr);
-    }
+  cstr = data.GetCStr(&offset);
+  if (!cstr)
+    return false;
 
-    return true;
-}
+  process_info.GetExecutableFile().SetFile(cstr, false);
 
-static bool
-GetNetBSDProcessCPUType (ProcessInstanceInfo &process_info)
-{
-    if (process_info.ProcessIDIsValid())
-    {
-        process_info.GetArchitecture() = HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
-        return true;
-    }
-    process_info.GetArchitecture().Clear();
+  if (!(match_info_ptr == NULL ||
+        NameMatches(process_info.GetExecutableFile().GetFilename().GetCString(),
+                    match_info_ptr->GetNameMatchType(),
+                    match_info_ptr->GetProcessInfo().GetName())))
     return false;
-}
 
-static bool
-GetNetBSDProcessUserAndGroup(ProcessInstanceInfo &process_info)
-{
-    ::kvm_t *kdp;
-    char errbuf[_POSIX2_LINE_MAX]; /* XXX: error string unused */
-
-    struct ::kinfo_proc2 *proc_kinfo;
-    const int pid = process_info.GetProcessID();
-    int nproc;
-
-    if (!process_info.ProcessIDIsValid())
-        goto error;
-
-    if ((kdp = ::kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, errbuf)) == NULL)
-        goto error;
-
-    if ((proc_kinfo = ::kvm_getproc2(kdp, KERN_PROC_PID, pid,
-                                     sizeof(struct ::kinfo_proc2),
-                                     &nproc)) == NULL) {
-        ::kvm_close(kdp);
-        goto error;
+  Args &proc_args = process_info.GetArguments();
+  while (1) {
+    const uint8_t *p = data.PeekData(offset, 1);
+    while ((p != NULL) && (*p == '\0') && offset < arg_data_size) {
+      ++offset;
+      p = data.PeekData(offset, 1);
     }
+    if (p == NULL || offset >= arg_data_size)
+      break;
 
-    if (nproc < 1) {
-        ::kvm_close(kdp); /* XXX: we don't check for error here */
-        goto error;
-    }
+    cstr = data.GetCStr(&offset);
+    if (!cstr)
+      break;
 
-    process_info.SetParentProcessID (proc_kinfo->p_ppid);
-    process_info.SetUserID (proc_kinfo->p_ruid);
-    process_info.SetGroupID (proc_kinfo->p_rgid);
-    process_info.SetEffectiveUserID (proc_kinfo->p_uid);
-    process_info.SetEffectiveGroupID (proc_kinfo->p_gid);
+    proc_args.AppendArgument(cstr);
+  }
 
-    ::kvm_close(kdp); /* XXX: we don't check for error here */
+  return true;
+}
 
+static bool GetNetBSDProcessCPUType(ProcessInstanceInfo &process_info) {
+  if (process_info.ProcessIDIsValid()) {
+    process_info.GetArchitecture() =
+        HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
     return true;
-
-error:
-     process_info.SetParentProcessID (LLDB_INVALID_PROCESS_ID);
-     process_info.SetUserID (UINT32_MAX);
-     process_info.SetGroupID (UINT32_MAX);
-     process_info.SetEffectiveUserID (UINT32_MAX);
-     process_info.SetEffectiveGroupID (UINT32_MAX);
-     return false;
+  }
+  process_info.GetArchitecture().Clear();
+  return false;
 }
 
-uint32_t
-Host::FindProcesses (const ProcessInstanceInfoMatch &match_info, ProcessInstanceInfoList &process_infos)
-{
-    const ::pid_t our_pid = ::getpid();
-    const ::uid_t our_uid = ::getuid();
-
-    const bool all_users = match_info.GetMatchAllUsers() ||
-        // Special case, if lldb is being run as root we can attach to anything
-        (our_uid == 0);
-
-    kvm_t *kdp;
-    char errbuf[_POSIX2_LINE_MAX]; /* XXX: error string unused */
-    if ((kdp = ::kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, errbuf)) == NULL)
-        return 0;
-
-    struct ::kinfo_proc2 *proc_kinfo;
-    int nproc;
-    if ((proc_kinfo = ::kvm_getproc2(kdp, KERN_PROC_ALL, 0,
-                                     sizeof(struct ::kinfo_proc2),
-                                     &nproc)) == NULL) {
-        ::kvm_close(kdp);
-        return 0;
-    }
+static bool GetNetBSDProcessUserAndGroup(ProcessInstanceInfo &process_info) {
+  ::kvm_t *kdp;
+  char errbuf[_POSIX2_LINE_MAX]; /* XXX: error string unused */
+
+  struct ::kinfo_proc2 *proc_kinfo;
+  const int pid = process_info.GetProcessID();
+  int nproc;
+
+  if (!process_info.ProcessIDIsValid())
+    goto error;
+
+  if ((kdp = ::kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, errbuf)) == NULL)
+    goto error;
+
+  if ((proc_kinfo = ::kvm_getproc2(kdp, KERN_PROC_PID, pid,
+                                   sizeof(struct ::kinfo_proc2), &nproc)) ==
+      NULL) {
+    ::kvm_close(kdp);
+    goto error;
+  }
 
-    for (int i = 0; i < nproc; i++) {
-        if (proc_kinfo[i].p_pid < 1)
-            continue; /* not valid */
-        /* Make sure the user is acceptable */
-        if (!all_users && proc_kinfo[i].p_ruid != our_uid)
-             continue;
-
-        if (proc_kinfo[i].p_pid  == our_pid || // Skip this process
-            proc_kinfo[i].p_pid  == 0       || // Skip kernel (kernel pid is 0)
-            proc_kinfo[i].p_stat == LSZOMB  || // Zombies are bad
-            proc_kinfo[i].p_flag & P_TRACED || // Being debugged?
-            proc_kinfo[i].p_flag & P_WEXIT)    // Working on exiting
-             continue;
-
-
-        // Every thread is a process in NetBSD, but all the threads of a single
-        // process have the same pid. Do not store the process info in the
-        // result list if a process with given identifier is already registered
-        // there.
-        if (proc_kinfo[i].p_nlwps > 1) {
-            bool already_registered = false;
-            for (size_t pi = 0; pi < process_infos.GetSize(); pi++) {
-                if (process_infos.GetProcessIDAtIndex(pi) ==
-                    proc_kinfo[i].p_pid) {
-                    already_registered = true;
-                    break;
-                }
-            }
+  if (nproc < 1) {
+    ::kvm_close(kdp); /* XXX: we don't check for error here */
+    goto error;
+  }
 
-            if (already_registered)
-                continue;
-        }
-        ProcessInstanceInfo process_info;
-        process_info.SetProcessID (proc_kinfo[i].p_pid);
-        process_info.SetParentProcessID (proc_kinfo[i].p_ppid);
-        process_info.SetUserID (proc_kinfo[i].p_ruid);
-        process_info.SetGroupID (proc_kinfo[i].p_rgid);
-        process_info.SetEffectiveUserID (proc_kinfo[i].p_uid);
-        process_info.SetEffectiveGroupID (proc_kinfo[i].p_gid);
-        // Make sure our info matches before we go fetch the name and cpu type
-        if (match_info.Matches (process_info) &&
-            GetNetBSDProcessArgs (&match_info, process_info))
-        {
-            GetNetBSDProcessCPUType (process_info);
-            if (match_info.Matches (process_info))
-                process_infos.Append (process_info);
+  process_info.SetParentProcessID(proc_kinfo->p_ppid);
+  process_info.SetUserID(proc_kinfo->p_ruid);
+  process_info.SetGroupID(proc_kinfo->p_rgid);
+  process_info.SetEffectiveUserID(proc_kinfo->p_uid);
+  process_info.SetEffectiveGroupID(proc_kinfo->p_gid);
+
+  ::kvm_close(kdp); /* XXX: we don't check for error here */
+
+  return true;
+
+error:
+  process_info.SetParentProcessID(LLDB_INVALID_PROCESS_ID);
+  process_info.SetUserID(UINT32_MAX);
+  process_info.SetGroupID(UINT32_MAX);
+  process_info.SetEffectiveUserID(UINT32_MAX);
+  process_info.SetEffectiveGroupID(UINT32_MAX);
+  return false;
+}
+
+uint32_t Host::FindProcesses(const ProcessInstanceInfoMatch &match_info,
+                             ProcessInstanceInfoList &process_infos) {
+  const ::pid_t our_pid = ::getpid();
+  const ::uid_t our_uid = ::getuid();
+
+  const bool all_users =
+      match_info.GetMatchAllUsers() ||
+      // Special case, if lldb is being run as root we can attach to anything
+      (our_uid == 0);
+
+  kvm_t *kdp;
+  char errbuf[_POSIX2_LINE_MAX]; /* XXX: error string unused */
+  if ((kdp = ::kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, errbuf)) == NULL)
+    return 0;
+
+  struct ::kinfo_proc2 *proc_kinfo;
+  int nproc;
+  if ((proc_kinfo = ::kvm_getproc2(kdp, KERN_PROC_ALL, 0,
+                                   sizeof(struct ::kinfo_proc2), &nproc)) ==
+      NULL) {
+    ::kvm_close(kdp);
+    return 0;
+  }
+
+  for (int i = 0; i < nproc; i++) {
+    if (proc_kinfo[i].p_pid < 1)
+      continue; /* not valid */
+    /* Make sure the user is acceptable */
+    if (!all_users && proc_kinfo[i].p_ruid != our_uid)
+      continue;
+
+    if (proc_kinfo[i].p_pid == our_pid ||  // Skip this process
+        proc_kinfo[i].p_pid == 0 ||        // Skip kernel (kernel pid is 0)
+        proc_kinfo[i].p_stat == LSZOMB ||  // Zombies are bad
+        proc_kinfo[i].p_flag & P_TRACED || // Being debugged?
+        proc_kinfo[i].p_flag & P_WEXIT)    // Working on exiting
+      continue;
+
+    // Every thread is a process in NetBSD, but all the threads of a single
+    // process have the same pid. Do not store the process info in the
+    // result list if a process with given identifier is already registered
+    // there.
+    if (proc_kinfo[i].p_nlwps > 1) {
+      bool already_registered = false;
+      for (size_t pi = 0; pi < process_infos.GetSize(); pi++) {
+        if (process_infos.GetProcessIDAtIndex(pi) == proc_kinfo[i].p_pid) {
+          already_registered = true;
+          break;
         }
+      }
+
+      if (already_registered)
+        continue;
+    }
+    ProcessInstanceInfo process_info;
+    process_info.SetProcessID(proc_kinfo[i].p_pid);
+    process_info.SetParentProcessID(proc_kinfo[i].p_ppid);
+    process_info.SetUserID(proc_kinfo[i].p_ruid);
+    process_info.SetGroupID(proc_kinfo[i].p_rgid);
+    process_info.SetEffectiveUserID(proc_kinfo[i].p_uid);
+    process_info.SetEffectiveGroupID(proc_kinfo[i].p_gid);
+    // Make sure our info matches before we go fetch the name and cpu type
+    if (match_info.Matches(process_info) &&
+        GetNetBSDProcessArgs(&match_info, process_info)) {
+      GetNetBSDProcessCPUType(process_info);
+      if (match_info.Matches(process_info))
+        process_infos.Append(process_info);
     }
+  }
 
-    kvm_close(kdp); /* XXX: we don't check for error here */
+  kvm_close(kdp); /* XXX: we don't check for error here */
 
-    return process_infos.GetSize();
+  return process_infos.GetSize();
 }
 
-bool
-Host::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info)
-{
-    process_info.SetProcessID(pid);
-
-    if (GetNetBSDProcessArgs(NULL, process_info))
-    {
-        GetNetBSDProcessCPUType(process_info);
-        GetNetBSDProcessUserAndGroup(process_info);
-        return true;
-    }
+bool Host::GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &process_info) {
+  process_info.SetProcessID(pid);
 
-    process_info.Clear();
-    return false;
+  if (GetNetBSDProcessArgs(NULL, process_info)) {
+    GetNetBSDProcessCPUType(process_info);
+    GetNetBSDProcessUserAndGroup(process_info);
+    return true;
+  }
+
+  process_info.Clear();
+  return false;
 }
 
-lldb::DataBufferSP
-Host::GetAuxvData(lldb_private::Process *process)
-{
-	return lldb::DataBufferSP();
+lldb::DataBufferSP Host::GetAuxvData(lldb_private::Process *process) {
+  return lldb::DataBufferSP();
 }
 
-Error
-Host::ShellExpandArguments (ProcessLaunchInfo &launch_info)
-{
-    return Error("unimplemented");
+Error Host::ShellExpandArguments(ProcessLaunchInfo &launch_info) {
+  return Error("unimplemented");
 }

Modified: lldb/trunk/source/Host/netbsd/HostInfoNetBSD.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/netbsd/HostInfoNetBSD.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/netbsd/HostInfoNetBSD.cpp (original)
+++ lldb/trunk/source/Host/netbsd/HostInfoNetBSD.cpp Tue Sep  6 15:57:50 2016
@@ -9,104 +9,92 @@
 
 #include "lldb/Host/netbsd/HostInfoNetBSD.h"
 
+#include <inttypes.h>
 #include <limits.h>
+#include <pthread.h>
 #include <stdio.h>
 #include <string.h>
-#include <sys/types.h>
 #include <sys/sysctl.h>
+#include <sys/types.h>
 #include <sys/utsname.h>
 #include <unistd.h>
-#include <pthread.h>
-#include <inttypes.h>
-
 
 using namespace lldb_private;
 
-uint32_t
-HostInfoNetBSD::GetMaxThreadNameLength()
-{
-    return PTHREAD_MAX_NAMELEN_NP;
+uint32_t HostInfoNetBSD::GetMaxThreadNameLength() {
+  return PTHREAD_MAX_NAMELEN_NP;
 }
 
-bool
-HostInfoNetBSD::GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update)
-{
-    struct utsname un;
-
-    ::memset(&un, 0, sizeof(un));
-    if (::uname(&un) < 0)
-        return false;
-
-    /* Accept versions like 7.99.21 and 6.1_STABLE */
-    int status = ::sscanf(un.release, "%" PRIu32 ".%" PRIu32 ".%" PRIu32, &major, &minor, &update);
-    switch(status) {
-    case 0:
-        return false;
-    case 1:
-        minor = 0;
-        /* FALLTHROUGH */
-    case 2:
-        update = 0;
-        /* FALLTHROUGH */
-    case 3:
-    default:
-        return true;
-    }
-}
+bool HostInfoNetBSD::GetOSVersion(uint32_t &major, uint32_t &minor,
+                                  uint32_t &update) {
+  struct utsname un;
 
-bool
-HostInfoNetBSD::GetOSBuildString(std::string &s)
-{
-    int mib[2] = {CTL_KERN, KERN_OSREV};
-    char osrev_str[12];
-    int osrev = 0;
-    size_t osrev_len = sizeof(osrev);
-
-    if (::sysctl(mib, 2, &osrev, &osrev_len, NULL, 0) == 0)
-    {
-        ::snprintf(osrev_str, sizeof(osrev_str), "%-10.10d", osrev);
-        s.assign(osrev_str);
-        return true;
-    }
+  ::memset(&un, 0, sizeof(un));
+  if (::uname(&un) < 0)
+    return false;
 
-    s.clear();
+  /* Accept versions like 7.99.21 and 6.1_STABLE */
+  int status = ::sscanf(un.release, "%" PRIu32 ".%" PRIu32 ".%" PRIu32, &major,
+                        &minor, &update);
+  switch (status) {
+  case 0:
     return false;
+  case 1:
+    minor = 0;
+  /* FALLTHROUGH */
+  case 2:
+    update = 0;
+  /* FALLTHROUGH */
+  case 3:
+  default:
+    return true;
+  }
 }
 
-bool
-HostInfoNetBSD::GetOSKernelDescription(std::string &s)
-{
-    struct utsname un;
+bool HostInfoNetBSD::GetOSBuildString(std::string &s) {
+  int mib[2] = {CTL_KERN, KERN_OSREV};
+  char osrev_str[12];
+  int osrev = 0;
+  size_t osrev_len = sizeof(osrev);
+
+  if (::sysctl(mib, 2, &osrev, &osrev_len, NULL, 0) == 0) {
+    ::snprintf(osrev_str, sizeof(osrev_str), "%-10.10d", osrev);
+    s.assign(osrev_str);
+    return true;
+  }
 
-    ::memset(&un, 0, sizeof(un));
-    s.clear();
+  s.clear();
+  return false;
+}
 
-    if (::uname(&un) < 0)
-        return false;
+bool HostInfoNetBSD::GetOSKernelDescription(std::string &s) {
+  struct utsname un;
 
-    s.assign(un.version);
+  ::memset(&un, 0, sizeof(un));
+  s.clear();
 
-    return true;
+  if (::uname(&un) < 0)
+    return false;
+
+  s.assign(un.version);
+
+  return true;
 }
 
-FileSpec
-HostInfoNetBSD::GetProgramFileSpec()
-{
-    static FileSpec g_program_filespec;
-
-    if (!g_program_filespec)
-    {
-        ssize_t len;
-        static char buf[PATH_MAX];
-        char name[PATH_MAX];
-
-        ::snprintf(name, PATH_MAX, "/proc/%d/exe", ::getpid());
-        len = ::readlink(name, buf, PATH_MAX - 1);
-        if (len != -1)
-        {
-            buf[len] = '\0';
-            g_program_filespec.SetFile(buf, false);
-        }
+FileSpec HostInfoNetBSD::GetProgramFileSpec() {
+  static FileSpec g_program_filespec;
+
+  if (!g_program_filespec) {
+    ssize_t len;
+    static char buf[PATH_MAX];
+    char name[PATH_MAX];
+
+    ::snprintf(name, PATH_MAX, "/proc/%d/exe", ::getpid());
+    len = ::readlink(name, buf, PATH_MAX - 1);
+    if (len != -1) {
+      buf[len] = '\0';
+      g_program_filespec.SetFile(buf, false);
     }
-    return g_program_filespec;
+  }
+  return g_program_filespec;
 }

Modified: lldb/trunk/source/Host/netbsd/HostThreadNetBSD.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/netbsd/HostThreadNetBSD.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/netbsd/HostThreadNetBSD.cpp (original)
+++ lldb/trunk/source/Host/netbsd/HostThreadNetBSD.cpp Tue Sep  6 15:57:50 2016
@@ -24,27 +24,20 @@
 
 using namespace lldb_private;
 
-HostThreadNetBSD::HostThreadNetBSD()
-{
-}
+HostThreadNetBSD::HostThreadNetBSD() {}
 
 HostThreadNetBSD::HostThreadNetBSD(lldb::thread_t thread)
-    : HostThreadPosix(thread)
-{
-}
+    : HostThreadPosix(thread) {}
 
-void
-HostThreadNetBSD::SetName(lldb::thread_t thread, llvm::StringRef &name)
-{
-    ::pthread_setname_np(thread, "%s", const_cast<char*>(name.data()));
+void HostThreadNetBSD::SetName(lldb::thread_t thread, llvm::StringRef &name) {
+  ::pthread_setname_np(thread, "%s", const_cast<char *>(name.data()));
 }
 
-void
-HostThreadNetBSD::GetName(lldb::thread_t thread, llvm::SmallVectorImpl<char> &name)
-{
-    char buf[PTHREAD_MAX_NAMELEN_NP];
-    ::pthread_getname_np(thread, buf, PTHREAD_MAX_NAMELEN_NP);
+void HostThreadNetBSD::GetName(lldb::thread_t thread,
+                               llvm::SmallVectorImpl<char> &name) {
+  char buf[PTHREAD_MAX_NAMELEN_NP];
+  ::pthread_getname_np(thread, buf, PTHREAD_MAX_NAMELEN_NP);
 
-    name.clear();
-    name.append(buf, buf + strlen(buf));
+  name.clear();
+  name.append(buf, buf + strlen(buf));
 }

Modified: lldb/trunk/source/Host/netbsd/ThisThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/netbsd/ThisThread.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Host/netbsd/ThisThread.cpp (original)
+++ lldb/trunk/source/Host/netbsd/ThisThread.cpp Tue Sep  6 15:57:50 2016
@@ -7,8 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "lldb/Host/HostNativeThread.h"
 #include "lldb/Host/ThisThread.h"
+#include "lldb/Host/HostNativeThread.h"
 
 #include "llvm/ADT/SmallVector.h"
 
@@ -17,14 +17,10 @@
 
 using namespace lldb_private;
 
-void
-ThisThread::SetName(llvm::StringRef name)
-{
-    HostNativeThread::SetName(::pthread_self(), name);
+void ThisThread::SetName(llvm::StringRef name) {
+  HostNativeThread::SetName(::pthread_self(), name);
 }
 
-void
-ThisThread::GetName(llvm::SmallVectorImpl<char> &name)
-{
-    HostNativeThread::GetName(::pthread_self(), name);
+void ThisThread::GetName(llvm::SmallVectorImpl<char> &name) {
+  HostNativeThread::GetName(::pthread_self(), name);
 }




More information about the lldb-commits mailing list