Author: sewardj
Date: 2008-02-26 18:36:29 +0000 (Tue, 26 Feb 2008)
New Revision: 7479

Log:
Add some regression tests for the Dwarf3 variable reader.


Added:
   branches/DATASYMS/memcheck/tests/varinfo1.c
   branches/DATASYMS/memcheck/tests/varinfo1.stderr.exp
   branches/DATASYMS/memcheck/tests/varinfo1.stdout.exp
   branches/DATASYMS/memcheck/tests/varinfo1.vgtest
   branches/DATASYMS/memcheck/tests/varinfo2.c
   branches/DATASYMS/memcheck/tests/varinfo2.stderr.exp
   branches/DATASYMS/memcheck/tests/varinfo2.stdout.exp
   branches/DATASYMS/memcheck/tests/varinfo2.vgtest
   branches/DATASYMS/memcheck/tests/varinfo3.c
   branches/DATASYMS/memcheck/tests/varinfo3.stderr.exp
   branches/DATASYMS/memcheck/tests/varinfo3.stdout.exp
   branches/DATASYMS/memcheck/tests/varinfo3.vgtest
   branches/DATASYMS/memcheck/tests/varinfo4.c
   branches/DATASYMS/memcheck/tests/varinfo4.stderr.exp
   branches/DATASYMS/memcheck/tests/varinfo4.stdout.exp
   branches/DATASYMS/memcheck/tests/varinfo4.vgtest
Modified:
   branches/DATASYMS/memcheck/tests/Makefile.am


Modified: branches/DATASYMS/memcheck/tests/Makefile.am
===================================================================
--- branches/DATASYMS/memcheck/tests/Makefile.am        2008-02-26 17:23:54 UTC 
(rev 7478)
+++ branches/DATASYMS/memcheck/tests/Makefile.am        2008-02-26 18:36:29 UTC 
(rev 7479)
@@ -129,6 +129,10 @@
        toobig-allocs.stderr.exp toobig-allocs.vgtest \
        trivialleak.stderr.exp trivialleak.vgtest \
        metadata.stderr.exp metadata.stdout.exp metadata.vgtest \
+       varinfo1.vgtest varinfo1.stdout.exp varinfo1.stderr.exp \
+       varinfo2.vgtest varinfo2.stdout.exp varinfo2.stderr.exp \
+       varinfo3.vgtest varinfo3.stdout.exp varinfo3.stderr.exp \
+       varinfo4.vgtest varinfo4.stdout.exp varinfo4.stderr.exp \
        vcpu_bz2.stdout.exp vcpu_bz2.stderr.exp vcpu_bz2.vgtest \
        vcpu_fbench.stdout.exp vcpu_fbench.stderr.exp vcpu_fbench.vgtest \
        vcpu_fnfns.stdout.exp vcpu_fnfns.stderr.exp vcpu_fnfns.vgtest \
@@ -181,6 +185,7 @@
        supp_unknown supp1 supp2 suppfree \
        trivialleak \
        mismatches new_override metadata \
+       varinfo1 varinfo2 varinfo3 varinfo4 \
        vcpu_bz2 vcpu_fbench vcpu_fnfns \
        xml1 \
        wrap1 wrap2 wrap3 wrap4 wrap5 wrap6 wrap7 wrap7so.so wrap8 \

Added: branches/DATASYMS/memcheck/tests/varinfo1.c
===================================================================
--- branches/DATASYMS/memcheck/tests/varinfo1.c                         (rev 0)
+++ branches/DATASYMS/memcheck/tests/varinfo1.c 2008-02-26 18:36:29 UTC (rev 
7479)
@@ -0,0 +1,53 @@
+
+/* Basic check of variable location identification, in a zero-biased
+   executable. */
+
+/* Relevant compile flags are:
+
+   -Wall -g -I$prefix/include/valgrind
+
+   eg -Wall -g -I`pwd`/Inst/include/valgrind
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include "memcheck/memcheck.h"
+
+/* Cause memcheck to complain about the address "a" and so to print
+   its best guess as to what "a" actually is.  a must be
+   addressible. */
+
+void croak ( void* a )
+{
+  volatile char undef;
+  *(char*)a = undef;
+  VALGRIND_CHECK_MEM_IS_DEFINED(a, 1);
+}
+
+#include <stdio.h>
+
+int global_u1;
+
+int global_i1 = 17;
+
+char global_u2[10];
+
+char global_i2[10] = { 1,2,3,4,5,6,7,8,9,10 };
+
+
+int main ( void )
+{
+  int local;
+  char* onheap = malloc(3);
+  assert(onheap);
+  croak(onheap+1);
+  free(onheap);
+
+  croak( &global_u1 );
+  croak( &global_i1 );
+  croak( &global_u2[3] );
+  croak( &global_i2[7] );
+  croak( &local );
+  return 0;
+}

