LLVM 20.0.0git
LookupResult.h
Go to the documentation of this file.
1//===- LookupResult.h -------------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_DEBUGINFO_GSYM_LOOKUPRESULT_H
10#define LLVM_DEBUGINFO_GSYM_LOOKUPRESULT_H
11
13#include "llvm/ADT/StringRef.h"
14#include <inttypes.h>
15#include <vector>
16
17namespace llvm {
18class raw_ostream;
19namespace gsym {
20
22 StringRef Name; ///< Function or symbol name.
23 StringRef Dir; ///< Line entry source file directory path.
24 StringRef Base; ///< Line entry source file basename.
25 uint32_t Line = 0; ///< Source file line number.
26 uint32_t Offset = 0; ///< Byte size offset within the named function.
27};
28
29inline bool operator==(const SourceLocation &LHS, const SourceLocation &RHS) {
30 return LHS.Name == RHS.Name && LHS.Dir == RHS.Dir && LHS.Base == RHS.Base &&
31 LHS.Line == RHS.Line && LHS.Offset == RHS.Offset;
32}
33
34raw_ostream &operator<<(raw_ostream &OS, const SourceLocation &R);
35
36using SourceLocations = std::vector<SourceLocation>;
37
39 uint64_t LookupAddr = 0; ///< The address that this lookup pertains to.
40 AddressRange FuncRange; ///< The concrete function address range.
41 StringRef FuncName; ///< The concrete function name that contains LookupAddr.
42 /// The source locations that match this address. This information will only
43 /// be filled in if the FunctionInfo contains a line table. If an address is
44 /// for a concrete function with no inlined functions, this array will have
45 /// one entry. If an address points to an inline function, there will be one
46 /// SourceLocation for each inlined function with the last entry pointing to
47 /// the concrete function itself. This allows one address to generate
48 /// multiple locations and allows unwinding of inline call stacks. The
49 /// deepest inline function will appear at index zero in the source locations
50 /// array, and the concrete function will appear at the end of the array.
52
53 /// Function name regex patterns associated with a call site at the lookup
54 /// address. This vector will be populated when:
55 /// 1. The lookup address matches a call site's return address in a function
56 /// 2. The call site has associated regex patterns that describe what
57 /// functions can be called from that location
58 ///
59 /// The regex patterns can be used to validate function calls during runtime
60 /// checking or symbolication. For example:
61 /// - Patterns like "^foo$" indicate the call site can only call function
62 /// "foo"
63 /// - Patterns like "^std::" indicate the call site can call any function in
64 /// the std namespace
65 /// - Multiple patterns allow matching against a set of allowed functions
66 ///
67 /// The patterns are stored as string references into the GSYM string table.
68 /// This information is typically loaded from:
69 /// - DWARF debug info call site entries
70 /// - External YAML files specifying call site patterns
71 /// - Other debug info formats that encode call site constraints
72 ///
73 /// The patterns will be empty if:
74 /// - The lookup address is not at the return address of a call site
75 /// - The call site has no associated function name constraints
76 /// - Call site info was not included when creating the GSYM file
77 std::vector<StringRef> CallSiteFuncRegex;
78
79 std::string getSourceFile(uint32_t Index) const;
80};
81
82inline bool operator==(const LookupResult &LHS, const LookupResult &RHS) {
83 if (LHS.LookupAddr != RHS.LookupAddr)
84 return false;
85 if (LHS.FuncRange != RHS.FuncRange)
86 return false;
87 if (LHS.FuncName != RHS.FuncName)
88 return false;
89 if (LHS.CallSiteFuncRegex != RHS.CallSiteFuncRegex)
90 return false;
91 return LHS.Locations == RHS.Locations;
92}
93
94raw_ostream &operator<<(raw_ostream &OS, const LookupResult &R);
95
96} // namespace gsym
97} // namespace llvm
98
99#endif // LLVM_DEBUGINFO_GSYM_LOOKUPRESULT_H
uint32_t Index
raw_pwrite_stream & OS
Value * RHS
Value * LHS
A class that represents an address range.
Definition: AddressRanges.h:22
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
raw_ostream & operator<<(raw_ostream &OS, const CallSiteInfo &CSI)
std::vector< SourceLocation > SourceLocations
Definition: LookupResult.h:36
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
bool operator==(const AddressRangeValuePair &LHS, const AddressRangeValuePair &RHS)
uint64_t LookupAddr
The address that this lookup pertains to.
Definition: LookupResult.h:39
std::string getSourceFile(uint32_t Index) const
AddressRange FuncRange
The concrete function address range.
Definition: LookupResult.h:40
std::vector< StringRef > CallSiteFuncRegex
Function name regex patterns associated with a call site at the lookup address.
Definition: LookupResult.h:77
StringRef FuncName
The concrete function name that contains LookupAddr.
Definition: LookupResult.h:41
SourceLocations Locations
The source locations that match this address.
Definition: LookupResult.h:51
StringRef Base
Line entry source file basename.
Definition: LookupResult.h:24
uint32_t Line
Source file line number.
Definition: LookupResult.h:25
uint32_t Offset
Byte size offset within the named function.
Definition: LookupResult.h:26
StringRef Dir
Line entry source file directory path.
Definition: LookupResult.h:23
StringRef Name
Function or symbol name.
Definition: LookupResult.h:22