Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch/rfc] Rewrite "structs" testcase
@ 2003-11-05 22:17 Andrew Cagney
  0 siblings, 0 replies; 18+ messages in thread
From: Andrew Cagney @ 2003-11-05 22:17 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 578 bytes --]

Hello,

The attached rewrites the "structs" testcase, greatly increasing its 
coverage of struct return inferior function call edge cases.  Of note 
the patch:

- hacks structs.c so that it can be built to test almost any scalar 
struct return construct

- rewrites structs.exp to build structs.c / test structs.c with several 
combinations of char, short, int, long, long long, float, double, and 
long double.

- since the bug that stopped GDB finding inferior function call struct 
return values has been fixed, it expects all tests to pass

Look ok?  Tested on PPC.

Andrew

[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 25147 bytes --]

2003-11-05  Andrew Cagney  <cagney@redhat.com>

	* gdb.base/structs.exp: Update copyright.  Rewrite.
	* gdb.base/structs.c: Update copyright.  Rewrite.

Index: gdb.base/structs.c
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/structs.c,v
retrieving revision 1.2
diff -u -r1.2 structs.c
--- gdb.base/structs.c	6 Mar 2001 08:21:51 -0000	1.2
+++ gdb.base/structs.c	5 Nov 2003 22:02:58 -0000
@@ -1,4 +1,6 @@
-/* Copyright 1996, 1999 Free Software Foundation, Inc.
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 1996, 1999, 2003 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -17,37 +19,105 @@
    Please email any bugs, comments, and/or additions to this file to:
    bug-gdb@prep.ai.mit.edu  */
 
-struct struct1 { char a;};
-struct struct2 { char a, b;};
-struct struct3 { char a, b, c; };
-struct struct4 { char a, b, c, d; };
-struct struct5 { char a, b, c, d, e; };
-struct struct6 { char a, b, c, d, e, f; };
-struct struct7 { char a, b, c, d, e, f, g; };
-struct struct8 { char a, b, c, d, e, f, g, h; };
-struct struct9 { char a, b, c, d, e, f, g, h, i; };
-struct struct10 { char a, b, c, d, e, f, g, h, i, j; };
-struct struct11 { char a, b, c, d, e, f, g, h, i, j, k; };
-struct struct12 { char a, b, c, d, e, f, g, h, i, j, k, l; };
-struct struct16 { char a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p; };
-
-struct struct1 foo1 = {'1'},  L1;
-struct struct2 foo2 = { 'a', 'b'},  L2;
-struct struct3 foo3 = { 'A', 'B', 'C'},  L3;
-struct struct4 foo4 = {'1', '2', '3', '4'},  L4;
-struct struct5 foo5 = {'a', 'b', 'c', 'd', 'e'},  L5;
-struct struct6 foo6 = {'A', 'B', 'C', 'D', 'E', 'F'},  L6;
-struct struct7 foo7 = {'1', '2', '3', '4', '5', '6', '7'},  L7;
-struct struct8 foo8 = {'1', '2', '3', '4', '5', '6', '7', '8'},  L8;
-struct struct9 foo9 = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'},  L9;
-struct struct10 foo10 = {
-  'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'},  L10;
-struct struct11 foo11 = {
-  '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B'}, L11;
-struct struct12 foo12 = {
-  'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L'}, L12;
-struct struct16 foo16 = {
-  'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p'}, L16;
+/* Useful abreviations.  */
+typedef void t;
+typedef char tc;
+typedef short ts;
+typedef int ti;
+typedef long tl;
+typedef long long tll;
+typedef float tf;
+typedef double td;
+typedef long double tld;
+
+/* Force the type of each field.  */
+#ifndef tA
+typedef t tA;
+#endif
+#ifndef tB
+typedef tA tB;
+#endif
+#ifndef tC
+typedef tB tC;
+#endif
+#ifndef tD
+typedef tC tD;
+#endif
+#ifndef tE
+typedef tD tE;
+#endif
+#ifndef tF
+typedef tE tF;
+#endif
+#ifndef tG
+typedef tF tG;
+#endif
+#ifndef tH
+typedef tG tH;
+#endif
+#ifndef tI
+typedef tH tI;
+#endif
+#ifndef tJ
+typedef tI tJ;
+#endif
+#ifndef tK
+typedef tJ tK;
+#endif
+#ifndef tL
+typedef tK tL;
+#endif
+#ifndef tM
+typedef tL tM;
+#endif
+#ifndef tN
+typedef tM tN;
+#endif
+#ifndef tO
+typedef tN tO;
+#endif
+#ifndef tP
+typedef tO tP;
+#endif
+#ifndef tQ
+typedef tP tQ;
+#endif
+
+struct  struct1 {tA a;};
+struct  struct2 {tA a; tB b;};
+struct  struct3 {tA a; tB b; tC c; };
+struct  struct4 {tA a; tB b; tC c; tD D; };
+struct  struct5 {tA a; tB b; tC c; tD D; tE e; };
+struct  struct6 {tA a; tB b; tC c; tD D; tE e; tF f; };
+struct  struct7 {tA a; tB b; tC c; tD D; tE e; tF f; tG g; };
+struct  struct8 {tA a; tB b; tC c; tD D; tE e; tF f; tG g; tH h; };
+struct  struct9 {tA a; tB b; tC c; tD D; tE e; tF f; tG g; tH h; tI i; };
+struct struct10 {tA a; tB b; tC c; tD D; tE e; tF f; tG g; tH h; tI i; tJ j; };
+struct struct11 {tA a; tB b; tC c; tD D; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; };
+struct struct12 {tA a; tB b; tC c; tD D; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; };
+struct struct13 {tA a; tB b; tC c; tD D; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; tM m; };
+struct struct14 {tA a; tB b; tC c; tD D; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; tM m; tN n; };
+struct struct15 {tA a; tB b; tC c; tD D; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; tM m; tN n; tO o; };
+struct struct16 {tA a; tB b; tC c; tD D; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; tM m; tN n; tO o; tP p; };
+struct struct17 {tA a; tB b; tC c; tD D; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; tM m; tN n; tO o; tP p; tQ q; };
+
+struct  struct1  foo1 = {'1'}, L1;
+struct  struct2  foo2 = {'a','2'}, L2;
+struct  struct3  foo3 = {'1','b','3'}, L3;
+struct  struct4  foo4 = {'a','2','c','4'}, L4;
+struct  struct5  foo5 = {'1','b','3','d','5'}, L5;
+struct  struct6  foo6 = {'a','2','c','4','e','6'}, L6;
+struct  struct7  foo7 = {'1','b','3','d','5','f','7'}, L7;
+struct  struct8  foo8 = {'a','2','c','4','e','6','g','8'}, L8;
+struct  struct9  foo9 = {'1','b','3','d','5','f','7','h','9'}, L9;
+struct struct10 foo10 = {'a','2','c','4','e','6','g','8','i','A'}, L10;
+struct struct11 foo11 = {'1','b','3','d','5','f','7','h','9','j','B'}, L11;
+struct struct12 foo12 = {'a','2','c','4','e','6','g','8','i','A','k','C'}, L12;
+struct struct13 foo13 = {'1','b','3','d','5','f','7','h','9','j','B','l','D'}, L13;
+struct struct14 foo14 = {'a','2','c','4','e','6','g','8','i','A','k','C','m','E'}, L14;
+struct struct15 foo15 = {'1','b','3','d','5','f','7','h','9','j','B','l','D','n','F'}, L15;
+struct struct16 foo16 = {'a','2','c','4','e','6','g','8','i','A','k','C','m','E','o','G'}, L16;
+struct struct17 foo17 = {'1','b','3','d','5','f','7','h','9','j','B','l','D','n','F','p','H'}, L17;
 
 struct struct1  fun1()
 {
@@ -97,10 +167,26 @@
 {
   return foo12; 
 }
+struct struct13 fun13()
+{
+  return foo13; 
+}
+struct struct14 fun14()
+{
+  return foo14; 
+}
+struct struct15 fun15()
+{
+  return foo15; 
+}
 struct struct16 fun16()
 {
   return foo16; 
 }
+struct struct17 fun17()
+{
+  return foo17; 
+}
 
 #ifdef PROTOTYPES
 void Fun1(struct struct1 foo1)
@@ -211,6 +297,33 @@
   L12 = foo12; 
 }
 #ifdef PROTOTYPES
