diff options
author | Zachary Turner <zturner@google.com> | 2014-07-02 17:24:07 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2014-07-02 17:24:07 +0000 |
commit | a746e8e58a460f6667cc9e16eb94d256ea4b0121 (patch) | |
tree | 39bdccf355cbc36ce7820f8831fc39639e0b694b /lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp | |
parent | 379b97f2856afebc4fbdfb8bdde2251c046a10a3 (diff) | |
download | llvm-a746e8e58a460f6667cc9e16eb94d256ea4b0121.zip llvm-a746e8e58a460f6667cc9e16eb94d256ea4b0121.tar.gz llvm-a746e8e58a460f6667cc9e16eb94d256ea4b0121.tar.bz2 |
Start converting usages of off_t to other types.
off_t is a type which is used for file offsets. Even more
specifically, it is only used by a limited number of C APIs that
deal with files. Any usage of off_t where the variable is not
intended to be used with one of these APIs is a bug, by definition.
This patch corrects some easy mis-uses of off_t, generally by
converting them to lldb::offset_t, but sometimes by using other
types such as size_t, when appropriate.
The use of off_t to represent these offsets has worked fine in
practice on linux-y platforms, since we used _FILE_OFFSET_64 to
guarantee that off_t was a uint64. On Windows, however,
_FILE_OFFSET_64 is unrecognized, and off_t will always be 32-bit.
So the usage of off_t on Windows actually leads to legitimate bugs.
Reviewed by: Greg Clayton
Differential Revision: http://reviews.llvm.org/D4358
llvm-svn: 212192
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp')
-rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp index 583f49c..1eed9ef 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp @@ -680,32 +680,32 @@ GDBRemoteRegisterContext::WriteAllRegisterValues (const lldb::DataBufferSP &data // If the slice registers are not included, then using the byte_offset values into the // data buffer is the best way to find individual register values. - int size_including_slice_registers = 0; - int size_not_including_slice_registers = 0; - int size_by_highest_offset = 0; + uint64_t size_including_slice_registers = 0; + uint64_t size_not_including_slice_registers = 0; + uint64_t size_by_highest_offset = 0; for (uint32_t reg_idx=0; (reg_info = GetRegisterInfoAtIndex (reg_idx)) != NULL; ++reg_idx) { size_including_slice_registers += reg_info->byte_size; if (reg_info->value_regs == NULL) size_not_including_slice_registers += reg_info->byte_size; - if (static_cast<off_t>(reg_info->byte_offset) >= size_by_highest_offset) + if (reg_info->byte_offset >= size_by_highest_offset) size_by_highest_offset = reg_info->byte_offset + reg_info->byte_size; } bool use_byte_offset_into_buffer; - if (static_cast<size_t>(size_by_highest_offset) == restore_data.GetByteSize()) + if (size_by_highest_offset == restore_data.GetByteSize()) { // The size of the packet agrees with the highest offset: + size in the register file use_byte_offset_into_buffer = true; } - else if (static_cast<size_t>(size_not_including_slice_registers) == restore_data.GetByteSize()) + else if (size_not_including_slice_registers == restore_data.GetByteSize()) { // The size of the packet is the same as concatenating all of the registers sequentially, // skipping the slice registers use_byte_offset_into_buffer = true; } - else if (static_cast<size_t>(size_including_slice_registers) == restore_data.GetByteSize()) + else if (size_including_slice_registers == restore_data.GetByteSize()) { // The slice registers are present in the packet (when they shouldn't be). // Don't try to use the RegisterInfo byte_offset into the restore_data, it will |