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]

Re: [PATCH] Fix ptype problem printing typedefs defined differently in different compilation units


On Monday 20 February 2006 11:23, Daniel Jacobowitz wrote:
> Yuck.  In general futzing with global variables in a parser is bad
> news.  And here's another good hint that this isn't happening in the
> right place:

OK.  Lets forget the c-exp.y part of the patch.

I think it would probably be a good idea to put in the testsuite
changes, pending a better fix...

With the attached patch, I get the new PASS's:

  PASS: gdb.base/ptype.exp: ptype 'file'::symbol
  PASS: gdb.base/ptype.exp: ptype 'file'::symbol
  PASS: gdb.base/ptype.exp: p (long)1
  PASS: gdb.base/ptype.exp: ptype long value from value history
  PASS: gdb.base/ptype.exp: p (short)1
  PASS: gdb.base/ptype.exp: ptype short value from value history
  PASS: gdb.base/whatis.exp: whatis named structure in explicit scope
  PASS: gdb.base/whatis.exp: whatis unnamed structure in explicit scope
  PASS: gdb.base/whatis.exp: whatis named union in explicit scope
  PASS: gdb.base/whatis.exp: whatis unnamed union in explicit scope
  PASS: gdb.base/whatis.exp: whatis applied to variable defined by typedef in explicit scope
  PASS: gdb.base/whatis.exp: p (long)1
  PASS: gdb.base/whatis.exp: whatis long value from value history
  PASS: gdb.base/whatis.exp: p (short)1
  PASS: gdb.base/whatis.exp: whatis short value from value history

and the (expected) failures:

  FAIL: gdb.base/ptype.exp: ptype 'file'::typename
  FAIL: gdb.base/ptype.exp: ptype 'file'::typename
  FAIL: gdb.base/whatis.exp: whatis named structure using type name and explicit scope
  FAIL: gdb.base/whatis.exp: whatis named union using type name and explicit scope
  FAIL: gdb.base/whatis.exp: whatis using typedef type name and explicit scope

-Fred

============================================================================

2006-05-17  Fred Fish  <fnf@specifix.com>

	* gdb.base/ptype.c (afoo): Add variable using foo typedef.
	* gdb.base/ptype1.c (afoo): Ditto.

	* gdb.base/ptype.exp: Add tests using 'file':: prefix
	to specify scope for variables and types.  Add tests for
	printing type of last value history entry.
	* gdb.base/whatis.exp: Ditto.

Index: gdb.base/ptype.c
===================================================================
RCS file: /cvsroots/latest/src/gdb/gdb/testsuite/gdb.base/ptype.c,v
retrieving revision 1.1.1.2
diff -c -p -r1.1.1.2 ptype.c
*** gdb.base/ptype.c	8 Jan 2006 20:37:18 -0000	1.1.1.2
--- gdb.base/ptype.c	17 May 2006 18:53:28 -0000
*************** func_type v_func_type;
*** 260,265 ****
--- 260,266 ----
  /***********/
  
  typedef int foo;
