[LLVMdev] Instrumenting virtual function calls
Robert Zeh
robert.a.zeh at gmail.com
Tue Feb 12 17:08:27 PST 2008
After hacking away at it for a bit, it looks like the mystery function
is actually a stub function. The function pointer is coming from a
vtable, which gets filled in with pointers to stub functions.
Is there any way to do the round trip for a stub function? Two
possible solutions come to mind:
1) Modify getGlobalValueAtAddress to work for pointers to stub
functions
2) Add a getStubAtAddress
Any other suggestions?
Robert
On Feb 10, 2008, at 3:41 PM, Chris Lattner wrote:
>
> 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
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
More information about the llvm-dev
mailing list