12c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha//===-- llvm/MC/MCExternalSymbolizer.h - ------------------------*- C++ -*-===// 22c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha// 32c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha// The LLVM Compiler Infrastructure 42c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha// 52c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha// This file is distributed under the University of Illinois Open Source 62c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha// License. See LICENSE.TXT for details. 72c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha// 82c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha//===----------------------------------------------------------------------===// 92c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha// 102c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha// This file contains the declaration of the MCExternalSymbolizer class, which 112c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha// enables library users to provide callbacks (through the C API) to do the 122c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha// symbolization externally. 132c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha// 142c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha//===----------------------------------------------------------------------===// 152c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha 162c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha#ifndef LLVM_MC_MCEXTERNALSYMBOLIZER_H 172c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha#define LLVM_MC_MCEXTERNALSYMBOLIZER_H 182c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha 192c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha#include "llvm-c/Disassembler.h" 202c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha#include "llvm/MC/MCSymbolizer.h" 2136b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines#include <memory> 222c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha 232c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougachanamespace llvm { 242c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha 252c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha/// \brief Symbolize using user-provided, C API, callbacks. 262c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha/// 272c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha/// See llvm-c/Disassembler.h. 282c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougachaclass MCExternalSymbolizer : public MCSymbolizer { 29dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hinesprotected: 302c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha /// \name Hooks for symbolic disassembly via the public 'C' interface. 312c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha /// @{ 322c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha /// The function to get the symbolic information for operands. 332c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha LLVMOpInfoCallback GetOpInfo; 342c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha /// The function to lookup a symbol name. 352c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha LLVMSymbolLookupCallback SymbolLookUp; 362c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha /// The pointer to the block of symbolic information for above call back. 372c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha void *DisInfo; 382c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha /// @} 392c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha 402c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougachapublic: 412c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha MCExternalSymbolizer(MCContext &Ctx, 4236b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines std::unique_ptr<MCRelocationInfo> RelInfo, 432c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha LLVMOpInfoCallback getOpInfo, 4436b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines LLVMSymbolLookupCallback symbolLookUp, void *disInfo) 4536b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines : MCSymbolizer(Ctx, std::move(RelInfo)), GetOpInfo(getOpInfo), 4636b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines SymbolLookUp(symbolLookUp), DisInfo(disInfo) {} 472c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha 482c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha bool tryAddingSymbolicOperand(MCInst &MI, raw_ostream &CommentStream, 4936b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines int64_t Value, uint64_t Address, bool IsBranch, 5036b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines uint64_t Offset, uint64_t InstSize) override; 512c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha void tryAddingPcLoadReferenceComment(raw_ostream &CommentStream, 5236b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines int64_t Value, 5336b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines uint64_t Address) override; 542c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha}; 552c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha 562c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha} 572c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha 582c94d0faa0e1c268893d5e04dc77e8a35889db00Ahmed Bougacha#endif 59