|
From: Paul F. <pa...@so...> - 2026-02-27 20:29:03
|
https://sourceware.org/cgit/valgrind/commit/?id=9529ce722eea10a32cbeefe1bafc8745b565f8fa commit 9529ce722eea10a32cbeefe1bafc8745b565f8fa Author: Paul Floyd <pj...@wa...> Date: Fri Feb 27 21:26:23 2026 +0100 Clean up setting carry flag in VG_(fixup_guest_state_after_syscall_interrupted) This wasn't consistent (not at all for Darwin, not checking SfNoWriteResult on Solaris and a bit long winded on FreeBSD). Simplify the code for all 3 platforms. Diff: --- coregrind/m_syswrap/syswrap-main.c | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/coregrind/m_syswrap/syswrap-main.c b/coregrind/m_syswrap/syswrap-main.c index 07f1930469..763833c526 100644 --- a/coregrind/m_syswrap/syswrap-main.c +++ b/coregrind/m_syswrap/syswrap-main.c @@ -3407,40 +3407,24 @@ VG_(fixup_guest_state_after_syscall_interrupted)( ThreadId tid, we expect our caller (the signal handler) will have fixed this up. */ /* XXX: needed? */ -#if defined(VGP_x86_freebsd) - /* On FreeBSD, the success/fail status is returned to the caller - and still has to be fixed up here. */ +#if defined(VGP_x86_freebsd) || defined(VGP_x86_solaris) || defined(VGP_x86_darwin) + /* The %eax and %edx values are committed but the carry flag is still + uncommitted. Save it now. */ if (!(sci->flags & SfNoWriteResult)) { - if (sr_isError(sres)) - LibVEX_GuestX86_put_eflag_c(1, &th_regs->vex); - else - LibVEX_GuestX86_put_eflag_c(0, &th_regs->vex); + LibVEX_GuestX86_put_eflag_c(sr_isError(sres), &th_regs->vex); } -#elif defined(VGP_amd64_freebsd) +#elif defined(VGP_amd64_freebsd) || defined(VGP_amd64_solaris) || defined(VGP_amd64_darwin) if (!(sci->flags & SfNoWriteResult)) { - if (sr_isError(sres)) - LibVEX_GuestAMD64_put_rflag_c(1, &th_regs->vex); - else - LibVEX_GuestAMD64_put_rflag_c(0, &th_regs->vex); + LibVEX_GuestAMD64_put_rflag_c(sr_isError(sres), &th_regs->vex); } #elif defined(VGP_arm64_freebsd) if (!(sci->flags & SfNoWriteResult)) { - if (sr_isError(sres)) - LibVEX_GuestARM64_put_nzcv_c(1, &th_regs->vex); - else - LibVEX_GuestARM64_put_nzcv_c(0, &th_regs->vex); + LibVEX_GuestARM64_put_nzcv_c(sr_isError(sres), &th_regs->vex); } #endif if (VG_(clo_trace_signals)) VG_(message)( Vg_DebugMsg, " completed and committed: nothing to do\n"); -# if defined(VGP_x86_solaris) - /* The %eax and %edx values are committed but the carry flag is still - uncommitted. Save it now. */ - LibVEX_GuestX86_put_eflag_c(sr_isError(sres), &th_regs->vex); -# elif defined(VGP_amd64_solaris) - LibVEX_GuestAMD64_put_rflag_c(sr_isError(sres), &th_regs->vex); -# endif getSyscallStatusFromGuestState( &sci->status, &th_regs->vex ); vg_assert(sci->status.what == SsComplete); VG_(post_syscall)(tid); |