当前位置: 首页>>代码示例>>C++>>正文


C++ DataExtractor::isValidOffset方法代码示例

本文整理汇总了C++中DataExtractor::isValidOffset方法的典型用法代码示例。如果您正苦于以下问题:C++ DataExtractor::isValidOffset方法的具体用法?C++ DataExtractor::isValidOffset怎么用?C++ DataExtractor::isValidOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataExtractor的用法示例。


在下文中一共展示了DataExtractor::isValidOffset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: extract

bool DWARFCompileUnit::extract(DataExtractor debug_info, uint32_t *offset_ptr) {
  clear();

  Offset = *offset_ptr;

  if (debug_info.isValidOffset(*offset_ptr)) {
    uint64_t abbrOffset;
    Length = debug_info.getU32(offset_ptr);
    Version = debug_info.getU16(offset_ptr);
    abbrOffset = debug_info.getU32(offset_ptr);
    AddrSize = debug_info.getU8(offset_ptr);

    bool lengthOK = debug_info.isValidOffset(getNextCompileUnitOffset()-1);
    bool versionOK = DWARFContext::isSupportedVersion(Version);
    bool abbrOffsetOK = AbbrevSection.size() > abbrOffset;
    bool addrSizeOK = AddrSize == 4 || AddrSize == 8;

    if (lengthOK && versionOK && addrSizeOK && abbrOffsetOK && Abbrev != NULL) {
      Abbrevs = Abbrev->getAbbreviationDeclarationSet(abbrOffset);
      return true;
    }

    // reset the offset to where we tried to parse from if anything went wrong
    *offset_ptr = Offset;
  }

  return false;
}
开发者ID:TristanSchmelcher,项目名称:llvm-andersen,代码行数:28,代码来源:DWARFCompileUnit.cpp

示例2: extractImpl

bool DWARFUnit::extractImpl(DataExtractor debug_info, uint32_t *offset_ptr) {
  Length = debug_info.getU32(offset_ptr);
  Version = debug_info.getU16(offset_ptr);
  uint64_t AbbrOffset = debug_info.getU32(offset_ptr);
  if (IndexEntry) {
    if (AbbrOffset)
      return false;
    auto *UnitContrib = IndexEntry->getOffset();
    if (!UnitContrib || UnitContrib->Length != (Length + 4))
      return false;
    auto *AbbrEntry = IndexEntry->getOffset(DW_SECT_ABBREV);
    if (!AbbrEntry)
      return false;
    AbbrOffset = AbbrEntry->Offset;
  }
  AddrSize = debug_info.getU8(offset_ptr);

  bool LengthOK = debug_info.isValidOffset(getNextUnitOffset() - 1);
  bool VersionOK = DWARFContext::isSupportedVersion(Version);
  bool AddrSizeOK = AddrSize == 4 || AddrSize == 8;

  if (!LengthOK || !VersionOK || !AddrSizeOK)
    return false;

  Abbrevs = Abbrev->getAbbreviationDeclarationSet(AbbrOffset);
  return Abbrevs != nullptr;
}
开发者ID:amrav,项目名称:pres_plus,代码行数:27,代码来源:DWARFUnit.cpp

示例3: extract

bool DWARFDebugAranges::extract(DataExtractor debug_aranges_data) {
  if (debug_aranges_data.isValidOffset(0)) {
    uint32_t offset = 0;

    typedef std::vector<DWARFDebugArangeSet> SetCollection;
    typedef SetCollection::const_iterator SetCollectionIter;
    SetCollection sets;

    DWARFDebugArangeSet set;
    Range range;
    while (set.extract(debug_aranges_data, &offset))
      sets.push_back(set);

    uint32_t count = 0;

    std::for_each(sets.begin(), sets.end(), CountArangeDescriptors(count));

    if (count > 0) {
      Aranges.reserve(count);
      AddArangeDescriptors range_adder(Aranges);
      std::for_each(sets.begin(), sets.end(), range_adder);
    }
  }
  return false;
}
开发者ID:2014-class,项目名称:freerouter,代码行数:25,代码来源:DWARFDebugAranges.cpp

示例4: while

