Files
clang-p2996/lldb/test/API/lang/objcxx/objc-from-cpp-frames-without-debuginfo/TestObjCFromCppFramesWithoutDebugInfo.py
Michael Buch 9e6ea387c8 Reland "[lldb][ObjC] Don't query objective-c runtime for decls in C++ contexts"
This relands https://github.com/llvm/llvm-project/pull/95963. It had to
be reverted because the `TestEarlyProcessLaunch.py` test was failing
on the incremental macOS bots. The test failed because it was relying on
expression log output from the ObjC introspection routines (but was
the expression was called from a C++ context). The relanded patch
simply ensures that the test runs the expressions as `ObjC` expressions.

When LLDB isn't able to find a `clang::Decl` in response
to a `FindExternalVisibleDeclsByName`, it will fall-back
to looking into the Objective-C runtime for that decl. This
ends up doing a lot of work which isn't necessary when we're
debugging a C++ program. This patch makes the ObjC lookup
conditional on the language that the ExpressionParser deduced
(which can be explicitly set using the `expr --language` option
or is set implicitly if we're stopped in an ObjC frame or a
C++ frame without debug-info).

rdar://96236519
2024-06-21 20:35:30 +01:00

26 lines
788 B
Python

"""
Test that the the expression parser enables ObjC support
when stopped in a C++ frame without debug-info.
"""
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
class TestObjCFromCppFramesWithoutDebugInfo(TestBase):
def test(self):
self.build()
(_, process, _, _) = lldbutil.run_to_name_breakpoint(self, "main")
self.assertState(process.GetState(), lldb.eStateStopped)
# Tests that we can use builtin Objective-C identifiers.
self.expect("expr id", error=False)
# Tests that we can lookup Objective-C decls in the ObjC runtime plugin.
self.expect_expr(
"NSString *c; c == nullptr", result_value="true", result_type="bool"
)