aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/DebugInfo
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2022-07-14 18:50:02 +0000
committerDimitry Andric <dim@FreeBSD.org>2022-07-14 18:50:02 +0000
commit1f917f69ff07f09b6dbb670971f57f8efe718b84 (patch)
tree99293cbc1411737cd995dac10a99b2c40ef0944c /llvm/lib/DebugInfo
parent145449b1e420787bb99721a429341fa6be3adfb6 (diff)
Diffstat (limited to 'llvm/lib/DebugInfo')
-rw-r--r--llvm/lib/DebugInfo/CodeView/CodeViewError.cpp5
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFContext.cpp4
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp10
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFDie.cpp29
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp8
-rw-r--r--llvm/lib/DebugInfo/MSF/MSFError.cpp7
-rw-r--r--llvm/lib/DebugInfo/PDB/DIA/DIAError.cpp7
-rw-r--r--llvm/lib/DebugInfo/PDB/GenericError.cpp7
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/RawError.cpp7
-rw-r--r--llvm/lib/DebugInfo/Symbolize/Symbolize.cpp4
10 files changed, 53 insertions, 35 deletions
diff --git a/llvm/lib/DebugInfo/CodeView/CodeViewError.cpp b/llvm/lib/DebugInfo/CodeView/CodeViewError.cpp
index d12f6c796e50..74803a3e495a 100644
--- a/llvm/lib/DebugInfo/CodeView/CodeViewError.cpp
+++ b/llvm/lib/DebugInfo/CodeView/CodeViewError.cpp
@@ -8,7 +8,6 @@
#include "llvm/DebugInfo/CodeView/CodeViewError.h"
#include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/ManagedStatic.h"
#include <string>
using namespace llvm;
@@ -42,9 +41,9 @@ public:
};
} // namespace
-static llvm::ManagedStatic<CodeViewErrorCategory> CodeViewErrCategory;
const std::error_category &llvm::codeview::CVErrorCategory() {
- return *CodeViewErrCategory;
+ static CodeViewErrorCategory CodeViewErrCategory;
+ return CodeViewErrCategory;
}
char CodeViewError::ID;
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
index c785026f8461..2e567d8bc7ee 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -1205,13 +1205,13 @@ void DWARFContext::addLocalsForDie(DWARFCompileUnit *CU, DWARFDie Subprogram,
if (auto DeclFileAttr = Die.find(DW_AT_decl_file)) {
if (const auto *LT = CU->getContext().getLineTableForUnit(CU))
LT->getFileNameByIndex(
- DeclFileAttr->getAsUnsignedConstant().getValue(),
+ DeclFileAttr->getAsUnsignedConstant().value(),
CU->getCompilationDir(),
DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath,
Local.DeclFile);
}
if (auto DeclLineAttr = Die.find(DW_AT_decl_line))
- Local.DeclLine = DeclLineAttr->getAsUnsignedConstant().getValue();
+ Local.DeclLine = DeclLineAttr->getAsUnsignedConstant().value();
Result.push_back(Local);
return;
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
index 2e0780e249aa..33856c12b3c9 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
@@ -327,20 +327,20 @@ parseV5DirFileTables(const DWARFDataExtractor &DebugLineData,
FileEntry.Source = Value;
break;
case DW_LNCT_directory_index:
- FileEntry.DirIdx = Value.getAsUnsignedConstant().getValue();
+ FileEntry.DirIdx = Value.getAsUnsignedConstant().value();
break;
case DW_LNCT_timestamp:
- FileEntry.ModTime = Value.getAsUnsignedConstant().getValue();
+ FileEntry.ModTime = Value.getAsUnsignedConstant().value();
break;
case DW_LNCT_size:
- FileEntry.Length = Value.getAsUnsignedConstant().getValue();
+ FileEntry.Length = Value.getAsUnsignedConstant().value();
break;
case DW_LNCT_MD5:
- if (!Value.getAsBlock() || Value.getAsBlock().getValue().size() != 16)
+ if (!Value.getAsBlock() || Value.getAsBlock().value().size() != 16)
return createStringError(
errc::invalid_argument,
"failed to parse file entry because the MD5 hash is invalid");
- std::uninitialized_copy_n(Value.getAsBlock().getValue().begin(), 16,
+ std::uninitialized_copy_n(Value.getAsBlock().value().begin(), 16,
FileEntry.Checksum.begin());
break;
default:
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
index 96c546250974..15a2d23c4fd2 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
@@ -136,23 +136,30 @@ static void dumpAttribute(raw_ostream &OS, const DWARFDie &Die,
auto Color = HighlightColor::Enumerator;
if (Attr == DW_AT_decl_file || Attr == DW_AT_call_file) {
Color = HighlightColor::String;
- if (const auto *LT = U->getContext().getLineTableForUnit(U))
- if (LT->getFileNameByIndex(
- *FormValue.getAsUnsignedConstant(), U->getCompilationDir(),
- DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath, File)) {
- File = '"' + File + '"';
- Name = File;
+ if (const auto *LT = U->getContext().getLineTableForUnit(U)) {
+ if (Optional<uint64_t> Val = FormValue.getAsUnsignedConstant()) {
+ if (LT->getFileNameByIndex(
+ *Val, U->getCompilationDir(),
+ DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath,
+ File)) {
+ File = '"' + File + '"';
+ Name = File;
+ }
}
+ }
} else if (Optional<uint64_t> Val = FormValue.getAsUnsignedConstant())
Name = AttributeValueString(Attr, *Val);
if (!Name.empty())
WithColor(OS, Color) << Name;
- else if (Attr == DW_AT_decl_line || Attr == DW_AT_call_line)
- OS << *FormValue.getAsUnsignedConstant();
- else if (Attr == DW_AT_low_pc &&
- (FormValue.getAsAddress() ==
- dwarf::computeTombstoneAddress(U->getAddressByteSize()))) {
+ else if (Attr == DW_AT_decl_line || Attr == DW_AT_call_line) {
+ if (Optional<uint64_t> Val = FormValue.getAsUnsignedConstant())
+ OS << *Val;
+ else
+ FormValue.dump(OS, DumpOpts);
+ } else if (Attr == DW_AT_low_pc &&
+ (FormValue.getAsAddress() ==
+ dwarf::computeTombstoneAddress(U->getAddressByteSize()))) {
if (DumpOpts.Verbose) {
FormValue.dump(OS, DumpOpts);
OS << " (";
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
index c704f8f583af..2be2a12aa025 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
@@ -704,6 +704,14 @@ unsigned DWARFVerifier::verifyDebugInfoAttribute(const DWARFDie &Die,
}
break;
}
+ case DW_AT_call_line:
+ case DW_AT_decl_line: {
+ if (!AttrValue.Value.getAsUnsignedConstant()) {
+ ReportError("DIE has " + AttributeString(Attr) +
+ " with invalid encoding");
+ }
+ break;
+ }
default:
break;
}
diff --git a/llvm/lib/DebugInfo/MSF/MSFError.cpp b/llvm/lib/DebugInfo/MSF/MSFError.cpp
index 9df2158423a4..fd93c3e726cc 100644
--- a/llvm/lib/DebugInfo/MSF/MSFError.cpp
+++ b/llvm/lib/DebugInfo/MSF/MSFError.cpp
@@ -8,7 +8,6 @@
#include "llvm/DebugInfo/MSF/MSFError.h"
#include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/ManagedStatic.h"
#include <string>
using namespace llvm;
@@ -50,7 +49,9 @@ public:
};
} // namespace
-static llvm::ManagedStatic<MSFErrorCategory> MSFCategory;
-const std::error_category &llvm::msf::MSFErrCategory() { return *MSFCategory; }
+const std::error_category &llvm::msf::MSFErrCategory() {
+ static MSFErrorCategory MSFCategory;
+ return MSFCategory;
+}
char MSFError::ID;
diff --git a/llvm/lib/DebugInfo/PDB/DIA/DIAError.cpp b/llvm/lib/DebugInfo/PDB/DIA/DIAError.cpp
index 819651f77787..0bd93a0e9506 100644
--- a/llvm/lib/DebugInfo/PDB/DIA/DIAError.cpp
+++ b/llvm/lib/DebugInfo/PDB/DIA/DIAError.cpp
@@ -1,6 +1,5 @@
#include "llvm/DebugInfo/PDB/DIA/DIAError.h"
#include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/ManagedStatic.h"
using namespace llvm;
using namespace llvm::pdb;
@@ -31,7 +30,9 @@ public:
}
};
-static llvm::ManagedStatic<DIAErrorCategory> DIACategory;
-const std::error_category &llvm::pdb::DIAErrCategory() { return *DIACategory; }
+const std::error_category &llvm::pdb::DIAErrCategory() {
+ static DIAErrorCategory DIACategory;
+ return DIACategory;
+}
char DIAError::ID;
diff --git a/llvm/lib/DebugInfo/PDB/GenericError.cpp b/llvm/lib/DebugInfo/PDB/GenericError.cpp
index 0e4cba3174b2..d6da2dd62140 100644
--- a/llvm/lib/DebugInfo/PDB/GenericError.cpp
+++ b/llvm/lib/DebugInfo/PDB/GenericError.cpp
@@ -8,7 +8,6 @@
#include "llvm/DebugInfo/PDB/GenericError.h"
#include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/ManagedStatic.h"
using namespace llvm;
using namespace llvm::pdb;
@@ -42,7 +41,9 @@ public:
};
} // namespace
-static llvm::ManagedStatic<PDBErrorCategory> PDBCategory;
-const std::error_category &llvm::pdb::PDBErrCategory() { return *PDBCategory; }
+const std::error_category &llvm::pdb::PDBErrCategory() {
+ static PDBErrorCategory PDBCategory;
+ return PDBCategory;
+}
char PDBError::ID;
diff --git a/llvm/lib/DebugInfo/PDB/Native/RawError.cpp b/llvm/lib/DebugInfo/PDB/Native/RawError.cpp
index ed6cf0839675..31320288a603 100644
--- a/llvm/lib/DebugInfo/PDB/Native/RawError.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/RawError.cpp
@@ -1,6 +1,5 @@
#include "llvm/DebugInfo/PDB/Native/RawError.h"
#include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/ManagedStatic.h"
using namespace llvm;
using namespace llvm::pdb;
@@ -47,7 +46,9 @@ public:
};
} // namespace
-static llvm::ManagedStatic<RawErrorCategory> RawCategory;
-const std::error_category &llvm::pdb::RawErrCategory() { return *RawCategory; }
+const std::error_category &llvm::pdb::RawErrCategory() {
+ static RawErrorCategory RawCategory;
+ return RawCategory;
+}
char RawError::ID;
diff --git a/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp b/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
index d2ff8aa7c995..c239d4c260ec 100644
--- a/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
+++ b/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
@@ -327,6 +327,8 @@ Optional<ArrayRef<uint8_t>> getBuildID(const ELFFile<ELFT> &Obj) {
return {};
}
+} // end anonymous namespace
+
Optional<ArrayRef<uint8_t>> getBuildID(const ELFObjectFileBase *Obj) {
Optional<ArrayRef<uint8_t>> BuildID;
if (auto *O = dyn_cast<ELFObjectFile<ELF32LE>>(Obj))
@@ -342,8 +344,6 @@ Optional<ArrayRef<uint8_t>> getBuildID(const ELFObjectFileBase *Obj) {
return BuildID;
}
-} // end anonymous namespace
-
ObjectFile *LLVMSymbolizer::lookUpDsymFile(const std::string &ExePath,
const MachOObjectFile *MachExeObj,
const std::string &ArchName) {