summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Labath <labath@google.com>2017-02-13 11:03:17 +0000
committerPavel Labath <labath@google.com>2017-02-13 11:03:17 +0000
commit6302bf6a260ba5fbbd10214a3e23effc535fe6f5 (patch)
treecacbbecff4255a03c32c14623018e8ad146f1f18
parent796e0d6df1d6f8c20da4e8e2cb20c5c8939db6b3 (diff)
downloadbcm5719-llvm-6302bf6a260ba5fbbd10214a3e23effc535fe6f5.tar.gz
bcm5719-llvm-6302bf6a260ba5fbbd10214a3e23effc535fe6f5.zip
Clean up debug logging
Summary: We've had two ways to print a "debug" log message. - Log::GetDebug() was testing a Stream flag which was never set. - Log::Debug() was checking for the presence of "log enable --debug" flag. Given that these two were used very rarely and we already have a different way to specify "I want a more verbose log", I propose to remove these two functions and migrate the callers to LLDB_LOGV. This commit does that. Reviewers: clayborg, zturner Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D29823 llvm-svn: 294939
-rw-r--r--lldb/include/lldb/Core/Log.h5
-rw-r--r--lldb/source/Commands/CommandObjectLog.cpp4
-rw-r--r--lldb/source/Core/Log.cpp22
-rw-r--r--lldb/source/Core/StringList.cpp2
-rw-r--r--lldb/source/DataFormatters/FormatManager.cpp56
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp16
-rw-r--r--lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp5
7 files changed, 31 insertions, 79 deletions
diff --git a/lldb/include/lldb/Core/Log.h b/lldb/include/lldb/Core/Log.h
index c91ed914cb5..4de5c34679f 100644
--- a/lldb/include/lldb/Core/Log.h
+++ b/lldb/include/lldb/Core/Log.h
@@ -29,7 +29,6 @@
//----------------------------------------------------------------------
#define LLDB_LOG_OPTION_THREADSAFE (1u << 0)
#define LLDB_LOG_OPTION_VERBOSE (1u << 1)
-#define LLDB_LOG_OPTION_DEBUG (1u << 2)
#define LLDB_LOG_OPTION_PREPEND_SEQUENCE (1u << 3)
#define LLDB_LOG_OPTION_PREPEND_TIMESTAMP (1u << 4)
#define LLDB_LOG_OPTION_PREPEND_PROC_AND_THREAD (1u << 5)
@@ -122,8 +121,6 @@ public:
void LogIf(uint32_t mask, const char *fmt, ...)
__attribute__((format(printf, 3, 4)));
- void Debug(const char *fmt, ...) __attribute__((format(printf, 2, 3)));
-
void Error(const char *fmt, ...) __attribute__((format(printf, 2, 3)));
void VAError(const char *format, va_list args);
@@ -142,8 +139,6 @@ public:
bool GetVerbose() const;
- bool GetDebug() const;
-
void SetStream(const std::shared_ptr<llvm::raw_ostream> &stream_sp) {
m_stream_sp = stream_sp;
}
diff --git a/lldb/source/Commands/CommandObjectLog.cpp b/lldb/source/Commands/CommandObjectLog.cpp
index 019ed6a25d5..6fbab08ac63 100644
--- a/lldb/source/Commands/CommandObjectLog.cpp
+++ b/lldb/source/Commands/CommandObjectLog.cpp
@@ -41,7 +41,6 @@ static OptionDefinition g_log_options[] = {
{ LLDB_OPT_SET_1, false, "file", 'f', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeFilename, "Set the destination file to log to." },
{ LLDB_OPT_SET_1, false, "threadsafe", 't', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Enable thread safe logging to avoid interweaved log lines." },
{ LLDB_OPT_SET_1, false, "verbose", 'v', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Enable verbose logging." },
- { LLDB_OPT_SET_1, false, "debug", 'g', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Enable debug logging." },
{ LLDB_OPT_SET_1, false, "sequence", 's', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Prepend all log lines with an increasing integer sequence id." },
{ LLDB_OPT_SET_1, false, "timestamp", 'T', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Prepend all log lines with a timestamp." },
{ LLDB_OPT_SET_1, false, "pid-tid", 'p', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Prepend all log lines with the process and thread ID that generates the log line." },
@@ -110,9 +109,6 @@ public:
case 'v':
log_options |= LLDB_LOG_OPTION_VERBOSE;
break;
- case 'g':
- log_options |= LLDB_LOG_OPTION_DEBUG;
- break;
case 's':
log_options |= LLDB_LOG_OPTION_PREPEND_SEQUENCE;
break;
diff --git a/lldb/source/Core/Log.cpp b/lldb/source/Core/Log.cpp
index 14b237826ff..0a983799e87 100644
--- a/lldb/source/Core/Log.cpp
+++ b/lldb/source/Core/Log.cpp
@@ -85,20 +85,6 @@ void Log::VAPrintf(const char *format, va_list args) {
}
//----------------------------------------------------------------------
-// Print debug strings if and only if the global debug option is set to
-// a non-zero value.
-//----------------------------------------------------------------------
-void Log::Debug(const char *format, ...) {
- if (!GetOptions().Test(LLDB_LOG_OPTION_DEBUG))
- return;
-
- va_list args;
- va_start(args, format);
- VAPrintf(format, args);
- va_end(args);
-}
-
-//----------------------------------------------------------------------
// Log only if all of the bits are set
//----------------------------------------------------------------------
void Log::LogIf(uint32_t bits, const char *format, ...) {
@@ -308,14 +294,6 @@ void Log::ListAllLogChannels(Stream *strm) {
bool Log::GetVerbose() const { return m_options.Test(LLDB_LOG_OPTION_VERBOSE); }
-//------------------------------------------------------------------
-// Returns true if the debug flag bit is set in this stream.
-//------------------------------------------------------------------
-bool Log::GetDebug() const {
- // TODO: remove and clean up callers
- return false;
-}
-
void Log::WriteHeader(llvm::raw_ostream &OS, llvm::StringRef file,
llvm::StringRef function) {
static uint32_t g_sequence_id = 0;
diff --git a/lldb/source/Core/StringList.cpp b/lldb/source/Core/StringList.cpp
index 597bd9ed276..c51a6e3071a 100644
--- a/lldb/source/Core/StringList.cpp
+++ b/lldb/source/Core/StringList.cpp
@@ -267,5 +267,5 @@ void StringList::LogDump(Log *log, const char *name) {
if (name)
strm.Printf("End %s.\n", name);
- log->Debug("%s", strm.GetData());
+ LLDB_LOGV(log, "{0}", strm.GetData());
}
diff --git a/lldb/source/DataFormatters/FormatManager.cpp b/lldb/source/DataFormatters/FormatManager.cpp
index 6e5fdf92305..a7006ccf830 100644
--- a/lldb/source/DataFormatters/FormatManager.cpp
+++ b/lldb/source/DataFormatters/FormatManager.cpp
@@ -660,11 +660,9 @@ FormatManager::GetFormat(ValueObject &valobj,
if (log) {
log->Printf(
"[FormatManager::GetFormat] Cache search success. Returning.");
- if (log->GetDebug())
- log->Printf("[FormatManager::GetFormat] Cache hits: %" PRIu64
- " - Cache Misses: %" PRIu64,
- m_format_cache.GetCacheHits(),
- m_format_cache.GetCacheMisses());
+ LLDB_LOGV(log, "Cache hits: {0} - Cache Misses: {1}",
+ m_format_cache.GetCacheHits(),
+ m_format_cache.GetCacheMisses());
}
return retval;
}
@@ -705,10 +703,8 @@ FormatManager::GetFormat(ValueObject &valobj,
match_data.GetTypeForCache().AsCString("<invalid>"));
m_format_cache.SetFormat(match_data.GetTypeForCache(), retval);
}
- if (log && log->GetDebug())
- log->Printf("[FormatManager::GetFormat] Cache hits: %" PRIu64
- " - Cache Misses: %" PRIu64,
- m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
+ LLDB_LOGV(log, "Cache hits: {0} - Cache Misses: {1}",
+ m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
return retval;
}
@@ -742,11 +738,9 @@ FormatManager::GetSummaryFormat(ValueObject &valobj,
if (log) {
log->Printf("[FormatManager::GetSummaryFormat] Cache search success. "
"Returning.");
- if (log->GetDebug())
- log->Printf("[FormatManager::GetSummaryFormat] Cache hits: %" PRIu64
- " - Cache Misses: %" PRIu64,
- m_format_cache.GetCacheHits(),
- m_format_cache.GetCacheMisses());
+ LLDB_LOGV(log, "Cache hits: {0} - Cache Misses: {1}",
+ m_format_cache.GetCacheHits(),
+ m_format_cache.GetCacheMisses());
}
return retval;
}
@@ -787,10 +781,8 @@ FormatManager::GetSummaryFormat(ValueObject &valobj,
match_data.GetTypeForCache().AsCString("<invalid>"));
m_format_cache.SetSummary(match_data.GetTypeForCache(), retval);
}
- if (log && log->GetDebug())
- log->Printf("[FormatManager::GetSummaryFormat] Cache hits: %" PRIu64
- " - Cache Misses: %" PRIu64,
- m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
+ LLDB_LOGV(log, "Cache hits: {0} - Cache Misses: {1}",
+ m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
return retval;
}
@@ -825,11 +817,9 @@ FormatManager::GetSyntheticChildren(ValueObject &valobj,
if (log) {
log->Printf("[FormatManager::GetSyntheticChildren] Cache search "
"success. Returning.");
- if (log->GetDebug())
- log->Printf(
- "[FormatManager::GetSyntheticChildren] Cache hits: %" PRIu64
- " - Cache Misses: %" PRIu64,
- m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
+ LLDB_LOGV(log, "Cache hits: {0} - Cache Misses: {1}",
+ m_format_cache.GetCacheHits(),
+ m_format_cache.GetCacheMisses());
}
return retval;
}
@@ -871,10 +861,8 @@ FormatManager::GetSyntheticChildren(ValueObject &valobj,
match_data.GetTypeForCache().AsCString("<invalid>"));
m_format_cache.SetSynthetic(match_data.GetTypeForCache(), retval);
}
- if (log && log->GetDebug())
- log->Printf("[FormatManager::GetSyntheticChildren] Cache hits: %" PRIu64
- " - Cache Misses: %" PRIu64,
- m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
+ LLDB_LOGV(log, "Cache hits: {0} - Cache Misses: {1}",
+ m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
return retval;
}
#endif
@@ -895,11 +883,9 @@ FormatManager::GetValidator(ValueObject &valobj,
if (log) {
log->Printf(
"[FormatManager::GetValidator] Cache search success. Returning.");
- if (log->GetDebug())
- log->Printf("[FormatManager::GetValidator] Cache hits: %" PRIu64
- " - Cache Misses: %" PRIu64,
- m_format_cache.GetCacheHits(),
- m_format_cache.GetCacheMisses());
+ LLDB_LOGV(log, "Cache hits: {0} - Cache Misses: {1}",
+ m_format_cache.GetCacheHits(),
+ m_format_cache.GetCacheMisses());
}
return retval;
}
@@ -940,10 +926,8 @@ FormatManager::GetValidator(ValueObject &valobj,
match_data.GetTypeForCache().AsCString("<invalid>"));
m_format_cache.SetValidator(match_data.GetTypeForCache(), retval);
}
- if (log && log->GetDebug())
- log->Printf("[FormatManager::GetValidator] Cache hits: %" PRIu64
- " - Cache Misses: %" PRIu64,
- m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
+ LLDB_LOGV(log, "Cache hits: {0} - Cache Misses: {1}",
+ m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
return retval;
}
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
index 8f9e194d2aa..27cbf10dbac 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -339,16 +339,16 @@ ClangExpressionParser::ClangExpressionParser(ExecutionContextScope *exe_scope,
lang_rt->GetOverrideExprOptions(m_compiler->getTargetOpts());
if (overridden_target_opts)
- if (log) {
- log->Debug(
- "Using overridden target options for the expression evaluation");
+ if (log && log->GetVerbose()) {
+ LLDB_LOGV(
+ log, "Using overridden target options for the expression evaluation");
auto opts = m_compiler->getTargetOpts();
- log->Debug("Triple: '%s'", opts.Triple.c_str());
- log->Debug("CPU: '%s'", opts.CPU.c_str());
- log->Debug("FPMath: '%s'", opts.FPMath.c_str());
- log->Debug("ABI: '%s'", opts.ABI.c_str());
- log->Debug("LinkerVersion: '%s'", opts.LinkerVersion.c_str());
+ LLDB_LOGV(log, "Triple: '{0}'", opts.Triple);
+ LLDB_LOGV(log, "CPU: '{0}'", opts.CPU);
+ LLDB_LOGV(log, "FPMath: '{0}'", opts.FPMath);
+ LLDB_LOGV(log, "ABI: '{0}'", opts.ABI);
+ LLDB_LOGV(log, "LinkerVersion: '{0}'", opts.LinkerVersion);
StringList::LogDump(log, opts.FeaturesAsWritten, "FeaturesAsWritten");
StringList::LogDump(log, opts.Features, "Features");
StringList::LogDump(log, opts.Reciprocals, "Reciprocals");
diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
index 6c6e17449e3..068d79b2ebc 100644
--- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
@@ -3128,9 +3128,8 @@ bool RSModuleDescriptor::ParseRSInfo() {
// in numeric fields at the moment
uint64_t n_lines;
if (val.getAsInteger(10, n_lines)) {
- if (log)
- log->Debug("Failed to parse non-numeric '.rs.info' section %s",
- line->str().c_str());
+ LLDB_LOGV(log, "Failed to parse non-numeric '.rs.info' section {0}",
+ line->str());
continue;
}
if (info_lines.end() - (line + 1) < (ptrdiff_t)n_lines)
OpenPOWER on IntegriCloud