<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">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.<div><br class="webkit-block-placeholder"></div><div>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.</div><div><br class="webkit-block-placeholder"></div><div>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.</div><div><br class="webkit-block-placeholder"></div><div>What am I missing?<br><div><div><br></div><div>Lines starting with "!" are the instrumented lines.</div><div><br class="webkit-block-placeholder"></div><div><div>define double @Return() {</div><div>entry:</div><div><span class="Apple-tab-span" style="white-space: pre; "> </span>%this = load %"struct.Q::BinaryOperation<bool,bool,bool,Q::AddOperator>"** @q_constant2<span class="Apple-tab-span" style="white-space: pre; "> </span>; <%"struct.Q::BinaryOperation<bool,bool,bool,Q::AddOperator>"*> [#uses=2]</div><div><span class="Apple-tab-span" style="white-space: pre; "> </span>%tmp9.i = getelementptr %"struct.Q::BinaryOperation<bool,bool,bool,Q::AddOperator>"* %this, i32 0, i32 2, i32 0<span class="Apple-tab-span" style="white-space: pre; "> </span>; <%"struct.Q::Function"**> [#uses=1]</div><div><span class="Apple-tab-span" style="white-space: pre; "> </span>%tmp10.i = load %"struct.Q::Function"** %tmp9.i, align 4<span class="Apple-tab-span" style="white-space: pre; "> </span>; <%"struct.Q::Function"*> [#uses=2]</div><div><span class="Apple-tab-span" style="white-space: pre; "> </span>%tmp17.i = getelementptr %"struct.Q::BinaryOperation<bool,bool,bool,Q::AddOperator>"* %this, i32 0, i32 1, i32 0<span class="Apple-tab-span" style="white-space: pre; "> </span>; <%"struct.Q::Function"**> [#uses=1]</div><div><span class="Apple-tab-span" style="white-space: pre; "> </span>%tmp18.i = load %"struct.Q::Function"** %tmp17.i, align 4<span class="Apple-tab-span" style="white-space: pre; "> </span>; <%"struct.Q::Function"*> [#uses=2]</div><div><span class="Apple-tab-span" style="white-space: pre; "> </span>%tmp33.i = getelementptr %"struct.Q::Function"* %tmp18.i, i32 0, i32 0, i32 0, i32 0, i32 0<span class="Apple-tab-span" style="white-space: pre; "> </span>; <i32 (...)***> [#uses=1]</div><div><span class="Apple-tab-span" style="white-space: pre; "> </span>%tmp34.i = load i32 (...)*** %tmp33.i, align 4<span class="Apple-tab-span" style="white-space: pre; "> </span>; <i32 (...)**> [#uses=1]</div><div><span class="Apple-tab-span" style="white-space: pre; "> </span>%tmp35.i = getelementptr i32 (...)** %tmp34.i, i32 9<span class="Apple-tab-span" style="white-space: pre; "> </span>; <i32 (...)**> [#uses=1]</div><div><span class="Apple-tab-span" style="white-space: pre; "> </span>%tmp36.i = load i32 (...)** %tmp35.i, align 4<span class="Apple-tab-span" style="white-space: pre; "> </span>; <i32 (...)*> [#uses=1]</div><div><span class="Apple-tab-span" style="white-space: pre; "> </span>%tmp3637.i = bitcast i32 (...)* %tmp36.i to double (%"struct.Q::Function"*)*<span class="Apple-tab-span" style="white-space: pre; "> </span>; <double (%"struct.Q::Function"*)*> [#uses=2]</div><div><span class="Apple-tab-span" style="white-space: pre; "> </span>%tmp39.i = call double %tmp3637.i( %"struct.Q::Function"* %tmp18.i )<span class="Apple-tab-span" style="white-space: pre; "> </span>; <double> [#uses=1]</div><div><span class="Apple-tab-span" style="white-space: pre; "><b>! </b></span><b>bitcast double (%"struct.Q::Function"*)* %tmp3637.i to i8*</b><span class="Apple-tab-span" style="white-space: pre; "><b> </b></span><b>; <i8*>:0 [#uses=1]</b></div><div><span class="Apple-tab-span" style="white-space: pre; "><b>! </b></span><b>call void @registerMethod( i64 73846672, i8* %0 )</b></div><div><span class="Apple-tab-span" style="white-space: pre; "> </span>%tmp49.i = getelementptr %"struct.Q::Function"* %tmp10.i, i32 0, i32 0, i32 0, i32 0, i32 0<span class="Apple-tab-span" style="white-space: pre; "> </span>; <i32 (...)***> [#uses=1]</div><div><span class="Apple-tab-span" style="white-space: pre; "> </span>%tmp50.i = load i32 (...)*** %tmp49.i, align 4<span class="Apple-tab-span" style="white-space: pre; "> </span>; <i32 (...)**> [#uses=1]</div><div><span class="Apple-tab-span" style="white-space: pre; "> </span>%tmp51.i = getelementptr i32 (...)** %tmp50.i, i32 9<span class="Apple-tab-span" style="white-space: pre; "> </span>; <i32 (...)**> [#uses=1]</div><div><span class="Apple-tab-span" style="white-space: pre; "> </span>%tmp52.i = load i32 (...)** %tmp51.i, align 4<span class="Apple-tab-span" style="white-space: pre; "> </span>; <i32 (...)*> [#uses=1]</div><div><span class="Apple-tab-span" style="white-space: pre; "> </span>%tmp5253.i = bitcast i32 (...)* %tmp52.i to i32 (%"struct.Q::Function"*)*<span class="Apple-tab-span" style="white-space: pre; "> </span>; <i32 (%"struct.Q::Function"*)*> [#uses=2]</div><div><span class="Apple-tab-span" style="white-space: pre; "> </span>%tmp55.i = call i32 %tmp5253.i( %"struct.Q::Function"* %tmp10.i )<span class="Apple-tab-span" style="white-space: pre; "> </span>; <i32> [#uses=1]</div><div><span class="Apple-tab-span" style="white-space: pre; "><b>! </b></span><b>bitcast i32 (%"struct.Q::Function"*)* %tmp5253.i to i8*</b><span class="Apple-tab-span" style="white-space: pre; "><b> </b></span><b>; <i8*>:1 [#uses=1]</b></div><div><span class="Apple-tab-span" style="white-space: pre; "><b>! </b></span><b>call void @registerMethod( i64 73865808, i8* %1 )</b></div><div><span class="Apple-tab-span" style="white-space: pre; "> </span>%tmp5859.i = sitofp i32 %tmp55.i to double<span class="Apple-tab-span" style="white-space: pre; "> </span>; <double> [#uses=1]</div><div><span class="Apple-tab-span" style="white-space: pre; "> </span>%tmp61.i = add double %tmp39.i, %tmp5859.i<span class="Apple-tab-span" style="white-space: pre; "> </span>; <double> [#uses=1]</div><div><span class="Apple-tab-span" style="white-space: pre; "> </span>ret double %tmp61.i</div><div>}</div><div><br></div><div>Robert</div></div></div></div></body></html>