+void Fun13(struct struct13 foo13)
+#else
+void Fun13(foo13)
+     struct struct13 foo13;
+#endif
+{
+  L13 = foo13; 
+}
+#ifdef PROTOTYPES
+void Fun14(struct struct14 foo14)
+#else
+void Fun14(foo14)
+     struct struct14 foo14;
+#endif
+{
+  L14 = foo14; 
+}
+#ifdef PROTOTYPES
+void Fun15(struct struct15 foo15)
+#else
+void Fun15(foo15)
+     struct struct15 foo15;
+#endif
+{
+  L15 = foo15; 
+}
+#ifdef PROTOTYPES
 void Fun16(struct struct16 foo16)
 #else
 void Fun16(foo16)
@@ -219,6 +332,15 @@
 {
   L16 = foo16; 
 }
+#ifdef PROTOTYPES
+void Fun17(struct struct17 foo17)
+#else
+void Fun17(foo17)
+     struct struct17 foo17;
+#endif
+{
+  L17 = foo17; 
+}
 
 int main()
 {
@@ -240,10 +362,15 @@
   L10 = fun10();
   L11 = fun11();
   L12 = fun12();
+  L13 = fun13();
+  L14 = fun14();
+  L15 = fun15();
   L16 = fun16();
+  L17 = fun17();
 
   foo1.a = foo2.a = foo3.a = foo4.a = foo5.a = foo6.a = foo7.a = foo8.a =
-    foo9.a = foo10.a = foo11.a = foo12.a = foo16.a = '$';
+    foo9.a = foo10.a = foo11.a = foo12.a = foo13.a = foo14.a = foo15.a =
+    foo16.a = foo17.a = '$';
 
   Fun1(foo1);	
   Fun2(foo2);	
@@ -257,7 +384,11 @@
   Fun10(foo10);
   Fun11(foo11);
   Fun12(foo12);
+  Fun13(foo13);
+  Fun14(foo14);
+  Fun15(foo15);
   Fun16(foo16);
+  Fun17(foo17);
 
   return 0;
 }
Index: gdb.base/structs.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/structs.exp,v
retrieving revision 1.5
diff -u -r1.5 structs.exp
--- gdb.base/structs.exp	7 Jan 2002 19:20:09 -0000	1.5
+++ gdb.base/structs.exp	5 Nov 2003 22:02:58 -0000
@@ -1,4 +1,6 @@
-# Copyright 1996, 1997, 1999 Free Software Foundation, Inc.
+# This testcase is part of GDB, the GNU debugger.
+
+# Copyright 1996, 1997, 1999, 2003 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -26,142 +28,241 @@
 set prms_id 0
 set bug_id 0
 
