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