MCExternalSymbolizer.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //===-- llvm/MC/MCExternalSymbolizer.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. //
  10. // This file contains the declaration of the MCExternalSymbolizer class, which
  11. // enables library users to provide callbacks (through the C API) to do the
  12. // symbolization externally.
  13. //
  14. //===----------------------------------------------------------------------===//
  15. #ifndef LLVM_MC_MCEXTERNALSYMBOLIZER_H
  16. #define LLVM_MC_MCEXTERNALSYMBOLIZER_H
  17. #include "llvm-c/Disassembler.h"
  18. #include "llvm/MC/MCSymbolizer.h"
  19. #include <memory>
  20. namespace llvm {
  21. /// \brief Symbolize using user-provided, C API, callbacks.
  22. ///
  23. /// See llvm-c/Disassembler.h.
  24. class MCExternalSymbolizer : public MCSymbolizer {
  25. protected:
  26. /// \name Hooks for symbolic disassembly via the public 'C' interface.
  27. /// @{
  28. /// The function to get the symbolic information for operands.
  29. LLVMOpInfoCallback GetOpInfo;
  30. /// The function to lookup a symbol name.
  31. LLVMSymbolLookupCallback SymbolLookUp;
  32. /// The pointer to the block of symbolic information for above call back.
  33. void *DisInfo;
  34. /// @}
  35. public:
  36. MCExternalSymbolizer(MCContext &Ctx,
  37. std::unique_ptr<MCRelocationInfo> RelInfo,
  38. LLVMOpInfoCallback getOpInfo,
  39. LLVMSymbolLookupCallback symbolLookUp, void *disInfo)
  40. : MCSymbolizer(Ctx, std::move(RelInfo)), GetOpInfo(getOpInfo),
  41. SymbolLookUp(symbolLookUp), DisInfo(disInfo) {}
  42. bool tryAddingSymbolicOperand(MCInst &MI, raw_ostream &CommentStream,
  43. int64_t Value, uint64_t Address, bool IsBranch,
  44. uint64_t Offset, uint64_t InstSize) override;
  45. void tryAddingPcLoadReferenceComment(raw_ostream &CommentStream,
  46. int64_t Value,
  47. uint64_t Address) override;
  48. };
  49. }
  50. #endif