bool
DWARFAbbreviationDeclaration::extract(DataExtractor data, uint32_t* offset_ptr,
                                      uint32_t code) {
  Code = code;
  Attribute.clear();
  if (Code) {
    Tag = data.getULEB128(offset_ptr);
    HasChildren = data.getU8(offset_ptr);

    while (data.isValidOffset(*offset_ptr)) {
      uint16_t attr = data.getULEB128(offset_ptr);
      uint16_t form = data.getULEB128(offset_ptr);

      if (attr && form)
        Attribute.push_back(DWARFAttribute(attr, form));
      else
        break;
    }

    return Tag != 0;
  } else {
    Tag = 0;
    HasChildren = false;
  }

  return false;
}
开发者ID:32bitmicro,项目名称:llvm,代码行数:27,代码来源:DWARFAbbreviationDeclaration.cpp

示例5: parse

void DWARFDebugLocDWO::parse(DataExtractor data) {
  uint32_t Offset = 0;
  while (data.isValidOffset(Offset)) {
    Locations.resize(Locations.size() + 1);
    LocationList &Loc = Locations.back();
    Loc.Offset = Offset;
    dwarf::LocationListEntry Kind;
    while ((Kind = static_cast<dwarf::LocationListEntry>(
                data.getU8(&Offset))) != dwarf::DW_LLE_end_of_list) {

      if (Kind != dwarf::DW_LLE_startx_length) {
        llvm::errs() << "error: dumping support for LLE of kind " << (int)Kind
                     << " not implemented\n";
        return;
      }

      Entry E;

      E.Start = data.getULEB128(&Offset);
      E.Length = data.getU32(&Offset);

      unsigned Bytes = data.getU16(&Offset);
      // A single location description describing the location of the object...
      StringRef str = data.getData().substr(Offset, Bytes);
      Offset += Bytes;
      E.Loc.resize(str.size());
      std::copy(str.begin(), str.end(), E.Loc.begin());

      Loc.Entries.push_back(std::move(E));
    }
  }
}
开发者ID:AstroVPK,项目名称:LLVM-4.0.0,代码行数:32,代码来源:DWARFDebugLoc.cpp

示例6: extract

void DWARFDebugAranges::extract(DataExtractor DebugArangesData) {
  if (!DebugArangesData.isValidOffset(0))
    return;
  uint32_t Offset = 0;
  typedef std::vector<DWARFDebugArangeSet> RangeSetColl;
  RangeSetColl Sets;
  DWARFDebugArangeSet Set;
  uint32_t TotalRanges = 0;

  while (Set.extract(DebugArangesData, &Offset)) {
    Sets.push_back(Set);
    TotalRanges += Set.getNumDescriptors();
  }
  if (TotalRanges == 0)
    return;

  Aranges.reserve(TotalRanges);
  for (RangeSetColl::const_iterator I = Sets.begin(), E = Sets.end(); I != E;
       ++I) {
    uint32_t CUOffset = I->getCompileUnitDIEOffset();

    for (uint32_t i = 0, n = I->getNumDescriptors(); i < n; ++i) {
      const DWARFDebugArangeSet::Descriptor *ArangeDescPtr =
          I->getDescriptor(i);
      uint64_t LowPC = ArangeDescPtr->Address;
      uint64_t HighPC = LowPC + ArangeDescPtr->Length;
      appendRange(CUOffset, LowPC, HighPC);
    }
  }
}
开发者ID:7heaven,项目名称:softart,代码行数:30,代码来源:DWARFDebugAranges.cpp

示例7: extract

void DWARFDebugAbbrev::extract(DataExtractor Data) {
  clear();

  uint32_t Offset = 0;
  DWARFAbbreviationDeclarationSet AbbrDecls;
  while (Data.isValidOffset(Offset)) {
    uint32_t CUAbbrOffset = Offset;
    if (!AbbrDecls.extract(Data, &Offset))
      break;
    AbbrDeclSets[CUAbbrOffset] = std::move(AbbrDecls);
  }
}
开发者ID:2trill2spill,项目名称:freebsd,代码行数:12,代码来源:DWARFDebugAbbrev.cpp