Added: branches/DATASYMS/memcheck/tests/varinfo1.stderr.exp
===================================================================
--- branches/DATASYMS/memcheck/tests/varinfo1.stderr.exp                        
        (rev 0)
+++ branches/DATASYMS/memcheck/tests/varinfo1.stderr.exp        2008-02-26 
18:36:29 UTC (rev 7479)
@@ -0,0 +1,43 @@
+
+Uninitialised byte(s) found during client check request
+   at 0x........: croak (varinfo1.c:25)
+   by 0x........: main (varinfo1.c:44)
+ Address 0x........ is 1 bytes inside a block of size 3 alloc'd
+   at 0x........: malloc (vg_replace_malloc.c:...)
+   by 0x........: main (varinfo1.c:42)
+
+Uninitialised byte(s) found during client check request
+   at 0x........: croak (varinfo1.c:25)
+   by 0x........: main (varinfo1.c:47)
+ Location 0x........ is 0 bytes inside global var "global_u1"
+ declared at varinfo1.c:30
+
+Uninitialised byte(s) found during client check request
+   at 0x........: croak (varinfo1.c:25)
+   by 0x........: main (varinfo1.c:48)
+ Location 0x........ is 0 bytes inside global var "global_i1"
+ declared at varinfo1.c:32
+
+Uninitialised byte(s) found during client check request
+   at 0x........: croak (varinfo1.c:25)
+   by 0x........: main (varinfo1.c:49)
+ Location 0x........ is 0 bytes inside global_u2[3],
+ a global variable declared at varinfo1.c:34
+
+Uninitialised byte(s) found during client check request
+   at 0x........: croak (varinfo1.c:25)
+   by 0x........: main (varinfo1.c:50)
+ Location 0x........ is 0 bytes inside global_i2[7],
+ a global variable declared at varinfo1.c:36
+
+Uninitialised byte(s) found during client check request
+   at 0x........: croak (varinfo1.c:25)
+   by 0x........: main (varinfo1.c:51)
+ Location 0x........ is 0 bytes inside local var "local"
+ declared at varinfo1.c:41, in frame #1 of thread 1
+
+ERROR SUMMARY: 6 errors from 6 contexts (suppressed: 0 from 0)
+malloc/free: in use at exit: 0 bytes in 0 blocks.
+malloc/free: 1 allocs, 1 frees, 3 bytes allocated.
+For a detailed leak analysis,  rerun with: --leak-check=yes
+For counts of detected errors, rerun with: -v

Added: branches/DATASYMS/memcheck/tests/varinfo1.stdout.exp
===================================================================

Added: branches/DATASYMS/memcheck/tests/varinfo1.vgtest
===================================================================
--- branches/DATASYMS/memcheck/tests/varinfo1.vgtest                            
(rev 0)
+++ branches/DATASYMS/memcheck/tests/varinfo1.vgtest    2008-02-26 18:36:29 UTC 
(rev 7479)
@@ -0,0 +1 @@
+prog: varinfo1

Added: branches/DATASYMS/memcheck/tests/varinfo2.c
===================================================================
--- branches/DATASYMS/memcheck/tests/varinfo2.c                         (rev 0)
+++ branches/DATASYMS/memcheck/tests/varinfo2.c 2008-02-26 18:36:29 UTC (rev 
7479)
@@ -0,0 +1,48 @@
+
+/* Check for correct handling of nested scopes in a zero-biased
+   executable. */
+
+/* Relevant compile flags are:
+
+   -Wall -g -I$prefix/include/valgrind
+
+   eg -Wall -g -I`pwd`/Inst/include/valgrind
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include "memcheck/memcheck.h"
+
+/* Cause memcheck to complain about the address "a" and so to print
+   its best guess as to what "a" actually is.  a must be
+   addressible. */
+
+void croak ( void* a )
+{
+  volatile char undef;
+  *(char*)a = undef;
+  VALGRIND_CHECK_MEM_IS_DEFINED(a, 1);
+}
+
+#include <stdio.h>
+
+void foo ( void )
+{
+  int var;
+  var = 1;
+  { char var[10];
+    var[6] = 4;
+    croak( &var[7] );
+    { struct { double foo; float bar; } var;
+      croak ( 2 + (char*)&var.bar );
+    }
+  }
+  croak( 1 + (char*)&var );
+}
+
+int main ( void )
+{
+  foo();
+  return 0;
+}

