ayermolo created this revision.
Herald added subscribers: hoy, modimo, wenlei, arphaman.
Herald added a reviewer: shafik.
Herald added a project: All.
ayermolo requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: lldb-commits, sstefan1.
Herald added a project: LLDB.

In preparation for eanbling 64bit support in LLDB switching to use llvm::formatv
instead of format MACROs.


Repository:
  rG LLVM Github Monorepo

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/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.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/Symbol/DWARFCallFrameInfo.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
@@ -59,6 +59,11 @@
   va_end(args);
 }
 
+Status::Status(const std::string &errMsg) : m_string() {
+  SetErrorToGenericError();
+  m_string = errMsg;
+}
+
 const Status &Status::operator=(llvm::Error error) {
   if (!error) {
     Clear();
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::%s(dwarf_offset: "
+                                "{0:x+16}, startaddr: {{{1: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/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
 
@@ -1520,8 +1510,9 @@
     Log *log = GetLog(DWARFLog::DebugInfo);
     if (log)
       GetObjectFile()->GetModule()->LogMessage(
-          log, "SymbolFileDWARF::ResolveTypeUID (die = 0x%8.8x) %s '%s'",
-          die.GetOffset(), die.GetTagAsCString(), die.GetName());
+          log, std::string(llvm::formatv(
+                   "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
     // class, an enum within a class), so parse any needed parent DIEs before
@@ -1536,11 +1527,12 @@
           // Get the type, which could be a forward declaration
           if (log)
             GetObjectFile()->GetModule()->LogMessage(
-                log,
-                "SymbolFileDWARF::ResolveTypeUID (die = 0x%8.8x) %s '%s' "
-                "resolve parent forward type for 0x%8.8x",
-                die.GetOffset(), die.GetTagAsCString(), die.GetName(),
-                decl_ctx_die.GetOffset());
+                log, std::string(llvm::formatv(
+                         "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;
 
         default:
@@ -1628,9 +1620,9 @@
       if (type != DIE_IS_BEING_PARSED)
         return type;
 
-      GetObjectFile()->GetModule()->ReportError(
-          "Parsing a die that is being parsed die: 0x%8.8x: %s %s",
-          die.GetOffset(), die.GetTagAsCString(), die.GetName());
+      GetObjectFile()->GetModule()->ReportError(std::string(llvm::formatv(
+          "Parsing a die that is being parsed die: {0:x+16}: {1} {2}",
+          die.GetOffset(), die.GetTagAsCString(), die.GetName())));
 
     } else
       return type;
@@ -1744,8 +1736,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(std::string(llvm::formatv(
+        "missing DWO name in skeleton DIE {0:x+16}", cu_die.GetOffset()))));
     return nullptr;
   }
 
@@ -1759,10 +1751,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(std::string(
+          llvm::formatv("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;
     }
 
@@ -1779,10 +1772,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(std::string(llvm::formatv(
+        "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(
@@ -1800,9 +1793,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(std::string(llvm::formatv(
+        "unable to load object file for .dwo debug file \"{0}\" for "
+        "unit DIE {1:x+16}",
+        dwo_name, cu_die.GetOffset()))));
     return nullptr;
   }
 
@@ -1877,13 +1871,13 @@
     Status error = ModuleList::GetSharedModule(dwo_module_spec, module_sp,
                                                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 "
+      GetObjectFile()->GetModule()->ReportWarning(std::string(llvm::formatv(
+          "{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(),
-          error.AsCString("unknown error"));
+          error.AsCString("unknown error"))));
       continue;
     }
 
@@ -1902,12 +1896,13 @@
       continue;
 
     if (dwo_id != dwo_dwo_id) {
-      GetObjectFile()->GetModule()->ReportWarning(
-          "0x%8.8x: Module %s is out-of-date (hash mismatch). Type information "
+      GetObjectFile()->GetModule()->ReportWarning(std::string(llvm::formatv(
+          "{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.",
-          die.GetOffset(), dwo_module_spec.GetFileSpec().GetPath().c_str());
+          die.GetOffset(), dwo_module_spec.GetFileSpec().GetPath().c_str())));
     }
   }
 }
@@ -2082,10 +2077,10 @@
             resolved &= ~eSymbolContextCompUnit;
           }
         } else {
-          GetObjectFile()->GetModule()->ReportWarning(
-              "0x%8.8x: compile unit %u failed to create a valid "
+          GetObjectFile()->GetModule()->ReportWarning(std::string(llvm::formatv(
+              "{0:x+16}: compile unit {1:u} failed to create a valid "
               "lldb_private::CompileUnit class.",
-              cu_offset, cu_idx);
+              cu_offset, cu_idx)));
         }
       }
     }
