[Lldb-commits] [PATCH] D88992: [lldb] Fix "frame var" for large bitfields

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Oct 8 09:43:08 PDT 2020


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG19d64138e6a7: [lldb] Fix "frame var" for large bitfields (authored by labath).

Changed prior to commit:
  https://reviews.llvm.org/D88992?vs=296749&id=296998#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88992

Files:
  lldb/source/Core/ValueObjectChild.cpp
  lldb/test/API/lang/c/bitfields/TestBitfields.py


Index: lldb/test/API/lang/c/bitfields/TestBitfields.py
===================================================================
--- lldb/test/API/lang/c/bitfields/TestBitfields.py
+++ lldb/test/API/lang/c/bitfields/TestBitfields.py
@@ -147,6 +147,27 @@
         self.expect("v/x large_packed", VARIABLES_DISPLAYED_CORRECTLY,
                     substrs=["a = 0x0000000cbbbbaaaa", "b = 0x0000000dffffeee"])
 
+    # BitFields exhibit crashes in record layout on Windows
+    # (http://llvm.org/pr21800)
+    @skipIfWindows
+    def test_expression_bug(self):
+        # Ensure evaluating (emulating) an expression does not break bitfield
+        # values for already parsed variables. The expression is run twice
+        # because the very first expression can resume a target (to allocate
+        # memory, etc.) even if it is not being jitted.
+        self.build()
+        lldbutil.run_to_line_breakpoint(self, lldb.SBFileSpec("main.c"),
+                self.line)
+        self.expect("v/x large_packed", VARIABLES_DISPLAYED_CORRECTLY,
+                    substrs=["a = 0x0000000cbbbbaaaa", "b = 0x0000000dffffeee"])
+        self.expect("expr --allow-jit false  -- more_bits.a", VARIABLES_DISPLAYED_CORRECTLY,
+                    substrs=['uint32_t', '3'])
+        self.expect("v/x large_packed", VARIABLES_DISPLAYED_CORRECTLY,
+                    substrs=["a = 0x0000000cbbbbaaaa", "b = 0x0000000dffffeee"])
+        self.expect("expr --allow-jit false  -- more_bits.a", VARIABLES_DISPLAYED_CORRECTLY,
+                    substrs=['uint32_t', '3'])
+        self.expect("v/x large_packed", VARIABLES_DISPLAYED_CORRECTLY,
+                    substrs=["a = 0x0000000cbbbbaaaa", "b = 0x0000000dffffeee"])
 
     @add_test_categories(['pyapi'])
     # BitFields exhibit crashes in record layout on Windows
Index: lldb/source/Core/ValueObjectChild.cpp
===================================================================
--- lldb/source/Core/ValueObjectChild.cpp
+++ lldb/source/Core/ValueObjectChild.cpp
@@ -165,10 +165,6 @@
           } else if (addr == 0) {
             m_error.SetErrorString("parent is NULL");
           } else {
-            // Set this object's scalar value to the address of its value by
-            // adding its byte offset to the parent address
-            m_value.GetScalar() += GetByteOffset();
-
             // If a bitfield doesn't fit into the child_byte_size'd
             // window at child_byte_offset, move the window forward
             // until it fits.  The problem here is that Value has no
@@ -187,11 +183,15 @@
                 if (bitfield_end > *type_bit_size) {
                   uint64_t overhang_bytes =
                       (bitfield_end - *type_bit_size + 7) / 8;
-                  m_value.GetScalar() += overhang_bytes;
+                  m_byte_offset += overhang_bytes;
                   m_bitfield_bit_offset -= overhang_bytes * 8;
                 }
               }
             }
+
+            // Set this object's scalar value to the address of its value by
+            // adding its byte offset to the parent address
+            m_value.GetScalar() += m_byte_offset;
           }
         } break;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88992.296998.patch
Type: text/x-patch
Size: 3179 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20201008/05dac3e7/attachment.bin>


More information about the lldb-commits mailing list