MCExternalSymbolizer.h 2.3 KB

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