@@ -3019,12 +3014,12 @@
       if (!try_resolving_type) {
         if (log) {
           GetObjectFile()->GetModule()->LogMessage(
-              log,
-              "SymbolFileDWARF::"
-              "FindDefinitionTypeForDWARFDeclContext(tag=%s, "
-              "name='%s') ignoring die=0x%8.8x (%s)",
-              DW_TAG_value_to_name(tag), die.GetName(), type_die.GetOffset(),
-              type_die.GetName());
+              log, std::string(llvm::formatv(
+                       "SymbolFileDWARF::"
+                       "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())));
         }
         return true;
       }
@@ -3034,11 +3029,12 @@
       if (log) {
         GetObjectFile()->GetModule()->LogMessage(
             log,
-            "SymbolFileDWARF::"
-            "FindDefinitionTypeForDWARFDeclContext(tag=%s, "
-            "name='%s') trying die=0x%8.8x (%s)",
-            DW_TAG_value_to_name(tag), die.GetName(), type_die.GetOffset(),
-            type_dwarf_decl_ctx.GetQualifiedName());
+            std::string(llvm::formatv(
+                "SymbolFileDWARF::"
+                "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())));
       }
 
       // Make sure the decl contexts match all the way up
@@ -3430,9 +3426,9 @@
       if (op_error) {
         StreamString strm;
         location->DumpLocation(&strm, eDescriptionLevelFull, nullptr);
-        GetObjectFile()->GetModule()->ReportError(
-            "0x%8.8x: %s has an invalid location: %s", die.GetOffset(),
-            die.GetTagAsCString(), strm.GetData());
+        GetObjectFile()->GetModule()->ReportError(std::string(llvm::formatv(
+            "{0:x+16}: {1} has an invalid location: {2}", die.GetOffset(),
+            die.GetTagAsCString(), strm.GetData())));
       }
       if (location_DW_OP_addr != LLDB_INVALID_ADDRESS)
         is_static_lifetime = true;
Index: lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -142,8 +142,10 @@
 
   if (log) {
     m_module.LogMessage(
-        log, "ManualDWARFIndex::IndexUnit for unit at .debug_info[0x%8.8x]",
-        unit.GetOffset());
+        log,
+        std::string(llvm::formatv(
+            "ManualDWARFIndex::IndexUnit for unit at .debug_info[{0:x+16}]",
+            unit.GetOffset())));
   }
 
   const LanguageType cu_language = SymbolFileDWARF::GetLanguage(unit);
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(std::string(llvm::formatv(
+        "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);
@@ -99,9 +99,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(std::string(llvm::formatv(
+        "unable to extract compile unit DIE from .dwo file for skeleton "
+        "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.
@@ -574,10 +579,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;
@@ -635,9 +642,9 @@
     return DWARFDIE(); // Not found
 
   if (!ContainsDIEOffset(die_offset)) {
-    GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
-        "GetDIE for DIE 0x%" PRIx32 " is outside of its CU 0x%" PRIx32,
-        die_offset, GetOffset());
+    GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(std::string(
+        llvm::formatv("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
@@ -100,8 +100,8 @@
 }
 
 void DWARFIndex::ReportInvalidDIERef(DIERef ref, llvm::StringRef name) const {
-  m_module.ReportErrorIfModifyDetected(
+  m_module.ReportErrorIfModifyDetected(std::string(llvm::formatv(
       "the DWARF debug information has been modified (accelerator table had "
-      "bad die 0x%8.8x for '%s')\n",
-      ref.die_offset(), name.str().c_str());
+      "bad die {0:x+16} for '{1}')\n",
+      ref.die_offset(), name.str().c_str())));
 }
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,11 @@
   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 "
-        "attach the file at the start of this error message",
-        m_offset, (unsigned)abbr_idx);
+        std::string(
+            llvm::formatv("{{{0:x+16}}}: invalid abbreviation code {1:u}, "
+                          "please file a bug and "
+                          "attach the file at the start of this error message",
+                          (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 +192,11 @@
 
         default:
           cu->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
-              "{0x%8.8x}: Unsupported DW_FORM_0x%x, please file a bug and "
-              "attach the file at the start of this error message",
-              m_offset, (unsigned)form);
+              std::string(llvm::formatv(
+                  "{{{0:x+16}}}: Unsupported DW_FORM_{1:x}, please file a bug "
+                  "and "
+                  "attach the file at the start of this error message",
+                  (uint64_t)m_offset, (unsigned)form)));
           *offset_ptr = m_offset;
           return false;
         }
@@ -214,13 +218,15 @@
           : 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 "
-      "and attach the file at the start of this error message",
-      die.GetOffset(),
-      llvm::dwarf::FormEncodingString(value.Form()).str().c_str(),
-      value.Unsigned(), toString(expected_ranges.takeError()).c_str());
+      std::string(llvm::formatv(
+          "{{{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(),
+          value.Unsigned(), toString(expected_ranges.takeError()).c_str())));
   return DWARFRangeList();
 }
 
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,9 +258,10 @@
     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.",
-        type_name_cstr ? type_name_cstr : "", die.GetOffset());
+        std::string(llvm::formatv(
+            "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())));
   }
 
   // We don't have a type definition and/or the import failed. We must
@@ -427,10 +429,12 @@
 
     dwarf->GetObjectFile()->GetModule()->LogMessage(
         log,
-        "DWARFASTParserClang::ParseTypeFromDWARF "
-        "(die = 0x%8.8x, decl_ctx = %p (die 0x%8.8x)) %s name = '%s')",
-        die.GetOffset(), static_cast<void *>(context), context_die.GetOffset(),
-        die.GetTagAsCString(), die.GetName());
+        std::string(llvm::formatv("DWARFASTParserClang::ParseTypeFromDWARF "
+                                  "(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())));
   }
 
   Type *type_ptr = dwarf->GetDIEToType().lookup(die.GetDIE());
@@ -504,10 +508,11 @@
     break;
   }
   default:
-    dwarf->GetObjectFile()->GetModule()->ReportError(
-        "{0x%8.8x}: unhandled type tag 0x%4.4x (%s), please file a bug and "
-        "attach the file at the start of this error message",
-        die.GetOffset(), tag, DW_TAG_value_to_name(tag));
+    dwarf->GetObjectFile()->GetModule()->ReportError(std::string(
+        llvm::formatv("{{{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,9 +679,10 @@
           if (log)
             dwarf->GetObjectFile()->GetModule()->LogMessage(
                 log,
-                "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' "
-                "is Objective-C 'id' built-in type.",
-                die.GetOffset(), die.GetTagAsCString(), die.GetName());
+                std::string(llvm::formatv(
+                    "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);
           encoding_data_type = Type::eEncodingIsUID;
           attrs.type.Clear();
@@ -685,9 +691,10 @@
           if (log)
             dwarf->GetObjectFile()->GetModule()->LogMessage(
                 log,
-                "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' "
-                "is Objective-C 'Class' built-in type.",
-                die.GetOffset(), die.GetTagAsCString(), die.GetName());
+                std::string(llvm::formatv(
+                    "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);
           encoding_data_type = Type::eEncodingIsUID;
           attrs.type.Clear();
@@ -696,9 +703,10 @@
           if (log)
             dwarf->GetObjectFile()->GetModule()->LogMessage(
                 log,
-                "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' "
-                "is Objective-C 'selector' built-in type.",
-                die.GetOffset(), die.GetTagAsCString(), die.GetName());
+                std::string(llvm::formatv(
+                    "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);
           encoding_data_type = Type::eEncodingIsUID;
           attrs.type.Clear();
@@ -717,10 +725,11 @@
             if (log)
               dwarf->GetObjectFile()->GetModule()->LogMessage(
                   log,
-                  "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s "
-                  "'%s' is 'objc_object*', which we overrode to "
-                  "'id'.",
-                  die.GetOffset(), die.GetTagAsCString(), die.GetName());
+                  std::string(llvm::formatv(
+                      "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);
             encoding_data_type = Type::eEncodingIsUID;
             attrs.type.Clear();
@@ -768,11 +777,12 @@
       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,
-            static_cast<void *>(this), die.GetOffset(),
-            DW_TAG_value_to_name(tag), attrs.name.GetCString(),
-            type_sp->GetID());
+            std::string(llvm::formatv(
+                "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())));
       }
 
       // We found a real definition for this type elsewhere so lets use
@@ -837,11 +847,11 @@
     }
     TypeSystemClang::CompleteTagDeclarationDefinition(clang_type);
   } else {
-    dwarf->GetObjectFile()->GetModule()->ReportError(
-        "DWARF DIE at 0x%8.8x named \"%s\" was not able to start its "
+    dwarf->GetObjectFile()->GetModule()->ReportError(std::string(llvm::formatv(
+        "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());
+        die.GetOffset(), attrs.name.GetCString())));
   }
   return type_sp;
 }
@@ -1001,10 +1011,11 @@
             m_ast.SetMetadataAsUserID(objc_method_decl, die.GetID());
           } else {
             dwarf->GetObjectFile()->GetModule()->ReportError(
-                "{0x%8.8x}: invalid Objective-C method 0x%4.4x (%s), "
-                "please file a bug and attach the file at the start of "
-                "this error message",
-                die.GetOffset(), tag, DW_TAG_value_to_name(tag));
+                std::string(llvm::formatv(
+                    "{{{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))));
           }
         }
       } else if (is_cxx_method) {
@@ -1053,10 +1064,10 @@
             if (spec_clang_decl_ctx) {
               LinkDeclContextToDIE(spec_clang_decl_ctx, die);
             } else {
-              dwarf->GetObjectFile()->GetModule()->ReportWarning(
-                  "0x%8.8" PRIx64 ": DW_AT_specification(0x%8.8x"
-                  ") has no decl\n",
-                  die.GetID(), spec_die.GetOffset());
+              dwarf->GetObjectFile()->GetModule()->ReportWarning(std::string(
+                  llvm::formatv("{0:x+8}: DW_AT_specification({1:x+16}"
+                                ") has no decl\n",
+                                die.GetID(), spec_die.GetOffset())));
             }
             type_handled = true;
           } else if (attrs.abstract_origin.IsValid()) {
@@ -1072,10 +1083,10 @@
             if (abs_clang_decl_ctx) {
               LinkDeclContextToDIE(abs_clang_decl_ctx, die);
             } else {
-              dwarf->GetObjectFile()->GetModule()->ReportWarning(
-                  "0x%8.8" PRIx64 ": DW_AT_abstract_origin(0x%8.8x"
-                  ") has no decl\n",
-                  die.GetID(), abs_die.GetOffset());
+              dwarf->GetObjectFile()->GetModule()->ReportWarning(std::string(
+                  llvm::formatv("{0:x+8}: DW_AT_abstract_origin({1:x+16}"
+                                ") has no decl\n",
+                                die.GetID(), abs_die.GetOffset())));
             }
             type_handled = true;
           } else {
@@ -1425,14 +1436,14 @@
 
   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 "
-                           "a bug and attach the file at the start of "
-                           "this error message",
-                           die.GetOffset(),
-                           encoding_form.Reference().GetOffset(),
-                           parent_die.GetOffset());
+    module_sp->ReportError(std::string(
+        llvm::formatv("{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(), encoding_form.Reference().GetOffset(),
+                      parent_die.GetOffset())));
     return;
   }
 
@@ -1691,12 +1702,13 @@
       if (type_sp) {
         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,
-              static_cast<void *>(this), die.GetOffset(),
-              DW_TAG_value_to_name(tag), attrs.name.GetCString(),
-              type_sp->GetID());
+              log, std::string(llvm::formatv(
+                       "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())));
         }
 
         // We found a real definition for this type elsewhere so lets use
@@ -1716,11 +1728,11 @@
     // elsewhere...
     if (log) {
       dwarf->GetObjectFile()->GetModule()->LogMessage(
-          log,
-          "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is a "
-          "forward declaration, trying to find complete type",
-          static_cast<void *>(this), die.GetOffset(), DW_TAG_value_to_name(tag),
-          attrs.name.GetCString());
+          log, std::string(llvm::formatv(
+                   "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())));
     }
 
     // See if the type comes from a Clang module and if so, track down
@@ -1745,12 +1757,12 @@
     if (type_sp) {
       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,
-            static_cast<void *>(this), die.GetOffset(),
-            DW_TAG_value_to_name(tag), attrs.name.GetCString(),
-            type_sp->GetID());
+            log, std::string(llvm::formatv(
+                     "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())));
       }
 
       // We found a real definition for this type elsewhere so lets use
@@ -1799,11 +1811,11 @@
       if (!class_template_decl) {
         if (log) {
           dwarf->GetObjectFile()->GetModule()->LogMessage(
-              log,
-              "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" "
-              "clang::ClassTemplateDecl failed to return a decl.",
-              static_cast<void *>(this), die.GetOffset(),
-              DW_TAG_value_to_name(tag), attrs.name.GetCString());
+              log, std::string(llvm::formatv(
+                       "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())));
         }
         return TypeSP();
       }
@@ -1860,10 +1872,12 @@
         TypeSystemClang::CompleteTagDeclarationDefinition(clang_type);
       } else {
         dwarf->GetObjectFile()->GetModule()->ReportError(
-            "DWARF DIE at 0x%8.8x named \"%s\" 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());
+            std::string(llvm::formatv(
+                "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())));
       }
 
       // If the byte size of the record is specified then overwrite the size
@@ -2669,11 +2683,11 @@
 
   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(std::string(llvm::formatv(
+        "{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;
   }
 
@@ -2808,15 +2822,16 @@
   Type *member_type = die.ResolveTypeUID(attrs.encoding_form.Reference());
   if (!member_type) {
     if (attrs.name)
-      module_sp->ReportError(
-          "0x%8.8" PRIx64 ": DW_TAG_member '%s' refers to type 0x%8.8x"
-          " which was unable to be parsed",
-          die.GetID(), attrs.name, attrs.encoding_form.Reference().GetOffset());
+      module_sp->ReportError(std::string(
+          llvm::formatv("{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"
+      module_sp->ReportError(std::string(llvm::formatv(
+          "{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());
+          die.GetID(), attrs.encoding_form.Reference().GetOffset())));
     return;
   }
 
@@ -2865,13 +2880,13 @@
           !last_field_info.NextBitfieldOffsetIsValid(
               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",
+      objfile->GetModule()->ReportWarning(std::string(llvm::formatv(
+          "{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());
+          this_field_info.bit_offset, GetUnitName(parent_die).c_str())));
       return;
     }
 
@@ -2984,12 +2999,12 @@
         if (member_array_size != 1 &&
             (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,
+          module_sp->ReportError(std::string(llvm::formatv(
+              "{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());
+              parent_die.GetID())));
         }
 
         member_clang_type =
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"
@@ -1178,49 +1179,79 @@
   }
 }
 
+void Module::ReportErrorIfModifyDetected(const std::string &msg) {
+  if (!m_first_file_changed_log) {
+    if (FileHasChanged()) {
+      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(msg.c_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()));
+    ReportError(std::string(strm.GetString()));
   }
 }
 
+void Module::ReportError(const std::string &msg) {
+  StreamString strm;
+  GetDescription(strm.AsRawOstream(), lldb::eDescriptionLevelBrief);
+  strm.PutChar(' ');
+  strm.PutCString(msg);
+  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()));
+    ReportWarning(strm.GetString().str());
   }
 }
 
+void Module::ReportWarning(const std::string &msg) {
+  StreamString strm;
+  GetDescription(strm.AsRawOstream(), lldb::eDescriptionLevelFull);
+  strm.PutChar(' ');
+  strm.PutCString(msg);
+  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());
+    LogMessage(log, log_message.GetString().str());
   }
 }
 
+void Module::LogMessage(Log *log, const std::string &msg) {
+  StreamString log_message;
+  GetDescription(log_message.AsRawOstream(), lldb::eDescriptionLevelFull);
+  log_message.PutCString(": ");
+  log->PutCString(log_message.GetData());
+}
+
 void Module::LogMessageVerboseBacktrace(Log *log, const char *format, ...) {
   if (log != nullptr) {
     StreamString log_message;
Index: lldb/include/lldb/Utility/Status.h
===================================================================
--- lldb/include/lldb/Utility/Status.h
+++ lldb/include/lldb/Utility/Status.h
@@ -64,6 +64,8 @@
   explicit Status(const char *format, ...)
       __attribute__((format(printf, 2, 3)));
 
+  Status(const std::string &errMsg);
+
   ~Status();
 
   // llvm::Error support
Index: lldb/include/lldb/Core/Module.h
===================================================================
--- lldb/include/lldb/Core/Module.h
+++ lldb/include/lldb/Core/Module.h
@@ -836,11 +836,20 @@
   void ReportError(const char *format, ...)
       __attribute__((format(printf, 2, 3)));
 
+  // The llvm::formatv version of above APIs
+  void LogMessage(Log *log, const std::string &msg);
+
+  void ReportWarning(const std::string &msg);
+
+  void ReportError(const std::string &msg);
+
   // 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)));
 
+  void ReportErrorIfModifyDetected(const std::string &msg);
+
   void ReportWarningOptimization(llvm::Optional<lldb::user_id_t> debugger_id);
 
   void
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to