Skip to contentSkip to conversation

Counting Instructions and Looking for Conditional Branches

Qemu-devel Shane Brennan 2 participants 2 messages Feb 18, 2007 – Feb 19, 2007

lore
Share & tools
lore
#0 lore raw

I am wondering if anyone knows where in the QEMU source code I can create a counter to count the number of executed instructions? In addition, where I can place an IF statement to see if a conditional branch instruction is about to execute.

I need to do this to create a basic block vector for SimPoint. I have found that the function cpu-exec in cpu-exec.c is probably going to be involved, but I would appreciate any help in narrowing things down. Basically, all I need to do is at every instruction I increase a counter. Then, I see if that instruction is a conditional branch. If it is, I print some characters to a file, and reset the counter. I would greatly appreciate any help.

~Shane

#1 lore raw

RE: [Qemu-devel] Counting Instructions and Looking for ConditionalBranches

Hello Shane.

I have successfully added instruction counters to QEMU with a low run-time overhead. I cannot give you the code but I can tell you how I did it.

1: Make sure that QEMU knows which block is the current_tb. What I did was to update the goto_tb block to update the current_tb pointer.
2: Add an epilogue to the basic blocks that uses the current_tb pointer and increase the instruction counter with the information stored in the current_tb. In my test system it was a one to one mapping with the size of the TB.

The files you will need to update are: exec.c and translate.c together with op.c for your target. Maybe more..

/Regards
Torbjörn Andersson
________________________________

From: qemu-devel-bounces+torbjorn.k.andersson=tietoenator.com@nongnu.org [mailto:qemu-devel-bounces+torbjorn.k.andersson=tietoenator.com@nongnu.org] On Behalf Of Shane Brennan
Sent: den 18 februari 2007 03:08
To: [email protected]
Subject: [Qemu-devel] Counting Instructions and Looking for ConditionalBranches

I am wondering if anyone knows where in the QEMU source code I can create a counter to count the number of executed instructions? In addition, where I can place an IF statement to see if a conditional branch instruction is about to execute.

I need to do this to create a basic block vector for SimPoint. I have found that the function cpu-exec in cpu-exec.c is probably going to be involved, but I would appreciate any help in narrowing things down. Basically, all I need to do is at every instruction I increase a counter. Then, I see if that instruction is a conditional branch. If it is, I print some characters to a file, and reset the counter. I would greatly appreciate any help.

~Shane