Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Re: [rfa:testsuite} Overhaul sizeof.exp
@ 2002-02-20  8:59 Michael Elizabeth Chastain
  0 siblings, 0 replies; 27+ messages in thread
From: Michael Elizabeth Chastain @ 2002-02-20  8:59 UTC (permalink / raw)
  To: ac131313; +Cc: gdb-patches

> I think this one avoids any potential ``print/d (long double)1'' problems.

It does.  I give it a clean bill of health, all PASSes for the new tests.
Recommended for approval.

(We've got to sort out this XFAIL/KFAIL issue though.  You just wrote a
test that reveals a bug in gdb, and you had to take it out of the
test script!)

Michael C

2002-02-19  Andrew Cagney  <ac131313@redhat.com>

	* gdb.base/sizeof.c (main): Call fill_structs.  Print value of
	signed, unsigned and straight char.
	(padding_char, padding_short, padding_int, padding_long,
	padding_long_long, padding_float, padding_double,
	padding_long_double): New global variables.
	(fill, fill_structs): New functions.

	* gdb.base/sizeof.exp: Check for signed and unsigned char.  Check
	for correctly sized writes.  Update copyright.
	(get_valueof): New procedure.
	(get_sizeof): Call get_valueof.
	(check_valueof): New procedure.
	(check_padding): New procedure.


^ permalink raw reply	[flat|nested] 27+ messages in thread
* Re: [rfa:testsuite} Overhaul sizeof.exp
@ 2002-02-20 10:24 Michael Elizabeth Chastain
  2002-02-20 11:48 ` Fernando Nasser
  0 siblings, 1 reply; 27+ messages in thread
From: Michael Elizabeth Chastain @ 2002-02-20 10:24 UTC (permalink / raw)
  To: drow, fnasser; +Cc: ac131313, gdb-patches

Daniel Jacobowitz wrote:
> 
> As far as I'm concerned, the ideal path would be:
>   - Add KFAIL support.
>   - Add new failing tests that we can fix in GDB as KFAIL
>   - Change appropriate existing XFAILs to KFAILs, and document
>     BOTH XFAILS AND KFAILS!
> 

Fernando Nasser wrote:
> I agree that that is the ideal plan.  I don't know where I will find the
> time but I would be willing to try and come up with a 'kfail' patch
> if people really want it.

Okay, I'm on board with KFAIL.  I haven't heard anyone object to KFAIL.
I'll go write the Sunday Project support for it (I am on vacation today).

fn> I can discuss this with the Dejagnu author as well.  Do you guys want
fn> me to try and contact him?

Yes please.

Let's charge down the KFAIL path until it either works or we hit a
brick wall.

Michael C


^ permalink raw reply	[flat|nested] 27+ messages in thread
* Re: [rfa:testsuite} Overhaul sizeof.exp
@ 2002-02-20  9:49 Michael Elizabeth Chastain
  2002-02-20 10:06 ` Fernando Nasser
                   ` (2 more replies)
  0 siblings, 3 replies; 27+ messages in thread
From: Michael Elizabeth Chastain @ 2002-02-20  9:49 UTC (permalink / raw)
  To: fnasser; +Cc: ac131313, drow, gdb-patches

It sounds like we understand the alternatives and everyone's got opinions
about them.

  [0] Status quo
  [1] FAIL the test
  [2] XFAIL the test
  [3] KFAIL the test

I'm concerned that for each alternative, someone will find a flaw, and
therefore we'll stick with [0] and keep rejecting useful tests.

Fernando and Daniel and Andrew, I'd like to hold your feet to the fire:
Can you please rank these in priority order and indicate how many of the
high priority ones are acceptable.

Also there may very well be a [4] that I haven't heard of or thought of.

My rank is [2] > [1] > [3] > [0].  [2], [1], and [3] are acceptable to me.
[0] is not.

Michael C


^ permalink raw reply	[flat|nested] 27+ messages in thread
* Re: [rfa:testsuite} Overhaul sizeof.exp
@ 2002-02-20  9:17 Michael Elizabeth Chastain
  2002-02-20  9:42 ` Fernando Nasser
  2002-02-20 10:20 ` Andrew Cagney
  0 siblings, 2 replies; 27+ messages in thread
From: Michael Elizabeth Chastain @ 2002-02-20  9:17 UTC (permalink / raw)
  To: drow, fnasser; +Cc: ac131313, gdb-patches

Hmmm, let's start by looking at the alternatives.  Suppose someone writes
a new test that revels an unexpected bug in gdb (hi Andrew).

[0] Stqtus quo: we reject the test.
[1] FAIL it:  we accept the test and let it FAIL. 
[2] XFAIL it: we accept the test and mark it with XFAIL.
[3] KFAIL it: we accept the test and mark it with KFAIL.

I really want that test in the test suite.  If the test is in the test
suite, it gets run regularly in a lot of configurations.  Anyone can
check the status of the test just by reading the latest Sunday Project
errors-warnings-fails report.  Someone who tackles the bug has the saves
time when they start and when they finish.  And so on.

My preference order is [2] > [1] > [3] > [0].  All but [0] are
acceptable to me.

I understand that [1] has a problem because it looks similar to a
regression.  I don't see that in my tables because they distinguish
between "old test that PASSed before and FAILs now" and "new test with
no result before and FAILs now".  But I acknowledge that other people
oppose [1].

[3] has a problem because KFAIL does not exist.  If the senior maintainers
decide to approve [3] then I can add it to my analysis tables right away,
but someone will have to add it to dejagnu.

I agree with Daniel Jacobowitz; I think [2] is the right thing to do.
It's also practical because we can start today.

  @item XFAIL
  @kindex XFAIL
  @cindex expected failure
  @cindex failing test, expected
  A test failed, but it was expected to fail.  This result indicates no
  change in a known bug.  If a test fails because the operating system
  where the test runs lacks some facility required by the test, the
  outcome is @code{UNSUPPORTED} instead.

  @item UNSUPPORTED
  @kindex UNSUPPORTED
  @cindex unsupported test
  @cindex test, unsupported
  A test depends on a conditionally available feature that does not exist
  (in the configured testing environment).  For example, you can use this
  outcome to report on a test case that does not work on a particular
  target because its operating system support does not include a required
  subroutine.
  @end table

Michael C


^ permalink raw reply	[flat|nested] 27+ messages in thread
* Re: [rfa:testsuite} Overhaul sizeof.exp
@ 2002-02-19 20:57 Michael Elizabeth Chastain
  2002-02-20  6:57 ` Andrew Cagney
  0 siblings, 1 reply; 27+ messages in thread
