[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 08:49:11 PDT 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8da5d111a5d2: [lldb] DumpDataExtractor tests for item byte size errors (authored by DavidSpickett).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101631/new/

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.
   TestDump<float>(10, lldb::Format::eFormatHexFloat, "0x1.4p3");
   TestDump<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, see ItemByteSizeErrors.
 
   // Can't disassemble without an execution context.
   TestDump<uint32_t>(0xcafef00d, lldb::Format::eFormatInstruction,
@@ -301,3 +299,46 @@
                     lldb::Format::eFormatBytesWithASCII, 3,
                     expected_chars_2_lines);
 }
+
+void TestDumpWithItemByteSize(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;
+  TestDumpImpl(&dummy, 1, item_byte_size, 1, 1, LLDB_INVALID_ADDRESS, format,
+               expected);
+}
+
+TEST(DumpDataExtractorTest, ItemByteSizeErrors) {
+  TestDumpWithItemByteSize(
+      16, lldb::Format::eFormatBoolean,
+      "error: unsupported byte size (16) for boolean format");
+  TestDumpWithItemByteSize(21, lldb::Format::eFormatChar,
+                           "error: unsupported byte size (21) for char format");
+  TestDumpWithItemByteSize(
+      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.
+  TestDumpWithItemByteSize(
+      34, lldb::Format::eFormatComplex,
+      "error: unsupported byte size (34) for complex float format");
+  TestDumpWithItemByteSize(
+      18, lldb::Format::eFormatFloat,
+      "error: unsupported byte size (18) for float format");
+
+  // We want sizes to exactly match one of float/double.
+  TestDumpWithItemByteSize(
+      14, lldb::Format::eFormatComplex,
+      "error: unsupported byte size (14) for complex float format");
+  TestDumpWithItemByteSize(3, lldb::Format::eFormatFloat,
+                           "error: unsupported byte size (3) for float format");
+
+  // We only allow float and double size.
+  TestDumpWithItemByteSize(
+      1, lldb::Format::eFormatHexFloat,
+      "error: unsupported byte size (1) for hex float format");
+  TestDumpWithItemByteSize(
+      17, lldb::Format::eFormatHexFloat,
+      "error: unsupported byte size (17) for hex float format");
+}


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


More information about the lldb-commits mailing list