This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[commit] Test for ptype problem printing typedefs defined differently in different compilation units


After review and approval by Jim Blandy, I committed the testsuite
changes for testing the printing of typedefs defined differently in
different compilation units, when statically examining an executable.

Per his suggestions, I'm looking at alternative ways to actually fix
the issue.

Here is the testsuite patch.

-Fred

2006-01-04  Fred Fish  <fnf@specifix.com>

	* gdb.base/ptype.c (foo): Add typedef.
	(intfoo): Add function.
	* gdb.base/ptype1.c: New file.
	* gdb.base/ptype.exp: Handle compilation and linking with two
	source files.  Test that proper type for "foo" is found based
	on source context rather than first match found in symtabs.

Index: gdb.base/ptype.c
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/ptype.c,v
retrieving revision 1.3
diff -c -p -r1.3 ptype.c
*** gdb.base/ptype.c	26 Mar 2003 22:10:39 -0000	1.3
--- gdb.base/ptype.c	4 Jan 2006 14:43:37 -0000
*************** func_type v_func_type;
*** 259,264 ****
--- 259,273 ----
  
  /***********/
  
+ typedef int foo;
+ 
+ foo intfoo (afoo)
+ {
+   return (afoo * 2);
+ }
+ 
+ /***********/
+ 
  int main ()
  {
    /* Ensure that malloc is a pointer type; avoid use of "void" and any include files. */
Index: gdb.base/ptype.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/ptype.exp,v
retrieving revision 1.7
diff -c -p -r1.7 ptype.exp
*** gdb.base/ptype.exp	27 Mar 2003 18:59:11 -0000	1.7
--- gdb.base/ptype.exp	4 Jan 2006 14:43:37 -0000
*************** set prms_id 0
*** 31,39 ****
  set bug_id 0
  
  set testfile "ptype"
! set srcfile ${testfile}.c
  set binfile ${objdir}/${subdir}/${testfile}
! if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
       gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
  }
  
--- 31,47 ----
  set bug_id 0
  
  set testfile "ptype"
! set srcfile0 ${testfile}.c
! set srcfile1 ${testfile}1.c
  set binfile ${objdir}/${subdir}/${testfile}
! 
! if  { [gdb_compile "${srcdir}/${subdir}/${srcfile0}" "${binfile}0.o" object {debug}] != "" } {
!      gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
! }
! if  { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug}] != "" } {
!      gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
! }
! if  { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug}] != "" } {
       gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
  }
  
*************** ptype_maybe_prototyped "ffptr" "int (*(*
*** 574,579 ****
--- 582,599 ----
  ptype_maybe_prototyped "fffptr" "int (*(*(*)(char))(short int))(long int)" \
                                  "int (*(*(*)())())()"
  
+ # Test printing type of typedefs in different scopes, with same name
+ # but different type.
+ 
+ gdb_test "list intfoo" ""
+ gdb_test "ptype foo" "type = int" "ptype foo typedef after first list of intfoo"
+ gdb_test "list charfoo" ""
+ gdb_test "ptype foo" "type = char" "ptype foo typedef after first list of charfoo"
+ gdb_test "list intfoo" ""
+ gdb_test "ptype foo" "type = int" "ptype foo typedef after second list of intfoo"
+ gdb_test "list charfoo" ""
+ gdb_test "ptype foo" "type = char" "ptype foo typedef after second list of charfoo"
+ 
  # Test printing type of string constants and array constants, but
  # requires a running process.  These call malloc, and can take a long
  # time to execute over a slow serial link, so increase the timeout.
Index: gdb.base/ptype1.c
===================================================================
RCS file: gdb.base/ptype1.c
diff -N gdb.base/ptype1.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gdb.base/ptype1.c	4 Jan 2006 14:43:37 -0000
***************
*** 0 ****
--- 1,6 ----
+ typedef char foo;
+ 
+ foo charfoo (afoo)
+ {
+   return (afoo * 2);
+ }




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]