Author: petr.pavlu
Date: Wed Oct 11 01:48:18 2017
New Revision: 315444
URL: http://llvm.org/viewvc/llvm-project?rev=315444&view=rev
Log:
Fix dumping of characters with non-standard sizes
* Prevent dumping of characters in DumpDataExtractor() with
item_byte_size bigger than 8 bytes. This case is not supported by the
code and results in a crash because the code calls
DataExtractor::GetMaxU64Bitfield() -> GetMaxU64() that asserts for
byte size > 8 bytes.
* Teach DataExtractor::GetMaxU64(), GetMaxU32(), GetMaxS64() and
GetMaxU64_unchecked() how to handle byte sizes that are not a multiple
of 2. This allows DumpDataExtractor() to dump characters and booleans
with item_byte_size in the interval of [1, 8] bytes. Values that are
not a multiple of 2 would previously result in a crash because they
were not handled by GetMaxU64().
Modified:
lldb/trunk/include/lldb/Utility/DataExtractor.h
lldb/trunk/source/Core/DumpDataExtractor.cpp
lldb/trunk/source/Utility/DataExtractor.cpp
lldb/trunk/unittests/Core/DataExtractorTest.cpp
Modified: lldb/trunk/include/lldb/Utility/DataExtractor.h
URL:
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/DataExtractor.h?rev=315444&r1=315443&r2=315444&view=diff
==
--- lldb/trunk/include/lldb/Utility/DataExtractor.h (original)
+++ lldb/trunk/include/lldb/Utility/DataExtractor.h Wed Oct 11 01:48:18 2017
@@ -513,10 +513,8 @@ public:
///
/// Extract a single integer value and update the offset pointed to
/// by \a offset_ptr. The size of the extracted integer is specified
- /// by the \a byte_size argument. \a byte_size should have a value
- /// >= 1 and <= 4 since the return value is only 32 bits wide. Any
- /// \a byte_size values less than 1 or greater than 4 will result in
- /// nothing being extracted, and zero being returned.
+ /// by the \a byte_size argument. \a byte_size must have a value
+ /// >= 1 and <= 4 since the return value is only 32 bits wide.
///
/// @param[in,out] offset_ptr
/// A pointer to an offset within the data that will be advanced
@@ -539,11 +537,9 @@ public:
///
/// Extract a single unsigned integer value and update the offset
/// pointed to by \a offset_ptr. The size of the extracted integer
- /// is specified by the \a byte_size argument. \a byte_size should
+ /// is specified by the \a byte_size argument. \a byte_size must
/// have a value greater than or equal to one and less than or equal
- /// to eight since the return value is 64 bits wide. Any
- /// \a byte_size values less than 1 or greater than 8 will result in
- /// nothing being extracted, and zero being returned.
+ /// to eight since the return value is 64 bits wide.
///
/// @param[in,out] offset_ptr
/// A pointer to an offset within the data that will be advanced
@@ -570,10 +566,9 @@ public:
/// Extract a single signed integer value (sign extending if required)
/// and update the offset pointed to by \a offset_ptr. The size of
/// the extracted integer is specified by the \a byte_size argument.
- /// \a byte_size should have a value greater than or equal to one
- /// and less than or equal to eight since the return value is 64
- /// bits wide. Any \a byte_size values less than 1 or greater than
- /// 8 will result in nothing being extracted, and zero being returned.
+ /// \a byte_size must have a value greater than or equal to one and
+ /// less than or equal to eight since the return value is 64 bits
+ /// wide.
///
/// @param[in,out] offset_ptr
/// A pointer to an offset within the data that will be advanced
@@ -589,7 +584,7 @@ public:
/// The sign extended signed integer value that was extracted,
/// or zero on failure.
//--
- int64_t GetMaxS64(lldb::offset_t *offset_ptr, size_t size) const;
+ int64_t GetMaxS64(lldb::offset_t *offset_ptr, size_t byte_size) const;
//--
/// Extract an unsigned integer of size \a byte_size from \a
@@ -598,11 +593,9 @@ public:
///
/// Extract a single unsigned integer value and update the offset
/// pointed to by \a offset_ptr. The size of the extracted integer
- /// is specified by the \a byte_size argument. \a byte_size should
+ /// is specified by the \a byte_size argument. \a byte_size must
/// have a value greater than or equal to one and less than or equal
- /// to 8 since the return value is 64 bits wide. Any
- /// \a byte_size values less than 1 or greater than 8 will result in
- /// nothing being extracted, and zero being returned.
+ /// to 8 since the return value is 64 bits wide.
///
/// @param[in,out] offset_ptr
/// A pointer to an offset within the data that will be advanced
@@ -641,10 +634,9 @@ public:
/// Extract a single signed integer value (sign ext