[Lldb-commits] [lldb] [lldb][test] TestConstStaticIntegralMember: relax assertion on number of global variables (PR #73707)

Michael Buch via lldb-commits lldb-commits at lists.llvm.org
Tue Nov 28 14:43:46 PST 2023


https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/73707

In https://github.com/llvm/llvm-project/pull/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.

>From cec4d1bb8a26f44ba701eb62596014c71e607fc4 Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Tue, 28 Nov 2023 22:42:10 +0000
Subject: [PATCH] [lldb][test] TestConstStaticIntegralMember: relax assertion
 on number of global variables

In https://github.com/llvm/llvm-project/pull/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.
---
 .../TestConstStaticIntegralMember.py                            | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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)



More information about the lldb-commits mailing list