Skip to content

Don't stop on breakpoints when running the swift Object Description function #10693

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

Open
wants to merge 1 commit into
base: swift/release/6.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -922,9 +922,10 @@ llvm::Error SwiftLanguageRuntime::RunObjectDescriptionExpr(
Log *log(GetLog(LLDBLog::DataFormatters | LLDBLog::Expressions));
ValueObjectSP result_sp;
EvaluateExpressionOptions eval_options;
eval_options.SetUnwindOnError(true);
eval_options.SetLanguage(lldb::eLanguageTypeSwift);
eval_options.SetSuppressPersistentResult(true);
eval_options.SetGenerateDebugInfo(true);
eval_options.SetIgnoreBreakpoints(true);
eval_options.SetTimeout(GetProcess().GetUtilityExpressionTimeout());

StackFrameSP frame_sp = object.GetFrameSP();
Expand Down
38 changes: 36 additions & 2 deletions lldb/test/API/lang/swift/po/val_types/TestSwiftPOValTypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,41 @@
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
#
# ------------------------------------------------------------------------------
import lldbsuite.test.lldbinline as lldbinline
import lldb
import lldbsuite.test
import lldbsuite.test.lldbutil as lldbutil
from lldbsuite.test.lldbtest import *
from lldbsuite.test.decorators import *

lldbinline.MakeInlineTest(__file__, globals(), decorators=[swiftTest])
class TestPOValueTypes(TestBase):

def test_value_types(self):
"""Test 'po' on a variety of value types with and without custom descriptions."""
self.build()
(_,_,_,_) = lldbutil.run_to_source_breakpoint(self, "Break here to run tests", lldb.SBFileSpec("main.swift"))

self.expect("po dm", substrs=['a', '12', 'b', '24'])
self.expect("po cm", substrs=['c', '36'])
self.expect("po cm", substrs=['12', '24'], matching=False)
self.expect("po cs", substrs=['CustomDebugStringConvertible'])
self.expect("po cs", substrs=['CustomStringConvertible'], matching=False)
self.expect("po cs", substrs=['a', '12', 'b', '24'])
self.expect("script lldb.frame.FindVariable('cs').GetObjectDescription()", substrs=['a', '12', 'b', '24'])
self.expect("po (12,24,36,48)", substrs=['12', '24', '36', '48'])
self.expect("po (dm as Any, cm as Any,48 as Any)", substrs=['12', '24', '36', '48'])
self.expect("po patatino", substrs=['foo'])

def test_ignore_bkpts_in_po(self):
"""Run a po expression with a breakpoint in the debugDescription, make sure we don't hit it."""

self.build()
main_spec = lldb.SBFileSpec("main.swift")
(target, process, thread, _) = lldbutil.run_to_source_breakpoint(self, "Break here to run tests", main_spec)
po_bkpt = target.BreakpointCreateBySourceRegex("Breakpoint in debugDescription", main_spec)

# As part of the po expression we should auto-continue past the breakpoint so this succeeds:
self.expect("po cs", substrs=['CustomDebugStringConvertible'])
self.assertEqual(po_bkpt.GetHitCount(), 1, "Did hit the breakpoint")



22 changes: 9 additions & 13 deletions lldb/test/API/lang/swift/po/val_types/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,21 @@ struct CustomSummary : CustomStringConvertible, CustomDebugStringConvertible {
var a = 12
var b = 24

var description: String { return "CustomStringConvertible" }
var debugDescription: String { return "CustomDebugStringConvertible" }
var description: String {
return "CustomStringConvertible"
}
var debugDescription: String {
return "CustomDebugStringConvertible" // Breakpoint in debugDescription
}
}

func main() {
var dm = DefaultMirror()
var cm = CustomMirror()
var cs = CustomSummary()
var patatino = "foo" //% self.expect("image list")
print("yay I am done!") //% self.expect("po dm", substrs=['a', '12', 'b', '24'])
//% self.expect("po cm", substrs=['c', '36'])
//% self.expect("po cm", substrs=['12', '24'], matching=False)
//% self.expect("po cs", substrs=['CustomDebugStringConvertible'])
//% self.expect("po cs", substrs=['CustomStringConvertible'], matching=False)
//% self.expect("po cs", substrs=['a', '12', 'b', '24'])
//% self.expect("script lldb.frame.FindVariable('cs').GetObjectDescription()", substrs=['a', '12', 'b', '24'])
//% self.expect("po (12,24,36,48)", substrs=['12', '24', '36', '48'])
//% self.expect("po (dm as Any, cm as Any,48 as Any)", substrs=['12', '24', '36', '48'])
//% self.expect("po patatino", substrs=['foo'])
var patatino = "foo"

print("yay I am done!") // Break here to run tests.
}

main()