DWARFDebugAbbrev.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- DWARFDebugAbbrev.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_DWARFDEBUGABBREV_H
  14. #define LLVM_DEBUGINFO_DWARFDEBUGABBREV_H
  15. #include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h"
  16. #include "llvm/Support/DataExtractor.h"
  17. #include <cstdint>
  18. #include <map>
  19. #include <vector>
  20. namespace llvm {
  21. class raw_ostream;
  22. class DWARFAbbreviationDeclarationSet {
  23. uint64_t Offset;
  24. /// Code of the first abbreviation, if all abbreviations in the set have
  25. /// consecutive codes. UINT32_MAX otherwise.
  26. uint32_t FirstAbbrCode;
  27. std::vector<DWARFAbbreviationDeclaration> Decls;
  28. using const_iterator =
  29. std::vector<DWARFAbbreviationDeclaration>::const_iterator;
  30. public:
  31. DWARFAbbreviationDeclarationSet();
  32. uint64_t getOffset() const { return Offset; }
  33. void dump(raw_ostream &OS) const;
  34. bool extract(DataExtractor Data, uint64_t *OffsetPtr);
  35. const DWARFAbbreviationDeclaration *
  36. getAbbreviationDeclaration(uint32_t AbbrCode) const;
  37. const_iterator begin() const {
  38. return Decls.begin();
  39. }
  40. const_iterator end() const {
  41. return Decls.end();
  42. }
  43. private:
  44. void clear();
  45. };
  46. class DWARFDebugAbbrev {
  47. using DWARFAbbreviationDeclarationSetMap =
  48. std::map<uint64_t, DWARFAbbreviationDeclarationSet>;
  49. mutable DWARFAbbreviationDeclarationSetMap AbbrDeclSets;
  50. mutable DWARFAbbreviationDeclarationSetMap::const_iterator PrevAbbrOffsetPos;
  51. mutable Optional<DataExtractor> Data;
  52. public:
  53. DWARFDebugAbbrev();
  54. const DWARFAbbreviationDeclarationSet *
  55. getAbbreviationDeclarationSet(uint64_t CUAbbrOffset) const;
  56. void dump(raw_ostream &OS) const;
  57. void parse() const;
  58. void extract(DataExtractor Data);
  59. DWARFAbbreviationDeclarationSetMap::const_iterator begin() const {
  60. parse();
  61. return AbbrDeclSets.begin();
  62. }
  63. DWARFAbbreviationDeclarationSetMap::const_iterator end() const {
  64. return AbbrDeclSets.end();
  65. }
  66. private:
  67. void clear();
  68. };
  69. } // end namespace llvm
  70. #endif // LLVM_DEBUGINFO_DWARFDEBUGABBREV_H
  71. #ifdef __GNUC__
  72. #pragma GCC diagnostic pop
  73. #endif