On 12/17/24 16:43, Pierrick Bouvier wrote:
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
> contrib/plugins/cache.c | 18 ++++++------------
> 1 file changed, 6 insertions(+), 12 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
>
> diff --git a/contrib/plugins/cache.c b/contrib/plugins/cache.c
> index 512ef6776b7..7baff868609 100644
> --- a/contrib/plugins/cache.c
> +++ b/contrib/plugins/cache.c
> @@ -208,7 +208,7 @@ static int fifo_get_first_block(Cache *cache, int set)
> static void fifo_update_on_miss(Cache *cache, int set, int blk_idx)
> {
> GQueue *q = cache->sets[set].fifo_queue;
> - g_queue_push_head(q, GINT_TO_POINTER(blk_idx));
> + g_queue_push_head(q, (gpointer)(intptr_t) blk_idx);
> }
>
> static void fifo_destroy(Cache *cache)
> @@ -471,13 +471,8 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
> n_insns = qemu_plugin_tb_n_insns(tb);
> for (i = 0; i < n_insns; i++) {
> struct qemu_plugin_insn *insn = qemu_plugin_tb_get_insn(tb, i);
> - uint64_t effective_addr;
> -
> - if (sys) {
> - effective_addr = (uint64_t) qemu_plugin_insn_haddr(insn);
> - } else {
> - effective_addr = (uint64_t) qemu_plugin_insn_vaddr(insn);
> - }
> + uint64_t effective_addr = sys ? (uintptr_t) qemu_plugin_insn_haddr(insn) :
> + qemu_plugin_insn_vaddr(insn);
>
> /*
> * Instructions might get translated multiple times, we do not create
> @@ -485,14 +480,13 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
> * entry from the hash table and register it for the callback again.
> */
> g_mutex_lock(&hashtable_lock);
> - data = g_hash_table_lookup(miss_ht, GUINT_TO_POINTER(effective_addr));
> + data = g_hash_table_lookup(miss_ht, &effective_addr);
> if (data == NULL) {
> data = g_new0(InsnData, 1);
> data->disas_str = qemu_plugin_insn_disas(insn);
> data->symbol = qemu_plugin_insn_symbol(insn);
> data->addr = effective_addr;
> - g_hash_table_insert(miss_ht, GUINT_TO_POINTER(effective_addr),
> - (gpointer) data);
> + g_hash_table_insert(miss_ht, &data->addr, data);
> }
> g_mutex_unlock(&hashtable_lock);
>
> @@ -853,7 +847,7 @@ int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info,
> qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans);
> qemu_plugin_register_atexit_cb(id, plugin_exit, NULL);
>
> - miss_ht = g_hash_table_new_full(NULL, g_direct_equal, NULL, insn_free);
> + miss_ht = g_hash_table_new_full(g_int64_hash, g_int64_equal, NULL, insn_free);
>
> return 0;
> }