Files
clang-p2996/lldb/test/API/lang/objc/conflicting-class-list-function-from-user/TestObjCClassListFunctionFromUser.py
Raphael Isemann 57bf5c8659 [lldb] Add a test for user-defined objc_copyRealizedClassList_nolock
LLDB evaluates some utility expression to update the Objective-C class list that
ends up calling function such as `free` or `objc_copyRealizedClassList_nolock`.
This adds a test that just tries to define our own bogus version of
`objc_copyRealizedClassList_nolock`. It just tests that LLDB doesn't crash as we
currently don't have a way to tell LLDB to look for the function in a specific
library.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D107778
2021-08-10 14:54:42 +02:00

31 lines
1.0 KiB
Python

import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
class TestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
@skipUnlessDarwin
# LLDB ends up calling the user-defined function (but at least doesn't
# crash).
@expectedFailureDarwin
def test(self):
"""
Tests LLDB's behaviour if the user defines their own conflicting
objc_copyRealizedClassList_nolock function.
"""
self.build()
lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.m"))
# Get the (dynamic) type of our 'id' variable so that our Objective-C
# runtime information is updated.
str_val = self.expect_expr("custom_class")
dyn_val = str_val.GetDynamicValue(lldb.eDynamicCanRunTarget)
# We should have retrieved the proper class list even in presence of
# the user-defined function.
self.assertEqual(dyn_val.GetTypeName(), "CustomClass *")