Go to the documentation of this file.
32 class DWARFLocationInterpreter {
34 std::function<Optional<object::SectionedAddress>(
uint32_t)> LookupAddr;
37 DWARFLocationInterpreter(
54 case dwarf::DW_LLE_end_of_list:
56 case dwarf::DW_LLE_base_addressx: {
57 Base = LookupAddr(
E.Value0);
62 case dwarf::DW_LLE_startx_endx: {
73 case dwarf::DW_LLE_startx_length: {
82 case dwarf::DW_LLE_offset_pair: {
85 "Unable to resolve location list offset pair: "
86 "Base address not defined");
90 if (Range.SectionIndex == SectionedAddress::UndefSection)
91 Range.SectionIndex =
E.SectionIndex;
94 case dwarf::DW_LLE_default_location:
96 case dwarf::DW_LLE_base_address:
99 case dwarf::DW_LLE_start_end:
102 case dwarf::DW_LLE_start_length:
128 unsigned Indent)
const {
129 DWARFLocationInterpreter Interp(
135 OS <<
format(
"0x%8.8" PRIx64
": ", *Offset);
148 if (Loc.
get()->Range)
156 if (
E.Kind != dwarf::DW_LLE_base_address &&
157 E.Kind != dwarf::DW_LLE_base_addressx &&
158 E.Kind != dwarf::DW_LLE_end_of_list) {
160 dumpExpression(OS, DumpOpts, E.Loc, Data.isLittleEndian(),
161 Data.getAddressSize(), MRI, U);
176 DWARFLocationInterpreter Interp(BaseAddr,
std::move(LookupAddr));
182 return Callback(**Loc);
190 auto BaseAddr =
None;
191 unsigned Indent = 12;
198 bool CanContinue =
true;
225 if (Value0 == 0 && Value1 == 0) {
226 E.Kind = dwarf::DW_LLE_end_of_list;
228 E.Kind = dwarf::DW_LLE_base_address;
230 E.SectionIndex = SectionIndex;
232 E.Kind = dwarf::DW_LLE_offset_pair;
235 E.SectionIndex = SectionIndex;
242 return C.takeError();
243 if (!Callback(
E) ||
E.Kind == dwarf::DW_LLE_end_of_list)
255 switch (Entry.Kind) {
256 case dwarf::DW_LLE_base_address:
258 Value1 = Entry.Value0;
260 case dwarf::DW_LLE_offset_pair:
261 Value0 = Entry.Value0;
262 Value1 = Entry.Value1;
264 case dwarf::DW_LLE_end_of_list:
280 bool Continue =
true;
285 case dwarf::DW_LLE_end_of_list:
287 case dwarf::DW_LLE_base_addressx:
290 case dwarf::DW_LLE_startx_endx:
294 case dwarf::DW_LLE_startx_length:
303 case dwarf::DW_LLE_offset_pair:
306 E.SectionIndex = SectionedAddress::UndefSection;
308 case dwarf::DW_LLE_default_location:
310 case dwarf::DW_LLE_base_address:
313 case dwarf::DW_LLE_start_end:
317 case dwarf::DW_LLE_start_length:
324 "LLE of kind %x not supported", (
int)
E.Kind);
327 if (
E.Kind != dwarf::DW_LLE_base_address &&
328 E.Kind != dwarf::DW_LLE_base_addressx &&
329 E.Kind != dwarf::DW_LLE_end_of_list) {
336 return C.takeError();
337 Continue =
F(
E) &&
E.Kind != dwarf::DW_LLE_end_of_list;
347 size_t MaxEncodingStringLength = 0;
348 #define HANDLE_DW_LLE(ID, NAME) \
349 MaxEncodingStringLength = std::max(MaxEncodingStringLength, \
350 dwarf::LocListEncodingString(ID).size());
351 #include "llvm/BinaryFormat/Dwarf.def"
357 assert(!EncodingString.
empty() &&
"Unknown loclist entry encoding");
358 OS <<
format(
"%-*s(", MaxEncodingStringLength, EncodingString.
data());
360 switch (Entry.Kind) {
361 case dwarf::DW_LLE_end_of_list:
362 case dwarf::DW_LLE_default_location:
364 case dwarf::DW_LLE_startx_endx:
365 case dwarf::DW_LLE_startx_length:
366 case dwarf::DW_LLE_offset_pair:
367 case dwarf::DW_LLE_start_end:
368 case dwarf::DW_LLE_start_length:
369 OS <<
format_hex(Entry.Value0, FieldSize) <<
", "
372 case dwarf::DW_LLE_base_addressx:
373 case dwarf::DW_LLE_base_address:
378 switch (Entry.Kind) {
379 case dwarf::DW_LLE_base_address:
380 case dwarf::DW_LLE_start_end:
381 case dwarf::DW_LLE_start_length:
394 OS <<
"Invalid dump range\n";
399 bool CanContinue =
true;
400 while (CanContinue && Offset < StartOffset + Size) {
405 nullptr, DumpOpts, 12);
411 OS <<
format(
"unable to resolve indirect address %u for: %s", Index,
static void dumpExpression(raw_ostream &OS, DIDumpOptions DumpOpts, ArrayRef< uint8_t > Data, bool IsLittleEndian, unsigned AddressSize, const MCRegisterInfo *MRI, DWARFUnit *U)
This is an optimization pass for GlobalISel generic memory operations.
static ErrorSuccess success()
Create a success value.
Represents a single DWARF expression, whose value is location-dependent.
void print(raw_ostream &OS, DIDumpOptions DumpOpts, const MCRegisterInfo *RegInfo, DWARFUnit *U, bool IsEH=false) const
Tagged union holding either a T or a Error.
LoclistEntries
DWARF v5 loc list entry encoding values.
void consumeError(Error Err)
Consume a Error without doing anything.
Optional< object::SectionedAddress > getAddrOffsetSectionItem(uint32_t Index) const
void dumpRawEntry(const DWARFLocationEntry &Entry, raw_ostream &OS, unsigned Indent, DIDumpOptions DumpOpts, const DWARFObject &Obj) const override
A single location within a location list.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
(vector float) vec_cmpeq(*A, *B) C
bool dumpLocationList(uint64_t *Offset, raw_ostream &OS, Optional< object::SectionedAddress > BaseAddr, const MCRegisterInfo *MRI, const DWARFObject &Obj, DWARFUnit *U, DIDumpOptions DumpOpts, unsigned Indent) const
Dump the location list at the given Offset.
This class implements an extremely fast bulk output stream that can only output to a stream.
An efficient, type-erasing, non-owning reference to a callable.
void log(raw_ostream &OS) const override
Print an error message to an output stream.
constexpr LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
Error visitAbsoluteLocationList(uint64_t Offset, Optional< object::SectionedAddress > BaseAddr, std::function< Optional< object::SectionedAddress >(uint32_t)> LookupAddr, function_ref< bool(Expected< DWARFLocationExpression >)> Callback) const
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
print Print MemDeps of function
StringRef - Represent a constant reference to a string, i.e.
virtual Error visitLocationList(uint64_t *Offset, function_ref< bool(const DWARFLocationEntry &)> Callback) const =0
Call the user-provided callback for each entry (including the end-of-list entry) in the location list...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
if(llvm_vc STREQUAL "") set(fake_version_inc "$
reference get()
Returns a reference to the stored T value.
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
void dump(raw_ostream &OS, const MCRegisterInfo *RegInfo, const DWARFObject &Obj, DIDumpOptions DumpOpts, Optional< uint64_t > Offset) const
Print the location lists found within the debug_loc section.
unsigned const MachineRegisterInfo * MRI
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Lightweight error class with error context and mandatory checking.
Error visitLocationList(uint64_t *Offset, function_ref< bool(const DWARFLocationEntry &)> Callback) const override
Call the user-provided callback for each entry (including the end-of-list entry) in the location list...
virtual void dumpRawEntry(const DWARFLocationEntry &Entry, raw_ostream &OS, unsigned Indent, DIDumpOptions DumpOpts, const DWARFObject &Obj) const =0
Error takeError()
Take ownership of the stored error.
raw_ostream & indent(unsigned NumSpaces)
indent - Insert 'NumSpaces' spaces.
void dumpRange(uint64_t StartOffset, uint64_t Size, raw_ostream &OS, const MCRegisterInfo *MRI, const DWARFObject &Obj, DIDumpOptions DumpOpts)
Dump all location lists within the given range.
const LLVM_NODISCARD char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Error visitLocationList(uint64_t *Offset, function_ref< bool(const DWARFLocationEntry &)> Callback) const override
Call the user-provided callback for each entry (including the end-of-list entry) in the location list...
void dumpRawEntry(const DWARFLocationEntry &Entry, raw_ostream &OS, unsigned Indent, DIDumpOptions DumpOpts, const DWARFObject &Obj) const override
FormattedNumber format_hex(uint64_t N, unsigned Width, bool Upper=false)
format_hex - Output N as a fixed width hexadecimal.
StringRef LocListEncodingString(unsigned Encoding)
static Error createResolverError(uint32_t Index, unsigned Kind)
Container for dump options that control which debug information will be dumped.
std::function< void(Error)> RecoverableErrorHandler