aboutsummaryrefslogtreecommitdiff
path: root/lldb/test/API/python_api
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/test/API/python_api')
-rw-r--r--lldb/test/API/python_api/type/TestTypeList.py33
-rw-r--r--lldb/test/API/python_api/type/main.cpp3
2 files changed, 36 insertions, 0 deletions
diff --git a/lldb/test/API/python_api/type/TestTypeList.py b/lldb/test/API/python_api/type/TestTypeList.py
index c647c2b..81c44f7 100644
--- a/lldb/test/API/python_api/type/TestTypeList.py
+++ b/lldb/test/API/python_api/type/TestTypeList.py
@@ -33,6 +33,32 @@ class TypeAndTypeListTestCase(TestBase):
self.assertTrue(pointer_masks2_type)
self.DebugSBType(pointer_masks2_type)
+ def _find_static_field_in_Task_pointer(self, task_pointer):
+ self.assertTrue(task_pointer)
+ self.DebugSBType(task_pointer)
+
+ task_type = task_pointer.GetPointeeType()
+ self.assertTrue(task_type)
+ self.DebugSBType(task_type)
+
+ static_constexpr_field = task_type.GetStaticFieldWithName(
+ "static_constexpr_field"
+ )
+ self.assertTrue(static_constexpr_field)
+ self.assertEqual(static_constexpr_field.GetName(), "static_constexpr_field")
+ self.assertEqual(static_constexpr_field.GetType().GetName(), "const long")
+
+ value = static_constexpr_field.GetConstantValue(self.target())
+ self.DebugSBValue(value)
+ self.assertEqual(value.GetValueAsSigned(), 47)
+
+ static_mutable_field = task_type.GetStaticFieldWithName("static_mutable_field")
+ self.assertTrue(static_mutable_field)
+ self.assertEqual(static_mutable_field.GetName(), "static_mutable_field")
+ self.assertEqual(static_mutable_field.GetType().GetName(), "int")
+
+ self.assertFalse(static_mutable_field.GetConstantValue(self.target()))
+
@skipIf(compiler="clang", compiler_version=["<", "17.0"])
def test(self):
"""Exercise SBType and SBTypeList API."""
@@ -175,6 +201,13 @@ class TypeAndTypeListTestCase(TestBase):
frame0.EvaluateExpression("pointer").GetType()
)
+ self._find_static_field_in_Task_pointer(
+ frame0.FindVariable("task_head").GetType()
+ )
+ self._find_static_field_in_Task_pointer(
+ frame0.EvaluateExpression("task_head").GetType()
+ )
+
# We'll now get the child member 'id' from 'task_head'.
id = task_head.GetChildMemberWithName("id")
self.DebugSBValue(id)
diff --git a/lldb/test/API/python_api/type/main.cpp b/lldb/test/API/python_api/type/main.cpp
index 391f58e..c86644d 100644
--- a/lldb/test/API/python_api/type/main.cpp
+++ b/lldb/test/API/python_api/type/main.cpp
@@ -27,12 +27,15 @@ public:
enum E : unsigned char {} e;
union U {
} u;
+ static constexpr long static_constexpr_field = 47;
+ static int static_mutable_field;
Task(int i, Task *n):
id(i),
next(n),
type(TASK_TYPE_1)
{}
};
+int Task::static_mutable_field = 42;
template <unsigned Value> struct PointerInfo {
enum Masks1 { pointer_mask };