Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lldb][ClangExpressionParser] Don't by default enable Objecitve-C support when evaluating C++ expressions #87767

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CXX_SOURCES := main.cpp
CXXFLAGS_EXTRAS := -g0

include Makefile.rules
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
int main() { return 0; }