Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] testsuite/gdb.c++/cplusfuncs.{exp,cc}: work with either g++ demangler
@ 2001-02-11 15:49 Michael Elizabeth Chastain
  2001-02-12 12:12 ` Michael Snyder
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Elizabeth Chastain @ 2001-02-11 15:49 UTC (permalink / raw)
  To: gdb-patches

This is Sunday Sourceware patch #2, revision 2.

Changes since revision 1:
  - Change wording of ChangeLog with respect to gdb/19.
  - Change one more "char *" to "$dm_type_char_star".

gdb has two g++ demanglers.  Currently, this test script works okay on
the v2 demangler, but gives 83 FAILs with the v3 demangler.  This patch
enhances testsuite/gdb.c++/cplusfuncs.{cc,exp} to work with either
demangler.

The bulk of the change is handling formatting differences:

  old demangler         new demangler
  --- ---------		--- ---------
  "operator, "          "operator,"
  "char *"              "char*"
  "int *"               "int*"
  "long *"              "long*"
  "void *"              "void*"
  "foo &"               "foo&"
  "unsigned int"        "unsigned"
  "void"                ""

While working on this test script, I discovered two bugs in gdb.
I have filed bug reports in gnats:

  gdb/18  gdb can't parse "info func operator*" or "info func operator\*"
  gdb/19  gdb v3 demangler fails on hairyfunc5 hairyfunc6 hairyfunc7

gdb/18 occurs with both demanglers (it is not a demangler bug).  The test
script used to XFAIL some tests and had strange code in other tests to
accomodate the bug.  That's not how a gdb test script is supposed to deal
with gdb bugs!  I changed the script to issue the correct commands and
FAIL if they don't work.  This causes 5 new FAILs with either demangler.

The new FAILs caused by the bug in gdb/18 are:

  FAIL: gdb.c++/cplusfuncs.exp: info function for "operator*("
  FAIL: gdb.c++/cplusfuncs.exp: info function for "operator*=("
  FAIL: gdb.c++/cplusfuncs.exp: info function for "operator->*("
  FAIL: gdb.c++/cplusfuncs.exp: info function for "operator[]("
  FAIL: gdb.c++/cplusfuncs.exp: info function for "operator char *("

gdb/19 is a bug in the v3 demangler.  If the v3 demangler is used, there
are 3 new FAILs.  If the v2 demangler is used, there are no new FAILs.

The new FAILs caused by the bug in gdb/19 are:

  FAIL: gdb.c++/cplusfuncs.exp: print &'hairyfunc5'
  FAIL: gdb.c++/cplusfuncs.exp: print &'hairyfunc6'
  FAIL: gdb.c++/cplusfuncs.exp: print &'hairyfunc7'

Testing: I tested on Red Hat Linux 7 native and Solaris 2.6 native.
On each platform, I ran before-and-after tests with both the v2 demangler
(using an older compiler) and the v3 demangler (using the sourceware cvs
gcc compiler).

OK to apply?

Michael Elizabeth Chastain
<chastain@redhat.com>
"love without fear"

===

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

	* gdb.c++/cplusfuncs.cc (dm_type_char_star): New function
	helps the test script figure out which demangler is in use.
	(dm_type_foo_ref): Ditto.
	(dm_type_int_star): Ditto.
	(dm_type_long_star): Ditto.
	(dm_type_unsigned_int): Ditto.
	(dm_type_void): Ditto.
	(dm_type_void_star): Ditto.
	* gdb.base/cplusfuncs.exp (probe_demangler): New function.
	Probe the gdb demangler and set variables to accommodate
	formatting differences.
	(info_func_regexp): New function.  Same as info_func, but
	matches against a regexp.
	(info_func): Match against a literal string.
	(print_addr_2): New function.  Match against a literal string,
	which can be different from the input to gdb.
	(print_addr): Simply call print_addr_2 with the same argument twice.
	(test_lookup_operator_functions): Use demangler formatting variables.
	Blow away the xfails and workarounds for gnats gdb bug gdb/18.  Sort
	the tests in the same order as the C++ class declaration.
	(test_paddr_operator_functions): Ditto.
	(test_paddr_overloaded_functions): Ditto.
	(test_paddr_hairy_functions): Use demangler formatting variables.
	Add reference to gdb/19 for related tests.
	(do_tests): Call probe_demangler.

===

Index: gdb/testsuite/gdb.c++/cplusfuncs.cc
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.c++/cplusfuncs.cc,v
retrieving revision 1.1.1.3
diff -c -3 -p -r1.1.1.3 cplusfuncs.cc
*** cplusfuncs.cc	1999/08/02 23:46:53	1.1.1.3
--- cplusfuncs.cc	2001/02/11 23:37:20
*************** int	  hairyfunc4 (PFPFPc_s_i arg)		{ arg
*** 183,185 ****
--- 183,196 ----
  int	  hairyfunc5 (PFPc_PFl_i arg)		{ arg = 0; return 0; }
  int	  hairyfunc6 (PFPi_PFl_i arg)		{ arg = 0; return 0; }
  int	  hairyfunc7 (PFPFPc_i_PFl_i arg)	{ arg = 0; return 0; }
+ 
+ /* gdb has two demanglers (one for g++ 2.95, one for g++ 3).
+    These marker functions help me figure out which demangler is in use. */
+ 
+ int	dm_type_char_star (char * p)		{ return (int) p; }
+ int	dm_type_foo_ref (foo & foo)		{ return foo.ifoo; }
+ int	dm_type_int_star (int * p)		{ return (int) p; }
+ int	dm_type_long_star (long * p)		{ return (int) p; }
+ int	dm_type_unsigned_int (unsigned int i)	{ return i; }
+ int	dm_type_void (void)			{ return 0; }
+ int	dm_type_void_star (void * p)		{ return (int) p; }
Index: gdb/testsuite/gdb.c++/cplusfuncs.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.c++/cplusfuncs.exp,v
retrieving revision 1.1.1.3
diff -c -3 -p -r1.1.1.3 cplusfuncs.exp
*** cplusfuncs.exp	1999/09/09 00:00:27	1.1.1.3
--- cplusfuncs.exp	2001/02/11 23:37:21
***************
*** 1,4 ****
! # Copyright (C) 1992, 1997, 1999 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 (C) 1992, 1997, 1999, 2001 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
***************
*** 18,23 ****
--- 18,24 ----
  # bug-gdb@prep.ai.mit.edu
  
  # This file was written by Fred Fish. (fnf@cygnus.com)
+ # Adapted for g++ 3.0 ABI by Michael Chastain. (chastain@redhat.com)
  
  if $tracelevel then {
  	strace $tracelevel
*************** if  { [gdb_compile "${srcdir}/${subdir}/
*** 38,100 ****
  }
  
  #
! #  Cause gdb to lookup a specific C++ function and print the demangled
! #  form.
  #
  
! proc info_func { regex demangled } {
      global gdb_prompt
  
!     send_gdb "info function $regex\n"
      gdb_expect {
! 	-re "File .*:\r\n$demangled\r\n.*$gdb_prompt $" {
! 	    pass "info function for \"$regex\""
  	}
! 	-re "File .*:\r\nclass $demangled\r\n.*$gdb_prompt $" {
! 	    pass "info function for \"$regex\""
  	}
  	-re ".*$gdb_prompt $" {
! 	    fail "info function for \"$regex\""
  	}
  	timeout {
! 	    fail "info function for \"$regex\" (timeout)"
  	}
      }
  }
  
  #
! #  Run print &'$arg' on the input arg and verify that we can correctly
! #  lookup the fully qualified C++ function.
! #  We ignore the return type of the function since we are only interested
! #  in the rootname and arguments part.
  #
  
! proc print_addr_of { arg } {
      global gdb_prompt
      global hex
  
!     set pattern [string_to_regexp $arg]
!     send_gdb "print &'$arg'\n"
      gdb_expect {
! 	-re ".* = .* $hex <$pattern>\r\n$gdb_prompt $" { pass "print &'$arg'" }
  	-re ".*$gdb_prompt $" {
! 	    fail "print &'$arg'"
  	}
  	timeout {
! 	    fail "print &'$arg' (timeout)"
  	}
      }
  }
  
  #
  # Test name demangling for operators.
  #
  # The '(' at the end of each regex input pattern is so that we match only
  # the one we are looking for.  I.E. "operator&" would match both
  # "operator&(foo &)" and "operator&&(foo &)".
  #
  
  proc test_lookup_operator_functions {} {
  
      # These tests don't work for COFF targets; don't even try them
      if [istarget "a29k-*-udi"] then {
--- 39,309 ----
  }
  
  #
! # g++ changed its ABI between 2.95 and 3.0.  gdb has two demanglers
! # for the two different styles.  The two demanglers have some subtle
! # discrepancies in their output.
  #
+ # I probe for the forms in use.
+ # The defaults are for the v3 demangler.
+ #
+ 
+ set dm_operator_comma		","
+ set dm_type_char_star		"char*"
+ set dm_type_foo_ref 		"foo&"
+ set dm_type_int_star		"int*"
+ set dm_type_long_star		"long*"
+ set dm_type_unsigned_int	"unsigned"
+ set dm_type_void		""
+ set dm_type_void_star		"void*"
  
! proc probe_demangler { } {
      global gdb_prompt
+     global dm_operator_comma
+     global dm_type_char_star
+     global dm_type_foo_ref
+     global dm_type_int_star
+     global dm_type_long_star
+     global dm_type_unsigned_int
+     global dm_type_void
+     global dm_type_void_star
+ 
+     send_gdb "print &'foo::operator,(foo&)'\n"
+     gdb_expect {
+ 	-re ".*foo::operator, \\(.*foo.*&.*\\).*\r\n$gdb_prompt $" {
+ 	    # v2 demangler
+ 	    set dm_operator_comma ", "
+ 	    pass "detect dm_operator_comma"
+ 	}
+ 	-re ".*foo::operator,\\(.*foo.*&.*\\).*\r\n$gdb_prompt $" {
+ 	    # v3 demangler
+ 	    pass "detect dm_operator_comma"
+ 	}
+ 	-re ".*$gdb_prompt $" {
+ 	    fail "detect dm_operator_comma"
+ 	}
+ 	timeout {
+ 	    fail "detect dm_operator_comma"
+ 	}
+     }
+ 
+     send_gdb "print &'dm_type_char_star'\n"
+     gdb_expect {
+ 	-re ".*dm_type_char_star\\(char \\*\\).*\r\n$gdb_prompt $" {
+ 	    # v2 demangler
+ 	    set dm_type_char_star "char *"
+ 	    pass "detect dm_type_char_star"
+ 	}
+ 	-re ".*dm_type_char_star\\(char\\*\\).*\r\n$gdb_prompt $" {
+ 	    # v3 demangler
+ 	    pass "detect dm_type_char_star"
+ 	}
+ 	-re ".*$gdb_prompt $" {
+ 	    fail "detect dm_type_char_star"
+ 	}
+ 	timeout {
+ 	    fail "detect dm_type_char_star (timeout)"
+ 	}
+     }
  
!     send_gdb "print &'dm_type_foo_ref'\n"
      gdb_expect {
! 	-re ".*dm_type_foo_ref\\(foo &\\).*\r\n$gdb_prompt $" {
! 	    # v2 demangler
! 	    set dm_type_foo_ref "foo &"
! 	    pass "detect dm_type_foo_ref"
  	}
! 	-re ".*dm_type_foo_ref\\(foo&\\).*\r\n$gdb_prompt $" {
! 	    # v3 demangler
! 	    pass "detect dm_type_foo_ref"
  	}
  	-re ".*$gdb_prompt $" {
! 	    fail "detect dm_type_foo_ref"
  	}
  	timeout {
! 	    fail "detect dm_type_foo_ref (timeout)"
  	}
      }
+ 
+     send_gdb "print &'dm_type_int_star'\n"
+     gdb_expect {
+ 	-re ".*dm_type_int_star\\(int \\*\\).*\r\n$gdb_prompt $" {
+ 	    # v2 demangler
+ 	    set dm_type_int_star "int *"
+ 	    pass "detect dm_type_int_star"
+ 	}
+ 	-re ".*dm_type_int_star\\(int\\*\\).*\r\n$gdb_prompt $" {
+ 	    # v3 demangler
+ 	    pass "detect dm_type_int_star"
+ 	}
+ 	-re ".*$gdb_prompt $" {
+ 	    fail "detect dm_type_int_star"
+ 	}
+ 	timeout {
+ 	    fail "detect dm_type_int_star (timeout)"
+ 	}
+     }
+ 
+     send_gdb "print &'dm_type_long_star'\n"
+     gdb_expect {
+ 	-re ".*dm_type_long_star\\(long \\*\\).*\r\n$gdb_prompt $" {
+ 	    # v2 demangler
+ 	    set dm_type_long_star "long *"
+ 	    pass "detect dm_type_long_star"
+ 	}
+ 	-re ".*dm_type_long_star\\(long\\*\\).*\r\n$gdb_prompt $" {
+ 	    # v3 demangler
+ 	    pass "detect dm_type_long_star"
+ 	}
+ 	-re ".*$gdb_prompt $" {
+ 	    fail "detect dm_type_long_star"
+ 	}
+ 	timeout {
+ 	    fail "detect dm_type_long_star (timeout)"
+ 	}
+     }
+ 
+     send_gdb "print &'dm_type_unsigned_int'\n"
+     gdb_expect {
+ 	-re ".*dm_type_unsigned_int\\(unsigned int\\).*\r\n$gdb_prompt $" {
+ 	    # v2 demangler
+ 	    set dm_type_unsigned_int "unsigned int"
+ 	    pass "detect dm_type_unsigned_int"
+ 	}
+ 	-re ".*dm_type_unsigned_int\\(unsigned\\).*\r\n$gdb_prompt $" {
+ 	    # v3 demangler
+ 	    pass "detect dm_type_unsigned_int"
+ 	}
+ 	-re ".*$gdb_prompt $" {
+ 	    fail "detect dm_type_unsigned_int"
+ 	}
+ 	timeout {
+ 	    fail "detect dm_unsigned int (timeout)"
+ 	}
+     }
+ 
+     send_gdb "print &'dm_type_void'\n"
+     gdb_expect {
+ 	-re ".*dm_type_void\\(void\\).*\r\n$gdb_prompt $" {
+ 	    # v2 demangler
+ 	    set dm_type_void "void"
+ 	    pass "detect dm_type_void"
+ 	}
+ 	-re ".*dm_type_void\\(\\).*\r\n$gdb_prompt $" {
+ 	    # v3 demangler
+ 	    pass "detect dm_type_void"
+ 	}
+ 	-re ".*$gdb_prompt $" {
+ 	    fail "detect dm_type_void"
+ 	}
+ 	timeout {
+ 	    fail "detect dm_type_void (timeout)"
+ 	}
+     }
+ 
+     send_gdb "print &'dm_type_void_star'\n"
+     gdb_expect {
+ 	-re ".*dm_type_void_star\\(void \\*\\).*\r\n$gdb_prompt $" {
+ 	    # v2 demangler
+ 	    set dm_type_void_star "void *"
+ 	    pass "detect dm_type_void_star"
+ 	}
+ 	-re ".*dm_type_void_star\\(void\\*\\).*\r\n$gdb_prompt $" {
+ 	    # v3 demangler
+ 	    pass "detect dm_type_void_star"
+ 	}
+ 	-re ".*$gdb_prompt $" {
+ 	    fail "detect dm_type_void_star"
+ 	}
+ 	timeout {
+ 	    fail "detect dm_type_void_star (timeout)"
+ 	}
+     }
+ }
+ 
+ #
+ #  Lookup a specific C++ function and print the demangled type.
+ #  This form accepts the demangled type as a regexp.
+ #
+ 
+ proc info_func_regexp { name demangled } {
+     global gdb_prompt
+ 
+     send_gdb "info function $name\n"
+     gdb_expect {
+ 	-re ".*File .*:\r\n(class |)$demangled\r\n.*$gdb_prompt $" {
+ 	    pass "info function for \"$name\""
+ 	}
+ 	-re ".*$gdb_prompt $" {
+ 	    fail "info function for \"$name\""
+ 	}
+ 	timeout {
+ 	    fail "info function for \"$name\" (timeout)"
+ 	}
+     }
  }
  
  #
! #  Lookup a specific C++ function and print the demangled type.
! #  This form accepts the demangled type as a literal string.
  #
  
! proc info_func { name demangled } {
!     info_func_regexp "$name" [string_to_regexp "$demangled"]
! }
! 
! #
! # Print the address of a function.
! # This checks that I can lookup a fully qualified C++ function.
! # This also checks the argument types on the return string.
! #
! 
! proc print_addr_2 { name good } {
      global gdb_prompt
      global hex
+ 
+     set good_pattern [string_to_regexp $good]
  
!     send_gdb "print &'$name'\n"
      gdb_expect {
! 	-re ".* = .* $hex <$good_pattern>\r\n$gdb_prompt $" {
! 	    pass "print &'$name'"
! 	}
  	-re ".*$gdb_prompt $" {
! 	    fail "print &'$name'"
  	}
  	timeout {
! 	    fail "print &'$name' (timeout)"
  	}
      }
  }
  
  #
+ #  Simple interfaces to print_addr_2.
+ #
+ 
+ proc print_addr { name } {
+     print_addr_2 "$name" "$name"
+ }
+ 
+ #
  # Test name demangling for operators.
  #
  # The '(' at the end of each regex input pattern is so that we match only
  # the one we are looking for.  I.E. "operator&" would match both
  # "operator&(foo &)" and "operator&&(foo &)".
  #
+ # gdb-gnats bug gdb/18:
+ #  "gdb can't parse "info func operator*" or "info func operator\*".
+ #  The star in "operator*" is interpreted as a regexp, but the "\*"
+ #  in  "operator\*" is not a legal operator.
+ #
  
  proc test_lookup_operator_functions {} {
+     global dm_operator_comma
+     global dm_type_char_star
+     global dm_type_foo_ref
+     global dm_type_void
+     global dm_type_void_star
  
      # These tests don't work for COFF targets; don't even try them
      if [istarget "a29k-*-udi"] then {
*************** proc test_lookup_operator_functions {} {
*** 103,229 ****
  	return
      }
  
!     info_func "operator&&("  "void foo::operator&&\\(foo &\\);"
!     info_func "operator&=("  "void foo::operator&=\\(foo &\\);"
!     info_func "operator&("  "void foo::operator&\\(foo &\\);"
!     info_func "operator/=("  "void foo::operator/=\\(foo &\\);"
!     info_func "operator^=("  "void foo::operator.=\\(foo &\\);"
!     info_func "operator<<=("  "void foo::operator<<=\\(foo &\\);"
!     info_func "operator%=("  "void foo::operator%=\\(foo &\\);"
!     info_func "operator-=("  "void foo::operator-=\\(foo &\\);"
! 
!     # There doesn't appear to be any way to get GDB to treat '*' as a
!     # character to match, rather than as a regex special character.
!     setup_xfail "*-*-*"
!     info_func "operator\*=("  "void foo::operator\\*=\\(foo &\\);"
! 
!     info_func "operator|=("  "void foo::operator\\|=\\(foo &\\);"
!     info_func "operator+=("  "void foo::operator.=\\(foo &\\);"
!     info_func "operator>>=("  "void foo::operator\>\>=\\(foo &\\);"
!     info_func "operator=("  "void foo::operator=\\(foo &\\);"
!     info_func "operator()("  "void foo::operator\\(\\)\\(foo &\\);"
! 
!     # The function should be "operator," not "operator, ".  (note space)
!     # This test will work; I've commented it out because it should not
!     # count as a pass, since it is incorrect.  Ian Taylor.
!     # info_func "operator, ("  "void foo::operator, \\(foo &\\);"
!     setup_xfail "*-*-*"
!     info_func "operator,("  "void foo::operator,\\(foo &\\);"
! 
!     info_func "operator~("  "void foo::operator~\\(void\\);"
!     info_func "operator delete("  "void foo::operator delete\\(void \\*\\)(| static);"
!     info_func "operator/("  "void foo::operator/\\(foo &\\);"
!     info_func "operator==("  "void foo::operator==\\(foo &\\);"
!     info_func "operator^("  "void foo::operator\\^\\(foo &\\);"
! 
!     info_func "operator>=("  "void foo::operator>=\\(foo &\\);"
!     info_func "operator>("  "void foo::operator>\\(foo &\\);"
!     info_func "operator<=("  "void foo::operator<=\\(foo &\\);"
!     info_func "operator<<("  "void foo::operator<<\\(foo &\\);"
!     info_func "operator<("  "void foo::operator<\\(foo &\\);"
!     info_func "operator%("  "void foo::operator%\\(foo &\\);"
!     info_func "operator-("  "void foo::operator-\\(foo &\\);"
! 
!     # There doesn't appear to be anyway to get '*' treated as a character
!     # to match, rather than as a regex special character.
!     setup_xfail "*-*-*"
!     info_func "operator\*("  "void foo::operator\\*\\(foo &\\);"
! 
!     info_func "operator--("  "void foo::operator--\\(int\\);"
!     info_func "operator!=("  "void foo::operator!=\\(foo &\\);"
!     info_func "operator!("  "void foo::operator!\\(void\\);"
!     info_func "operator new("  "void \\*foo::operator new\\(.*\\)(| static);"
!     info_func "operator||("  "void foo::operator\\|\\|\\(foo &\\);"
!     info_func "operator char \\*("  "char \\*foo::operator char \\*\\(void\\);"
!     info_func "operator int("  "int foo::operator int\\(void\\);"
!     info_func "operator|("  "void foo::operator\\|\\(foo &\\);"
!     info_func "operator+("  "void foo::operator\\+\\(foo &\\);"
!     info_func "operator++("  "void foo::operator\\+\\+\\(int\\);"
!     info_func "operator->("  "foo \\*foo::operator->\\(void\\);"
!     info_func "operator->\\*("  "void foo::operator->\\*\\(foo &\\);"
!     info_func "operator>>("  "void foo::operator\>\>\\(foo &\\);"
! 
!     # GDB says "`operator \[\](' not supported".  I don't know why.
!     setup_xfail "*-*-*"
!     info_func "operator\\\[\\\](" "void foo::operator\\\[\\\]\\(foo &\\);"
!     # But this works, for some reason.
!     info_func ".perator\\\[\\\](" "void foo::operator\\\[\\\]\\(foo &\\);"
  }
  
  
  proc test_paddr_operator_functions {} {
      global hex
      global hp_aCC_compiler
  
!     print_addr_of "foo::operator&&(foo &)"
!     print_addr_of "foo::operator&=(foo &)"
!     print_addr_of "foo::operator&(foo &)"
!     print_addr_of "foo::operator/=(foo &)"
!     print_addr_of "foo::operator^=(foo &)"
!     print_addr_of "foo::operator<<=(foo &)"
!     print_addr_of "foo::operator%=(foo &)"
!     print_addr_of "foo::operator-=(foo &)"
!     print_addr_of "foo::operator*=(foo &)"
!     print_addr_of "foo::operator|=(foo &)"
!     print_addr_of "foo::operator+=(foo &)"
!     print_addr_of "foo::operator>>=(foo &)"
!     print_addr_of "foo::operator=(foo &)"
!     print_addr_of "foo::operator()(foo &)"
!     print_addr_of "foo::operator, (foo &)"
!     print_addr_of "foo::operator~(void)"
      if { !$hp_aCC_compiler } {
! 	print_addr_of "foo::operator delete(void *)"
      } else {
! 	gdb_test "print &'foo::operator delete(void *) static'" \
  	    " = .*(0x\[0-9a-f\]+|) <foo::operator delete.*>"
      }
!     print_addr_of "foo::operator/(foo &)"
!     print_addr_of "foo::operator==(foo &)"
!     print_addr_of "foo::operator^(foo &)"
!     print_addr_of "foo::operator>=(foo &)"
!     print_addr_of "foo::operator>(foo &)"
!     print_addr_of "foo::operator<=(foo &)"
!     print_addr_of "foo::operator<<(foo &)"
!     print_addr_of "foo::operator<(foo &)"
!     print_addr_of "foo::operator%(foo &)"
!     print_addr_of "foo::operator-(foo &)"
!     print_addr_of "foo::operator*(foo &)"
!     print_addr_of "foo::operator--(int)"
!     print_addr_of "foo::operator!=(foo &)"
!     print_addr_of "foo::operator!(void)"
!     gdb_test "print &'foo::operator new'" \
! 	" = .* $hex <foo::operator new\\(.*\\)(| static)>"
!     print_addr_of "foo::operator||(foo &)"
!     print_addr_of "foo::operator char *(void)"
!     print_addr_of "foo::operator int(void)"
!     print_addr_of "foo::operator|(foo &)"
!     print_addr_of "foo::operator+(foo &)"
!     print_addr_of "foo::operator++(int)"
!     print_addr_of "foo::operator->(void)"
!     print_addr_of "foo::operator->*(foo &)"
!     print_addr_of "foo::operator>>(foo &)"
!     gdb_test "print &'foo::operator\[\](foo &)'" \
! 	" = .*0x\[0-9a-f\]+ <foo::operator\\\[\\\]\\(foo &\\)>"
  }
  
  #
