[Lldb-commits] [lldb] r338591 - Don't ignore byte_order in Stream::PutMaxHex64
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Wed Aug 1 10:12:58 PDT 2018
Author: teemperor
Date: Wed Aug 1 10:12:58 2018
New Revision: 338591
URL: http://llvm.org/viewvc/llvm-project?rev=338591&view=rev
Log:
Don't ignore byte_order in Stream::PutMaxHex64
Reviewers: labath
Reviewed By: labath
Subscribers: zturner, lldb-commits
Differential Revision: https://reviews.llvm.org/D50025
Modified:
lldb/trunk/source/Utility/Stream.cpp
lldb/trunk/unittests/Utility/StreamTest.cpp
Modified: lldb/trunk/source/Utility/Stream.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/Stream.cpp?rev=338591&r1=338590&r2=338591&view=diff
==============================================================================
--- lldb/trunk/source/Utility/Stream.cpp (original)
+++ lldb/trunk/source/Utility/Stream.cpp Wed Aug 1 10:12:58 2018
@@ -427,11 +427,11 @@ size_t Stream::PutMaxHex64(uint64_t uval
case 1:
return PutHex8((uint8_t)uvalue);
case 2:
- return PutHex16((uint16_t)uvalue);
+ return PutHex16((uint16_t)uvalue, byte_order);
case 4:
- return PutHex32((uint32_t)uvalue);
+ return PutHex32((uint32_t)uvalue, byte_order);
case 8:
- return PutHex64(uvalue);
+ return PutHex64(uvalue, byte_order);
}
return 0;
}
Modified: lldb/trunk/unittests/Utility/StreamTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/StreamTest.cpp?rev=338591&r1=338590&r2=338591&view=diff
==============================================================================
--- lldb/trunk/unittests/Utility/StreamTest.cpp (original)
+++ lldb/trunk/unittests/Utility/StreamTest.cpp Wed Aug 1 10:12:58 2018
@@ -187,6 +187,32 @@ TEST_F(StreamTest, PutHex64ByteOrderBig)
EXPECT_EQ("0000000000000000", TakeValue());
}
+TEST_F(StreamTest, PutMaxHex64ByteOrderBig) {
+ std::size_t bytes;
+ bytes = s.PutMaxHex64(0x12U, 1, lldb::eByteOrderBig);
+ EXPECT_EQ(2U, bytes);
+ bytes = s.PutMaxHex64(0x1234U, 2, lldb::eByteOrderBig);
+ EXPECT_EQ(4U, bytes);
+ bytes = s.PutMaxHex64(0x12345678U, 4, lldb::eByteOrderBig);
+ EXPECT_EQ(8U, bytes);
+ bytes = s.PutMaxHex64(0x1234567890ABCDEFU, 8, lldb::eByteOrderBig);
+ EXPECT_EQ(16U, bytes);
+ EXPECT_EQ("121234123456781234567890abcdef", TakeValue());
+}
+
+TEST_F(StreamTest, PutMaxHex64ByteOrderLittle) {
+ std::size_t bytes;
+ bytes = s.PutMaxHex64(0x12U, 1, lldb::eByteOrderLittle);
+ EXPECT_EQ(2U, bytes);
+ bytes = s.PutMaxHex64(0x1234U, 2, lldb::eByteOrderLittle);
+ EXPECT_EQ(4U, bytes);
+ bytes = s.PutMaxHex64(0x12345678U, 4, lldb::eByteOrderLittle);
+ EXPECT_EQ(8U, bytes);
+ bytes = s.PutMaxHex64(0x1234567890ABCDEFU, 8, lldb::eByteOrderLittle);
+ EXPECT_EQ(16U, bytes);
+ EXPECT_EQ("12341278563412efcdab9078563412", TakeValue());
+}
+
//------------------------------------------------------------------------------
// Shift operator tests.
//------------------------------------------------------------------------------
More information about the lldb-commits
mailing list