Added: branches/DATASYMS/memcheck/tests/varinfo2.stderr.exp
===================================================================
--- branches/DATASYMS/memcheck/tests/varinfo2.stderr.exp                        
        (rev 0)
+++ branches/DATASYMS/memcheck/tests/varinfo2.stderr.exp        2008-02-26 
18:36:29 UTC (rev 7479)
@@ -0,0 +1,27 @@
+
+Uninitialised byte(s) found during client check request
+   at 0x........: croak (varinfo2.c:25)
+   by 0x........: foo (varinfo2.c:36)
+   by 0x........: main (varinfo2.c:46)
+ Location 0x........ is 0 bytes inside var[7],
+ declared at varinfo2.c:34, in frame #1 of thread 1
+
+Uninitialised byte(s) found during client check request
+   at 0x........: croak (varinfo2.c:25)
+   by 0x........: foo (varinfo2.c:38)
+   by 0x........: main (varinfo2.c:46)
+ Location 0x........ is 2 bytes inside var.bar,
+ declared at varinfo2.c:37, in frame #1 of thread 1
+
+Uninitialised byte(s) found during client check request
+   at 0x........: croak (varinfo2.c:25)
+   by 0x........: foo (varinfo2.c:41)
+   by 0x........: main (varinfo2.c:46)
+ Location 0x........ is 1 byte inside local var "var"
+ declared at varinfo2.c:32, in frame #1 of thread 1
+
+ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 0 from 0)
+malloc/free: in use at exit: 0 bytes in 0 blocks.
+malloc/free: 0 allocs, 0 frees, 0 bytes allocated.
+For a detailed leak analysis,  rerun with: --leak-check=yes
+For counts of detected errors, rerun with: -v

Added: branches/DATASYMS/memcheck/tests/varinfo2.stdout.exp
===================================================================

Added: branches/DATASYMS/memcheck/tests/varinfo2.vgtest
===================================================================
--- branches/DATASYMS/memcheck/tests/varinfo2.vgtest                            
(rev 0)
+++ branches/DATASYMS/memcheck/tests/varinfo2.vgtest    2008-02-26 18:36:29 UTC 
(rev 7479)
@@ -0,0 +1 @@
+prog: varinfo2

Added: branches/DATASYMS/memcheck/tests/varinfo3.c
===================================================================
--- branches/DATASYMS/memcheck/tests/varinfo3.c                         (rev 0)
+++ branches/DATASYMS/memcheck/tests/varinfo3.c 2008-02-26 18:36:29 UTC (rev 
7479)
@@ -0,0 +1,63 @@
+
+/* Check for correct handling of static vs non-static, local vs
+   non-local variables in a zero-biased executable. */
+
+/* Relevant compile flags are:
+
+   -Wall -g -I$prefix/include/valgrind
+
+   eg -Wall -g -I`pwd`/Inst/include/valgrind
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include "memcheck/memcheck.h"
+
+/* Cause memcheck to complain about the address "a" and so to print
+   its best guess as to what "a" actually is.  a must be
+   addressible. */
+
+void croak ( void* a )
+{
+  volatile char undef;
+  *(char*)a = undef;
+  VALGRIND_CHECK_MEM_IS_DEFINED(a, 1);
+}
+
+#include <stdio.h>
+
+static char static_global_def[10]    = {0,0,0,0,0, 0,0,0,0,0};
+       char nonstatic_global_def[10] = {0,0,0,0,0, 0,0,0,0,0};
+static char static_global_undef[10];
+       char nonstatic_global_undef[10];
+
+void bar ( char* p1, char* p2, char* p3, char* p4 )
+{
+   croak(p1);
+   croak(p2);
+   croak(p3);
+   croak(p4);
+}
+
+void foo ( void )
+{
+   static char static_local_def[10]    = {0,0,0,0,0, 0,0,0,0,0};
+          char nonstatic_local_def[10] = {0,0,0,0,0, 0,0,0,0,0};
+   static char static_local_undef[10];
+          char nonstatic_local_undef[10];
+   croak ( 1 + (char*)&static_global_def );
+   croak ( 2 + (char*)&nonstatic_global_def );
+   croak ( 3 + (char*)&static_global_undef );
+   croak ( 4 + (char*)&nonstatic_global_undef );
+   bar( 5 + (char*)&static_local_def,
+        6 + (char*)&nonstatic_local_def,
+        7 + (char*)&static_local_undef,
+        8 + (char*)&nonstatic_local_undef );
+}
+
+int main ( void )
+{
+  foo();
+  return 0;
+}

