diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp index 822d286cd6c3c..f48bdc730d916 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp @@ -526,7 +526,10 @@ ClangExpressionParser::ClangExpressionParser( [[fallthrough]]; case lldb::eLanguageTypeC_plus_plus_03: lang_opts.CPlusPlus = true; - if (process_sp) + if (process_sp + // We're stopped in a frame without debug-info. The user probably + // intends to make global queries (which should include Objective-C). + && !(frame_sp && frame_sp->HasDebugInformation())) lang_opts.ObjC = process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC) != nullptr; break; diff --git a/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py b/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py index d64e9897a844f..ddc1c3598480c 100644 --- a/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py +++ b/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py @@ -172,7 +172,7 @@ def test_source_locations_from_objc_modules(self): # Import foundation so that the Obj-C module is loaded (which contains source locations # that can be used by LLDB). - self.runCmd("expr @import Foundation") + self.runCmd("expr --language objective-c++ -- @import Foundation") value = frame.EvaluateExpression("NSLog(1);") self.assertFalse(value.GetError().Success()) # LLDB should print the source line that defines NSLog. To not rely on any diff --git a/lldb/test/API/commands/expression/options/TestExprOptions.py b/lldb/test/API/commands/expression/options/TestExprOptions.py index 6652c71083a95..01899f3b97cf4 100644 --- a/lldb/test/API/commands/expression/options/TestExprOptions.py +++ b/lldb/test/API/commands/expression/options/TestExprOptions.py @@ -59,7 +59,6 @@ def test_expr_options(self): self.assertTrue(val.IsValid()) self.assertFalse(val.GetError().Success()) - @skipIfDarwin def test_expr_options_lang(self): """These expression language options should work as expected.""" self.build() diff --git a/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py b/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py index 1eb7205f1bb46..611c738899905 100644 --- a/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py +++ b/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py @@ -51,7 +51,4 @@ def test_with_python_api(self): "expr --language Objective-C++ -- id my_id = 0; my_id", patterns=["\(id\) \$.* = nil"], ) - self.expect( - "expr --language C++ -- id my_id = 0; my_id", - patterns=["\(id\) \$.* = nullptr"], - ) + self.expect("expr --language C++ -- id my_id = 0; my_id", error=True) diff --git a/lldb/test/API/lang/objcxx/objc-from-cpp-frames-without-debuginfo/Makefile b/lldb/test/API/lang/objcxx/objc-from-cpp-frames-without-debuginfo/Makefile new file mode 100644 index 0000000000000..7c3c32d6f82df --- /dev/null +++ b/lldb/test/API/lang/objcxx/objc-from-cpp-frames-without-debuginfo/Makefile @@ -0,0 +1,4 @@ +CXX_SOURCES := main.cpp +CXXFLAGS_EXTRAS := -g0 + +include Makefile.rules diff --git a/lldb/test/API/lang/objcxx/objc-from-cpp-frames-without-debuginfo/TestObjCFromCppFramesWithoutDebugInfo.py b/lldb/test/API/lang/objcxx/objc-from-cpp-frames-without-debuginfo/TestObjCFromCppFramesWithoutDebugInfo.py new file mode 100644 index 0000000000000..ef8d5540fa4ef --- /dev/null +++ b/lldb/test/API/lang/objcxx/objc-from-cpp-frames-without-debuginfo/TestObjCFromCppFramesWithoutDebugInfo.py @@ -0,0 +1,18 @@ +""" +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) + self.expect("expr id", error=False) diff --git a/lldb/test/API/lang/objcxx/objc-from-cpp-frames-without-debuginfo/main.cpp b/lldb/test/API/lang/objcxx/objc-from-cpp-frames-without-debuginfo/main.cpp new file mode 100644 index 0000000000000..76e8197013aab --- /dev/null +++ b/lldb/test/API/lang/objcxx/objc-from-cpp-frames-without-debuginfo/main.cpp @@ -0,0 +1 @@ +int main() { return 0; }