[Lldb-commits] [PATCH] D101631: [lldb] DumpDataExtractor tests for item byte size errors

David Spickett via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Apr 30 07:22:37 PDT 2021


DavidSpickett created this revision.
DavidSpickett requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101631

Files:
  lldb/unittests/Core/DumpDataExtractorTest.cpp


Index: lldb/unittests/Core/DumpDataExtractorTest.cpp
===================================================================
--- lldb/unittests/Core/DumpDataExtractorTest.cpp
+++ lldb/unittests/Core/DumpDataExtractorTest.cpp
@@ -202,9 +202,7 @@
   // Input not written in hex form because that requires C++17.
   test_dump<float>(10, lldb::Format::eFormatHexFloat, "0x1.4p3");
   test_dump<double>(10, lldb::Format::eFormatHexFloat, "0x1.4p3");
-  // Long double we don't support and format an error saying so.
-  // However sizeof(long double) is 8/12/16 depending on the host so not tested
-  // here.
+  // long double not supported, eee ItemByteSizeErrors.
 
   // Can't disassemble without an execution context.
   test_dump<uint32_t>(0xcafef00d, lldb::Format::eFormatInstruction,
@@ -301,3 +299,48 @@
                       lldb::Format::eFormatBytesWithASCII, 3,
                       expected_chars_2_lines);
 }
+
+void test_dump_with_item_byte_size(size_t item_byte_size, lldb::Format format,
+                                   llvm::StringRef expected) {
+  // We won't be reading this data so anything will do.
+  uint8_t dummy = 0;
+  test_dump_impl(&dummy, 1, item_byte_size, 1, 1, LLDB_INVALID_ADDRESS, format,
+                 expected);
+}
+
+TEST(DumpDataExtractorTest, ItemByteSizeErrors) {
+  test_dump_with_item_byte_size(
+      16, lldb::Format::eFormatBoolean,
+      "error: unsupported byte size (16) for boolean format");
+  test_dump_with_item_byte_size(
+      21, lldb::Format::eFormatChar,
+      "error: unsupported byte size (21) for char format");
+  test_dump_with_item_byte_size(
+      18, lldb::Format::eFormatComplexInteger,
+      "error: unsupported byte size (18) for complex integer format");
+
+  // The code uses sizeof(long double) for these checks. This changes by host
+  // but we know it won't be >16.
+  test_dump_with_item_byte_size(
+      34, lldb::Format::eFormatComplex,
+      "error: unsupported byte size (34) for complex float format");
+  test_dump_with_item_byte_size(
+      18, lldb::Format::eFormatFloat,
+      "error: unsupported byte size (18) for float format");
+
+  // We want sizes to exactly match one of float/double.
+  test_dump_with_item_byte_size(
+      14, lldb::Format::eFormatComplex,
+      "error: unsupported byte size (14) for complex float format");
+  test_dump_with_item_byte_size(
+      3, lldb::Format::eFormatFloat,
+      "error: unsupported byte size (3) for float format");
+
+  // We only allow float and double size.
+  test_dump_with_item_byte_size(
+      1, lldb::Format::eFormatHexFloat,
+      "error: unsupported byte size (1) for hex float format");
+  test_dump_with_item_byte_size(
+      17, lldb::Format::eFormatHexFloat,
+      "error: unsupported byte size (17) for hex float format");
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101631.341895.patch
Type: text/x-patch
Size: 2798 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210430/010cfdf0/attachment.bin>


More information about the lldb-commits mailing list