llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Igor Kudrin (igorkudrin)

<details>
<summary>Changes</summary>

Generic data variables are considered to be of the type `void *&amp;`, see 
`ClangExpressionDeclMap::AddOneGenericVariable()`. On 64-bit platforms (e.g. 
AArch64), this type is 8 bytes long, while the `conflicting_symbol` variables 
are defined as `int`, which is typically 4 bytes. `test_conflicting_symbols` 
could fail if the next 4 bytes in memory after any of the variables are not 
zero. This can be reproduced by adding a variable with a non-zero value after 
`conflicting_symbol`:
```
--- a/lldb/test/API/lang/c/conflicting-symbol/One/OneConstant.c
+++ b/lldb/test/API/lang/c/conflicting-symbol/One/OneConstant.c
@@ -1 +1,2 @@
 int __attribute__ ((visibility("hidden"))) conflicting_symbol = 11111;
+int guard = 1;
```

In this case, the test fails with:
```
AssertionError: Ran command:
"expr (unsigned long long)conflicting_symbol"

Got output:
(unsigned long long) $0 = 4294978407

Expecting sub string: "11111" (was not found)
Symbol from One should be found
```

Note that 4294978407 = 0x100002B67 = 1 * 2^32 + 11111.

---
Full diff: https://github.com/llvm/llvm-project/pull/172792.diff


3 Files Affected:

- (modified) lldb/test/API/lang/c/conflicting-symbol/One/OneConstant.c (+1-1) 
- (modified) lldb/test/API/lang/c/conflicting-symbol/TestConflictingSymbol.py 
(+7-5) 
- (modified) lldb/test/API/lang/c/conflicting-symbol/Two/TwoConstant.c (+1-1) 


``````````diff
diff --git a/lldb/test/API/lang/c/conflicting-symbol/One/OneConstant.c 
b/lldb/test/API/lang/c/conflicting-symbol/One/OneConstant.c
index 8255c2fce995c..37ddd8018afe1 100644
--- a/lldb/test/API/lang/c/conflicting-symbol/One/OneConstant.c
+++ b/lldb/test/API/lang/c/conflicting-symbol/One/OneConstant.c
@@ -1 +1 @@
-int __attribute__ ((visibility("hidden"))) conflicting_symbol = 11111;
+void *__attribute__((visibility("hidden"))) conflicting_symbol = (void 
*)0x1111;
diff --git a/lldb/test/API/lang/c/conflicting-symbol/TestConflictingSymbol.py 
b/lldb/test/API/lang/c/conflicting-symbol/TestConflictingSymbol.py
index 6e29796ed58be..130874c979480 100644
--- a/lldb/test/API/lang/c/conflicting-symbol/TestConflictingSymbol.py
+++ b/lldb/test/API/lang/c/conflicting-symbol/TestConflictingSymbol.py
@@ -52,9 +52,10 @@ def test_conflicting_symbols(self):
 
         # This should display correctly.
         self.expect(
-            "expr (unsigned long long)conflicting_symbol",
+            "expr conflicting_symbol",
             "Symbol from One should be found",
-            substrs=["11111"],
+            startstr="(void *)",
+            patterns=["0x0+1111$"],
         )
 
         self.runCmd("continue", RUN_SUCCEEDED)
@@ -69,9 +70,10 @@ def test_conflicting_symbols(self):
         lldbutil.check_breakpoint(self, bpno=1, expected_hit_count=1)
 
         self.expect(
-            "expr (unsigned long long)conflicting_symbol",
+            "expr conflicting_symbol",
             "Symbol from Two should be found",
-            substrs=["22222"],
+            startstr="(void *)",
+            patterns=["0x0+2222$"],
         )
 
         self.runCmd("continue", RUN_SUCCEEDED)
@@ -86,7 +88,7 @@ def test_conflicting_symbols(self):
         lldbutil.check_breakpoint(self, bpno=1, expected_hit_count=1)
 
         self.expect(
-            "expr (unsigned long long)conflicting_symbol",
+            "expr conflicting_symbol",
             "An error should be printed when symbols can't be ordered",
             error=True,
             substrs=["Multiple internal symbols"],
diff --git a/lldb/test/API/lang/c/conflicting-symbol/Two/TwoConstant.c 
b/lldb/test/API/lang/c/conflicting-symbol/Two/TwoConstant.c
index 9fc7c4b79515f..9efe79c53431d 100644
--- a/lldb/test/API/lang/c/conflicting-symbol/Two/TwoConstant.c
+++ b/lldb/test/API/lang/c/conflicting-symbol/Two/TwoConstant.c
@@ -1 +1 @@
-int __attribute__ ((visibility("hidden"))) conflicting_symbol = 22222;
+void *__attribute__((visibility("hidden"))) conflicting_symbol = (void 
*)0x2222;

``````````

</details>


https://github.com/llvm/llvm-project/pull/172792
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to