[lldb/Reproducers] Make SBStream::Print an API instead of a SWIG extension

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
This commit is contained in:
Jonas Devlieghere 2020-05-20 10:32:51 -07:00
parent b8cbff51d3
commit bfb2783726
3 changed files with 11 additions and 8 deletions

View File

@ -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);

View File

@ -37,6 +37,8 @@ public:
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);

View File

@ -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;
@ -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 *));
}
}