Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] testsuite/gdb.c++/ref-types.exp: use runto
@ 2001-03-04 15:25 Michael Elizabeth Chastain
  0 siblings, 0 replies; 31+ messages in thread
From: Michael Elizabeth Chastain @ 2001-03-04 15:25 UTC (permalink / raw)
  To: gdb-patches

This is Sunday Project Patch #5 (try #2).  This is unchanged from
the previous version, submitted 2001-02024, which received no response.

gdb.c++/ref-types.exp has several places with control logic like this:

  send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $"

      send_gdb "cont\n"
      gdb_expect {
	  -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" {
	      send_gdb "up\n"
	      gdb_expect {
		  -re ".*main.*$gdb_prompt $" {
		    pass "up from marker1"
		}
		  -re ".*$gdb_prompt $" {
		    fail "up from marker1"
		}
		  timeout { fail "up from marker1 (timeout)" }
	      }
	  }
	  -re "$gdb_prompt $" { fail "continue to marker1"  }
	  timeout { fail "(timeout) continue to marker1"  }
      }

With FSF g++ v3, I am getting output like this:

  Breakpoint 2, marker1() () at /vittone/fsf/2001-02-21/source-src/gdb/testsuite/gdb.c++/ref-types.cc:6
  6	}
  (gdb) FAIL: gdb.c++/ref-types.exp: continue to marker1

So the test script never issues the "up" command, the test script goes
off the rails, and every test FAILs.

The "marker1() ()" output is a v3 bug and I have filed PR gdb/34 about it.

This patch changes the test script to:

  if ![runto 'marker1'] then {
      perror "couldn't run to marker1"
      continue
  }

  gdb_test "up" ".*main.*" "up from marker1"

... which is shorter and cleaner anyways.  This enables the test script
to run its real tests, which proceed to PASS.  This fixes 60 FAILs,
leaving no FAILs for this test script.

Testing: tested on Red Hat Linux 6.2 native and Solaris 2.6 native with
g++ v2 and g++ v3.

OK to apply?

Michael

===

2001-02-24  Michael Chastain  <chastain@redhat.com>

	* gdb.c++/ref-types.exp: Change handwritten code to library
	function 'runto'.

===

Index: gdb/testsuite/gdb.c++/ref-types.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.c++/ref-types.exp,v
retrieving revision 1.3
diff -c -3 -p -r1.3 ref-types.exp
*** gdb/testsuite/gdb.c++/ref-types.exp	2000/12/05 23:57:36	1.3
--- gdb/testsuite/gdb.c++/ref-types.exp	2001/02/24 05:49:52
*************** if ![runto_main] then {
*** 54,123 ****
      continue
  }
  
! send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $"
! 
!     send_gdb "cont\n"
!     gdb_expect {
!         -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" {
!             send_gdb "up\n"
!             gdb_expect {
!                 -re ".*main.*$gdb_prompt $" {
! 		    pass "up from marker1"
! 		}
!                 -re ".*$gdb_prompt $" {
! 		    fail "up from marker1"
! 		}
!                 timeout { fail "up from marker1 (timeout)" }
!             }
!         }
!         -re "$gdb_prompt $" { fail "continue to marker1"  }
!         timeout { fail "(timeout) continue to marker1"  }
!     }
! 
! 
! proc gdb_start_again {} {
! global srcdir
! global subdir
! global binfile
! global gdb_prompt
! global decimal
! 
! gdb_start
! gdb_reinitialize_dir $srcdir/$subdir
! gdb_load ${binfile}
! 
! source ${binfile}.ci
! 
! #
! # set it up at a breakpoint so we can play with the variable values
! #
! if ![runto_main] then {
!     perror "couldn't run to breakpoint"
      continue
  }
  
! send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $"
  
!     send_gdb "cont\n"
!     gdb_expect {
!         -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" {
!             send_gdb "up\n"
!             gdb_expect {
!                 -re ".*main.*$gdb_prompt $" {
! 		    pass "up from marker1"
! 		}
!                 -re ".*$gdb_prompt $" {
! 		    fail "up from marker1"
! 		}
!                 timeout { fail "up from marker1 (timeout)" }
!             }
!         }
!         -re "$gdb_prompt $" { fail "continue to marker1"  }
!         timeout { fail "(timeout) continue to marker1"  }
      }
