]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Make the leak tests a whole lot less flaky on ppc32/64-linux by
authorJulian Seward <jseward@acm.org>
Fri, 3 Sep 2010 15:14:41 +0000 (15:14 +0000)
committerJulian Seward <jseward@acm.org>
Fri, 3 Sep 2010 15:14:41 +0000 (15:14 +0000)
zeroing out caller saves registers before the leak check.  We should
really do this on all platforms, not just these.
(Maynard Johnson, maynardj@us.ibm.com)

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11336

memcheck/tests/leak-cases.c
memcheck/tests/leak-cycle.c
memcheck/tests/leak.h

index e6a010a16363dad09135b7c071854e9fd8214f80..026e7d2f4287800ef4fe2cec57718fd7dff9dccf 100644 (file)
@@ -106,6 +106,7 @@ int main(void)
    // counting in main() avoids the problem.
    f();
 
+   CLEAR_CALLER_SAVED_REGS;
    GET_FINAL_LEAK_COUNTS;
 
    PRINT_LEAK_COUNTS(stderr);
index 76dae77d5293554704db9c3459c6922d7059b48c..cee967b32278fe902499ade7bfbc4ea141ea42d6 100644 (file)
@@ -68,6 +68,8 @@ int main()
 
        c1 = c2 = 0;
 
+       CLEAR_CALLER_SAVED_REGS;
+
        GET_FINAL_LEAK_COUNTS;
 
        PRINT_LEAK_COUNTS(stderr);
index ec94fe05cf774d9e7a990bdb147631e5605e75da..ac8a64cf08d3b84ac1a18740a5a3cae59ee33536 100644 (file)
                      S_bytes,S_blocks); \
    } while (0)
 
+/* Upon a call to a function, some architectures store pointers into
+ * into registers.  Valgrind may consider these registers when determining
+ * whether an address is reachable, so we need to zero-out these registers
+ * as needed.
+ */
+#if defined __powerpc__
+#define CLEAR_CALLER_SAVED_REGS \
+  do { \
+   __asm__ __volatile__( "li 3, 0" : : :/*trash*/"r3" ); \
+   __asm__ __volatile__( "li 4, 0" : : :/*trash*/"r4" ); \
+   __asm__ __volatile__( "li 5, 0" : : :/*trash*/"r5" ); \
+   __asm__ __volatile__( "li 6, 0" : : :/*trash*/"r6" ); \
+   __asm__ __volatile__( "li 7, 0" : : :/*trash*/"r7" ); \
+   __asm__ __volatile__( "li 8, 0" : : :/*trash*/"r8" ); \
+   __asm__ __volatile__( "li 9, 0" : : :/*trash*/"r9" ); \
+   __asm__ __volatile__( "li 10, 0" : : :/*trash*/"r10" ); \
+   __asm__ __volatile__( "li 11, 0" : : :/*trash*/"r11" ); \
+   __asm__ __volatile__( "li 12, 0" : : :/*trash*/"r12" ); \
+  } while (0)
+#else
+#define CLEAR_CALLER_SAVED_REGS  /*nothing*/
+#endif
+
+