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 | 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 116 of file IRDynamicChecks.cpp.
|
protected |
Definition at line 256 of file IRDynamicChecks.cpp.
|
protected |
Definition at line 255 of file IRDynamicChecks.cpp.
|
inline |
Constructor.
[in] | module | The module being instrumented. |
Definition at line 122 of file IRDynamicChecks.cpp.
References m_checker_function, and m_module.
Referenced by ObjcObjectChecker::ObjcObjectChecker().
|
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 222 of file IRDynamicChecks.cpp.
References GetI8PtrTy(), GetIntptrTy(), and m_module.
Referenced by ObjcObjectChecker::InstrumentInstruction().
|
inlineprotected |
Definition at line 238 of file IRDynamicChecks.cpp.
References m_i8ptr_ty, and m_module.
Referenced by BuildObjectCheckerFunc().
|
inlineprotected |
Definition at line 245 of file IRDynamicChecks.cpp.
References m_intptr_ty, and m_module.
Referenced by BuildObjectCheckerFunc().
|
inline |
Inspect a function to find instructions to instrument.
[in] | function | The function to inspect. |
Definition at line 135 of file IRDynamicChecks.cpp.
References InspectFunction().
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 187 of file IRDynamicChecks.cpp.
References InspectInstruction().
Referenced by InspectFunction().
|
inlineprotectedvirtual |
Scan a function to see if any instructions are interesting.
[in] | f | The function to be inspected. |
Definition at line 204 of file IRDynamicChecks.cpp.
References InspectBasicBlock().
Referenced by Inspect().
|
inlineprotectedvirtual |
Determine whether a single instruction is interesting to instrument, and, if so, call RegisterInstruction.
[in] | i | The instruction to be inspected. |
Reimplemented in ObjcObjectChecker.
Definition at line 178 of file IRDynamicChecks.cpp.
Referenced by InspectBasicBlock().
|
inline |
Instrument all the instructions found by Inspect()
Definition at line 141 of file IRDynamicChecks.cpp.
References InstrumentInstruction(), and m_to_instrument.
Referenced by lldb_private::IRDynamicChecks::runOnModule().
|
protectedpure virtual |
Add instrumentation to a single instruction.
[in] | inst | The instruction to be instrumented. |
Implemented in ObjcObjectChecker.
Referenced by Instrument().
|
inlineprotected |
Register a single instruction to be instrumented.
[in] | inst | The instruction to be instrumented. |
Definition at line 166 of file IRDynamicChecks.cpp.
References m_to_instrument.
Referenced by ObjcObjectChecker::InspectInstruction().
|
protected |
The dynamic checker function for the process.
Definition at line 261 of file IRDynamicChecks.cpp.
Referenced by Instrumenter(), and ObjcObjectChecker::InstrumentInstruction().
|
private |
Definition at line 264 of file IRDynamicChecks.cpp.
Referenced by GetI8PtrTy().
|
private |
Definition at line 265 of file IRDynamicChecks.cpp.
Referenced by GetIntptrTy().
|
protected |
The module which is being instrumented.
Definition at line 259 of file IRDynamicChecks.cpp.
Referenced by BuildObjectCheckerFunc(), GetI8PtrTy(), GetIntptrTy(), and Instrumenter().
|
protected |
List of instructions the inspector found.
Definition at line 258 of file IRDynamicChecks.cpp.
Referenced by Instrument(), and RegisterInstruction().