Skip to content

Commit 9c0784e

Browse files
committed
[lldb] Fix incorrect uses of LLDB_LOG_ERROR
Fix incorrect uses of LLDB_LOG_ERROR. The macro doesn't automatically inject the error in the log message: it merely passes the error as the first argument to formatv and therefore must be referenced with {0}. Thanks to Nicholas Allegra for collecting a list of places where the macro was misused. rdar://111581655 Differential revision: https://reviews.llvm.org/D154530 (cherry picked from commit e0e36e3)
1 parent de0a10e commit 9c0784e

File tree

15 files changed

+51
-47
lines changed

15 files changed

+51
-47
lines changed

lldb/source/Breakpoint/Watchpoint.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ Watchpoint::Watchpoint(Target &target, lldb::addr_t addr, uint32_t size,
4141
target.GetScratchTypeSystemForLanguage(eLanguageTypeC);
4242
if (auto err = type_system_or_err.takeError()) {
4343
LLDB_LOG_ERROR(GetLog(LLDBLog::Watchpoints), std::move(err),
44-
"Failed to set type.");
44+
"Failed to set type: {0}");
4545
} else {
4646
if (auto ts = *type_system_or_err)
4747
m_type =
4848
ts->GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, 8 * size);
4949
else
5050
LLDB_LOG_ERROR(GetLog(LLDBLog::Watchpoints), std::move(err),
51-
"Failed to set type. Typesystem is no longer live.");
51+
"Failed to set type: Typesystem is no longer live: {0}");
5252
}
5353
}
5454

lldb/source/Core/ValueObjectRegister.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ CompilerType ValueObjectRegister::GetCompilerTypeImpl() {
204204
exe_module->GetTypeSystemForLanguage(eLanguageTypeC);
205205
if (auto err = type_system_or_err.takeError()) {
206206
LLDB_LOG_ERROR(GetLog(LLDBLog::Types), std::move(err),
207-
"Unable to get CompilerType from TypeSystem");
207+
"Unable to get CompilerType from TypeSystem: {0}");
208208
} else {
209209
if (auto ts = *type_system_or_err)
210210
m_compiler_type = ts->GetBuiltinTypeForEncodingAndBitSize(

lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class BlockPointerSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
4545
lldb::eLanguageTypeC_plus_plus);
4646
if (auto err = type_system_or_err.takeError()) {
4747
LLDB_LOG_ERROR(GetLog(LLDBLog::DataFormatters), std::move(err),
48-
"Failed to get scratch TypeSystemClang");
48+
"Failed to get scratch TypeSystemClang: {0}");
4949
return;
5050
}
5151

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,7 +1698,7 @@ AppleObjCRuntimeV2::SharedCacheImageHeaders::CreateSharedCacheImageHeaders(
16981698
entsize));
16991699
if (auto Err = shared_cache_image_headers->UpdateIfNeeded()) {
17001700
LLDB_LOG_ERROR(log, std::move(Err),
1701-
"Failed to update SharedCacheImageHeaders");
1701+
"Failed to update SharedCacheImageHeaders: {0}");
17021702
return nullptr;
17031703
}
17041704

@@ -1758,7 +1758,7 @@ bool AppleObjCRuntimeV2::SharedCacheImageHeaders::IsImageLoaded(
17581758
if (auto Err = UpdateIfNeeded()) {
17591759
Log *log = GetLog(LLDBLog::Process | LLDBLog::Types);
17601760
LLDB_LOG_ERROR(log, std::move(Err),
1761-
"Failed to update SharedCacheImageHeaders");
1761+
"Failed to update SharedCacheImageHeaders: {0}");
17621762
}
17631763
return m_loaded_images.test(image_index);
17641764
}
@@ -1767,7 +1767,7 @@ uint64_t AppleObjCRuntimeV2::SharedCacheImageHeaders::GetVersion() {
17671767
if (auto Err = UpdateIfNeeded()) {
17681768
Log *log = GetLog(LLDBLog::Process | LLDBLog::Types);
17691769
LLDB_LOG_ERROR(log, std::move(Err),
1770-
"Failed to update SharedCacheImageHeaders");
1770+
"Failed to update SharedCacheImageHeaders: {0}");
17711771
}
17721772
return m_version;
17731773
}

lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ bool ProcessKDP::StartAsyncThread() {
730730
"<lldb.process.kdp-remote.async>", [this] { return AsyncThread(); });
731731
if (!async_thread) {
732732
LLDB_LOG_ERROR(GetLog(LLDBLog::Host), async_thread.takeError(),
733-
"failed to launch host thread: {}");
733+
"failed to launch host thread: {0}");
734734
return false;
735735
}
736736
m_async_thread = *async_thread;

lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3411,7 +3411,7 @@ bool ProcessGDBRemote::StartAsyncThread() {
34113411
});
34123412
if (!async_thread) {
34133413
LLDB_LOG_ERROR(GetLog(LLDBLog::Host), async_thread.takeError(),
3414-
"failed to launch host thread: {}");
3414+
"failed to launch host thread: {0}");
34153415
return false;
34163416
}
34173417
m_async_thread = *async_thread;

lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void DWARFDebugAranges::extract(const DWARFDataExtractor &debug_aranges_data) {
4343
Log *log = GetLog(DWARFLog::DebugInfo);
4444
LLDB_LOG_ERROR(log, std::move(error),
4545
"DWARFDebugAranges::extract failed to extract "
46-
".debug_aranges set at offset %#" PRIx64,
46+
".debug_aranges set at offset {1:x}: {0}",
4747
set_offset);
4848
} else {
4949
const uint32_t num_descriptors = set.NumDescriptors();

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ Function *SymbolFileDWARF::ParseFunction(CompileUnit &comp_unit,
828828
auto type_system_or_err = GetTypeSystemForLanguage(GetLanguage(*die.GetCU()));
829829
if (auto err = type_system_or_err.takeError()) {
830830
LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
831-
"Unable to parse function");
831+
"Unable to parse function: {0}");
832832
return nullptr;
833833
}
834834
auto ts = *type_system_or_err;
@@ -876,7 +876,7 @@ SymbolFileDWARF::ConstructFunctionDemangledName(const DWARFDIE &die) {
876876
auto type_system_or_err = GetTypeSystemForLanguage(GetLanguage(*die.GetCU()));
877877
if (auto err = type_system_or_err.takeError()) {
878878
LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
879-
"Unable to construct demangled name for function");
879+
"Unable to construct demangled name for function: {0}");
880880
return ConstString();
881881
}
882882

@@ -1073,7 +1073,7 @@ SymbolFileDWARF::GetTypeUnitSupportFiles(DWARFTypeUnit &tu) {
10731073
Log *log = GetLog(DWARFLog::DebugInfo);
10741074
LLDB_LOG_ERROR(log, std::move(error),
10751075
"SymbolFileDWARF::GetTypeUnitSupportFiles failed to parse "
1076-
"the line table prologue");
1076+
"the line table prologue: {0}");
10771077
};
10781078
ElapsedTime elapsed(m_parse_time);
10791079
llvm::Error error = prologue.parse(data, &line_table_offset, report, ctx);
@@ -2174,7 +2174,7 @@ bool SymbolFileDWARF::DeclContextMatchesThisSymbolFile(
21742174
decl_ctx_type_system->GetMinimumLanguage(nullptr));
21752175
if (auto err = type_system_or_err.takeError()) {
21762176
LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
2177-
"Unable to match namespace decl using TypeSystem");
2177+
"Unable to match namespace decl using TypeSystem: {0}");
21782178
return false;
21792179
}
21802180

@@ -2955,7 +2955,7 @@ TypeSP SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(
29552955
auto type_system_or_err = GetTypeSystemForLanguage(language);
29562956
if (auto err = type_system_or_err.takeError()) {
29572957
LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
2958-
"Cannot get TypeSystem for language {}",
2958+
"Cannot get TypeSystem for language {1}: {0}",
29592959
Language::GetNameForLanguageType(language));
29602960
} else {
29612961
type_system = *type_system_or_err;
@@ -3113,7 +3113,7 @@ TypeSP SymbolFileDWARF::ParseType(const SymbolContext &sc, const DWARFDIE &die,
31133113
auto type_system_or_err = GetTypeSystemForLanguage(GetLanguage(*die.GetCU()));
31143114
if (auto err = type_system_or_err.takeError()) {
31153115
LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
3116-
"Unable to parse type");
3116+
"Unable to parse type: {0}");
31173117
return {};
31183118
}
31193119
auto ts = *type_system_or_err;
@@ -4193,7 +4193,7 @@ DWARFASTParser *SymbolFileDWARF::GetDWARFParser(DWARFUnit &unit) {
41934193
auto type_system_or_err = GetTypeSystem(unit);
41944194
if (auto err = type_system_or_err.takeError()) {
41954195
LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
4196-
"Unable to get DWARFASTParser");
4196+
"Unable to get DWARFASTParser: {0}");
41974197
return nullptr;
41984198
}
41994199
if (auto ts = *type_system_or_err)

lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ void SymbolFileNativePDB::InitializeObject() {
352352
lldb::eLanguageTypeC_plus_plus);
353353
if (auto err = ts_or_err.takeError()) {
354354
LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
355-
"Failed to initialize");
355+
"Failed to initialize: {0}");
356356
} else {
357357
if (auto ts = *ts_or_err)
358358
ts->SetSymbolFile(this);

lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ SymbolFilePDB::ParseCompileUnitFunctionForPDBFunc(const PDBSymbolFunc &pdb_func,
314314
auto type_system_or_err = GetTypeSystemForLanguage(lang);
315315
if (auto err = type_system_or_err.takeError()) {
316316
LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
317-
"Unable to parse PDBFunc");
317+
"Unable to parse PDBFunc: {0}");
318318
return nullptr;
319319
}
320320

@@ -565,7 +565,7 @@ lldb_private::Type *SymbolFilePDB::ResolveTypeUID(lldb::user_id_t type_uid) {
565565
GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus);
566566
if (auto err = type_system_or_err.takeError()) {
567567
LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
568-
"Unable to ResolveTypeUID");
568+
"Unable to ResolveTypeUID: {0}");
569569
return nullptr;
570570
}
571571

@@ -602,7 +602,7 @@ bool SymbolFilePDB::CompleteType(lldb_private::CompilerType &compiler_type) {
602602
GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus);
603603
if (auto err = type_system_or_err.takeError()) {
604604
LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
605-
"Unable to get dynamic array info for UID");
605+
"Unable to get dynamic array info for UID: {0}");
606606
return false;
607607
}
608608
auto ts = *type_system_or_err;
@@ -624,7 +624,7 @@ lldb_private::CompilerDecl SymbolFilePDB::GetDeclForUID(lldb::user_id_t uid) {
624624
GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus);
625625
if (auto err = type_system_or_err.takeError()) {
626626
LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
627-
"Unable to get decl for UID");
627+
"Unable to get decl for UID: {0}");
628628
return CompilerDecl();
629629
}
630630
auto ts = *type_system_or_err;
@@ -654,7 +654,7 @@ SymbolFilePDB::GetDeclContextForUID(lldb::user_id_t uid) {
654654
GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus);
655655
if (auto err = type_system_or_err.takeError()) {
656656
LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
657-
"Unable to get DeclContext for UID");
657+
"Unable to get DeclContext for UID: {0}");
658658
return CompilerDeclContext();
659659
}
660660

@@ -685,7 +685,7 @@ SymbolFilePDB::GetDeclContextContainingUID(lldb::user_id_t uid) {
685685
GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus);
686686
if (auto err = type_system_or_err.takeError()) {
687687
LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
688-
"Unable to get DeclContext containing UID");
688+
"Unable to get DeclContext containing UID: {0}");
689689
return CompilerDeclContext();
690690
}
691691

@@ -715,7 +715,7 @@ void SymbolFilePDB::ParseDeclsForContext(
715715
GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus);
716716
if (auto err = type_system_or_err.takeError()) {
717717
LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
718-
"Unable to parse decls for context");
718+
"Unable to parse decls for context: {0}");
719719
return;
720720
}
721721

@@ -1464,7 +1464,7 @@ void SymbolFilePDB::DumpClangAST(Stream &s) {
14641464
GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus);
14651465
if (auto err = type_system_or_err.takeError()) {
14661466
LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
1467-
"Unable to dump ClangAST");
1467+
"Unable to dump ClangAST: {0}");
14681468
return;
14691469
}
14701470

@@ -1677,7 +1677,7 @@ PDBASTParser *SymbolFilePDB::GetPDBAstParser() {
16771677
GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus);
16781678
if (auto err = type_system_or_err.takeError()) {
16791679
LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
1680-
"Unable to get PDB AST parser");
1680+
"Unable to get PDB AST parser: {0}");
16811681
return nullptr;
16821682
}
16831683

@@ -1698,7 +1698,7 @@ SymbolFilePDB::FindNamespace(lldb_private::ConstString name,
16981698
GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus);
16991699
if (auto err = type_system_or_err.takeError()) {
17001700
LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
1701-
"Unable to find namespace {}", name.AsCString());
1701+
"Unable to find namespace {1}: {0}", name.AsCString());
17021702
return CompilerDeclContext();
17031703
}
17041704
auto ts = *type_system_or_err;
@@ -1993,7 +1993,7 @@ bool SymbolFilePDB::DeclContextMatchesThisSymbolFile(
19931993
if (auto err = type_system_or_err.takeError()) {
19941994
LLDB_LOG_ERROR(
19951995
GetLog(LLDBLog::Symbols), std::move(err),
1996-
"Unable to determine if DeclContext matches this symbol file");
1996+
"Unable to determine if DeclContext matches this symbol file: {0}");
19971997
return false;
19981998
}
19991999

0 commit comments

Comments
 (0)