LookupResult.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- LookupResult.h -------------------------------------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_DEBUGINFO_GSYM_LOOKUPRESULT_H
  14. #define LLVM_DEBUGINFO_GSYM_LOOKUPRESULT_H
  15. #include "llvm/DebugInfo/GSYM/Range.h"
  16. #include "llvm/ADT/StringRef.h"
  17. #include <inttypes.h>
  18. #include <vector>
  19. namespace llvm {
  20. class raw_ostream;
  21. namespace gsym {
  22. struct FileEntry;
  23. struct SourceLocation {
  24. StringRef Name; ///< Function or symbol name.
  25. StringRef Dir; ///< Line entry source file directory path.
  26. StringRef Base; ///< Line entry source file basename.
  27. uint32_t Line = 0; ///< Source file line number.
  28. uint32_t Offset = 0; ///< Byte size offset within the named function.
  29. };
  30. inline bool operator==(const SourceLocation &LHS, const SourceLocation &RHS) {
  31. return LHS.Name == RHS.Name && LHS.Dir == RHS.Dir &&
  32. LHS.Base == RHS.Base && LHS.Line == RHS.Line &&
  33. LHS.Offset == RHS.Offset;
  34. }
  35. raw_ostream &operator<<(raw_ostream &OS, const SourceLocation &R);
  36. using SourceLocations = std::vector<SourceLocation>;
  37. struct LookupResult {
  38. uint64_t LookupAddr = 0; ///< The address that this lookup pertains to.
  39. AddressRange FuncRange; ///< The concrete function address range.
  40. StringRef FuncName; ///< The concrete function name that contains LookupAddr.
  41. /// The source locations that match this address. This information will only
  42. /// be filled in if the FunctionInfo contains a line table. If an address is
  43. /// for a concrete function with no inlined functions, this array will have
  44. /// one entry. If an address points to an inline function, there will be one
  45. /// SourceLocation for each inlined function with the last entry pointing to
  46. /// the concrete function itself. This allows one address to generate
  47. /// multiple locations and allows unwinding of inline call stacks. The
  48. /// deepest inline function will appear at index zero in the source locations
  49. /// array, and the concrete function will appear at the end of the array.
  50. SourceLocations Locations;
  51. std::string getSourceFile(uint32_t Index) const;
  52. };
  53. raw_ostream &operator<<(raw_ostream &OS, const LookupResult &R);
  54. } // namespace gsym
  55. } // namespace llvm
  56. #endif // #ifndef LLVM_DEBUGINFO_GSYM_LOOKUPRESULT_H
  57. #ifdef __GNUC__
  58. #pragma GCC diagnostic pop
  59. #endif