cb589a
commit be7a73004583aab5d4c97cf55276ca58d5b3090b
cb589a
Author: Mark Wielaard <mark@klomp.org>
cb589a
Date:   Wed Dec 12 14:15:28 2018 +0100
cb589a
cb589a
    Mark helper regs defined in final_tidyup before freeres_wrapper call.
cb589a
    
cb589a
    In final_tidyup we setup the guest to call the freeres_wrapper, which
cb589a
    will (possibly) call __gnu_cxx::__freeres() and/or __libc_freeres().
cb589a
    
cb589a
    In a couple of cases (ppc64be, ppc64le and mips32) this involves setting
cb589a
    up one or more helper registers. Since we setup these guest registers
cb589a
    we should make sure to mark them as fully defined. Otherwise we might
cb589a
    see spurious warnings about undefined value usage if the guest register
cb589a
    happened to not be fully defined before.
cb589a
    
cb589a
    This fixes PR402006.
cb589a
cb589a
diff --git a/coregrind/m_main.c b/coregrind/m_main.c
cb589a
index 00702fc..22872a2 100644
cb589a
--- a/coregrind/m_main.c
cb589a
+++ b/coregrind/m_main.c
cb589a
@@ -2304,22 +2304,35 @@ static void final_tidyup(ThreadId tid)
cb589a
                    "Caught __NR_exit; running %s wrapper\n", msgs[to_run - 1]);
cb589a
    }
cb589a
       
cb589a
-   /* set thread context to point to freeres_wrapper */
cb589a
-   /* ppc64be-linux note: freeres_wrapper gives us the real
cb589a
+   /* Set thread context to point to freeres_wrapper.
cb589a
+      ppc64be-linux note: freeres_wrapper gives us the real
cb589a
       function entry point, not a fn descriptor, so can use it
cb589a
       directly.  However, we need to set R2 (the toc pointer)
cb589a
       appropriately. */
cb589a
    VG_(set_IP)(tid, freeres_wrapper);
cb589a
+
cb589a
 #  if defined(VGP_ppc64be_linux)
cb589a
    VG_(threads)[tid].arch.vex.guest_GPR2 = r2;
cb589a
+   VG_TRACK(post_reg_write, Vg_CoreClientReq, tid,
cb589a
+            offsetof(VexGuestPPC64State, guest_GPR2),
cb589a
+            sizeof(VG_(threads)[tid].arch.vex.guest_GPR2));
cb589a
 #  elif  defined(VGP_ppc64le_linux)
cb589a
    /* setting GPR2 but not really needed, GPR12 is needed */
cb589a
    VG_(threads)[tid].arch.vex.guest_GPR2  = freeres_wrapper;
cb589a
+   VG_TRACK(post_reg_write, Vg_CoreClientReq, tid,
cb589a
+            offsetof(VexGuestPPC64State, guest_GPR2),
cb589a
+            sizeof(VG_(threads)[tid].arch.vex.guest_GPR2));
cb589a
    VG_(threads)[tid].arch.vex.guest_GPR12 = freeres_wrapper;
cb589a
+   VG_TRACK(post_reg_write, Vg_CoreClientReq, tid,
cb589a
+            offsetof(VexGuestPPC64State, guest_GPR12),
cb589a
+            sizeof(VG_(threads)[tid].arch.vex.guest_GPR12));
cb589a
 #  endif
cb589a
    /* mips-linux note: we need to set t9 */
cb589a
 #  if defined(VGP_mips32_linux) || defined(VGP_mips64_linux)
cb589a
    VG_(threads)[tid].arch.vex.guest_r25 = freeres_wrapper;
cb589a
+   VG_TRACK(post_reg_write, Vg_CoreClientReq, tid,
cb589a
+            offsetof(VexGuestMIPS32State, guest_r25),
cb589a
+            sizeof(VG_(threads)[tid].arch.vex.guest_r25));
cb589a
 #  endif
cb589a
 
cb589a
    /* Pass a parameter to freeres_wrapper(). */