diff options
| author | Aaron Smith <aaron.smith@microsoft.com> | 2019-02-07 18:46:25 +0000 |
|---|---|---|
| committer | Aaron Smith <aaron.smith@microsoft.com> | 2019-02-07 18:46:25 +0000 |
| commit | 3a14249525235d9d2bcbc0e931759d083bcdb0d1 (patch) | |
| tree | 42fc3fd705c69cbddb24e36ace4dff518d8e6c78 /lldb/source/Host/common/File.cpp | |
| parent | 1e6ba236083687e612d6805bd572e4ba16956c86 (diff) | |
| download | bcm5719-llvm-3a14249525235d9d2bcbc0e931759d083bcdb0d1.tar.gz bcm5719-llvm-3a14249525235d9d2bcbc0e931759d083bcdb0d1.zip | |
[lldb-server] Improve support on Windows
Summary:
This commit contains the following changes:
- Rewrite vfile close/read/write packet handlers with portable routines from lldb.
This removes #if(s) and allows the handlers to work on Windows.
- Fix a bug in File::Write. This is intended to write data at an offset to a file
but actually writes at the current position of the file.
- Add a default boolean argument 'should_close_fd' to FileSystem::Open to
let the user decide whether to close the fd or not.
Reviewers: zturner, llvm-commits, labath
Reviewed By: zturner
Subscribers: Hui, labath, abidh, lldb-commits
Differential Revision: https://reviews.llvm.org/D56231
llvm-svn: 353446
Diffstat (limited to 'lldb/source/Host/common/File.cpp')
| -rw-r--r-- | lldb/source/Host/common/File.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lldb/source/Host/common/File.cpp b/lldb/source/Host/common/File.cpp index dba6e08acb3..512e7c58702 100644 --- a/lldb/source/Host/common/File.cpp +++ b/lldb/source/Host/common/File.cpp @@ -178,7 +178,7 @@ Status File::Close() { void File::Clear() { m_stream = nullptr; - m_descriptor = -1; + m_descriptor = kInvalidDescriptor; m_options = 0; m_own_stream = false; m_is_interactive = m_supports_colors = m_is_real_terminal = @@ -503,6 +503,7 @@ Status File::Read(void *buf, size_t &num_bytes, off_t &offset) { error.SetErrorString("invalid file handle"); } #else + std::lock_guard<std::mutex> guard(offset_access_mutex); long cur = ::lseek(m_descriptor, 0, SEEK_CUR); SeekFromStart(offset); error = Read(buf, num_bytes); @@ -602,7 +603,9 @@ Status File::Write(const void *buf, size_t &num_bytes, off_t &offset) { num_bytes = bytes_written; } #else + std::lock_guard<std::mutex> guard(offset_access_mutex); long cur = ::lseek(m_descriptor, 0, SEEK_CUR); + SeekFromStart(offset); error = Write(buf, num_bytes); long after = ::lseek(m_descriptor, 0, SEEK_CUR); |

