LLDB mainline
|
Finds and instruments individual LLVM IR instructions. More...
#include <IRDynamicChecks.cpp>
Public Member Functions | |
Instrumenter (llvm::Module &module, std::shared_ptr< UtilityFunction > checker_function) | |
Constructor. | |
virtual | ~Instrumenter ()=default |
bool | Inspect (llvm::Function &function) |
Inspect a function to find instructions to instrument. | |
bool | Instrument () |
Instrument all the instructions found by Inspect() | |
Protected Types | |
typedef std::vector< llvm::Instruction * > | InstVector |
typedef InstVector::iterator | InstIterator |
Protected Member Functions | |
virtual bool | InstrumentInstruction (llvm::Instruction *inst)=0 |
Add instrumentation to a single instruction. | |
void | RegisterInstruction (llvm::Instruction &inst) |
Register a single instruction to be instrumented. | |
virtual bool | InspectInstruction (llvm::Instruction &i) |
Determine whether a single instruction is interesting to instrument, and, if so, call RegisterInstruction. | |
virtual bool | InspectBasicBlock (llvm::BasicBlock &bb) |
Scan a basic block to see if any instructions are interesting. | |
virtual bool | InspectFunction (llvm::Function &f) |
Scan a function to see if any instructions are interesting. | |
llvm::FunctionCallee | BuildPointerValidatorFunc (lldb::addr_t start_address) |
Build a function pointer for a function with signature void (*)(uint8_t*) with a given address. | |
llvm::FunctionCallee | BuildObjectCheckerFunc (lldb::addr_t start_address) |
Build a function pointer for a function with signature void (*)(uint8_t*, uint8_t*) with a given address. | |
PointerType * | GetI8PtrTy () |
IntegerType * | GetIntptrTy () |
Protected Attributes | |
InstVector | m_to_instrument |
List of instructions the inspector found. | |
llvm::Module & | m_module |
The module which is being instrumented. | |
std::shared_ptr< UtilityFunction > | m_checker_function |
The dynamic checker function for the process. | |
Private Attributes | |
PointerType * | m_i8ptr_ty = nullptr |
IntegerType * | m_intptr_ty = nullptr |
Finds and instruments individual LLVM IR instructions.
When instrumenting LLVM IR, it is frequently desirable to first search for instructions, and then later modify them. This way iterators remain intact, and multiple passes can look at the same code base without treading on each other's toes.
The Instrumenter class implements this functionality. A client first calls Inspect on a function, which populates a list of instructions to be instrumented. Then, later, when all passes' Inspect functions have been called, the client calls Instrument, which adds the desired instrumentation.
A subclass of Instrumenter must override InstrumentInstruction, which is responsible for adding whatever instrumentation is necessary.
A subclass of Instrumenter may override:
Definition at line 128 of file IRDynamicChecks.cpp.
|
protected |
Definition at line 291 of file IRDynamicChecks.cpp.
|
protected |
Definition at line 290 of file IRDynamicChecks.cpp.
|
inline |
Constructor.
[in] | module | The module being instrumented. |
Definition at line 134 of file IRDynamicChecks.cpp.
|
virtualdefault |
|
inlineprotected |
Build a function pointer for a function with signature void (*)(uint8_t*, uint8_t*) with a given address.
[in] | start_address | The address of the function. |
Definition at line 257 of file IRDynamicChecks.cpp.
|
inlineprotected |
Build a function pointer for a function with signature void (*)(uint8_t*) with a given address.
[in] | start_address | The address of the function. |
Definition at line 234 of file IRDynamicChecks.cpp.
|
inlineprotected |
Definition at line 273 of file IRDynamicChecks.cpp.
|
inlineprotected |
Definition at line 280 of file IRDynamicChecks.cpp.
|
inline |
Inspect a function to find instructions to instrument.
[in] | function | The function to inspect. |
Definition at line 147 of file IRDynamicChecks.cpp.
Referenced by lldb_private::IRDynamicChecks::runOnModule().
|
inlineprotectedvirtual |
Scan a basic block to see if any instructions are interesting.
[in] | bb | The basic block to be inspected. |
Definition at line 199 of file IRDynamicChecks.cpp.
|
inlineprotectedvirtual |
Scan a function to see if any instructions are interesting.
[in] | f | The function to be inspected. |
Definition at line 216 of file IRDynamicChecks.cpp.
|
inlineprotectedvirtual |
Determine whether a single instruction is interesting to instrument, and, if so, call RegisterInstruction.
[in] | i | The instruction to be inspected. |
Reimplemented in ValidPointerChecker, and ObjcObjectChecker.
Definition at line 190 of file IRDynamicChecks.cpp.
|
inline |
Instrument all the instructions found by Inspect()
Definition at line 153 of file IRDynamicChecks.cpp.
Referenced by lldb_private::IRDynamicChecks::runOnModule().
|
protectedpure virtual |
Add instrumentation to a single instruction.
[in] | inst | The instruction to be instrumented. |
Implemented in ValidPointerChecker, and ObjcObjectChecker.
|
inlineprotected |
Register a single instruction to be instrumented.
[in] | inst | The instruction to be instrumented. |
Definition at line 178 of file IRDynamicChecks.cpp.
|
protected |
The dynamic checker function for the process.
Definition at line 296 of file IRDynamicChecks.cpp.
|
private |
Definition at line 299 of file IRDynamicChecks.cpp.
|
private |
Definition at line 300 of file IRDynamicChecks.cpp.
|
protected |
The module which is being instrumented.
Definition at line 294 of file IRDynamicChecks.cpp.
|
protected |
List of instructions the inspector found.
Definition at line 293 of file IRDynamicChecks.cpp.