-set prototypes 1
+# Some targets can't call functions, so don't even bother with this
+# test.
+
+if [target_info exists gdb,cannot_call_functions] {
+    setup_xfail "*-*-*" 2416
+    fail "This target can not call functions"
+    continue
+}
+
+# Build a variant of the testcase.
+
 set testfile "structs"
 set srcfile ${testfile}.c
 set binfile ${objdir}/${subdir}/${testfile}
 
-# build the first test case
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-    # built the second test case since we can't use prototypes
-    warning "Prototypes not supported, rebuilding with -DNO_PROTOTYPES"
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DNO_PROTOTYPES}] != "" } {
-     gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+proc start_structs_test { suffix defs } {
+    global testfile
+    global srcfile
+    global binfile
+    global objdir
+    global subdir
+    global srcdir
+    set binfile ${objdir}/${subdir}/${testfile}-${suffix}
+    if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "debug ${defs}"] != "" } {
+	# built the second test case since we can't use prototypes
+	warning "Prototypes not supported, rebuilding with -DNO_PROTOTYPES"
+	if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "debug ${defs} additional_flags=-DNO_PROTOTYPES"] != "" } {
+	    gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+	}
     }
-    set prototypes 0
-}
 
-# Create and source the file that provides information about the compiler
-# used to compile the test case.
-if [get_compiler_info ${binfile}] {
-    return -1;
+    # Start with a fresh gdb.
+    gdb_start
+    gdb_reinitialize_dir $srcdir/$subdir
+    gdb_load ${binfile}
+
+    # Make certain that the output is consistent
+    gdb_test "set print sevenbit-strings" "" "set print sevenbit-strings for ${suffix}"
+    gdb_test "set print address off" ""      "set print address off for ${suffix}"
+    gdb_test "set width 0" ""                "set width 0 for ${suffix}"
 }
 
 
-# Some targets can't call functions, so don't even bother with this
-# test.
-if [target_info exists gdb,cannot_call_functions] {
-    setup_xfail "*-*-*" 2416
-    fail "This target can not call functions"
-    continue
-}
+# Create and source the file that provides information about the
+# compiler used to compile the test case.
 
+if [get_compiler_info ${binfile}] {
+    return -1;
+}
 
 # Call FUNC with no arguments, and expect to see the regexp RESULT in
