xref: /freebsd-src/contrib/llvm-project/llvm/include/llvm/DebugInfo/GSYM/LookupResult.h (revision 5ffd83dbcc34f10e07f6d3e968ae6365869615f4)
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 
12480093f4SDimitry Andric #include "llvm/DebugInfo/GSYM/Range.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 struct FileEntry;
21480093f4SDimitry Andric 
22480093f4SDimitry Andric struct SourceLocation {
23480093f4SDimitry Andric   StringRef Name; ///< Function or symbol name.
24480093f4SDimitry Andric   StringRef Dir; ///< Line entry source file directory path.
25480093f4SDimitry Andric   StringRef Base; ///< Line entry source file basename.
26480093f4SDimitry Andric   uint32_t Line = 0; ///< Source file line number.
27*5ffd83dbSDimitry Andric   uint32_t Offset = 0; ///< Byte size offset within the named function.
28480093f4SDimitry Andric };
29480093f4SDimitry Andric 
30480093f4SDimitry Andric inline bool operator==(const SourceLocation &LHS, const SourceLocation &RHS) {
31480093f4SDimitry Andric   return LHS.Name == RHS.Name && LHS.Dir == RHS.Dir &&
32*5ffd83dbSDimitry Andric          LHS.Base == RHS.Base && LHS.Line == RHS.Line &&
33*5ffd83dbSDimitry Andric          LHS.Offset == RHS.Offset;
34480093f4SDimitry Andric }
35480093f4SDimitry Andric 
36480093f4SDimitry Andric raw_ostream &operator<<(raw_ostream &OS, const SourceLocation &R);
37480093f4SDimitry Andric 
38480093f4SDimitry Andric using SourceLocations = std::vector<SourceLocation>;
39480093f4SDimitry Andric 
40480093f4SDimitry Andric 
41480093f4SDimitry Andric struct LookupResult {
42480093f4SDimitry Andric   uint64_t LookupAddr = 0; ///< The address that this lookup pertains to.
43480093f4SDimitry Andric   AddressRange FuncRange; ///< The concrete function address range.
44480093f4SDimitry Andric   StringRef FuncName; ///< The concrete function name that contains LookupAddr.
45480093f4SDimitry Andric   /// The source locations that match this address. This information will only
46480093f4SDimitry Andric   /// be filled in if the FunctionInfo contains a line table. If an address is
47480093f4SDimitry Andric   /// for a concrete function with no inlined functions, this array will have
48480093f4SDimitry Andric   /// one entry. If an address points to an inline function, there will be one
49480093f4SDimitry Andric   /// SourceLocation for each inlined function with the last entry pointing to
50480093f4SDimitry Andric   /// the concrete function itself. This allows one address to generate
51480093f4SDimitry Andric   /// multiple locations and allows unwinding of inline call stacks. The
52480093f4SDimitry Andric   /// deepest inline function will appear at index zero in the source locations
53480093f4SDimitry Andric   /// array, and the concrete function will appear at the end of the array.
54480093f4SDimitry Andric   SourceLocations Locations;
55480093f4SDimitry Andric   std::string getSourceFile(uint32_t Index) const;
56480093f4SDimitry Andric };
57480093f4SDimitry Andric 
58480093f4SDimitry Andric raw_ostream &operator<<(raw_ostream &OS, const LookupResult &R);
59480093f4SDimitry Andric 
60480093f4SDimitry Andric } // namespace gsym
61480093f4SDimitry Andric } // namespace llvm
62480093f4SDimitry Andric 
63480093f4SDimitry Andric #endif // #ifndef LLVM_DEBUGINFO_GSYM_LOOKUPRESULT_H
64