- }
  
  
  
  
  
--- 54,94 ----
      continue
  }
  
! if ![runto 'marker1'] then {
!     perror "couldn't run to marker1"
      continue
  }
  
! gdb_test "up" ".*main.*" "up from marker1 1"
  
! proc gdb_start_again {} {
!     global srcdir
!     global subdir
!     global binfile
!     global gdb_prompt
!     global decimal
! 
!     gdb_start
!     gdb_reinitialize_dir $srcdir/$subdir
!     gdb_load ${binfile}
! 
!     source ${binfile}.ci
! 
!     #
!     # set it up at a breakpoint so we can play with the variable values
!     #
!     if ![runto_main] then {
! 	perror "couldn't run to breakpoint"
! 	continue
      }
  
+     if ![runto 'marker1'] then {
+ 	perror "couldn't run to marker1"
+ 	continue
+     }
  
+     gdb_test "up" ".*main.*" "up from marker1 2"
+ }
  
  
  
*************** gdb_expect {
*** 289,315 ****
      timeout           { fail "(timeout) print value of ras\[3\]" }
    }
  
- 
- send_gdb "break f\n" ; gdb_expect -re ".*$gdb_prompt $"
  
!     send_gdb "cont\n"
!     gdb_expect {
!         -re "Break.* f \\(\\) at .*:$decimal.*$gdb_prompt $" {
!             send_gdb "up\n"
!             gdb_expect {
!                 -re ".*main2.*$gdb_prompt $" {
! 		    pass "up from f" 
! 		}
!                 -re ".*$gdb_prompt $" {
! 		    fail "up from f" 
! 		}
!                 timeout { fail "up from f (timeout)" }
!             }
!         }
!         -re "$gdb_prompt $" { fail "continue to f"  }
!         timeout { fail "(timeout) continue to f"  }
!     }
  
  
  send_gdb "print C\n"
  gdb_expect {
--- 260,272 ----
      timeout           { fail "(timeout) print value of ras\[3\]" }
    }
  
  
! if ![runto 'f'] then {
!     perror "couldn't run to f"
!     continue
! }
  
