Skip to content

Commit 15f34ff

Browse files
committed
[lldb] Allow expect_expr without a running target
Summary: If we don't have a current frame then we can still run many expressions as long as we have an active target. With this patch `expect_expr` directly calls the target's EvaluateExpression function when there is no current frame. Reviewers: labath Reviewed By: labath Subscribers: JDevlieghere Differential Revision: https://reviews.llvm.org/D77197
1 parent f9f401d commit 15f34ff

File tree

2 files changed

+6
-17
lines changed

2 files changed

+6
-17
lines changed

lldb/packages/Python/lldbsuite/test/lldbtest.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2414,9 +2414,12 @@ def expect_expr(
24142414

24152415
# Set the usual default options for normal expressions.
24162416
options.SetIgnoreBreakpoints(True)
2417-
options.SetLanguage(frame.GuessLanguage())
24182417

2419-
eval_result = frame.EvaluateExpression(expr, options)
2418+
if self.frame().IsValid():
2419+
options.SetLanguage(frame.GuessLanguage())
2420+
eval_result = self.frame().EvaluateExpression(expr, options)
2421+
else:
2422+
eval_result = self.target().EvaluateExpression(expr, options)
24202423

24212424
if not eval_result.GetError().Success():
24222425
self.assertTrue(eval_result.GetError().Success(),

lldb/test/API/commands/expression/call-function/TestCallBuiltinFunction.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,10 @@ class ExprCommandCallBuiltinFunction(TestBase):
1717
# Builtins are expanded by Clang, so debug info shouldn't matter.
1818
NO_DEBUG_INFO_TESTCASE = True
1919

20-
def setUp(self):
21-
TestBase.setUp(self)
22-
# Find the line number to break for main.c.
23-
self.line = line_number(
24-
'main.cpp',
25-
'// Please test these expressions while stopped at this line:')
26-
2720
def test(self):
2821
self.build()
2922

30-
# Set breakpoint in main and run exe
31-
self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
32-
lldbutil.run_break_set_by_file_and_line(
33-
self, "main.cpp", self.line, num_expected_locations=-1, loc_exact=True)
34-
35-
self.runCmd("run", RUN_SUCCEEDED)
36-
37-
# Test different builtin functions.
23+
target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
3824

3925
self.expect_expr("__builtin_isinf(0.0f)", result_type="int", result_value="0")
4026
self.expect_expr("__builtin_isnormal(0.0f)", result_type="int", result_value="0")

0 commit comments

Comments
 (0)