[Lldb-commits] [PATCH] D127458: [lldb][bindings] Implement __repr__ instead of __str__
Dave Lee via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Fri Jun 10 11:07:28 PDT 2022
kastiglione updated this revision to Diff 435980.
kastiglione added a comment.
update TestConvenienceVariables.test
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D127458/new/
https://reviews.llvm.org/D127458
Files:
lldb/bindings/macros.swig
lldb/test/API/sanity/TestReprStrEquality.py
lldb/test/Shell/Driver/Inputs/convenience.in
lldb/test/Shell/Driver/TestConvenienceVariables.test
Index: lldb/test/Shell/Driver/TestConvenienceVariables.test
===================================================================
--- lldb/test/Shell/Driver/TestConvenienceVariables.test
+++ 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()
Index: lldb/test/Shell/Driver/Inputs/convenience.in
===================================================================
--- lldb/test/Shell/Driver/Inputs/convenience.in
+++ 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()
Index: lldb/test/API/sanity/TestReprStrEquality.py
===================================================================
--- /dev/null
+++ 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))
Index: lldb/bindings/macros.swig
===================================================================
--- lldb/bindings/macros.swig
+++ 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();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127458.435980.patch
Type: text/x-patch
Size: 2842 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220610/aa01f0a5/attachment-0001.bin>
More information about the lldb-commits
mailing list