<html><head/><body><html><head></head><body>I think that would work in the majority of cases.  But consider the case where an instrumented-ABI function A calls a native-ABI function B which then calls an instrumented-ABI function C once.  C would then test and reset the flag making it appear from A's perspective that B was instrumented-ABI.<br>
<br>
Perhaps it would be better to store the expected callee function pointer in the thread local variable instead of 1, and have the callee check for its own pointer.<br><br><div class="gmail_quote">Kostya Serebryany <kcc@google.com> wrote:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre style="white-space: pre-wrap; word-wrap:break-word; font-family: sans-serif; margin-top: 0px"><br />LGTM<br /><br />An idea for run-time checks. There are two failure modes:<br />1. Calling a native-ABI function as if instrumented-ABI<br />2. Calling a instrumented-ABI function as if native-ABI<br /><br />We can have a thread-local integer is_instrumented_abi_call, which is zero almost all the time.<br />Before instrumented-ABI call we increment it.<br />In instrumented-ABI function we check that it's 1 (otherwise trap) and set it to 0.<br />After instrumented-ABI call we check that it's 0 (otherwise trap).<br /><br />This will catch both failure modes.<br /><br /><a href="http://llvm-reviews.chandlerc.com/D1443">http://llvm-reviews.chandlerc.com/D1443</a><br /><br />ARCANIST PROJECT<br />clang<br /><br /></pre></blockquote></div><br>
-- <br>
Sent from my Android phone with K-9 Mail. Please excuse my brevity.</body></html></body></html>