[Lldb-commits] [PATCH] D25783: [Host] handle short reads and writes

Zachary Turner via lldb-commits lldb-commits at lists.llvm.org
Wed Oct 19 11:49:29 PDT 2016


zturner created this revision.
zturner added reviewers: clayborg, beanz, EugeneBi.
zturner added a subscriber: lldb-commits.

The original motivation for this came from https://reviews.llvm.org/D25712, in which Eugene pointed out that `File::Read()` does not correctly handle short reads.  However, I felt the fix was incomplete because it left the bug in other functions, and the code in general could have used some cleanup since there was a ton of duplication, which may be what led to this bug showing up in the first place.

Changes in this patch are:

1. Have the normal `Read()` and `Write()` functions delegate to the versions that read and write with offset.
2. Supply thread-safe versions of the Windows codepaths, which were previously incorrect in a multi-threaded environment.
3. Delete a bunch of dead functions that are not used anywhere in LLDB.
4. Remove the apple specific path due to `MAX_READ_SIZE` and `MAX_WRITE_SIZE` and merge with the standard non-Windows path.

The only real tricky part about this patch was that when you open a file in append mode, the old version of `Write()` with no offset would write at the end, whereas `pwrite()` always writes at the offset you specify.  So to fix this I made the version of `Write()` with no offset explicitly compute the offset of the end of the file and pass that to the offset-version of `Write()`.


https://reviews.llvm.org/D25783

Files:
  include/lldb/Host/File.h
  source/Host/common/File.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25783.75181.patch
Type: text/x-patch
Size: 14649 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20161019/124e8b9e/attachment-0001.bin>


More information about the lldb-commits mailing list