+ static foo afoo = 2;
  
  foo intfoo (afoo)
  {
Index: gdb.base/ptype.exp
===================================================================
RCS file: /cvsroots/latest/src/gdb/gdb/testsuite/gdb.base/ptype.exp,v
retrieving revision 1.1.1.2
diff -c -p -r1.1.1.2 ptype.exp
*** gdb.base/ptype.exp	8 Jan 2006 20:37:19 -0000	1.1.1.2
--- gdb.base/ptype.exp	17 May 2006 18:53:28 -0000
*************** gdb_test "ptype foo" "type = int" "ptype
*** 594,599 ****
--- 594,613 ----
  gdb_test "list charfoo" ""
  gdb_test "ptype foo" "type = char" "ptype foo typedef after second list of charfoo"
  
+ # Test the 'file'::exp syntax for variables and types
+ 
+ gdb_test "ptype 'ptype.c'::afoo" "type = int" "ptype 'file'::symbol"
+ gdb_test "ptype 'ptype.c'::foo" "type = int" "ptype 'file'::typename"
+ gdb_test "ptype 'ptype1.c'::afoo" "type = char" "ptype 'file'::symbol"
+ gdb_test "ptype 'ptype1.c'::foo" "type = char" "ptype 'file'::typename"
+ 
+ # Test printing value history type
+ 
+ gdb_test "p (long)1" ""
+ gdb_test "ptype" "type = long" "ptype long value from value history"
+ gdb_test "p (short)1" ""
+ gdb_test "ptype" "type = short" "ptype short value from value history"
+ 
  # 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: /cvsroots/latest/src/gdb/gdb/testsuite/gdb.base/ptype1.c,v
retrieving revision 1.1.1.1
diff -c -p -r1.1.1.1 ptype1.c
*** gdb.base/ptype1.c	8 Jan 2006 20:37:18 -0000	1.1.1.1
--- gdb.base/ptype1.c	17 May 2006 18:53:28 -0000
***************
*** 1,4 ****
--- 1,5 ----
  typedef char foo;
+ static foo afoo = 1;
  
  foo charfoo (afoo)
  {
Index: gdb.base/whatis.exp
===================================================================
RCS file: /cvsroots/latest/src/gdb/gdb/testsuite/gdb.base/whatis.exp,v
retrieving revision 1.1.1.2
diff -c -p -r1.1.1.2 whatis.exp
*** gdb.base/whatis.exp	18 Feb 2006 21:07:16 -0000	1.1.1.2
--- gdb.base/whatis.exp	17 May 2006 18:53:28 -0000
*************** gdb_test "whatis v_struct1" \
*** 273,300 ****
--- 273,324 ----
      "type = struct t_struct" \
      "whatis named structure"
  
+ gdb_test "whatis 'whatis.c'::v_struct1" \
+     "type = struct t_struct" \
+     "whatis named structure in explicit scope"
+ 
  gdb_test "whatis struct t_struct" \
      "type = struct t_struct" \
      "whatis named structure using type name"
  
+ gdb_test "whatis 'whatis.c'::struct t_struct" \
+     "type = struct t_struct" \
+     "whatis named structure using type name and explicit scope"
+ 
  gdb_test "whatis v_struct2" \
      "type = struct \{$unstruct\}" \
      "whatis unnamed structure"
  
+ gdb_test "whatis 'whatis.c'::v_struct2" \
+     "type = struct \{$unstruct\}" \
+     "whatis unnamed structure in explicit scope"
+ 
  
  # test whatis command with union types
  gdb_test "whatis v_union" \
      "type = union t_union" \
      "whatis named union"
  
+ gdb_test "whatis 'whatis.c'::v_union" \
+     "type = union t_union" \
+     "whatis named union in explicit scope"
+ 
  gdb_test "whatis union t_union" \
      "type = union t_union" \
      "whatis named union using type name"
  
+ gdb_test "whatis 'whatis.c'::union t_union" \
+     "type = union t_union" \
+     "whatis named union using type name and explicit scope"
+ 
  gdb_test "whatis v_union2" \
      "type = union \{$ununion\}" \
      "whatis unnamed union"
  
+ gdb_test "whatis 'whatis.c'::v_union2" \
+     "type = union \{$ununion\}" \
+     "whatis unnamed union in explicit scope"
+ 
  
  # HP-UX: HP aCC compiler w/ +objdebug option detects language as
  # c++, so we need the 'void' pattern here.
*************** gdb_test "whatis char_addr" \
*** 421,426 ****
--- 445,465 ----
      "type = char \\*" \
      "whatis using typedef type name"
  
+ gdb_test "whatis 'whatis.c'::char_addr" \
+     "type = char \\*" \
+     "whatis using typedef type name and explicit scope"
+ 
  gdb_test "whatis a_char_addr" \
      "type = char_addr" \
      "whatis applied to variable defined by typedef"
+ 
+ gdb_test "whatis 'whatis.c'::a_char_addr" \
+     "type = char_addr" \
+     "whatis applied to variable defined by typedef in explicit scope"
+ 
+ # Test printing value history type
+ 
+ gdb_test "p (long)1" ""
+ gdb_test "whatis" "type = long" "whatis long value from value history"
+ gdb_test "p (short)1" ""
+ gdb_test "whatis" "type = short" "whatis short value from value history"


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