[Lldb-commits] [PATCH] D80312: [lldb/Reproducers] Make SBStream::Print a first-class API instead of a SWIG extension

Jonas Devlieghere via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed May 20 10:55:23 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGbfb278372633: [lldb/Reproducers] Make SBStream::Print an API instead of a SWIG extension (authored by JDevlieghere).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80312/new/

https://reviews.llvm.org/D80312

Files:
  lldb/bindings/interface/SBStream.i
  lldb/include/lldb/API/SBStream.h
  lldb/source/API/SBStream.cpp


Index: lldb/source/API/SBStream.cpp
===================================================================
--- lldb/source/API/SBStream.cpp
+++ lldb/source/API/SBStream.cpp
@@ -60,6 +60,12 @@
   return static_cast<StreamString *>(m_opaque_up.get())->GetSize();
 }
 
+void SBStream::Print(const char *str) {
+  LLDB_RECORD_METHOD(void, SBStream, Print, (const char *), str);
+
+  Printf("%s", str);
+}
+
 void SBStream::Printf(const char *format, ...) {
   if (!format)
     return;
@@ -204,6 +210,7 @@
   LLDB_REGISTER_METHOD(void, SBStream, RedirectToFileHandle, (FILE *, bool));
   LLDB_REGISTER_METHOD(void, SBStream, RedirectToFileDescriptor, (int, bool));
   LLDB_REGISTER_METHOD(void, SBStream, Clear, ());
+  LLDB_REGISTER_METHOD(void, SBStream, Print, (const char *));
 }
 
 }
Index: lldb/include/lldb/API/SBStream.h
===================================================================
--- lldb/include/lldb/API/SBStream.h
+++ lldb/include/lldb/API/SBStream.h
@@ -37,6 +37,8 @@
 
   void Printf(const char *format, ...) __attribute__((format(printf, 2, 3)));
 
+  void Print(const char *str);
+
   void RedirectToFile(const char *path, bool append);
 
   void RedirectToFile(lldb::SBFile file);
Index: lldb/bindings/interface/SBStream.i
===================================================================
--- lldb/bindings/interface/SBStream.i
+++ lldb/bindings/interface/SBStream.i
@@ -62,14 +62,8 @@
     size_t
     GetSize();
 
-    // wrapping the variadic Printf() with a plain Print()
-    // because it is hard to support varargs in SWIG bridgings
-    %extend {
-        void Print (const char* str)
-        {
-            self->Printf("%s", str);
-        }
-    }
+    void
+    Print (const char* str);
 
     void
     RedirectToFile (const char *path, bool append);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80312.265305.patch
Type: text/x-patch
Size: 1785 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200520/97a9a92b/attachment-0001.bin>


More information about the lldb-commits mailing list