[LLVMdev] Instrumenting virtual function calls
Chris Lattner
sabre at nondot.org
Sun Feb 10 13:41:18 PST 2008
On Feb 10, 2008, at 5:33 AM, Robert Zeh wrote:
> I'm attempting to instrument virtual function calls in my code.
> After each virtual call I'm calling my own registerMethod function,
> with an integer marking the location of the call and a pointer to
> the function that was called.
>
> However, and this is where I get confused, the function pointer
> doesn't match any of the functions in my module. I'd hoped to call
> ExecutionEngine::getGlobalValueAtAddress to get a Function* for the
> virtual function, but ExecutionEngine::getGlobalValueAtAddress
> returns null.
>
> If I look up the virtual function that is getting called (with
> ExeuctionEngine::getPointerToFunction) it doesn't match the
> arguments being passed to my instrumentation. What's a little
> strange is that the pointers are somewhat close:
> getPointerToFunction returns 0x47829a0, but my instrumentation gets
> 0x477fc10.
This should basically work. You'll have to walk through the various
code that populates the maps. It could be that the start of the
function is actually a constant pool or jump table or something, not
the first instruction of the function.
-Chris
More information about the llvm-dev
mailing list