From: Michael Elizabeth Chastain @ 2002-02-19 20:57 UTC (permalink / raw)
  To: ac131313; +Cc: gdb-patches

My test bed gives the same results: all the new tests PASS in all
configurations, except for that one long double test, which FAILs
in all configurations.

The value is the same in all ten configurations:

  $36 = 2505196557366531417849200640

The value from the previous patch was always:

  $36 = 2523330444660750855469793280

I don't think that's important; I'm just capturing the data.

Michael C

===

2002-02-19  Andrew Cagney  <ac131313@redhat.com>

	* gdb.base/sizeof.c (main): Call fill_structs.  Print value of
	signed, unsigned and straight char.
	(padding_char, padding_short, padding_int, padding_long,
	padding_long_long, padding_float, padding_double,
	padding_long_double): New global variables.
	(fill, fill_structs): New functions.

	* gdb.base/sizeof.exp: Check for signed and unsigned char.  Check
	for correctly sized writes.  Update copyright.
	(get_valueof): New procedure.
	(get_sizeof): Call get_valueof.
	(check_valueof): New procedure.
	(check_padding): New procedure.

Index: gdb.base/sizeof.c
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/sizeof.c,v
retrieving revision 1.2
diff -u -r1.2 sizeof.c
--- sizeof.c	2000/08/02 22:13:01	1.2
+++ sizeof.c	2002/02/20 01:49:56
@@ -1,8 +1,105 @@
 #include <stdio.h>
 
