Skip to content

Commit

Permalink
[lldb/Reproducers] Make SBStream::Print an API instead of a SWIG exte…
Browse files Browse the repository at this point in the history
…nsion

This makes it possible to instrument the call for the reproducers. This
fixes TestStructuredDataAPI.py with reproducer replay.

Differential revision: https://reviews.llvm.org/D80312
  • Loading branch information
JDevlieghere committed May 20, 2020
1 parent b8cbff5 commit bfb2783
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
10 changes: 2 additions & 8 deletions lldb/bindings/interface/SBStream.i
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,8 @@ public:
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);
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class LLDB_API SBStream {

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);
Expand Down
7 changes: 7 additions & 0 deletions lldb/source/API/SBStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ size_t SBStream::GetSize() {
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;
Expand Down Expand Up @@ -204,6 +210,7 @@ void RegisterMethods<SBStream>(Registry &R) {
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 *));
}

}
Expand Down

0 comments on commit bfb2783

Please sign in to comment.