From 694f67a7addeb147aed156c9e366f6bb15f8b02c Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Thu, 21 Jul 2022 15:36:29 +0100 Subject: [PATCH] linux-user: Print debug info for timer_create and timer_delete Temporary debug printing to show host and guest timer ID handling in timer_create and timer_delete syscalls. Signed-off-by: Peter Maydell --- linux-user/syscall.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 991b85e6b4d..cc4b6270429 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -506,9 +506,11 @@ static inline int next_free_host_timer(void) for (k = 0; k < ARRAY_SIZE(g_posix_timers); k++) { if (g_posix_timers[k] == 0) { g_posix_timers[k] = (timer_t) 1; + printf("next_free_host_timer: returning %d\n", k); return k; } } + printf("next_free_host_timer: all timers allocated, returning -1\n"); return -1; } #endif @@ -8312,6 +8314,8 @@ static target_timer_t get_timer_id(abi_long arg) return -TARGET_EINVAL; } + printf("get_timer_id: guest timer id 0x%x -> index %d\n", + (target_timer_t)arg, timerid); return timerid; } @@ -12837,12 +12841,18 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, } ret = get_errno(timer_create(clkid, phost_sevp, phtimer)); + printf("timer_create: host timer_create: returned 0x" + TARGET_ABI_FMT_lx ", set phtimer %p to %p\n", + ret, phtimer, *phtimer); if (ret) { phtimer = NULL; } else { if (put_user(TIMER_MAGIC | timer_index, arg3, target_timer_t)) { return -TARGET_EFAULT; } + printf("timer_create: wrote 0x%x to guest address 0x" + TARGET_ABI_FMT_lx "\n", + (TIMER_MAGIC | timer_index), arg3); } } return ret; @@ -12975,6 +12985,8 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, ret = timerid; } else { timer_t htimer = g_posix_timers[timerid]; + printf("timer_delete: guest arg 0x" TARGET_ABI_FMT_lx + " host timer_t %p: deleting\n", arg1, htimer); ret = get_errno(timer_delete(htimer)); g_posix_timers[timerid] = 0; } -- 2.25.1