-# the output.  If we get back the error message "Function return value
-# unknown", call that an unsupported test; on some architectures, it's
-# impossible to find structs returned by value reliably.
-proc call_struct_func { func result } {
+# the output.  Since GDB called the function, GDB always knows where
+# the return value is.  These tests should never fail.  Use a char
+# formatted print so that, regardless of the type of each struct
+# element, the printed value are always the same.
+
+proc call_struct_func { name n result } {
     global gdb_prompt
     
-    set command "p ${func}()"
+    set command "p/c fun${n}()"
     send_gdb "${command}\n"
     gdb_expect {
         -re "$result\[\r\n\]+$gdb_prompt $" {
-            pass "$command"
-        }
-        -re "Function return value unknown.\[\r\n\]+$gdb_prompt $" {
-            unsupported "$command"
+            pass "$command for ${name}"
         }
         -re "$gdb_prompt $" {
-            fail "$command"
+            fail "$command for ${name}"
         }
         timeout {
-            fail "$command (timeout)"
+            fail "$command for ${name} (timeout)"
         }
     }
 }
 
-# FIXME:  Before calling this proc, we should probably verify that
-# we can call inferior functions and get a valid integral value
-# returned.
+proc call_void_func { name n } {
+    set command  "p Fun${n}(foo${n})"
+    gdb_test "${command}" " = (void|0)" "${command} for ${n}"
+}
+
+proc print_struct { name n result } {
+    set command  "p/c L${n}"
+    gdb_test "${command}" ${result} "${command} for ${name}"
+}
+
 # Note that it is OK to check for 0 or 1 as the returned values, because C
 # specifies that the numeric value of a relational or logical expression
 # (computed in the inferior) is 1 for true and 0 for false.
 
-proc do_function_calls {} {
+proc do_function_calls { name } {
     global prototypes
     global gcc_compiled
     global gdb_prompt
 
-    # First, call the "fun" functions and examine the value they return.
-    call_struct_func "fun1" " = {a = 49 '1'}"
-    call_struct_func "fun2" " = {a = 97 'a', b = 98 'b'}"
-    call_struct_func "fun3" " = {a = 65 'A', b = 66 'B', c = 67 'C'}"
-    call_struct_func "fun4" " = {a = 49 '1', b = 50 '2', c = 51 '3', d = 52 '4'}"
-    call_struct_func "fun5" " = {a = 97 'a', b = 98 'b', c = 99 'c', d = 100 'd', e = 101 'e'}"
-    call_struct_func "fun6" " = {a = 65 'A', b = 66 'B', c = 67 'C', d = 68 'D', e = 69 'E', f = 70 'F'}"
-    call_struct_func "fun7" " = {a = 49 '1', b = 50 '2', c = 51 '3', d = 52 '4', e = 53 '5', f = 54 '6', g = 55 '7'}"
-    call_struct_func "fun8" " = {a = 49 '1', b = 50 '2', c = 51 '3', d = 52 '4', e = 53 '5', f = 54 '6', g = 55 '7', h = 56 '8'}"
-    call_struct_func "fun9" " = {a = 97 'a', b = 98 'b', c = 99 'c', d = 100 'd', e = 101 'e', f = 102 'f', g = 103 'g', h = 104 'h', i = 105 'i'}"
-    call_struct_func "fun10" " = {a = 65 'A', b = 66 'B', c = 67 'C', d = 68 'D', e = 69 'E', f = 70 'F', g = 71 'G', h = 72 'H', i = 73 'I', j = 74 'J'}"
-    call_struct_func "fun11" " = {a = 49 '1', b = 50 '2', c = 51 '3', d = 52 '4', e = 53 '5', f = 54 '6', g = 55 '7', h = 56 '8', i = 57 '9', j = 65 'A', k = 66 'B'}"
-    call_struct_func "fun12" " = {a = 65 'A', b = 66 'B', c = 67 'C', d = 68 'D', e = 69 'E', f = 70 'F', g = 71 'G', h = 72 'H', i = 73 'I', j = 74 'J', k = 75 'K', l = 76 'L'}"
-    call_struct_func "fun16" " = {a = 97 'a', b = 98 'b', c = 99 'c', d = 100 'd', e = 101 'e', f = 102 'f', g = 103 'g', h = 104 'h', i = 105 'i', j = 106 'j', k = 107 'k', l = 108 'l', m = 109 'm', n = 110 'n', o = 111 'o', p = 112 'p'}"
+    # First, call the "fun" functions and examine the value they
+    # return.  This checks that GDB can correctly, and always, extract
+    # the return value from an inferior function call.
+
+    call_struct_func ${name} 1 " = {a = 49 '1'}"
+    call_struct_func ${name} 2 " = {a = 97 'a', b = 50 '2'}"
+    call_struct_func ${name} 3 " = {a = 49 '1', b = 98 'b', c = 51 '3'}"
+    call_struct_func ${name} 4 " = {a = 97 'a', b = 50 '2', c = 99 'c', D = 52 '4'}"
+    call_struct_func ${name} 5 " = {a = 49 '1', b = 98 'b', c = 51 '3', D = 100 'd', e = 53 '5'}"
+    call_struct_func ${name} 6 " = {a = 97 'a', b = 50 '2', c = 99 'c', D = 52 '4', e = 101 'e', f = 54 '6'}"
+    call_struct_func ${name} 7 " = {a = 49 '1', b = 98 'b', c = 51 '3', D = 100 'd', e = 53 '5', f = 102 'f', g = 55 '7'}"
+    call_struct_func ${name} 8 " = {a = 97 'a', b = 50 '2', c = 99 'c', D = 52 '4', e = 101 'e', f = 54 '6', g = 103 'g', h = 56 '8'}"
+    call_struct_func ${name} 9 " = {a = 49 '1', b = 98 'b', c = 51 '3', D = 100 'd', e = 53 '5', f = 102 'f', g = 55 '7', h = 104 'h', i = 57 '9'}"
+    call_struct_func ${name} 10 " = {a = 97 'a', b = 50 '2', c = 99 'c', D = 52 '4', e = 101 'e', f = 54 '6', g = 103 'g', h = 56 '8', i = 105 'i', j = 65 'A'}"
+    call_struct_func ${name} 11 " = {a = 49 '1', b = 98 'b', c = 51 '3', D = 100 'd', e = 53 '5', f = 102 'f', g = 55 '7', h = 104 'h', i = 57 '9', j = 106 'j', k = 66 'B'}"
+    call_struct_func ${name} 12 " = {a = 97 'a', b = 50 '2', c = 99 'c', D = 52 '4', e = 101 'e', f = 54 '6', g = 103 'g', h = 56 '8', i = 105 'i', j = 65 'A', k = 107 'k', l = 67 'C'}"
+    call_struct_func ${name} 13 " = {a = 49 '1', b = 98 'b', c = 51 '3', D = 100 'd', e = 53 '5', f = 102 'f', g = 55 '7', h = 104 'h', i = 57 '9', j = 106 'j', k = 66 'B', l = 108 'l', m = 68 'D'}"
+    call_struct_func ${name} 14 " = {a = 97 'a', b = 50 '2', c = 99 'c', D = 52 '4', e = 101 'e', f = 54 '6', g = 103 'g', h = 56 '8', i = 105 'i', j = 65 'A', k = 107 'k', l = 67 'C', m = 109 'm', n = 69 'E'}"
+    call_struct_func ${name} 15 " = {a = 49 '1', b = 98 'b', c = 51 '3', D = 100 'd', e = 53 '5', f = 102 'f', g = 55 '7', h = 104 'h', i = 57 '9', j = 106 'j', k = 66 'B', l = 108 'l', m = 68 'D', n = 110 'n', o = 70 'F'}"
+    call_struct_func ${name} 16 " = {a = 97 'a', b = 50 '2', c = 99 'c', D = 52 '4', e = 101 'e', f = 54 '6', g = 103 'g', h = 56 '8', i = 105 'i', j = 65 'A', k = 107 'k', l = 67 'C', m = 109 'm', n = 69 'E', o = 111 'o', p = 71 'G'}"
+    call_struct_func ${name} 17 " = {a = 49 '1', b = 98 'b', c = 51 '3', D = 100 'd', e = 53 '5', f = 102 'f', g = 55 '7', h = 104 'h', i = 57 '9', j = 106 'j', k = 66 'B', l = 108 'l', m = 68 'D', n = 110 'n', o = 70 'F', p = 112 'p', q = 72 'H'}"
 
     # Now call the Fun functions to set the L* variables.  This
     # tests that gdb properly passes structures to functions.
-    gdb_test "p Fun1(foo1)" " = (void|0)"
-    gdb_test "p Fun2(foo2)" " = (void|0)"
-    gdb_test "p Fun3(foo3)" " = (void|0)"
-    gdb_test "p Fun4(foo4)" " = (void|0)"
-    gdb_test "p Fun5(foo5)" " = (void|0)"
-    gdb_test "p Fun6(foo6)" " = (void|0)"
-    gdb_test "p Fun7(foo7)" " = (void|0)"
-    gdb_test "p Fun8(foo8)" " = (void|0)"
-    gdb_test "p Fun9(foo9)" " = (void|0)"
-    gdb_test "p Fun10(foo10)" " = (void|0)"
-    gdb_test "p Fun11(foo11)" " = (void|0)"
-    gdb_test "p Fun12(foo12)" " = (void|0)"
-    gdb_test "p Fun16(foo16)" " = (void|0)"
+
+    call_void_func ${name} 1
+    call_void_func ${name} 2
+    call_void_func ${name} 3
+    call_void_func ${name} 4
+    call_void_func ${name} 5
+    call_void_func ${name} 6
+    call_void_func ${name} 7
+    call_void_func ${name} 8
+    call_void_func ${name} 9
+    call_void_func ${name} 10
+    call_void_func ${name} 11
+    call_void_func ${name} 12
+    call_void_func ${name} 13
+    call_void_func ${name} 14
+    call_void_func ${name} 15
+    call_void_func ${name} 16
+    call_void_func ${name} 17
 
     # Now print the L* variables and examine their values.
-    gdb_test "p L1" " = {a = 49 '1'}"
-    gdb_test "p L2" " = {a = 97 'a', b = 98 'b'}"
-    gdb_test "p L3" " = {a = 65 'A', b = 66 'B', c = 67 'C'}"
-    gdb_test "p L4" " = {a = 49 '1', b = 50 '2', c = 51 '3', d = 52 '4'}"
-    gdb_test "p L5" " = {a = 97 'a', b = 98 'b', c = 99 'c', d = 100 'd', e = 101 'e'}"
-    gdb_test "p L6" " = {a = 65 'A', b = 66 'B', c = 67 'C', d = 68 'D', e = 69 'E', f = 70 'F'}"
-    gdb_test "p L7" " = {a = 49 '1', b = 50 '2', c = 51 '3', d = 52 '4', e = 53 '5', f = 54 '6', g = 55 '7'}"
-    gdb_test "p L8" " = {a = 49 '1', b = 50 '2', c = 51 '3', d = 52 '4', e = 53 '5', f = 54 '6', g = 55 '7', h = 56 '8'}"
-    gdb_test "p L9" " = {a = 97 'a', b = 98 'b', c = 99 'c', d = 100 'd', e = 101 'e', f = 102 'f', g = 103 'g', h = 104 'h', i = 105 'i'}"
-    gdb_test "p L10" " = {a = 65 'A', b = 66 'B', c = 67 'C', d = 68 'D', e = 69 'E', f = 70 'F', g = 71 'G', h = 72 'H', i = 73 'I', j = 74 'J'}"
-    gdb_test "p L11" " = {a = 49 '1', b = 50 '2', c = 51 '3', d = 52 '4', e = 53 '5', f = 54 '6', g = 55 '7', h = 56 '8', i = 57 '9', j = 65 'A', k = 66 'B'}"
-    gdb_test "p L12" " = {a = 65 'A', b = 66 'B', c = 67 'C', d = 68 'D', e = 69 'E', f = 70 'F', g = 71 'G', h = 72 'H', i = 73 'I', j = 74 'J', k = 75 'K', l = 76 'L'}"
-    gdb_test "p L16" " = {a = 97 'a', b = 98 'b', c = 99 'c', d = 100 'd', e = 101 'e', f = 102 'f', g = 103 'g', h = 104 'h', i = 105 'i', j = 106 'j', k = 107 'k', l = 108 'l', m = 109 'm', n = 110 'n', o = 111 'o', p = 112 'p'}"
-}
-# Start with a fresh gdb.
-
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
-gdb_test "set print sevenbit-strings" ""
-gdb_test "set print address off" ""
-gdb_test "set width 0" ""
+    print_struct ${name} 1 " = {a = 49 '1'}"
+    print_struct ${name} 2 " = {a = 97 'a', b = 50 '2'}"
+    print_struct ${name} 3 " = {a = 49 '1', b = 98 'b', c = 51 '3'}"
+    print_struct ${name} 4 " = {a = 97 'a', b = 50 '2', c = 99 'c', D = 52 '4'}"
+    print_struct ${name} 5 " = {a = 49 '1', b = 98 'b', c = 51 '3', D = 100 'd', e = 53 '5'}"
+    print_struct ${name} 6 " = {a = 97 'a', b = 50 '2', c = 99 'c', D = 52 '4', e = 101 'e', f = 54 '6'}"
+    print_struct ${name} 7 " = {a = 49 '1', b = 98 'b', c = 51 '3', D = 100 'd', e = 53 '5', f = 102 'f', g = 55 '7'}"
+    print_struct ${name} 8 " = {a = 97 'a', b = 50 '2', c = 99 'c', D = 52 '4', e = 101 'e', f = 54 '6', g = 103 'g', h = 56 '8'}"
+    print_struct ${name} 9 " = {a = 49 '1', b = 98 'b', c = 51 '3', D = 100 'd', e = 53 '5', f = 102 'f', g = 55 '7', h = 104 'h', i = 57 '9'}"
+    print_struct ${name} 10 " = {a = 97 'a', b = 50 '2', c = 99 'c', D = 52 '4', e = 101 'e', f = 54 '6', g = 103 'g', h = 56 '8', i = 105 'i', j = 65 'A'}"
+    print_struct ${name} 11 " = {a = 49 '1', b = 98 'b', c = 51 '3', D = 100 'd', e = 53 '5', f = 102 'f', g = 55 '7', h = 104 'h', i = 57 '9', j = 106 'j', k = 66 'B'}"
+    print_struct ${name} 12 " = {a = 97 'a', b = 50 '2', c = 99 'c', D = 52 '4', e = 101 'e', f = 54 '6', g = 103 'g', h = 56 '8', i = 105 'i', j = 65 'A', k = 107 'k', l = 67 'C'}"
+    print_struct ${name} 13 " = {a = 49 '1', b = 98 'b', c = 51 '3', D = 100 'd', e = 53 '5', f = 102 'f', g = 55 '7', h = 104 'h', i = 57 '9', j = 106 'j', k = 66 'B', l = 108 'l', m = 68 'D'}"
+    print_struct ${name} 14 " = {a = 97 'a', b = 50 '2', c = 99 'c', D = 52 '4', e = 101 'e', f = 54 '6', g = 103 'g', h = 56 '8', i = 105 'i', j = 65 'A', k = 107 'k', l = 67 'C', m = 109 'm', n = 69 'E'}"
+    print_struct ${name} 15 " = {a = 49 '1', b = 98 'b', c = 51 '3', D = 100 'd', e = 53 '5', f = 102 'f', g = 55 '7', h = 104 'h', i = 57 '9', j = 106 'j', k = 66 'B', l = 108 'l', m = 68 'D', n = 110 'n', o = 70 'F'}"
+    print_struct ${name} 16 " = {a = 97 'a', b = 50 '2', c = 99 'c', D = 52 '4', e = 101 'e', f = 54 '6', g = 103 'g', h = 56 '8', i = 105 'i', j = 65 'A', k = 107 'k', l = 67 'C', m = 109 'm', n = 69 'E', o = 111 'o', p = 71 'G'}"
+    print_struct ${name} 17 " = {a = 49 '1', b = 98 'b', c = 51 '3', D = 100 'd', e = 53 '5', f = 102 'f', g = 55 '7', h = 104 'h', i = 57 '9', j = 106 'j', k = 66 'B', l = 108 'l', m = 68 'D', n = 110 'n', o = 70 'F', p = 112 'p', q = 72 'H'}"
+}
 
-if [target_info exists gdb,cannot_call_functions] {
-    setup_xfail "*-*-*" 2416
-    fail "This target can not call functions"
-    return 0
+# Simple test - all elements are the same size
+
+proc run_struct1_test { suffix type } {
+    global ws
+    start_structs_test 1${suffix} "additional_flags=-DtA=${suffix}"
+
+    if { ![runto_main] } then {
+	gdb_suppress_tests;
+    }
+
+    # check that the type is correct
+    gdb_test "ptype foo1.a" "type = ${type}" "ptype foo1.a for 1${suffix}"
+
+    do_function_calls 2${suffix};
+
+    gdb_stop_suppressing_tests;
 }
 
-if { ![runto_main] } then {
-    gdb_suppress_tests;
+run_struct1_test  tc "char"
+run_struct1_test  ts "short int"
+run_struct1_test  ti "int"
+run_struct1_test  tl "long int"
+run_struct1_test  tll "long long int"
+run_struct1_test  tf "float"
+run_struct1_test  td "double"
+run_struct1_test  tld "long double"
+
+# First element is something strange, rest are char
+
+proc run_struct2_test { suffix type } {
+    global ws
+    start_structs_test 2${suffix} "additional_flags=-DtA=${suffix} additional_flags=-DtB=tc"
+
+    if { ![runto_main] } then {
+	gdb_suppress_tests;
+    }
+
+    # check that the types are correct
+    gdb_test "ptype foo2.a" "type = ${type}" "ptype foo2.a for 2${suffix}"
+    gdb_test "ptype foo2.b" "type = char" "ptype foo2.b for 2${suffix}"
+
+    do_function_calls 2${suffix};
+
+    gdb_stop_suppressing_tests;
 }
 
-do_function_calls;
+run_struct2_test  ts "short int"
+run_struct2_test  ti "int"
+run_struct2_test  tl "long int"
+run_struct2_test  tll "long long int"
+run_struct2_test  tf "float"
+run_struct2_test  td "double"
+run_struct2_test  tld "long double"
+
+# First element is char, rest are something strange
+
+proc run_struct3_test { suffix type } {
+    global ws
+    start_structs_test 3${suffix} "additional_flags=-DtA=tc additional_flags=-DtB=${suffix}"
+
+    if { ![runto_main] } then {
+	gdb_suppress_tests;
+    }
+
+    # check that the types are correct
+    gdb_test "ptype foo3.a" "type = char" "ptype foo2.a for 3${suffix}"
+    gdb_test "ptype foo3.b" "type = ${type}" "ptype foo2.b for 3${suffix}"
+
+    do_function_calls 3${suffix};
+
+    gdb_stop_suppressing_tests;
+}
 
-gdb_stop_suppressing_tests;
+run_struct2_test  ts "short int"
+run_struct2_test  ti "int"
+run_struct2_test  tl "long int"
+run_struct2_test  tll "long long int"
+run_struct2_test  tf "float"
+run_struct2_test  td "double"
+run_struct2_test  tld "long double"
 
 return 0

^ permalink raw reply	[flat|nested] 18+ messages in thread
* Re: [patch/rfc] Rewrite "structs" testcase
@ 2003-11-06 17:33 Michael Elizabeth Chastain
  2003-11-06 18:49 ` Andrew Cagney
  2003-11-06 21:38 ` Michael Snyder
  0 siblings, 2 replies; 18+ messages in thread
From: Michael Elizabeth Chastain @ 2003-11-06 17:33 UTC (permalink / raw)
  To: ac131313, gdb-patches

I'm concerned about the use of "long long" in a test program.
What if someone uses a non-gcc Ansi C compiler?
But this doesn't look any worse than other tests, so okay.

In structs.exp, line 22:

  # This file was written by Jeff Law. (law@cygnus.com)

Add something like:

  # And rewritten by Andrew Cagney  (cagney@redhat.com)

I got a lot of FAILS with the new tests.
native i686-pc-linux-gnu, gdb HEAD, binutils 2.14.

                        PASS  FAIL
  gcc 2.95.3 -gdwarf-2  1086   138
  gcc 2.95.3 -gstabs+   1122   102
  gcc 3.3.2  -gdwarf-2  1122   102
  gcc 3.3.2  -gstabs+   1122   102

I have put up a tarball:

  ftp://ftp.shout.net/pub/users/mec/gdb/2003-11-06-2.tar.gz

There are a lot of duplicate test names too.  It would be good
to uniquify them.

Not proofread yet because of so many FAIL results.

Michael C

2003-11-05  Andrew Cagney  <cagney@redhat.com>

	* gdb.base/structs.exp: Update copyright.  Rewrite.
	* gdb.base/structs.c: Update copyright.  Rewrite.


^ permalink raw reply	[flat|nested] 18+ messages in thread
* Re: [patch/rfc] Rewrite "structs" testcase
@ 2003-11-06 19:10 Michael Elizabeth Chastain
  2003-11-06 20:22 ` Andrew Cagney
  0 siblings, 1 reply; 18+ messages in thread
From: Michael Elizabeth Chastain @ 2003-11-06 19:10 UTC (permalink / raw)
  To: ac131313; +Cc: gdb-patches

mec> # And rewritten by Andrew Cagney  (cagney@redhat.com)
ac> I'll just drop that.

Okay by me.

mec> There are a lot of duplicate test names too.  It would be good
mec> to uniquify them.
ac> Yes, working on it.  I can't see a way to fix things like "run_to_main" 
ac> though.

If you can get the low-hanging fruit then that is good enough
for now.

ac> Some debug info prints "long double", some prints "tld".  I've changed 
ac> whats printed to hopefully be something more robust ...

Sounds good.

ac> (gdb) FAIL: gdb.base/structs.exp: ptype foo1.a for 1tld
ac> p/c fun1()
ac> $1 = {a = 0x08044004c400000000000000}
ac> 
ac> Seems GDB and GCC disagree over how the i386 returns floating-point 
ac> values.  My "this will always work" test has found a bug in GDB - cool. 
ac> Note that the tests do all pass for PPC.

That's the kind of test I like to see!

Can you file a PR and then make the test KFAIL for i386,
with reference to the bug report.  My recollection of the
policy is: new PASS is good, new KFAIL is really good,
new FAIL is bad.

I'll keep the test bed warm.

Michael C


^ permalink raw reply	[flat|nested] 18+ messages in thread
* Re: [patch/rfc] Rewrite "structs" testcase
@ 2003-11-06 20:44 Michael Elizabeth Chastain
  2003-11-07 20:35 ` Andrew Cagney
  0 siblings, 1 reply; 18+ messages in thread
From: Michael Elizabeth Chastain @ 2003-11-06 20:44 UTC (permalink / raw)
  To: ac131313; +Cc: gdb-patches

Ah, this version is much beter.

The results are:

                        PASS  FAIL
  gcc 2.95.3 -gdwarf-2  290   3
  gcc 2.95.3 -gstabs+   290   3
  gcc 3.3.2  -gdwarf-2  290   3
  gcc 3.3.2  -gstabs+   290   3

The three FAIL results are:

  p/c fun1()^M
  $1 = {a = 0x08044004c400000000000000}^M
  (gdb) FAIL: gdb.base/structs.exp: p/c fun1() for call-tld 1

  p/c L1^M
  $3 = {a = 0x00004004c400000000000000}^M
  (gdb) FAIL: gdb.base/structs.exp: p/c L1 for call-tld 1

  p/c L1^M
  $1 = {a = 0 '\0'}^M
  (gdb) FAIL: gdb.base/structs.exp: p/c L1 for return-tc

All the test names are unique.

Michael C


^ permalink raw reply	[flat|nested] 18+ messages in thread
* Re: [patch/rfc] Rewrite "structs" testcase
@ 2003-11-08  1:05 Michael Elizabeth Chastain
  2003-11-09  1:22 ` Andrew Cagney
  0 siblings, 1 reply; 18+ messages in thread
From: Michael Elizabeth Chastain @ 2003-11-08  1:05 UTC (permalink / raw)
  To: ac131313; +Cc: gdb-patches

The results are:

			PASS  FAIL
  gcc 2.95.3 -gdwarf-2  544   40
  gcc 2.95.3 -gstabs+   544   40
  gcc 3.3.2  -gdwarf-2  540   44
  gcc 3.3.2  -gstabs+   544   40

The problem is in this code:

  # Now force a return.  Be careful to only produce one PASS/FAIL.
  send_gdb "return foo${n}\n"
  gdb_expect {
      -re  "Make fun${n} return now.*y or n. $" {
	  send_gdb "y\n"
	  gdb_expect {
	      -re "L${n} *= fun${n}.*${gdb_prompt} $" {
		  # Need to step off the function call
		  gdb_test "next" "L.* *= fun.*" "${test}"
	      }
	      -re "${gdb_prompt} $" {
		  pass "${test}"
	      }
	      timeout {
		  fail "${test} (timeout)"
	      }
	  }
      }
  }

First there are duplicate "${test}" names in the output,
and some of them PASS and some of them FAIL.  Confusion!

The real problem is what to do when the notorious
"location at which to store the function's return value is unknown"
happens.  If that message happens, perhaps it is a KFAIL because
gdb cannot do what the user asked.  Or perhaps it is okay because
a message was printed.  I'm leaning towards the KFAIL, myself.

But the next bit of code:

  # Finally check that the value returned ended up in "L${n}".
  setup_fails ${fails} gdb/1444
  gdb_test "p/c L${n}" " = [foo ${n}]" "${test}"

If "location unknown" has occurred, then it's not even worthwhile
to execute this at all.  Once gdb has informed the user about
"location unknown" then there should be no expectation on the
part of the user that the return value will get stored into memory.

Maybe gdb needs to print an additional message to make it
more clear to the user:

  The location at which to store the function's return value is unknown.
  If you continue, the return value that you specified will be ignored.
  Make fun1 return now? (y or n) y

Then in the test script, if you get "location unknown", issue a KFAIL
(or do whatever) and skip a test or two.

I put up a tarball here:

  ftp://ftp.shout.net/pub/users/mec/gdb/2003-11-06.tar.gz

(The filename is lame because I made 2003-11-06-2 yesterday).

Michael C


^ permalink raw reply	[flat|nested] 18+ messages in thread
* Re: [patch/rfc] Rewrite "structs" testcase
@ 2003-11-12 16:51 Michael Elizabeth Chastain
  0 siblings, 0 replies; 18+ messages in thread
From: Michael Elizabeth Chastain @ 2003-11-12 16:51 UTC (permalink / raw)
  To: ac131313; +Cc: gdb-patches

I'm getting 508 PASS / 71 KFAIL with three configurations,
but I'm getting 504 PASS / 4 FAIL / 71 KFAIL with gcc 3.3.2 -gdwarf-2.

The FAILs are

  # gcc 3.3.2, binutils 2.14, -gdwarf-2

  p/c fun2()
  $1 = {a = 97 'a', b = 0 '\0'}
  (gdb) FAIL: gdb.base/structs.exp: p/c fun2(); call 2 structs-tc-tll

  p/c L2
  $2 = {a = 97 'a', b = 0 '\0'}
  (gdb) FAIL: gdb.base/structs.exp: p/c L2; call 2 structs-tc-tll

  p/c fun2()
  $1 = {a = 97 'a', b = 0 '\0'}
  (gdb) FAIL: gdb.base/structs.exp: p/c fun2(); call 2 structs-tc-td

  p/c L2
  $2 = {a = 97 'a', b = 0 '\0'}
  (gdb) FAIL: gdb.base/structs.exp: p/c L2; call 2 structs-tc-td

Do these look like bugs in the script or bugs in gdb?  If they are
bugs in gdb then the test script is doing a good job.

Michael C


^ permalink raw reply	[flat|nested] 18+ messages in thread
* Re: [patch/rfc] Rewrite "structs" testcase
@ 2003-11-12 18:13 Michael Elizabeth Chastain
  2003-11-13 16:11 ` Andrew Cagney
  0 siblings, 1 reply; 18+ messages in thread
From: Michael Elizabeth Chastain @ 2003-11-12 18:13 UTC (permalink / raw)
  To: ac131313; +Cc: gdb-patches

Ah, I ran it again with my full spectrum of compilers.

  gcc 2.95.3
  gcc 3.2-7-rh
  gcc 3.3.2
  gcc gcc-3_3-branch
  gcc HEAD

With dwarf-2:
  gcc 3.3.2 and gcc gcc-3_3-branch gave the four extra FAILs.
  gcc 2.95.3, gcc 3.2-7-rh, and gcc HEAD gave pure PASS+KFAIL.

With stabs+
  All compilers gave pure PASS+KFAIL.

Since it PASSes with gcc HEAD I am more sanguine that the
questionable tests (the tests that FAIL with some gcc's)
are good tests.

Tarball with executable files, gdb.log, et cetera at

  ftp://ftp.shout.net/~mec/gdb/2003-11-10-structs.tar.gz

Michael C


^ permalink raw reply	[flat|nested] 18+ messages in thread
* Re: [patch/rfc] Rewrite "structs" testcase
@ 2003-11-12 18:30 Michael Elizabeth Chastain
  0 siblings, 0 replies; 18+ messages in thread
From: Michael Elizabeth Chastain @ 2003-11-12 18:30 UTC (permalink / raw)
  To: ac131313, mec.gnu; +Cc: gdb-patches

Err, I botched the URL for the test tarball.

  ftp://ftp.shout.net/pub/users/mec/gdb/2003-11-10-structs.tar.gz

Michael C


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2003-11-20 17:17 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-05 22:17 [patch/rfc] Rewrite "structs" testcase Andrew Cagney
2003-11-06 17:33 Michael Elizabeth Chastain
2003-11-06 18:49 ` Andrew Cagney
2003-11-06 21:38 ` Michael Snyder
2003-11-06 19:10 Michael Elizabeth Chastain
2003-11-06 20:22 ` Andrew Cagney
2003-11-06 20:44 Michael Elizabeth Chastain
2003-11-07 20:35 ` Andrew Cagney
2003-11-08  1:05 Michael Elizabeth Chastain
2003-11-09  1:22 ` Andrew Cagney
2003-11-10  0:32   ` Michael Elizabeth Chastain
2003-11-11 22:28     ` Andrew Cagney
2003-11-12 16:51 Michael Elizabeth Chastain
2003-11-12 18:13 Michael Elizabeth Chastain
2003-11-13 16:11 ` Andrew Cagney
2003-11-17 15:59   ` Andrew Cagney
2003-11-20 17:17     ` Andrew Cagney
2003-11-12 18:30 Michael Elizabeth Chastain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox