30 assert(Operand < Operands.
size() &&
"operand out of bounds");
32 OS <<
format(
" <base_type ref: 0x%" PRIx64
">", Operands[Operand]);
35 auto Die = U->getDIEForOffset(U->getOffset() + Operands[Operand]);
36 if (Die && Die.getTag() == dwarf::DW_TAG_base_type) {
39 OS <<
format(
"0x%08" PRIx64
" -> ", Operands[Operand]);
40 OS <<
format(
"0x%08" PRIx64
")", U->getOffset() + Operands[Operand]);
42 OS <<
" \"" << *Name <<
"\"";
44 OS <<
format(
" <invalid base_type ref: 0x%" PRIx64
">", Operands[Operand]);
53 OS <<
"<decoding error>";
57 std::optional<unsigned> SubOpcode =
Op->getSubCode();
66 if ((
Op->getCode() >= DW_OP_breg0 &&
Op->getCode() <= DW_OP_breg31) ||
67 (
Op->getCode() >= DW_OP_reg0 &&
Op->getCode() <= DW_OP_reg31) ||
68 Op->getCode() == DW_OP_bregx ||
Op->getCode() == DW_OP_regx ||
69 Op->getCode() == DW_OP_regval_type ||
70 SubOpcode == DW_OP_LLVM_call_frame_entry_reg ||
71 SubOpcode == DW_OP_LLVM_aspace_bregx) {
73 Op->getRawOperands()))
79 if (
Op->getCode() == DW_OP_constu) {
83 if (
Op->getCode() == DW_OP_consts) {
84 OS << (int64_t)
Op->getRawOperand(0);
87 if (
Op->getCode() >= DW_OP_lit0 &&
Op->getCode() <= DW_OP_lit31) {
91 if (
Op->getCode() == DW_OP_stack_value)
99 assert(!Name.empty() &&
"DW_OP has no name!");
104 assert(!SubName.
empty() &&
"DW_OP SubOp has no name!");
105 OS <<
' ' << SubName;
109 if ((
Op->getCode() >= DW_OP_breg0 &&
Op->getCode() <= DW_OP_breg31) ||
110 (
Op->getCode() >= DW_OP_reg0 &&
Op->getCode() <= DW_OP_reg31) ||
111 Op->getCode() == DW_OP_bregx ||
Op->getCode() == DW_OP_regx ||
112 Op->getCode() == DW_OP_regval_type ||
113 SubOpcode == DW_OP_LLVM_call_frame_entry_reg ||
114 SubOpcode == DW_OP_LLVM_aspace_bregx)
116 Op->getRawOperands()))
120 for (
unsigned Operand = 0; Operand <
Op->getDescription().
Op.size();
122 unsigned Size =
Op->getDescription().Op[Operand];
126 assert(Operand == 0 &&
"DW_OP SubOp must be the first operand");
127 assert(SubOpcode &&
"DW_OP SubOp description is inconsistent");
132 if (
Op->getCode() == DW_OP_convert &&
Op->getRawOperand(Operand) == 0)
139 switch (
Op->getRawOperand(0)) {
145 OS <<
format(
" 0x%" PRIx64,
Op->getRawOperand(Operand));
152 for (
unsigned i = 0; i <
Op->getRawOperand(Operand - 1); ++i)
157 OS <<
formatv(
" {0:+d}", (int64_t)
Op->getRawOperand(Operand));
158 else if (
Op->getCode() != DW_OP_entry_value &&
159 Op->getCode() != DW_OP_GNU_entry_value)
160 OS <<
format(
" 0x%" PRIx64,
Op->getRawOperand(Operand));
171 if (E->getData().empty())
174 for (
auto &
Op : *E) {
175 DumpOpts.
IsEH = IsEH;
178 while (FailOffset < E->getData().
size())
179 OS <<
format(
" %02x",
static_cast<uint8_t>(E->getData()[FailOffset++]));
183 if (
Op.getCode() == DW_OP_entry_value ||
184 Op.getCode() == DW_OP_GNU_entry_value) {
186 EntryValExprSize =
Op.getRawOperand(0);
187 EntryValStartOffset =
Op.getEndOffset();
191 if (EntryValExprSize) {
192 EntryValExprSize -=
Op.getEndOffset() - EntryValStartOffset;
193 if (EntryValExprSize == 0)
197 if (
Op.getEndOffset() < E->getData().size())
225 std::optional<unsigned> SubOpcode) ->
bool {
232 <<
" (" << *SubOpcode;
241 case dwarf::DW_OP_regx: {
245 auto RegName = GetNameForDWARFReg(DwarfRegNum,
false);
252 case dwarf::DW_OP_bregx: {
253 int DwarfRegNum =
Op.getRawOperand(0);
254 int64_t
Offset =
Op.getRawOperand(1);
255 auto RegName = GetNameForDWARFReg(DwarfRegNum,
false);
264 case dwarf::DW_OP_entry_value:
265 case dwarf::DW_OP_GNU_entry_value: {
278 case dwarf::DW_OP_stack_value: {
285 case dwarf::DW_OP_nop: {
288 case dwarf::DW_OP_LLVM_user: {
289 std::optional<unsigned> SubOpcode =
Op.getSubCode();
290 if (SubOpcode == dwarf::DW_OP_LLVM_nop)
292 return UnknownOpcode(OS, Opcode, SubOpcode);
295 if (Opcode >= dwarf::DW_OP_reg0 && Opcode <= dwarf::DW_OP_reg31) {
298 uint64_t DwarfRegNum = Opcode - dwarf::DW_OP_reg0;
299 auto RegName = GetNameForDWARFReg(DwarfRegNum,
false);
304 }
else if (Opcode >= dwarf::DW_OP_breg0 &&
305 Opcode <= dwarf::DW_OP_breg31) {
306 int DwarfRegNum = Opcode - dwarf::DW_OP_breg0;
307 int64_t
Offset =
Op.getRawOperand(0);
308 auto RegName = GetNameForDWARFReg(DwarfRegNum,
false);
316 return UnknownOpcode(OS, Opcode, std::nullopt);
323 if (Stack.size() != 1) {
324 OS <<
"<stack of size " << Stack.size() <<
", expected 1>";
329 OS <<
"[" << Stack.front().String <<
"]";
331 OS << Stack.front().String;
351 std::optional<unsigned> SubOpcode;
352 if (Opcode == DW_OP_LLVM_user)
353 SubOpcode = Operands[OpNum++];
355 if (Opcode == DW_OP_bregx || Opcode == DW_OP_regx ||
356 Opcode == DW_OP_regval_type || SubOpcode == DW_OP_LLVM_aspace_bregx ||
357 SubOpcode == DW_OP_LLVM_call_frame_entry_reg)
358 DwarfRegNum = Operands[OpNum++];
359 else if (Opcode >= DW_OP_breg0 && Opcode < DW_OP_bregx)
360 DwarfRegNum = Opcode - DW_OP_breg0;
362 DwarfRegNum = Opcode - DW_OP_reg0;
366 if ((Opcode >= DW_OP_breg0 && Opcode <= DW_OP_breg31) ||
367 Opcode == DW_OP_bregx || SubOpcode == DW_OP_LLVM_aspace_bregx)
368 OS <<
' ' <<
RegName <<
formatv(
"{0:+d}", int64_t(Operands[OpNum]));
372 if (Opcode == DW_OP_regval_type)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the SmallString class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - 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...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
constexpr bool empty() const
empty - 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.
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)
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
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)