* 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:49 [rfa:testsuite} Overhaul sizeof.exp 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:07 ` Richard Earnshaw
2 siblings, 1 reply; 27+ messages in thread
From: Fernando Nasser @ 2002-02-20 10:06 UTC (permalink / raw)
To: Michael Elizabeth Chastain; +Cc: ac131313, drow, gdb-patches
I can take a look at the KFAIL stuff this weekend if you want.
But if the ample majority wants to try again [2] and is willing to
work in establishing polices to try and make that work
this time and is willing to help enforcing those polices I would
agree with that.
So, I am for [3]->[2']->[0']
2' - [2] with extrict polices to prevent xfails to be forgotten.
0' - [0] but the tests are saved somewhere, so they are added
when the fix goes in.
Fernando
Michael Elizabeth Chastain wrote:
>
> 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
--
Fernando Nasser
Red Hat Canada Ltd. E-Mail: fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario M4P 2C9
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [rfa:testsuite} Overhaul sizeof.exp
2002-02-20 9:49 [rfa:testsuite} Overhaul sizeof.exp Michael Elizabeth Chastain
2002-02-20 10:06 ` Fernando Nasser
@ 2002-02-20 10:07 ` Daniel Jacobowitz
2002-02-20 10:18 ` Fernando Nasser
2002-02-20 10:07 ` Richard Earnshaw
2 siblings, 1 reply; 27+ messages in thread
From: Daniel Jacobowitz @ 2002-02-20 10:07 UTC (permalink / raw)
To: Michael Elizabeth Chastain; +Cc: fnasser, ac131313, gdb-patches
On Wed, Feb 20, 2002 at 11:49:47AM -0600, Michael Elizabeth Chastain wrote:
> 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.
[3] is best for me. I disagreed with Fernando's claim that we are using
XFAIL the way DejaGNU defines it; I do not disagree that we need more
granularity. [1] is barely tolerable. [2] and [0] are not.
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!
--
Daniel Jacobowitz Carnegie Mellon University
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [rfa:testsuite} Overhaul sizeof.exp
2002-02-20 9:49 [rfa:testsuite} Overhaul sizeof.exp Michael Elizabeth Chastain
2002-02-20 10:06 ` Fernando Nasser
2002-02-20 10:07 ` Daniel Jacobowitz
@ 2002-02-20 10:07 ` Richard Earnshaw
2 siblings, 0 replies; 27+ messages in thread
From: Richard Earnshaw @ 2002-02-20 10:07 UTC (permalink / raw)
To: gdb-patches; +Cc: Richard.Earnshaw
mec@shout.net said:
> 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
Well, speaking personally, I don't particularly like XFAIL because it
hides failures from me. Since I rarely see a run with zero FAILs the only
thing that is interesting is a diff between this and a previous run, to
tell me if an existing test has started failing, or whether a new test has
been added.
About the only reasonable use of XFAIL that I can think of is when we fail
because there was a bug in an external tool (such as the compiler) which
means we are unable to successfully run the test (but haven't failed so
badly as to get an UNRESOLVED -- we know the outcome we know its wrong,
but we know its because of an external problem). Everything else should
be a FAIL, because its our fault and we *should* fix it.
R.
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [rfa:testsuite} Overhaul sizeof.exp
2002-02-20 10:06 ` Fernando Nasser
@ 2002-02-20 10:12 ` Daniel Jacobowitz
0 siblings, 0 replies; 27+ messages in thread
From: Daniel Jacobowitz @ 2002-02-20 10:12 UTC (permalink / raw)
To: Fernando Nasser; +Cc: Michael Elizabeth Chastain, ac131313, gdb-patches
On Wed, Feb 20, 2002 at 01:05:38PM -0500, Fernando Nasser wrote:
> I can take a look at the KFAIL stuff this weekend if you want.
>
> But if the ample majority wants to try again [2] and is willing to
> work in establishing polices to try and make that work
> this time and is willing to help enforcing those polices I would
> agree with that.
>
> So, I am for [3]->[2']->[0']
>
> 2' - [2] with extrict polices to prevent xfails to be forgotten.
I agree with Fernando at this point (except that I consider 0'
unacceptable).
Fernando, I'd really appreciate it if you investigated KFAILs.
--
Daniel Jacobowitz Carnegie Mellon University
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [rfa:testsuite} Overhaul sizeof.exp
2002-02-20 10:07 ` Daniel Jacobowitz
@ 2002-02-20 10:18 ` Fernando Nasser
0 siblings, 0 replies; 27+ messages in thread
From: Fernando Nasser @ 2002-02-20 10:18 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: Michael Elizabeth Chastain, 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!
>
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.
I can discuss this with the Dejagnu author as well. Do you guys want
me to try and contact him?
--
Fernando Nasser
Red Hat Canada Ltd. E-Mail: fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario M4P 2C9
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [rfa:testsuite} Overhaul sizeof.exp
2002-02-21 14:04 ` Jim Blandy
@ 2002-02-21 14:23 ` Daniel Jacobowitz
0 siblings, 0 replies; 27+ messages in thread
From: Daniel Jacobowitz @ 2002-02-21 14:23 UTC (permalink / raw)
To: gdb-patches
On Thu, Feb 21, 2002 at 05:04:41PM -0500, Jim Blandy wrote:
>
> Ach! I was about to remark that this seems to be the longest thread
> to which Daniel Jacobowitz has not contributed. :)
<clasps at his heart and dies>
Oh, a low blow! My soul is wounded beyond repair!
--
Daniel Jacobowitz Carnegie Mellon University
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [rfa:testsuite} Overhaul sizeof.exp
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
1 sibling, 1 reply; 27+ messages in thread
From: Jim Blandy @ 2002-02-21 14:04 UTC (permalink / raw)
To: Daniel Jacobowitz
Cc: Fernando Nasser, Andrew Cagney, Michael Elizabeth Chastain, gdb-patches
Ach! I was about to remark that this seems to be the longest thread
to which Daniel Jacobowitz has not contributed. :)
^ 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, 0 replies; 27+ messages in thread
From: Jim Blandy @ 2002-02-21 14:03 UTC (permalink / raw)
To: Michael Elizabeth Chastain; +Cc: ac131313, gdb-patches
Michael Elizabeth Chastain <mec@shout.net> writes:
> 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.
*LOL*
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [rfa:testsuite} Overhaul sizeof.exp
2002-02-20 8:19 ` Fernando Nasser
@ 2002-02-20 17:57 ` Andrew Cagney
0 siblings, 0 replies; 27+ messages in thread
From: Andrew Cagney @ 2002-02-20 17:57 UTC (permalink / raw)
To: Fernando Nasser; +Cc: Michael Elizabeth Chastain, gdb-patches
>
> If Michael has no more objections it is OK with me.
>
> Thanks to Andrew for the new tests and to Michael for reviewing it.
Thanks. It is in.
Andrew
^ 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, 0 replies; 27+ messages in thread
From: Fernando Nasser @ 2002-02-20 11:48 UTC (permalink / raw)
To: Michael Elizabeth Chastain; +Cc: drow, ac131313, gdb-patches
Michael Elizabeth Chastain wrote:
>
> fn> I can discuss this with the Dejagnu author as well. Do you guys want
> fn> me to try and contact him?
>
> Yes please.
>
I sent Rob Savoy (the creator and maintainer of DejaGNU) a message.
We have our own copy but it would be nice to keep the changes minimal
and Rob may have some suggestions as well.
--
Fernando Nasser
Red Hat Canada Ltd. E-Mail: fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario M4P 2C9
^ 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:17 Michael Elizabeth Chastain
2002-02-20 9:42 ` Fernando Nasser
@ 2002-02-20 10:20 ` Andrew Cagney
1 sibling, 0 replies; 27+ messages in thread
From: Andrew Cagney @ 2002-02-20 10:20 UTC (permalink / raw)
To: Michael Elizabeth Chastain; +Cc: drow, fnasser, gdb-patches
A foot note.
GDB contains ``setup_xfail ...'' both for limitations in the OS and for
targets that are broken. I obsoleted the biggest offender - a29k -
however there are others. A clean slate on that one may be in order.
enjoy,
Andrew
^ 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
1 sibling, 0 replies; 27+ messages in thread
From: Fernando Nasser @ 2002-02-20 9:42 UTC (permalink / raw)
To: Michael Elizabeth Chastain; +Cc: drow, ac131313, gdb-patches
Michael Elizabeth Chastain wrote:
>
> 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.
I agree that this is not good.
> [1] FAIL it: we accept the test and let it FAIL.
Makes it harder for engineers to check if a toolchain is healthy.
> [2] XFAIL it: we accept the test and mark it with XFAIL.
It will be forgotten in the middle of so many other XFAILs.
> [3] KFAIL it: we accept the test and mark it with KFAIL.
>
With this one you can have a script that produces a "Release Notes"
section with the known bugs by retrieving the bug description from
the database (based on the bug id mentioned in the KFAIL).
The list of KFAILs corresponds to the bugs we all should be trying to
fix (and that we can fix in GDB independently from any fixes to
compilers,
operation systems, etc.)
> [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.
>
It is just copy and paste xfail code and add a bit to force the bug id
to be
mandatory.
> I agree with Daniel Jacobowitz; I think [2] is the right thing to do.
This same discussion keeps coming back. We discovered by trial and
error that XFAILing things only serves to hide them.
But if everybody wants to try again, lets enforce some very stringent
police using the Gnats/Bugzilla database so that the XFAILs are tracked
and removed when the fix is in.
> It's also practical because we can start today.
>
I don't think this is a good argument. This has a long time impact
and we should not do it the "easy" way. We once xfailed things in
mass and it did not go very well. If we are going to do it lets do
it very cautiously, after discussing how effective our enforcement
police can be.
--
Fernando Nasser
Red Hat Canada Ltd. E-Mail: fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario M4P 2C9
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [rfa:testsuite} Overhaul sizeof.exp
2002-02-20 8:51 ` Daniel Jacobowitz
@ 2002-02-20 9:24 ` Fernando Nasser
2002-02-21 14:04 ` Jim Blandy
1 sibling, 0 replies; 27+ messages in thread
From: Fernando Nasser @ 2002-02-20 9:24 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: Andrew Cagney, Michael Elizabeth Chastain, gdb-patches
Daniel Jacobowitz wrote:
>
> On Wed, Feb 20, 2002 at 11:15:44AM -0500, Fernando Nasser wrote:
> > Andrew Cagney wrote:
> > >
> > > The XFAIL policy is different to GDB. GDB interprets XFAILs to mean not
> > > supported due to something outside of GDB's control. Not this is a bug
> > > but we're not fixing it at present.
> > >
> >
> > Gdb follows the Dejagnu intended meaning for XFAILs.
>
> Really? I think you mean that GCC does. From the DejaGNU manual:
>
> `XFAIL'
> 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 `UNSUPPORTED' instead.
>
> XFAILS are intended to represent known bugs, and we should be using
> UNSUPPORTED more heavily.
>
"lacks some facility required by the test" means something that the OS
or
run environment does not support and will never support because it is
just not the way things are done on that type of system.
We should _not_ be using UNSUPPORTED at large.
"This result indicates no change in a known bug." This sentence is too
ambiguous. I guess you can twist it in any way you want.
The GDB meaning for "A test failed, but it was expected to fail", for
many
years now, has been that there is a problem in the OS/runtime
environment
that will cause it to fail. That is why it is normally marked as xfail
for some specific target triplet.
I guess the reasoning was that nobody normally "expects" something to
fail,
we expect something to work. We only expect it to fail when there is
something
beyond our control that will cause it to fail and that we hope will be
fixed
(and things suddenly become XPASSes).
Anyway, who has the right interpretation or not is irrelevant. We do
have
two distinct situations and it would be nice to be able to handle them
accordingly.
--
Fernando Nasser
Red Hat Canada Ltd. E-Mail: fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario M4P 2C9
^ 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-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 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
0 siblings, 2 replies; 27+ messages in thread
From: Daniel Jacobowitz @ 2002-02-20 8:51 UTC (permalink / raw)
To: Fernando Nasser; +Cc: Andrew Cagney, Michael Elizabeth Chastain, gdb-patches
On Wed, Feb 20, 2002 at 11:15:44AM -0500, Fernando Nasser wrote:
> Andrew Cagney wrote:
> >
> > The XFAIL policy is different to GDB. GDB interprets XFAILs to mean not
> > supported due to something outside of GDB's control. Not this is a bug
> > but we're not fixing it at present.
> >
>
> Gdb follows the Dejagnu intended meaning for XFAILs.
Really? I think you mean that GCC does. From the DejaGNU manual:
`XFAIL'
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 `UNSUPPORTED' instead.
XFAILS are intended to represent known bugs, and we should be using
UNSUPPORTED more heavily.
> We've noticed that we need something else for "Known bugs"
> long ago. I suggested that we should create the KFAILs for that,
> which would be documented with a bug database reference.
>
> I still think we should do that.
I agree on the documenting part at least.
--
Daniel Jacobowitz Carnegie Mellon University
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [rfa:testsuite} Overhaul sizeof.exp
2002-02-20 7:21 ` Andrew Cagney
@ 2002-02-20 8:19 ` Fernando Nasser
2002-02-20 17:57 ` Andrew Cagney
0 siblings, 1 reply; 27+ messages in thread
From: Fernando Nasser @ 2002-02-20 8:19 UTC (permalink / raw)
To: Andrew Cagney; +Cc: Michael Elizabeth Chastain, gdb-patches
Andrew Cagney wrote:
>
> I think this one avoids any potential ``print/d (long double)1'' problems.
>
> enjoy,
> Andrew
>
If Michael has no more objections it is OK with me.
Thanks to Andrew for the new tests and to Michael for reviewing it.
Fernando
> ------------------------------------------------------------------------
> 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 -p -r1.2 sizeof.c
> *** sizeof.c 2000/08/02 22:13:01 1.2
> --- sizeof.c 2002/02/20 15:15:17
> ***************
> *** 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));
> *************** main ()
> *** 15,19 ****
> --- 112,122 ----
> 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/20 15:15:17
> ***************
> *** 1,4 ****
> ! # Copyright 2000 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
> --- 1,4 ----
> ! # 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
> *************** 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 { fmt exp default } {
> global gdb_prompt
> ! send_gdb "print${fmt} ${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 "/d" "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 "/d" "(int) (char) -1" -1]
> + set signof_signed_char [get_valueof "/d" "(int) (signed char) -1" -1]
> + set signof_unsigned_char [get_valueof "/d" "(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 { fmt type val } {
> + global gdb_prompt
> + gdb_test "set padding_${type}.v = ${val}"
> + gdb_test "print padding_${type}.p1" "= \"The quick brown \""
> + gdb_test "print${fmt} 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 "/d" "char" 1
> + check_padding "/d" "short" 2
> + check_padding "/d" "int" 4
> + check_padding "/d" "long" 4
> + check_padding "/d" "long_long" 8
> +
> + # use multiples of two which can be represented exactly
> + check_padding "/f" "float" 1
> + check_padding "/f" "double" 2
> + check_padding "/f" "long_double" 4
>
> #
> # For reference, dump out the entire architecture
--
Fernando Nasser
Red Hat Canada Ltd. E-Mail: fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario M4P 2C9
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [rfa:testsuite} Overhaul sizeof.exp
2002-02-20 6:57 ` Andrew Cagney
2002-02-20 7:21 ` Andrew Cagney
@ 2002-02-20 8:16 ` Fernando Nasser
2002-02-20 8:51 ` Daniel Jacobowitz
1 sibling, 1 reply; 27+ messages in thread
From: Fernando Nasser @ 2002-02-20 8:16 UTC (permalink / raw)
To: Andrew Cagney; +Cc: Michael Elizabeth Chastain, gdb-patches
Andrew Cagney wrote:
>
> The XFAIL policy is different to GDB. GDB interprets XFAILs to mean not
> supported due to something outside of GDB's control. Not this is a bug
> but we're not fixing it at present.
>
Gdb follows the Dejagnu intended meaning for XFAILs.
We've noticed that we need something else for "Known bugs"
long ago. I suggested that we should create the KFAILs for that,
which would be documented with a bug database reference.
I still think we should do that.
--
Fernando Nasser
Red Hat Canada Ltd. E-Mail: fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario M4P 2C9
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [rfa:testsuite} Overhaul sizeof.exp
2002-02-20 6:57 ` Andrew Cagney
@ 2002-02-20 7:21 ` Andrew Cagney
2002-02-20 8:19 ` Fernando Nasser
2002-02-20 8:16 ` Fernando Nasser
1 sibling, 1 reply; 27+ messages in thread
From: Andrew Cagney @ 2002-02-20 7:21 UTC (permalink / raw)
To: Andrew Cagney; +Cc: Michael Elizabeth Chastain, gdb-patches
[-- Attachment #1: Type: text/plain, Size: 90 bytes --]
I think this one avoids any potential ``print/d (long double)1'' problems.
enjoy,
Andrew
[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 8639 bytes --]
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 -p -r1.2 sizeof.c
*** sizeof.c 2000/08/02 22:13:01 1.2
--- sizeof.c 2002/02/20 15:15:17
***************
*** 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));
*************** main ()
*** 15,19 ****
--- 112,122 ----
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/20 15:15:17
***************
*** 1,4 ****
! # Copyright 2000 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
--- 1,4 ----
! # 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
*************** 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 { fmt exp default } {
global gdb_prompt
! send_gdb "print${fmt} ${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 "/d" "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 "/d" "(int) (char) -1" -1]
+ set signof_signed_char [get_valueof "/d" "(int) (signed char) -1" -1]
+ set signof_unsigned_char [get_valueof "/d" "(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 { fmt type val } {
+ global gdb_prompt
+ gdb_test "set padding_${type}.v = ${val}"
+ gdb_test "print padding_${type}.p1" "= \"The quick brown \""
+ gdb_test "print${fmt} 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 "/d" "char" 1
+ check_padding "/d" "short" 2
+ check_padding "/d" "int" 4
+ check_padding "/d" "long" 4
+ check_padding "/d" "long_long" 8
+
+ # use multiples of two which can be represented exactly
+ check_padding "/f" "float" 1
+ check_padding "/f" "double" 2
+ check_padding "/f" "long_double" 4
#
# For reference, dump out the entire architecture
^ 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
2002-02-20 7:21 ` Andrew Cagney
2002-02-20 8:16 ` Fernando Nasser
0 siblings, 2 replies; 27+ messages in thread
From: Andrew Cagney @ 2002-02-20 6:57 UTC (permalink / raw)
To: Michael Elizabeth Chastain; +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
Yes. I poked a finger in that pie recently by getting approval to
commit a test that demonstrated a regression! (Wswitch.c)
The XFAIL policy is different to GDB. GDB interprets XFAILs to mean not
supported due to something outside of GDB's control. Not this is a bug
but we're not fixing it at present.
Anyway, what we're looking at here isn't a regression - it is just wierd.
> 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
I had a bit of a think. I'm going to change the test so that it avoids
the /d problem. I figure I'm trying to test GDB vs TARGET sizes, not
printf. I'll bug report the above problem.
Patch shortly.
Andrew
^ 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, 0 replies; 27+ messages in thread
From: Andrew Cagney @ 2002-02-19 18:19 UTC (permalink / raw)
To: Michael Elizabeth Chastain; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1901 bytes --]
> A nit: there is an extraneous change to call-ar-st.exp.
How did that sneak its way in :-( Ulgh, I updated the copyright on the
wrong file (I'll try to blame emacs ...).
> Bigger nit: the ChangeLog says that it's about sizeof.exp, but the patch
> includes changes to sizeof.c.
Will fix.
> 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.
(evil laughter :-) The print/d statement was wrong - it should not
include the assignment and instead should look like:
(gdb) PASS: gdb.base/sizeof.exp: print padding_double.p2
set padding_long_double.v = 4
(gdb) PASS: gdb.base/sizeof.exp: set padding_long_double.v = 4
print padding_long_double.p1
$35 = "The quick brown "
(gdb) PASS: gdb.base/sizeof.exp: print padding_long_double.p1
print/d padding_long_double.v
$36 = 4
(gdb) PASS: gdb.base/sizeof.exp: print/d padding_long_double.v
print padding_long_double.p2
$37 = "The quick brown "
(gdb) PASS: gdb.base/sizeof.exp: print padding_long_double.p2
The attached includes that fixes.
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.
sigh,
Andrew
(updated change attached)
[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 7424 bytes --]
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
^ 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 9:49 [rfa:testsuite} Overhaul sizeof.exp 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
-- 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:17 Michael Elizabeth Chastain
2002-02-20 9:42 ` Fernando Nasser
2002-02-20 10:20 ` Andrew Cagney
2002-02-20 8:59 Michael Elizabeth Chastain
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