DWARFDebugLoc.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //===-- DWARFDebugLoc.h -----------------------------------------*- C++ -*-===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #ifndef LLVM_LIB_DEBUGINFO_DWARFDEBUGLOC_H
  10. #define LLVM_LIB_DEBUGINFO_DWARFDEBUGLOC_H
  11. #include "llvm/ADT/SmallVector.h"
  12. #include "llvm/DebugInfo/DWARF/DWARFRelocMap.h"
  13. #include "llvm/Support/DataExtractor.h"
  14. namespace llvm {
  15. class raw_ostream;
  16. class DWARFDebugLoc {
  17. /// A single location within a location list.
  18. struct Entry {
  19. /// The beginning address of the instruction range.
  20. uint64_t Begin;
  21. /// The ending address of the instruction range.
  22. uint64_t End;
  23. /// The location of the variable within the specified range.
  24. SmallVector<unsigned char, 4> Loc;
  25. };
  26. /// A list of locations that contain one variable.
  27. struct LocationList {
  28. /// The beginning offset where this location list is stored in the debug_loc
  29. /// section.
  30. unsigned Offset;
  31. /// All the locations in which the variable is stored.
  32. SmallVector<Entry, 2> Entries;
  33. };
  34. typedef SmallVector<LocationList, 4> LocationLists;
  35. /// A list of all the variables in the debug_loc section, each one describing
  36. /// the locations in which the variable is stored.
  37. LocationLists Locations;
  38. /// A map used to resolve binary relocations.
  39. const RelocAddrMap &RelocMap;
  40. public:
  41. DWARFDebugLoc(const RelocAddrMap &LocRelocMap) : RelocMap(LocRelocMap) {}
  42. /// Print the location lists found within the debug_loc section.
  43. void dump(raw_ostream &OS) const;
  44. /// Parse the debug_loc section accessible via the 'data' parameter using the
  45. /// specified address size to interpret the address ranges.
  46. void parse(DataExtractor data, unsigned AddressSize);
  47. };
  48. class DWARFDebugLocDWO {
  49. struct Entry {
  50. uint64_t Start;
  51. uint32_t Length;
  52. SmallVector<unsigned char, 4> Loc;
  53. };
  54. struct LocationList {
  55. unsigned Offset;
  56. SmallVector<Entry, 2> Entries;
  57. };
  58. typedef SmallVector<LocationList, 4> LocationLists;
  59. LocationLists Locations;
  60. public:
  61. void parse(DataExtractor data);
  62. void dump(raw_ostream &OS) const;
  63. };
  64. }
  65. #endif