--- 312,432 ----
  	return
      }
  
!     info_func "operator*("	"void foo::operator*($dm_type_foo_ref);"
!     info_func "operator%("	"void foo::operator%($dm_type_foo_ref);"
!     info_func "operator-("	"void foo::operator-($dm_type_foo_ref);"
!     info_func "operator>>("	"void foo::operator>>($dm_type_foo_ref);"
!     info_func "operator!=("	"void foo::operator!=($dm_type_foo_ref);"
!     info_func "operator>("	"void foo::operator>($dm_type_foo_ref);"
!     info_func "operator>=("	"void foo::operator>=($dm_type_foo_ref);"
!     info_func "operator|("	"void foo::operator|($dm_type_foo_ref);"
!     info_func "operator&&("	"void foo::operator&&($dm_type_foo_ref);"
!     info_func "operator!("	"void foo::operator!($dm_type_void);"
!     info_func "operator++("	"void foo::operator++(int);"
!     info_func "operator=("	"void foo::operator=($dm_type_foo_ref);"
!     info_func "operator+=("	"void foo::operator+=($dm_type_foo_ref);"
!     info_func "operator*=("	"void foo::operator*=($dm_type_foo_ref);"
!     info_func "operator%=("	"void foo::operator%=($dm_type_foo_ref);"
!     info_func "operator>>=("	"void foo::operator>>=($dm_type_foo_ref);"
!     info_func "operator|=("	"void foo::operator|=($dm_type_foo_ref);"
!     info_func "operator$dm_operator_comma\("	\
!     				"void foo::operator$dm_operator_comma\($dm_type_foo_ref);"
!     info_func "operator/("	"void foo::operator/($dm_type_foo_ref);"
!     info_func "operator+("	"void foo::operator+($dm_type_foo_ref);"
!     info_func "operator<<("	"void foo::operator<<($dm_type_foo_ref);"
!     info_func "operator==("	"void foo::operator==($dm_type_foo_ref);"
!     info_func "operator<("	"void foo::operator<($dm_type_foo_ref);"
!     info_func "operator<=("	"void foo::operator<=($dm_type_foo_ref);"
!     info_func "operator&("	"void foo::operator&($dm_type_foo_ref);"
!     info_func "operator^("	"void foo::operator^($dm_type_foo_ref);"
!     info_func "operator||("	"void foo::operator||($dm_type_foo_ref);"
!     info_func "operator~("	"void foo::operator~($dm_type_void);"
!     info_func "operator--("	"void foo::operator--(int);"
!     info_func "operator->("	"foo *foo::operator->($dm_type_void);"
!     info_func "operator-=("	"void foo::operator-=($dm_type_foo_ref);"
!     info_func "operator/=("	"void foo::operator/=($dm_type_foo_ref);"
!     info_func "operator<<=("	"void foo::operator<<=($dm_type_foo_ref);"
!     info_func "operator&=("	"void foo::operator&=($dm_type_foo_ref);"
!     info_func "operator^=("	"void foo::operator^=($dm_type_foo_ref);"
!     info_func "operator->*("	"void foo::operator->*($dm_type_foo_ref);"
! 
!     # operator[] needs backslashes to protect against TCL evaluation.
!     info_func "operator\[\]("	"void foo::operator\[\]($dm_type_foo_ref);"
! 
!     # These are gnarly because they might end with 'static'.
!     set dm_type_void_star_regexp [string_to_regexp $dm_type_void_star]
!     info_func_regexp "operator new("     "void \\*foo::operator new\\(.*\\)(| static);"
!     info_func_regexp "operator delete("  "void foo::operator delete\\($dm_type_void_star_regexp\\)(| static);"
! 
!     info_func "operator int("	"int foo::operator int($dm_type_void);"
!     info_func "operator()("	"void foo::operator()($dm_type_foo_ref);"
!     info_func "operator $dm_type_char_star\(" \
! 				"char *foo::operator $dm_type_char_star\($dm_type_void);"
! 
  }
  
  
  proc test_paddr_operator_functions {} {
      global hex
      global hp_aCC_compiler
+     global dm_operator_comma
+     global dm_type_char_star
+     global dm_type_foo_ref
+     global dm_type_long_star
+     global dm_type_unsigned_int
+     global dm_type_void
+     global dm_type_void_star
+ 
+     print_addr "foo::operator*($dm_type_foo_ref)"
+     print_addr "foo::operator%($dm_type_foo_ref)"
+     print_addr "foo::operator-($dm_type_foo_ref)"
+     print_addr "foo::operator>>($dm_type_foo_ref)"
+     print_addr "foo::operator!=($dm_type_foo_ref)"
+     print_addr "foo::operator>($dm_type_foo_ref)"
+     print_addr "foo::operator>=($dm_type_foo_ref)"
+     print_addr "foo::operator|($dm_type_foo_ref)"
+     print_addr "foo::operator&&($dm_type_foo_ref)"
+     print_addr "foo::operator!($dm_type_void)"
+     print_addr "foo::operator++(int)"
+     print_addr "foo::operator=($dm_type_foo_ref)"
+     print_addr "foo::operator+=($dm_type_foo_ref)"
+     print_addr "foo::operator*=($dm_type_foo_ref)"
+     print_addr "foo::operator%=($dm_type_foo_ref)"
+     print_addr "foo::operator>>=($dm_type_foo_ref)"
+     print_addr "foo::operator|=($dm_type_foo_ref)"
+     print_addr "foo::operator$dm_operator_comma\($dm_type_foo_ref)"
+     print_addr "foo::operator/($dm_type_foo_ref)"
+     print_addr "foo::operator+($dm_type_foo_ref)"
+     print_addr "foo::operator<<($dm_type_foo_ref)"
+     print_addr "foo::operator==($dm_type_foo_ref)"
+     print_addr "foo::operator<($dm_type_foo_ref)"
+     print_addr "foo::operator<=($dm_type_foo_ref)"
+     print_addr "foo::operator&($dm_type_foo_ref)"
+     print_addr "foo::operator^($dm_type_foo_ref)"
+     print_addr "foo::operator||($dm_type_foo_ref)"
+     print_addr "foo::operator~($dm_type_void)"
+     print_addr "foo::operator--(int)"
+     print_addr "foo::operator->($dm_type_void)"
+     print_addr "foo::operator-=($dm_type_foo_ref)"
+     print_addr "foo::operator/=($dm_type_foo_ref)"
+     print_addr "foo::operator<<=($dm_type_foo_ref)"
+     print_addr "foo::operator&=($dm_type_foo_ref)"
+     print_addr "foo::operator^=($dm_type_foo_ref)"
+     print_addr "foo::operator->*($dm_type_foo_ref)"
+     print_addr "foo::operator\[\]($dm_type_foo_ref)"
+     print_addr "foo::operator()($dm_type_foo_ref)"
  
!     gdb_test "print &'foo::operator new'" \
! 	" = .* $hex <foo::operator new\\(.*\\)(| static)>"
      if { !$hp_aCC_compiler } {
! 	print_addr "foo::operator delete($dm_type_void_star)"
      } else {
! 	gdb_test "print &'foo::operator delete($dm_type_void_star) static'" \
  	    " = .*(0x\[0-9a-f\]+|) <foo::operator delete.*>"
      }
! 
!     print_addr "foo::operator int($dm_type_void)"
!     print_addr "foo::operator $dm_type_char_star\($dm_type_void)"
  }
  
  #
