[Lldb-commits] [lldb] r366768 - [Logging] Replace LogIfAnyCategoriesSet with LLDB_LOG.
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Mon Jul 22 16:48:01 PDT 2019
Author: jdevlieghere
Date: Mon Jul 22 16:48:01 2019
New Revision: 366768
URL: http://llvm.org/viewvc/llvm-project?rev=366768&view=rev
Log:
[Logging] Replace LogIfAnyCategoriesSet with LLDB_LOG.
This patch removes any remaining instances of LogIfAnyCategoriesSet and
replaces them with the LLDB_LOG macro. This in turn made it possible to
make Log::VAPrintf and Log::VAError private.
Modified:
lldb/trunk/include/lldb/Utility/Log.h
lldb/trunk/include/lldb/Utility/Logging.h
lldb/trunk/source/Core/Communication.cpp
lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp
lldb/trunk/source/Target/Target.cpp
lldb/trunk/source/Utility/Logging.cpp
Modified: lldb/trunk/include/lldb/Utility/Log.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/Log.h?rev=366768&r1=366767&r2=366768&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Utility/Log.h (original)
+++ lldb/trunk/include/lldb/Utility/Log.h Mon Jul 22 16:48:01 2019
@@ -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
Modified: lldb/trunk/include/lldb/Utility/Logging.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/Logging.h?rev=366768&r1=366767&r2=366768&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Utility/Logging.h (original)
+++ lldb/trunk/include/lldb/Utility/Logging.h Mon Jul 22 16:48:01 2019
@@ -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);
Modified: lldb/trunk/source/Core/Communication.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Communication.cpp?rev=366768&r1=366767&r2=366768&view=diff
==============================================================================
--- lldb/trunk/source/Core/Communication.cpp (original)
+++ lldb/trunk/source/Core/Communication.cpp Mon Jul 22 16:48:01 2019
@@ -46,9 +46,10 @@ Communication::Communication(const char
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
}
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(
}
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 *
lldb::ConnectionSP connection_sp(m_connection_sp);
std::lock_guard<std::mutex> 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(Stat
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), "<lldb.comm.%s>",
@@ -228,8 +227,8 @@ bool Communication::StopReadThread(Statu
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(voi
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;
Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp?rev=366768&r1=366767&r2=366768&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp Mon Jul 22 16:48:01 2019
@@ -554,22 +554,6 @@ int RegisterContextDarwin_x86_64::GetSet
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)) {
Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=366768&r1=366767&r2=366768&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Mon Jul 22 16:48:01 2019
@@ -110,10 +110,10 @@ Target::Target(Debugger &debugger, const
if (log)
log->Printf("%p Target::Target()", static_cast<void *>(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);
}
}
Modified: lldb/trunk/source/Utility/Logging.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/Logging.cpp?rev=366768&r1=366767&r2=366768&view=diff
==============================================================================
--- lldb/trunk/source/Utility/Logging.cpp (original)
+++ lldb/trunk/source/Utility/Logging.cpp Mon Jul 22 16:48:01 2019
@@ -62,13 +62,3 @@ Log *lldb_private::GetLogIfAllCategories
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);
- }
-}
More information about the lldb-commits
mailing list