1 //===- DWARFDie.cpp -------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "llvm/DebugInfo/DWARF/DWARFDie.h" 10 #include "llvm/ADT/None.h" 11 #include "llvm/ADT/Optional.h" 12 #include "llvm/ADT/SmallSet.h" 13 #include "llvm/ADT/StringRef.h" 14 #include "llvm/BinaryFormat/Dwarf.h" 15 #include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h" 16 #include "llvm/DebugInfo/DWARF/DWARFContext.h" 17 #include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h" 18 #include "llvm/DebugInfo/DWARF/DWARFExpression.h" 19 #include "llvm/DebugInfo/DWARF/DWARFFormValue.h" 20 #include "llvm/DebugInfo/DWARF/DWARFUnit.h" 21 #include "llvm/Object/ObjectFile.h" 22 #include "llvm/Support/DataExtractor.h" 23 #include "llvm/Support/Format.h" 24 #include "llvm/Support/FormatAdapters.h" 25 #include "llvm/Support/FormatVariadic.h" 26 #include "llvm/Support/MathExtras.h" 27 #include "llvm/Support/WithColor.h" 28 #include "llvm/Support/raw_ostream.h" 29 #include <algorithm> 30 #include <cassert> 31 #include <cinttypes> 32 #include <cstdint> 33 #include <string> 34 #include <utility> 35 36 using namespace llvm; 37 using namespace dwarf; 38 using namespace object; 39 40 static void dumpApplePropertyAttribute(raw_ostream &OS, uint64_t Val) { 41 OS << " ("; 42 do { 43 uint64_t Shift = countTrailingZeros(Val); 44 assert(Shift < 64 && "undefined behavior"); 45 uint64_t Bit = 1ULL << Shift; 46 auto PropName = ApplePropertyString(Bit); 47 if (!PropName.empty()) 48 OS << PropName; 49 else 50 OS << format("DW_APPLE_PROPERTY_0x%" PRIx64, Bit); 51 if (!(Val ^= Bit)) 52 break; 53 OS << ", "; 54 } while (true); 55 OS << ")"; 56 } 57 58 static void dumpRanges(const DWARFObject &Obj, raw_ostream &OS, 59 const DWARFAddressRangesVector &Ranges, 60 unsigned AddressSize, unsigned Indent, 61 const DIDumpOptions &DumpOpts) { 62 if (!DumpOpts.ShowAddresses) 63 return; 64 65 for (const DWARFAddressRange &R : Ranges) { 66 OS << '\n'; 67 OS.indent(Indent); 68 R.dump(OS, AddressSize, DumpOpts, &Obj); 69 } 70 } 71 72 static void dumpLocationList(raw_ostream &OS, const DWARFFormValue &FormValue, 73 DWARFUnit *U, unsigned Indent, 74 DIDumpOptions DumpOpts) { 75 assert(FormValue.isFormClass(DWARFFormValue::FC_SectionOffset) && 76 "bad FORM for location list"); 77 DWARFContext &Ctx = U->getContext(); 78 const MCRegisterInfo *MRI = Ctx.getRegisterInfo(); 79 uint64_t Offset = *FormValue.getAsSectionOffset(); 80 81 if (FormValue.getForm() == DW_FORM_loclistx) { 82 FormValue.dump(OS, DumpOpts); 83 84 if (auto LoclistOffset = U->getLoclistOffset(Offset)) 85 Offset = *LoclistOffset; 86 else 87 return; 88 } 89 U->getLocationTable().dumpLocationList(&Offset, OS, U->getBaseAddress(), MRI, 90 Ctx.getDWARFObj(), U, DumpOpts, 91 Indent); 92 } 93 94 static void dumpLocationExpr(raw_ostream &OS, const DWARFFormValue &FormValue, 95 DWARFUnit *U, unsigned Indent, 96 DIDumpOptions DumpOpts) { 97 assert((FormValue.isFormClass(DWARFFormValue::FC_Block) || 98 FormValue.isFormClass(DWARFFormValue::FC_Exprloc)) && 99 "bad FORM for location expression"); 100 DWARFContext &Ctx = U->getContext(); 101 const MCRegisterInfo *MRI = Ctx.getRegisterInfo(); 102 ArrayRef<uint8_t> Expr = *FormValue.getAsBlock(); 103 DataExtractor Data(StringRef((const char *)Expr.data(), Expr.size()), 104 Ctx.isLittleEndian(), 0); 105 DWARFExpression(Data, U->getAddressByteSize(), U->getFormParams().Format) 106 .print(OS, DumpOpts, MRI, U); 107 } 108 109 static DWARFDie resolveReferencedType(DWARFDie D, 110 dwarf::Attribute Attr = DW_AT_type) { 111 return D.getAttributeValueAsReferencedDie(Attr).resolveTypeUnitReference(); 112 } 113 static DWARFDie resolveReferencedType(DWARFDie D, DWARFFormValue F) { 114 return D.getAttributeValueAsReferencedDie(F).resolveTypeUnitReference(); 115 } 116 117 namespace { 118 119 // FIXME: We should have pretty printers per language. Currently we print 120 // everything as if it was C++ and fall back to the TAG type name. 121 struct DWARFTypePrinter { 122 raw_ostream &OS; 123 bool Word = true; 124 bool EndedWithTemplate = false; 125 126 DWARFTypePrinter(raw_ostream &OS) : OS(OS) {} 127 128 /// Dump the name encoded in the type tag. 129 void appendTypeTagName(dwarf::Tag T) { 130 StringRef TagStr = TagString(T); 131 static constexpr StringRef Prefix = "DW_TAG_"; 132 static constexpr StringRef Suffix = "_type"; 133 if (!TagStr.startswith(Prefix) || !TagStr.endswith(Suffix)) 134 return; 135 OS << TagStr.substr(Prefix.size(), 136 TagStr.size() - (Prefix.size() + Suffix.size())) 137 << " "; 138 } 139 140 void appendArrayType(const DWARFDie &D) { 141 for (const DWARFDie &C : D.children()) { 142 if (C.getTag() != DW_TAG_subrange_type) 143 continue; 144 Optional<uint64_t> LB; 145 Optional<uint64_t> Count; 146 Optional<uint64_t> UB; 147 Optional<unsigned> DefaultLB; 148 if (Optional<DWARFFormValue> L = C.find(DW_AT_lower_bound)) 149 LB = L->getAsUnsignedConstant(); 150 if (Optional<DWARFFormValue> CountV = C.find(DW_AT_count)) 151 Count = CountV->getAsUnsignedConstant(); 152 if (Optional<DWARFFormValue> UpperV = C.find(DW_AT_upper_bound)) 153 UB = UpperV->getAsUnsignedConstant(); 154 if (Optional<DWARFFormValue> LV = 155 D.getDwarfUnit()->getUnitDIE().find(DW_AT_language)) 156 if (Optional<uint64_t> LC = LV->getAsUnsignedConstant()) 157 if ((DefaultLB = 158 LanguageLowerBound(static_cast<dwarf::SourceLanguage>(*LC)))) 159 if (LB && *LB == *DefaultLB) 160 LB = None; 161 if (!LB && !Count && !UB) 162 OS << "[]"; 163 else if (!LB && (Count || UB) && DefaultLB) 164 OS << '[' << (Count ? *Count : *UB - *DefaultLB + 1) << ']'; 165 else { 166 OS << "[["; 167 if (LB) 168 OS << *LB; 169 else 170 OS << '?'; 171 OS << ", "; 172 if (Count) 173 if (LB) 174 OS << *LB + *Count; 175 else 176 OS << "? + " << *Count; 177 else if (UB) 178 OS << *UB + 1; 179 else 180 OS << '?'; 181 OS << ")]"; 182 } 183 } 184 EndedWithTemplate = false; 185 } 186 187 DWARFDie skipQualifiers(DWARFDie D) { 188 while (D && (D.getTag() == DW_TAG_const_type || 189 D.getTag() == DW_TAG_volatile_type)) 190 D = resolveReferencedType(D); 191 return D; 192 } 193 194 bool needsParens(DWARFDie D) { 195 D = skipQualifiers(D); 196 return D && (D.getTag() == DW_TAG_subroutine_type || D.getTag() == DW_TAG_array_type); 197 } 198 199 void appendPointerLikeTypeBefore(DWARFDie D, DWARFDie Inner, StringRef Ptr) { 200 appendQualifiedNameBefore(Inner); 201 if (Word) 202 OS << ' '; 203 if (needsParens(Inner)) 204 OS << '('; 205 OS << Ptr; 206 Word = false; 207 EndedWithTemplate = false; 208 } 209 210 DWARFDie 211 appendUnqualifiedNameBefore(DWARFDie D, 212 std::string *OriginalFullName = nullptr) { 213 Word = true; 214 if (!D) { 215 OS << "void"; 216 return DWARFDie(); 217 } 218 DWARFDie InnerDIE; 219 auto Inner = [&] { return InnerDIE = resolveReferencedType(D); }; 220 const dwarf::Tag T = D.getTag(); 221 switch (T) { 222 case DW_TAG_pointer_type: { 223 appendPointerLikeTypeBefore(D, Inner(), "*"); 224 break; 225 } 226 case DW_TAG_subroutine_type: { 227 appendQualifiedNameBefore(Inner()); 228 if (Word) { 229 OS << ' '; 230 } 231 Word = false; 232 break; 233 } 234 case DW_TAG_array_type: { 235 appendQualifiedNameBefore(Inner()); 236 break; 237 } 238 case DW_TAG_reference_type: 239 appendPointerLikeTypeBefore(D, Inner(), "&"); 240 break; 241 case DW_TAG_rvalue_reference_type: 242 appendPointerLikeTypeBefore(D, Inner(), "&&"); 243 break; 244 case DW_TAG_ptr_to_member_type: { 245 appendQualifiedNameBefore(Inner()); 246 if (needsParens(InnerDIE)) 247 OS << '('; 248 else if (Word) 249 OS << ' '; 250 if (DWARFDie Cont = resolveReferencedType(D, DW_AT_containing_type)) { 251 appendQualifiedName(Cont); 252 OS << "::"; 253 } 254 OS << "*"; 255 Word = false; 256 break; 257 } 258 case DW_TAG_const_type: 259 case DW_TAG_volatile_type: 260 appendConstVolatileQualifierBefore(D); 261 break; 262 case DW_TAG_namespace: { 263 if (const char *Name = dwarf::toString(D.find(DW_AT_name), nullptr)) 264 OS << Name; 265 else 266 OS << "(anonymous namespace)"; 267 break; 268 } 269 case DW_TAG_unspecified_type: { 270 StringRef TypeName = D.getShortName(); 271 if (TypeName == "decltype(nullptr)") 272 TypeName = "std::nullptr_t"; 273 Word = true; 274 OS << TypeName; 275 EndedWithTemplate = false; 276 break; 277 } 278 /* 279 case DW_TAG_structure_type: 280 case DW_TAG_class_type: 281 case DW_TAG_enumeration_type: 282 case DW_TAG_base_type: 283 */ 284 default: { 285 const char *NamePtr = dwarf::toString(D.find(DW_AT_name), nullptr); 286 if (!NamePtr) { 287 appendTypeTagName(D.getTag()); 288 return DWARFDie(); 289 } 290 Word = true; 291 StringRef Name = NamePtr; 292 static constexpr StringRef MangledPrefix = "_STN"; 293 if (Name.startswith(MangledPrefix)) { 294 Name = Name.drop_front(MangledPrefix.size()); 295 auto Separator = Name.find('|'); 296 assert(Separator != StringRef::npos); 297 StringRef BaseName = Name.substr(0, Separator); 298 StringRef TemplateArgs = Name.substr(Separator + 1); 299 if (OriginalFullName) 300 *OriginalFullName = (BaseName + TemplateArgs).str(); 301 Name = BaseName; 302 } else 303 EndedWithTemplate = Name.endswith(">"); 304 OS << Name; 305 // This check would be insufficient for operator overloads like 306 // "operator>>" - but for now Clang doesn't try to simplify them, so this 307 // is OK. Add more nuanced operator overload handling here if/when needed. 308 if (Name.endswith(">")) 309 break; 310 if (!appendTemplateParameters(D)) 311 break; 312 313 if (EndedWithTemplate) 314 OS << ' '; 315 OS << '>'; 316 EndedWithTemplate = true; 317 Word = true; 318 break; 319 } 320 } 321 return InnerDIE; 322 } 323 324 void appendUnqualifiedNameAfter(DWARFDie D, DWARFDie Inner, 325 bool SkipFirstParamIfArtificial = false) { 326 if (!D) 327 return; 328 switch (D.getTag()) { 329 case DW_TAG_subroutine_type: { 330 appendSubroutineNameAfter(D, Inner, SkipFirstParamIfArtificial, false, 331 false); 332 break; 333 } 334 case DW_TAG_array_type: { 335 appendArrayType(D); 336 break; 337 } 338 case DW_TAG_const_type: 339 case DW_TAG_volatile_type: 340 appendConstVolatileQualifierAfter(D); 341 break; 342 case DW_TAG_ptr_to_member_type: 343 case DW_TAG_reference_type: 344 case DW_TAG_rvalue_reference_type: 345 case DW_TAG_pointer_type: { 346 if (needsParens(Inner)) 347 OS << ')'; 348 appendUnqualifiedNameAfter(Inner, resolveReferencedType(Inner), 349 /*SkipFirstParamIfArtificial=*/D.getTag() == 350 DW_TAG_ptr_to_member_type); 351 break; 352 } 353 /* 354 case DW_TAG_structure_type: 355 case DW_TAG_class_type: 356 case DW_TAG_enumeration_type: 357 case DW_TAG_base_type: 358 case DW_TAG_namespace: 359 */ 360 default: 361 break; 362 } 363 } 364 365 void appendQualifiedName(DWARFDie D) { 366 if (D) 367 appendScopes(D.getParent()); 368 appendUnqualifiedName(D); 369 } 370 DWARFDie appendQualifiedNameBefore(DWARFDie D) { 371 if (D) 372 appendScopes(D.getParent()); 373 return appendUnqualifiedNameBefore(D); 374 } 375 bool appendTemplateParameters(DWARFDie D, bool *FirstParameter = nullptr) { 376 bool FirstParameterValue = true; 377 bool IsTemplate = false; 378 if (!FirstParameter) 379 FirstParameter = &FirstParameterValue; 380 for (const DWARFDie &C : D) { 381 auto Sep = [&] { 382 if (*FirstParameter) 383 OS << '<'; 384 else 385 OS << ", "; 386 IsTemplate = true; 387 EndedWithTemplate = false; 388 *FirstParameter = false; 389 }; 390 if (C.getTag() == dwarf::DW_TAG_GNU_template_parameter_pack) { 391 IsTemplate = true; 392 appendTemplateParameters(C, FirstParameter); 393 } 394 if (C.getTag() == dwarf::DW_TAG_template_value_parameter) { 395 DWARFDie T = resolveReferencedType(C); 396 Sep(); 397 if (T.getTag() == DW_TAG_enumeration_type) { 398 auto V = C.find(DW_AT_const_value); 399 bool FoundEnumerator = false; 400 for (const DWARFDie &Enumerator : T) { 401 auto EV = Enumerator.find(DW_AT_const_value); 402 if (V && EV && 403 V->getAsSignedConstant() == EV->getAsSignedConstant()) { 404 if (T.find(DW_AT_enum_class)) { 405 appendQualifiedName(T); 406 OS << "::"; 407 } else 408 appendScopes(T.getParent()); 409 OS << Enumerator.getShortName(); 410 FoundEnumerator = true; 411 break; 412 } 413 } 414 if (FoundEnumerator) 415 continue; 416 OS << '('; 417 appendQualifiedName(T); 418 OS << ')'; 419 OS << to_string(*V->getAsSignedConstant()); 420 continue; 421 } 422 // /Maybe/ we could do pointer type parameters, looking for the 423 // symbol in the ELF symbol table to get back to the variable... 424 // but probably not worth it. 425 if (T.getTag() == DW_TAG_pointer_type) 426 continue; 427 const char *RawName = dwarf::toString(T.find(DW_AT_name), nullptr); 428 assert(RawName); 429 StringRef Name = RawName; 430 auto V = C.find(DW_AT_const_value); 431 bool IsQualifiedChar = false; 432 if (Name == "bool") { 433 OS << (*V->getAsUnsignedConstant() ? "true" : "false"); 434 } else if (Name == "short") { 435 OS << "(short)"; 436 OS << to_string(*V->getAsSignedConstant()); 437 } else if (Name == "unsigned short") { 438 OS << "(unsigned short)"; 439 OS << to_string(*V->getAsSignedConstant()); 440 } else if (Name == "int") 441 OS << to_string(*V->getAsSignedConstant()); 442 else if (Name == "long") { 443 OS << to_string(*V->getAsSignedConstant()); 444 OS << "L"; 445 } else if (Name == "long long") { 446 OS << to_string(*V->getAsSignedConstant()); 447 OS << "LL"; 448 } else if (Name == "unsigned int") { 449 OS << to_string(*V->getAsUnsignedConstant()); 450 OS << "U"; 451 } else if (Name == "unsigned long") { 452 OS << to_string(*V->getAsUnsignedConstant()); 453 OS << "UL"; 454 } else if (Name == "unsigned long long") { 455 OS << to_string(*V->getAsUnsignedConstant()); 456 OS << "ULL"; 457 } else if (Name == "char" || 458 (IsQualifiedChar = 459 (Name == "unsigned char" || Name == "signed char"))) { 460 // FIXME: check T's DW_AT_type to see if it's signed or not (since 461 // char signedness is implementation defined). 462 auto Val = *V->getAsSignedConstant(); 463 // Copied/hacked up from Clang's CharacterLiteral::print - incomplete 464 // (doesn't actually support different character types/widths, sign 465 // handling's not done, and doesn't correctly test if a character is 466 // printable or needs to use a numeric escape sequence instead) 467 if (IsQualifiedChar) { 468 OS << '('; 469 OS << Name; 470 OS << ')'; 471 } 472 switch (Val) { 473 case '\\': 474 OS << "'\\\\'"; 475 break; 476 case '\'': 477 OS << "'\\''"; 478 break; 479 case '\a': 480 // TODO: K&R: the meaning of '\\a' is different in traditional C 481 OS << "'\\a'"; 482 break; 483 case '\b': 484 OS << "'\\b'"; 485 break; 486 case '\f': 487 OS << "'\\f'"; 488 break; 489 case '\n': 490 OS << "'\\n'"; 491 break; 492 case '\r': 493 OS << "'\\r'"; 494 break; 495 case '\t': 496 OS << "'\\t'"; 497 break; 498 case '\v': 499 OS << "'\\v'"; 500 break; 501 default: 502 if ((Val & ~0xFFu) == ~0xFFu) 503 Val &= 0xFFu; 504 if (Val < 127 && Val >= 32) { 505 OS << "'"; 506 OS << (char)Val; 507 OS << "'"; 508 } else if (Val < 256) 509 OS << to_string(llvm::format("'\\x%02x'", Val)); 510 else if (Val <= 0xFFFF) 511 OS << to_string(llvm::format("'\\u%04x'", Val)); 512 else 513 OS << to_string(llvm::format("'\\U%08x'", Val)); 514 } 515 } 516 continue; 517 } 518 if (C.getTag() == dwarf::DW_TAG_GNU_template_template_param) { 519 const char *RawName = 520 dwarf::toString(C.find(DW_AT_GNU_template_name), nullptr); 521 assert(RawName); 522 StringRef Name = RawName; 523 Sep(); 524 OS << Name; 525 continue; 526 } 527 if (C.getTag() != dwarf::DW_TAG_template_type_parameter) 528 continue; 529 auto TypeAttr = C.find(DW_AT_type); 530 Sep(); 531 appendQualifiedName(TypeAttr ? resolveReferencedType(C, *TypeAttr) 532 : DWARFDie()); 533 } 534 if (IsTemplate && *FirstParameter && FirstParameter == &FirstParameterValue) 535 OS << '<'; 536 return IsTemplate; 537 } 538 void decomposeConstVolatile(DWARFDie &N, DWARFDie &T, DWARFDie &C, 539 DWARFDie &V) { 540 (N.getTag() == DW_TAG_const_type ? C : V) = N; 541 T = resolveReferencedType(N); 542 if (T) { 543 auto Tag = T.getTag(); 544 if (Tag == DW_TAG_const_type) { 545 C = T; 546 T = resolveReferencedType(T); 547 } else if (Tag == DW_TAG_volatile_type) { 548 V = T; 549 T = resolveReferencedType(T); 550 } 551 } 552 } 553 void appendConstVolatileQualifierAfter(DWARFDie N) { 554 DWARFDie C; 555 DWARFDie V; 556 DWARFDie T; 557 decomposeConstVolatile(N, T, C, V); 558 if (T && T.getTag() == DW_TAG_subroutine_type) 559 appendSubroutineNameAfter(T, resolveReferencedType(T), false, C.isValid(), 560 V.isValid()); 561 else 562 appendUnqualifiedNameAfter(T, resolveReferencedType(T)); 563 } 564 void appendConstVolatileQualifierBefore(DWARFDie N) { 565 DWARFDie C; 566 DWARFDie V; 567 DWARFDie T; 568 decomposeConstVolatile(N, T, C, V); 569 bool Subroutine = T && T.getTag() == DW_TAG_subroutine_type; 570 DWARFDie A = T; 571 while (A && A.getTag() == DW_TAG_array_type) 572 A = resolveReferencedType(A); 573 bool Leading = 574 (!A || (A.getTag() != DW_TAG_pointer_type && 575 A.getTag() != llvm::dwarf::DW_TAG_ptr_to_member_type)) && 576 !Subroutine; 577 if (Leading) { 578 if (C) 579 OS << "const "; 580 if (V) 581 OS << "volatile "; 582 } 583 appendQualifiedNameBefore(T); 584 if (!Leading && !Subroutine) { 585 Word = true; 586 if (C) 587 OS << "const"; 588 if (V) { 589 if (C) 590 OS << ' '; 591 OS << "volatile"; 592 } 593 } 594 } 595 596 /// Recursively append the DIE type name when applicable. 597 void appendUnqualifiedName(DWARFDie D, 598 std::string *OriginalFullName = nullptr) { 599 // FIXME: We should have pretty printers per language. Currently we print 600 // everything as if it was C++ and fall back to the TAG type name. 601 DWARFDie Inner = appendUnqualifiedNameBefore(D, OriginalFullName); 602 appendUnqualifiedNameAfter(D, Inner); 603 } 604 605 void appendSubroutineNameAfter(DWARFDie D, DWARFDie Inner, 606 bool SkipFirstParamIfArtificial, bool Const, 607 bool Volatile) { 608 DWARFDie FirstParamIfArtificial; 609 OS << '('; 610 EndedWithTemplate = false; 611 bool First = true; 612 bool RealFirst = true; 613 for (DWARFDie P : D) { 614 if (P.getTag() != DW_TAG_formal_parameter) 615 return; 616 DWARFDie T = resolveReferencedType(P); 617 if (SkipFirstParamIfArtificial && RealFirst && P.find(DW_AT_artificial)) { 618 FirstParamIfArtificial = T; 619 RealFirst = false; 620 continue; 621 } 622 if (!First) { 623 OS << ", "; 624 } 625 First = false; 626 appendQualifiedName(T); 627 } 628 EndedWithTemplate = false; 629 OS << ')'; 630 if (FirstParamIfArtificial) { 631 if (DWARFDie P = FirstParamIfArtificial) { 632 if (P.getTag() == DW_TAG_pointer_type) { 633 DWARFDie C; 634 DWARFDie V; 635 auto CVStep = [&](DWARFDie CV) { 636 if (DWARFDie U = resolveReferencedType(CV)) { 637 if (U.getTag() == DW_TAG_const_type) 638 return C = U; 639 if (U.getTag() == DW_TAG_volatile_type) 640 return V = U; 641 } 642 return DWARFDie(); 643 }; 644 if (DWARFDie CV = CVStep(P)) { 645 CVStep(CV); 646 } 647 if (C) 648 OS << " const"; 649 if (V) 650 OS << " volatile"; 651 } 652 } 653 } else { 654 if (Const) 655 OS << " const"; 656 if (Volatile) 657 OS << " volatile"; 658 } 659 if (D.find(DW_AT_reference)) 660 OS << " &"; 661 if (D.find(DW_AT_rvalue_reference)) 662 OS << " &&"; 663 appendUnqualifiedNameAfter(Inner, resolveReferencedType(Inner)); 664 } 665 void appendScopes(DWARFDie D) { 666 if (D.getTag() == DW_TAG_compile_unit) 667 return; 668 if (D.getTag() == DW_TAG_type_unit) 669 return; 670 if (D.getTag() == DW_TAG_skeleton_unit) 671 return; 672 if (D.getTag() == DW_TAG_subprogram) 673 return; 674 if (D.getTag() == DW_TAG_lexical_block) 675 return; 676 D = D.resolveTypeUnitReference(); 677 if (DWARFDie P = D.getParent()) 678 appendScopes(P); 679 appendUnqualifiedName(D); 680 OS << "::"; 681 } 682 }; 683 } // anonymous namespace 684 685 static void dumpAttribute(raw_ostream &OS, const DWARFDie &Die, 686 const DWARFAttribute &AttrValue, unsigned Indent, 687 DIDumpOptions DumpOpts) { 688 if (!Die.isValid()) 689 return; 690 const char BaseIndent[] = " "; 691 OS << BaseIndent; 692 OS.indent(Indent + 2); 693 dwarf::Attribute Attr = AttrValue.Attr; 694 WithColor(OS, HighlightColor::Attribute) << formatv("{0}", Attr); 695 696 dwarf::Form Form = AttrValue.Value.getForm(); 697 if (DumpOpts.Verbose || DumpOpts.ShowForm) 698 OS << formatv(" [{0}]", Form); 699 700 DWARFUnit *U = Die.getDwarfUnit(); 701 const DWARFFormValue &FormValue = AttrValue.Value; 702 703 OS << "\t("; 704 705 StringRef Name; 706 std::string File; 707 auto Color = HighlightColor::Enumerator; 708 if (Attr == DW_AT_decl_file || Attr == DW_AT_call_file) { 709 Color = HighlightColor::String; 710 if (const auto *LT = U->getContext().getLineTableForUnit(U)) 711 if (LT->getFileNameByIndex( 712 FormValue.getAsUnsignedConstant().getValue(), 713 U->getCompilationDir(), 714 DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath, File)) { 715 File = '"' + File + '"'; 716 Name = File; 717 } 718 } else if (Optional<uint64_t> Val = FormValue.getAsUnsignedConstant()) 719 Name = AttributeValueString(Attr, *Val); 720 721 if (!Name.empty()) 722 WithColor(OS, Color) << Name; 723 else if (Attr == DW_AT_decl_line || Attr == DW_AT_call_line) 724 OS << *FormValue.getAsUnsignedConstant(); 725 else if (Attr == DW_AT_low_pc && 726 (FormValue.getAsAddress() == 727 dwarf::computeTombstoneAddress(U->getAddressByteSize()))) { 728 if (DumpOpts.Verbose) { 729 FormValue.dump(OS, DumpOpts); 730 OS << " ("; 731 } 732 OS << "dead code"; 733 if (DumpOpts.Verbose) 734 OS << ')'; 735 } else if (Attr == DW_AT_high_pc && !DumpOpts.ShowForm && !DumpOpts.Verbose && 736 FormValue.getAsUnsignedConstant()) { 737 if (DumpOpts.ShowAddresses) { 738 // Print the actual address rather than the offset. 739 uint64_t LowPC, HighPC, Index; 740 if (Die.getLowAndHighPC(LowPC, HighPC, Index)) 741 DWARFFormValue::dumpAddress(OS, U->getAddressByteSize(), HighPC); 742 else 743 FormValue.dump(OS, DumpOpts); 744 } 745 } else if (DWARFAttribute::mayHaveLocationList(Attr) && 746 FormValue.isFormClass(DWARFFormValue::FC_SectionOffset)) 747 dumpLocationList(OS, FormValue, U, sizeof(BaseIndent) + Indent + 4, 748 DumpOpts); 749 else if (FormValue.isFormClass(DWARFFormValue::FC_Exprloc) || 750 (DWARFAttribute::mayHaveLocationExpr(Attr) && 751 FormValue.isFormClass(DWARFFormValue::FC_Block))) 752 dumpLocationExpr(OS, FormValue, U, sizeof(BaseIndent) + Indent + 4, 753 DumpOpts); 754 else 755 FormValue.dump(OS, DumpOpts); 756 757 std::string Space = DumpOpts.ShowAddresses ? " " : ""; 758 759 // We have dumped the attribute raw value. For some attributes 760 // having both the raw value and the pretty-printed value is 761 // interesting. These attributes are handled below. 762 if (Attr == DW_AT_specification || Attr == DW_AT_abstract_origin) { 763 if (const char *Name = 764 Die.getAttributeValueAsReferencedDie(FormValue).getName( 765 DINameKind::LinkageName)) 766 OS << Space << "\"" << Name << '\"'; 767 } else if (Attr == DW_AT_type) { 768 DWARFDie D = resolveReferencedType(Die, FormValue); 769 if (D && !D.isNULL()) { 770 OS << Space << "\""; 771 DWARFTypePrinter(OS).appendQualifiedName(D); 772 OS << '"'; 773 } 774 } else if (Attr == DW_AT_APPLE_property_attribute) { 775 if (Optional<uint64_t> OptVal = FormValue.getAsUnsignedConstant()) 776 dumpApplePropertyAttribute(OS, *OptVal); 777 } else if (Attr == DW_AT_ranges) { 778 const DWARFObject &Obj = Die.getDwarfUnit()->getContext().getDWARFObj(); 779 // For DW_FORM_rnglistx we need to dump the offset separately, since 780 // we have only dumped the index so far. 781 if (FormValue.getForm() == DW_FORM_rnglistx) 782 if (auto RangeListOffset = 783 U->getRnglistOffset(*FormValue.getAsSectionOffset())) { 784 DWARFFormValue FV = DWARFFormValue::createFromUValue( 785 dwarf::DW_FORM_sec_offset, *RangeListOffset); 786 FV.dump(OS, DumpOpts); 787 } 788 if (auto RangesOrError = Die.getAddressRanges()) 789 dumpRanges(Obj, OS, RangesOrError.get(), U->getAddressByteSize(), 790 sizeof(BaseIndent) + Indent + 4, DumpOpts); 791 else 792 DumpOpts.RecoverableErrorHandler(createStringError( 793 errc::invalid_argument, "decoding address ranges: %s", 794 toString(RangesOrError.takeError()).c_str())); 795 } 796 797 OS << ")\n"; 798 } 799 800 void DWARFDie::getFullName(raw_string_ostream &OS, 801 std::string *OriginalFullName) const { 802 const char *NamePtr = getShortName(); 803 if (!NamePtr) 804 return; 805 DWARFTypePrinter(OS).appendUnqualifiedName(*this, OriginalFullName); 806 } 807 808 bool DWARFDie::isSubprogramDIE() const { return getTag() == DW_TAG_subprogram; } 809 810 bool DWARFDie::isSubroutineDIE() const { 811 auto Tag = getTag(); 812 return Tag == DW_TAG_subprogram || Tag == DW_TAG_inlined_subroutine; 813 } 814 815 Optional<DWARFFormValue> DWARFDie::find(dwarf::Attribute Attr) const { 816 if (!isValid()) 817 return None; 818 auto AbbrevDecl = getAbbreviationDeclarationPtr(); 819 if (AbbrevDecl) 820 return AbbrevDecl->getAttributeValue(getOffset(), Attr, *U); 821 return None; 822 } 823 824 Optional<DWARFFormValue> 825 DWARFDie::find(ArrayRef<dwarf::Attribute> Attrs) const { 826 if (!isValid()) 827 return None; 828 auto AbbrevDecl = getAbbreviationDeclarationPtr(); 829 if (AbbrevDecl) { 830 for (auto Attr : Attrs) { 831 if (auto Value = AbbrevDecl->getAttributeValue(getOffset(), Attr, *U)) 832 return Value; 833 } 834 } 835 return None; 836 } 837 838 Optional<DWARFFormValue> 839 DWARFDie::findRecursively(ArrayRef<dwarf::Attribute> Attrs) const { 840 SmallVector<DWARFDie, 3> Worklist; 841 Worklist.push_back(*this); 842 843 // Keep track if DIEs already seen to prevent infinite recursion. 844 // Empirically we rarely see a depth of more than 3 when dealing with valid 845 // DWARF. This corresponds to following the DW_AT_abstract_origin and 846 // DW_AT_specification just once. 847 SmallSet<DWARFDie, 3> Seen; 848 Seen.insert(*this); 849 850 while (!Worklist.empty()) { 851 DWARFDie Die = Worklist.pop_back_val(); 852 853 if (!Die.isValid()) 854 continue; 855 856 if (auto Value = Die.find(Attrs)) 857 return Value; 858 859 if (auto D = Die.getAttributeValueAsReferencedDie(DW_AT_abstract_origin)) 860 if (Seen.insert(D).second) 861 Worklist.push_back(D); 862 863 if (auto D = Die.getAttributeValueAsReferencedDie(DW_AT_specification)) 864 if (Seen.insert(D).second) 865 Worklist.push_back(D); 866 } 867 868 return None; 869 } 870 871 DWARFDie 872 DWARFDie::getAttributeValueAsReferencedDie(dwarf::Attribute Attr) const { 873 if (Optional<DWARFFormValue> F = find(Attr)) 874 return getAttributeValueAsReferencedDie(*F); 875 return DWARFDie(); 876 } 877 878 DWARFDie 879 DWARFDie::getAttributeValueAsReferencedDie(const DWARFFormValue &V) const { 880 DWARFDie Result; 881 if (auto SpecRef = V.getAsRelativeReference()) { 882 if (SpecRef->Unit) 883 Result = SpecRef->Unit->getDIEForOffset(SpecRef->Unit->getOffset() + 884 SpecRef->Offset); 885 else if (auto SpecUnit = 886 U->getUnitVector().getUnitForOffset(SpecRef->Offset)) 887 Result = SpecUnit->getDIEForOffset(SpecRef->Offset); 888 } 889 return Result; 890 } 891 892 DWARFDie DWARFDie::resolveTypeUnitReference() const { 893 if (auto Attr = find(DW_AT_signature)) { 894 if (Optional<uint64_t> Sig = Attr->getAsReferenceUVal()) { 895 if (DWARFTypeUnit *TU = U->getContext().getTypeUnitForHash( 896 U->getVersion(), *Sig, U->isDWOUnit())) 897 return TU->getDIEForOffset(TU->getTypeOffset() + TU->getOffset()); 898 } 899 } 900 return *this; 901 } 902 903 Optional<uint64_t> DWARFDie::getRangesBaseAttribute() const { 904 return toSectionOffset(find({DW_AT_rnglists_base, DW_AT_GNU_ranges_base})); 905 } 906 907 Optional<uint64_t> DWARFDie::getLocBaseAttribute() const { 908 return toSectionOffset(find(DW_AT_loclists_base)); 909 } 910 911 Optional<uint64_t> DWARFDie::getHighPC(uint64_t LowPC) const { 912 uint64_t Tombstone = dwarf::computeTombstoneAddress(U->getAddressByteSize()); 913 if (LowPC == Tombstone) 914 return None; 915 if (auto FormValue = find(DW_AT_high_pc)) { 916 if (auto Address = FormValue->getAsAddress()) { 917 // High PC is an address. 918 return Address; 919 } 920 if (auto Offset = FormValue->getAsUnsignedConstant()) { 921 // High PC is an offset from LowPC. 922 return LowPC + *Offset; 923 } 924 } 925 return None; 926 } 927 928 bool DWARFDie::getLowAndHighPC(uint64_t &LowPC, uint64_t &HighPC, 929 uint64_t &SectionIndex) const { 930 auto F = find(DW_AT_low_pc); 931 auto LowPcAddr = toSectionedAddress(F); 932 if (!LowPcAddr) 933 return false; 934 if (auto HighPcAddr = getHighPC(LowPcAddr->Address)) { 935 LowPC = LowPcAddr->Address; 936 HighPC = *HighPcAddr; 937 SectionIndex = LowPcAddr->SectionIndex; 938 return true; 939 } 940 return false; 941 } 942 943 Expected<DWARFAddressRangesVector> DWARFDie::getAddressRanges() const { 944 if (isNULL()) 945 return DWARFAddressRangesVector(); 946 // Single range specified by low/high PC. 947 uint64_t LowPC, HighPC, Index; 948 if (getLowAndHighPC(LowPC, HighPC, Index)) 949 return DWARFAddressRangesVector{{LowPC, HighPC, Index}}; 950 951 Optional<DWARFFormValue> Value = find(DW_AT_ranges); 952 if (Value) { 953 if (Value->getForm() == DW_FORM_rnglistx) 954 return U->findRnglistFromIndex(*Value->getAsSectionOffset()); 955 return U->findRnglistFromOffset(*Value->getAsSectionOffset()); 956 } 957 return DWARFAddressRangesVector(); 958 } 959 960 bool DWARFDie::addressRangeContainsAddress(const uint64_t Address) const { 961 auto RangesOrError = getAddressRanges(); 962 if (!RangesOrError) { 963 llvm::consumeError(RangesOrError.takeError()); 964 return false; 965 } 966 967 for (const auto &R : RangesOrError.get()) 968 if (R.LowPC <= Address && Address < R.HighPC) 969 return true; 970 return false; 971 } 972 973 Expected<DWARFLocationExpressionsVector> 974 DWARFDie::getLocations(dwarf::Attribute Attr) const { 975 Optional<DWARFFormValue> Location = find(Attr); 976 if (!Location) 977 return createStringError(inconvertibleErrorCode(), "No %s", 978 dwarf::AttributeString(Attr).data()); 979 980 if (Optional<uint64_t> Off = Location->getAsSectionOffset()) { 981 uint64_t Offset = *Off; 982 983 if (Location->getForm() == DW_FORM_loclistx) { 984 if (auto LoclistOffset = U->getLoclistOffset(Offset)) 985 Offset = *LoclistOffset; 986 else 987 return createStringError(inconvertibleErrorCode(), 988 "Loclist table not found"); 989 } 990 return U->findLoclistFromOffset(Offset); 991 } 992 993 if (Optional<ArrayRef<uint8_t>> Expr = Location->getAsBlock()) { 994 return DWARFLocationExpressionsVector{ 995 DWARFLocationExpression{None, to_vector<4>(*Expr)}}; 996 } 997 998 return createStringError( 999 inconvertibleErrorCode(), "Unsupported %s encoding: %s", 1000 dwarf::AttributeString(Attr).data(), 1001 dwarf::FormEncodingString(Location->getForm()).data()); 1002 } 1003 1004 const char *DWARFDie::getSubroutineName(DINameKind Kind) const { 1005 if (!isSubroutineDIE()) 1006 return nullptr; 1007 return getName(Kind); 1008 } 1009 1010 const char *DWARFDie::getName(DINameKind Kind) const { 1011 if (!isValid() || Kind == DINameKind::None) 1012 return nullptr; 1013 // Try to get mangled name only if it was asked for. 1014 if (Kind == DINameKind::LinkageName) { 1015 if (auto Name = getLinkageName()) 1016 return Name; 1017 } 1018 return getShortName(); 1019 } 1020 1021 const char *DWARFDie::getShortName() const { 1022 if (!isValid()) 1023 return nullptr; 1024 1025 return dwarf::toString(findRecursively(dwarf::DW_AT_name), nullptr); 1026 } 1027 1028 const char *DWARFDie::getLinkageName() const { 1029 if (!isValid()) 1030 return nullptr; 1031 1032 return dwarf::toString(findRecursively({dwarf::DW_AT_MIPS_linkage_name, 1033 dwarf::DW_AT_linkage_name}), 1034 nullptr); 1035 } 1036 1037 uint64_t DWARFDie::getDeclLine() const { 1038 return toUnsigned(findRecursively(DW_AT_decl_line), 0); 1039 } 1040 1041 std::string 1042 DWARFDie::getDeclFile(DILineInfoSpecifier::FileLineInfoKind Kind) const { 1043 if (auto FormValue = findRecursively(DW_AT_decl_file)) 1044 if (auto OptString = FormValue->getAsFile(Kind)) 1045 return *OptString; 1046 return {}; 1047 } 1048 1049 void DWARFDie::getCallerFrame(uint32_t &CallFile, uint32_t &CallLine, 1050 uint32_t &CallColumn, 1051 uint32_t &CallDiscriminator) const { 1052 CallFile = toUnsigned(find(DW_AT_call_file), 0); 1053 CallLine = toUnsigned(find(DW_AT_call_line), 0); 1054 CallColumn = toUnsigned(find(DW_AT_call_column), 0); 1055 CallDiscriminator = toUnsigned(find(DW_AT_GNU_discriminator), 0); 1056 } 1057 1058 /// Helper to dump a DIE with all of its parents, but no siblings. 1059 static unsigned dumpParentChain(DWARFDie Die, raw_ostream &OS, unsigned Indent, 1060 DIDumpOptions DumpOpts, unsigned Depth = 0) { 1061 if (!Die) 1062 return Indent; 1063 if (DumpOpts.ParentRecurseDepth > 0 && Depth >= DumpOpts.ParentRecurseDepth) 1064 return Indent; 1065 Indent = dumpParentChain(Die.getParent(), OS, Indent, DumpOpts, Depth + 1); 1066 Die.dump(OS, Indent, DumpOpts); 1067 return Indent + 2; 1068 } 1069 1070 void DWARFDie::dump(raw_ostream &OS, unsigned Indent, 1071 DIDumpOptions DumpOpts) const { 1072 if (!isValid()) 1073 return; 1074 DWARFDataExtractor debug_info_data = U->getDebugInfoExtractor(); 1075 const uint64_t Offset = getOffset(); 1076 uint64_t offset = Offset; 1077 if (DumpOpts.ShowParents) { 1078 DIDumpOptions ParentDumpOpts = DumpOpts; 1079 ParentDumpOpts.ShowParents = false; 1080 ParentDumpOpts.ShowChildren = false; 1081 Indent = dumpParentChain(getParent(), OS, Indent, ParentDumpOpts); 1082 } 1083 1084 if (debug_info_data.isValidOffset(offset)) { 1085 uint32_t abbrCode = debug_info_data.getULEB128(&offset); 1086 if (DumpOpts.ShowAddresses) 1087 WithColor(OS, HighlightColor::Address).get() 1088 << format("\n0x%8.8" PRIx64 ": ", Offset); 1089 1090 if (abbrCode) { 1091 auto AbbrevDecl = getAbbreviationDeclarationPtr(); 1092 if (AbbrevDecl) { 1093 WithColor(OS, HighlightColor::Tag).get().indent(Indent) 1094 << formatv("{0}", getTag()); 1095 if (DumpOpts.Verbose) { 1096 OS << format(" [%u] %c", abbrCode, 1097 AbbrevDecl->hasChildren() ? '*' : ' '); 1098 if (Optional<uint32_t> ParentIdx = Die->getParentIdx()) 1099 OS << format(" (0x%8.8" PRIx64 ")", 1100 U->getDIEAtIndex(*ParentIdx).getOffset()); 1101 } 1102 OS << '\n'; 1103 1104 // Dump all data in the DIE for the attributes. 1105 for (const DWARFAttribute &AttrValue : attributes()) 1106 dumpAttribute(OS, *this, AttrValue, Indent, DumpOpts); 1107 1108 if (DumpOpts.ShowChildren && DumpOpts.ChildRecurseDepth > 0) { 1109 DWARFDie Child = getFirstChild(); 1110 DumpOpts.ChildRecurseDepth--; 1111 DIDumpOptions ChildDumpOpts = DumpOpts; 1112 ChildDumpOpts.ShowParents = false; 1113 while (Child) { 1114 Child.dump(OS, Indent + 2, ChildDumpOpts); 1115 Child = Child.getSibling(); 1116 } 1117 } 1118 } else { 1119 OS << "Abbreviation code not found in 'debug_abbrev' class for code: " 1120 << abbrCode << '\n'; 1121 } 1122 } else { 1123 OS.indent(Indent) << "NULL\n"; 1124 } 1125 } 1126 } 1127 1128 LLVM_DUMP_METHOD void DWARFDie::dump() const { dump(llvm::errs(), 0); } 1129 1130 DWARFDie DWARFDie::getParent() const { 1131 if (isValid()) 1132 return U->getParent(Die); 1133 return DWARFDie(); 1134 } 1135 1136 DWARFDie DWARFDie::getSibling() const { 1137 if (isValid()) 1138 return U->getSibling(Die); 1139 return DWARFDie(); 1140 } 1141 1142 DWARFDie DWARFDie::getPreviousSibling() const { 1143 if (isValid()) 1144 return U->getPreviousSibling(Die); 1145 return DWARFDie(); 1146 } 1147 1148 DWARFDie DWARFDie::getFirstChild() const { 1149 if (isValid()) 1150 return U->getFirstChild(Die); 1151 return DWARFDie(); 1152 } 1153 1154 DWARFDie DWARFDie::getLastChild() const { 1155 if (isValid()) 1156 return U->getLastChild(Die); 1157 return DWARFDie(); 1158 } 1159 1160 iterator_range<DWARFDie::attribute_iterator> DWARFDie::attributes() const { 1161 return make_range(attribute_iterator(*this, false), 1162 attribute_iterator(*this, true)); 1163 } 1164 1165 DWARFDie::attribute_iterator::attribute_iterator(DWARFDie D, bool End) 1166 : Die(D), Index(0) { 1167 auto AbbrDecl = Die.getAbbreviationDeclarationPtr(); 1168 assert(AbbrDecl && "Must have abbreviation declaration"); 1169 if (End) { 1170 // This is the end iterator so we set the index to the attribute count. 1171 Index = AbbrDecl->getNumAttributes(); 1172 } else { 1173 // This is the begin iterator so we extract the value for this->Index. 1174 AttrValue.Offset = D.getOffset() + AbbrDecl->getCodeByteSize(); 1175 updateForIndex(*AbbrDecl, 0); 1176 } 1177 } 1178 1179 void DWARFDie::attribute_iterator::updateForIndex( 1180 const DWARFAbbreviationDeclaration &AbbrDecl, uint32_t I) { 1181 Index = I; 1182 // AbbrDecl must be valid before calling this function. 1183 auto NumAttrs = AbbrDecl.getNumAttributes(); 1184 if (Index < NumAttrs) { 1185 AttrValue.Attr = AbbrDecl.getAttrByIndex(Index); 1186 // Add the previous byte size of any previous attribute value. 1187 AttrValue.Offset += AttrValue.ByteSize; 1188 uint64_t ParseOffset = AttrValue.Offset; 1189 if (AbbrDecl.getAttrIsImplicitConstByIndex(Index)) 1190 AttrValue.Value = DWARFFormValue::createFromSValue( 1191 AbbrDecl.getFormByIndex(Index), 1192 AbbrDecl.getAttrImplicitConstValueByIndex(Index)); 1193 else { 1194 auto U = Die.getDwarfUnit(); 1195 assert(U && "Die must have valid DWARF unit"); 1196 AttrValue.Value = DWARFFormValue::createFromUnit( 1197 AbbrDecl.getFormByIndex(Index), U, &ParseOffset); 1198 } 1199 AttrValue.ByteSize = ParseOffset - AttrValue.Offset; 1200 } else { 1201 assert(Index == NumAttrs && "Indexes should be [0, NumAttrs) only"); 1202 AttrValue = {}; 1203 } 1204 } 1205 1206 DWARFDie::attribute_iterator &DWARFDie::attribute_iterator::operator++() { 1207 if (auto AbbrDecl = Die.getAbbreviationDeclarationPtr()) 1208 updateForIndex(*AbbrDecl, Index + 1); 1209 return *this; 1210 } 1211 1212 bool DWARFAttribute::mayHaveLocationList(dwarf::Attribute Attr) { 1213 switch(Attr) { 1214 case DW_AT_location: 1215 case DW_AT_string_length: 1216 case DW_AT_return_addr: 1217 case DW_AT_data_member_location: 1218 case DW_AT_frame_base: 1219 case DW_AT_static_link: 1220 case DW_AT_segment: 1221 case DW_AT_use_location: 1222 case DW_AT_vtable_elem_location: 1223 return true; 1224 default: 1225 return false; 1226 } 1227 } 1228 1229 bool DWARFAttribute::mayHaveLocationExpr(dwarf::Attribute Attr) { 1230 switch (Attr) { 1231 // From the DWARF v5 specification. 1232 case DW_AT_location: 1233 case DW_AT_byte_size: 1234 case DW_AT_bit_offset: 1235 case DW_AT_bit_size: 1236 case DW_AT_string_length: 1237 case DW_AT_lower_bound: 1238 case DW_AT_return_addr: 1239 case DW_AT_bit_stride: 1240 case DW_AT_upper_bound: 1241 case DW_AT_count: 1242 case DW_AT_data_member_location: 1243 case DW_AT_frame_base: 1244 case DW_AT_segment: 1245 case DW_AT_static_link: 1246 case DW_AT_use_location: 1247 case DW_AT_vtable_elem_location: 1248 case DW_AT_allocated: 1249 case DW_AT_associated: 1250 case DW_AT_data_location: 1251 case DW_AT_byte_stride: 1252 case DW_AT_rank: 1253 case DW_AT_call_value: 1254 case DW_AT_call_origin: 1255 case DW_AT_call_target: 1256 case DW_AT_call_target_clobbered: 1257 case DW_AT_call_data_location: 1258 case DW_AT_call_data_value: 1259 // Extensions. 1260 case DW_AT_GNU_call_site_value: 1261 case DW_AT_GNU_call_site_target: 1262 return true; 1263 default: 1264 return false; 1265 } 1266 } 1267