LLVM API Documentation

MCExternalSymbolizer.h
Go to the documentation of this file.
00001 //===-- llvm/MC/MCExternalSymbolizer.h - ------------------------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file contains the declaration of the MCExternalSymbolizer class, which
00011 // enables library users to provide callbacks (through the C API) to do the
00012 // symbolization externally.
00013 //
00014 //===----------------------------------------------------------------------===//
00015 
00016 #ifndef LLVM_MC_MCEXTERNALSYMBOLIZER_H
00017 #define LLVM_MC_MCEXTERNALSYMBOLIZER_H
00018 
00019 #include "llvm-c/Disassembler.h"
00020 #include "llvm/MC/MCSymbolizer.h"
00021 #include <memory>
00022 
00023 namespace llvm {
00024 
00025 /// \brief Symbolize using user-provided, C API, callbacks.
00026 ///
00027 /// See llvm-c/Disassembler.h.
00028 class MCExternalSymbolizer : public MCSymbolizer {
00029 protected:
00030   /// \name Hooks for symbolic disassembly via the public 'C' interface.
00031   /// @{
00032   /// The function to get the symbolic information for operands.
00033   LLVMOpInfoCallback GetOpInfo;
00034   /// The function to lookup a symbol name.
00035   LLVMSymbolLookupCallback SymbolLookUp;
00036   /// The pointer to the block of symbolic information for above call back.
00037   void *DisInfo;
00038   /// @}
00039 
00040 public:
00041   MCExternalSymbolizer(MCContext &Ctx,
00042                        std::unique_ptr<MCRelocationInfo> RelInfo,
00043                        LLVMOpInfoCallback getOpInfo,
00044                        LLVMSymbolLookupCallback symbolLookUp, void *disInfo)
00045     : MCSymbolizer(Ctx, std::move(RelInfo)), GetOpInfo(getOpInfo),
00046       SymbolLookUp(symbolLookUp), DisInfo(disInfo) {}
00047 
00048   bool tryAddingSymbolicOperand(MCInst &MI, raw_ostream &CommentStream,
00049                                 int64_t Value, uint64_t Address, bool IsBranch,
00050                                 uint64_t Offset, uint64_t InstSize) override;
00051   void tryAddingPcLoadReferenceComment(raw_ostream &CommentStream,
00052                                        int64_t Value,
00053                                        uint64_t Address) override;
00054 };
00055 
00056 }
00057 
00058 #endif