@@ -76,6 +76,8 @@ typedef struct {
76
76
77
77
/* We use this to track the current execution state */
78
78
typedef struct {
79
+ /* address of current translated block */
80
+ uint64_t tb_pc ;
79
81
/* address of end of block */
80
82
uint64_t end_block ;
81
83
/* next pc after end of block */
@@ -85,6 +87,7 @@ typedef struct {
85
87
} VCPUScoreBoard ;
86
88
87
89
/* descriptors for accessing the above scoreboard */
90
+ static qemu_plugin_u64 tb_pc ;
88
91
static qemu_plugin_u64 end_block ;
89
92
static qemu_plugin_u64 pc_after_block ;
90
93
static qemu_plugin_u64 last_pc ;
@@ -189,10 +192,11 @@ static void plugin_exit(qemu_plugin_id_t id, void *p)
189
192
static void plugin_init (void )
190
193
{
191
194
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 );
193
196
state = qemu_plugin_scoreboard_new (sizeof (VCPUScoreBoard ));
194
197
195
198
/* score board declarations */
199
+ tb_pc = qemu_plugin_scoreboard_u64_in_struct (state , VCPUScoreBoard , tb_pc );
196
200
end_block = qemu_plugin_scoreboard_u64_in_struct (state , VCPUScoreBoard ,
197
201
end_block );
198
202
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)
215
219
NodeData * node = NULL ;
216
220
217
221
g_mutex_lock (& node_lock );
218
- node = (NodeData * ) g_hash_table_lookup (nodes , ( gconstpointer ) addr );
222
+ node = (NodeData * ) g_hash_table_lookup (nodes , & addr );
219
223
if (!node && create_if_not_found ) {
220
224
node = create_node (addr );
221
- g_hash_table_insert (nodes , ( gpointer ) addr , ( gpointer ) node );
225
+ g_hash_table_insert (nodes , & node -> addr , node );
222
226
}
223
227
g_mutex_unlock (& node_lock );
224
228
return node ;
@@ -234,7 +238,7 @@ static void vcpu_tb_branched_exec(unsigned int cpu_index, void *udata)
234
238
uint64_t lpc = qemu_plugin_u64_get (last_pc , cpu_index );
235
239
uint64_t ebpc = qemu_plugin_u64_get (end_block , cpu_index );
236
240
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 );
238
242
239
243
/* return early for address 0 */
240
244
if (!lpc ) {
@@ -305,10 +309,11 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
305
309
* handle both early block exits and normal branches in the
306
310
* callback if we hit it.
307
311
*/
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 );
309
314
qemu_plugin_register_vcpu_tb_exec_cond_cb (
310
315
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 );
312
317
313
318
/*
314
319
* Now we can set start/end for this block so the next block can
0 commit comments