xref: /freebsd-src/contrib/llvm-project/llvm/include/llvm/DebugInfo/GSYM/LookupResult.h (revision 06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e)
1480093f4SDimitry Andric //===- LookupResult.h -------------------------------------------*- C++ -*-===//
2480093f4SDimitry Andric //
3480093f4SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4480093f4SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5480093f4SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6480093f4SDimitry Andric //
7480093f4SDimitry Andric //===----------------------------------------------------------------------===//
8480093f4SDimitry Andric 
9480093f4SDimitry Andric #ifndef LLVM_DEBUGINFO_GSYM_LOOKUPRESULT_H
10480093f4SDimitry Andric #define LLVM_DEBUGINFO_GSYM_LOOKUPRESULT_H
11480093f4SDimitry Andric 
1281ad6265SDimitry Andric #include "llvm/ADT/AddressRanges.h"
13480093f4SDimitry Andric #include "llvm/ADT/StringRef.h"
14480093f4SDimitry Andric #include <inttypes.h>
15480093f4SDimitry Andric #include <vector>
16480093f4SDimitry Andric 
17480093f4SDimitry Andric namespace llvm {
18480093f4SDimitry Andric class raw_ostream;
19480093f4SDimitry Andric namespace gsym {
20480093f4SDimitry Andric 
21480093f4SDimitry Andric struct SourceLocation {
22480093f4SDimitry Andric   StringRef Name;      ///< Function or symbol name.
23480093f4SDimitry Andric   StringRef Dir;       ///< Line entry source file directory path.
24480093f4SDimitry Andric   StringRef Base;      ///< Line entry source file basename.
25480093f4SDimitry Andric   uint32_t Line = 0;   ///< Source file line number.
265ffd83dbSDimitry Andric   uint32_t Offset = 0; ///< Byte size offset within the named function.
27480093f4SDimitry Andric };
28480093f4SDimitry Andric 
29480093f4SDimitry Andric inline bool operator==(const SourceLocation &LHS, const SourceLocation &RHS) {
30fe6060f1SDimitry Andric   return LHS.Name == RHS.Name && LHS.Dir == RHS.Dir && LHS.Base == RHS.Base &&
31fe6060f1SDimitry Andric          LHS.Line == RHS.Line && LHS.Offset == RHS.Offset;
32480093f4SDimitry Andric }
33480093f4SDimitry Andric 
34480093f4SDimitry Andric raw_ostream &operator<<(raw_ostream &OS, const SourceLocation &R);
35480093f4SDimitry Andric 
36480093f4SDimitry Andric using SourceLocations = std::vector<SourceLocation>;
37480093f4SDimitry Andric 
38480093f4SDimitry Andric struct LookupResult {
39480093f4SDimitry Andric   uint64_t LookupAddr = 0; ///< The address that this lookup pertains to.
40480093f4SDimitry Andric   AddressRange FuncRange;  ///< The concrete function address range.
41480093f4SDimitry Andric   StringRef FuncName; ///< The concrete function name that contains LookupAddr.
42480093f4SDimitry Andric   /// The source locations that match this address. This information will only
43480093f4SDimitry Andric   /// be filled in if the FunctionInfo contains a line table. If an address is
44480093f4SDimitry Andric   /// for a concrete function with no inlined functions, this array will have
45480093f4SDimitry Andric   /// one entry. If an address points to an inline function, there will be one
46480093f4SDimitry Andric   /// SourceLocation for each inlined function with the last entry pointing to
47480093f4SDimitry Andric   /// the concrete function itself. This allows one address to generate
48480093f4SDimitry Andric   /// multiple locations and allows unwinding of inline call stacks. The
49480093f4SDimitry Andric   /// deepest inline function will appear at index zero in the source locations
50480093f4SDimitry Andric   /// array, and the concrete function will appear at the end of the array.
51480093f4SDimitry Andric   SourceLocations Locations;
52480093f4SDimitry Andric   std::string getSourceFile(uint32_t Index) const;
53480093f4SDimitry Andric };
54480093f4SDimitry Andric 
55*06c3fb27SDimitry Andric inline bool operator==(const LookupResult &LHS, const LookupResult &RHS) {
56*06c3fb27SDimitry Andric   if (LHS.LookupAddr != RHS.LookupAddr)
57*06c3fb27SDimitry Andric     return false;
58*06c3fb27SDimitry Andric   if (LHS.FuncRange != RHS.FuncRange)
59*06c3fb27SDimitry Andric     return false;
60*06c3fb27SDimitry Andric   if (LHS.FuncName != RHS.FuncName)
61*06c3fb27SDimitry Andric     return false;
62*06c3fb27SDimitry Andric   return LHS.Locations == RHS.Locations;
63*06c3fb27SDimitry Andric }
64*06c3fb27SDimitry Andric 
65480093f4SDimitry Andric raw_ostream &operator<<(raw_ostream &OS, const LookupResult &R);
66480093f4SDimitry Andric 
67480093f4SDimitry Andric } // namespace gsym
68480093f4SDimitry Andric } // namespace llvm
69480093f4SDimitry Andric 
70fe6060f1SDimitry Andric #endif // LLVM_DEBUGINFO_GSYM_LOOKUPRESULT_H
71