ayermolo updated this revision to Diff 484259.
ayermolo added a comment.
Herald added subscribers: MaskRay, emaste.
pulled a trigger and changed all the call sites. I think less confusing then
having two sets of APIs. One with printf symantics another with formatv.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D139955/new/
https://reviews.llvm.org/D139955
Files:
lldb/include/lldb/Core/Module.h
lldb/include/lldb/Utility/Status.h
lldb/source/Core/Module.cpp
lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
lldb/source/Symbol/CompileUnit.cpp
lldb/source/Symbol/DWARFCallFrameInfo.cpp
lldb/source/Target/SectionLoadList.cpp
lldb/source/Utility/Status.cpp
lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
lldb/test/Shell/SymbolFile/DWARF/x86/debug_ranges-missing-section.s
Index: lldb/test/Shell/SymbolFile/DWARF/x86/debug_ranges-missing-section.s
===================================================================
--- lldb/test/Shell/SymbolFile/DWARF/x86/debug_ranges-missing-section.s
+++ lldb/test/Shell/SymbolFile/DWARF/x86/debug_ranges-missing-section.s
@@ -2,7 +2,7 @@
# RUN: %lldb %t -o "image lookup -v -s lookup_ranges" -o exit 2>%t.error | FileCheck %s
# RUN: cat %t.error | FileCheck %s --check-prefix ERROR
-# ERROR: DIE has DW_AT_ranges(DW_FORM_sec_offset 0x47) attribute, but range extraction failed (No debug_ranges section),
+# ERROR: DIE has DW_AT_ranges(DW_FORM_sec_offset 0x0000000000000047) attribute, but range extraction failed (No debug_ranges section),
# CHECK: Function: id = {0x0000001c}, name = "ranges", range = [0x0000000000000000-0x0000000000000004)
# CHECK: Blocks: id = {0x0000001c}, range = [0x00000000-0x00000004)
Index: lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
===================================================================
--- lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
+++ lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
@@ -22,7 +22,7 @@
# RUN: cat %t.error | FileCheck --check-prefix=ERROR %s
# RNGLISTX-LABEL: image lookup -v -s lookup_rnglists
-# ERROR: error: {{.*}} {0x0000003f}: DIE has DW_AT_ranges(DW_FORM_rnglistx 0x0) attribute, but range extraction failed (DW_FORM_rnglistx cannot be used without DW_AT_rnglists_base for CU at 0x00000000), please file a bug and attach the file at the start of this error message
+# ERROR: error: {{.*}} [0x000000000000003f]: DIE has DW_AT_ranges(DW_FORM_rnglistx 0x0000000000000000) attribute, but range extraction failed (DW_FORM_rnglistx cannot be used without DW_AT_rnglists_base for CU at 0x0000000000000000), please file a bug and attach the file at the start of this error message
# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj \
# RUN: --defsym RNGLISTX=0 --defsym RNGLISTBASE=0 %s > %t-rnglistbase
@@ -31,7 +31,7 @@
# RUN: cat %t.error | FileCheck --check-prefix=ERRORBASE %s
# RNGLISTBASE-LABEL: image lookup -v -s lookup_rnglists
-# ERRORBASE: error: {{.*}}-rnglistbase {0x00000043}: DIE has DW_AT_ranges(DW_FORM_rnglistx 0x0) attribute, but range extraction failed (invalid range list table index 0; OffsetEntryCount is 0, DW_AT_rnglists_base is 24), please file a bug and attach the file at the start of this error message
+# ERRORBASE: error: {{.*}}-rnglistbase [0x0000000000000043]: DIE has DW_AT_ranges(DW_FORM_rnglistx 0x0000000000000000) attribute, but range extraction failed (invalid range list table index 0; OffsetEntryCount is 0, DW_AT_rnglists_base is 24), please file a bug and attach the file at the start of this error message
.text
rnglists:
Index: lldb/source/Utility/Status.cpp
===================================================================
--- lldb/source/Utility/Status.cpp
+++ lldb/source/Utility/Status.cpp
@@ -51,14 +51,6 @@
: eErrorTypeGeneric),
m_string(EC.message()) {}
-Status::Status(const char *format, ...) : m_string() {
- va_list args;
- va_start(args, format);
- SetErrorToGenericError();
- SetErrorStringWithVarArg(format, args);
- va_end(args);
-}
-
const Status &Status::operator=(llvm::Error error) {
if (!error) {
Clear();
Index: lldb/source/Target/SectionLoadList.cpp
===================================================================
--- lldb/source/Target/SectionLoadList.cpp
+++ lldb/source/Target/SectionLoadList.cpp
@@ -106,8 +106,8 @@
ModuleSP curr_module_sp(ats_pos->second->GetModule());
if (curr_module_sp) {
module_sp->ReportWarning(
- "address 0x%16.16" PRIx64
- " maps to more than one section: %s.%s and %s.%s",
+ "address {0:x+16} maps to more than one section: {1}.{2} and "
+ "{3}.{4}",
load_addr, module_sp->GetFileSpec().GetFilename().GetCString(),
section->GetName().GetCString(),
curr_module_sp->GetFileSpec().GetFilename().GetCString(),
Index: lldb/source/Symbol/DWARFCallFrameInfo.cpp
===================================================================
--- lldb/source/Symbol/DWARFCallFrameInfo.cpp
+++ lldb/source/Symbol/DWARFCallFrameInfo.cpp
@@ -772,12 +772,16 @@
// useful for compilers that move epilogue code into the body of a
// function.)
if (stack.empty()) {
- LLDB_LOGF(log,
- "DWARFCallFrameInfo::%s(dwarf_offset: %" PRIx32
- ", startaddr: %" PRIx64
- " encountered DW_CFA_restore_state but state stack "
- "is empty. Corrupt unwind info?",
- __FUNCTION__, dwarf_offset, startaddr.GetFileAddress());
+ LLDB_LOGF(
+ log, "%s",
+ std::string(
+ llvm::formatv("DWARFCallFrameInfo::{0}(dwarf_offset: "
+ "{1:x+16}, startaddr: [{2:x+16}] encountered "
+ "DW_CFA_restore_state but state stack "
+ "is empty. Corrupt unwind info?",
+ __FUNCTION__, dwarf_offset,
+ startaddr.GetFileAddress()))
+ .c_str());
break;
}
lldb::addr_t offset = row->GetOffset();
Index: lldb/source/Symbol/CompileUnit.cpp
===================================================================
--- lldb/source/Symbol/CompileUnit.cpp
+++ lldb/source/Symbol/CompileUnit.cpp
@@ -361,9 +361,10 @@
// address resolving is completely failing and more deserving of an
// error message the user can see.
resolved_sc.module_sp->ReportError(
- "unable to resolve a line table file address 0x%" PRIx64 " back "
+ "unable to resolve a line table file address {0:x+16} back "
"to a compile unit, please file a bug and attach the address "
- "and file.", line_entry.range.GetBaseAddress().GetFileAddress());
+ "and file.",
+ line_entry.range.GetBaseAddress().GetFileAddress());
}
sc_list.Append(sc);
}
Index: lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
+++ lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
@@ -1260,7 +1260,7 @@
auto member_comp_type = member_type->GetLayoutCompilerType();
if (!member_comp_type.GetCompleteType()) {
symbol_file.GetObjectFile()->GetModule()->ReportError(
- ":: Class '%s' has a member '%s' of type '%s' "
+ ":: Class '{0}' has a member '{1}' of type '{2}' "
"which does not have a complete definition.",
record_type.GetTypeName().GetCString(), member_name.c_str(),
member_comp_type.GetTypeName().GetCString());
@@ -1370,7 +1370,7 @@
auto base_comp_type = base_type->GetFullCompilerType();
if (!base_comp_type.GetCompleteType()) {
symbol_file.GetObjectFile()->GetModule()->ReportError(
- ":: Class '%s' has a base class '%s' "
+ ":: Class '{0}' has a base class '{1}' "
"which does not have a complete definition.",
record_type.GetTypeName().GetCString(),
base_comp_type.GetTypeName().GetCString());
@@ -1429,7 +1429,7 @@
CompilerType method_comp_type = method_type->GetFullCompilerType();
if (!method_comp_type.GetCompleteType()) {
symbol_file.GetObjectFile()->GetModule()->ReportError(
- ":: Class '%s' has a method '%s' whose type cannot be completed.",
+ ":: Class '{0}' has a method '{1}' whose type cannot be completed.",
record_type.GetTypeName().GetCString(),
method_comp_type.GetTypeName().GetCString());
if (TypeSystemClang::StartTagDeclarationDefinition(method_comp_type))
Index: lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -423,8 +423,9 @@
child_block->AddRange(Block::Range(block_base - func_base, block.CodeSize));
else {
GetObjectFile()->GetModule()->ReportError(
- "S_BLOCK32 at modi: %d offset: %d: adding range [0x%" PRIx64
- "-0x%" PRIx64 ") which has a base that is less than the function's "
+ "S_BLOCK32 at modi: {0:d} offset: {1:d}: adding range "
+ "[{2:x+16}-{3:x+16}) which has a base that is less than the "
+ "function's "
"low PC 0x%" PRIx64 ". Please file a bug and attach the file at the "
"start of this error message",
block_id.modi, block_id.offset, block_base,
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -351,7 +351,8 @@
// "i"
if (sibling_idx == UINT32_MAX) {
m_objfile_sp->GetModule()->ReportError(
- "N_SO in symbol with UID %u has invalid sibling in debug map, "
+ "N_SO in symbol with UID {0} has invalid sibling in debug "
+ "map, "
"please file a bug and attach the binary listed in this error",
so_symbol->GetID());
} else {
@@ -367,22 +368,25 @@
} else {
if (oso_symbol == nullptr)
m_objfile_sp->GetModule()->ReportError(
- "N_OSO symbol[%u] can't be found, please file a bug and attach "
+ "N_OSO symbol[{0}] can't be found, please file a bug and "
+ "attach "
"the binary listed in this error",
oso_idx);
else if (so_symbol == nullptr)
m_objfile_sp->GetModule()->ReportError(
- "N_SO not found for N_OSO symbol[%u], please file a bug and "
+ "N_SO not found for N_OSO symbol[{0}], please file a bug and "
"attach the binary listed in this error",
oso_idx);
else if (so_symbol->GetType() != eSymbolTypeSourceFile)
m_objfile_sp->GetModule()->ReportError(
- "N_SO has incorrect symbol type (%u) for N_OSO symbol[%u], "
+ "N_SO has incorrect symbol type ({0}) for N_OSO "
+ "symbol[{1}], "
"please file a bug and attach the binary listed in this error",
so_symbol->GetType(), oso_idx);
else if (oso_symbol->GetType() != eSymbolTypeSourceFile)
m_objfile_sp->GetModule()->ReportError(
- "N_OSO has incorrect symbol type (%u) for N_OSO symbol[%u], "
+ "N_OSO has incorrect symbol type ({0}) for N_OSO "
+ "symbol[{1}], "
"please file a bug and attach the binary listed in this error",
oso_symbol->GetType(), oso_idx);
}
@@ -429,8 +433,8 @@
"will not be loaded", oso_file.GetPath().c_str(),
(uint32_t)llvm::sys::toTimeT(oso_mod_time),
(uint32_t)llvm::sys::toTimeT(comp_unit_info->oso_mod_time));
- obj_file->GetModule()->ReportError("%s",
- comp_unit_info->oso_load_error.AsCString());
+ obj_file->GetModule()->ReportError(
+ "{0}", comp_unit_info->oso_load_error.AsCString());
return nullptr;
}
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -8,11 +8,29 @@
#include "SymbolFileDWARF.h"
-#include "llvm/ADT/Optional.h"
-#include "llvm/DebugInfo/DWARF/DWARFDebugLoc.h"
-#include "llvm/Support/Casting.h"
-#include "llvm/Support/Threading.h"
-
+#include "AppleDWARFIndex.h"
+#include "DWARFASTParser.h"
+#include "DWARFASTParserClang.h"
+#include "DWARFCompileUnit.h"
+#include "DWARFDebugAbbrev.h"
+#include "DWARFDebugAranges.h"
+#include "DWARFDebugInfo.h"
+#include "DWARFDebugMacro.h"
+#include "DWARFDebugRanges.h"
+#include "DWARFDeclContext.h"
+#include "DWARFFormValue.h"
+#include "DWARFTypeUnit.h"
+#include "DWARFUnit.h"
+#include "DebugNamesDWARFIndex.h"
+#include "LogChannelDWARF.h"
+#include "ManualDWARFIndex.h"
+#include "Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h"
+#include "Plugins/ExpressionParser/Clang/ClangUtil.h"
+#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
+#include "Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
+#include "SymbolFileDWARFDebugMap.h"
+#include "SymbolFileDWARFDwo.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleList.h"
#include "lldb/Core/ModuleSpec.h"
@@ -21,25 +39,10 @@
#include "lldb/Core/Section.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/Value.h"
-#include "lldb/Utility/ArchSpec.h"
-#include "lldb/Utility/LLDBLog.h"
-#include "lldb/Utility/RegularExpression.h"
-#include "lldb/Utility/Scalar.h"
-#include "lldb/Utility/StreamString.h"
-#include "lldb/Utility/Timer.h"
-
-#include "Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h"
-#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
-
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
-
#include "lldb/Interpreter/OptionValueFileSpecList.h"
#include "lldb/Interpreter/OptionValueProperties.h"
-
-#include "Plugins/ExpressionParser/Clang/ClangUtil.h"
-#include "Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h"
-#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Symbol/Block.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/CompilerDecl.h"
@@ -52,39 +55,26 @@
#include "lldb/Symbol/TypeMap.h"
#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Symbol/VariableList.h"
-
#include "lldb/Target/Language.h"
#include "lldb/Target/Target.h"
-
-#include "AppleDWARFIndex.h"
-#include "DWARFASTParser.h"
-#include "DWARFASTParserClang.h"
-#include "DWARFCompileUnit.h"
-#include "DWARFDebugAbbrev.h"
-#include "DWARFDebugAranges.h"
-#include "DWARFDebugInfo.h"
-#include "DWARFDebugMacro.h"
-#include "DWARFDebugRanges.h"
-#include "DWARFDeclContext.h"
-#include "DWARFFormValue.h"
-#include "DWARFTypeUnit.h"
-#include "DWARFUnit.h"
-#include "DebugNamesDWARFIndex.h"
-#include "LogChannelDWARF.h"
-#include "ManualDWARFIndex.h"
-#include "SymbolFileDWARFDebugMap.h"
-#include "SymbolFileDWARFDwo.h"
-
+#include "lldb/Utility/ArchSpec.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/RegularExpression.h"
+#include "lldb/Utility/Scalar.h"
+#include "lldb/Utility/StreamString.h"
+#include "lldb/Utility/Timer.h"
+#include "llvm/ADT/Optional.h"
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
+#include "llvm/DebugInfo/DWARF/DWARFDebugLoc.h"
+#include "llvm/Support/Casting.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FormatVariadic.h"
-
+#include "llvm/Support/Threading.h"
#include <algorithm>
-#include <map>
-#include <memory>
-
#include <cctype>
#include <cstring>
+#include <map>
+#include <memory>
//#define ENABLE_DEBUG_PRINTF // COMMENT OUT THIS LINE PRIOR TO CHECKIN
@@ -556,7 +546,7 @@
for (auto form : invalid_forms)
error.Printf(" %#x", form);
m_objfile_sp->GetModule()->ReportWarning(
- "%s", error.GetString().str().c_str());
+ "{0}", error.GetString().str().c_str());
return 0;
}
}
@@ -1314,9 +1304,9 @@
range.GetByteSize()));
else {
GetObjectFile()->GetModule()->ReportError(
- "0x%8.8" PRIx64 ": adding range [0x%" PRIx64 "-0x%" PRIx64
- ") which has a base that is less than the function's low PC "
- "0x%" PRIx64 ". Please file a bug and attach the file at the "
+ "{0x:+8}: adding range [{1:x+16}-{2:x+16}) which has a base "
+ "that is less than the function's low PC {3:x+16}. Please file "
+ "a bug and attach the file at the "
"start of this error message",
block->GetID(), range_base, range.GetRangeEnd(),
subprogram_low_pc);
@@ -1520,7 +1510,7 @@
Log *log = GetLog(DWARFLog::DebugInfo);
if (log)
GetObjectFile()->GetModule()->LogMessage(
- log, "SymbolFileDWARF::ResolveTypeUID (die = 0x%8.8x) %s '%s'",
+ log, "SymbolFileDWARF::ResolveTypeUID (die = {0:x+16}) {1} '{2}'",
die.GetOffset(), die.GetTagAsCString(), die.GetName());
// We might be coming in in the middle of a type tree (a class within a
@@ -1537,8 +1527,9 @@
if (log)
GetObjectFile()->GetModule()->LogMessage(
log,
- "SymbolFileDWARF::ResolveTypeUID (die = 0x%8.8x) %s '%s' "
- "resolve parent forward type for 0x%8.8x",
+ "SymbolFileDWARF::ResolveTypeUID (die = {0:x+16}) "
+ "{1} '{2}' "
+ "resolve parent forward type for {3:x+16})",
die.GetOffset(), die.GetTagAsCString(), die.GetName(),
decl_ctx_die.GetOffset());
} break;
@@ -1629,7 +1620,7 @@
return type;
GetObjectFile()->GetModule()->ReportError(
- "Parsing a die that is being parsed die: 0x%8.8x: %s %s",
+ "Parsing a die that is being parsed die: {0:x+16}: {1} {2}",
die.GetOffset(), die.GetTagAsCString(), die.GetName());
} else
@@ -1744,7 +1735,7 @@
const char *dwo_name = GetDWOName(*dwarf_cu, cu_die);
if (!dwo_name) {
- unit.SetDwoError(Status("missing DWO name in skeleton DIE 0x%8.8" PRIx32,
+ unit.SetDwoError(Status("missing DWO name in skeleton DIE {0:x+16}",
cu_die.GetOffset()));
return nullptr;
}
@@ -1760,9 +1751,10 @@
nullptr);
if (!comp_dir) {
unit.SetDwoError(
- Status("unable to locate relative .dwo debug file \"%s\" for "
- "skeleton DIE 0x%8.8" PRIx32 " without valid DW_AT_comp_dir "
- "attribute", dwo_name, cu_die.GetOffset()));
+ Status("unable to locate relative .dwo debug file \"{0}\" for "
+ "skeleton DIE {1:x+16} without valid DW_AT_comp_dir "
+ "attribute",
+ dwo_name, cu_die.GetOffset()));
return nullptr;
}
@@ -1780,9 +1772,9 @@
if (!FileSystem::Instance().Exists(dwo_file)) {
unit.SetDwoError(
- Status("unable to locate .dwo debug file \"%s\" for skeleton DIE "
- "0x%8.8" PRIx32, dwo_file.GetPath().c_str(),
- cu_die.GetOffset()));
+ Status("unable to locate .dwo debug file \"{0}\" for skeleton DIE "
+ "{1:x+16}",
+ dwo_file.GetPath().c_str(), cu_die.GetOffset()));
if (m_dwo_warning_issued.test_and_set(std::memory_order_relaxed) == false) {
GetObjectFile()->GetModule()->ReportWarning(
@@ -1801,8 +1793,9 @@
dwo_file_data_offset);
if (dwo_obj_file == nullptr) {
unit.SetDwoError(
- Status("unable to load object file for .dwo debug file \"%s\" for "
- "unit DIE 0x%8.8" PRIx32, dwo_name, cu_die.GetOffset()));
+ Status("unable to load object file for .dwo debug file \"{0}\" for "
+ "unit DIE {1:x+16}",
+ dwo_name, cu_die.GetOffset()));
return nullptr;
}
@@ -1878,8 +1871,8 @@
nullptr, nullptr, nullptr);
if (!module_sp) {
GetObjectFile()->GetModule()->ReportWarning(
- "0x%8.8x: unable to locate module needed for external types: "
- "%s\nerror: %s\nDebugging will be degraded due to missing "
+ "{0:x+16}: unable to locate module needed for external types: "
+ "{1}\nerror: {2}\nDebugging will be degraded due to missing "
"types. Rebuilding the project will regenerate the needed "
"module files.",
die.GetOffset(), dwo_module_spec.GetFileSpec().GetPath().c_str(),
@@ -1903,7 +1896,8 @@
if (dwo_id != dwo_dwo_id) {
GetObjectFile()->GetModule()->ReportWarning(
- "0x%8.8x: Module %s is out-of-date (hash mismatch). Type information "
+ "{0:x+16}: Module {1} is out-of-date (hash mismatch). Type "
+ "information "
"from this module may be incomplete or inconsistent with the rest of "
"the program. Rebuilding the project will regenerate the needed "
"module files.",
@@ -2083,7 +2077,7 @@
}
} else {
GetObjectFile()->GetModule()->ReportWarning(
- "0x%8.8x: compile unit %u failed to create a valid "
+ "{0:x+16}: compile unit {1} failed to create a valid "
"lldb_private::CompileUnit class.",
cu_offset, cu_idx);
}
@@ -2177,8 +2171,8 @@
if (log)
GetObjectFile()->GetModule()->LogMessage(
log,
- "SymbolFileDWARF::FindGlobalVariables (name=\"%s\", "
- "parent_decl_ctx=%p, max_matches=%u, variables)",
+ "SymbolFileDWARF::FindGlobalVariables (name=\"{0}\", "
+ "parent_decl_ctx={1:p}, max_matches={2}, variables)",
name.GetCString(), static_cast<const void *>(&parent_decl_ctx),
max_matches);
@@ -2243,8 +2237,8 @@
if (log && num_matches > 0) {
GetObjectFile()->GetModule()->LogMessage(
log,
- "SymbolFileDWARF::FindGlobalVariables (name=\"%s\", "
- "parent_decl_ctx=%p, max_matches=%u, variables) => %u",
+ "SymbolFileDWARF::FindGlobalVariables (name=\"{0}\", "
+ "parent_decl_ctx={1:p}, max_matches={2}, variables) => {3}",
name.GetCString(), static_cast<const void *>(&parent_decl_ctx),
max_matches, num_matches);
}
@@ -2259,8 +2253,8 @@
if (log) {
GetObjectFile()->GetModule()->LogMessage(
log,
- "SymbolFileDWARF::FindGlobalVariables (regex=\"%s\", "
- "max_matches=%u, variables)",
+ "SymbolFileDWARF::FindGlobalVariables (regex=\"{0}\", "
+ "max_matches={1}, variables)",
regex.GetText().str().c_str(), max_matches);
}
@@ -2370,7 +2364,7 @@
if (log) {
GetObjectFile()->GetModule()->LogMessage(
log,
- "SymbolFileDWARF::FindFunctions (name=\"%s\", name_type_mask=0x%x, "
+ "SymbolFileDWARF::FindFunctions (name=\"{0}\", name_type_mask={1:x}, "
"sc_list)",
name.GetCString(), name_type_mask);
}
@@ -2419,8 +2413,8 @@
if (log && num_matches > 0) {
GetObjectFile()->GetModule()->LogMessage(
log,
- "SymbolFileDWARF::FindFunctions (name=\"%s\", "
- "name_type_mask=0x%x, include_inlines=%d, sc_list) => %u",
+ "SymbolFileDWARF::FindFunctions (name=\"{0}\", "
+ "name_type_mask={1:x}, include_inlines={2:d}, sc_list) => {3}",
name.GetCString(), name_type_mask, include_inlines, num_matches);
}
}
@@ -2436,7 +2430,7 @@
if (log) {
GetObjectFile()->GetModule()->LogMessage(
- log, "SymbolFileDWARF::FindFunctions (regex=\"%s\", sc_list)",
+ log, "SymbolFileDWARF::FindFunctions (regex=\"{0}\", sc_list)",
regex.GetText().str().c_str());
}
@@ -2486,15 +2480,15 @@
if (parent_decl_ctx)
GetObjectFile()->GetModule()->LogMessage(
log,
- "SymbolFileDWARF::FindTypes (sc, name=\"%s\", parent_decl_ctx = "
- "%p (\"%s\"), max_matches=%u, type_list)",
+ "SymbolFileDWARF::FindTypes (sc, name=\"{0}\", parent_decl_ctx = "
+ "{1:p} (\"{2}\"), max_matches={3}, type_list)",
name.GetCString(), static_cast<const void *>(&parent_decl_ctx),
parent_decl_ctx.GetName().AsCString("<NULL>"), max_matches);
else
GetObjectFile()->GetModule()->LogMessage(
log,
- "SymbolFileDWARF::FindTypes (sc, name=\"%s\", parent_decl_ctx = "
- "NULL, max_matches=%u, type_list)",
+ "SymbolFileDWARF::FindTypes (sc, name=\"{0}\", parent_decl_ctx = "
+ "NULL, max_matches={1}, type_list)",
name.GetCString(), max_matches);
}
@@ -2571,16 +2565,16 @@
if (parent_decl_ctx) {
GetObjectFile()->GetModule()->LogMessage(
log,
- "SymbolFileDWARF::FindTypes (sc, name=\"%s\", parent_decl_ctx "
- "= %p (\"%s\"), max_matches=%u, type_list) => %u",
+ "SymbolFileDWARF::FindTypes (sc, name=\"{0}\", parent_decl_ctx "
+ "= {1:p} (\"{2}\"), max_matches={3}, type_list) => {4}",
name.GetCString(), static_cast<const void *>(&parent_decl_ctx),
parent_decl_ctx.GetName().AsCString("<NULL>"), max_matches,
types.GetSize());
} else {
GetObjectFile()->GetModule()->LogMessage(
log,
- "SymbolFileDWARF::FindTypes (sc, name=\"%s\", parent_decl_ctx "
- "= NULL, max_matches=%u, type_list) => %u",
+ "SymbolFileDWARF::FindTypes (sc, name=\"{0}\", parent_decl_ctx "
+ "= NULL, max_matches={1}, type_list) => {2}",
name.GetCString(), max_matches, types.GetSize());
}
}
@@ -2638,7 +2632,7 @@
if (log) {
GetObjectFile()->GetModule()->LogMessage(
- log, "SymbolFileDWARF::FindNamespace (sc, name=\"%s\")",
+ log, "SymbolFileDWARF::FindNamespace (sc, name=\"{0}\")",
name.GetCString());
}
@@ -2662,8 +2656,8 @@
if (log && namespace_decl_ctx) {
GetObjectFile()->GetModule()->LogMessage(
log,
- "SymbolFileDWARF::FindNamespace (sc, name=\"%s\") => "
- "CompilerDeclContext(%p/%p) \"%s\"",
+ "SymbolFileDWARF::FindNamespace (sc, name=\"{0}\") => "
+ "CompilerDeclContext({1:p}/{2:p}) \"{3}\"",
name.GetCString(),
static_cast<const void *>(namespace_decl_ctx.GetTypeSystem()),
static_cast<const void *>(namespace_decl_ctx.GetOpaqueDeclContext()),
@@ -2958,7 +2952,7 @@
GetObjectFile()->GetModule()->LogMessage(
log,
"SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(tag=%"
- "s, name='%s')",
+ "s, name='{0}')",
DW_TAG_value_to_name(tag), die.GetName());
}
@@ -3021,8 +3015,8 @@
GetObjectFile()->GetModule()->LogMessage(
log,
"SymbolFileDWARF::"
- "FindDefinitionTypeForDWARFDeclContext(tag=%s, "
- "name='%s') ignoring die=0x%8.8x (%s)",
+ "FindDefinitionTypeForDWARFDeclContext(tag={0}, "
+ "name='{1}') ignoring die={2:x+16} ({3})",
DW_TAG_value_to_name(tag), die.GetName(), type_die.GetOffset(),
type_die.GetName());
}
@@ -3034,9 +3028,10 @@
if (log) {
GetObjectFile()->GetModule()->LogMessage(
log,
+
"SymbolFileDWARF::"
- "FindDefinitionTypeForDWARFDeclContext(tag=%s, "
- "name='%s') trying die=0x%8.8x (%s)",
+ "FindDefinitionTypeForDWARFDeclContext(tag={0}, "
+ "name='{1}') trying die={2:x+16} ({3})",
DW_TAG_value_to_name(tag), die.GetName(), type_die.GetOffset(),
type_dwarf_decl_ctx.GetQualifiedName());
}
@@ -3431,7 +3426,7 @@
StreamString strm;
location->DumpLocation(&strm, eDescriptionLevelFull, nullptr);
GetObjectFile()->GetModule()->ReportError(
- "0x%8.8x: %s has an invalid location: %s", die.GetOffset(),
+ "{0:x+16}: {1} has an invalid location: {2}", die.GetOffset(),
die.GetTagAsCString(), strm.GetData());
}
if (location_DW_OP_addr != LLDB_INVALID_ADDRESS)
@@ -3652,8 +3647,8 @@
variable_list_sp = sc.comp_unit->GetVariableList(false);
} else {
GetObjectFile()->GetModule()->ReportError(
- "parent 0x%8.8" PRIx64 " %s with no valid compile unit in "
- "symbol context for 0x%8.8" PRIx64 " %s.\n",
+ "parent {0:x+8} {1} with no valid compile unit in "
+ "symbol context for {2:x+8} {3}.\n",
sc_parent_die.GetID(), sc_parent_die.GetTagAsCString(), die.GetID(),
die.GetTagAsCString());
return;
@@ -3662,8 +3657,8 @@
default:
GetObjectFile()->GetModule()->ReportError(
- "didn't find appropriate parent DIE for variable list for "
- "0x%8.8" PRIx64 " %s.\n",
+ "didn't find appropriate parent DIE for variable list for {0:x+8} "
+ "{1}.\n",
die.GetID(), die.GetTagAsCString());
return;
}
Index: lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -142,7 +142,7 @@
if (log) {
m_module.LogMessage(
- log, "ManualDWARFIndex::IndexUnit for unit at .debug_info[0x%8.8x]",
+ log, "ManualDWARFIndex::IndexUnit for unit at .debug_info[{0:x+16}]",
unit.GetOffset());
}
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -87,11 +87,11 @@
DWARFUnit *dwo_cu = dwo_symbol_file->GetDWOCompileUnitForHash(*m_dwo_id);
if (!dwo_cu) {
- SetDwoError(
- Status("unable to load .dwo file from \"%s\" due to ID (0x%16.16" PRIx64
- ") mismatch for skeleton DIE at 0x%8.8" PRIx32,
- dwo_symbol_file->GetObjectFile()->GetFileSpec().GetPath().c_str(),
- *m_dwo_id, m_first_die.GetOffset()));
+ SetDwoError(Status(
+ "unable to load .dwo file from \"{0}\" due to ID ({1:x+16}) mismatch "
+ "for skeleton DIE at {2:x+8}",
+ dwo_symbol_file->GetObjectFile()->GetFileSpec().GetPath().c_str(),
+ *m_dwo_id, m_first_die.GetOffset()));
return; // Can't fetch the compile unit from the dwo file.
}
dwo_cu->SetUserData(this);
@@ -101,7 +101,8 @@
// Can't fetch the compile unit DIE from the dwo file.
SetDwoError(
Status("unable to extract compile unit DIE from .dwo file for skeleton "
- "DIE at 0x%8.8" PRIx32, m_first_die.GetOffset()));
+ "DIE at {0:x+16}",
+ m_first_die.GetOffset()));
return;
}
@@ -212,7 +213,11 @@
llvm::sys::ScopedWriter first_die_lock(m_first_die_mutex);
ElapsedTime elapsed(m_dwarf.GetDebugInfoParseTimeRef());
- LLDB_SCOPED_TIMERF("%8.8x: DWARFUnit::ExtractDIEsIfNeeded()", GetOffset());
+ LLDB_SCOPED_TIMERF(
+ "%s",
+ std::string(llvm::formatv("{0:x+16}: DWARFUnit::ExtractDIEsIfNeeded()",
+ GetOffset()))
+ .c_str());
// Set the offset to that of the first DIE and calculate the start of the
// next compilation unit header.
@@ -479,7 +484,7 @@
if (!contribution) {
GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
"Failed to find location list contribution for CU with DWO Id "
- "0x%" PRIx64,
+ "{0:x+16}",
*GetDWOId());
return;
}
@@ -497,8 +502,8 @@
m_dwarf.GetDWARFContext().getOrLoadLocListsData().GetAsLLVM(),
&offset)) {
GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
- "Failed to extract location list table at offset 0x%" PRIx64
- " (location list base: 0x%" PRIx64 "): %s",
+ "Failed to extract location list table at offset {0:x+16} (location "
+ "list base: {1:x+16}): {2}",
offset, loclists_base, toString(std::move(E)).c_str());
}
}
@@ -537,8 +542,7 @@
return DWARFDataExtractor(data, contribution->Offset,
contribution->Length);
GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
- "Failed to find range list contribution for CU with signature "
- "0x%" PRIx64,
+ "Failed to find range list contribution for CU with signature {0:x+16}",
entry->getSignature());
return DWARFDataExtractor();
@@ -562,7 +566,7 @@
m_rnglist_table = std::move(table_or_error.get());
else
GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
- "Failed to extract range list table at offset 0x%" PRIx64 ": %s",
+ "Failed to extract range list table at offset {0:x+16}: {1}",
m_ranges_base, toString(table_or_error.takeError()).c_str());
}
return m_rnglist_table;
@@ -574,10 +578,12 @@
return llvm::createStringError(std::errc::invalid_argument,
"missing or invalid range list table");
if (!m_ranges_base)
- return llvm::createStringError(std::errc::invalid_argument,
- "DW_FORM_rnglistx cannot be used without "
- "DW_AT_rnglists_base for CU at 0x%8.8x",
- GetOffset());
+ return llvm::createStringError(
+ std::errc::invalid_argument,
+ std::string(llvm::formatv("DW_FORM_rnglistx cannot be used without "
+ "DW_AT_rnglists_base for CU at {0:x+16}",
+ GetOffset()))
+ .c_str());
if (std::optional<uint64_t> off = GetRnglistTable()->getOffsetEntry(
GetRnglistData().GetAsLLVM(), Index))
return *off + m_ranges_base;
@@ -636,8 +642,8 @@
if (!ContainsDIEOffset(die_offset)) {
GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
- "GetDIE for DIE 0x%" PRIx32 " is outside of its CU 0x%" PRIx32,
- die_offset, GetOffset());
+ "GetDIE for DIE {0:x+16} is outside of its CU {0:x+16}", die_offset,
+ GetOffset());
return DWARFDIE(); // Not found
}
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.cpp
@@ -15,9 +15,14 @@
using namespace lldb_private;
void DWARFTypeUnit::Dump(Stream *s) const {
- s->Printf("0x%8.8x: Type Unit: length = 0x%8.8x, version = 0x%4.4x, "
- "abbr_offset = 0x%8.8x, addr_size = 0x%2.2x (next CU at "
- "{0x%8.8x})\n",
- GetOffset(), GetLength(), GetVersion(), GetAbbrevOffset(),
- GetAddressByteSize(), GetNextUnitOffset());
+ s->Printf("%s",
+ std::string(
+ llvm::formatv(
+ "{0:x+16}: Type Unit: length = {1:x+8}, version = {2:x+4}, "
+ "abbr_offset = {3:x+8}, addr_size = {4:x+2} (next CU at "
+ "[{5:x+16}])\n",
+ GetOffset(), (uint32_t)GetLength(), GetVersion(),
+ (uint32_t)GetAbbrevOffset(), GetAddressByteSize(),
+ GetNextUnitOffset()))
+ .c_str());
}
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
@@ -102,6 +102,6 @@
void DWARFIndex::ReportInvalidDIERef(DIERef ref, llvm::StringRef name) const {
m_module.ReportErrorIfModifyDetected(
"the DWARF debug information has been modified (accelerator table had "
- "bad die 0x%8.8x for '%s')\n",
+ "bad die {0:x+16} for '{1}')\n",
ref.die_offset(), name.str().c_str());
}
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
@@ -512,8 +512,7 @@
value += m_unit->GetOffset();
if (!m_unit->ContainsDIEOffset(value)) {
m_unit->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
- "DW_FORM_ref* DIE reference 0x%" PRIx64 " is outside of its CU",
- value);
+ "DW_FORM_ref* DIE reference {0:x+16} is outside of its CU", value);
return {};
}
return const_cast<DWARFUnit *>(m_unit)->GetDIE(value);
@@ -524,8 +523,7 @@
DIERef::Section::DebugInfo, value);
if (!ref_cu) {
m_unit->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
- "DW_FORM_ref_addr DIE reference 0x%" PRIx64 " has no matching CU",
- value);
+ "DW_FORM_ref_addr DIE reference {0:x+16} has no matching CU", value);
return {};
}
return ref_cu->GetDIE(value);
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -60,9 +60,10 @@
const auto *abbrevDecl = GetAbbreviationDeclarationPtr(cu);
if (abbrevDecl == nullptr) {
cu->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
- "{0x%8.8x}: invalid abbreviation code %u, please file a bug and "
+ "[{0:x+16}]: invalid abbreviation code {1}, "
+ "please file a bug and "
"attach the file at the start of this error message",
- m_offset, (unsigned)abbr_idx);
+ (uint64_t)m_offset, (unsigned)abbr_idx);
// WE can't parse anymore if the DWARF is borked...
*offset_ptr = UINT32_MAX;
return false;
@@ -190,9 +191,10 @@
default:
cu->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
- "{0x%8.8x}: Unsupported DW_FORM_0x%x, please file a bug and "
+ "[{0:x+16}]: Unsupported DW_FORM_{1:x}, please file a bug "
+ "and "
"attach the file at the start of this error message",
- m_offset, (unsigned)form);
+ (uint64_t)m_offset, (unsigned)form);
*offset_ptr = m_offset;
return false;
}
@@ -214,9 +216,10 @@
: unit.FindRnglistFromOffset(value.Unsigned());
if (expected_ranges)
return std::move(*expected_ranges);
+
unit.GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
- "{0x%8.8x}: DIE has DW_AT_ranges(%s 0x%" PRIx64 ") attribute, but "
- "range extraction failed (%s), please file a bug "
+ "[{0:x+16}]: DIE has DW_AT_ranges({1} {2:x+16}) attribute, but "
+ "range extraction failed ({3}), please file a bug "
"and attach the file at the start of this error message",
die.GetOffset(),
llvm::dwarf::FormEncodingString(value.Form()).str().c_str(),
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
@@ -18,11 +18,17 @@
using namespace lldb_private;
void DWARFCompileUnit::Dump(Stream *s) const {
- s->Printf("0x%8.8x: Compile Unit: length = 0x%8.8x, version = 0x%4.4x, "
- "abbr_offset = 0x%8.8x, addr_size = 0x%2.2x (next CU at "
- "{0x%8.8x})\n",
- GetOffset(), GetLength(), GetVersion(), GetAbbrevOffset(),
- GetAddressByteSize(), GetNextUnitOffset());
+ s->Printf(
+ "%s",
+ std::string(
+ llvm::formatv(
+ "{0:x+16}: Compile Unit: length = {1:x+8}, version = {2:x}, "
+ "abbr_offset = {3:x+8}, addr_size = {4:x+2} (next CU at "
+ "[{5:x+16}])\n",
+ GetOffset(), GetLength(), GetVersion(),
+ (uint32_t)GetAbbrevOffset(), GetAddressByteSize(),
+ GetNextUnitOffset()))
+ .c_str());
}
void DWARFCompileUnit::BuildAddressRangeTable(
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -45,6 +45,7 @@
#include <map>
#include <memory>
+#include <string>
#include <vector>
//#define ENABLE_DEBUG_PRINTF // COMMENT OUT THIS LINE PRIOR TO CHECKIN
@@ -257,8 +258,8 @@
if (ast_importer.RequireCompleteType(qual_type))
return;
die.GetDWARF()->GetObjectFile()->GetModule()->ReportError(
- "Unable to complete the Decl context for DIE '%s' at offset "
- "0x%8.8x.\nPlease file a bug report.",
+ "Unable to complete the Decl context for DIE {0} at offset "
+ "{1:x+16}.\nPlease file a bug report.",
type_name_cstr ? type_name_cstr : "", die.GetOffset());
}
@@ -428,7 +429,8 @@
dwarf->GetObjectFile()->GetModule()->LogMessage(
log,
"DWARFASTParserClang::ParseTypeFromDWARF "
- "(die = 0x%8.8x, decl_ctx = %p (die 0x%8.8x)) %s name = '%s')",
+ "(die = {0:x+16}, decl_ctx = {1:p} (die "
+ "{2:16+x})) (3:s) name = '{4}')",
die.GetOffset(), static_cast<void *>(context), context_die.GetOffset(),
die.GetTagAsCString(), die.GetName());
}
@@ -505,7 +507,8 @@
}
default:
dwarf->GetObjectFile()->GetModule()->ReportError(
- "{0x%8.8x}: unhandled type tag 0x%4.4x (%s), please file a bug and "
+ "[{0:x+16}]: unhandled type tag {1:x+4} ({2}), "
+ "please file a bug and "
"attach the file at the start of this error message",
die.GetOffset(), tag, DW_TAG_value_to_name(tag));
break;
@@ -674,7 +677,7 @@
if (log)
dwarf->GetObjectFile()->GetModule()->LogMessage(
log,
- "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' "
+ "SymbolFileDWARF::ParseType (die = {0:16+x}) {1} '{2}' "
"is Objective-C 'id' built-in type.",
die.GetOffset(), die.GetTagAsCString(), die.GetName());
clang_type = m_ast.GetBasicType(eBasicTypeObjCID);
@@ -685,7 +688,7 @@
if (log)
dwarf->GetObjectFile()->GetModule()->LogMessage(
log,
- "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' "
+ "SymbolFileDWARF::ParseType (die = {0:x+16}) {1} '{2}' "
"is Objective-C 'Class' built-in type.",
die.GetOffset(), die.GetTagAsCString(), die.GetName());
clang_type = m_ast.GetBasicType(eBasicTypeObjCClass);
@@ -696,7 +699,7 @@
if (log)
dwarf->GetObjectFile()->GetModule()->LogMessage(
log,
- "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' "
+ "SymbolFileDWARF::ParseType (die = {0:x+16}) {1} '{2}' "
"is Objective-C 'selector' built-in type.",
die.GetOffset(), die.GetTagAsCString(), die.GetName());
clang_type = m_ast.GetBasicType(eBasicTypeObjCSel);
@@ -717,8 +720,8 @@
if (log)
dwarf->GetObjectFile()->GetModule()->LogMessage(
log,
- "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s "
- "'%s' is 'objc_object*', which we overrode to "
+ "SymbolFileDWARF::ParseType (die = {0:x+16}) {1} "
+ "'{2}' is 'objc_object*', which we overrode to "
"'id'.",
die.GetOffset(), die.GetTagAsCString(), die.GetName());
clang_type = m_ast.GetBasicType(eBasicTypeObjCID);
@@ -768,8 +771,8 @@
if (log) {
dwarf->GetObjectFile()->GetModule()->LogMessage(
log,
- "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is a "
- "forward declaration, complete type is 0x%8.8" PRIx64,
+ "SymbolFileDWARF({0:p}) - {1:x+16}}: {2} type \"{3}\" is a "
+ "forward declaration, complete type is {4:x+8}",
static_cast<void *>(this), die.GetOffset(),
DW_TAG_value_to_name(tag), attrs.name.GetCString(),
type_sp->GetID());
@@ -838,7 +841,7 @@
TypeSystemClang::CompleteTagDeclarationDefinition(clang_type);
} else {
dwarf->GetObjectFile()->GetModule()->ReportError(
- "DWARF DIE at 0x%8.8x named \"%s\" was not able to start its "
+ "DWARF DIE at {0:x+16} named \"{1}\" was not able to start its "
"definition.\nPlease file a bug and attach the file at the "
"start of this error message",
die.GetOffset(), attrs.name.GetCString());
@@ -1001,7 +1004,7 @@
m_ast.SetMetadataAsUserID(objc_method_decl, die.GetID());
} else {
dwarf->GetObjectFile()->GetModule()->ReportError(
- "{0x%8.8x}: invalid Objective-C method 0x%4.4x (%s), "
+ "[{0:x+16}]: invalid Objective-C method {1:x+4} ({2}), "
"please file a bug and attach the file at the start of "
"this error message",
die.GetOffset(), tag, DW_TAG_value_to_name(tag));
@@ -1054,7 +1057,7 @@
LinkDeclContextToDIE(spec_clang_decl_ctx, die);
} else {
dwarf->GetObjectFile()->GetModule()->ReportWarning(
- "0x%8.8" PRIx64 ": DW_AT_specification(0x%8.8x"
+ "{0:x+8}: DW_AT_specification({1:x+16}"
") has no decl\n",
die.GetID(), spec_die.GetOffset());
}
@@ -1073,7 +1076,7 @@
LinkDeclContextToDIE(abs_clang_decl_ctx, die);
} else {
dwarf->GetObjectFile()->GetModule()->ReportWarning(
- "0x%8.8" PRIx64 ": DW_AT_abstract_origin(0x%8.8x"
+ "{0:x+8}: DW_AT_abstract_origin({1:x+16}"
") has no decl\n",
die.GetID(), abs_die.GetOffset());
}
@@ -1425,9 +1428,9 @@
Type *base_class_type = die.ResolveTypeUID(encoding_form.Reference());
if (base_class_type == nullptr) {
- module_sp->ReportError("0x%8.8x: DW_TAG_inheritance failed to "
- "resolve the base class at 0x%8.8x"
- " from enclosing type 0x%8.8x. \nPlease file "
+ module_sp->ReportError("{0:x+16}: DW_TAG_inheritance failed to "
+ "resolve the base class at {1:x+16}"
+ " from enclosing type {2:x+16}. \nPlease file "
"a bug and attach the file at the start of "
"this error message",
die.GetOffset(),
@@ -1692,8 +1695,9 @@
if (log) {
dwarf->GetObjectFile()->GetModule()->LogMessage(
log,
- "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is an "
- "incomplete objc type, complete type is 0x%8.8" PRIx64,
+ "SymbolFileDWARF({0:p}) - {1:x+16}: {2} type "
+ "\"{3}\" is an "
+ "incomplete objc type, complete type is {4:x+8}",
static_cast<void *>(this), die.GetOffset(),
DW_TAG_value_to_name(tag), attrs.name.GetCString(),
type_sp->GetID());
@@ -1717,7 +1721,7 @@
if (log) {
dwarf->GetObjectFile()->GetModule()->LogMessage(
log,
- "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is a "
+ "SymbolFileDWARF({0:p}) - {1:16+x}: {2} type \"{3}\" is a "
"forward declaration, trying to find complete type",
static_cast<void *>(this), die.GetOffset(), DW_TAG_value_to_name(tag),
attrs.name.GetCString());
@@ -1746,8 +1750,8 @@
if (log) {
dwarf->GetObjectFile()->GetModule()->LogMessage(
log,
- "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is a "
- "forward declaration, complete type is 0x%8.8" PRIx64,
+ "SymbolFileDWARF({0:p}) - {1:16+x}: {2} type \"{3}\" is a "
+ "forward declaration, complete type is {4:x+8}",
static_cast<void *>(this), die.GetOffset(),
DW_TAG_value_to_name(tag), attrs.name.GetCString(),
type_sp->GetID());
@@ -1800,7 +1804,7 @@
if (log) {
dwarf->GetObjectFile()->GetModule()->LogMessage(
log,
- "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" "
+ "SymbolFileDWARF({0:p}) - {1:x+16}: {2} type \"{3}\" "
"clang::ClassTemplateDecl failed to return a decl.",
static_cast<void *>(this), die.GetOffset(),
DW_TAG_value_to_name(tag), attrs.name.GetCString());
@@ -1860,7 +1864,9 @@
TypeSystemClang::CompleteTagDeclarationDefinition(clang_type);
} else {
dwarf->GetObjectFile()->GetModule()->ReportError(
- "DWARF DIE at 0x%8.8x named \"%s\" was not able to start its "
+
+ "DWARF DIE at {0:x+16} named \"{1}\" was not able to start "
+ "its "
"definition.\nPlease file a bug and attach the file at the "
"start of this error message",
die.GetOffset(), attrs.name.GetCString());
@@ -2662,18 +2668,18 @@
const PropertyAttributes propAttrs(die);
if (!propAttrs.prop_name) {
- module_sp->ReportError(
- "0x%8.8" PRIx64 ": DW_TAG_APPLE_property has no name.", die.GetID());
+ module_sp->ReportError("{0:x+8}: DW_TAG_APPLE_property has no name.",
+ die.GetID());
return;
}
Type *member_type = die.ResolveTypeUID(attrs.encoding_form.Reference());
if (!member_type) {
- module_sp->ReportError("0x%8.8" PRIx64
- ": DW_TAG_APPLE_property '%s' refers to type 0x%8.8x"
- " which was unable to be parsed",
- die.GetID(), propAttrs.prop_name,
- attrs.encoding_form.Reference().GetOffset());
+ module_sp->ReportError(
+ "{0:x+8}: DW_TAG_APPLE_property '{1}' refers to type {2:x+16}"
+ " which was unable to be parsed",
+ die.GetID(), propAttrs.prop_name,
+ attrs.encoding_form.Reference().GetOffset());
return;
}
@@ -2809,14 +2815,14 @@
if (!member_type) {
if (attrs.name)
module_sp->ReportError(
- "0x%8.8" PRIx64 ": DW_TAG_member '%s' refers to type 0x%8.8x"
+ "{0:x+8}: DW_TAG_member '{1}' refers to type {2:x+16}"
" which was unable to be parsed",
die.GetID(), attrs.name, attrs.encoding_form.Reference().GetOffset());
else
- module_sp->ReportError(
- "0x%8.8" PRIx64 ": DW_TAG_member refers to type 0x%8.8x"
- " which was unable to be parsed",
- die.GetID(), attrs.encoding_form.Reference().GetOffset());
+ module_sp->ReportError("{0:x+8}: DW_TAG_member refers to type {1:x+16}"
+ " which was unable to be parsed",
+ die.GetID(),
+ attrs.encoding_form.Reference().GetOffset());
return;
}
@@ -2866,10 +2872,10 @@
this_field_info.bit_offset)))) {
ObjectFile *objfile = die.GetDWARF()->GetObjectFile();
objfile->GetModule()->ReportWarning(
- "0x%8.8" PRIx64 ": %s bitfield named \"%s\" has invalid "
- "bit offset (0x%8.8" PRIx64
- ") member will be ignored. Please file a bug against the "
- "compiler and include the preprocessed output for %s\n",
+ "{0:x+16}: {1} bitfield named \"{2}\" has invalid "
+ "bit offset ({3:x+8}) member will be ignored. Please file a bug "
+ "against the "
+ "compiler and include the preprocessed output for {4}\n",
die.GetID(), DW_TAG_value_to_name(tag), attrs.name,
this_field_info.bit_offset, GetUnitName(parent_die).c_str());
return;
@@ -2985,11 +2991,10 @@
(member_array_size != 0 ||
attrs.member_byte_offset > parent_byte_size)) {
module_sp->ReportError(
- "0x%8.8" PRIx64 ": DW_TAG_member '%s' refers to type 0x%8.8x"
- " which extends beyond the bounds of 0x%8.8" PRIx64,
+ "{0:x+8}: DW_TAG_member '{1}' refers to type {2:16+x}"
+ " which extends beyond the bounds of {3:x+8}",
die.GetID(), attrs.name,
- attrs.encoding_form.Reference().GetOffset(),
- parent_die.GetID());
+ attrs.encoding_form.Reference().GetOffset(), parent_die.GetID());
}
member_clang_type =
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
===================================================================
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -350,9 +350,8 @@
// Before we try to attach, make sure we aren't already monitoring something
// else.
if (!m_debugged_processes.empty())
- return Status("cannot attach to process %" PRIu64
- " when another process with pid %" PRIu64
- " is being debugged.",
+ return Status("cannot attach to process {0} when another process with pid "
+ "{1:x} is being debugged.",
pid, m_current_process->GetID());
// Try to attach.
Index: lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
===================================================================
--- lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -1398,9 +1398,8 @@
const char *lc_segment_name =
seg_cmd.cmd == LC_SEGMENT_64 ? "LC_SEGMENT_64" : "LC_SEGMENT";
GetModule()->ReportWarning(
- "load command %u %s has a fileoff (0x%" PRIx64
- ") that extends beyond the end of the file (0x%" PRIx64
- "), ignoring this section",
+ "load command {0} {1} has a fileoff ({2:x+16}) that extends beyond "
+ "the end of the file ({3:x+16}), ignoring this section",
cmd_idx, lc_segment_name, seg_cmd.fileoff, m_length);
seg_cmd.fileoff = 0;
@@ -1417,9 +1416,9 @@
const char *lc_segment_name =
seg_cmd.cmd == LC_SEGMENT_64 ? "LC_SEGMENT_64" : "LC_SEGMENT";
GetModule()->ReportWarning(
- "load command %u %s has a fileoff + filesize (0x%" PRIx64
- ") that extends beyond the end of the file (0x%" PRIx64
- "), the segment will be truncated to match",
+ "load command {0} {1} has a fileoff + filesize ({2:x+16}) that "
+ "extends beyond the end of the file ({4:x+16}), the segment will be "
+ "truncated to match",
cmd_idx, lc_segment_name, seg_cmd.fileoff + seg_cmd.filesize, m_length);
// Truncate the length
@@ -2188,8 +2187,8 @@
version_str[6] = '\0';
if (strcmp(version_str, "dyld_v") == 0) {
offset = offsetof(struct lldb_copy_dyld_cache_header_v1, uuid);
- dsc_uuid = UUID(dsc_header_data.GetData(&offset, sizeof(uuid_t)),
- sizeof(uuid_t));
+ dsc_uuid =
+ UUID(dsc_header_data.GetData(&offset, sizeof(uuid_t)), sizeof(uuid_t));
}
Log *log = GetLog(LLDBLog::Symbols);
if (log && dsc_uuid.IsValid()) {
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===================================================================
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1951,7 +1951,7 @@
auto err = lldb_private::lzma::uncompress(data.GetData(), uncompressedData);
if (err) {
GetModule()->ReportWarning(
- "An error occurred while decompression the section %s: %s",
+ "An error occurred while decompression the section {0}: {1}",
section->GetName().AsCString(), llvm::toString(std::move(err)).c_str());
return nullptr;
}
@@ -2614,7 +2614,7 @@
for (unsigned i = 0; i < num_relocations; ++i) {
if (!rel.Parse(rel_data, &offset)) {
- GetModule()->ReportError(".rel%s[%d] failed to parse relocation",
+ GetModule()->ReportError(".rel{0}[{1:d}] failed to parse relocation",
rel_section->GetName().AsCString(), i);
break;
}
@@ -2642,7 +2642,7 @@
}
*dst = value;
} else {
- GetModule()->ReportError(".rel%s[%u] unknown symbol id: %d",
+ GetModule()->ReportError(".rel{0}[{1}] unknown symbol id: {2:d}",
rel_section->GetName().AsCString(), i,
reloc_symbol(rel));
}
@@ -2650,7 +2650,7 @@
case R_386_PC32:
default:
GetModule()->ReportError("unsupported 32-bit relocation:"
- " .rel%s[%u], type %u",
+ " .rel{0}[{1}], type {2}",
rel_section->GetName().AsCString(), i,
reloc_type(rel));
}
@@ -3395,7 +3395,7 @@
GetByteOrder() == eByteOrderLittle, GetAddressByteSize() == 8);
if (!Decompressor) {
GetModule()->ReportWarning(
- "Unable to initialize decompressor for section '%s': %s",
+ "Unable to initialize decompressor for section '{0}': {1}",
section->GetName().GetCString(),
llvm::toString(Decompressor.takeError()).c_str());
section_data.Clear();
@@ -3406,10 +3406,9 @@
std::make_shared<DataBufferHeap>(Decompressor->getDecompressedSize(), 0);
if (auto error = Decompressor->decompress(
{buffer_sp->GetBytes(), size_t(buffer_sp->GetByteSize())})) {
- GetModule()->ReportWarning(
- "Decompression of section '%s' failed: %s",
- section->GetName().GetCString(),
- llvm::toString(std::move(error)).c_str());
+ GetModule()->ReportWarning("Decompression of section '{0}' failed: {1}",
+ section->GetName().GetCString(),
+ llvm::toString(std::move(error)).c_str());
section_data.Clear();
return 0;
}
Index: lldb/source/Core/Module.cpp
===================================================================
--- lldb/source/Core/Module.cpp
+++ lldb/source/Core/Module.cpp
@@ -47,6 +47,7 @@
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/StreamString.h"
#include "lldb/Utility/Timer.h"
+#include <string>
#if defined(_WIN32)
#include "lldb/Host/windows/PosixApi.h"
@@ -1149,76 +1150,46 @@
&m_language_warning);
}
-void Module::ReportErrorIfModifyDetected(const char *format, ...) {
+void Module::ReportErrorIfModifyDetected(
+ const llvm::formatv_object_base &payload) {
if (!m_first_file_changed_log) {
if (FileHasChanged()) {
m_first_file_changed_log = true;
- if (format) {
- StreamString strm;
- strm.PutCString("the object file ");
- GetDescription(strm.AsRawOstream(), lldb::eDescriptionLevelFull);
- strm.PutCString(" has been modified\n");
-
- va_list args;
- va_start(args, format);
- strm.PrintfVarArg(format, args);
- va_end(args);
-
- const int format_len = strlen(format);
- if (format_len > 0) {
- const char last_char = format[format_len - 1];
- if (last_char != '\n' && last_char != '\r')
- strm.EOL();
- }
- strm.PutCString("The debug session should be aborted as the original "
- "debug information has been overwritten.");
- Debugger::ReportError(std::string(strm.GetString()));
- }
+ m_first_file_changed_log = true;
+ StreamString strm;
+ strm.PutCString("the object file ");
+ GetDescription(strm.AsRawOstream(), lldb::eDescriptionLevelFull);
+ strm.PutCString(" has been modified\n");
+ strm.PutCString(payload.str());
+ strm.PutCString("The debug session should be aborted as the original "
+ "debug information has been overwritten.");
+ Debugger::ReportError(std::string(strm.GetString()));
}
}
}
-void Module::ReportError(const char *format, ...) {
- if (format && format[0]) {
- StreamString strm;
- GetDescription(strm.AsRawOstream(), lldb::eDescriptionLevelBrief);
- strm.PutChar(' ');
-
- va_list args;
- va_start(args, format);
- strm.PrintfVarArg(format, args);
- va_end(args);
-
- Debugger::ReportError(std::string(strm.GetString()));
- }
+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());
}
-void Module::ReportWarning(const char *format, ...) {
- if (format && format[0]) {
- StreamString strm;
- GetDescription(strm.AsRawOstream(), lldb::eDescriptionLevelFull);
- strm.PutChar(' ');
-
- va_list args;
- va_start(args, format);
- strm.PrintfVarArg(format, args);
- va_end(args);
-
- Debugger::ReportWarning(std::string(strm.GetString()));
- }
+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()));
}
-void Module::LogMessage(Log *log, const char *format, ...) {
- if (log != nullptr) {
- StreamString log_message;
- GetDescription(log_message.AsRawOstream(), lldb::eDescriptionLevelFull);
- log_message.PutCString(": ");
- va_list args;
- va_start(args, format);
- log_message.PrintfVarArg(format, args);
- va_end(args);
- log->PutCString(log_message.GetData());
- }
+void Module::LogMessage(Log *log, const llvm::formatv_object_base &payload) {
+ StreamString log_message;
+ GetDescription(log_message.AsRawOstream(), lldb::eDescriptionLevelFull);
+ log_message.PutCString(": ");
+ log_message.PutCString(payload.str());
+ log->PutCString(log_message.GetData());
}
void Module::LogMessageVerboseBacktrace(Log *log, const char *format, ...) {
@@ -1293,7 +1264,7 @@
// those values that overwrite unspecified unknown values.
m_arch.MergeFrom(m_objfile_sp->GetArchitecture());
} else {
- ReportError("failed to load objfile for %s",
+ ReportError("failed to load objfile for {0}",
GetFileSpec().GetPath().c_str());
}
}
Index: lldb/include/lldb/Utility/Status.h
===================================================================
--- lldb/include/lldb/Utility/Status.h
+++ lldb/include/lldb/Utility/Status.h
@@ -61,8 +61,11 @@
Status(std::error_code EC);
- explicit Status(const char *format, ...)
- __attribute__((format(printf, 2, 3)));
+ template <typename... Args>
+ explicit Status(const char *format, Args &&...args) {
+ SetErrorToGenericError();
+ m_string = std::string(llvm::formatv(format, std::forward<Args>(args)...));
+ }
~Status();
Index: lldb/include/lldb/Core/Module.h
===================================================================
--- lldb/include/lldb/Core/Module.h
+++ lldb/include/lldb/Core/Module.h
@@ -824,22 +824,34 @@
// architecture, path and object name (if any)). This centralizes code so
// that everyone doesn't need to format their error and log messages on their
// own and keeps the output a bit more consistent.
- void LogMessage(Log *log, const char *format, ...)
- __attribute__((format(printf, 3, 4)));
+ template <typename... Args>
+ void LogMessage(Log *log, const char *format, Args &&...args) {
+ if (log != nullptr)
+ LogMessage(log, llvm::formatv(format, std::forward<Args>(args)...));
+ }
- void LogMessageVerboseBacktrace(Log *log, const char *format, ...)
- __attribute__((format(printf, 3, 4)));
+ void LogMessageVerboseBacktrace(Log *log, const char *format, ...);
- void ReportWarning(const char *format, ...)
- __attribute__((format(printf, 2, 3)));
+ template <typename... Args>
+ void ReportWarning(const char *format, Args &&...args) {
+ if (format && format[0])
+ ReportWarning(llvm::formatv(format, std::forward<Args>(args)...));
+ }
- void ReportError(const char *format, ...)
- __attribute__((format(printf, 2, 3)));
+ template <typename... Args>
+ void ReportError(const char *format, Args &&...args) {
+ if (format && format[0])
+ ReportError(llvm::formatv(format, std::forward<Args>(args)...));
+ }
// Only report an error once when the module is first detected to be modified
// so we don't spam the console with many messages.
- void ReportErrorIfModifyDetected(const char *format, ...)
- __attribute__((format(printf, 2, 3)));
+ template <typename... Args>
+ void ReportErrorIfModifyDetected(const char *format, Args &&...args) {
+ if (format)
+ ReportErrorIfModifyDetected(
+ llvm::formatv(format, std::forward<Args>(args)...));
+ }
void ReportWarningOptimization(llvm::Optional<lldb::user_id_t> debugger_id);
@@ -1154,6 +1166,11 @@
Module(const Module &) = delete;
const Module &operator=(const Module &) = delete;
+
+ void LogMessage(Log *log, const llvm::formatv_object_base &payload);
+ void ReportWarning(const llvm::formatv_object_base &payload);
+ void ReportError(const llvm::formatv_object_base &payload);
+ void ReportErrorIfModifyDetected(const llvm::formatv_object_base &payload);
};
} // namespace lldb_private
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits