Go to the documentation of this file.
28 class DWARFLocationInterpreter {
30 std::function<Optional<object::SectionedAddress>(
uint32_t)> LookupAddr;
33 DWARFLocationInterpreter(
36 : Base(Base), LookupAddr(
std::
move(LookupAddr)) {}
45 "Unable to resolve indirect address %u for: %s",
52 case dwarf::DW_LLE_end_of_list:
54 case dwarf::DW_LLE_base_addressx: {
55 Base = LookupAddr(
E.Value0);
60 case dwarf::DW_LLE_startx_endx: {
71 case dwarf::DW_LLE_startx_length: {
80 case dwarf::DW_LLE_offset_pair: {
83 "Unable to resolve location list offset pair: "
84 "Base address not defined");
88 if (Range.SectionIndex == SectionedAddress::UndefSection)
89 Range.SectionIndex =
E.SectionIndex;
92 case dwarf::DW_LLE_default_location:
94 case dwarf::DW_LLE_base_address:
97 case dwarf::DW_LLE_start_end:
100 case dwarf::DW_LLE_start_length:
126 unsigned Indent)
const {
127 DWARFLocationInterpreter Interp(
146 if (Loc.
get()->Range)
154 if (
E.Kind != dwarf::DW_LLE_base_address &&
155 E.Kind != dwarf::DW_LLE_base_addressx &&
156 E.Kind != dwarf::DW_LLE_end_of_list) {
158 dumpExpression(OS, DumpOpts, E.Loc, Data.isLittleEndian(),
159 Data.getAddressSize(), MRI, U);
174 DWARFLocationInterpreter Interp(BaseAddr,
std::move(LookupAddr));
180 return Callback(**Loc);
188 auto BaseAddr =
None;
189 unsigned Indent = 12;
196 bool CanContinue =
true;
213 uint64_t SectionIndex;
223 if (Value0 == 0 && Value1 == 0) {
224 E.Kind = dwarf::DW_LLE_end_of_list;
226 E.Kind = dwarf::DW_LLE_base_address;
228 E.SectionIndex = SectionIndex;
230 E.Kind = dwarf::DW_LLE_offset_pair;
233 E.SectionIndex = SectionIndex;
240 return C.takeError();
241 if (!Callback(
E) ||
E.Kind == dwarf::DW_LLE_end_of_list)
252 uint64_t Value0, Value1;
253 switch (Entry.Kind) {
254 case dwarf::DW_LLE_base_address:
256 Value1 = Entry.Value0;
258 case dwarf::DW_LLE_offset_pair:
259 Value0 = Entry.Value0;
260 Value1 = Entry.Value1;
262 case dwarf::DW_LLE_end_of_list:
278 bool Continue =
true;
283 case dwarf::DW_LLE_end_of_list:
285 case dwarf::DW_LLE_base_addressx:
288 case dwarf::DW_LLE_startx_endx:
292 case dwarf::DW_LLE_startx_length:
301 case dwarf::DW_LLE_offset_pair:
304 E.SectionIndex = SectionedAddress::UndefSection;
306 case dwarf::DW_LLE_default_location:
308 case dwarf::DW_LLE_base_address:
311 case dwarf::DW_LLE_start_end:
315 case dwarf::DW_LLE_start_length:
322 "LLE of kind %x not supported", (
int)
E.Kind);
325 if (
E.Kind != dwarf::DW_LLE_base_address &&
326 E.Kind != dwarf::DW_LLE_base_addressx &&
327 E.Kind != dwarf::DW_LLE_end_of_list) {
334 return C.takeError();
335 Continue =
F(
E) &&
E.Kind != dwarf::DW_LLE_end_of_list;
345 size_t MaxEncodingStringLength = 0;
346 #define HANDLE_DW_LLE(ID, NAME) \
347 MaxEncodingStringLength = std::max(MaxEncodingStringLength, \
348 dwarf::LocListEncodingString(ID).size());
349 #include "llvm/BinaryFormat/Dwarf.def"
355 assert(!EncodingString.
empty() &&
"Unknown loclist entry encoding");
356 OS <<
format(
"%-*s(", MaxEncodingStringLength, EncodingString.
data());
358 switch (Entry.Kind) {
359 case dwarf::DW_LLE_end_of_list:
360 case dwarf::DW_LLE_default_location:
362 case dwarf::DW_LLE_startx_endx:
363 case dwarf::DW_LLE_startx_length:
364 case dwarf::DW_LLE_offset_pair:
365 case dwarf::DW_LLE_start_end:
366 case dwarf::DW_LLE_start_length:
367 OS <<
format_hex(Entry.Value0, FieldSize) <<
", "
370 case dwarf::DW_LLE_base_addressx:
371 case dwarf::DW_LLE_base_address:
376 switch (Entry.Kind) {
377 case dwarf::DW_LLE_base_address:
378 case dwarf::DW_LLE_start_end:
379 case dwarf::DW_LLE_start_length:
392 OS <<
"Invalid dump range\n";
395 uint64_t
Offset = StartOffset;
397 bool CanContinue =
true;
398 while (CanContinue &&
Offset < StartOffset +
Size) {
403 nullptr, DumpOpts, 12);
static void dumpExpression(raw_ostream &OS, DIDumpOptions DumpOpts, ArrayRef< uint8_t > Data, bool IsLittleEndian, unsigned AddressSize, const MCRegisterInfo *MRI, DWARFUnit *U)
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
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.
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.
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