示例8: parse

void DWARFDebugLocDWO::parse(DataExtractor data) {
  IsLittleEndian = data.isLittleEndian();
  AddressSize = data.getAddressSize();

  uint32_t Offset = 0;
  while (data.isValidOffset(Offset)) {
    if (auto LL = parseOneLocationList(data, &Offset))
      Locations.push_back(std::move(*LL));
    else
      return;
  }
}
开发者ID:a565109863,项目名称:src,代码行数:12,代码来源:DWARFDebugLoc.cpp

示例9: parse

void DWARFDebugLoc::parse(DataExtractor data, unsigned AddressSize) {
  uint32_t Offset = 0;
  while (data.isValidOffset(Offset+AddressSize-1)) {
    Locations.resize(Locations.size() + 1);
    LocationList &Loc = Locations.back();
    Loc.Offset = Offset;
    // 2.6.2 Location Lists
    // A location list entry consists of:
    while (true) {
      Entry E;
      RelocAddrMap::const_iterator AI = RelocMap.find(Offset);
      // 1. A beginning address offset. ...
      E.Begin = data.getUnsigned(&Offset, AddressSize);
      if (AI != RelocMap.end())
        E.Begin += AI->second.second;

      AI = RelocMap.find(Offset);
      // 2. An ending address offset. ...
      E.End = data.getUnsigned(&Offset, AddressSize);
      if (AI != RelocMap.end())
        E.End += AI->second.second;

      // The end of any given location list is marked by an end of list entry,
      // which consists of a 0 for the beginning address offset and a 0 for the
      // ending address offset.
      if (E.Begin == 0 && E.End == 0)
        break;

      unsigned Bytes = data.getU16(&Offset);
      // A single location description describing the location of the object...
      StringRef str = data.getData().substr(Offset, Bytes);
      Offset += Bytes;
      E.Loc.reserve(str.size());
      std::copy(str.begin(), str.end(), std::back_inserter(E.Loc));
      Loc.Entries.push_back(llvm_move(E));
    }
  }
  if (data.isValidOffset(Offset))
    llvm::errs() << "error: failed to consume entire .debug_loc section\n";
}
开发者ID:QuentinFiard,项目名称:llvm,代码行数:40,代码来源:DWARFDebugLoc.cpp

示例10: clear

uint32_t
DWARFCompileUnit::extract(uint32_t offset, DataExtractor debug_info_data,
                          const DWARFAbbreviationDeclarationSet *abbrevs) {
  clear();

  Offset = offset;

  if (debug_info_data.isValidOffset(offset)) {
    Length = debug_info_data.getU32(&offset);
    Version = debug_info_data.getU16(&offset);
    bool abbrevsOK = debug_info_data.getU32(&offset) == abbrevs->getOffset();
    Abbrevs = abbrevs;
    AddrSize = debug_info_data.getU8(&offset);

    bool versionOK = DWARFContext::isSupportedVersion(Version);
    bool addrSizeOK = AddrSize == 4 || AddrSize == 8;

    if (versionOK && addrSizeOK && abbrevsOK &&
        debug_info_data.isValidOffset(offset))
      return offset;
  }
  return 0;
}
开发者ID:TristanSchmelcher,项目名称:llvm-andersen,代码行数:23,代码来源:DWARFCompileUnit.cpp

示例11: extract

bool DWARFUnit::extract(DataExtractor debug_info, uint32_t *offset_ptr) {
  clear();

  Offset = *offset_ptr;

  if (debug_info.isValidOffset(*offset_ptr)) {
    if (extractImpl(debug_info, offset_ptr))
      return true;

    // reset the offset to where we tried to parse from if anything went wrong
    *offset_ptr = Offset;
  }

  return false;
}
开发者ID:amrav,项目名称:pres_plus,代码行数:15,代码来源:DWARFUnit.cpp

示例12: extract

