diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h --- a/lldb/include/lldb/Core/Module.h +++ b/lldb/include/lldb/Core/Module.h @@ -825,22 +825,35 @@ // 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 + void LogMessage(Log *log, const char *format, Args &&...args) { + LogMessage(log, llvm::formatv(format, std::forward(args)...)); + } - void LogMessageVerboseBacktrace(Log *log, const char *format, ...) - __attribute__((format(printf, 3, 4))); + template + void LogMessageVerboseBacktrace(Log *log, const char *format, + Args &&...args) { + LogMessageVerboseBacktrace( + log, llvm::formatv(format, std::forward(args)...)); + } - void ReportWarning(const char *format, ...) - __attribute__((format(printf, 2, 3))); + template + void ReportWarning(const char *format, Args &&...args) { + ReportWarning(llvm::formatv(format, std::forward(args)...)); + } - void ReportError(const char *format, ...) - __attribute__((format(printf, 2, 3))); + template + void ReportError(const char *format, Args &&...args) { + ReportError(llvm::formatv(format, std::forward(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 + void ReportErrorIfModifyDetected(const char *format, Args &&...args) { + ReportErrorIfModifyDetected( + llvm::formatv(format, std::forward(args)...)); + } void ReportWarningOptimization(std::optional debugger_id); @@ -1155,6 +1168,13 @@ Module(const Module &) = delete; const Module &operator=(const Module &) = delete; + + void LogMessage(Log *log, const llvm::formatv_object_base &payload); + void LogMessageVerboseBacktrace(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 diff --git a/lldb/include/lldb/Utility/Status.h b/lldb/include/lldb/Utility/Status.h --- a/lldb/include/lldb/Utility/Status.h +++ b/lldb/include/lldb/Utility/Status.h @@ -64,6 +64,11 @@ explicit Status(const char *format, ...) __attribute__((format(printf, 2, 3))); + template + static Status createWithFormat(const char *format, Args &&...args) { + return Status(llvm::formatv(format, std::forward(args)...)); + } + ~Status(); // llvm::Error support @@ -190,6 +195,11 @@ lldb::ErrorType m_type = lldb::eErrorTypeInvalid; ///< The type of the above error code. mutable std::string m_string; ///< A string representation of the error code. +private: + explicit Status(const llvm::formatv_object_base &payload) { + SetErrorToGenericError(); + m_string = payload.str(); + } }; } // namespace lldb_private diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp --- a/lldb/source/Core/Module.cpp +++ b/lldb/source/Core/Module.cpp @@ -1150,95 +1150,60 @@ &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())); - } + 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::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::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::LogMessageVerboseBacktrace(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); - if (log->GetVerbose()) { - std::string back_trace; - llvm::raw_string_ostream stream(back_trace); - llvm::sys::PrintStackTrace(stream); - log_message.PutCString(back_trace); - } - log->PutCString(log_message.GetData()); +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 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 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 llvm::formatv_object_base &payload) { + StreamString log_message; + GetDescription(log_message.AsRawOstream(), lldb::eDescriptionLevelFull); + log_message.PutCString(": "); + log_message.PutCString(payload.str()); + if (log->GetVerbose()) { + std::string back_trace; + llvm::raw_string_ostream stream(back_trace); + llvm::sys::PrintStackTrace(stream); + log_message.PutCString(back_trace); } + log->PutCString(log_message.GetData()); } void Module::Dump(Stream *s) { @@ -1294,7 +1259,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()); } } diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -1952,7 +1952,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; } @@ -2615,7 +2615,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; } @@ -2643,7 +2643,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)); } @@ -2651,7 +2651,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)); } @@ -3396,7 +3396,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(); @@ -3407,10 +3407,9 @@ std::make_shared(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; } diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp --- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -1399,9 +1399,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:x16}) that extends beyond " + "the end of the file ({3:x16}), ignoring this section", cmd_idx, lc_segment_name, seg_cmd.fileoff, m_length); seg_cmd.fileoff = 0; @@ -1418,9 +1417,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:x16}) that " + "extends beyond the end of the file ({4:x16}), the segment will be " + "truncated to match", cmd_idx, lc_segment_name, seg_cmd.fileoff + seg_cmd.filesize, m_length); // Truncate the length @@ -2189,8 +2188,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()) { diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -258,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:x16}.\nPlease file a bug report.", type_name_cstr ? type_name_cstr : "", die.GetOffset()); } @@ -429,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:x16}, decl_ctx = {1:p} (die " + "{2:16x})) (3:s) name = '{4}')", die.GetOffset(), static_cast(context), context_die.GetOffset(), die.GetTagAsCString(), die.GetName()); } @@ -506,7 +507,8 @@ } default: dwarf->GetObjectFile()->GetModule()->ReportError( - "{0x%8.8x}: unhandled type tag 0x%4.4x (%s), please file a bug and " + "[{0:x16}]: unhandled type tag {1:x4} ({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; @@ -675,7 +677,7 @@ if (log) dwarf->GetObjectFile()->GetModule()->LogMessage( log, - "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' " + "SymbolFileDWARF::ParseType (die = {0:16x}) {1} '{2}' " "is Objective-C 'id' built-in type.", die.GetOffset(), die.GetTagAsCString(), die.GetName()); clang_type = m_ast.GetBasicType(eBasicTypeObjCID); @@ -686,7 +688,7 @@ if (log) dwarf->GetObjectFile()->GetModule()->LogMessage( log, - "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' " + "SymbolFileDWARF::ParseType (die = {0:x16}) {1} '{2}' " "is Objective-C 'Class' built-in type.", die.GetOffset(), die.GetTagAsCString(), die.GetName()); clang_type = m_ast.GetBasicType(eBasicTypeObjCClass); @@ -697,7 +699,7 @@ if (log) dwarf->GetObjectFile()->GetModule()->LogMessage( log, - "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' " + "SymbolFileDWARF::ParseType (die = {0:x16}) {1} '{2}' " "is Objective-C 'selector' built-in type.", die.GetOffset(), die.GetTagAsCString(), die.GetName()); clang_type = m_ast.GetBasicType(eBasicTypeObjCSel); @@ -718,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:x16}) {1} " + "'{2}' is 'objc_object*', which we overrode to " "'id'.", die.GetOffset(), die.GetTagAsCString(), die.GetName()); clang_type = m_ast.GetBasicType(eBasicTypeObjCID); @@ -800,8 +802,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:x16}}: {2} type \"{3}\" is a " + "forward declaration, complete type is {4:x8}", static_cast(this), die.GetOffset(), DW_TAG_value_to_name(tag), attrs.name.GetCString(), type_sp->GetID()); @@ -870,7 +872,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:x16} 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()); @@ -1033,7 +1035,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:x16}]: invalid Objective-C method {1:x4} ({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)); @@ -1086,7 +1088,7 @@ LinkDeclContextToDIE(spec_clang_decl_ctx, die); } else { dwarf->GetObjectFile()->GetModule()->ReportWarning( - "0x%8.8" PRIx64 ": DW_AT_specification(0x%8.8x" + "{0:x8}: DW_AT_specification({1:x16}" ") has no decl\n", die.GetID(), spec_die.GetOffset()); } @@ -1105,7 +1107,7 @@ LinkDeclContextToDIE(abs_clang_decl_ctx, die); } else { dwarf->GetObjectFile()->GetModule()->ReportWarning( - "0x%8.8" PRIx64 ": DW_AT_abstract_origin(0x%8.8x" + "{0:x8}: DW_AT_abstract_origin({1:x16}" ") has no decl\n", die.GetID(), abs_die.GetOffset()); } @@ -1457,9 +1459,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:x16}: DW_TAG_inheritance failed to " + "resolve the base class at {1:x16}" + " from enclosing type {2:x16}. \nPlease file " "a bug and attach the file at the start of " "this error message", die.GetOffset(), @@ -1689,8 +1691,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:x16}: {2} type " + "\"{3}\" is an " + "incomplete objc type, complete type is {4:x8}", static_cast(this), die.GetOffset(), DW_TAG_value_to_name(tag), attrs.name.GetCString(), type_sp->GetID()); @@ -1714,7 +1717,7 @@ if (log) { dwarf->GetObjectFile()->GetModule()->LogMessage( log, - "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is a " + "SymbolFileDWARF({0:p}) - {1:x16}: {2} type \"{3}\" is a " "forward declaration, trying to find complete type", static_cast(this), die.GetOffset(), DW_TAG_value_to_name(tag), attrs.name.GetCString()); @@ -1743,8 +1746,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:x16}: {2} type \"{3}\" is a " + "forward declaration, complete type is {4:x8}", static_cast(this), die.GetOffset(), DW_TAG_value_to_name(tag), attrs.name.GetCString(), type_sp->GetID()); @@ -1795,7 +1798,7 @@ if (log) { dwarf->GetObjectFile()->GetModule()->LogMessage( log, - "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" " + "SymbolFileDWARF({0:p}) - {1:x16}: {2} type \"{3}\" " "clang::ClassTemplateDecl failed to return a decl.", static_cast(this), die.GetOffset(), DW_TAG_value_to_name(tag), attrs.name.GetCString()); @@ -1855,7 +1858,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:x16} 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()); @@ -2660,18 +2665,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:x8}: 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:x8}: DW_TAG_APPLE_property '{1}' refers to type {2:x16}" + " which was unable to be parsed", + die.GetID(), propAttrs.prop_name, + attrs.encoding_form.Reference().GetOffset()); return; } @@ -2807,14 +2812,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:x8}: DW_TAG_member '{1}' refers to type {2:x16}" " 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:x8}: DW_TAG_member refers to type {1:x16}" + " which was unable to be parsed", + die.GetID(), + attrs.encoding_form.Reference().GetOffset()); return; } @@ -2864,10 +2869,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:x16}: {1} bitfield named \"{2}\" has invalid " + "bit offset ({3:x8}) 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; @@ -2983,11 +2988,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:x8}: DW_TAG_member '{1}' refers to type {2:x16}" + " which extends beyond the bounds of {3:x8}", die.GetID(), attrs.name, - attrs.encoding_form.Reference().GetOffset(), - parent_die.GetID()); + attrs.encoding_form.Reference().GetOffset(), parent_die.GetID()); } member_clang_type = diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp @@ -18,11 +18,13 @@ 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->Format( + + "{0:x16}: Compile Unit: length = {1:x8}, version = {2:x}, " + "abbr_offset = {3:x8}, addr_size = {4:x2} (next CU at " + "[{5:x16}])\n", + GetOffset(), GetLength(), GetVersion(), (uint32_t)GetAbbrevOffset(), + GetAddressByteSize(), GetNextUnitOffset()); } void DWARFCompileUnit::BuildAddressRangeTable( diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp @@ -61,7 +61,8 @@ 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:x16}]: invalid abbreviation code {1}, " + "please file a bug and " "attach the file at the start of this error message", m_offset, (unsigned)abbr_idx); // WE can't parse anymore if the DWARF is borked... @@ -191,7 +192,8 @@ default: cu->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError( - "{0x%8.8x}: Unsupported DW_FORM_0x%x, please file a bug and " + "[{0:x16}]: Unsupported DW_FORM_{1:x}, please file a bug " + "and " "attach the file at the start of this error message", m_offset, (unsigned)form); *offset_ptr = m_offset; @@ -215,9 +217,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:x16}]: DIE has DW_AT_ranges({1} {2:x16}) 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(), diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp @@ -513,8 +513,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:x16} is outside of its CU", value); return {}; } return const_cast(m_unit)->GetDIE(value); @@ -525,8 +524,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:x16} has no matching CU", value); return {}; } return ref_cu->GetDIE(value); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp +++ b/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:x16} for '{1}')\n", ref.die_offset(), name.str().c_str()); } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.cpp @@ -15,9 +15,10 @@ 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->Format("{0:x16}: Type Unit: length = {1:x8}, version = {2:x4}, " + "abbr_offset = {3:x8}, addr_size = {4:x2} (next CU at " + "[{5:x16}])\n", + GetOffset(), (uint32_t)GetLength(), GetVersion(), + (uint32_t)GetAbbrevOffset(), GetAddressByteSize(), + GetNextUnitOffset()); } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp @@ -88,11 +88,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::createWithFormat( + "unable to load .dwo file from \"{0}\" due to ID ({1:x16}) mismatch " + "for skeleton DIE at {2:x8}", + 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); @@ -100,9 +100,10 @@ DWARFBaseDIE dwo_cu_die = dwo_cu->GetUnitDIEOnly(); if (!dwo_cu_die.IsValid()) { // 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())); + SetDwoError(Status::createWithFormat( + "unable to extract compile unit DIE from .dwo file for skeleton " + "DIE at {0:x16}", + m_first_die.GetOffset())); return; } @@ -213,7 +214,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", + llvm::formatv("{0:x16}: DWARFUnit::ExtractDIEsIfNeeded()", GetOffset()) + .str() + .c_str()); // Set the offset to that of the first DIE and calculate the start of the // next compilation unit header. @@ -480,7 +485,7 @@ if (!contribution) { GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError( "Failed to find location list contribution for CU with DWO Id " - "0x%" PRIx64, + "{0:x16}", *GetDWOId()); return; } @@ -498,8 +503,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:x16} (location " + "list base: {1:x16}): {2}", offset, loclists_base, toString(std::move(E)).c_str()); } } @@ -538,8 +543,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:x16}", entry->getSignature()); return DWARFDataExtractor(); @@ -563,7 +567,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:x16}: {1}", m_ranges_base, toString(table_or_error.takeError()).c_str()); } return m_rnglist_table; @@ -575,10 +579,13 @@ 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, + llvm::formatv("DW_FORM_rnglistx cannot be used without " + "DW_AT_rnglists_base for CU at {0:x16}", + GetOffset()) + .str() + .c_str()); if (std::optional off = GetRnglistTable()->getOffsetEntry( GetRnglistData().GetAsLLVM(), Index)) return *off + m_ranges_base; @@ -637,8 +644,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:x16} is outside of its CU {0:x16}", die_offset, + GetOffset()); return DWARFDIE(); // Not found } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp @@ -143,7 +143,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:x16}]", unit.GetOffset()); } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -556,7 +556,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 +1314,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:x16}-{2:x16}) which has a base " + "that is less than the function's low PC {3:x16}. Please file " + "a bug and attach the file at the " "start of this error message", block->GetID(), range_base, range.GetRangeEnd(), subprogram_low_pc); @@ -1519,7 +1519,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:x16}) {1} '{2}'", die.GetOffset(), die.GetTagAsCString(), die.GetName()); // We might be coming in in the middle of a type tree (a class within a @@ -1536,8 +1536,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:x16}) " + "{1} '{2}' " + "resolve parent forward type for {3:x16})", die.GetOffset(), die.GetTagAsCString(), die.GetName(), decl_ctx_die.GetOffset()); } break; @@ -1607,7 +1608,7 @@ Log *log = GetLog(DWARFLog::DebugInfo | DWARFLog::TypeCompletion); if (log) GetObjectFile()->GetModule()->LogMessageVerboseBacktrace( - log, "0x%8.8" PRIx64 ": %s '%s' resolving forward declaration...", + log, "{0:x8}: {1} '{2}' resolving forward declaration...", dwarf_die.GetID(), dwarf_die.GetTagAsCString(), type->GetName().AsCString()); assert(compiler_type); @@ -1628,7 +1629,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:x16}: {1} {2}", die.GetOffset(), die.GetTagAsCString(), die.GetName()); } else @@ -1743,8 +1744,8 @@ 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, - cu_die.GetOffset())); + unit.SetDwoError(Status::createWithFormat( + "missing DWO name in skeleton DIE {0:x16}", cu_die.GetOffset())); return nullptr; } @@ -1758,10 +1759,11 @@ comp_dir = cu_die.GetAttributeValueAsString(dwarf_cu, DW_AT_comp_dir, 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())); + unit.SetDwoError(Status::createWithFormat( + "unable to locate relative .dwo debug file \"{0}\" for " + "skeleton DIE {1:x16} without valid DW_AT_comp_dir " + "attribute", + dwo_name, cu_die.GetOffset())); return nullptr; } @@ -1778,10 +1780,10 @@ } 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())); + unit.SetDwoError(Status::createWithFormat( + "unable to locate .dwo debug file \"{0}\" for skeleton DIE " + "{1:x16}", + dwo_file.GetPath().c_str(), cu_die.GetOffset())); if (m_dwo_warning_issued.test_and_set(std::memory_order_relaxed) == false) { GetObjectFile()->GetModule()->ReportWarning( @@ -1799,9 +1801,10 @@ FileSystem::Instance().GetByteSize(dwo_file), dwo_file_data_sp, 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())); + unit.SetDwoError(Status::createWithFormat( + "unable to load object file for .dwo debug file \"{0}\" for " + "unit DIE {1:x16}", + dwo_name, cu_die.GetOffset())); return nullptr; } @@ -1877,8 +1880,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:x16}: 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(), @@ -1902,7 +1905,8 @@ if (dwo_id != dwo_dwo_id) { GetObjectFile()->GetModule()->ReportWarning( - "0x%8.8x: Module %s is out-of-date (hash mismatch). Type information " + "{0:x16}: 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.", @@ -2082,7 +2086,7 @@ } } else { GetObjectFile()->GetModule()->ReportWarning( - "0x%8.8x: compile unit %u failed to create a valid " + "{0:x16}: compile unit {1} failed to create a valid " "lldb_private::CompileUnit class.", cu_offset, cu_idx); } @@ -2176,8 +2180,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(&parent_decl_ctx), max_matches); @@ -2242,8 +2246,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(&parent_decl_ctx), max_matches, num_matches); } @@ -2258,8 +2262,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); } @@ -2369,7 +2373,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); } @@ -2418,8 +2422,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); } } @@ -2435,7 +2439,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()); } @@ -2485,15 +2489,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(&parent_decl_ctx), parent_decl_ctx.GetName().AsCString(""), 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); } @@ -2582,16 +2586,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(&parent_decl_ctx), parent_decl_ctx.GetName().AsCString(""), 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()); } } @@ -2649,7 +2653,7 @@ if (log) { GetObjectFile()->GetModule()->LogMessage( - log, "SymbolFileDWARF::FindNamespace (sc, name=\"%s\")", + log, "SymbolFileDWARF::FindNamespace (sc, name=\"{0}\")", name.GetCString()); } @@ -2673,8 +2677,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(namespace_decl_ctx.GetTypeSystem()), static_cast(namespace_decl_ctx.GetOpaqueDeclContext()), @@ -2969,7 +2973,7 @@ GetObjectFile()->GetModule()->LogMessage( log, "SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(tag=%" - "s, name='%s')", + "s, name='{0}')", DW_TAG_value_to_name(tag), die.GetName()); } @@ -3041,8 +3045,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:x16} ({3})", DW_TAG_value_to_name(tag), die.GetName(), type_die.GetOffset(), type_die.GetName()); } @@ -3055,8 +3059,8 @@ GetObjectFile()->GetModule()->LogMessage( log, "SymbolFileDWARF::" - "FindDefinitionTypeForDWARFDeclContext(tag=%s, " - "name='%s') trying die=0x%8.8x (%s)", + "FindDefinitionTypeForDWARFDeclContext(tag={0}, " + "name='{1}') trying die={2:x16} ({3})", DW_TAG_value_to_name(tag), die.GetName(), type_die.GetOffset(), type_dwarf_decl_ctx.GetQualifiedName()); } @@ -3472,7 +3476,7 @@ StreamString strm; location->DumpLocation(&strm, eDescriptionLevelFull, nullptr); GetObjectFile()->GetModule()->ReportError( - "0x%8.8x: %s has an invalid location: %s", die.GetOffset(), + "{0:x16}: {1} has an invalid location: {2}", die.GetOffset(), die.GetTagAsCString(), strm.GetData()); } if (location_DW_OP_addr != LLDB_INVALID_ADDRESS) @@ -3693,8 +3697,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:x8} {1} with no valid compile unit in " + "symbol context for {2:x8} {3}.\n", sc_parent_die.GetID(), sc_parent_die.GetTagAsCString(), die.GetID(), die.GetTagAsCString()); return; @@ -3703,8 +3707,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:x8} " + "{1}.\n", die.GetID(), die.GetTagAsCString()); return; } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -352,7 +352,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 { @@ -368,22 +369,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); } @@ -430,8 +434,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; } diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp --- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp @@ -424,8 +424,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:x16}-{3:x16}) 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, diff --git a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp --- a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp +++ b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp @@ -1261,7 +1261,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()); @@ -1371,7 +1371,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()); @@ -1430,7 +1430,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)) diff --git a/lldb/source/Symbol/CompileUnit.cpp b/lldb/source/Symbol/CompileUnit.cpp --- a/lldb/source/Symbol/CompileUnit.cpp +++ b/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:x16} 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); } diff --git a/lldb/source/Symbol/DWARFCallFrameInfo.cpp b/lldb/source/Symbol/DWARFCallFrameInfo.cpp --- a/lldb/source/Symbol/DWARFCallFrameInfo.cpp +++ b/lldb/source/Symbol/DWARFCallFrameInfo.cpp @@ -773,12 +773,12 @@ // 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_LOG(log, + "DWARFCallFrameInfo::{0}(dwarf_offset: " + "{1:x16}, startaddr: [{2:x16}] encountered " + "DW_CFA_restore_state but state stack " + "is empty. Corrupt unwind info?", + __FUNCTION__, dwarf_offset, startaddr.GetFileAddress()); break; } lldb::addr_t offset = row->GetOffset(); diff --git a/lldb/source/Target/SectionLoadList.cpp b/lldb/source/Target/SectionLoadList.cpp --- a/lldb/source/Target/SectionLoadList.cpp +++ b/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:x16} 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(), diff --git a/lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s b/lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s --- a/lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s +++ b/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: diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/debug_ranges-missing-section.s b/lldb/test/Shell/SymbolFile/DWARF/x86/debug_ranges-missing-section.s --- a/lldb/test/Shell/SymbolFile/DWARF/x86/debug_ranges-missing-section.s +++ b/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)