+ gdb_test "up" ".main2.*" "up from f"
  
  send_gdb "print C\n"
  gdb_expect {


^ permalink raw reply	[flat|nested] 31+ messages in thread
* Re: [RFA] testsuite/gdb.c++/ref-types.exp: use runto
@ 2001-03-17 14:37 Michael Elizabeth Chastain
  0 siblings, 0 replies; 31+ messages in thread
From: Michael Elizabeth Chastain @ 2001-03-17 14:37 UTC (permalink / raw)
  To: chastain, dberlin; +Cc: gdb-patches

Daniel Berlin writes:

> I think I can come up with a better heuristic.
> How bout i do a minimal symbol lookup on the address we think the
> virtual function is at, and make sure it's the start of some real
> function (and if you really want to go a bit further, i'll make sure
> it's a function in the class, or it's base classes)

That sounds good to me.

In the virtfunc.cc case, the test script calls pAe->f(), but gdb actually
calls VB::vvb, because it's using the wrong vtable.

When gdb goes off the wire, it winds up reading out of some memory
that's near the right memory.  The vtables appear close to each other
in memory so I think it will often pick a random word out of a random
nearby vtable.

Instead of, or in addition to, looking at the class membership, you
could look at the function name.  If the user calls "f", but gdb
wants to call "vvb", then it's always wrong.

Michael


^ permalink raw reply	[flat|nested] 31+ messages in thread
* Re: [RFA] testsuite/gdb.c++/ref-types.exp: use runto
@ 2001-03-17 12:42 Michael Elizabeth Chastain
  2001-03-17 15:31 ` Daniel Berlin
  0 siblings, 1 reply; 31+ messages in thread
From: Michael Elizabeth Chastain @ 2001-03-17 12:42 UTC (permalink / raw)
  To: chastain, dberlin; +Cc: cgf, gdb-patches

Hi Daniel,

> It's not "usually" erroneous, it's that virtfunc.cc is worst case.
> In reality, it works most of the time.

I tried this out with the canonical diamond class, and it did work in
all the cases I tried (gcc 2.95.2, gdb cvs 2001-03-17, red hat linux
native, stabs).

I spent some time looking at gdb with virtfunc.cc.  gdb is coming up
with a bizarre offset: it thinks the offset of the "A" object in class
"E" is 28, when it should be 0.  That's causing most (if not all) of
the problems.

Maybe this can be fixed without breaking something else.  I'm going
to investigate more.

Michael


^ permalink raw reply	[flat|nested] 31+ messages in thread
* Re: [RFA] testsuite/gdb.c++/ref-types.exp: use runto
@ 2001-03-17 12:35 Michael Elizabeth Chastain
  2001-03-17 14:23 ` Daniel Berlin
  0 siblings, 1 reply; 31+ messages in thread
From: Michael Elizabeth Chastain @ 2001-03-17 12:35 UTC (permalink / raw)
  To: dberlin, gdb-patches

Actually, I'm suggesting two things:

(1) In the gdb test suite, print FAIL when gdb gives a wrong answer.

(2) In gdb, figure out a cover set for the cases that fail, and
    don't execute those cases.
    
"virtual functions altogether" would certainly cover all the buggy cases,
but it's too broad.

Perhaps "virtual functions in for classes where the complete type has
a virtual base"?

Michael


^ permalink raw reply	[flat|nested] 31+ messages in thread
* Re: [RFA] testsuite/gdb.c++/ref-types.exp: use runto
@ 2001-03-16 21:00 Michael Elizabeth Chastain
  2001-03-17 11:12 ` Daniel Berlin
  0 siblings, 1 reply; 31+ messages in thread
From: Michael Elizabeth Chastain @ 2001-03-16 21:00 UTC (permalink / raw)
  To: cgf, gdb-patches

The test suite knows that gdb is printing erroneous information.

And gdb knows that it's doing something which is likely to be
erroneous.  It's better to not do that in the first place than return
data which is usually erroneous.

Michael


^ permalink raw reply	[flat|nested] 31+ messages in thread
* Re: [RFA] testsuite/gdb.c++/ref-types.exp: use runto
@ 2001-03-16 16:03 Michael Elizabeth Chastain
  0 siblings, 0 replies; 31+ messages in thread
From: Michael Elizabeth Chastain @ 2001-03-16 16:03 UTC (permalink / raw)
  To: dberlin, msnyder; +Cc: chastain, fnasser, fnasser, gdb-patches, Peter.Schauer

Michael Snyder asks:
> When are we going to stop doing that???

The new C++ ABI has a public multi-vendor specification:

  http://reality.sgi.com/dehnert_engr/cxx/cxx-summary.html

The existence of a spec is a very good thing for gdb.

Michael


^ permalink raw reply	[flat|nested] 31+ messages in thread
* Re: [RFA] testsuite/gdb.c++/ref-types.exp: use runto
@ 2001-03-16 14:50 Michael Elizabeth Chastain
  2001-03-16 14:55 ` Daniel Berlin
  0 siblings, 1 reply; 31+ messages in thread
From: Michael Elizabeth Chastain @ 2001-03-16 14:50 UTC (permalink / raw)
  To: chastain, fnasser; +Cc: dan, dberlin, fnasser, gdb-patches

Fernando Nasser writes:
> Something is broken.  It is just not GDB ;-)

Of course.  It's never GDB.  :)

Michael


