public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [RFA] Fix jmisc.exp failures/bz 9320/java "void" issues
@ 2010-03-26 22:27 Keith Seitz
  2010-03-29 15:41 ` Ulrich Weigand
  0 siblings, 1 reply; 3+ messages in thread
From: Keith Seitz @ 2010-03-26 22:27 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 2011 bytes --]

Hi,

These three Java problems are all fairly related, so I'm submitting 
patches to fix all of them.

Explanation of the problems:

1) jmisc.exp failures
Ulrich Weigand recently pointed out that jmisc.exp was failing due to 
the recent dwarf2_physname patches. In actuality this test was already 
failing, but since dwarf2_physname, it just failed slightly differently. 
Previously, it failed because of bz 9320, but now it fails because it 
prints out constructor names like "jmisc(void)void". I've changed this 
so that it once again prints out "jmisc()".

2) bz 9320
This is the whole "java methods have return types appended" bug, e.g., 
"jmisc.main(java.lang.String[])void". In the output of the ptype 
command, the return type is already printed, so we don't need to see the 
appended return type here.

3) "void"
Methods which take no parameters were being marked "(void)" (just like 
C++). In fact, in java, this syntax is illegal. So I've changed 
physnames (and c_type_print_args) to NOT print "void" if the language is 
java.

I've also made a small change to jmisc.exp to allow the constructor to 
be listed before the method "main". All tests in jmisc.exp should now pass.

Regression tested on i686-pc-linux-gnu native.*

Keith

* Note that there are some java failures that were recently introduced. 
They do not affect these patches to the best of my knowledge. I reverted 
the offending patches for testing.

ChangeLog
2010-03-26  Keith Seitz  <keiths@redhat.com>

	* c-typeprint.c (c_type_print_args): Don't print "void"
	for java, regardless of whether it is TYPE_PROTOTYPED.
	Use the passed-in language instead of current_language.
	(c_type_print_varspec_suffix): Use current_language instead
	of assuming language_c.
	* jv-typeprint.c (java_type_print_base): (bz 9320) Strip off
	any return type specifier from the physname.

testsuite/ChangeLog
2010-03-26  Keith Seitz  <keiths@redhat.com>

	* gdb.java/jmisc.exp (ptype jmisc): Allow the constructor to
	appear in the output before main.

[-- Attachment #2: java-void.patch --]
[-- Type: text/plain, Size: 3661 bytes --]

Index: c-typeprint.c
===================================================================
RCS file: /cvs/src/src/gdb/c-typeprint.c,v
retrieving revision 1.54
diff -u -p -r1.54 c-typeprint.c
--- c-typeprint.c	9 Mar 2010 18:09:07 -0000	1.54
+++ c-typeprint.c	26 Mar 2010 22:13:08 -0000
@@ -416,8 +416,8 @@ c_type_print_args (struct type *type, st
 	}
     }
   else if (!printed_any
-      && (TYPE_PROTOTYPED (type)
-	  || current_language->la_language == language_cplus))
+	   && ((TYPE_PROTOTYPED (type) && language != language_java)
+	       || language == language_cplus))
     fprintf_filtered (stream, "void");
 
   fprintf_filtered (stream, ")");
@@ -616,7 +616,7 @@ c_type_print_varspec_suffix (struct type
       if (passed_a_ptr)
 	fprintf_filtered (stream, ")");
       if (!demangled_args)
-	c_type_print_args (type, stream, 1, language_c);
+	c_type_print_args (type, stream, 1, current_language->la_language);
       c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, show,
 				   passed_a_ptr, 0);
       break;
Index: jv-typeprint.c
===================================================================
RCS file: /cvs/src/src/gdb/jv-typeprint.c,v
retrieving revision 1.17
diff -u -p -r1.17 jv-typeprint.c
--- jv-typeprint.c	1 Jan 2010 07:31:36 -0000	1.17
+++ jv-typeprint.c	26 Mar 2010 22:13:08 -0000
@@ -28,6 +28,7 @@
 #include "typeprint.h"
 #include "c-lang.h"
 #include "cp-abi.h"
+#include "gdb_assert.h"
 
 /* Local functions */
 
@@ -219,10 +220,19 @@ java_type_print_base (struct type *type,
 
 	      for (j = 0; j < n_overloads; j++)
 		{
-		  char *physname;
+		  char *real_physname, *physname, *p;
 		  int is_full_physname_constructor;
 
-		  physname = TYPE_FN_FIELD_PHYSNAME (f, j);
+		  real_physname = TYPE_FN_FIELD_PHYSNAME (f, j);
+
+		  /* The physname will contain the return type
+		     after the final closing parenthesis.  Strip it off.  */
+		  p = strrchr (real_physname, ')');
+		  gdb_assert (p != NULL);
+		  ++p;   /* Keep the trailing ')'.  */
+		  physname = alloca (p - real_physname + 1);
+		  memcpy (physname, real_physname, p - real_physname);
+		  physname[p - real_physname] = '\0';
 
 		  is_full_physname_constructor
                     = (is_constructor_name (physname)
@@ -268,7 +278,7 @@ java_type_print_base (struct type *type,
 		    /* Build something we can demangle.  */
 		    mangled_name = gdb_mangle_name (type, i, j);
 		  else
-		    mangled_name = TYPE_FN_FIELD_PHYSNAME (f, j);
+		    mangled_name = physname;
 
 		  demangled_name =
 		    cplus_demangle (mangled_name,
Index: testsuite/gdb.java/jmisc.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.java/jmisc.exp,v
retrieving revision 1.15
diff -u -p -r1.15 jmisc.exp
--- testsuite/gdb.java/jmisc.exp	9 Mar 2010 18:08:04 -0000	1.15
+++ testsuite/gdb.java/jmisc.exp	26 Mar 2010 22:13:08 -0000
@@ -79,6 +79,8 @@ if ![set_lang_java] then {
     gdb_expect {   
 	-re "type = class jmisc  extends java.lang.Object \{\[\r\n\ \t]+void main\\(java\.lang\.String\\\[]\\);\[\r\n\ \t]+jmisc\\(\\);\[\r\n\ \t]+\}\[\r\n\ \t]+$gdb_prompt $"
 	    { pass "ptype jmisc" }
+	-re "type = class jmisc  extends java.lang.Object \{\[\r\n\ \t]+jmisc\\(\\);\[\r\n\ \t]+void main\\(java\.lang\.String\\\[]\\);\[\r\n\ \t]+\}\[\r\n\ \t]+$gdb_prompt $"
+	    { pass "ptype jmisc" }
 	-re "type = class jmisc  extends java.lang.Object \{\[\r\n\ \t]+void main\\(java\.lang\.String\\\[]\\)void;\[\r\n\ \t]+jmisc\\(\\);\[\r\n\ \t]+\}\[\r\n\ \t]+$gdb_prompt $" {
 	    # Just because GCC includes the signature doesn't mean we
 	    # should print it here.  We already show the return type.

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

* Re: [RFA] Fix jmisc.exp failures/bz 9320/java "void" issues
  2010-03-26 22:27 [RFA] Fix jmisc.exp failures/bz 9320/java "void" issues Keith Seitz
@ 2010-03-29 15:41 ` Ulrich Weigand
  2010-03-31  0:50   ` Keith Seitz
  0 siblings, 1 reply; 3+ messages in thread
From: Ulrich Weigand @ 2010-03-29 15:41 UTC (permalink / raw)
  To: Keith Seitz; +Cc: gdb-patches

Keith Seitz wrote:

> ChangeLog
> 2010-03-26  Keith Seitz  <keiths@redhat.com>
> 
> 	* c-typeprint.c (c_type_print_args): Don't print "void"
> 	for java, regardless of whether it is TYPE_PROTOTYPED.
> 	Use the passed-in language instead of current_language.
> 	(c_type_print_varspec_suffix): Use current_language instead
> 	of assuming language_c.
> 	* jv-typeprint.c (java_type_print_base): (bz 9320) Strip off
> 	any return type specifier from the physname.
> 
> testsuite/ChangeLog
> 2010-03-26  Keith Seitz  <keiths@redhat.com>
> 
> 	* gdb.java/jmisc.exp (ptype jmisc): Allow the constructor to
> 	appear in the output before main.

This is OK, thanks.

> Index: testsuite/gdb.java/jmisc.exp
> ===================================================================
> RCS file: /cvs/src/src/gdb/testsuite/gdb.java/jmisc.exp,v
> retrieving revision 1.15
> diff -u -p -r1.15 jmisc.exp
> --- testsuite/gdb.java/jmisc.exp	9 Mar 2010 18:08:04 -0000	1.15
> +++ testsuite/gdb.java/jmisc.exp	26 Mar 2010 22:13:08 -0000
> @@ -79,6 +79,8 @@ if ![set_lang_java] then {
>      gdb_expect {   
>  	-re "type = class jmisc  extends java.lang.Object \{\[\r\n\ \t]+void main\\(java\.lang\.String\\\[]\\);\[\r\n\ \t]+jmisc\\(\\);\[\r\n\ \t]+\}\[\r\n\ \t]+$gdb_prompt $"
>  	    { pass "ptype jmisc" }
> +	-re "type = class jmisc  extends java.lang.Object \{\[\r\n\ \t]+jmisc\\(\\);\[\r\n\ \t]+void main\\(java\.lang\.String\\\[]\\);\[\r\n\ \t]+\}\[\r\n\ \t]+$gdb_prompt $"
> +	    { pass "ptype jmisc" }
>  	-re "type = class jmisc  extends java.lang.Object \{\[\r\n\ \t]+void main\\(java\.lang\.String\\\[]\\)void;\[\r\n\ \t]+jmisc\\(\\);\[\r\n\ \t]+\}\[\r\n\ \t]+$gdb_prompt $" {
>  	    # Just because GCC includes the signature doesn't mean we
>  	    # should print it here.  We already show the return type.

It should be OK to remove that last clause now (the KFAIL for 9320), right?

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com

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

* Re: [RFA] Fix jmisc.exp failures/bz 9320/java "void" issues
  2010-03-29 15:41 ` Ulrich Weigand
@ 2010-03-31  0:50   ` Keith Seitz
  0 siblings, 0 replies; 3+ messages in thread
From: Keith Seitz @ 2010-03-31  0:50 UTC (permalink / raw)
  To: gdb-patches

On 03/29/2010 08:41 AM, Ulrich Weigand wrote:
> This is OK, thanks.

I have committed this. Thank you for reviewing it.

I have also closed 9320.

Keith

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

end of thread, other threads:[~2010-03-31  0:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-26 22:27 [RFA] Fix jmisc.exp failures/bz 9320/java "void" issues Keith Seitz
2010-03-29 15:41 ` Ulrich Weigand
2010-03-31  0:50   ` Keith Seitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).