*************** proc test_paddr_operator_functions {} {
*** 231,269 ****
  #
  
  proc test_paddr_overloaded_functions {} {
!     print_addr_of "overload1arg(signed char)"
!     print_addr_of "overload1arg(unsigned char)"
!     print_addr_of "overload1arg(unsigned int)"
!     print_addr_of "overload1arg(unsigned long)"
!     print_addr_of "overload1arg(unsigned short)"
!     print_addr_of "overload1arg(char)"
!     print_addr_of "overload1arg(double)"
!     print_addr_of "overload1arg(float)"
!     print_addr_of "overload1arg(int)"
!     print_addr_of "overload1arg(long)"
!     print_addr_of "overload1arg(short)"
!     print_addr_of "overload1arg(void)"
!     print_addr_of "overloadargs(int)"
!     print_addr_of "overloadargs(int, int)"
!     print_addr_of "overloadargs(int, int, int)"
!     print_addr_of "overloadargs(int, int, int, int)"
!     print_addr_of "overloadargs(int, int, int, int, int)"
!     print_addr_of "overloadargs(int, int, int, int, int, int)"
!     print_addr_of "overloadargs(int, int, int, int, int, int, int)"
!     print_addr_of "overloadargs(int, int, int, int, int, int, int, int)"
!     print_addr_of "overloadargs(int, int, int, int, int, int, int, int, int)"
!     print_addr_of "overloadargs(int, int, int, int, int, int, int, int, int, int)"
!     print_addr_of "overloadargs(int, int, int, int, int, int, int, int, int, int, int)"
  }
  
  proc test_paddr_hairy_functions {} {
!     print_addr_of "hairyfunc1(int)"
!     print_addr_of "hairyfunc2(int (*)(char *))"
!     print_addr_of "hairyfunc3(int (*)(short (*)(long *)))"
!     print_addr_of "hairyfunc4(int (*)(short (*)(char *)))"
!     print_addr_of "hairyfunc5(int (*(*)(char *))(long))"
!     print_addr_of "hairyfunc6(int (*(*)(int *))(long))"
!     print_addr_of "hairyfunc7(int (*(*)(int (*)(char *)))(long))"
  }
  
  proc do_tests {} {
--- 434,485 ----
  #
  
  proc test_paddr_overloaded_functions {} {
!     global dm_type_unsigned_int
!     global dm_type_void
! 
!     print_addr "overload1arg($dm_type_void)"
!     print_addr "overload1arg(char)"
!     print_addr "overload1arg(signed char)"
!     print_addr "overload1arg(unsigned char)"
!     print_addr "overload1arg(short)"
!     print_addr "overload1arg(unsigned short)"
!     print_addr "overload1arg(int)"
!     print_addr "overload1arg($dm_type_unsigned_int)"
!     print_addr "overload1arg(long)"
!     print_addr "overload1arg(unsigned long)"
!     print_addr "overload1arg(float)"
!     print_addr "overload1arg(double)"
! 
!     print_addr "overloadargs(int)"
!     print_addr "overloadargs(int, int)"
!     print_addr "overloadargs(int, int, int)"
!     print_addr "overloadargs(int, int, int, int)"
!     print_addr "overloadargs(int, int, int, int, int)"
!     print_addr "overloadargs(int, int, int, int, int, int)"
!     print_addr "overloadargs(int, int, int, int, int, int, int)"
!     print_addr "overloadargs(int, int, int, int, int, int, int, int)"
!     print_addr "overloadargs(int, int, int, int, int, int, int, int, int)"
!     print_addr "overloadargs(int, int, int, int, int, int, int, int, int, int)"
!     print_addr "overloadargs(int, int, int, int, int, int, int, int, int, int, int)"
  }
  
  proc test_paddr_hairy_functions {} {
!     global gdb_prompt
!     global hex
!     global dm_type_char_star
!     global dm_type_int_star
!     global dm_type_long_star
! 
!     print_addr_2 "hairyfunc1" "hairyfunc1(int)"
!     print_addr_2 "hairyfunc2" "hairyfunc2(int (*)($dm_type_char_star))"
!     print_addr_2 "hairyfunc3" "hairyfunc3(int (*)(short (*)($dm_type_long_star)))"
!     print_addr_2 "hairyfunc4" "hairyfunc4(int (*)(short (*)($dm_type_char_star)))"
! 
!     # gdb-gnats bug gdb/19:
!     # "gdb v3 demangler fails on hairyfunc5 hairyfunc6 hairyfunc7"
!     print_addr_2 "hairyfunc5" "hairyfunc5(int (*(*)($dm_type_char_star))(long))"
!     print_addr_2 "hairyfunc6" "hairyfunc6(int (*(*)($dm_type_int_star))(long))"
!     print_addr_2 "hairyfunc7" "hairyfunc7(int (*(*)(int (*)($dm_type_char_star)))(long))"
  }
  
  proc do_tests {} {
*************** proc do_tests {} {
*** 303,308 ****
--- 519,525 ----
  	clear_xfail "*-*-*"
      }
  
+     probe_demangler
      test_paddr_overloaded_functions
      test_paddr_operator_functions
      test_paddr_hairy_functions


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

* Re: [RFA] testsuite/gdb.c++/cplusfuncs.{exp,cc}: work with either g++ demangler
  2001-02-11 15:49 [RFA] testsuite/gdb.c++/cplusfuncs.{exp,cc}: work with either g++ demangler Michael Elizabeth Chastain
@ 2001-02-12 12:12 ` Michael Snyder
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Snyder @ 2001-02-12 12:12 UTC (permalink / raw)
  To: Michael Elizabeth Chastain; +Cc: gdb-patches

Michael Elizabeth Chastain wrote:
> 
> This is Sunday Sourceware patch #2, revision 2.
> 
> Changes since revision 1:
>   - Change wording of ChangeLog with respect to gdb/19.
>   - Change one more "char *" to "$dm_type_char_star".
> 
> gdb has two g++ demanglers.  Currently, this test script works okay on
> the v2 demangler, but gives 83 FAILs with the v3 demangler.  This patch
> enhances testsuite/gdb.c++/cplusfuncs.{cc,exp} to work with either
> demangler.
> 
> The bulk of the change is handling formatting differences:
> 
>   old demangler         new demangler
>   --- ---------         --- ---------
>   "operator, "          "operator,"
>   "char *"              "char*"
>   "int *"               "int*"
>   "long *"              "long*"
>   "void *"              "void*"
>   "foo &"               "foo&"
>   "unsigned int"        "unsigned"
>   "void"                ""

Michael, 
I'm curious why you didn't simply write separate regular expressions,
one to recognize the new demangler style and one to recognize the old,
rather than add all this new mechanics.  I'm concerned about the tcl 
scripts becoming complicated and difficult to maintain.

Please don't get me wrong -- I very much appreciate both the work
that you're investing and the fact that you're championing this
cause.


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

* Re: [RFA] testsuite/gdb.c++/cplusfuncs.{exp,cc}: work with either g++ demangler
@ 2001-02-14  9:21 Michael Elizabeth Chastain
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Elizabeth Chastain @ 2001-02-14  9:21 UTC (permalink / raw)
  To: fnasser; +Cc: gdb-patches

Hi Fernando,

> Also, we must consider that what the tests are really checking for is
> not the presence of one some spaces, but that the right methods were
> found etc. (well, int and void disappearing does hurt a bit, but still,
> that was not what the test was written for).

Right.  As I understand it, this is the autoconf way.  Version checks are
bad, specific feature tests are good.

Last night I checked out the discussion on gcc-patches about Daniel
Berlin's demangler patch.  There's a style discussion going on about
what the demangler should emit with people referring to their style
document, gcc/libstdc++-v3/docs/html/17_intro/C++STYLE.

I will not willingly accept a project dependency on a controversial
decision that belongs to another project.  I'm going to continue
submitting patches that make gdb testsuite work with all known styles.
If the demangler gets more compatible, that's great.

> 1) If we had the "known failures" we could have marked those 8 tests as
>    such and associated with the Gnats id.

We have those bug_id and prms_id fields that are associated with the
whole test.  If someone wants to do some infrastructure work to link to
Gnats, I will be happy to use them.  I like filing Gnats bugs.

> 3) Your patch should have been submitted as 3 separate patches.

Understood.

> 4) Before checking in, please add some of the comments to the test file
>    (see below).  No need to repost.

You got it.

> 5) This is a nitty-picky thing :-) Please add a period after "New file" in
>    your first ChangeLog entry (and capitalize the following letter) before
     checking it in.

Ditto.

> And again, thanks for the patch.

Two down (almost).  Thirteen to go.

Michael


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

* Re: [RFA] testsuite/gdb.c++/cplusfuncs.{exp,cc}: work with either g++ demangler
       [not found] <200102050418.UAA29343@bosch.cygnus.com>
@ 2001-02-14  9:00 ` Fernando Nasser
  0 siblings, 0 replies; 5+ messages in thread
From: Fernando Nasser @ 2001-02-14  9:00 UTC (permalink / raw)
  To: Michael Elizabeth Chastain; +Cc: gdb-patches

Finally I was able to look a Michael's patch...

First of all, thanks for taking care of this all all the work you put into it.

I though of possible alternatives like, for instance, having the test act accordingly to the configuration.  But gcc and gdb versions are not released simultaneously, so this is not possible.  For instance: gcc default will be v3 while gdb default will be v2 (for 5.1 at least).

Also, we must consider that what the tests are really checking for is not the presence of one some spaces, but that the right methods were found etc. (well, int and void disappearing does hurt a bit, but still, that was not what the test was written for).

So, your approach is the only one that we can rely on.


A few comments:

1) If we had the "known failures" we could have marked those 8 tests as such and associated with the Gnats id.  We could have avoided distancing more from the zero baseline that we would like so much and still have the two bug entry summaries printed in a list of known bugs for this code base at the end.

2) I hate adding new FAILs, but as we don't have (1) and XFAILS are not an acceptable alternative I guess there is not much we can do.  I will add one myself for that "nexti" that is broken.

3) Your patch should have been submitted as 3 separate patches.  The grouping is not for being on the same file but rather on the issue that is being addressed.  I will overlook it, but please remember this in future submissions.

