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/raw_ostream.h"
14 using namespace dwarf;
17 DWARFAbbreviationDeclaration::extract(DataExtractor data, uint32_t* offset_ptr){
18 return extract(data, offset_ptr, data.getULEB128(offset_ptr));
22 DWARFAbbreviationDeclaration::extract(DataExtractor data, uint32_t* offset_ptr,
27 Tag = data.getULEB128(offset_ptr);
28 HasChildren = data.getU8(offset_ptr);
30 while (data.isValidOffset(*offset_ptr)) {
31 uint16_t attr = data.getULEB128(offset_ptr);
32 uint16_t form = data.getULEB128(offset_ptr);
35 Attributes.push_back(DWARFAttribute(attr, form));
49 void DWARFAbbreviationDeclaration::dump(raw_ostream &OS) const {
50 OS << '[' << getCode() << "] " << TagString(getTag()) << "\tDW_CHILDREN_"
51 << (hasChildren() ? "yes" : "no") << '\n';
52 for (unsigned i = 0, e = Attributes.size(); i != e; ++i)
53 OS << '\t' << AttributeString(Attributes[i].getAttribute())
54 << '\t' << FormEncodingString(Attributes[i].getForm()) << '\n';
59 DWARFAbbreviationDeclaration::findAttributeIndex(uint16_t attr) const {
60 for (uint32_t i = 0, e = Attributes.size(); i != e; ++i) {
61 if (Attributes[i].getAttribute() == attr)