<div dir="ltr"><div dir="ltr">Hi Felix,<div><br></div><div>I think this may be related to this issue:</div><div><br></div><div><a href="https://github.com/panda-re/panda/issues/315">https://github.com/panda-re/panda/issues/315</a><br></div><div><br></div><div>Basically, during replay QEMU periodically pops out of execution to check for pending input to the monitor, gdb stub, etc. Unfortunately, this can happen after the basic block callback has fired (but before any code in a basic block has executed), which could lead to a block callback executing twice.</div><div><br></div><div>One solution to the basic block callback issue might be to inline the callback into the generated TCG and ensure that it only happens *after* the check of exit_request at the start of the block.</div><div><br></div><div>-Brendan</div></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Nov 15, 2018 at 9:38 AM Felix Eberstaller &lt;<a href="mailto:felix.eberstaller@students.fh-hagenberg.at">felix.eberstaller@students.fh-hagenberg.at</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi :),<br>
<br>
First of all, thank you for the great work on panda. It is truly amazing!<br>
<br>
The problem:<br>
It seems that the callback PANDA_CB_BEFORE_BLOCK_EXEC or<br>
PANDA_CB_AFTER_BLOCK_EXEC sometimes is being called too often during<br>
replay ?<br>
Running the same replay and printing out the blocks (pc) leads to<br>
different traces (see appendix).<br>
The variation between the traces is minimal and this has been tested<br>
with the current docker image and r-18-06.<br>
Is this a problem with my setup and is this the recommended way to track<br>
basic block execution during replay ?<br>
<br>
Best,<br>
Felix Eberstaller<br>
<br>
Appendix:<br>
<br>
Bash snippet:<br>
<br>
for i in {1..10}; do /panda/build/i386-softmmu/qemu-system-i386 -m 256 <br>
-replay ii_01  -panda dumper  | grep &quot;PC &gt;&gt;&quot; &gt; /tmp/log$i; done ; md5sum<br>
/tmp/log*<br>
<br>
Initializing plugin dumper<br>
Initializing plugin dumper<br>
Initializing plugin dumper<br>
Initializing plugin dumper<br>
Initializing plugin dumper<br>
Initializing plugin dumper<br>
Initializing plugin dumper<br>
Initializing plugin dumper<br>
Initializing plugin dumper<br>
Initializing plugin dumper<br>
2c0c8bd2c3ebe82bbc657f78905ac60a  /tmp/log1<br>
b1cfdd0d7ca41c669d765ed12452b276  /tmp/log10<br>
2c0c8bd2c3ebe82bbc657f78905ac60a  /tmp/log2<br>
4217cd4699f4322c40b873213f84a518  /tmp/log3<br>
3d619029a54bd5a9507bbf876ee6d809  /tmp/log4<br>
ee27f65e1ca86cce4e3d792cb78c0a20  /tmp/log5<br>
4217cd4699f4322c40b873213f84a518  /tmp/log6<br>
2c0c8bd2c3ebe82bbc657f78905ac60a  /tmp/log7<br>
4217cd4699f4322c40b873213f84a518  /tmp/log8<br>
3db131b965c8445d4c91aade227af439  /tmp/log9<br>
<br>
<br>
Diff between two traces:<br>
diff log1 log10<br>
22336a22337<br>
&gt; PC &gt;&gt; c116b903<br>
22339d22339<br>
&lt; PC &gt;&gt; c116b870<br>
70987d70986<br>
&lt; PC &gt;&gt; c12cfadc<br>
<br>
diff log6 log9<br>
70987a70988<br>
&gt; PC &gt;&gt; c12cfadc<br>
<br>
<br>
Code for dumper:<br>
<br>
#define __STDC_FORMAT_MACROS<br>
#include &quot;panda/plugin.h&quot;<br>
extern &quot;C&quot; {<br>
bool init_plugin(void *);<br>
void uninit_plugin(void *);<br>
}<br>
<br>
int before_block(CPUState* env, TranslationBlock* tb){<br>
    printf(&quot;PC &gt;&gt; &quot; TARGET_FMT_lx &quot;\n&quot;, tb-&gt;pc);<br>
    return 0x1;<br>
}<br>
<br>
bool init_plugin(void *self) {<br>
    panda_cb pcb;<br>
    pcb.before_block_exec = before_block;<br>
    panda_register_callback(self, PANDA_CB_BEFORE_BLOCK_EXEC, pcb);<br>
    return true;<br>
}<br>
<br>
void uninit_plugin(void *self) { }<br>
<br>
<br>
_______________________________________________<br>
panda-users mailing list<br>
<a href="mailto:panda-users@mit.edu" target="_blank">panda-users@mit.edu</a><br>
<a href="http://mailman.mit.edu/mailman/listinfo/panda-users" rel="noreferrer" target="_blank">http://mailman.mit.edu/mailman/listinfo/panda-users</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">Brendan Dolan-Gavitt<br>Assistant Professor, Department of Computer Science and Engineering<br>NYU Tandon School of Engineering</div>