[llvm-branch-commits] [lldb] 54b022d - [lldb] Fix nondeterminism in TestCppBitfields

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Jan 28 05:25:16 PST 2020


Author: Pavel Labath
Date: 2020-01-28T14:24:36+01:00
New Revision: 54b022d344412fc9f1dfe37ee05de934a01e1ea4

URL: https://github.com/llvm/llvm-project/commit/54b022d344412fc9f1dfe37ee05de934a01e1ea4
DIFF: https://github.com/llvm/llvm-project/commit/54b022d344412fc9f1dfe37ee05de934a01e1ea4.diff

LOG: [lldb] Fix nondeterminism in TestCppBitfields

The test was printing a char[3] variable without a terminating nul. The
memory after that variable (an unnamed bitfield) was not initialized. If
the memory happened to be nonzero, the summary provider for the variable
would run off into the next field.

This is probably not the right behavior (it should stop at the end of
the array), but this is not the purpose of this test. I have filed
pr44649 for this bug, and fixed the test to not depend on this behavior.

(cherry picked from commit 77cedb0cdb8623ff9eb22dbf3b9302ee4d9f8a20)

Added: 
    

Modified: 
    lldb/packages/Python/lldbsuite/test/lang/cpp/bitfields/TestCppBitfields.py
    lldb/packages/Python/lldbsuite/test/lang/cpp/bitfields/main.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/bitfields/TestCppBitfields.py b/lldb/packages/Python/lldbsuite/test/lang/cpp/bitfields/TestCppBitfields.py
index 696e5647f13f..1b362e6b04f9 100644
--- a/lldb/packages/Python/lldbsuite/test/lang/cpp/bitfields/TestCppBitfields.py
+++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/bitfields/TestCppBitfields.py
@@ -80,7 +80,7 @@ def test_and_run_command(self):
             "frame variable --show-types lbd",
             VARIABLES_DISPLAYED_CORRECTLY,
             substrs=[
-                '(char [3]) arr = "abc"',
+                '(char [3]) arr = "ab"',
                 '(int:32)  =',
                 '(unsigned int:20) a = 5',
                 ])

diff  --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/bitfields/main.cpp b/lldb/packages/Python/lldbsuite/test/lang/cpp/bitfields/main.cpp
index 975c0f05683c..e43bf8c138e9 100644
--- a/lldb/packages/Python/lldbsuite/test/lang/cpp/bitfields/main.cpp
+++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/bitfields/main.cpp
@@ -73,7 +73,7 @@ int main(int argc, char const *argv[]) {
 
   lbd.arr[0] = 'a';
   lbd.arr[1] = 'b';
-  lbd.arr[2] = 'c';
+  lbd.arr[2] = '\0';
   lbd.a = 5;
 
 


        


More information about the llvm-branch-commits mailing list