4) Before checking in, please add some of the comments to the test file (see below).  No need to repost.

5) This is a nitty-picky thing :-) Please add a period after "New file" in your first ChangeLog entry (and capitalize the following letter) before checking it in.


And again, thanks for the patch.

Regards,
Fernando




This is nice to have in the test file:

> gdb has two g++ demanglers.
> 
>   old demangler         new demangler
>   --- ---------         --- ---------
>   "operator, "          "operator,"
>   "char *"              "char*"
>   "int *"               "int*"
>   "long *"              "long*"
>   "void *"              "void*"
>   "foo &"               "foo&"
>   "unsigned int"        "unsigned"
>   "void"                ""
> 



Can you please add a not to gdb/18 with this:

> The new FAILs caused by the bug in gdb/18 are:
> 
>   FAIL: gdb.c++/cplusfuncs.exp: info function for "operator*("
>   FAIL: gdb.c++/cplusfuncs.exp: info function for "operator*=("
>   FAIL: gdb.c++/cplusfuncs.exp: info function for "operator->*("
>   FAIL: gdb.c++/cplusfuncs.exp: info function for "operator[]("
>   FAIL: gdb.c++/cplusfuncs.exp: info function for "operator char *("
> 


And one to gdb/19 with this:
> 
> The new FAILs caused by the bug in gdb/19 are:
> 
>   FAIL: gdb.c++/cplusfuncs.exp: print &'hairyfunc5'
>   FAIL: gdb.c++/cplusfuncs.exp: print &'hairyfunc6'
>   FAIL: gdb.c++/cplusfuncs.exp: print &'hairyfunc7'
> 

