Skip to content

Commit a5555b2

Browse files
pbo-linarostsquad
authored andcommitted
contrib/plugins/cflow: fix 32-bit build
Reviewed-by: Richard Henderson <[email protected]> Signed-off-by: Pierrick Bouvier <[email protected]> Message-Id: <[email protected]> Signed-off-by: Alex Bennée <[email protected]> Message-Id: <[email protected]>
1 parent 2fb2aa0 commit a5555b2

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

contrib/plugins/cflow.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ typedef struct {
7676

7777
/* We use this to track the current execution state */
7878
typedef struct {
79+
/* address of current translated block */
80+
uint64_t tb_pc;
7981
/* address of end of block */
8082
uint64_t end_block;
8183
/* next pc after end of block */
@@ -85,6 +87,7 @@ typedef struct {
8587
} VCPUScoreBoard;
8688

8789
/* descriptors for accessing the above scoreboard */
90+
static qemu_plugin_u64 tb_pc;
8891
static qemu_plugin_u64 end_block;
8992
static qemu_plugin_u64 pc_after_block;
9093
static qemu_plugin_u64 last_pc;
@@ -189,10 +192,11 @@ static void plugin_exit(qemu_plugin_id_t id, void *p)
189192
static void plugin_init(void)
190193
{
191194
g_mutex_init(&node_lock);
192-
nodes = g_hash_table_new(NULL, g_direct_equal);
195+
nodes = g_hash_table_new(g_int64_hash, g_int64_equal);
193196
state = qemu_plugin_scoreboard_new(sizeof(VCPUScoreBoard));
194197

195198
/* score board declarations */
199+
tb_pc = qemu_plugin_scoreboard_u64_in_struct(state, VCPUScoreBoard, tb_pc);
196200
end_block = qemu_plugin_scoreboard_u64_in_struct(state, VCPUScoreBoard,
197201
end_block);
198202
pc_after_block = qemu_plugin_scoreboard_u64_in_struct(state, VCPUScoreBoard,
@@ -215,10 +219,10 @@ static NodeData *fetch_node(uint64_t addr, bool create_if_not_found)
215219
NodeData *node = NULL;
216220

217221
g_mutex_lock(&node_lock);
218-
node = (NodeData *) g_hash_table_lookup(nodes, (gconstpointer) addr);
222+
node = (NodeData *) g_hash_table_lookup(nodes, &addr);
219223
if (!node && create_if_not_found) {
220224
node = create_node(addr);
221-
g_hash_table_insert(nodes, (gpointer) addr, (gpointer) node);
225+
g_hash_table_insert(nodes, &node->addr, node);
222226
}
223227
g_mutex_unlock(&node_lock);
224228
return node;
@@ -234,7 +238,7 @@ static void vcpu_tb_branched_exec(unsigned int cpu_index, void *udata)
234238
uint64_t lpc = qemu_plugin_u64_get(last_pc, cpu_index);
235239
uint64_t ebpc = qemu_plugin_u64_get(end_block, cpu_index);
236240
uint64_t npc = qemu_plugin_u64_get(pc_after_block, cpu_index);
237-
uint64_t pc = GPOINTER_TO_UINT(udata);
241+
uint64_t pc = qemu_plugin_u64_get(tb_pc, cpu_index);
238242

239243
/* return early for address 0 */
240244
if (!lpc) {
@@ -305,10 +309,11 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
305309
* handle both early block exits and normal branches in the
306310
* callback if we hit it.
307311
*/
308-
gpointer udata = GUINT_TO_POINTER(pc);
312+
qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu(
313+
tb, QEMU_PLUGIN_INLINE_STORE_U64, tb_pc, pc);
309314
qemu_plugin_register_vcpu_tb_exec_cond_cb(
310315
tb, vcpu_tb_branched_exec, QEMU_PLUGIN_CB_NO_REGS,
311-
QEMU_PLUGIN_COND_NE, pc_after_block, pc, udata);
316+
QEMU_PLUGIN_COND_NE, pc_after_block, pc, NULL);
312317

313318
/*
314319
* Now we can set start/end for this block so the next block can

0 commit comments

Comments
 (0)