aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp')
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp42
1 files changed, 25 insertions, 17 deletions
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index 5487f709d223..903cd2e38f76 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -13,6 +13,7 @@
#include "lldb/Utility/LLDBAssert.h"
#include "lldb/Utility/StreamString.h"
#include "lldb/Utility/Timer.h"
+#include "llvm/DebugInfo/DWARF/DWARFDebugLoc.h"
#include "llvm/Object/Error.h"
#include "DWARFCompileUnit.h"
@@ -24,7 +25,7 @@
using namespace lldb;
using namespace lldb_private;
-using namespace std;
+using namespace lldb_private::dwarf;
extern int g_verbose;
@@ -447,7 +448,7 @@ ParseListTableHeader(const llvm::DWARFDataExtractor &data, uint64_t offset,
uint64_t HeaderSize = llvm::DWARFListTableHeader::getHeaderSize(format);
if (offset < HeaderSize)
- return llvm::createStringError(errc::invalid_argument,
+ return llvm::createStringError(std::errc::invalid_argument,
"did not detect a valid"
" list table with base = 0x%" PRIx64 "\n",
offset);
@@ -557,10 +558,10 @@ DWARFUnit::GetRnglistTable() {
// This function is called only for DW_FORM_rnglistx.
llvm::Expected<uint64_t> DWARFUnit::GetRnglistOffset(uint32_t Index) {
if (!GetRnglistTable())
- return llvm::createStringError(errc::invalid_argument,
+ return llvm::createStringError(std::errc::invalid_argument,
"missing or invalid range list table");
if (!m_ranges_base)
- return llvm::createStringError(errc::invalid_argument,
+ 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());
@@ -568,7 +569,7 @@ llvm::Expected<uint64_t> DWARFUnit::GetRnglistOffset(uint32_t Index) {
GetRnglistData().GetAsLLVM(), Index))
return *off + m_ranges_base;
return llvm::createStringError(
- errc::invalid_argument,
+ std::errc::invalid_argument,
"invalid range list table index %u; OffsetEntryCount is %u, "
"DW_AT_rnglists_base is %" PRIu64,
Index, GetRnglistTable()->getOffsetEntryCount(), m_ranges_base);
@@ -771,7 +772,8 @@ removeHostnameFromPathname(llvm::StringRef path_from_dwarf) {
// check whether we have a windows path, and so the first character is a
// drive-letter not a hostname.
- if (host.size() == 1 && llvm::isAlpha(host[0]) && path.startswith("\\"))
+ if (host.size() == 1 && llvm::isAlpha(host[0]) &&
+ (path.startswith("\\") || path.startswith("/")))
return path_from_dwarf;
return path;
@@ -787,7 +789,7 @@ void DWARFUnit::ComputeCompDirAndGuessPathStyle() {
die->GetAttributeValueAsString(this, DW_AT_comp_dir, nullptr));
if (!comp_dir.empty()) {
FileSpec::Style comp_dir_style =
- FileSpec::GuessPathStyle(comp_dir).getValueOr(FileSpec::Style::native);
+ FileSpec::GuessPathStyle(comp_dir).value_or(FileSpec::Style::native);
m_comp_dir = FileSpec(comp_dir, comp_dir_style);
} else {
// Try to detect the style based on the DW_AT_name attribute, but just store
@@ -795,7 +797,7 @@ void DWARFUnit::ComputeCompDirAndGuessPathStyle() {
const char *name =
die->GetAttributeValueAsString(this, DW_AT_name, nullptr);
m_comp_dir = FileSpec(
- "", FileSpec::GuessPathStyle(name).getValueOr(FileSpec::Style::native));
+ "", FileSpec::GuessPathStyle(name).value_or(FileSpec::Style::native));
}
}
@@ -863,14 +865,24 @@ DWARFUnitHeader::extract(const DWARFDataExtractor &data,
section == DIERef::Section::DebugTypes ? DW_UT_type : DW_UT_compile;
}
+ if (header.IsTypeUnit()) {
+ header.m_type_hash = data.GetU64(offset_ptr);
+ header.m_type_offset = data.GetDWARFOffset(offset_ptr);
+ }
+
if (context.isDwo()) {
+ const llvm::DWARFUnitIndex *Index;
if (header.IsTypeUnit()) {
- header.m_index_entry =
- context.GetAsLLVM().getTUIndex().getFromOffset(header.m_offset);
+ Index = &context.GetAsLLVM().getTUIndex();
+ if (*Index)
+ header.m_index_entry = Index->getFromHash(header.m_type_hash);
} else {
- header.m_index_entry =
- context.GetAsLLVM().getCUIndex().getFromOffset(header.m_offset);
+ Index = &context.GetAsLLVM().getCUIndex();
+ if (*Index && header.m_version >= 5)
+ header.m_index_entry = Index->getFromHash(header.m_dwo_id);
}
+ if (!header.m_index_entry)
+ header.m_index_entry = Index->getFromOffset(header.m_offset);
}
if (header.m_index_entry) {
@@ -893,10 +905,6 @@ DWARFUnitHeader::extract(const DWARFDataExtractor &data,
}
header.m_abbr_offset = abbr_entry->Offset;
}
- if (header.IsTypeUnit()) {
- header.m_type_hash = data.GetU64(offset_ptr);
- header.m_type_offset = data.GetDWARFOffset(offset_ptr);
- }
bool length_OK = data.ValidOffset(header.GetNextUnitOffset() - 1);
bool version_OK = SymbolFileDWARF::SupportedVersion(header.m_version);
@@ -997,7 +1005,7 @@ DWARFUnit::FindRnglistFromOffset(dw_offset_t offset) {
}
if (!GetRnglistTable())
- return llvm::createStringError(errc::invalid_argument,
+ return llvm::createStringError(std::errc::invalid_argument,
"missing or invalid range list table");
llvm::DWARFDataExtractor data = GetRnglistData().GetAsLLVM();