+typedef char padding[16];
+
+struct {
+  padding p1;
+  char v;
+  padding p2;
+} padding_char;
+
+struct {
+  padding p1;
+  short v;
+  padding p2;
+} padding_short;
+
+struct {
+  padding p1;
+  int v;
+  padding p2;
+} padding_int;
+
+struct {
+  padding p1;
+  long v;
+  padding p2;
+} padding_long;
+
+struct {
+  padding p1;
+  long long v;
+  padding p2;
+} padding_long_long;
+
+struct {
+  padding p1;
+  float v;
+  padding p2;
+} padding_float;
+
+struct {
+  padding p1;
+  double v;
+  padding p2;
+} padding_double;
+
+struct {
+  padding p1;
+  long double v;
+  padding p2;
+} padding_long_double;
+
+static void
+fill (void *buf, long sizeof_buf)
+{
+  char *p = buf;
+  int i;
+  for (i = 0; i < sizeof_buf; i++)
+    p[i] = "The quick brown dingo jumped over the layzy dog."[i];
+}
+
+void
+fill_structs (void)
+{
+  fill (&padding_char.p1, sizeof (padding));
+  fill (&padding_char.v, sizeof (padding_char.v));
+  fill (&padding_char.p2, sizeof (padding));
+
+  fill (&padding_short.p1, sizeof (padding));
+  fill (&padding_short.v, sizeof (padding_short.v));
+  fill (&padding_short.p2, sizeof (padding));
+
+  fill (&padding_int.p1, sizeof (padding));
+  fill (&padding_int.v, sizeof (padding_int.v));
+  fill (&padding_int.p2, sizeof (padding));
+
+  fill (&padding_long.p1, sizeof (padding));
+  fill (&padding_long.v, sizeof (padding_long.v));
+  fill (&padding_long.p2, sizeof (padding));
+
+  fill (&padding_long_long.p1, sizeof (padding));
+  fill (&padding_long_long.v, sizeof (padding_long_long.v));
+  fill (&padding_long_long.p2, sizeof (padding));
+
+  fill (&padding_float.p1, sizeof (padding));
+  fill (&padding_float.v, sizeof (padding_float.v));
+  fill (&padding_float.p2, sizeof (padding));
+
+  fill (&padding_double.p1, sizeof (padding));
+  fill (&padding_double.v, sizeof (padding_double.v));
+  fill (&padding_double.p2, sizeof (padding));
+
+  fill (&padding_long_double.p1, sizeof (padding));
+  fill (&padding_long_double.v, sizeof (padding_long_double.v));
+  fill (&padding_long_double.p2, sizeof (padding));
+}
+
 int
 main ()
 {
+  fill_structs ();
+
   printf ("sizeof (char) == %d\n", sizeof (char));
   printf ("sizeof (short) == %d\n", sizeof (short));
   printf ("sizeof (int) == %d\n", sizeof (int));
@@ -15,5 +112,11 @@
   printf ("sizeof (float) == %d\n", sizeof (float));
   printf ("sizeof (double) == %d\n", sizeof (double));
   printf ("sizeof (long double) == %d\n", sizeof (long double));
+
+  /* Signed char?  */
+  printf ("valueof ((int) (char) -1) == %d\n", (int) (char) -1);
+  printf ("valueof ((int) (signed char) -1) == %d\n", (int) (signed char) -1);
+  printf ("valueof ((int) (unsigned char) -1) == %d\n", (int) (unsigned char) -1);
+
   return 0;
 }
Index: gdb.base/sizeof.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/sizeof.exp,v
retrieving revision 1.3
diff -u -r1.3 sizeof.exp
--- sizeof.exp	2001/03/06 08:21:51	1.3
+++ sizeof.exp	2002/02/20 01:49:56
@@ -1,4 +1,4 @@
-# Copyright 2000 Free Software Foundation, Inc.
+# Copyright 2000, 2002 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
@@ -56,22 +56,28 @@
 # Query GDB for the size of various types
 #
 
