diff options
author | Kate Stone <katherine.stone@apple.com> | 2016-09-06 20:57:50 +0000 |
---|---|---|
committer | Kate Stone <katherine.stone@apple.com> | 2016-09-06 20:57:50 +0000 |
commit | b9c1b51e45b845debb76d8658edabca70ca56079 (patch) | |
tree | dfcb5a13ef2b014202340f47036da383eaee74aa /lldb/source/Core/ConnectionSharedMemory.cpp | |
parent | d5aa73376966339caad04013510626ec2e42c760 (diff) | |
download | bcm5719-llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.gz bcm5719-llvm-b9c1b51e45b845debb76d8658edabca70ca56079.zip |
*** This commit represents a complete reformatting of the LLDB source code
*** to conform to clang-format’s LLVM style. This kind of mass change has
*** two obvious implications:
Firstly, merging this particular commit into a downstream fork may be a huge
effort. Alternatively, it may be worth merging all changes up to this commit,
performing the same reformatting operation locally, and then discarding the
merge for this particular commit. The commands used to accomplish this
reformatting were as follows (with current working directory as the root of
the repository):
find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} +
find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ;
The version of clang-format used was 3.9.0, and autopep8 was 1.2.4.
Secondly, “blame” style tools will generally point to this commit instead of
a meaningful prior commit. There are alternatives available that will attempt
to look through this change and find the appropriate prior commit. YMMV.
llvm-svn: 280751
Diffstat (limited to 'lldb/source/Core/ConnectionSharedMemory.cpp')
-rw-r--r-- | lldb/source/Core/ConnectionSharedMemory.cpp | 193 |
1 files changed, 84 insertions, 109 deletions
diff --git a/lldb/source/Core/ConnectionSharedMemory.cpp b/lldb/source/Core/ConnectionSharedMemory.cpp index 46948b842e0..74487b017e4 100644 --- a/lldb/source/Core/ConnectionSharedMemory.cpp +++ b/lldb/source/Core/ConnectionSharedMemory.cpp @@ -15,10 +15,10 @@ #ifdef _WIN32 #include "lldb/Host/windows/windows.h" #else +#include <fcntl.h> #include <sys/mman.h> #include <sys/stat.h> #include <sys/types.h> -#include <fcntl.h> #endif // C++ Includes @@ -26,8 +26,8 @@ #include <cstdlib> // Other libraries and framework includes -#include "llvm/Support/MathExtras.h" #include "llvm/Support/ConvertUTF.h" +#include "llvm/Support/MathExtras.h" // Project includes #include "lldb/Core/Communication.h" @@ -37,135 +37,110 @@ using namespace lldb; using namespace lldb_private; -ConnectionSharedMemory::ConnectionSharedMemory () : - Connection(), - m_name(), - m_fd (-1), - m_mmap() -{ -} - -ConnectionSharedMemory::~ConnectionSharedMemory () -{ - Disconnect(nullptr); -} - -bool -ConnectionSharedMemory::IsConnected () const -{ - return m_fd >= 0; -} - -ConnectionStatus -ConnectionSharedMemory::Connect (const char *s, Error *error_ptr) -{ -// if (s && s[0]) -// { -// if (strstr(s, "shm-create://")) -// { -// } -// else if (strstr(s, "shm-connect://")) -// { -// } -// if (error_ptr) -// error_ptr->SetErrorStringWithFormat ("unsupported connection URL: '%s'", s); -// return eConnectionStatusError; -// } - if (error_ptr) - error_ptr->SetErrorString("invalid connect arguments"); - return eConnectionStatusError; +ConnectionSharedMemory::ConnectionSharedMemory() + : Connection(), m_name(), m_fd(-1), m_mmap() {} + +ConnectionSharedMemory::~ConnectionSharedMemory() { Disconnect(nullptr); } + +bool ConnectionSharedMemory::IsConnected() const { return m_fd >= 0; } + +ConnectionStatus ConnectionSharedMemory::Connect(const char *s, + Error *error_ptr) { + // if (s && s[0]) + // { + // if (strstr(s, "shm-create://")) + // { + // } + // else if (strstr(s, "shm-connect://")) + // { + // } + // if (error_ptr) + // error_ptr->SetErrorStringWithFormat ("unsupported connection + // URL: '%s'", s); + // return eConnectionStatusError; + // } + if (error_ptr) + error_ptr->SetErrorString("invalid connect arguments"); + return eConnectionStatusError; } -ConnectionStatus -ConnectionSharedMemory::Disconnect (Error *error_ptr) -{ - m_mmap.Clear(); - if (!m_name.empty()) - { +ConnectionStatus ConnectionSharedMemory::Disconnect(Error *error_ptr) { + m_mmap.Clear(); + if (!m_name.empty()) { #ifdef _WIN32 - close(m_fd); - m_fd = -1; + close(m_fd); + m_fd = -1; #else - shm_unlink (m_name.c_str()); + shm_unlink(m_name.c_str()); #endif - m_name.clear(); - } - return eConnectionStatusSuccess; + m_name.clear(); + } + return eConnectionStatusSuccess; } -size_t -ConnectionSharedMemory::Read (void *dst, - size_t dst_len, - uint32_t timeout_usec, - ConnectionStatus &status, - Error *error_ptr) -{ - status = eConnectionStatusSuccess; - return 0; +size_t ConnectionSharedMemory::Read(void *dst, size_t dst_len, + uint32_t timeout_usec, + ConnectionStatus &status, + Error *error_ptr) { + status = eConnectionStatusSuccess; + return 0; } -size_t -ConnectionSharedMemory::Write (const void *src, size_t src_len, ConnectionStatus &status, Error *error_ptr) -{ - status = eConnectionStatusSuccess; - return 0; +size_t ConnectionSharedMemory::Write(const void *src, size_t src_len, + ConnectionStatus &status, + Error *error_ptr) { + status = eConnectionStatusSuccess; + return 0; } -std::string -ConnectionSharedMemory::GetURI() -{ - // TODO: fix when Connect is fixed? - return ""; +std::string ConnectionSharedMemory::GetURI() { + // TODO: fix when Connect is fixed? + return ""; } -ConnectionStatus -ConnectionSharedMemory::BytesAvailable (uint32_t timeout_usec, Error *error_ptr) -{ - return eConnectionStatusLostConnection; +ConnectionStatus ConnectionSharedMemory::BytesAvailable(uint32_t timeout_usec, + Error *error_ptr) { + return eConnectionStatusLostConnection; } -ConnectionStatus -ConnectionSharedMemory::Open (bool create, const char *name, size_t size, Error *error_ptr) -{ - if (m_fd != -1) - { - if (error_ptr) - error_ptr->SetErrorString("already open"); - return eConnectionStatusError; - } - - m_name.assign (name); +ConnectionStatus ConnectionSharedMemory::Open(bool create, const char *name, + size_t size, Error *error_ptr) { + if (m_fd != -1) { + if (error_ptr) + error_ptr->SetErrorString("already open"); + return eConnectionStatusError; + } + + m_name.assign(name); #ifdef _WIN32 - HANDLE handle = INVALID_HANDLE_VALUE; - std::wstring wname; - if (llvm::ConvertUTF8toWide(name, wname)) - { - if (create) - { - handle = CreateFileMappingW(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, llvm::Hi_32(size), - llvm::Lo_32(size), wname.c_str()); - } - else - handle = OpenFileMappingW(FILE_MAP_ALL_ACCESS, FALSE, wname.c_str()); - } - - m_fd = _open_osfhandle((intptr_t)handle, 0); + HANDLE handle = INVALID_HANDLE_VALUE; + std::wstring wname; + if (llvm::ConvertUTF8toWide(name, wname)) { + if (create) { + handle = CreateFileMappingW(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, + llvm::Hi_32(size), llvm::Lo_32(size), + wname.c_str()); + } else + handle = OpenFileMappingW(FILE_MAP_ALL_ACCESS, FALSE, wname.c_str()); + } + + m_fd = _open_osfhandle((intptr_t)handle, 0); #else - int oflag = O_RDWR; - if (create) - oflag |= O_CREAT; - m_fd = ::shm_open (m_name.c_str(), oflag, S_IRUSR|S_IWUSR); + int oflag = O_RDWR; + if (create) + oflag |= O_CREAT; + m_fd = ::shm_open(m_name.c_str(), oflag, S_IRUSR | S_IWUSR); - if (create) - ::ftruncate (m_fd, size); + if (create) + ::ftruncate(m_fd, size); #endif - if (m_mmap.MemoryMapFromFileDescriptor(m_fd, 0, size, true, false) == size) - return eConnectionStatusSuccess; + if (m_mmap.MemoryMapFromFileDescriptor(m_fd, 0, size, true, false) == size) + return eConnectionStatusSuccess; - Disconnect(nullptr); - return eConnectionStatusError; + Disconnect(nullptr); + return eConnectionStatusError; } #endif // __ANDROID_NDK__ |