[patch/testsuite] Reference more unused variables

Daniel Jacobowitz drow@false.org
Fri Nov 13 21:54:00 GMT 2009


Just like my patch from yesterday; without these references, RealView
will drop the things we try to print or display from the .exp files.
I'll commit this patch after comments on my earlier patch for "info
variables"; without that, the innocuous change to included.c causes a
regression.

Tested on arm-none-eabi and x86_64-linux.

2009-11-13  Daniel Jacobowitz  <dan@codesourcery.com>

	* gdb.base/find.c (main): Reference search buffers.
	* gdb.base/included.c (main): Reference integer.
	* gdb.base/ptype.c (charfoo): Declare.
	(intfoo): Call charfoo.
	* gdb.base/scope0.c (useitp): New function.
	(usestatics): Use useitp.
	(useit): Add a type for val.
	* gdb.base/scope1.c (useit1): Take a pointer argument.
	(usestatics1): Update calls to useit1.
	* gdb.cp/call-c.cc: Declare foo.
	(main): Call foo.
	* gdb.cp/m-static.cc (main): Reference test4.elsewhere.
	* gdb.cp/namespace.cc (ensureOtherRefs): Declare.
	(main): Call C::ensureRefs and ensureOtherRefs.
	* gdb.cp/namespace1.cc (C::ensureOtherRefs): Also reference int
	variables.
	(ensureOtherRefs): New function.
	* gdb.cp/overload.cc (main): Call all overloadNamespace variants.
	* gdb.cp/templates.cc (main): Call t5i.value.

---
 gdb/testsuite/gdb.base/find.c      |    6 ++++++
 gdb/testsuite/gdb.base/included.c  |    2 +-
 gdb/testsuite/gdb.base/ptype.c     |    3 +++
 gdb/testsuite/gdb.base/scope0.c    |   26 +++++++++++++++++++++-----
 gdb/testsuite/gdb.base/scope1.c    |   17 +++++++++--------
 gdb/testsuite/gdb.cp/call-c.cc     |    5 +++++
 gdb/testsuite/gdb.cp/m-static.cc   |    1 +
 gdb/testsuite/gdb.cp/namespace.cc  |    5 +++++
 gdb/testsuite/gdb.cp/namespace1.cc |   19 +++++++++++++------
 gdb/testsuite/gdb.cp/overload.cc   |    4 ++++
 gdb/testsuite/gdb.cp/templates.cc  |    4 +++-
 11 files changed, 71 insertions(+), 21 deletions(-)

Index: gdb/testsuite/gdb.cp/call-c.cc
===================================================================
--- gdb/testsuite/gdb.cp/call-c.cc.orig	2009-02-03 00:39:17.000000000 -0800
+++ gdb/testsuite/gdb.cp/call-c.cc	2009-11-13 09:40:35.000000000 -0800
@@ -30,6 +30,10 @@ struct Foo {
 
 typedef Foo *FooHandle;
 
+extern "C" {
+  int foo(int);
+}
+
 int main()
 {
     Foo f;
@@ -37,5 +41,6 @@ int main()
     Foo* &rf = pf;
     FooHandle handle = pf;
     rf->func(); /* set breakpoint here */
+    foo(0);
     return func(0);
 }
Index: gdb/testsuite/gdb.cp/m-static.cc
===================================================================
--- gdb/testsuite/gdb.cp/m-static.cc.orig	2006-05-06 00:24:04.000000000 -0700
+++ gdb/testsuite/gdb.cp/m-static.cc	2009-11-13 09:39:49.000000000 -0800
@@ -68,6 +68,7 @@ int main()
   gnu_obj_3<long>	test3(greek);
   gnu_obj_4		test4;
 
+  test4.dummy = test4.elsewhere;
   test4.dummy = 0;
   return test4.dummy;	// breakpoint: constructs-done
 }
Index: gdb/testsuite/gdb.cp/namespace.cc
===================================================================
--- gdb/testsuite/gdb.cp/namespace.cc.orig	2004-01-23 13:55:57.000000000 -0800
+++ gdb/testsuite/gdb.cp/namespace.cc	2009-11-13 09:39:49.000000000 -0800
@@ -168,6 +168,8 @@ namespace C
   }
 }
 
+extern int ensureOtherRefs ();
+
 int main ()
 {
   using AAA::inA;
@@ -195,4 +197,7 @@ int main ()
   marker1();
   
   C::D::marker2 ();
+
+  C::ensureRefs ();
+  ensureOtherRefs ();
 }
Index: gdb/testsuite/gdb.cp/overload.cc
===================================================================
--- gdb/testsuite/gdb.cp/overload.cc.orig	2004-02-02 12:44:53.000000000 -0800
+++ gdb/testsuite/gdb.cp/overload.cc	2009-11-13 09:39:49.000000000 -0800
@@ -102,6 +102,10 @@ int main () 
        breakpoint();
     #endif
 
+    overloadNamespace (1);
+    overloadNamespace (dummyInstance);
+    XXX::overloadNamespace ('a');
+
     // Verify that intToChar should work:
     intToChar(1);
 
Index: gdb/testsuite/gdb.cp/templates.cc
===================================================================
--- gdb/testsuite/gdb.cp/templates.cc.orig	2009-09-22 00:29:05.000000000 -0700
+++ gdb/testsuite/gdb.cp/templates.cc	2009-11-13 09:41:08.000000000 -0800
@@ -782,8 +782,10 @@ int main()
 
   intBazOne ibo;
   z = ibo.baz (2, 21);
+
+  t5i.value();
+
   return 0;
-    
 }
 
 