void DWARFDebugAranges::extract(DataExtractor DebugArangesData) {
  if (!DebugArangesData.isValidOffset(0))
    return;
  uint32_t Offset = 0;
  DWARFDebugArangeSet Set;

  while (Set.extract(DebugArangesData, &Offset)) {
    uint32_t CUOffset = Set.getCompileUnitDIEOffset();
    for (const auto &Desc : Set.descriptors()) {
      uint64_t LowPC = Desc.Address;
      uint64_t HighPC = Desc.getEndAddress();
      appendRange(CUOffset, LowPC, HighPC);
    }
    ParsedCUOffsets.insert(CUOffset);
  }
}
开发者ID:bugsnag,项目名称:llvm,代码行数:16,代码来源:DWARFDebugAranges.cpp

示例13: extractImpl

bool DWARFUnit::extractImpl(DataExtractor debug_info, uint32_t *offset_ptr) {
  Length = debug_info.getU32(offset_ptr);
  Version = debug_info.getU16(offset_ptr);
  uint64_t abbrOffset = debug_info.getU32(offset_ptr);
  AddrSize = debug_info.getU8(offset_ptr);

  bool lengthOK = debug_info.isValidOffset(getNextUnitOffset() - 1);
  bool versionOK = DWARFContext::isSupportedVersion(Version);
  bool abbrOffsetOK = AbbrevSection.size() > abbrOffset;
  bool addrSizeOK = AddrSize == 4 || AddrSize == 8;

  if (!lengthOK || !versionOK || !addrSizeOK || !abbrOffsetOK)
    return false;

  Abbrevs = Abbrev->getAbbreviationDeclarationSet(abbrOffset);
  return true;
}
开发者ID:AmesianX,项目名称:dagger,代码行数:17,代码来源:DWARFUnit.cpp

示例14: parse

void DWARFDebugMacro::parse(DataExtractor data) {
  uint32_t Offset = 0;
  while (data.isValidOffset(Offset)) {
    // A macro list entry consists of:
    Entry E;
    // 1. Macinfo type
    E.Type = data.getULEB128(&Offset);

    if (E.Type == 0) {
      // Reached end of ".debug_macinfo" section.
      return;
    }

    switch (E.Type) {
    default:
      // Got a corrupted ".debug_macinfo" section (invalid macinfo type).
      // Push the corrupted entry to the list and halt parsing.
      E.Type = DW_MACINFO_invalid;
      Macros.push_back(E);
      return;
    case DW_MACINFO_define:
    case DW_MACINFO_undef:
      // 2. Source line
      E.Line = data.getULEB128(&Offset);
      // 3. Macro string
      E.MacroStr = data.getCStr(&Offset);
      break;
    case DW_MACINFO_start_file:
      // 2. Source line
      E.Line = data.getULEB128(&Offset);
      // 3. Source file id
      E.File = data.getULEB128(&Offset);
      break;
    case DW_MACINFO_end_file:
      break;
    case DW_MACINFO_vendor_ext:
      // 2. Vendor extension constant
      E.ExtConstant = data.getULEB128(&Offset);
      // 3. Vendor extension string
      E.ExtStr = data.getCStr(&Offset);
      break;
    }

    Macros.push_back(E);
  }
}
开发者ID:CTSRD-CHERI,项目名称:cheribsd,代码行数:46,代码来源:DWARFDebugMacro.cpp

示例15: extractImpl

bool DWARFUnit::extractImpl(DataExtractor debug_info, uint32_t *offset_ptr) {
  Length = debug_info.getU32(offset_ptr);
  Version = debug_info.getU16(offset_ptr);
  uint64_t AbbrOffset = debug_info.getU32(offset_ptr);
  AddrSize = debug_info.getU8(offset_ptr);

  bool LengthOK = debug_info.isValidOffset(getNextUnitOffset() - 1);
  bool VersionOK = DWARFContext::isSupportedVersion(Version);
  bool AddrSizeOK = AddrSize == 4 || AddrSize == 8;

  if (!LengthOK || !VersionOK || !AddrSizeOK)
    return false;

  Abbrevs = Abbrev->getAbbreviationDeclarationSet(AbbrOffset);
  if (Abbrevs == nullptr)
    return false;

  return true;
}
开发者ID:CTSRD-TESLA,项目名称:freebsd,代码行数:19,代码来源:DWARFUnit.cpp


注:本文中的DataExtractor::isValidOffset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。