LLVM  9.0.0svn
MCExternalSymbolizer.h
Go to the documentation of this file.
1 //===-- llvm/MC/MCExternalSymbolizer.h - ------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains the declaration of the MCExternalSymbolizer class, which
10 // enables library users to provide callbacks (through the C API) to do the
11 // symbolization externally.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_MC_MCDISASSEMBLER_MCEXTERNALSYMBOLIZER_H
16 #define LLVM_MC_MCDISASSEMBLER_MCEXTERNALSYMBOLIZER_H
17 
18 #include "llvm-c/Disassembler.h"
20 #include <memory>
21 
22 namespace llvm {
23 
24 /// Symbolize using user-provided, C API, callbacks.
25 ///
26 /// See llvm-c/Disassembler.h.
28 protected:
29  /// \name Hooks for symbolic disassembly via the public 'C' interface.
30  /// @{
31  /// The function to get the symbolic information for operands.
33  /// The function to lookup a symbol name.
35  /// The pointer to the block of symbolic information for above call back.
36  void *DisInfo;
37  /// @}
38 
39 public:
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 
47  bool tryAddingSymbolicOperand(MCInst &MI, raw_ostream &CommentStream,
48  int64_t Value, uint64_t Address, bool IsBranch,
49  uint64_t Offset, uint64_t InstSize) override;
50  void tryAddingPcLoadReferenceComment(raw_ostream &CommentStream,
51  int64_t Value,
52  uint64_t Address) override;
53 };
54 
55 }
56 
57 #endif
std::unique_ptr< MCRelocationInfo > RelInfo
Definition: MCSymbolizer.h:41
This class represents lattice values for constants.
Definition: AllocatorList.h:23
Symbolize using user-provided, C API, callbacks.
MCContext & Ctx
Definition: MCSymbolizer.h:40
void * DisInfo
The pointer to the block of symbolic information for above call back.
Definition: BitVector.h:937
int(* LLVMOpInfoCallback)(void *DisInfo, uint64_t PC, uint64_t Offset, uint64_t Size, int TagType, void *TagBuf)
The type for the operand information call back function.
Context object for machine code objects.
Definition: MCContext.h:62
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:158
MCExternalSymbolizer(MCContext &Ctx, std::unique_ptr< MCRelocationInfo > RelInfo, LLVMOpInfoCallback getOpInfo, LLVMSymbolLookupCallback symbolLookUp, void *disInfo)
Symbolize and annotate disassembled instructions.
Definition: MCSymbolizer.h:38
void tryAddingPcLoadReferenceComment(raw_ostream &CommentStream, int64_t Value, uint64_t Address) override
Try to add a comment on the PC-relative load.
bool tryAddingSymbolicOperand(MCInst &MI, raw_ostream &CommentStream, int64_t Value, uint64_t Address, bool IsBranch, uint64_t Offset, uint64_t InstSize) override
Try to add a symbolic operand instead of Value to the MCInst.
LLVM Value Representation.
Definition: Value.h:72
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
IRTranslator LLVM IR MI
const char *(* LLVMSymbolLookupCallback)(void *DisInfo, uint64_t ReferenceValue, uint64_t *ReferenceType, uint64_t ReferencePC, const char **ReferenceName)
The type for the symbol lookup function.
LLVMSymbolLookupCallback SymbolLookUp
The function to lookup a symbol name.