From: Julian Seward Date: Fri, 3 Sep 2010 15:14:41 +0000 (+0000) Subject: Make the leak tests a whole lot less flaky on ppc32/64-linux by X-Git-Tag: svn/VALGRIND_3_6_0~121 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a96d8cb71585e7b66050a4749ad96a35a83e313c;p=thirdparty%2Fvalgrind.git Make the leak tests a whole lot less flaky on ppc32/64-linux by 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 --- diff --git a/memcheck/tests/leak-cases.c b/memcheck/tests/leak-cases.c index e6a010a163..026e7d2f42 100644 --- a/memcheck/tests/leak-cases.c +++ b/memcheck/tests/leak-cases.c @@ -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); diff --git a/memcheck/tests/leak-cycle.c b/memcheck/tests/leak-cycle.c index 76dae77d52..cee967b322 100644 --- a/memcheck/tests/leak-cycle.c +++ b/memcheck/tests/leak-cycle.c @@ -68,6 +68,8 @@ int main() c1 = c2 = 0; + CLEAR_CALLER_SAVED_REGS; + GET_FINAL_LEAK_COUNTS; PRINT_LEAK_COUNTS(stderr); diff --git a/memcheck/tests/leak.h b/memcheck/tests/leak.h index ec94fe05cf..ac8a64cf08 100644 --- a/memcheck/tests/leak.h +++ b/memcheck/tests/leak.h @@ -41,3 +41,27 @@ 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 + +