//===- InlineInfo.cpp -------------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "llvm/DebugInfo/GSYM/FileEntry.h" #include "llvm/DebugInfo/GSYM/FileWriter.h" #include "llvm/DebugInfo/GSYM/GsymReader.h" #include "llvm/DebugInfo/GSYM/InlineInfo.h" #include "llvm/Support/DataExtractor.h" #include <algorithm> #include <inttypes.h> usingnamespacellvm; usingnamespacegsym; raw_ostream &llvm::gsym::operator<<(raw_ostream &OS, const InlineInfo &II) { … } static bool getInlineStackHelper(const InlineInfo &II, uint64_t Addr, std::vector<const InlineInfo *> &InlineStack) { … } std::optional<InlineInfo::InlineArray> InlineInfo::getInlineStack(uint64_t Addr) const { … } /// Skip an InlineInfo object in the specified data at the specified offset. /// /// Used during the InlineInfo::lookup() call to quickly skip child InlineInfo /// objects where the addres ranges isn't contained in the InlineInfo object /// or its children. This avoids allocations by not appending child InlineInfo /// objects to the InlineInfo::Children array. /// /// \param Data The binary stream to read the data from. /// /// \param Offset The byte offset within \a Data. /// /// \param SkippedRanges If true, address ranges have already been skipped. static bool skip(DataExtractor &Data, uint64_t &Offset, bool SkippedRanges) { … } /// A Lookup helper functions. /// /// Used during the InlineInfo::lookup() call to quickly only parse an /// InlineInfo object if the address falls within this object. This avoids /// allocations by not appending child InlineInfo objects to the /// InlineInfo::Children array and also skips any InlineInfo objects that do /// not contain the address we are looking up. /// /// \param Data The binary stream to read the data from. /// /// \param Offset The byte offset within \a Data. /// /// \param BaseAddr The address that the relative address range offsets are /// relative to. static bool lookup(const GsymReader &GR, DataExtractor &Data, uint64_t &Offset, uint64_t BaseAddr, uint64_t Addr, SourceLocations &SrcLocs, llvm::Error &Err) { … } llvm::Error InlineInfo::lookup(const GsymReader &GR, DataExtractor &Data, uint64_t BaseAddr, uint64_t Addr, SourceLocations &SrcLocs) { … } /// Decode an InlineInfo in Data at the specified offset. /// /// A local helper function to decode InlineInfo objects. This function is /// called recursively when parsing child InlineInfo objects. /// /// \param Data The data extractor to decode from. /// \param Offset The offset within \a Data to decode from. /// \param BaseAddr The base address to use when decoding address ranges. /// \returns An InlineInfo or an error describing the issue that was /// encountered during decoding. static llvm::Expected<InlineInfo> decode(DataExtractor &Data, uint64_t &Offset, uint64_t BaseAddr) { … } llvm::Expected<InlineInfo> InlineInfo::decode(DataExtractor &Data, uint64_t BaseAddr) { … } llvm::Error InlineInfo::encode(FileWriter &O, uint64_t BaseAddr) const { … } static uint64_t GetTotalNumChildren(const InlineInfo &II) { … } bool InlineInfo::operator<(const InlineInfo &RHS) const { … }