diff --git a/lldb/bindings/macros.swig b/lldb/bindings/macros.swig --- a/lldb/bindings/macros.swig +++ b/lldb/bindings/macros.swig @@ -1,6 +1,6 @@ %define STRING_EXTENSION_LEVEL(Class, Level) %extend { - std::string lldb:: ## Class ## ::__str__(){ + std::string lldb:: ## Class ## ::__repr__(){ lldb::SBStream stream; $self->GetDescription (stream, Level); const char *desc = stream.GetData(); @@ -15,7 +15,7 @@ %define STRING_EXTENSION(Class) %extend { - std::string lldb:: ## Class ## ::__str__(){ + std::string lldb:: ## Class ## ::__repr__(){ lldb::SBStream stream; $self->GetDescription (stream); const char *desc = stream.GetData(); diff --git a/lldb/test/API/sanity/TestReprStrEquality.py b/lldb/test/API/sanity/TestReprStrEquality.py new file mode 100644 --- /dev/null +++ b/lldb/test/API/sanity/TestReprStrEquality.py @@ -0,0 +1,18 @@ +""" +This is a sanity check that verifies that `repr(sbobject)` and `str(sbobject)` +produce the same string. +""" + + +import lldb +from lldbsuite.test.lldbtest import * + + +class TestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + NO_DEBUG_INFO_TESTCASE = True + + def test(self): + self.assertEqual(repr(self.dbg), str(self.dbg)) diff --git a/lldb/test/Shell/Driver/Inputs/convenience.in b/lldb/test/Shell/Driver/Inputs/convenience.in --- a/lldb/test/Shell/Driver/Inputs/convenience.in +++ b/lldb/test/Shell/Driver/Inputs/convenience.in @@ -1,8 +1,11 @@ breakpoint set -f hello.cpp -p Hello run script print(lldb.debugger) +script lldb.debugger script print(lldb.target) +script lldb.target script print(lldb.process) +script lldb.process script print(lldb.thread.GetStopDescription(100)) script lldb.frame.GetLineEntry().GetLine() script lldb.frame.GetLineEntry().GetFileSpec().GetFilename() diff --git a/lldb/test/Shell/Driver/TestConvenienceVariables.test b/lldb/test/Shell/Driver/TestConvenienceVariables.test --- a/lldb/test/Shell/Driver/TestConvenienceVariables.test +++ b/lldb/test/Shell/Driver/TestConvenienceVariables.test @@ -6,10 +6,16 @@ CHECK: stop reason = breakpoint 1.1 CHECK: script print(lldb.debugger) CHECK-NEXT: Debugger (instance: {{.*}}, id: {{[0-9]+}}) +CHECK: script lldb.debugger +CHECK-NEXT: Debugger (instance: {{.*}}, id: {{[0-9]+}}) CHECK: script print(lldb.target) CHECK-NEXT: target.out +CHECK: script lldb.target +CHECK-NEXT: target.out CHECK: script print(lldb.process) CHECK-NEXT: SBProcess: pid = {{[0-9]+}}, state = stopped, threads = {{[0-9]+}}, executable = target.out +CHECK: script lldb.process +CHECK-NEXT: SBProcess: pid = {{[0-9]+}}, state = stopped, threads = {{[0-9]+}}, executable = target.out CHECK: script print(lldb.thread.GetStopDescription(100)) CHECK-NEXT: breakpoint 1.1 CHECK: script lldb.frame.GetLineEntry().GetLine()