MCExternalSymbolizer.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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/DisassemblerTypes.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 OpSize,
  49. uint64_t InstSize) override;
  50. void tryAddingPcLoadReferenceComment(raw_ostream &CommentStream,
  51. int64_t Value,
  52. uint64_t Address) override;
  53. };
  54. }
  55. #endif
  56. #ifdef __GNUC__
  57. #pragma GCC diagnostic pop
  58. #endif