1 //===-- llvm/MC/MCExternalSymbolizer.h - ------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
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.
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_MC_MCEXTERNALSYMBOLIZER_H
17 #define LLVM_MC_MCEXTERNALSYMBOLIZER_H
19 #include "llvm-c/Disassembler.h"
20 #include "llvm/MC/MCSymbolizer.h"
24 /// \brief Symbolize using user-provided, C API, callbacks.
26 /// See llvm-c/Disassembler.h.
27 class MCExternalSymbolizer : public MCSymbolizer {
29 /// \name Hooks for symbolic disassembly via the public 'C' interface.
31 /// The function to get the symbolic information for operands.
32 LLVMOpInfoCallback GetOpInfo;
33 /// The function to lookup a symbol name.
34 LLVMSymbolLookupCallback SymbolLookUp;
35 /// The pointer to the block of symbolic information for above call back.
40 MCExternalSymbolizer(MCContext &Ctx,
41 OwningPtr<MCRelocationInfo> &RelInfo,
42 LLVMOpInfoCallback getOpInfo,
43 LLVMSymbolLookupCallback symbolLookUp,
45 : MCSymbolizer(Ctx, RelInfo),
46 GetOpInfo(getOpInfo), SymbolLookUp(symbolLookUp), DisInfo(disInfo) {}
48 bool tryAddingSymbolicOperand(MCInst &MI, raw_ostream &CommentStream,
50 uint64_t Address, bool IsBranch,
51 uint64_t Offset, uint64_t InstSize);
52 void tryAddingPcLoadReferenceComment(raw_ostream &CommentStream,
53 int64_t Value, uint64_t Address);