-proc get_sizeof { type default } {
+proc get_valueof { exp default } {
     global gdb_prompt
-    send_gdb "print/d sizeof (${type})\n"
+    send_gdb "print/d ${exp}\n"
     gdb_expect {
-	-re "\\$\[0-9\]* = (\[0-9\]*).*$gdb_prompt $" {
-	    set size $expect_out(1,string)
-	    pass "get sizeof ${type} ($size)"
+	-re "\\$\[0-9\]* = (\[-\]*\[0-9\]*).*$gdb_prompt $" {
+	    set val $expect_out(1,string)
+	    pass "get value of ${exp} ($val)"
 	}
 	timeout {
 	    set size ${default}
-	    fail "get sizeof ${type} (timeout)"
+	    fail "get value of ${exp} (timeout)"
 	}
     }
-    return ${size}
+    return ${val}
+}
+
+proc get_sizeof { type default } {
+    return [get_valueof "sizeof (${type})" $default]
 }
 
+gdb_test "next"
+
 set sizeof_char [get_sizeof "char" 1]
 set sizeof_short [get_sizeof "short" 2]
 set sizeof_int [get_sizeof "int" 4]
@@ -85,7 +91,6 @@
 set sizeof_double [get_sizeof "double" 8]
 set sizeof_long_double [get_sizeof "long double" 8]
 
-
 #
 # Compare GDB's idea of types with the running program
 #
@@ -97,10 +102,10 @@
 	return;
     }
 
-    set pat [string_to_regexp ${type}]
+    set pat [string_to_regexp "sizeof (${type}) == ${size}"]
     send_gdb "next\n"
     gdb_expect {
-	-re "sizeof \\(${pat}\\) == ${size}\[\r\n\].*$gdb_prompt $" {
+	-re "${pat}\[\r\n\].*$gdb_prompt $" {
 	    pass "check sizeof ${type} == ${size}"
 	}
 	-re ".*$gdb_prompt $" {
@@ -125,6 +130,59 @@
 check_sizeof "double" ${sizeof_double}
 check_sizeof "long double" ${sizeof_long_double}
 
+proc check_valueof { exp val } {
+    global gdb_prompt
+
+    if [gdb_skip_stdio_test "check valueof $exp == $val"] {
+	return;
+    }
+
+    set pat [string_to_regexp "valueof (${exp}) == ${val}"]
+    send_gdb "next\n"
+    gdb_expect {
+	-re "${pat}\[\r\n\].*$gdb_prompt $" {
+	    pass "check valueof ${exp} == ${val}"
+	}
+	-re ".*$gdb_prompt $" {
+	    fail "check valueof ${exp} == ${val}"
+	}
+	timeout {
+	    fail "check valueof ${exp} == ${val} (timeout)"
+	}
+    }
+}
+
+# Check that GDB and the target agree over the sign of a character.
+
+set signof_char [get_valueof "(int) (char) -1" -1]
+set signof_signed_char [get_valueof "(int) (signed char) -1" -1]
+set signof_unsigned_char [get_valueof "(int) (unsigned char) -1" -1]
+
+check_valueof "(int) (char) -1" ${signof_char}
+check_valueof "(int) (signed char) -1" ${signof_signed_char}
+check_valueof "(int) (unsigned char) -1" ${signof_unsigned_char}
+
+proc check_padding { type val } {
+    global gdb_prompt
+    gdb_test "set padding_${type}.v = ${val}"
+    gdb_test "print padding_${type}.p1" "= \"The quick brown \""
+    gdb_test "print/d padding_${type}.v" "= ${val}"
+    gdb_test "print padding_${type}.p2" "\"The quick brown \".*"
+}
+
+# Check that GDB is managing to store a value in a struct field
+# without corrupting the fields immediately adjacent to it.
+
+check_padding "char" 1
+check_padding "short" 2
+check_padding "int" 4
+check_padding "long" 4
+check_padding "long_long" 8
+
+# use multiples of two which can be represented exactly
+check_padding "float" 1
+check_padding "double" 2
+check_padding "long_double" 4
 
 #
 # For reference, dump out the entire architecture

--------------000300030605080106010205--


^ permalink raw reply	[flat|nested] 27+ messages in thread
* Re: [rfa:testsuite} Overhaul sizeof.exp
@ 2002-02-19 20:43 Michael Elizabeth Chastain
  2002-02-21 14:03 ` Jim Blandy
  0 siblings, 1 reply; 27+ messages in thread
From: Michael Elizabeth Chastain @ 2002-02-19 20:43 UTC (permalink / raw)
  To: ac131313; +Cc: gdb-patches

Hi Andrew,

> Unfortunatly it doesn't address the x86 problem.  Looking at 
> printcmd.c:print_scalar_formatted() the function behaves differently 
> when sizeof (host LONGEST) < sizeof (target type) (i.e. x86) :-(  I 
> think this a very long standing bug.
> 
> The problem I guess is what to do short term with this part of the test.

My opinion is that if a test finds a bug, it is a good test.  A really
great test causes the machine to reboot, catch on fire, and install
Windows XP from a Russian warez mirror.

Here is some policy from gcc:

  http://gcc.gnu.org/bugs.html#manage

I think this would be a good policy for gdb.  What do you think?

I will re-run my test bed on the new patch shortly.

Michael C


^ permalink raw reply	[flat|nested] 27+ messages in thread
* Re: [rfa:testsuite} Overhaul sizeof.exp
@ 2002-02-19 15:46 Michael Elizabeth Chastain
  2002-02-19 18:19 ` Andrew Cagney
  0 siblings, 1 reply; 27+ messages in thread
From: Michael Elizabeth Chastain @ 2002-02-19 15:46 UTC (permalink / raw)
  To: ac131313, gdb-patches

A nit: there is an extraneous change to call-ar-st.exp.

Bigger nit: the ChangeLog says that it's about sizeof.exp, but the patch
includes changes to sizeof.c.

The real feedback: I threw it in the native i686-pc-linux-gnu test bed
for a quick before-and-after,   Nothing broke, but one of the
the new tests FAILs in all configurations.

  FAIL: gdb.base/sizeof.exp: print/d padding_long_double.v = 4
    target=native, host=i686-pc-linux-gnu%rh-7.2, gdb=HEAD%2002-02-16, gcc=2.95.3, goption=-gdwarf-2
    target=native, host=i686-pc-linux-gnu%rh-7.2, gdb=HEAD%2002-02-16, gcc=2.95.3, goption=-gstabs+
    target=native, host=i686-pc-linux-gnu%rh-7.2, gdb=HEAD%2002-02-16, gcc=3.0.3, goption=-gdwarf-2
    target=native, host=i686-pc-linux-gnu%rh-7.2, gdb=HEAD%2002-02-16, gcc=3.0.3, goption=-gstabs+
    target=native, host=i686-pc-linux-gnu%rh-7.2, gdb=HEAD%2002-02-16, gcc=3.0.4-20020215, goption=-gdwarf-2
    target=native, host=i686-pc-linux-gnu%rh-7.2, gdb=HEAD%2002-02-16, gcc=3.0.4-20020215, goption=-gstabs+
    target=native, host=i686-pc-linux-gnu%rh-7.2, gdb=HEAD%2002-02-16, gcc=gcc-3_0-branch%2002-02-16, goption=-dwarf-2
    target=native, host=i686-pc-linux-gnu%rh-7.2, gdb=HEAD%2002-02-16, gcc=gcc-3_0-branch%2002-02-16, goption=-gstabs+
    target=native, host=i686-pc-linux-gnu%rh-7.2, gdb=HEAD%2002-02-16, gcc=HEAD%2002-02-16, goption=-dwarf-2
    target=native, host=i686-pc-linux-gnu%rh-7.2, gdb=HEAD%2002-02-16, gcc=HEAD%2002-02-16, goption=-gstabs+

Here is a log excerpt:

  # target=native, host=i686-pc-linux-gnu%rh-7.2, gdb=HEAD%2002-02-16, gcc=3.0.3, goption=-gstabs+
  print padding_long_double.p1^M
  $35 = "The quick brown "^M
  (gdb) PASS: gdb.base/sizeof.exp: print padding_long_double.p1
  print/d padding_long_double.v = 4^M
  $36 = 2523330444660750855469793280^M
  (gdb) FAIL: gdb.base/sizeof.exp: print/d padding_long_double.v = 4
  print padding_long_double.p2^M
  $37 = "The quick brown "^M
  (gdb) PASS: gdb.base/sizeof.exp: print padding_long_double.p2

All 10 gdb.log files have the same constant value for $36.

Michael C


^ permalink raw reply	[flat|nested] 27+ messages in thread
* [rfa:testsuite} Overhaul sizeof.exp
@ 2002-02-19 15:17 Andrew Cagney
  0 siblings, 0 replies; 27+ messages in thread
From: Andrew Cagney @ 2002-02-19 15:17 UTC (permalink / raw)
  To: gdb-patches

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

[oops, I posted this but to the wrong address.  Explains why no one saw it]

Hello,

This patch overhauls sizeof.exp adding more ``this could never fail
tests''.  In particular:

	checks char, signed char, unsigned char
	checks stores don't corrupt memory

Ok?  I've checked it in an unsigned char target (PPC).

Andrew


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

2002-02-16  Andrew Cagney  <ac131313@redhat.com>

	* gdb.base/sizeof.exp (get_valueof): Revise.  Check for signed and
	unsigned char.  Check for correctly sized writes.  Update copyright.

Index: gdb.base/call-ar-st.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/call-ar-st.exp,v
retrieving revision 1.11
diff -p -r1.11 call-ar-st.exp
*** call-ar-st.exp	2002/01/06 14:42:39	1.11
--- call-ar-st.exp	2002/02/17 00:41:08
***************
*** 1,4 ****
! #   Copyright 1998, 1999, 2000, 2001
  #   Free Software Foundation, Inc.
  
  # This program is free software; you can redistribute it and/or modify
--- 1,4 ----
! #   Copyright 1998, 1999, 2000, 2001, 2002
  #   Free Software Foundation, Inc.
  
  # This program is free software; you can redistribute it and/or modify
Index: gdb.base/sizeof.c
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/sizeof.c,v
retrieving revision 1.2
diff -p -r1.2 sizeof.c
*** sizeof.c	2000/08/02 22:13:01	1.2
--- sizeof.c	2002/02/17 00:41:08
***************
*** 1,8 ****
--- 1,90 ----
  #include <stdio.h>
  
+ typedef char padding[16];
+ 
+ struct {
+   padding p1;
+   char v;
+   padding p2;
+ } padding_char;
+ 
+ struct {
+   padding p1;
+   short v;
+   padding p2;
+ } padding_short;
+ 
+ struct {
+   padding p1;
+   int v;
+   padding p2;
+ } padding_int;
+ 
+ struct {
+   padding p1;
+   long v;
+   padding p2;
+ } padding_long;
+ 
+ struct {
+   padding p1;
+   long long v;
+   padding p2;
+ } padding_long_long;
+ 
+ struct {
+   padding p1;
+   float v;
+   padding p2;
+ } padding_float;
+ 
+ struct {
+   padding p1;
+   double v;
+   padding p2;
+ } padding_double;
+ 
+ struct {
+   padding p1;
+   long double v;
+   padding p2;
+ } padding_long_double;
+ 
+ static void
+ fill (void *buf, long sizeof_buf)
+ {
+   char *p = buf;
+   int i;
+   for (i = 0; i < sizeof_buf; i++)
+     p[i] = "The quick brown dingo jumped over the layzy dog."[i];
+ }
+ 
+ void
+ fill_structs (void)
+ {
+   fill (&padding_char.p1, sizeof (padding));
+   fill (&padding_char.p2, sizeof (padding));
+   fill (&padding_short.p1, sizeof (padding));
+   fill (&padding_short.p2, sizeof (padding));
+   fill (&padding_int.p1, sizeof (padding));
+   fill (&padding_int.p2, sizeof (padding));
+   fill (&padding_long.p1, sizeof (padding));
+   fill (&padding_long.p2, sizeof (padding));
+   fill (&padding_long_long.p1, sizeof (padding));
+   fill (&padding_long_long.p2, sizeof (padding));
+   fill (&padding_float.p1, sizeof (padding));
+   fill (&padding_float.p2, sizeof (padding));
+   fill (&padding_double.p1, sizeof (padding));
+   fill (&padding_double.p2, sizeof (padding));
+   fill (&padding_long_double.p1, sizeof (padding));
+   fill (&padding_long_double.p2, sizeof (padding));
+ }
+ 
  int
  main ()
  {
+   fill_structs ();
+ 
    printf ("sizeof (char) == %d\n", sizeof (char));
    printf ("sizeof (short) == %d\n", sizeof (short));
    printf ("sizeof (int) == %d\n", sizeof (int));
*************** main ()
*** 15,19 ****
--- 97,107 ----
    printf ("sizeof (float) == %d\n", sizeof (float));
    printf ("sizeof (double) == %d\n", sizeof (double));
    printf ("sizeof (long double) == %d\n", sizeof (long double));
+ 
+   /* Signed char?  */
+   printf ("valueof ((int) (char) -1) == %d\n", (int) (char) -1);
+   printf ("valueof ((int) (signed char) -1) == %d\n", (int) (signed char) -1);
+   printf ("valueof ((int) (unsigned char) -1) == %d\n", (int) (unsigned char) -1);
+ 
    return 0;
  }
Index: gdb.base/sizeof.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/sizeof.exp,v
retrieving revision 1.3
diff -p -r1.3 sizeof.exp
*** sizeof.exp	2001/03/06 08:21:51	1.3
--- sizeof.exp	2002/02/17 00:41:08
*************** if ![runto_main] then {
*** 56,77 ****
  # Query GDB for the size of various types
  #
  
! proc get_sizeof { type default } {
      global gdb_prompt
!     send_gdb "print/d sizeof (${type})\n"
      gdb_expect {
! 	-re "\\$\[0-9\]* = (\[0-9\]*).*$gdb_prompt $" {
! 	    set size $expect_out(1,string)
! 	    pass "get sizeof ${type} ($size)"
  	}
  	timeout {
  	    set size ${default}
! 	    fail "get sizeof ${type} (timeout)"
  	}
      }
!     return ${size}
  }
  
  set sizeof_char [get_sizeof "char" 1]
  set sizeof_short [get_sizeof "short" 2]
  set sizeof_int [get_sizeof "int" 4]
--- 56,83 ----
  # Query GDB for the size of various types
  #
  
! proc get_valueof { exp default } {
      global gdb_prompt
!     send_gdb "print/d ${exp}\n"
      gdb_expect {
! 	-re "\\$\[0-9\]* = (\[-\]*\[0-9\]*).*$gdb_prompt $" {
! 	    set val $expect_out(1,string)
! 	    pass "get value of ${exp} ($val)"
  	}
  	timeout {
  	    set size ${default}
! 	    fail "get value of ${exp} (timeout)"
  	}
      }
!     return ${val}
! }
! 
! proc get_sizeof { type default } {
!     return [get_valueof "sizeof (${type})" $default]
  }
  
+ gdb_test "next"
+ 
  set sizeof_char [get_sizeof "char" 1]
  set sizeof_short [get_sizeof "short" 2]
  set sizeof_int [get_sizeof "int" 4]
*************** set sizeof_float [get_sizeof "float" 4]
*** 85,91 ****
  set sizeof_double [get_sizeof "double" 8]
  set sizeof_long_double [get_sizeof "long double" 8]
  
- 
  #
  # Compare GDB's idea of types with the running program
  #
--- 91,96 ----
*************** proc check_sizeof { type size } {
*** 97,106 ****
  	return;
      }
  
!     set pat [string_to_regexp ${type}]
      send_gdb "next\n"
      gdb_expect {
! 	-re "sizeof \\(${pat}\\) == ${size}\[\r\n\].*$gdb_prompt $" {
  	    pass "check sizeof ${type} == ${size}"
  	}
  	-re ".*$gdb_prompt $" {
--- 102,111 ----
  	return;
      }
  
!     set pat [string_to_regexp "sizeof (${type}) == ${size}"]
      send_gdb "next\n"
      gdb_expect {
! 	-re "${pat}\[\r\n\].*$gdb_prompt $" {
  	    pass "check sizeof ${type} == ${size}"
  	}
  	-re ".*$gdb_prompt $" {
*************** check_sizeof "float" ${sizeof_float}
*** 125,130 ****
--- 130,188 ----
  check_sizeof "double" ${sizeof_double}
  check_sizeof "long double" ${sizeof_long_double}
  
+ proc check_valueof { exp val } {
+     global gdb_prompt
+ 
+     if [gdb_skip_stdio_test "check valueof $exp == $val"] {
+ 	return;
+     }
+ 
+     set pat [string_to_regexp "valueof (${exp}) == ${val}"]
+     send_gdb "next\n"
+     gdb_expect {
+ 	-re "${pat}\[\r\n\].*$gdb_prompt $" {
+ 	    pass "check valueof ${exp} == ${val}"
+ 	}
+ 	-re ".*$gdb_prompt $" {
+ 	    fail "check valueof ${exp} == ${val}"
+ 	}
+ 	timeout {
+ 	    fail "check valueof ${exp} == ${val} (timeout)"
+ 	}
+     }
+ }
+ 
+ # Check that GDB and the target agree over the sign of a character.
+ 
+ set signof_char [get_valueof "(int) (char) -1" -1]
+ set signof_signed_char [get_valueof "(int) (signed char) -1" -1]
+ set signof_unsigned_char [get_valueof "(int) (unsigned char) -1" -1]
+ 
+ check_valueof "(int) (char) -1" ${signof_char}
+ check_valueof "(int) (signed char) -1" ${signof_signed_char}
+ check_valueof "(int) (unsigned char) -1" ${signof_unsigned_char}
+ 
+ proc check_padding { type val } {
+     global gdb_prompt
+     gdb_test "set padding_${type}.v = ${val}"
+     gdb_test "print padding_${type}.p1" "= \"The quick brown \""
+     gdb_test "print/d padding_${type}.v = ${val}" "= ${val}"
+     gdb_test "print padding_${type}.p2" "\"The quick brown \".*"
+ }
+ 
+ # Check that GDB is managing to store a value in a struct field
+ # without corrupting the fields immediately adjacent to it.
+ 
+ check_padding "char" 1
+ check_padding "short" 2
+ check_padding "int" 4
+ check_padding "long" 4
+ check_padding "long_long" 8
+ 
+ # use multiples of two which can be represented exactly
+ check_padding "float" 1
+ check_padding "double" 2
+ check_padding "long_double" 4
  
  #
  # For reference, dump out the entire architecture

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

end of thread, other threads:[~2002-02-21 22:23 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-20  8:59 [rfa:testsuite} Overhaul sizeof.exp Michael Elizabeth Chastain
  -- strict thread matches above, loose matches on Subject: below --
2002-02-20 10:24 Michael Elizabeth Chastain
2002-02-20 11:48 ` Fernando Nasser
2002-02-20  9:49 Michael Elizabeth Chastain
2002-02-20 10:06 ` Fernando Nasser
2002-02-20 10:12   ` Daniel Jacobowitz
2002-02-20 10:07 ` Daniel Jacobowitz
2002-02-20 10:18   ` Fernando Nasser
2002-02-20 10:07 ` Richard Earnshaw
2002-02-20  9:17 Michael Elizabeth Chastain
2002-02-20  9:42 ` Fernando Nasser
2002-02-20 10:20 ` Andrew Cagney
2002-02-19 20:57 Michael Elizabeth Chastain
2002-02-20  6:57 ` Andrew Cagney
2002-02-20  7:21   ` Andrew Cagney
2002-02-20  8:19     ` Fernando Nasser
2002-02-20 17:57       ` Andrew Cagney
2002-02-20  8:16   ` Fernando Nasser
2002-02-20  8:51     ` Daniel Jacobowitz
2002-02-20  9:24       ` Fernando Nasser
2002-02-21 14:04       ` Jim Blandy
2002-02-21 14:23         ` Daniel Jacobowitz
2002-02-19 20:43 Michael Elizabeth Chastain
2002-02-21 14:03 ` Jim Blandy
2002-02-19 15:46 Michael Elizabeth Chastain
2002-02-19 18:19 ` Andrew Cagney
2002-02-19 15:17 Andrew Cagney

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