[SBAPI] Log from record macro

The current record macros already log the function being called. This
patch extends the macros to also log their input arguments and removes
explicit logging from the SB API.

This might degrade the amount of information in some cases (because of
smarter casts or efforts to log return values). However I think this is
outweighed by the increased coverage and consistency. Furthermore, using
the reproducer infrastructure, diagnosing bugs in the API layer should
become much easier compared to relying on log messages.

Differential revision: https://reviews.llvm.org/D59101

llvm-svn: 355649
This commit is contained in:
Jonas Devlieghere
2019-03-07 22:47:13 +00:00
parent d672e533d5
commit 581af8b09d
39 changed files with 124 additions and 3032 deletions

View File

@@ -75,23 +75,12 @@ const char *SBEvent::GetDataFlavor() {
uint32_t SBEvent::GetType() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBEvent, GetType);
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
const Event *lldb_event = get();
uint32_t event_type = 0;
if (lldb_event)
event_type = lldb_event->GetType();
if (log) {
StreamString sstr;
if (lldb_event && lldb_event->GetBroadcaster() &&
lldb_event->GetBroadcaster()->GetEventNames(sstr, event_type, true))
log->Printf("SBEvent(%p)::GetType () => 0x%8.8x (%s)",
static_cast<void *>(get()), event_type, sstr.GetData());
else
log->Printf("SBEvent(%p)::GetType () => 0x%8.8x",
static_cast<void *>(get()), event_type);
}
return event_type;
}
@@ -135,11 +124,6 @@ bool SBEvent::BroadcasterMatchesRef(const SBBroadcaster &broadcaster) {
if (lldb_event)
success = lldb_event->BroadcasterIs(broadcaster.get());
// For logging, this gets a little chatty so only enable this when verbose
// logging is on
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
LLDB_LOGV(log, "({0}) (SBBroadcaster({1}): {2}) => {3}", get(),
broadcaster.get(), broadcaster.GetName(), success);
return success;
}
@@ -187,14 +171,6 @@ const char *SBEvent::GetCStringFromEvent(const SBEvent &event) {
LLDB_RECORD_STATIC_METHOD(const char *, SBEvent, GetCStringFromEvent,
(const lldb::SBEvent &), event);
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
if (log)
log->Printf("SBEvent(%p)::GetCStringFromEvent () => \"%s\"",
static_cast<void *>(event.get()),
reinterpret_cast<const char *>(
EventDataBytes::GetBytesFromEvent(event.get())));
return reinterpret_cast<const char *>(
EventDataBytes::GetBytesFromEvent(event.get()));
}