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 
12 #include "llvm/DebugInfo/GSYM/Range.h"
13 #include "llvm/ADT/StringRef.h"
14 #include <inttypes.h>
15 #include <vector>
16 
17 namespace llvm {
18 class raw_ostream;
19 namespace gsym {
20 struct FileEntry;
21 
22 struct SourceLocation {
23   StringRef Name; ///< Function or symbol name.
24   StringRef Dir; ///< Line entry source file directory path.
25   StringRef Base; ///< Line entry source file basename.
26   uint32_t Line = 0; ///< Source file line number.
27 };
28 
29 inline bool operator==(const SourceLocation &LHS, const SourceLocation &RHS) {
30   return LHS.Name == RHS.Name && LHS.Dir == RHS.Dir &&
31          LHS.Base == RHS.Base && LHS.Line == RHS.Line;
32 }
33 
34 raw_ostream &operator<<(raw_ostream &OS, const SourceLocation &R);
35 
36 using SourceLocations = std::vector<SourceLocation>;
37 
38 
39 struct LookupResult {
40   uint64_t LookupAddr = 0; ///< The address that this lookup pertains to.
41   AddressRange FuncRange; ///< The concrete function address range.
42   StringRef FuncName; ///< The concrete function name that contains LookupAddr.
43   /// The source locations that match this address. This information will only
44   /// be filled in if the FunctionInfo contains a line table. If an address is
45   /// for a concrete function with no inlined functions, this array will have
46   /// one entry. If an address points to an inline function, there will be one
47   /// SourceLocation for each inlined function with the last entry pointing to
48   /// the concrete function itself. This allows one address to generate
49   /// multiple locations and allows unwinding of inline call stacks. The
50   /// deepest inline function will appear at index zero in the source locations
51   /// array, and the concrete function will appear at the end of the array.
52   SourceLocations Locations;
53   std::string getSourceFile(uint32_t Index) const;
54 };
55 
56 raw_ostream &operator<<(raw_ostream &OS, const LookupResult &R);
57 
58 } // namespace gsym
59 } // namespace llvm
60 
61 #endif // #ifndef LLVM_DEBUGINFO_GSYM_LOOKUPRESULT_H
62