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