[Lldb-commits] [lldb] 77cedb0 - [lldb] Fix nondeterminism in TestCppBitfields

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Fri Jan 24 03:16:21 PST 2020


Author: Pavel Labath
Date: 2020-01-24T12:09:20+01:00
New Revision: 77cedb0cdb8623ff9eb22dbf3b9302ee4d9f8a20

URL: https://github.com/llvm/llvm-project/commit/77cedb0cdb8623ff9eb22dbf3b9302ee4d9f8a20
DIFF: https://github.com/llvm/llvm-project/commit/77cedb0cdb8623ff9eb22dbf3b9302ee4d9f8a20.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.

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 lldb-commits mailing list