1 //===-- DWARFAbbreviationDeclaration.cpp ----------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "DWARFAbbreviationDeclaration.h"
11 #include "llvm/Support/Dwarf.h"
12 #include "llvm/Support/Format.h"
13 #include "llvm/Support/raw_ostream.h"
15 using namespace dwarf;
18 DWARFAbbreviationDeclaration::extract(DataExtractor data, uint32_t* offset_ptr){
19 return extract(data, offset_ptr, data.getULEB128(offset_ptr));
23 DWARFAbbreviationDeclaration::extract(DataExtractor data, uint32_t* offset_ptr,
28 Tag = data.getULEB128(offset_ptr);
29 HasChildren = data.getU8(offset_ptr);
31 while (data.isValidOffset(*offset_ptr)) {
32 uint16_t attr = data.getULEB128(offset_ptr);
33 uint16_t form = data.getULEB128(offset_ptr);
36 Attribute.push_back(DWARFAttribute(attr, form));
50 void DWARFAbbreviationDeclaration::dump(raw_ostream &OS) const {
51 const char *tagString = TagString(getTag());
52 OS << '[' << getCode() << "] ";
56 OS << format("DW_TAG_Unknown_%x", getTag());
57 OS << "\tDW_CHILDREN_" << (hasChildren() ? "yes" : "no") << '\n';
58 for (unsigned i = 0, e = Attribute.size(); i != e; ++i) {
60 const char *attrString = AttributeString(Attribute[i].getAttribute());
64 OS << format("DW_AT_Unknown_%x", Attribute[i].getAttribute());
66 const char *formString = FormEncodingString(Attribute[i].getForm());
70 OS << format("DW_FORM_Unknown_%x", Attribute[i].getForm());
77 DWARFAbbreviationDeclaration::findAttributeIndex(uint16_t attr) const {
78 for (uint32_t i = 0, e = Attribute.size(); i != e; ++i) {
79 if (Attribute[i].getAttribute() == attr)