Added: branches/DATASYMS/memcheck/tests/varinfo3.stderr.exp
===================================================================
--- branches/DATASYMS/memcheck/tests/varinfo3.stderr.exp                        
        (rev 0)
+++ branches/DATASYMS/memcheck/tests/varinfo3.stderr.exp        2008-02-26 
18:36:29 UTC (rev 7479)
@@ -0,0 +1,64 @@
+
+Uninitialised byte(s) found during client check request
+   at 0x........: croak (varinfo3.c:25)
+   by 0x........: foo (varinfo3.c:49)
+   by 0x........: main (varinfo3.c:61)
+ Location 0x........ is 0 bytes inside static_global_def[1],
+ declared at varinfo3.c:30, in frame #0 of thread 1
+
+Uninitialised byte(s) found during client check request
+   at 0x........: croak (varinfo3.c:25)
+   by 0x........: foo (varinfo3.c:50)
+   by 0x........: main (varinfo3.c:61)
+ Location 0x........ is 0 bytes inside nonstatic_global_def[2],
+ a global variable declared at varinfo3.c:31
+
+Uninitialised byte(s) found during client check request
+   at 0x........: croak (varinfo3.c:25)
+   by 0x........: foo (varinfo3.c:51)
+   by 0x........: main (varinfo3.c:61)
+ Location 0x........ is 0 bytes inside static_global_undef[3],
+ declared at varinfo3.c:32, in frame #0 of thread 1
+
+Uninitialised byte(s) found during client check request
+   at 0x........: croak (varinfo3.c:25)
+   by 0x........: foo (varinfo3.c:52)
+   by 0x........: main (varinfo3.c:61)
+ Location 0x........ is 0 bytes inside nonstatic_global_undef[4],
+ a global variable declared at varinfo3.c:33
+
+Uninitialised byte(s) found during client check request
+   at 0x........: croak (varinfo3.c:25)
+   by 0x........: bar (varinfo3.c:37)
+   by 0x........: foo (varinfo3.c:53)
+   by 0x........: main (varinfo3.c:61)
+ Address 0x........ is 5 bytes inside data symbol "static_local_def.2751"
+
+Uninitialised byte(s) found during client check request
+   at 0x........: croak (varinfo3.c:25)
+   by 0x........: bar (varinfo3.c:38)
+   by 0x........: foo (varinfo3.c:53)
+   by 0x........: main (varinfo3.c:61)
+ Location 0x........ is 0 bytes inside nonstatic_local_def[6],
+ declared at varinfo3.c:46, in frame #2 of thread 1
+
+Uninitialised byte(s) found during client check request
+   at 0x........: croak (varinfo3.c:25)
+   by 0x........: bar (varinfo3.c:39)
+   by 0x........: foo (varinfo3.c:53)
+   by 0x........: main (varinfo3.c:61)
+ Address 0x........ is 7 bytes inside data symbol "static_local_undef.2753"
+
+Uninitialised byte(s) found during client check request
+   at 0x........: croak (varinfo3.c:25)
+   by 0x........: bar (varinfo3.c:40)
+   by 0x........: foo (varinfo3.c:53)
+   by 0x........: main (varinfo3.c:61)
+ Location 0x........ is 0 bytes inside nonstatic_local_undef[8],
+ declared at varinfo3.c:48, in frame #2 of thread 1
+
+ERROR SUMMARY: 8 errors from 8 contexts (suppressed: 0 from 0)
+malloc/free: in use at exit: 0 bytes in 0 blocks.
+malloc/free: 0 allocs, 0 frees, 0 bytes allocated.
+For a detailed leak analysis,  rerun with: --leak-check=yes
+For counts of detected errors, rerun with: -v

Added: branches/DATASYMS/memcheck/tests/varinfo3.stdout.exp
===================================================================

Added: branches/DATASYMS/memcheck/tests/varinfo3.vgtest
===================================================================
--- branches/DATASYMS/memcheck/tests/varinfo3.vgtest                            
(rev 0)
+++ branches/DATASYMS/memcheck/tests/varinfo3.vgtest    2008-02-26 18:36:29 UTC 
(rev 7479)
@@ -0,0 +1 @@
+prog: varinfo3

