Skip to content

Commit

Permalink
[lldb][test] Add FindGlobalVariables tests for C++ inline static data…
Browse files Browse the repository at this point in the history
… members (#70641)

Tests that LLDB can find inline static data members.

Relies on the debug-info change in:
llvm/llvm-project#70639
  • Loading branch information
Michael137 authored and zahiraam committed Nov 20, 2023
1 parent 802a630 commit 6600888
Showing 1 changed file with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,39 @@ def test_class_with_only_const_static(self):

self.expect_expr("ClassWithOnlyConstStatic::member", result_value="3")

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)
varobj = var_list[0]
self.assertEqual(varobj.type.name, expect_type)
self.assertEqual(varobj.value, expect_val)

# For debug-info produced by older versions of clang, inline static data members
# wouldn't get indexed into the Names accelerator table preventing LLDB from finding
# them.
@expectedFailureAll(compiler=["clang"], compiler_version=["<", "18.0"])
@expectedFailureAll(debug_info=no_match(["dsym"]))
def test_inline_static_members(self):
self.build()
lldbutil.run_to_source_breakpoint(
self, "// break here", lldb.SBFileSpec("main.cpp")
)

self.check_global_var("A::int_val", "const int", "1")
self.check_global_var("A::int_val_with_address", "const int", "2")
self.check_global_var("A::bool_val", "const bool", "true")
self.check_global_var("A::enum_val", "Enum", "enum_case2")
self.check_global_var("A::enum_bool_val", "EnumBool", "enum_bool_case1")
self.check_global_var("A::scoped_enum_val", "ScopedEnum", "scoped_enum_case2")

self.check_global_var("ClassWithOnlyConstStatic::member", "const int", "3")

self.check_global_var("ClassWithConstexprs::member", "const int", "2")
self.check_global_var("ClassWithConstexprs::enum_val", "Enum", "enum_case2")
self.check_global_var(
"ClassWithConstexprs::scoped_enum_val", "ScopedEnum", "scoped_enum_case2"
)

# With older versions of Clang, LLDB fails to evaluate classes with only
# constexpr members when dsymutil is enabled
@expectedFailureAll(
Expand Down

0 comments on commit 6600888

Please sign in to comment.