mirror of
https://github.com/intel/llvm.git
synced 2026-01-15 04:17:17 +08:00
More aggressively deduplicate global warnings based on contents. (#112801)
I've been getting complaints from users being spammed by -gmodules missing file warnings going out of control because each object file depends on an entire DAG of PCM files that usually are all missing at once. To reduce this problem, this patch does two things: 1. Module now maintains a DenseMap<hash, once> that is used to display each warning only once, based on its actual text. 2. The PCM warning itself is reworded to include less details, such as the DIE offset, which is only useful to LLDB developers, who can get this from the dwarf log if they need it. Because the detail is omitted the hashing from (1) deduplicates the warnings. rdar://138144624
This commit is contained in:
@@ -1093,8 +1093,8 @@ void Module::ReportWarningOptimization(
|
||||
ss << file_name
|
||||
<< " was compiled with optimization - stepping may behave "
|
||||
"oddly; variables may not be available.";
|
||||
Debugger::ReportWarning(std::string(ss.GetString()), debugger_id,
|
||||
&m_optimization_warning);
|
||||
llvm::StringRef msg = ss.GetString();
|
||||
Debugger::ReportWarning(msg.str(), debugger_id, GetDiagnosticOnceFlag(msg));
|
||||
}
|
||||
|
||||
void Module::ReportWarningUnsupportedLanguage(
|
||||
@@ -1104,8 +1104,8 @@ void Module::ReportWarningUnsupportedLanguage(
|
||||
<< Language::GetNameForLanguageType(language)
|
||||
<< "\". "
|
||||
"Inspection of frame variables will be limited.";
|
||||
Debugger::ReportWarning(std::string(ss.GetString()), debugger_id,
|
||||
&m_language_warning);
|
||||
llvm::StringRef msg = ss.GetString();
|
||||
Debugger::ReportWarning(msg.str(), debugger_id, GetDiagnosticOnceFlag(msg));
|
||||
}
|
||||
|
||||
void Module::ReportErrorIfModifyDetected(
|
||||
@@ -1125,20 +1125,29 @@ void Module::ReportErrorIfModifyDetected(
|
||||
}
|
||||
}
|
||||
|
||||
std::once_flag *Module::GetDiagnosticOnceFlag(llvm::StringRef msg) {
|
||||
std::lock_guard<std::recursive_mutex> guard(m_diagnostic_mutex);
|
||||
auto &once_ptr = m_shown_diagnostics[llvm::stable_hash_name(msg)];
|
||||
if (!once_ptr)
|
||||
once_ptr = std::make_unique<std::once_flag>();
|
||||
return once_ptr.get();
|
||||
}
|
||||
|
||||
void Module::ReportError(const llvm::formatv_object_base &payload) {
|
||||
StreamString strm;
|
||||
GetDescription(strm.AsRawOstream(), lldb::eDescriptionLevelBrief);
|
||||
strm.PutChar(' ');
|
||||
strm.PutCString(payload.str());
|
||||
Debugger::ReportError(strm.GetString().str());
|
||||
std::string msg = payload.str();
|
||||
strm << ' ' << msg;
|
||||
Debugger::ReportError(strm.GetString().str(), {}, GetDiagnosticOnceFlag(msg));
|
||||
}
|
||||
|
||||
void Module::ReportWarning(const llvm::formatv_object_base &payload) {
|
||||
StreamString strm;
|
||||
GetDescription(strm.AsRawOstream(), lldb::eDescriptionLevelFull);
|
||||
strm.PutChar(' ');
|
||||
strm.PutCString(payload.str());
|
||||
Debugger::ReportWarning(std::string(strm.GetString()));
|
||||
std::string msg = payload.str();
|
||||
strm << ' ' << msg;
|
||||
Debugger::ReportWarning(strm.GetString().str(), {},
|
||||
GetDiagnosticOnceFlag(msg));
|
||||
}
|
||||
|
||||
void Module::LogMessage(Log *log, const llvm::formatv_object_base &payload) {
|
||||
|
||||
Reference in New Issue
Block a user