Index: gdb/testsuite/gdb.cp/namespace1.cc
===================================================================
--- gdb/testsuite/gdb.cp/namespace1.cc.orig	2009-01-03 00:43:31.000000000 -0800
+++ gdb/testsuite/gdb.cp/namespace1.cc	2009-11-13 09:39:49.000000000 -0800
@@ -23,19 +23,26 @@ namespace C
     int z;
   };
 
-  void ensureOtherRefs () {
-    // NOTE (2004-04-23, carlton): This function is here only to make
-    // sure that GCC 3.4 outputs debug info for this class.
-    static OtherFileClass *c = new OtherFileClass();
-  }
-
   namespace {
     int cXOtherFile = 29;
   };
 
   int cOtherFile = 316;
+
+  void ensureOtherRefs () {
+    // NOTE (2004-04-23, carlton): This function is here only to make
+    // sure that GCC 3.4 outputs debug info for this class.
+    static OtherFileClass *c = new OtherFileClass();
+    c->z = cOtherFile + cXOtherFile;
+  }
 }
 
 namespace {
   int XOtherFile = 317;
 }
+
+int ensureOtherRefs ()
+{
+  C::ensureOtherRefs ();
+  return XOtherFile;
+}
Index: gdb/testsuite/gdb.base/find.c
===================================================================
--- gdb/testsuite/gdb.base/find.c.orig	2009-11-13 06:59:34.000000000 -0800
+++ gdb/testsuite/gdb.base/find.c	2009-11-13 09:39:49.000000000 -0800
@@ -67,5 +67,11 @@ main ()
 
   stop_here ();
 
+  /* Reference variables.  */
+  x = int8_search_buf[0];
+  x = int16_search_buf[0];
+  x = int32_search_buf[0];
+  x = int64_search_buf[0];
+
   return 0;
 }
Index: gdb/testsuite/gdb.base/scope0.c
===================================================================
--- gdb/testsuite/gdb.base/scope0.c.orig	1999-06-28 09:03:51.000000000 -0700
+++ gdb/testsuite/gdb.base/scope0.c	2009-11-13 09:39:49.000000000 -0800
@@ -11,6 +11,7 @@ extern void foo();
 int autovars (int bcd, int abc);
 int localscopes (int x);
 int useit (int val);
+int useitp (const int *val);
 void init0();
 void marker1 ();
 void marker2 ();
@@ -30,12 +31,13 @@ int main ()
 }
 
 /* On some systems, such as AIX, unreferenced variables are deleted
-   from the executable.  */
+   from the executable.  On other compilers, such as ARM RealView,
+   const variables without their address taken are deleted.  */
 void usestatics ()
 {
-  useit (filelocal);
-  useit (filelocal_bss);
-  useit (filelocal_ro);
+  useitp (&filelocal);
+  useitp (&filelocal_bss);
+  useitp (&filelocal_ro);
 }
 
 void init0 ()
@@ -68,7 +70,7 @@ int
 useit (int val)
 #else
 int
-useit (val)
+useit (val) int val;
 #endif
 {
     static int usedval;
@@ -79,6 +81,20 @@ useit (val)
 
 #ifdef PROTOTYPES
 int
+useitp (const int *val)
+#else
+int
+useitp (val) const int *val;
+#endif
+{
+    static int usedval;
+
+    usedval = *val;
+    return *val + sum_upto (0);
+}
+
+#ifdef PROTOTYPES
+int
 autovars (int bcd, int abc)
 #else
 int
Index: gdb/testsuite/gdb.base/ptype.c
===================================================================
--- gdb/testsuite/gdb.base/ptype.c.orig	2007-12-22 00:15:06.000000000 -0800
+++ gdb/testsuite/gdb.base/ptype.c	2009-11-13 09:39:49.000000000 -0800
@@ -269,10 +269,13 @@ func_type v_func_type;
 
 /***********/
 
+extern char charfoo ();
+
 typedef int foo;
 
 foo intfoo (afoo)
 {
+  charfoo (afoo);
   return (afoo * 2);
 }
 
Index: gdb/testsuite/gdb.base/scope1.c
===================================================================
--- gdb/testsuite/gdb.base/scope1.c.orig	1999-06-28 09:03:52.000000000 -0700
+++ gdb/testsuite/gdb.base/scope1.c	2009-11-13 09:39:49.000000000 -0800
@@ -32,23 +32,24 @@ void init1 ()
 }
 
 /* On some systems, such as AIX, unreferenced variables are deleted
-   from the executable.  */
+   from the executable.  On other compilers, such as ARM RealView,
+   const variables without their address taken are deleted.  */
 void usestatics1 ()
 {
-  void useit1 (int val);
+  void useit1 (const int *val);
   
-  useit1 (filelocal);
-  useit1 (filelocal_bss);
-  useit1 (filelocal_ro);
+  useit1 (&filelocal);
+  useit1 (&filelocal_bss);
+  useit1 (&filelocal_ro);
 }
 
 #ifdef PROTOTYPES
-void useit1 (int val)
+void useit1 (const int *val)
 #else
-void useit1 (val) int val;
+void useit1 (val) const int *val;
 #endif
 {
     static int usedval;
 
-    usedval = val;
+    usedval = *val;
 }
Index: gdb/testsuite/gdb.base/included.c
===================================================================
--- gdb/testsuite/gdb.base/included.c.orig	2009-01-03 00:43:31.000000000 -0800
+++ gdb/testsuite/gdb.base/included.c	2009-11-13 09:39:49.000000000 -0800
@@ -20,5 +20,5 @@
 int
 main()
 {
-  return 0;
+  return integer;
 }

-- 
Daniel Jacobowitz
CodeSourcery



More information about the Gdb-patches mailing list