[Lldb-commits] [PATCH] D22755: Fix DataExtractor::PeekData for zero length peeks
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Tue Jul 26 01:19:36 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL276734: Fix DataExtractor::PeekData for zero length peeks (authored by labath).
Changed prior to commit:
https://reviews.llvm.org/D22755?vs=65339&id=65478#toc
Repository:
rL LLVM
https://reviews.llvm.org/D22755
Files:
lldb/trunk/include/lldb/Core/DataExtractor.h
lldb/trunk/unittests/Core/DataExtractorTest.cpp
Index: lldb/trunk/unittests/Core/DataExtractorTest.cpp
===================================================================
--- lldb/trunk/unittests/Core/DataExtractorTest.cpp
+++ lldb/trunk/unittests/Core/DataExtractorTest.cpp
@@ -21,7 +21,7 @@
TEST(DataExtractorTest, GetBitfield)
{
- char buffer[] = { 0x01, 0x23, 0x45, 0x67 };
+ uint8_t buffer[] = { 0x01, 0x23, 0x45, 0x67 };
DataExtractor LE(buffer, sizeof(buffer), lldb::eByteOrderLittle, sizeof(void *));
DataExtractor BE(buffer, sizeof(buffer), lldb::eByteOrderBig, sizeof(void *));
@@ -33,7 +33,24 @@
ASSERT_EQ(buffer[1], BE.GetMaxU64Bitfield(&offset, sizeof(buffer), 8, 8));
offset = 0;
- ASSERT_EQ(buffer[1], LE.GetMaxS64Bitfield(&offset, sizeof(buffer), 8, 8));
+ ASSERT_EQ(int8_t(buffer[1]), LE.GetMaxS64Bitfield(&offset, sizeof(buffer), 8, 8));
offset = 0;
- ASSERT_EQ(buffer[1], BE.GetMaxS64Bitfield(&offset, sizeof(buffer), 8, 8));
+ ASSERT_EQ(int8_t(buffer[1]), BE.GetMaxS64Bitfield(&offset, sizeof(buffer), 8, 8));
+}
+
+TEST(DataExtractorTest, PeekData)
+{
+ uint8_t buffer[] = { 0x01, 0x02, 0x03, 0x04 };
+ DataExtractor E(buffer, sizeof buffer, lldb::eByteOrderLittle, 4);
+
+ EXPECT_EQ(buffer + 0, E.PeekData(0, 0));
+ EXPECT_EQ(buffer + 0, E.PeekData(0, 4));
+ EXPECT_EQ(nullptr, E.PeekData(0, 5));
+
+ EXPECT_EQ(buffer + 2, E.PeekData(2, 0));
+ EXPECT_EQ(buffer + 2, E.PeekData(2, 2));
+ EXPECT_EQ(nullptr, E.PeekData(2, 3));
+
+ EXPECT_EQ(buffer + 4, E.PeekData(4, 0));
+ EXPECT_EQ(nullptr, E.PeekData(4, 1));
}
Index: lldb/trunk/include/lldb/Core/DataExtractor.h
===================================================================
--- lldb/trunk/include/lldb/Core/DataExtractor.h
+++ lldb/trunk/include/lldb/Core/DataExtractor.h
@@ -1139,7 +1139,7 @@
const uint8_t*
PeekData (lldb::offset_t offset, lldb::offset_t length) const
{
- if (length > 0 && ValidOffsetForDataOfSize(offset, length))
+ if (ValidOffsetForDataOfSize(offset, length))
return m_start + offset;
return nullptr;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22755.65478.patch
Type: text/x-patch
Size: 2096 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160726/1901d70f/attachment-0001.bin>
More information about the lldb-commits
mailing list