InlineInfo.h revision 355940
1//===- InlineInfo.h ---------------------------------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10#ifndef LLVM_DEBUGINFO_GSYM_INLINEINFO_H 11#define LLVM_DEBUGINFO_GSYM_INLINEINFO_H 12 13#include "llvm/ADT/Optional.h" 14#include "llvm/DebugInfo/GSYM/Range.h" 15#include <stdint.h> 16#include <vector> 17 18 19namespace llvm { 20class raw_ostream; 21 22namespace gsym { 23 24/// Inline information stores the name of the inline function along with 25/// an array of address ranges. It also stores the call file and call line 26/// that called this inline function. This allows us to unwind inline call 27/// stacks back to the inline or concrete function that called this 28/// function. Inlined functions contained in this function are stored in the 29/// "Children" variable. All address ranges must be sorted and all address 30/// ranges of all children must be contained in the ranges of this function. 31/// Any clients that encode information will need to ensure the ranges are 32/// all contined correctly or lookups could fail. Add ranges in these objects 33/// must be contained in the top level FunctionInfo address ranges as well. 34struct InlineInfo { 35 36 uint32_t Name; ///< String table offset in the string table. 37 uint32_t CallFile; ///< 1 based file index in the file table. 38 uint32_t CallLine; ///< Source line number. 39 AddressRanges Ranges; 40 std::vector<InlineInfo> Children; 41 InlineInfo() : Name(0), CallFile(0), CallLine(0) {} 42 void clear() { 43 Name = 0; 44 CallFile = 0; 45 CallLine = 0; 46 Ranges.clear(); 47 Children.clear(); 48 } 49 bool isValid() const { return !Ranges.empty(); } 50 51 using InlineArray = std::vector<const InlineInfo *>; 52 53 /// Lookup an address in the InlineInfo object 54 /// 55 /// This function is used to symbolicate an inline call stack and can 56 /// turn one address in the program into one or more inline call stacks 57 /// and have the stack trace show the original call site from 58 /// non-inlined code. 59 /// 60 /// \param Addr the address to lookup 61 /// 62 /// \returns optional vector of InlineInfo objects that describe the 63 /// inline call stack for a given address, false otherwise. 64 llvm::Optional<InlineArray> getInlineStack(uint64_t Addr) const; 65}; 66 67inline bool operator==(const InlineInfo &LHS, const InlineInfo &RHS) { 68 return LHS.Name == RHS.Name && LHS.CallFile == RHS.CallFile && 69 LHS.CallLine == RHS.CallLine && LHS.Ranges == RHS.Ranges && 70 LHS.Children == RHS.Children; 71} 72 73raw_ostream &operator<<(raw_ostream &OS, const InlineInfo &FI); 74 75} // namespace gsym 76} // namespace llvm 77 78#endif // #ifndef LLVM_DEBUGINFO_GSYM_INLINEINFO_H 79