LLVM
10.0.0
lib
DebugInfo
DWARF
DWARFDebugInfoEntry.cpp
Go to the documentation of this file.
1
//===- DWARFDebugInfoEntry.cpp --------------------------------------------===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#include "
llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h
"
10
#include "
llvm/ADT/Optional.h
"
11
#include "
llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h
"
12
#include "
llvm/DebugInfo/DWARF/DWARFFormValue.h
"
13
#include "
llvm/DebugInfo/DWARF/DWARFUnit.h
"
14
#include "
llvm/Support/DataExtractor.h
"
15
#include <cstddef>
16
#include <cstdint>
17
18
using namespace
llvm
;
19
using namespace
dwarf;
20
21
bool
DWARFDebugInfoEntry::extractFast
(
const
DWARFUnit
&U,
22
uint64_t *OffsetPtr) {
23
DWARFDataExtractor
DebugInfoData = U.
getDebugInfoExtractor
();
24
const
uint64_t UEndOffset = U.
getNextUnitOffset
();
25
return
extractFast(U, OffsetPtr, DebugInfoData, UEndOffset, 0);
26
}
27
28
bool
DWARFDebugInfoEntry::extractFast
(
const
DWARFUnit
&U, uint64_t *OffsetPtr,
29
const
DWARFDataExtractor
&DebugInfoData,
30
uint64_t UEndOffset,
uint32_t
D
) {
31
Offset
= *OffsetPtr;
32
Depth
=
D
;
33
if
(
Offset
>= UEndOffset || !DebugInfoData.
isValidOffset
(
Offset
))
34
return
false
;
35
uint64_t AbbrCode = DebugInfoData.
getULEB128
(OffsetPtr);
36
if
(0 == AbbrCode) {
37
// NULL debug tag entry.
38
AbbrevDecl =
nullptr
;
39
return
true
;
40
}
41
AbbrevDecl = U.
getAbbreviations
()->
getAbbreviationDeclaration
(AbbrCode);
42
if
(
nullptr
== AbbrevDecl) {
43
// Restore the original offset.
44
*OffsetPtr =
Offset
;
45
return
false
;
46
}
47
// See if all attributes in this DIE have fixed byte sizes. If so, we can
48
// just add this size to the offset to skip to the next DIE.
49
if
(
Optional<size_t>
FixedSize = AbbrevDecl->getFixedAttributesByteSize(U)) {
50
*OffsetPtr += *FixedSize;
51
return
true
;
52
}
53
54
// Skip all data in the .debug_info for the attributes
55
for
(
const
auto
&AttrSpec : AbbrevDecl->attributes()) {
56
// Check if this attribute has a fixed byte size.
57
if
(
auto
FixedSize = AttrSpec.getByteSize(U)) {
58
// Attribute byte size if fixed, just add the size to the offset.
59
*OffsetPtr += *FixedSize;
60
}
else
if
(!
DWARFFormValue::skipValue
(AttrSpec.Form, DebugInfoData,
61
OffsetPtr, U.
getFormParams
())) {
62
// We failed to skip this attribute's value, restore the original offset
63
// and return the failure status.
64
*OffsetPtr =
Offset
;
65
return
false
;
66
}
67
}
68
return
true
;
69
}
llvm::DWARFUnit::getAbbreviations
const DWARFAbbreviationDeclarationSet * getAbbreviations() const
Definition:
DWARFUnit.cpp:850
llvm::DWARFUnit::getNextUnitOffset
uint64_t getNextUnitOffset() const
Definition:
DWARFUnit.h:292
llvm
This class represents lattice values for constants.
Definition:
AllocatorList.h:23
llvm::AMDGPU::Hwreg::Offset
Offset
Definition:
SIDefines.h:342
DWARFDebugInfoEntry.h
llvm::DWARFDebugInfoEntry::extractFast
bool extractFast(const DWARFUnit &U, uint64_t *OffsetPtr)
Extracts a debug info entry, which is a child of a given unit, starting at a given offset...
Definition:
DWARFDebugInfoEntry.cpp:21
llvm::Depth
Definition:
SIMachineScheduler.h:36
llvm::DWARFUnit::getFormParams
const dwarf::FormParams & getFormParams() const
Definition:
DWARFUnit.h:280
DWARFDebugAbbrev.h
llvm::Optional< size_t >
DWARFFormValue.h
llvm::DWARFUnit
Definition:
DWARFUnit.h:194
DataExtractor.h
llvm::DWARFAbbreviationDeclarationSet::getAbbreviationDeclaration
const DWARFAbbreviationDeclaration * getAbbreviationDeclaration(uint32_t AbbrCode) const
Definition:
DWARFDebugAbbrev.cpp:56
llvm::DataExtractor::getULEB128
uint64_t getULEB128(uint64_t *offset_ptr, llvm::Error *Err=nullptr) const
Extract a unsigned LEB128 value from *offset_ptr.
Definition:
DataExtractor.cpp:174
llvm::DWARFDataExtractor
A DataExtractor (typically for an in-memory copy of an object-file section) plus a relocation map for...
Definition:
DWARFDataExtractor.h:20
uint32_t
DWARFUnit.h
D
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
llvm::DataExtractor::isValidOffset
bool isValidOffset(uint64_t offset) const
Test the validity of offset.
Definition:
DataExtractor.h:544
llvm::DWARFUnit::getDebugInfoExtractor
DWARFDataExtractor getDebugInfoExtractor() const
Definition:
DWARFUnit.cpp:214
llvm::DWARFFormValue::skipValue
bool skipValue(DataExtractor DebugInfoData, uint64_t *OffsetPtr, const dwarf::FormParams Params) const
Skip a form's value in DebugInfoData at the offset specified by OffsetPtr.
Definition:
DWARFFormValue.h:131
Optional.h
Generated on Tue Mar 24 2020 13:10:29 for LLVM by
1.8.13