This can be useful for whoever is working on fixing these PRs.



-- 
Fernando Nasser
Red Hat - Toronto                       E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9


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

* Re: [RFA] testsuite/gdb.c++/cplusfuncs.{exp,cc}: work with either g++ demangler
@ 2001-02-12 12:30 Michael Elizabeth Chastain
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Elizabeth Chastain @ 2001-02-12 12:30 UTC (permalink / raw)
  To: chastain, msnyder; +Cc: gdb-patches

Hi Michael,

> I'm curious why you didn't simply write separate regular expressions,
> one to recognize the new demangler style and one to recognize the old,
> rather than add all this new mechanics.

That's a reasonable question.

The script does not actually know about about "v2 demangler" and "v3
demangler" and which regexp's go with which version.  I wrote it more
like autoconf (although I am not experienced with autoconf).  It probes
for each type separately and accommodates all the versions that I
have ever seen.  If tomorrow's demangler wants to print 'foo    &',
or report every 'int' as a 'signed int', it would be easy to maintain
the script.

> I'm concerned about the tcl scripts becoming complicated and difficult
> to maintain.

There are two parts.  The probing part is meant to be independent and
can be copied-and-pasted into other scripts or put into a library.

The probing part can also be reduced to nothing if we stopped supporting
v2 abi.  The strings are initialized to their v3 values.

As far as the use goes -- it does bother me to fill up the whole script
with "$dm_type_foo_ref".

Part of the problem is that a lot of these test scripts are not very
careful about "input to gdb" (which must always be a literal string)
versus "output from gdb" (which they can model with either a literal
string or with a regular expression).  cplusfuncs.exp likes to specify
one string for both input and output, so it *has* to be a literal.

Michael


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

end of thread, other threads:[~2001-02-14  9:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-02-11 15:49 [RFA] testsuite/gdb.c++/cplusfuncs.{exp,cc}: work with either g++ demangler Michael Elizabeth Chastain
2001-02-12 12:12 ` Michael Snyder
2001-02-12 12:30 Michael Elizabeth Chastain
     [not found] <200102050418.UAA29343@bosch.cygnus.com>
2001-02-14  9:00 ` Fernando Nasser
2001-02-14  9:21 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