LookupResult.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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/ADT/AddressRanges.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 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. uint32_t Offset = 0; ///< Byte size offset within the named function.
  28. };
  29. inline 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. raw_ostream &operator<<(raw_ostream &OS, const SourceLocation &R);
  34. using SourceLocations = std::vector<SourceLocation>;
  35. struct LookupResult {
  36. uint64_t LookupAddr = 0; ///< The address that this lookup pertains to.
  37. AddressRange FuncRange; ///< The concrete function address range.
  38. StringRef FuncName; ///< The concrete function name that contains LookupAddr.
  39. /// The source locations that match this address. This information will only
  40. /// be filled in if the FunctionInfo contains a line table. If an address is
  41. /// for a concrete function with no inlined functions, this array will have
  42. /// one entry. If an address points to an inline function, there will be one
  43. /// SourceLocation for each inlined function with the last entry pointing to
  44. /// the concrete function itself. This allows one address to generate
  45. /// multiple locations and allows unwinding of inline call stacks. The
  46. /// deepest inline function will appear at index zero in the source locations
  47. /// array, and the concrete function will appear at the end of the array.
  48. SourceLocations Locations;
  49. std::string getSourceFile(uint32_t Index) const;
  50. };
  51. raw_ostream &operator<<(raw_ostream &OS, const LookupResult &R);
  52. } // namespace gsym
  53. } // namespace llvm
  54. #endif // LLVM_DEBUGINFO_GSYM_LOOKUPRESULT_H
  55. #ifdef __GNUC__
  56. #pragma GCC diagnostic pop
  57. #endif