forked from OSchip/llvm-project
[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. llvm-svn: 366768
This commit is contained in:
parent
a61c247ce1
commit
b2a9cf7764
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<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(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), "<lldb.comm.%s>",
|
||||
|
@ -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;
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -110,10 +110,10 @@ Target::Target(Debugger &debugger, const ArchSpec &target_arch,
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue