diff --git a/lldb/include/lldb/Utility/Log.h b/lldb/include/lldb/Utility/Log.h index 949de69c8e5a..7abf356a154e 100644 --- a/lldb/include/lldb/Utility/Log.h +++ b/lldb/include/lldb/Utility/Log.h @@ -144,12 +144,8 @@ public: void Printf(const char *format, ...) __attribute__((format(printf, 2, 3))); - void VAPrintf(const char *format, va_list args); - void Error(const char *fmt, ...) __attribute__((format(printf, 2, 3))); - void VAError(const char *format, va_list args); - void Verbose(const char *fmt, ...) __attribute__((format(printf, 2, 3))); void Warning(const char *fmt, ...) __attribute__((format(printf, 2, 3))); @@ -161,6 +157,9 @@ public: bool GetVerbose() const; private: + void VAPrintf(const char *format, va_list args); + void VAError(const char *format, va_list args); + Channel &m_channel; // The mutex makes sure enable/disable operations are thread-safe. The diff --git a/lldb/include/lldb/Utility/Logging.h b/lldb/include/lldb/Utility/Logging.h index 41086fedf8c2..1a8a1022c5c0 100644 --- a/lldb/include/lldb/Utility/Logging.h +++ b/lldb/include/lldb/Utility/Logging.h @@ -54,8 +54,6 @@ namespace lldb_private { class Log; -void LogIfAnyCategoriesSet(uint32_t mask, const char *format, ...); - Log *GetLogIfAllCategoriesSet(uint32_t mask); Log *GetLogIfAnyCategoriesSet(uint32_t mask); diff --git a/lldb/source/Core/Communication.cpp b/lldb/source/Core/Communication.cpp index a67cb925d648..9ec2b9be3563 100644 --- a/lldb/source/Core/Communication.cpp +++ b/lldb/source/Core/Communication.cpp @@ -46,9 +46,10 @@ Communication::Communication(const char *name) m_callback(nullptr), m_callback_baton(nullptr), m_close_on_eof(true) { - lldb_private::LogIfAnyCategoriesSet( - LIBLLDB_LOG_OBJECT | LIBLLDB_LOG_COMMUNICATION, - "%p Communication::Communication (name = %s)", this, name); + + LLDB_LOG(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_OBJECT | + LIBLLDB_LOG_COMMUNICATION), + "%p Communication::Communication (name = %s)", this, name); SetEventName(eBroadcastBitDisconnected, "disconnected"); SetEventName(eBroadcastBitReadThreadGotBytes, "got bytes"); @@ -61,10 +62,10 @@ Communication::Communication(const char *name) } Communication::~Communication() { - lldb_private::LogIfAnyCategoriesSet( - LIBLLDB_LOG_OBJECT | LIBLLDB_LOG_COMMUNICATION, - "%p Communication::~Communication (name = %s)", this, - GetBroadcasterName().AsCString()); + LLDB_LOG(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_OBJECT | + LIBLLDB_LOG_COMMUNICATION), + "%p Communication::~Communication (name = %s)", this, + GetBroadcasterName().AsCString()); Clear(); } @@ -77,9 +78,8 @@ void Communication::Clear() { ConnectionStatus Communication::Connect(const char *url, Status *error_ptr) { Clear(); - lldb_private::LogIfAnyCategoriesSet(LIBLLDB_LOG_COMMUNICATION, - "%p Communication::Connect (url = %s)", - this, url); + LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_COMMUNICATION), + "%p Communication::Connect (url = %s)", this, url); lldb::ConnectionSP connection_sp(m_connection_sp); if (connection_sp) @@ -90,8 +90,8 @@ ConnectionStatus Communication::Connect(const char *url, Status *error_ptr) { } ConnectionStatus Communication::Disconnect(Status *error_ptr) { - lldb_private::LogIfAnyCategoriesSet(LIBLLDB_LOG_COMMUNICATION, - "%p Communication::Disconnect ()", this); + LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_COMMUNICATION), + "%p Communication::Disconnect ()", this); lldb::ConnectionSP connection_sp(m_connection_sp); if (connection_sp) { @@ -173,11 +173,10 @@ size_t Communication::Write(const void *src, size_t src_len, lldb::ConnectionSP connection_sp(m_connection_sp); std::lock_guard guard(m_write_mutex); - lldb_private::LogIfAnyCategoriesSet( - LIBLLDB_LOG_COMMUNICATION, - "%p Communication::Write (src = %p, src_len = %" PRIu64 - ") connection = %p", - this, src, (uint64_t)src_len, connection_sp.get()); + LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_COMMUNICATION), + "%p Communication::Write (src = %p, src_len = %" PRIu64 + ") connection = %p", + this, src, (uint64_t)src_len, connection_sp.get()); if (connection_sp) return connection_sp->Write(src, src_len, status, error_ptr); @@ -195,8 +194,8 @@ bool Communication::StartReadThread(Status *error_ptr) { if (m_read_thread.IsJoinable()) return true; - lldb_private::LogIfAnyCategoriesSet( - LIBLLDB_LOG_COMMUNICATION, "%p Communication::StartReadThread ()", this); + LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_COMMUNICATION), + "%p Communication::StartReadThread ()", this); char thread_name[1024]; snprintf(thread_name, sizeof(thread_name), "", @@ -228,8 +227,8 @@ bool Communication::StopReadThread(Status *error_ptr) { if (!m_read_thread.IsJoinable()) return true; - lldb_private::LogIfAnyCategoriesSet( - LIBLLDB_LOG_COMMUNICATION, "%p Communication::StopReadThread ()", this); + LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_COMMUNICATION), + "%p Communication::StopReadThread ()", this); m_read_thread_enabled = false; @@ -270,11 +269,10 @@ size_t Communication::GetCachedBytes(void *dst, size_t dst_len) { void Communication::AppendBytesToCache(const uint8_t *bytes, size_t len, bool broadcast, ConnectionStatus status) { - lldb_private::LogIfAnyCategoriesSet( - LIBLLDB_LOG_COMMUNICATION, - "%p Communication::AppendBytesToCache (src = %p, src_len = %" PRIu64 - ", broadcast = %i)", - this, bytes, (uint64_t)len, broadcast); + LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_COMMUNICATION), + "%p Communication::AppendBytesToCache (src = %p, src_len = %" PRIu64 + ", broadcast = %i)", + this, bytes, (uint64_t)len, broadcast); if ((bytes == nullptr || len == 0) && (status != lldb::eConnectionStatusEndOfFile)) return; diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp index 62e512adc9f7..47758ce85eb2 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp @@ -554,22 +554,6 @@ int RegisterContextDarwin_x86_64::GetSetForNativeRegNum(int reg_num) { return -1; } -void RegisterContextDarwin_x86_64::LogGPR(Log *log, const char *format, ...) { - if (log) { - if (format) { - va_list args; - va_start(args, format); - log->VAPrintf(format, args); - va_end(args); - } - for (uint32_t i = 0; i < k_num_gpr_registers; i++) { - uint32_t reg = gpr_rax + i; - log->Printf("%12s = 0x%16.16" PRIx64, g_register_infos[reg].name, - (&gpr.rax)[reg]); - } - } -} - int RegisterContextDarwin_x86_64::ReadGPR(bool force) { int set = GPRRegSet; if (force || !RegisterSetIsCached(set)) { diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 37a661b062a8..71819a985965 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -110,10 +110,10 @@ Target::Target(Debugger &debugger, const ArchSpec &target_arch, if (log) log->Printf("%p Target::Target()", static_cast(this)); if (target_arch.IsValid()) { - LogIfAnyCategoriesSet(LIBLLDB_LOG_TARGET, - "Target::Target created with architecture %s (%s)", - target_arch.GetArchitectureName(), - target_arch.GetTriple().getTriple().c_str()); + LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_TARGET), + "Target::Target created with architecture %s (%s)", + target_arch.GetArchitectureName(), + target_arch.GetTriple().getTriple().c_str()); } } @@ -2319,11 +2319,10 @@ ArchSpec Target::GetDefaultArchitecture() { void Target::SetDefaultArchitecture(const ArchSpec &arch) { TargetPropertiesSP properties_sp(Target::GetGlobalProperties()); if (properties_sp) { - LogIfAnyCategoriesSet(LIBLLDB_LOG_TARGET, - "Target::SetDefaultArchitecture setting target's " - "default architecture to %s (%s)", - arch.GetArchitectureName(), - arch.GetTriple().getTriple().c_str()); + LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_TARGET), + "Target::SetDefaultArchitecture setting target's " + "default architecture to %s (%s)", + arch.GetArchitectureName(), arch.GetTriple().getTriple().c_str()); return properties_sp->SetDefaultArchitecture(arch); } } diff --git a/lldb/source/Utility/Logging.cpp b/lldb/source/Utility/Logging.cpp index c0856e5d9267..22f38192fa5d 100644 --- a/lldb/source/Utility/Logging.cpp +++ b/lldb/source/Utility/Logging.cpp @@ -62,13 +62,3 @@ Log *lldb_private::GetLogIfAllCategoriesSet(uint32_t mask) { Log *lldb_private::GetLogIfAnyCategoriesSet(uint32_t mask) { return g_log_channel.GetLogIfAny(mask); } - - -void lldb_private::LogIfAnyCategoriesSet(uint32_t mask, const char *format, ...) { - if (Log *log = GetLogIfAnyCategoriesSet(mask)) { - va_list args; - va_start(args, format); - log->VAPrintf(format, args); - va_end(args); - } -}