^ permalink raw reply	[flat|nested] 31+ messages in thread
* Re: [RFA] testsuite/gdb.c++/ref-types.exp: use runto
@ 2001-03-16 14:49 Michael Elizabeth Chastain
  2001-03-16 14:55 ` Daniel Berlin
       [not found] ` <20010316215907.A3607@redhat.com>
  0 siblings, 2 replies; 31+ messages in thread
From: Michael Elizabeth Chastain @ 2001-03-16 14:49 UTC (permalink / raw)
  To: chastain, dberlin; +Cc: dan, fnasser, fnasser, gdb-patches

Daniel Berlin writes:
> Um, what exactly *should* it print?

Ah, you are thinking about gdb, and I am thinking about the test suite.

As long as gdb stays the way it is, the test suite should print "FAIL".

gdb should print "20".  If it can't print "20", then it should print
"that's too hard for me" (perhaps refuse to call functions in classes with
virtual bases).

> Fine, mark them fail. Just put (Won't ever fix for v2 abi) in parentheses.

That's fine.  Then the FAIL count will reflect the actual state of the
software.

Michael


^ permalink raw reply	[flat|nested] 31+ messages in thread
* Re: [RFA] testsuite/gdb.c++/ref-types.exp: use runto
@ 2001-03-16 14:35 Michael Elizabeth Chastain
  2001-03-16 14:40 ` Fernando Nasser
                   ` (2 more replies)
  0 siblings, 3 replies; 31+ messages in thread
From: Michael Elizabeth Chastain @ 2001-03-16 14:35 UTC (permalink / raw)
  To: dan, fnasser; +Cc: chastain, dberlin, fnasser, gdb-patches

Daniel Berlin writes:
> Insufficient information, too many possibilities, and
> too much of a performance hit.

Well, I'll see the information for myself when I get to virtfunc.exp
and see whether the stabs have sufficient information or not.

As far as "too many possibilities" and "too much of a performance hit"
goes: those are not good reasons for (a) the software to print wrong
answers and then (b) the maintainers to claim that the software isn't
broken.

Michael


^ permalink raw reply	[flat|nested] 31+ messages in thread
* Re: [RFA] testsuite/gdb.c++/ref-types.exp: use runto
@ 2001-03-16 13:15 Michael Elizabeth Chastain
  2001-03-16 13:21 ` Fernando Nasser
  0 siblings, 1 reply; 31+ messages in thread
From: Michael Elizabeth Chastain @ 2001-03-16 13:15 UTC (permalink / raw)
  To: chastain, dberlin; +Cc: fnasser, gdb-patches

Mmmm, a philosophical dispute.

Daniel Berlin writes:
> They need to be xfail'd for old-abi, but not for new-abi.

I believe that when gdb has a bug which is under its control, that the
test suite should issue a FAIL, not an XFAIL.

Here is a gdb log entry for gcc 2.95.2, gdb CVS, Red Hat Linux 7 native,
stabs:

  (gdb) print pAe->f()
  $1 = 134547192
  (gdb) XFAIL: gdb.c++/virtfunc.exp: print pAe->f()

If gdb said "I'm sorry, but pAe->f() is too complex for me", I would
accept that as an XFAIL.  But when gdb prints wrong answers, that should
be a FAIL.

I'm interested in other maintainer's opinions on this because I'm
planning to submit patches to change such XFAIL's to FAIL's, so that
the test suite can actually report what is broken in C++ support.

Michael


^ permalink raw reply	[flat|nested] 31+ messages in thread
[parent not found: <200103161807.KAA06081@bosch.cygnus.com>]
* [RFA] testsuite/gdb.c++/ref-types.exp: use runto
@ 2001-02-24  0:16 Michael Elizabeth Chastain
  0 siblings, 0 replies; 31+ messages in thread
From: Michael Elizabeth Chastain @ 2001-02-24  0:16 UTC (permalink / raw)
  To: gdb-patches

This is Sunday Project Patch #5.

gdb.c++/ref-types.exp has several places with control logic like this:

  send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $"

      send_gdb "cont\n"
      gdb_expect {
	  -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" {
	      send_gdb "up\n"
	      gdb_expect {
		  -re ".*main.*$gdb_prompt $" {
		    pass "up from marker1"
		}
		  -re ".*$gdb_prompt $" {
		    fail "up from marker1"
		}
		  timeout { fail "up from marker1 (timeout)" }
	      }
	  }
	  -re "$gdb_prompt $" { fail "continue to marker1"  }
	  timeout { fail "(timeout) continue to marker1"  }
      }

With FSF g++ v3, I am getting output like this:

  Breakpoint 2, marker1() () at /vittone/fsf/2001-02-21/source-src/gdb/testsuite/gdb.c++/ref-types.cc:6
  6	}
  (gdb) FAIL: gdb.c++/ref-types.exp: continue to marker1

So the test script never issues the "up" command, the test script goes
off the rails, and every test FAILs.

The "marker1() ()" output is a v3 bug and I have filed PR gdb/34 about it.

This patch changes the test script to:

  if ![runto 'marker1'] then {
      perror "couldn't run to marker1"
      continue
  }

  gdb_test "up" ".*main.*" "up from marker1"

... which is shorter and cleaner anyways.  This enables the test script
to run its real tests, which proceed to PASS.  This fixes 60 FAILs,
leaving no FAILs for this test script.

Testing: tested on Red Hat Linux 6.2 native, Red Hat Linux 7.0 native,
and Solaris 2.6 native with g++ v2 and g++ v3.

OK to apply?

Michael

===

2001-02-24  Michael Chastain  <chastain@redhat.com>

	* gdb.c++/ref-types.exp: Change handwritten code to library
	function 'runto'.

===

Index: gdb/testsuite/gdb.c++/ref-types.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.c++/ref-types.exp,v
retrieving revision 1.3
diff -c -3 -p -r1.3 ref-types.exp
*** gdb/testsuite/gdb.c++/ref-types.exp	2000/12/05 23:57:36	1.3
--- gdb/testsuite/gdb.c++/ref-types.exp	2001/02/24 05:49:52
*************** if ![runto_main] then {
*** 54,123 ****
      continue
  }
  
! send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $"
! 
!     send_gdb "cont\n"
!     gdb_expect {
!         -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" {
!             send_gdb "up\n"
!             gdb_expect {
!                 -re ".*main.*$gdb_prompt $" {
! 		    pass "up from marker1"
! 		}
!                 -re ".*$gdb_prompt $" {
! 		    fail "up from marker1"
! 		}
!                 timeout { fail "up from marker1 (timeout)" }
!             }
!         }
!         -re "$gdb_prompt $" { fail "continue to marker1"  }
!         timeout { fail "(timeout) continue to marker1"  }
!     }
! 
! 
! proc gdb_start_again {} {
! global srcdir
! global subdir
! global binfile
! global gdb_prompt
! global decimal
! 
! gdb_start
! gdb_reinitialize_dir $srcdir/$subdir
! gdb_load ${binfile}
! 
! source ${binfile}.ci
! 
! #
! # set it up at a breakpoint so we can play with the variable values
! #
! if ![runto_main] then {
!     perror "couldn't run to breakpoint"
      continue
  }
  
! send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $"
  
!     send_gdb "cont\n"
!     gdb_expect {
!         -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" {
!             send_gdb "up\n"
!             gdb_expect {
!                 -re ".*main.*$gdb_prompt $" {
! 		    pass "up from marker1"
! 		}
!                 -re ".*$gdb_prompt $" {
! 		    fail "up from marker1"
! 		}
!                 timeout { fail "up from marker1 (timeout)" }
!             }
!         }
!         -re "$gdb_prompt $" { fail "continue to marker1"  }
!         timeout { fail "(timeout) continue to marker1"  }
      }
- }
  
  
  
  
  
--- 54,94 ----
      continue
  }
  
! if ![runto 'marker1'] then {
!     perror "couldn't run to marker1"
      continue
  }
  
! gdb_test "up" ".*main.*" "up from marker1 1"
  
! proc gdb_start_again {} {
!     global srcdir
!     global subdir
!     global binfile
!     global gdb_prompt
!     global decimal
! 
!     gdb_start
!     gdb_reinitialize_dir $srcdir/$subdir
!     gdb_load ${binfile}
! 
!     source ${binfile}.ci
! 
!     #
!     # set it up at a breakpoint so we can play with the variable values
!     #
!     if ![runto_main] then {
! 	perror "couldn't run to breakpoint"
! 	continue
      }
  
+     if ![runto 'marker1'] then {
+ 	perror "couldn't run to marker1"
+ 	continue
+     }
  
+     gdb_test "up" ".*main.*" "up from marker1 2"
+ }
  
  
  
*************** gdb_expect {
*** 289,315 ****
      timeout           { fail "(timeout) print value of ras\[3\]" }
    }
  
- 
- send_gdb "break f\n" ; gdb_expect -re ".*$gdb_prompt $"
  
!     send_gdb "cont\n"
!     gdb_expect {
!         -re "Break.* f \\(\\) at .*:$decimal.*$gdb_prompt $" {
!             send_gdb "up\n"
!             gdb_expect {
!                 -re ".*main2.*$gdb_prompt $" {
! 		    pass "up from f" 
! 		}
!                 -re ".*$gdb_prompt $" {
! 		    fail "up from f" 
! 		}
!                 timeout { fail "up from f (timeout)" }
!             }
!         }
!         -re "$gdb_prompt $" { fail "continue to f"  }
!         timeout { fail "(timeout) continue to f"  }
!     }
  
  
  send_gdb "print C\n"
  gdb_expect {
--- 260,272 ----
      timeout           { fail "(timeout) print value of ras\[3\]" }
    }
  
  
! if ![runto 'f'] then {
!     perror "couldn't run to f"
!     continue
! }
  
+ gdb_test "up" ".main2.*" "up from f"
  
  send_gdb "print C\n"
  gdb_expect {


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

end of thread, other threads:[~2001-03-17 15:31 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-03-04 15:25 [RFA] testsuite/gdb.c++/ref-types.exp: use runto Michael Elizabeth Chastain
  -- strict thread matches above, loose matches on Subject: below --
2001-03-17 14:37 Michael Elizabeth Chastain
2001-03-17 12:42 Michael Elizabeth Chastain
2001-03-17 15:31 ` Daniel Berlin
2001-03-17 12:35 Michael Elizabeth Chastain
2001-03-17 14:23 ` Daniel Berlin
2001-03-16 21:00 Michael Elizabeth Chastain
2001-03-17 11:12 ` Daniel Berlin
2001-03-16 16:03 Michael Elizabeth Chastain
2001-03-16 14:50 Michael Elizabeth Chastain
2001-03-16 14:55 ` Daniel Berlin
2001-03-16 14:49 Michael Elizabeth Chastain
2001-03-16 14:55 ` Daniel Berlin
     [not found] ` <20010316215907.A3607@redhat.com>
2001-03-17 11:59   ` Daniel Berlin
2001-03-16 14:35 Michael Elizabeth Chastain
2001-03-16 14:40 ` Fernando Nasser
2001-03-16 14:43 ` Daniel Berlin
2001-03-16 14:44 ` Daniel Berlin
2001-03-16 13:15 Michael Elizabeth Chastain
2001-03-16 13:21 ` Fernando Nasser
2001-03-16 15:14   ` Peter.Schauer
2001-03-16 15:17     ` Daniel Berlin
2001-03-16 15:45       ` Michael Snyder
2001-03-16 15:49         ` Daniel Berlin
2001-03-16 15:19   ` Andrew Cagney
2001-03-16 15:21     ` Daniel Berlin
2001-03-17  7:56   ` Daniel Berlin
     [not found] <200103161807.KAA06081@bosch.cygnus.com>
2001-03-16 12:00 ` Fernando Nasser
2001-03-16 13:00 ` Daniel Berlin
2001-03-16 14:29   ` Michael Snyder
2001-02-24  0:16 Michael Elizabeth Chastain

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