MinimalSymbolDumper.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. //===- MinimalSymbolDumper.h ---------------------------------- *- C++ --*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #ifndef LLVM_TOOLS_LLVMPDBUTIL_MINIMAL_SYMBOL_DUMPER_H
  9. #define LLVM_TOOLS_LLVMPDBUTIL_MINIMAL_SYMBOL_DUMPER_H
  10. #include "llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h"
  11. namespace llvm {
  12. namespace codeview {
  13. class LazyRandomTypeCollection;
  14. }
  15. namespace pdb {
  16. class LinePrinter;
  17. class SymbolGroup;
  18. class MinimalSymbolDumper : public codeview::SymbolVisitorCallbacks {
  19. public:
  20. MinimalSymbolDumper(LinePrinter &P, bool RecordBytes,
  21. codeview::LazyRandomTypeCollection &Ids,
  22. codeview::LazyRandomTypeCollection &Types)
  23. : P(P), RecordBytes(RecordBytes), Ids(Ids), Types(Types) {}
  24. MinimalSymbolDumper(LinePrinter &P, bool RecordBytes,
  25. const SymbolGroup &SymGroup,
  26. codeview::LazyRandomTypeCollection &Ids,
  27. codeview::LazyRandomTypeCollection &Types)
  28. : P(P), RecordBytes(RecordBytes), SymGroup(&SymGroup), Ids(Ids),
  29. Types(Types) {}
  30. Error visitSymbolBegin(codeview::CVSymbol &Record) override;
  31. Error visitSymbolBegin(codeview::CVSymbol &Record, uint32_t Offset) override;
  32. Error visitSymbolEnd(codeview::CVSymbol &Record) override;
  33. void setSymbolGroup(const SymbolGroup *Group) { SymGroup = Group; }
  34. #define SYMBOL_RECORD(EnumName, EnumVal, Name) \
  35. virtual Error visitKnownRecord(codeview::CVSymbol &CVR, \
  36. codeview::Name &Record) override;
  37. #define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
  38. #include "llvm/DebugInfo/CodeView/CodeViewSymbols.def"
  39. private:
  40. std::string typeOrIdIndex(codeview::TypeIndex TI, bool IsType) const;
  41. std::string typeIndex(codeview::TypeIndex TI) const;
  42. std::string idIndex(codeview::TypeIndex TI) const;
  43. LinePrinter &P;
  44. /// Dumping certain records requires knowing what machine this is. The
  45. /// S_COMPILE3 record will tell us, but if we don't see one, default to X64.
  46. codeview::CPUType CompilationCPU = codeview::CPUType::X64;
  47. bool RecordBytes;
  48. const SymbolGroup *SymGroup = nullptr;
  49. codeview::LazyRandomTypeCollection &Ids;
  50. codeview::LazyRandomTypeCollection &Types;
  51. };
  52. } // namespace pdb
  53. } // namespace llvm
  54. #endif