Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lldb][test] TestConstStaticIntegralMember: relax assertion on number of global variables #73707

Merged

Conversation

Michael137
Copy link
Member

@Michael137 Michael137 commented Nov 28, 2023

In #73626 we started attaching DW_AT_const_values on a static data-member's declaration again. In DWARFv5, those static members are represented with a DW_TAG_variable. When LLDB builds the ManualDWARFIndex, it simply iterates over all DIEs in a CU and puts any DW_TAG_variable with a constant or location into the index. So when using the manual index, we can end up having 2 entries for a static data member in the index, one for the declaration and one for the definition.

This caused a test failure on Linux (where DWARFv5 is the default and the tests use the manual index).

This patch loosens the restriction that we find exactly 1 variable.

… of global variables

In llvm#73626 we started attaching `DW_AT_const_value`s on a static data-member's declaration again. In DWARFv5, those static members are represented with a `DW_TAG_variable`. When LLDB builds the `ManualDWARFIndex`, it simply iterates over all DIEs in a CU and puts *any* `DW_TAG_variable` with a constant or location into the index. So when using the manual index, we can end up having 2 entries for a static data member in the index.

This caused a test failure on Linux (where DWARFv5 is the default and the tests use the manual index).

This patch loosens the restriction that we find exactly 1 variable.
@llvmbot
Copy link
Member

llvmbot commented Nov 28, 2023

@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)

Changes

In #73626 we started attaching DW_AT_const_values on a static data-member's declaration again. In DWARFv5, those static members are represented with a DW_TAG_variable. When LLDB builds the ManualDWARFIndex, it simply iterates over all DIEs in a CU and puts any DW_TAG_variable with a constant or location into the index. So when using the manual index, we can end up having 2 entries for a static data member in the index.

This caused a test failure on Linux (where DWARFv5 is the default and the tests use the manual index).

This patch loosens the restriction that we find exactly 1 variable.


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

1 Files Affected:

  • (modified) lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py (+1-1)
diff --git a/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py b/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
index 2e078ce9446b01a..e63a26f543cc429 100644
--- a/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
+++ b/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
@@ -118,7 +118,7 @@ def test_class_with_only_const_static(self):
 
     def check_global_var(self, name: str, expect_type, expect_val):
         var_list = self.target().FindGlobalVariables(name, lldb.UINT32_MAX)
-        self.assertEqual(len(var_list), 1)
+        self.assertGreaterEqual(len(var_list), 1)
         varobj = var_list[0]
         self.assertEqual(varobj.type.name, expect_type)
         self.assertEqual(varobj.value, expect_val)

Copy link
Contributor

@felipepiovezan felipepiovezan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is only a test change and since it is blocking linux bots, I will go ahead and also merge this for Michael, given the timezone differences.

@felipepiovezan felipepiovezan merged commit 4eb4211 into llvm:main Nov 29, 2023
4 checks passed
@DavidSpickett
Copy link
Collaborator

lldb Arm Linux bots all green now, thanks for fixing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants