41 const char *
Data =
reinterpret_cast<const char *
>(&DwarfRegNumBE);
42 const char *Begin = std::find_if(
Data,
Data +
sizeof(DwarfRegNumBE),
43 [](
char c) {
return c !=
'\0'; });
52 for (
size_t I = 1;
I < Tmp.size(); ++
I)
67 if (GetNameForDWARFReg) {
68 StringRef R = GetNameForDWARFReg(DwarfRegNum, IsEH);
74 return Decoded.
str().
str();
82 assert(Operand < Operands.
size() &&
"operand out of bounds");
84 OS <<
formatv(
" <base_type ref: {0:x}>", Operands[Operand]);
87 auto Die = U->getDIEForOffset(U->getOffset() + Operands[Operand]);
88 if (Die && Die.getTag() == dwarf::DW_TAG_base_type) {
91 OS <<
formatv(
"{0:x8} -> ", Operands[Operand]);
92 OS <<
formatv(
"{0:x8})", U->getOffset() + Operands[Operand]);
94 OS <<
" \"" << *Name <<
"\"";
96 OS <<
formatv(
" <invalid base_type ref: {0:x}>", Operands[Operand]);
105 OS <<
"<decoding error>";
109 std::optional<unsigned> SubOpcode =
Op->getSubCode();
118 if ((
Op->getCode() >= DW_OP_breg0 &&
Op->getCode() <= DW_OP_breg31) ||
119 (
Op->getCode() >= DW_OP_reg0 &&
Op->getCode() <= DW_OP_reg31) ||
120 Op->getCode() == DW_OP_bregx ||
Op->getCode() == DW_OP_regx ||
121 Op->getCode() == DW_OP_regval_type ||
122 SubOpcode == DW_OP_LLVM_call_frame_entry_reg ||
123 SubOpcode == DW_OP_LLVM_aspace_bregx) {
125 Op->getRawOperands()))
131 if (
Op->getCode() == DW_OP_constu) {
135 if (
Op->getCode() == DW_OP_consts) {
136 OS << (int64_t)
Op->getRawOperand(0);
139 if (
Op->getCode() >= DW_OP_lit0 &&
Op->getCode() <= DW_OP_lit31) {
143 if (
Op->getCode() == DW_OP_stack_value)
151 assert(!Name.empty() &&
"DW_OP has no name!");
156 assert(!SubName.
empty() &&
"DW_OP SubOp has no name!");
157 OS <<
' ' << SubName;
161 if ((
Op->getCode() >= DW_OP_breg0 &&
Op->getCode() <= DW_OP_breg31) ||
162 (
Op->getCode() >= DW_OP_reg0 &&
Op->getCode() <= DW_OP_reg31) ||
163 Op->getCode() == DW_OP_bregx ||
Op->getCode() == DW_OP_regx ||
164 Op->getCode() == DW_OP_regval_type ||
165 SubOpcode == DW_OP_LLVM_call_frame_entry_reg ||
166 SubOpcode == DW_OP_LLVM_aspace_bregx)
168 Op->getRawOperands()))
172 for (
unsigned Operand = 0; Operand <
Op->getDescription().
Op.size();
174 unsigned Size =
Op->getDescription().Op[Operand];
178 assert(Operand == 0 &&
"DW_OP SubOp must be the first operand");
179 assert(SubOpcode &&
"DW_OP SubOp description is inconsistent");
184 if (
Op->getCode() == DW_OP_convert &&
Op->getRawOperand(Operand) == 0)
191 switch (
Op->getRawOperand(0)) {
197 OS <<
formatv(
" {0:x}",
Op->getRawOperand(Operand));
204 for (
unsigned i = 0; i <
Op->getRawOperand(Operand - 1); ++i)
209 OS <<
formatv(
" {0:+d}", (int64_t)
Op->getRawOperand(Operand));
210 else if (
Op->getCode() != DW_OP_entry_value &&
211 Op->getCode() != DW_OP_GNU_entry_value)
212 OS <<
formatv(
" {0:x}",
Op->getRawOperand(Operand));
223 if (E->getData().empty())
226 for (
auto &
Op : *E) {
227 DumpOpts.
IsEH = IsEH;
230 while (FailOffset < E->getData().
size())
232 static_cast<uint8_t>(E->getData()[FailOffset++]));
236 if (
Op.getCode() == DW_OP_entry_value ||
237 Op.getCode() == DW_OP_GNU_entry_value) {
239 EntryValExprSize =
Op.getRawOperand(0);
240 EntryValStartOffset =
Op.getEndOffset();
244 if (EntryValExprSize) {
245 EntryValExprSize -=
Op.getEndOffset() - EntryValStartOffset;
246 if (EntryValExprSize == 0)
250 if (
Op.getEndOffset() < E->getData().size())
278 std::optional<unsigned> SubOpcode) ->
bool {
285 <<
" (" << *SubOpcode;
294 case dwarf::DW_OP_regx: {
297 const uint64_t DwarfRegNum =
Op.getRawOperand(0);
306 case dwarf::DW_OP_bregx: {
307 const uint64_t DwarfRegNum =
Op.getRawOperand(0);
319 case dwarf::DW_OP_entry_value:
320 case dwarf::DW_OP_GNU_entry_value: {
333 case dwarf::DW_OP_stack_value: {
340 case dwarf::DW_OP_nop: {
343 case dwarf::DW_OP_LLVM_user: {
344 std::optional<unsigned> SubOpcode =
Op.getSubCode();
345 if (SubOpcode == dwarf::DW_OP_LLVM_nop)
347 return UnknownOpcode(OS, Opcode, SubOpcode);
350 if (Opcode >= dwarf::DW_OP_reg0 && Opcode <= dwarf::DW_OP_reg31) {
353 uint64_t DwarfRegNum = Opcode - dwarf::DW_OP_reg0;
354 auto RegName = GetNameForDWARFReg(DwarfRegNum,
false);
359 }
else if (Opcode >= dwarf::DW_OP_breg0 &&
360 Opcode <= dwarf::DW_OP_breg31) {
361 int DwarfRegNum = Opcode - dwarf::DW_OP_breg0;
362 int64_t
Offset =
Op.getRawOperand(0);
363 auto RegName = GetNameForDWARFReg(DwarfRegNum,
false);
371 return UnknownOpcode(OS, Opcode, std::nullopt);
378 if (Stack.size() != 1) {
379 OS <<
"<stack of size " << Stack.size() <<
", expected 1>";
384 OS <<
"[" << Stack.front().String <<
"]";
386 OS << Stack.front().String;
403 std::optional<unsigned> SubOpcode;
404 if (Opcode == DW_OP_LLVM_user)
405 SubOpcode = Operands[OpNum++];
407 const bool RegNumFromOperand =
408 Opcode == DW_OP_bregx || Opcode == DW_OP_regx ||
409 Opcode == DW_OP_regval_type || SubOpcode == DW_OP_LLVM_aspace_bregx ||
410 SubOpcode == DW_OP_LLVM_call_frame_entry_reg;
412 if (RegNumFromOperand)
413 DwarfRegNum = Operands[OpNum++];
414 else if (Opcode >= DW_OP_breg0 && Opcode < DW_OP_bregx)
415 DwarfRegNum = Opcode - DW_OP_breg0;
417 DwarfRegNum = Opcode - DW_OP_reg0;
423 if ((Opcode >= DW_OP_breg0 && Opcode <= DW_OP_breg31) ||
424 Opcode == DW_OP_bregx || SubOpcode == DW_OP_LLVM_aspace_bregx)
425 OS <<
' ' <<
RegName <<
formatv(
"{0:+d}", int64_t(Operands[OpNum]));
429 if (Opcode == DW_OP_regval_type)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the SmallString class.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
Get the array size.
This class represents an Operation in the Expression.
@ SizeSubOpLEB
The operand is a ULEB128 encoded SubOpcode.
@ SizeBlock
Preceding operand contains block size.
An iterator to go through the expression operations.
StringRef getData() const
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
StringRef str() const
Explicit conversion to StringRef.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
std::string str() const
Get the contents as an std::string.
constexpr bool empty() const
Check if the string is empty.
This class implements an extremely fast bulk output stream that can only output to a stream.
A raw_ostream that writes to an SmallVector or SmallString.
LLVM_ABI StringRef SubOperationEncodingString(unsigned OpEncoding, unsigned SubOpEncoding)
LLVM_ABI StringRef OperationEncodingString(unsigned Encoding)
Calculates the starting offsets for various sections within the .debug_names section.
std::optional< const char * > toString(const std::optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract a string value from it.
value_type byte_swap(value_type value, endianness endian)
This is an optimization pass for GlobalISel generic memory operations.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
static bool printOp(const DWARFExpression::Operation *Op, raw_ostream &OS, DIDumpOptions DumpOpts, const DWARFExpression *Expr, DWARFUnit *U)
LLVM_ABI void printDwarfExpression(const DWARFExpression *E, raw_ostream &OS, DIDumpOptions DumpOpts, DWARFUnit *U, bool IsEH=false)
Print a Dwarf expression/.
static bool printCompactDWARFExpr(raw_ostream &OS, DWARFExpression::iterator I, const DWARFExpression::iterator E, std::function< StringRef(uint64_t RegNum, bool IsEH)> GetNameForDWARFReg=nullptr)
static void prettyPrintBaseTypeRef(DWARFUnit *U, raw_ostream &OS, DIDumpOptions DumpOpts, ArrayRef< uint64_t > Operands, unsigned Operand)
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
static bool decodeVirtualRegisterName(uint64_t DwarfRegNum, SmallString< 8 > &Out)
Some backends (e.g.
bool isAlnum(char C)
Checks whether character C is either a decimal digit or an uppercase or lowercase letter as classifie...
static std::string resolveRegName(uint64_t DwarfRegNum, bool IsEH, const std::function< StringRef(uint64_t, bool)> &GetNameForDWARFReg)
Resolves a DWARF register number to a display name: first via GetNameForDWARFReg (MC register names),...
FunctionAddr VTableAddr uintptr_t uintptr_t Data
DWARFExpression::Operation Op
LLVM_ABI bool prettyPrintRegisterOp(DWARFUnit *U, raw_ostream &OS, DIDumpOptions DumpOpts, uint8_t Opcode, ArrayRef< uint64_t > Operands)
Pretty print a register opcode and operands.
LLVM_ABI bool printDwarfExpressionCompact(const DWARFExpression *E, raw_ostream &OS, std::function< StringRef(uint64_t RegNum, bool IsEH)> GetNameForDWARFReg=nullptr)
Print the expression in a format intended to be compact and useful to a user, but not perfectly unamb...
Container for dump options that control which debug information will be dumped.
std::function< llvm::StringRef(uint64_t DwarfRegNum, bool IsEH)> GetNameForDWARFReg
Description of the encoding of one expression Op.
PrintedExpr(ExprKind K=Address)