Added: branches/DATASYMS/memcheck/tests/varinfo4.c
===================================================================
--- branches/DATASYMS/memcheck/tests/varinfo4.c                         (rev 0)
+++ branches/DATASYMS/memcheck/tests/varinfo4.c 2008-02-26 18:36:29 UTC (rev 
7479)
@@ -0,0 +1,53 @@
+
+/* A small demo of providing descriptions of structured types in error
+   messages. */
+
+/* Relevant compile flags are:
+
+   -Wall -g -I$prefix/include/valgrind
+
+   eg -Wall -g -I`pwd`/Inst/include/valgrind
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include "memcheck/memcheck.h"
+
+/* Cause memcheck to complain about the address "a" and so to print
+   its best guess as to what "a" actually is.  a must be
+   addressible. */
+
+void croak ( void* a )
+{
+  volatile char undef;
+  *(char*)a = undef;
+  VALGRIND_CHECK_MEM_IS_DEFINED(a, 1);
+}
+
+#include <stdio.h>
+#include <string.h>
+
+typedef struct { short c1; char* c2[3]; } XX;
+
+typedef
+   struct _str { int bing; int bong; XX xyzzy[77]; }
+   Str;
+
+__attribute__((noinline))
+int blah ( int x, int y )
+{
+  Str a[10];
+  memset(a, 0, sizeof(a));
+  croak(1 + (char*)(&a[3].xyzzy[x*y].c1));
+  croak( (char*)(&a[5].bong) );
+  croak( 1 + (char*)(&a[3].xyzzy[x*y].c2[2]) );
+  memset(a, 0, sizeof(a));
+  return a[3].xyzzy[x*y].c1;
+}
+
+int main ( void )
+{
+  printf("answer is %d\n", blah(3,7) );
+  return 0;
+}

Added: branches/DATASYMS/memcheck/tests/varinfo4.stderr.exp
===================================================================
--- branches/DATASYMS/memcheck/tests/varinfo4.stderr.exp                        
        (rev 0)
+++ branches/DATASYMS/memcheck/tests/varinfo4.stderr.exp        2008-02-26 
18:36:29 UTC (rev 7479)
@@ -0,0 +1,27 @@
+
+Uninitialised byte(s) found during client check request
+   at 0x........: croak (varinfo4.c:25)
+   by 0x........: blah (varinfo4.c:42)
+   by 0x........: main (varinfo4.c:51)
+ Location 0x........ is 1 byte inside a[3].xyzzy[21].c1,
+ declared at varinfo4.c:40, in frame #1 of thread 1
+
+Uninitialised byte(s) found during client check request
+   at 0x........: croak (varinfo4.c:25)
+   by 0x........: blah (varinfo4.c:43)
+   by 0x........: main (varinfo4.c:51)
+ Location 0x........ is 0 bytes inside a[5].bong,
+ declared at varinfo4.c:40, in frame #1 of thread 1
+
+Uninitialised byte(s) found during client check request
+   at 0x........: croak (varinfo4.c:25)
+   by 0x........: blah (varinfo4.c:44)
+   by 0x........: main (varinfo4.c:51)
+ Location 0x........ is 1 byte inside a[3].xyzzy[21].c2[2],
+ declared at varinfo4.c:40, in frame #1 of thread 1
+
+ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 0 from 0)
+malloc/free: in use at exit: 0 bytes in 0 blocks.
+malloc/free: 0 allocs, 0 frees, 0 bytes allocated.
+For a detailed leak analysis,  rerun with: --leak-check=yes
+For counts of detected errors, rerun with: -v

Added: branches/DATASYMS/memcheck/tests/varinfo4.stdout.exp
===================================================================
--- branches/DATASYMS/memcheck/tests/varinfo4.stdout.exp                        
        (rev 0)
+++ branches/DATASYMS/memcheck/tests/varinfo4.stdout.exp        2008-02-26 
18:36:29 UTC (rev 7479)
@@ -0,0 +1 @@
+answer is 0

Added: branches/DATASYMS/memcheck/tests/varinfo4.vgtest
===================================================================
--- branches/DATASYMS/memcheck/tests/varinfo4.vgtest                            
(rev 0)
+++ branches/DATASYMS/memcheck/tests/varinfo4.vgtest    2008-02-26 18:36:29 UTC 
(rev 7479)
@@ -0,0 +1 @@
+prog: varinfo4


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Valgrind-developers mailing list
Valgrind-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-developers

Reply via email to