Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:42

0001 //===- LookupResult.h -------------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLVM_DEBUGINFO_GSYM_LOOKUPRESULT_H
0010 #define LLVM_DEBUGINFO_GSYM_LOOKUPRESULT_H
0011 
0012 #include "llvm/ADT/AddressRanges.h"
0013 #include "llvm/ADT/StringRef.h"
0014 #include <inttypes.h>
0015 #include <vector>
0016 
0017 namespace llvm {
0018 class raw_ostream;
0019 namespace gsym {
0020 
0021 struct SourceLocation {
0022   StringRef Name;      ///< Function or symbol name.
0023   StringRef Dir;       ///< Line entry source file directory path.
0024   StringRef Base;      ///< Line entry source file basename.
0025   uint32_t Line = 0;   ///< Source file line number.
0026   uint32_t Offset = 0; ///< Byte size offset within the named function.
0027 };
0028 
0029 inline bool operator==(const SourceLocation &LHS, const SourceLocation &RHS) {
0030   return LHS.Name == RHS.Name && LHS.Dir == RHS.Dir && LHS.Base == RHS.Base &&
0031          LHS.Line == RHS.Line && LHS.Offset == RHS.Offset;
0032 }
0033 
0034 raw_ostream &operator<<(raw_ostream &OS, const SourceLocation &R);
0035 
0036 using SourceLocations = std::vector<SourceLocation>;
0037 
0038 struct LookupResult {
0039   uint64_t LookupAddr = 0; ///< The address that this lookup pertains to.
0040   AddressRange FuncRange;  ///< The concrete function address range.
0041   StringRef FuncName; ///< The concrete function name that contains LookupAddr.
0042   /// The source locations that match this address. This information will only
0043   /// be filled in if the FunctionInfo contains a line table. If an address is
0044   /// for a concrete function with no inlined functions, this array will have
0045   /// one entry. If an address points to an inline function, there will be one
0046   /// SourceLocation for each inlined function with the last entry pointing to
0047   /// the concrete function itself. This allows one address to generate
0048   /// multiple locations and allows unwinding of inline call stacks. The
0049   /// deepest inline function will appear at index zero in the source locations
0050   /// array, and the concrete function will appear at the end of the array.
0051   SourceLocations Locations;
0052 
0053   /// Function name regex patterns associated with a call site at the lookup
0054   /// address. This vector will be populated when:
0055   /// 1. The lookup address matches a call site's return address in a function
0056   /// 2. The call site has associated regex patterns that describe what
0057   /// functions can be called from that location
0058   ///
0059   /// The regex patterns can be used to validate function calls during runtime
0060   /// checking or symbolication. For example:
0061   /// - Patterns like "^foo$" indicate the call site can only call function
0062   /// "foo"
0063   /// - Patterns like "^std::" indicate the call site can call any function in
0064   ///   the std namespace
0065   /// - Multiple patterns allow matching against a set of allowed functions
0066   ///
0067   /// The patterns are stored as string references into the GSYM string table.
0068   /// This information is typically loaded from:
0069   /// - DWARF debug info call site entries
0070   /// - External YAML files specifying call site patterns
0071   /// - Other debug info formats that encode call site constraints
0072   ///
0073   /// The patterns will be empty if:
0074   /// - The lookup address is not at the return address of a call site
0075   /// - The call site has no associated function name constraints
0076   /// - Call site info was not included when creating the GSYM file
0077   std::vector<StringRef> CallSiteFuncRegex;
0078 
0079   std::string getSourceFile(uint32_t Index) const;
0080 };
0081 
0082 inline bool operator==(const LookupResult &LHS, const LookupResult &RHS) {
0083   if (LHS.LookupAddr != RHS.LookupAddr)
0084     return false;
0085   if (LHS.FuncRange != RHS.FuncRange)
0086     return false;
0087   if (LHS.FuncName != RHS.FuncName)
0088     return false;
0089   if (LHS.CallSiteFuncRegex != RHS.CallSiteFuncRegex)
0090     return false;
0091   return LHS.Locations == RHS.Locations;
0092 }
0093 
0094 raw_ostream &operator<<(raw_ostream &OS, const LookupResult &R);
0095 
0096 } // namespace gsym
0097 } // namespace llvm
0098 
0099 #endif // LLVM_DEBUGINFO_GSYM_LOOKUPRESULT_H