* [RFA]: Java Inferior Call Take 2
@ 2004-05-17 20:53 Jeff Johnston
2004-06-11 17:49 ` Jeff Johnston
2004-06-17 3:06 ` Daniel Jacobowitz
0 siblings, 2 replies; 36+ messages in thread
From: Jeff Johnston @ 2004-05-17 20:53 UTC (permalink / raw)
To: gdb-patches
This is the reworked java inferior call patch. My previous attempt tried to
modify the gdb v3 abi code to handle missing debug information from gcj. After
a couple of gcc patches from Andrew Haley, the gnu-v3-abi.c code doesn't require
any tampering.
I had to enhance dwarf2read.c to handle the java vtable name (which is vtable)
and to modify C++-only code to handle java syntax for class names.
I have included a test case.
Ok to commit?
-- Jeff J.
2004-05-17 Jeff Johnston <jjohnstn@redhat.com>
* dwarf2read.c (typename_concat): Change prototype to accept dwarf2_cu
struct pointer as argument. Change function to use new argument to
determine language. If language is Java, use "." as separator,
otherwise, use "::".
(partial_die_parent_scope): Change comment to include java. Check
language to determine if Java "." or C++ "::" separator should be used.
(add_partial_symbol): Enhance tests for C++ to also test for Java.
(guess_structure_name): Ditto.
(read_subroutine_type): Ditto.
(new_symbol): Ditto.
(dwarf2_add_member_fn): Add check for Java when reading member name.
Java debug info includes full class name which must be stripped off.
(read_structure_type): Add Java vtable support.
(read_namespace): Add Java support.
* jv-exp.y (FuncStart): New pattern.
(MethodInvocation): Add support for simple function calls. Change
warning message for other forms of inferior call currently not
supported.
* valarith.c (value_subscript): Treat an array with upper-bound
of -1 as unknown size.
gdb/testsuite/ChangeLog:
2004-05-17 Jeff Johnston <jjohnstn@redhat.com>
* gdb.java/jprint.exp: New test for java inferior call.
* gdb.java/jprint.java: Ditto.
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.151
diff -u -p -r1.151 dwarf2read.c
--- dwarf2read.c 7 May 2004 14:29:33 -0000 1.151
+++ dwarf2read.c 17 May 2004 20:48:15 -0000
@@ -788,7 +788,8 @@ static void read_type_die (struct die_in
static char *determine_prefix (struct die_info *die, struct dwarf2_cu *);
-static char *typename_concat (const char *prefix, const char *suffix);
+static char *typename_concat (const char *prefix, const char *suffix,
+ struct dwarf2_cu *);
static void read_typedef (struct die_info *, struct dwarf2_cu *);
@@ -1502,7 +1503,8 @@ scan_partial_symbols (struct partial_die
/* Functions used to compute the fully scoped name of a partial DIE.
Normally, this is simple. For C++, the parent DIE's fully scoped
- name is concatenated with "::" and the partial DIE's name.
+ name is concatenated with "::" and the partial DIE's name. For
+ Java, the same thing occurs except that "." is used instead of "::".
Enumerators are an exception; they use the scope of their parent
enumeration type, i.e. the name of the enumeration type is not
prepended to the enumerator.
@@ -1558,7 +1560,7 @@ partial_die_parent_scope (struct partial
parent->scope = parent->name;
else
parent->scope = obconcat (&cu->comp_unit_obstack, grandparent_scope,
- "::", parent->name);
+ cu->language == language_java ? "." : "::", parent->name);
}
else if (parent->tag == DW_TAG_enumeration_type)
/* Enumerators should not get the name of the enumeration as a prefix. */
@@ -1590,7 +1592,11 @@ partial_die_full_name (struct partial_di
if (parent_scope == NULL)
return NULL;
else
- return concat (parent_scope, "::", pdi->name, NULL);
+ {
+ if (cu->language == language_java)
+ return concat (parent_scope, ".", pdi->name, NULL);
+ return concat (parent_scope, "::", pdi->name, NULL);
+ }
}
static void
@@ -1708,14 +1714,16 @@ add_partial_symbol (struct partial_die_i
return;
add_psymbol_to_list (actual_name, strlen (actual_name),
STRUCT_DOMAIN, LOC_TYPEDEF,
- cu->language == language_cplus
+ (cu->language == language_cplus
+ || cu->language == language_java)
? &objfile->global_psymbols
: &objfile->static_psymbols,
0, (CORE_ADDR) 0, cu->language, objfile);
- if (cu->language == language_cplus)
+ if (cu->language == language_cplus
+ || cu->language == language_java)
{
- /* For C++, these implicitly act as typedefs as well. */
+ /* For C++ and Java, these implicitly act as typedefs as well. */
add_psymbol_to_list (actual_name, strlen (actual_name),
VAR_DOMAIN, LOC_TYPEDEF,
&objfile->global_psymbols,
@@ -1725,7 +1733,8 @@ add_partial_symbol (struct partial_die_i
case DW_TAG_enumerator:
add_psymbol_to_list (actual_name, strlen (actual_name),
VAR_DOMAIN, LOC_CONST,
- cu->language == language_cplus
+ (cu->language == language_cplus
+ || cu->language == language_java)
? &objfile->global_psymbols
: &objfile->static_psymbols,
0, (CORE_ADDR) 0, cu->language, objfile);
@@ -1805,7 +1814,8 @@ static void
guess_structure_name (struct partial_die_info *struct_pdi,
struct dwarf2_cu *cu)
{
- if (cu->language == language_cplus
+ if ((cu->language == language_cplus
+ || cu->language == language_java)
&& cu->has_namespace_info == 0
&& struct_pdi->has_children)
{
@@ -2460,7 +2470,8 @@ read_func_scope (struct die_info *die, s
if (name == NULL || !dwarf2_get_pc_bounds (die, &lowpc, &highpc, cu))
return;
- if (cu->language == language_cplus)
+ if (cu->language == language_cplus
+ || cu->language == language_java)
{
struct die_info *spec_die = die_specification (die, cu);
@@ -3101,7 +3112,29 @@ dwarf2_add_member_fn (struct field_info
/* Get name of member function. */
attr = dwarf2_attr (die, DW_AT_name, cu);
if (attr && DW_STRING (attr))
- fieldname = DW_STRING (attr);
+ {
+ /* Note: C++ and Java currently differ in how the member function
+ name is stored in the debug info. For Java, the member name is
+ fully qualified with prototype while C++ just has the member
+ name. To get the Java member name, we strip off any dot qualifiers
+ and remove the trailing prototype. */
+ char *dot_index;
+ char *lparen;
+ fieldname = DW_STRING (attr);
+ if (cu->language == language_java)
+ {
+ dot_index = strchr (fieldname, '.');
+ while (dot_index)
+ {
+ fieldname = dot_index + 1;
+ dot_index = strchr (fieldname, '.');
+ }
+ lparen = strchr (fieldname + 1, '(');
+ if (lparen)
+ fieldname = obsavestring (fieldname, lparen - fieldname,
+ &objfile->objfile_obstack);
+ }
+ }
else
return;
@@ -3292,7 +3325,8 @@ read_structure_type (struct die_info *di
attr = dwarf2_attr (die, DW_AT_name, cu);
if (attr && DW_STRING (attr))
{
- if (cu->language == language_cplus)
+ if (cu->language == language_cplus
+ || cu->language == language_java)
{
char *new_prefix = determine_class_name (die, cu);
TYPE_TAG_NAME (type) = obsavestring (new_prefix,
@@ -3398,6 +3432,9 @@ read_structure_type (struct die_info *di
{
static const char vptr_name[] =
{'_', 'v', 'p', 't', 'r', '\0'};
+ static const char vtable_name[] =
+ {'v', 't', 'a', 'b', 'l', 'e', '\0'};
+
int i;
/* Our own class provides vtbl ptr. */
@@ -3407,10 +3444,18 @@ read_structure_type (struct die_info *di
{
char *fieldname = TYPE_FIELD_NAME (t, i);
- if ((strncmp (fieldname, vptr_name,
- strlen (vptr_name) - 1)
- == 0)
- && is_cplus_marker (fieldname[strlen (vptr_name)]))
+ if (cu->language == language_java
+ && (strncmp (fieldname, vtable_name,
+ strlen (vtable_name) - 1)
+ == 0))
+ {
+ TYPE_VPTR_FIELDNO (type) = i;
+ break;
+ }
+ else if ((strncmp (fieldname, vptr_name,
+ strlen (vptr_name) - 1)
+ == 0)
+ && is_cplus_marker (fieldname[strlen (vptr_name)]))
{
TYPE_VPTR_FIELDNO (type) = i;
break;
@@ -3502,7 +3547,9 @@ read_enumeration_type (struct die_info *
TYPE_TAG_NAME (type) = obconcat (&objfile->objfile_obstack,
processing_current_prefix,
processing_current_prefix[0] == '\0'
- ? "" : "::",
+ ? "" :
+ cu->language == language_java
+ ? "." : "::",
name);
}
else
@@ -3527,7 +3574,7 @@ read_enumeration_type (struct die_info *
}
/* Determine the name of the type represented by DIE, which should be
- a named C++ compound type. Return the name in question; the caller
+ a named C++ or Java compound type. Return the name in question; the caller
is responsible for xfree()'ing it. */
static char *
@@ -3573,7 +3620,8 @@ determine_class_name (struct die_info *d
{
const char *name = dwarf2_name (die, cu);
new_prefix = typename_concat (processing_current_prefix,
- name ? name : "<<anonymous>>");
+ name ? name : "<<anonymous>>",
+ cu);
}
if (back_to != NULL)
@@ -3810,7 +3858,10 @@ read_namespace (struct die_info *die, st
char *temp_name = alloca (strlen (previous_prefix)
+ 2 + strlen(name) + 1);
strcpy (temp_name, previous_prefix);
- strcat (temp_name, "::");
+ if (cu->language == language_java)
+ strcat (temp_name, ".");
+ else
+ strcat (temp_name, "::");
strcat (temp_name, name);
processing_current_prefix = temp_name;
@@ -4099,10 +4150,11 @@ read_subroutine_type (struct die_info *d
type = die_type (die, cu);
ftype = lookup_function_type (type);
- /* All functions in C++ have prototypes. */
+ /* All functions in C++ and Java have prototypes. */
attr = dwarf2_attr (die, DW_AT_prototyped, cu);
if ((attr && (DW_UNSND (attr) != 0))
- || cu->language == language_cplus)
+ || cu->language == language_cplus
+ || cu->language == language_java)
TYPE_FLAGS (ftype) |= TYPE_FLAG_PROTOTYPED;
if (die->child != NULL)
@@ -4753,7 +4805,8 @@ load_partial_dies (bfd *abfd, char *info
else if (building_psymtab)
add_psymbol_to_list (part_die->name, strlen (part_die->name),
VAR_DOMAIN, LOC_CONST,
- cu->language == language_cplus
+ (cu->language == language_cplus
+ || cu->language == language_java)
? &cu->objfile->global_psymbols
: &cu->objfile->static_psymbols,
0, (CORE_ADDR) 0, cu->language, cu->objfile);
@@ -6357,7 +6410,8 @@ new_symbol (struct die_info *die, struct
read_structure_type, and the correct name is saved in
the type. */
- if (cu->language == language_cplus)
+ if (cu->language == language_cplus
+ || cu->language == language_java)
{
struct type *type = SYMBOL_TYPE (sym);
@@ -6374,7 +6428,7 @@ new_symbol (struct die_info *die, struct
}
{
- /* NOTE: carlton/2003-11-10: C++ class symbols shouldn't
+ /* NOTE: carlton/2003-11-10: C++ and Java class symbols shouldn't
really ever be static objects: otherwise, if you try
to, say, break of a class's method and you're in a file
which doesn't mention that class, it won't work unless
@@ -6385,15 +6439,17 @@ new_symbol (struct die_info *die, struct
struct pending **list_to_add;
list_to_add = (cu->list_in_scope == &file_symbols
- && cu->language == language_cplus
+ && (cu->language == language_cplus
+ || cu->language == language_java)
? &global_symbols : cu->list_in_scope);
add_symbol_to_list (sym, list_to_add);
- /* The semantics of C++ state that "struct foo { ... }" also
+ /* The semantics of C++ and Java state that "struct foo { ... }" also
defines a typedef for "foo". Synthesize a typedef symbol so
that "ptype foo" works as expected. */
- if (cu->language == language_cplus)
+ if (cu->language == language_cplus
+ || cu->language == language_java)
{
struct symbol *typedef_sym = (struct symbol *)
obstack_alloc (&objfile->objfile_obstack,
@@ -6415,7 +6471,8 @@ new_symbol (struct die_info *die, struct
{
SYMBOL_LINKAGE_NAME (sym) = obconcat (&objfile->objfile_obstack,
processing_current_prefix,
- "::",
+ cu->language == language_java
+ ? "." : "::",
name);
}
SYMBOL_CLASS (sym) = LOC_TYPEDEF;
@@ -6434,7 +6491,8 @@ new_symbol (struct die_info *die, struct
{
SYMBOL_LINKAGE_NAME (sym) = obconcat (&objfile->objfile_obstack,
processing_current_prefix,
- "::",
+ cu->language == language_java
+ ? "." : "::",
name);
}
attr = dwarf2_attr (die, DW_AT_const_value, cu);
@@ -6449,7 +6507,8 @@ new_symbol (struct die_info *die, struct
struct pending **list_to_add;
list_to_add = (cu->list_in_scope == &file_symbols
- && cu->language == language_cplus
+ && (cu->language == language_cplus
+ || cu->language == language_java)
? &global_symbols : cu->list_in_scope);
add_symbol_to_list (sym, list_to_add);
@@ -6758,7 +6817,8 @@ determine_prefix (struct die_info *die,
{
struct die_info *parent;
- if (cu->language != language_cplus)
+ if (cu->language != language_cplus
+ && cu->language != language_java)
return NULL;
parent = die->parent;
@@ -6784,7 +6844,8 @@ determine_prefix (struct die_info *die,
char *parent_prefix = determine_prefix (parent, cu);
char *retval = typename_concat (parent_prefix,
namespace_name (parent, &dummy,
- cu));
+ cu),
+ cu);
xfree (parent_prefix);
return retval;
}
@@ -6818,11 +6879,11 @@ determine_prefix (struct die_info *die,
}
/* Return a newly-allocated string formed by concatenating PREFIX,
- "::", and SUFFIX, except that if PREFIX is NULL or the empty
+ "::" or ".", and SUFFIX, except that if PREFIX is NULL or the empty
string, just return a copy of SUFFIX. */
static char *
-typename_concat (const char *prefix, const char *suffix)
+typename_concat (const char *prefix, const char *suffix, struct dwarf2_cu *cu)
{
if (prefix == NULL || prefix[0] == '\0')
return xstrdup (suffix);
@@ -6831,7 +6892,10 @@ typename_concat (const char *prefix, con
char *retval = xmalloc (strlen (prefix) + 2 + strlen (suffix) + 1);
strcpy (retval, prefix);
- strcat (retval, "::");
+ if (cu->language == language_java)
+ strcat (retval, ".");
+ else
+ strcat (retval, "::");
strcat (retval, suffix);
return retval;
Index: jv-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/jv-exp.y,v
retrieving revision 1.18
diff -u -p -r1.18 jv-exp.y
--- jv-exp.y 23 Nov 2003 20:41:17 -0000 1.18
+++ jv-exp.y 17 May 2004 20:48:15 -0000
@@ -446,13 +446,22 @@ FieldAccess:
/*| SUPER '.' SimpleName { FIXME } */
;
+FuncStart:
+ Name '('
+ { push_expression_name ($1); }
+;
+
MethodInvocation:
- Name '(' ArgumentList_opt ')'
- { error (_("Method invocation not implemented")); }
+ FuncStart
+ { start_arglist(); }
+ ArgumentList_opt ')'
+ { write_exp_elt_opcode (OP_FUNCALL);
+ write_exp_elt_longcst ((LONGEST) end_arglist ());
+ write_exp_elt_opcode (OP_FUNCALL); }
| Primary '.' SimpleName '(' ArgumentList_opt ')'
- { error (_("Method invocation not implemented")); }
+ { error (_("Form of method invocation not implemented")); }
| SUPER '.' SimpleName '(' ArgumentList_opt ')'
- { error (_("Method invocation not implemented")); }
+ { error (_("Form of method invocation not implemented")); }
;
ArrayAccess:
Index: valarith.c
===================================================================
RCS file: /cvs/src/src/gdb/valarith.c,v
retrieving revision 1.22
diff -u -p -r1.22 valarith.c
--- valarith.c 1 Apr 2004 12:08:30 -0000 1.22
+++ valarith.c 17 May 2004 20:48:15 -0000
@@ -202,7 +202,10 @@ value_subscript (struct value *array, st
LONGEST index = value_as_long (idx);
if (index >= lowerbound && index <= upperbound)
return value_subscripted_rvalue (array, idx, lowerbound);
- warning ("array or string index out of range");
+ /* Emit warning unless we have an array of unknown size.
+ An array of unknown size has lowerbound 0 and upperbound -1. */
+ if (upperbound > -1)
+ warning ("array or string index out of range");
/* fall doing C stuff */
c_style = 1;
}
Index: gdb.java/jprint.exp
===================================================================
RCS file: gdb.java/jprint.exp
diff -N gdb.java/jprint.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gdb.java/jprint.exp 17 May 2004 20:52:27 -0000
@@ -0,0 +1,83 @@
+# Copyright 2004 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+
+# This file was written by Jeff Johnston. (jjohnstn@redhat.com)
+#
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+load_lib "java.exp"
+
+set testfile "jprint"
+set srcfile ${srcdir}/$subdir/${testfile}.java
+set binfile ${objdir}/${subdir}/${testfile}
+if { [compile_java_from_source ${srcfile} ${binfile} "-g"] != "" } {
+ untested "Couldn't compile ${srcfile}"
+ return -1
+}
+
+# Set the current language to java. This counts as a test. If it
+# fails, then we skip the other tests.
+
+proc set_lang_java {} {
+ global gdb_prompt
+ global binfile objdir subdir
+
+ verbose "loading file '$binfile'"
+ gdb_load $binfile
+
+ send_gdb "set language java\n"
+ gdb_expect {
+ -re ".*$gdb_prompt $" {}
+ timeout { fail "set language java (timeout)" ; return 0 }
+ }
+
+ return [gdb_test "show language" ".* source language is \"java\".*" \
+ "set language to \"java\""]
+}
+
+set prms_id 0
+set bug_id 0
+
+# Start with a fresh gdb.
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+
+gdb_test "set print sevenbit-strings" ".*"
+
+if ![set_lang_java] then {
+ # Ref PR gdb:java/1565. Don't use the simpler "break jmisc.main".
+ # As of 2004-02-24 it wasn't working and is being tested separatly.
+ runto "\'${testfile}.main(java.lang.String\[\])\'"
+
+ gdb_test "p jvclass.addprint(4,5,6)" "sum is 15\r\n.*" "unambiguous static call"
+
+ gdb_test "next" ""
+ gdb_test "next" ""
+
+ gdb_test "p x.print(44)" "x is 44\r\n.*" "single argument print call"
+ gdb_test "p x.print(22,33)" "y is 33\r\n.*" "double argument print call"
+ gdb_test "call x.dothat(55)" "new value is 58\r\n.*= 62.*" "virtual fn call"
+ gdb_test "p x.addprint(1,2,3)" "sum is 6\r\n.*" "inherited static call"
+ gdb_test "call x.addk(44)" "adding k gives 121\r\n.*= 121.*" "inherited virtual fn call"
+}
Index: gdb.java/jprint.java
===================================================================
RCS file: gdb.java/jprint.java
diff -N gdb.java/jprint.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gdb.java/jprint.java 17 May 2004 20:52:27 -0000
@@ -0,0 +1,62 @@
+// jprint.java test program.
+//
+// Copyright 2004
+// Free Software Foundation, Inc.
+//
+// Written by Jeff Johnston <jjohnstn@redhat.com>
+// Contributed by Red Hat
+//
+// This file is part of GDB.
+//
+// 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
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+
+class jvclass {
+ public static int k;
+ static {
+ k = 77;
+ }
+ public static void addprint (int x, int y, int z) {
+ int sum = x + y + z;
+ System.out.println ("sum is " + sum);
+ }
+
+ public int addk (int x) {
+ int sum = x + k;
+ System.out.println ("adding k gives " + sum);
+ return sum;
+ }
+}
+
+public class jprint extends jvclass {
+ public int dothat (int x) {
+ int y = x + 3;
+ System.out.println ("new value is " + y);
+ return y + 4;
+ }
+ public static void print (int x) {
+ System.out.println("x is " + x);
+ }
+ public static void print (int x, int y) {
+ System.out.println("y is " + y);
+ }
+ public static void main(String[] args) {
+ jprint x = new jprint ();
+ x.print (44);
+ print (k, 33);
+ }
+}
+
+
From jimb@redhat.com Mon May 17 20:53:00 2004
From: Jim Blandy <jimb@redhat.com>
To: gdb-patches@sources.redhat.com
Subject: RFA: use constructor to build 'struct regset' objects
Date: Mon, 17 May 2004 20:53:00 -0000
Message-id: <vt2smdy93u9.fsf@zenia.home>
X-SW-Source: 2004-05/msg00510.html
Content-length: 15431
2004-05-17 Jim Blandy <jimb@redhat.com>
Use a constructor function to create regset structures.
* regset.h (supply_regset_ftype): New typedef.
(struct regset): Use supply_regset_ftype.
(readonly_regset_xmalloc): New declaration.
* regset.c: New file.
* am64-tdep.c (amd64_regset_from_core_section): Use
readonly_regset_xmalloc to construct regset structures.
* amd64obsd-tdep.c (amd64obsd_regset_from_core_section): Same.
* i386-tdep.c (i386_regset_from_core_section): Same.
* i386nbsd-tdep.c (i386nbsd_aout_regset_from_core_section): Same.
* i386obsd-tdep.c (i386obsd_aout_regset_from_core_section): Same.
* sparc64fbsd-tdep.c (sparc64fbsd_init_abi): Same.
* sparc64nbsd-tdep.c (sparc64nbsd_init_abi): Same.
* sparc64obsd-tdep.c (sparc64obsd_init_abi): Same.
* sparcnbsd-tdep.c (sparc32nbsd_init_abi): Same.
* Makefile.in (COMMON_OBS): Add regset.o.
(regset.o): New rule.
Index: gdb/regset.h
===================================================================
RCS file: /cvs/src/src/gdb/regset.h,v
retrieving revision 1.1
diff -c -p -r1.1 regset.h
*** gdb/regset.h 26 Sep 2003 14:36:56 -0000 1.1
--- gdb/regset.h 17 May 2004 19:24:09 -0000
*************** struct gdbarch;
*** 26,31 ****
--- 26,33 ----
struct regcache;
/* Data structure describing a register set. */
+ typedef void (supply_regset_ftype) (const struct regset *, struct regcache *,
+ int, const void *, size_t);
struct regset
{
*************** struct regset
*** 34,41 ****
const void *descr;
/* Function supplying a register set to a register cache. */
! void (*supply_regset) (const struct regset *, struct regcache *,
! int, const void *, size_t);
};
#endif /* regset.h */
--- 36,51 ----
const void *descr;
/* Function supplying a register set to a register cache. */
! supply_regset_ftype *supply_regset;
};
+
+
+ /* Allocate a fresh 'struct regset' whose descr is DESCR and whose
+ supply_regset function is SUPPLY_REGSET. The object returned is
+ allocated using xmalloc. */
+ extern struct regset *(readonly_regset_xmalloc
+ (void *descr,
+ supply_regset_ftype *supply_regset));
+
#endif /* regset.h */
Index: gdb/regset.c
===================================================================
RCS file: gdb/regset.c
diff -N gdb/regset.c
*** gdb/regset.c 1 Jan 1970 00:00:00 -0000
--- gdb/regset.c 17 May 2004 19:24:09 -0000
***************
*** 0 ****
--- 1,35 ----
+ /* Regset support functions, for GDB.
+
+ Copyright 2004 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ 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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+ #include "defs.h"
+ #include "regset.h"
+
+
+ struct regset *readonly_regset_xmalloc (void *descr,
+ supply_regset_ftype *supply_regset)
+ {
+ struct regset *r = (struct regset *) xmalloc (sizeof (*r));
+
+ r->descr = descr;
+ r->supply_regset = supply_regset;
+
+ return r;
+ }
Index: gdb/amd64-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/amd64-tdep.c,v
retrieving revision 1.9
diff -c -p -r1.9 amd64-tdep.c
*** gdb/amd64-tdep.c 9 May 2004 19:48:25 -0000 1.9
--- gdb/amd64-tdep.c 17 May 2004 19:24:06 -0000
*************** amd64_regset_from_core_section (struct g
*** 1074,1084 ****
if (strcmp (sect_name, ".reg2") == 0 && sect_size == tdep->sizeof_fpregset)
{
if (tdep->fpregset == NULL)
! {
! tdep->fpregset = XMALLOC (struct regset);
! tdep->fpregset->descr = tdep;
! tdep->fpregset->supply_regset = amd64_supply_fpregset;
! }
return tdep->fpregset;
}
--- 1074,1080 ----
if (strcmp (sect_name, ".reg2") == 0 && sect_size == tdep->sizeof_fpregset)
{
if (tdep->fpregset == NULL)
! tdep->fpregset = readonly_regset_xmalloc (tdep, amd64_supply_fpregset);
return tdep->fpregset;
}
Index: gdb/amd64obsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/amd64obsd-tdep.c,v
retrieving revision 1.9
diff -c -p -r1.9 amd64obsd-tdep.c
*** gdb/amd64obsd-tdep.c 9 Apr 2004 23:26:19 -0000 1.9
--- gdb/amd64obsd-tdep.c 17 May 2004 19:24:06 -0000
*************** amd64obsd_regset_from_core_section (stru
*** 63,73 ****
&& sect_size >= tdep->sizeof_gregset + I387_SIZEOF_FXSAVE)
{
if (tdep->gregset == NULL)
! {
! tdep->gregset = XMALLOC (struct regset);
! tdep->gregset->descr = tdep;
! tdep->gregset->supply_regset = amd64obsd_supply_regset;
! }
return tdep->gregset;
}
--- 63,70 ----
&& sect_size >= tdep->sizeof_gregset + I387_SIZEOF_FXSAVE)
{
if (tdep->gregset == NULL)
! tdep->gregset
! = readonly_regset_xmalloc (tdep, amd64obsd_supply_regset);
return tdep->gregset;
}
Index: gdb/i386-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-tdep.c,v
retrieving revision 1.191
diff -c -p -r1.191 i386-tdep.c
*** gdb/i386-tdep.c 8 May 2004 23:02:10 -0000 1.191
--- gdb/i386-tdep.c 17 May 2004 19:24:07 -0000
*************** i386_regset_from_core_section (struct gd
*** 1662,1672 ****
if (strcmp (sect_name, ".reg") == 0 && sect_size == tdep->sizeof_gregset)
{
if (tdep->gregset == NULL)
! {
! tdep->gregset = XMALLOC (struct regset);
! tdep->gregset->descr = tdep;
! tdep->gregset->supply_regset = i386_supply_gregset;
! }
return tdep->gregset;
}
--- 1662,1668 ----
if (strcmp (sect_name, ".reg") == 0 && sect_size == tdep->sizeof_gregset)
{
if (tdep->gregset == NULL)
! tdep->gregset = readonly_regset_xmalloc (tdep, i386_supply_gregset);
return tdep->gregset;
}
*************** i386_regset_from_core_section (struct gd
*** 1675,1685 ****
&& sect_size == I387_SIZEOF_FXSAVE))
{
if (tdep->fpregset == NULL)
! {
! tdep->fpregset = XMALLOC (struct regset);
! tdep->fpregset->descr = tdep;
! tdep->fpregset->supply_regset = i386_supply_fpregset;
! }
return tdep->fpregset;
}
--- 1671,1677 ----
&& sect_size == I387_SIZEOF_FXSAVE))
{
if (tdep->fpregset == NULL)
! tdep->fpregset = readonly_regset_xmalloc (tdep, i386_supply_fpregset);
return tdep->fpregset;
}
Index: gdb/i386nbsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386nbsd-tdep.c,v
retrieving revision 1.24
diff -c -p -r1.24 i386nbsd-tdep.c
*** gdb/i386nbsd-tdep.c 9 Apr 2004 23:26:19 -0000 1.24
--- gdb/i386nbsd-tdep.c 17 May 2004 19:24:07 -0000
*************** i386nbsd_aout_regset_from_core_section (
*** 86,96 ****
&& sect_size >= tdep->sizeof_gregset + I387_SIZEOF_FSAVE)
{
if (tdep->gregset == NULL)
! {
! tdep->gregset = XMALLOC (struct regset);
! tdep->gregset->descr = tdep;
! tdep->gregset->supply_regset = i386nbsd_aout_supply_regset;
! }
return tdep->gregset;
}
--- 86,93 ----
&& sect_size >= tdep->sizeof_gregset + I387_SIZEOF_FSAVE)
{
if (tdep->gregset == NULL)
! tdep->gregset
! = readonly_regset_xmalloc (tdep, i386nbsd_aout_supply_regset);
return tdep->gregset;
}
Index: gdb/i386obsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386obsd-tdep.c,v
retrieving revision 1.15
diff -c -p -r1.15 i386obsd-tdep.c
*** gdb/i386obsd-tdep.c 9 Apr 2004 23:26:19 -0000 1.15
--- gdb/i386obsd-tdep.c 17 May 2004 19:24:07 -0000
*************** i386obsd_aout_regset_from_core_section (
*** 141,151 ****
&& sect_size >= tdep->sizeof_gregset + I387_SIZEOF_FSAVE)
{
if (tdep->gregset == NULL)
! {
! tdep->gregset = XMALLOC (struct regset);
! tdep->gregset->descr = tdep;
! tdep->gregset->supply_regset = i386obsd_aout_supply_regset;
! }
return tdep->gregset;
}
--- 141,148 ----
&& sect_size >= tdep->sizeof_gregset + I387_SIZEOF_FSAVE)
{
if (tdep->gregset == NULL)
! tdep->gregset
! = readonly_regset_xmalloc (tdep, i386obsd_aout_supply_regset);
return tdep->gregset;
}
Index: gdb/sparc64fbsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sparc64fbsd-tdep.c,v
retrieving revision 1.6
diff -c -p -r1.6 sparc64fbsd-tdep.c
*** gdb/sparc64fbsd-tdep.c 10 Apr 2004 09:40:02 -0000 1.6
--- gdb/sparc64fbsd-tdep.c 17 May 2004 19:24:11 -0000
*************** sparc64fbsd_init_abi (struct gdbarch_inf
*** 199,211 ****
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
! tdep->gregset = XMALLOC (struct regset);
! tdep->gregset->descr = &sparc64fbsd_gregset;
! tdep->gregset->supply_regset = sparc64fbsd_supply_gregset;
tdep->sizeof_gregset = 256;
! tdep->fpregset = XMALLOC (struct regset);
! tdep->fpregset->supply_regset = sparc64fbsd_supply_fpregset;
tdep->sizeof_fpregset = 272;
frame_unwind_append_sniffer (gdbarch, sparc64fbsd_sigtramp_frame_sniffer);
--- 199,209 ----
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
! tdep->gregset = readonly_regset_xmalloc (&sparc64fbsd_gregset,
! sparc64fbsd_supply_gregset);
tdep->sizeof_gregset = 256;
! tdep->fpregset = readonly_regset_xmalloc (NULL, sparc64fbsd_supply_fpregset);
tdep->sizeof_fpregset = 272;
frame_unwind_append_sniffer (gdbarch, sparc64fbsd_sigtramp_frame_sniffer);
Index: gdb/sparc64nbsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sparc64nbsd-tdep.c,v
retrieving revision 1.7
diff -c -p -r1.7 sparc64nbsd-tdep.c
*** gdb/sparc64nbsd-tdep.c 10 Apr 2004 09:40:02 -0000 1.7
--- gdb/sparc64nbsd-tdep.c 17 May 2004 19:24:12 -0000
*************** sparc64nbsd_init_abi (struct gdbarch_inf
*** 226,238 ****
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
! tdep->gregset = XMALLOC (struct regset);
! tdep->gregset->descr = &sparc64nbsd_gregset;
! tdep->gregset->supply_regset = sparc64nbsd_supply_gregset;
tdep->sizeof_gregset = 160;
! tdep->fpregset = XMALLOC (struct regset);
! tdep->fpregset->supply_regset = sparc64nbsd_supply_fpregset;
tdep->sizeof_fpregset = 272;
frame_unwind_append_sniffer (gdbarch, sparc64nbsd_sigtramp_frame_sniffer);
--- 226,236 ----
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
! tdep->gregset = readonly_regset_xmalloc (&sparc64nbsd_gregset,
! sparc64nbsd_supply_gregset);
tdep->sizeof_gregset = 160;
! tdep->fpregset = readonly_regset_xmalloc (NULL, sparc64nbsd_supply_fpregset);
tdep->sizeof_fpregset = 272;
frame_unwind_append_sniffer (gdbarch, sparc64nbsd_sigtramp_frame_sniffer);
Index: gdb/sparc64obsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sparc64obsd-tdep.c,v
retrieving revision 1.3
diff -c -p -r1.3 sparc64obsd-tdep.c
*** gdb/sparc64obsd-tdep.c 10 Apr 2004 09:40:02 -0000 1.3
--- gdb/sparc64obsd-tdep.c 17 May 2004 19:24:12 -0000
*************** sparc64obsd_init_abi (struct gdbarch_inf
*** 184,192 ****
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
! tdep->gregset = XMALLOC (struct regset);
! tdep->gregset->descr = &sparc64obsd_core_gregset;
! tdep->gregset->supply_regset = sparc64obsd_supply_gregset;
tdep->sizeof_gregset = 832;
frame_unwind_append_sniffer (gdbarch, sparc64obsd_sigtramp_frame_sniffer);
--- 184,191 ----
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
! tdep->gregset = readonly_regset_xmalloc (&sparc64obsd_core_gregset,
! sparc64obsd_supply_gregset);
tdep->sizeof_gregset = 832;
frame_unwind_append_sniffer (gdbarch, sparc64obsd_sigtramp_frame_sniffer);
Index: gdb/sparcnbsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sparcnbsd-tdep.c,v
retrieving revision 1.18
diff -c -p -r1.18 sparcnbsd-tdep.c
*** gdb/sparcnbsd-tdep.c 18 Apr 2004 22:58:06 -0000 1.18
--- gdb/sparcnbsd-tdep.c 17 May 2004 19:24:12 -0000
*************** sparc32nbsd_init_abi (struct gdbarch_inf
*** 274,286 ****
set_gdbarch_long_double_bit (gdbarch, 64);
set_gdbarch_long_double_format (gdbarch, &floatformat_ieee_double_big);
! tdep->gregset = XMALLOC (struct regset);
! tdep->gregset->descr = &sparc32nbsd_gregset;
! tdep->gregset->supply_regset = sparc32nbsd_supply_gregset;
tdep->sizeof_gregset = 20 * 4;
! tdep->fpregset = XMALLOC (struct regset);
! tdep->fpregset->supply_regset = sparc32nbsd_supply_fpregset;
tdep->sizeof_fpregset = 33 * 4;
frame_unwind_append_sniffer (gdbarch, sparc32nbsd_sigtramp_frame_sniffer);
--- 274,284 ----
set_gdbarch_long_double_bit (gdbarch, 64);
set_gdbarch_long_double_format (gdbarch, &floatformat_ieee_double_big);
! tdep->gregset = readonly_regset_xmalloc (&sparc32nbsd_gregset,
! sparc32nbsd_supply_gregset);
tdep->sizeof_gregset = 20 * 4;
! tdep->fpregset = readonly_regset_xmalloc (NULL, sparc32nbsd_supply_fpregset);
tdep->sizeof_fpregset = 33 * 4;
frame_unwind_append_sniffer (gdbarch, sparc32nbsd_sigtramp_frame_sniffer);
Index: gdb/Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.569
diff -c -p -r1.569 Makefile.in
*** gdb/Makefile.in 11 May 2004 04:55:31 -0000 1.569
--- gdb/Makefile.in 17 May 2004 19:24:04 -0000
*************** COMMON_OBS = $(DEPFILES) $(YYOBJ) \
*** 910,916 ****
frame-base.o \
gnu-v2-abi.o gnu-v3-abi.o hpacc-abi.o cp-abi.o cp-support.o \
cp-namespace.o \
! reggroups.o \
trad-frame.o \
tramp-frame.o
--- 910,916 ----
frame-base.o \
gnu-v2-abi.o gnu-v3-abi.o hpacc-abi.o cp-abi.o cp-support.o \
cp-namespace.o \
! reggroups.o regset.o \
trad-frame.o \
tramp-frame.o
*************** regcache.o: regcache.c $(defs_h) $(infer
*** 2199,2204 ****
--- 2199,2205 ----
$(gdb_string_h) $(gdbcmd_h) $(observer_h)
reggroups.o: reggroups.c $(defs_h) $(reggroups_h) $(gdbtypes_h) \
$(gdb_assert_h) $(regcache_h) $(command_h) $(gdbcmd_h)
+ regset.o: regset.c $(defs_h) $(regset_h)
remote.o: remote.c $(defs_h) $(gdb_string_h) $(inferior_h) $(bfd_h) \
$(symfile_h) $(target_h) $(gdbcmd_h) $(objfiles_h) $(gdb_stabs_h) \
$(gdbthread_h) $(remote_h) $(regcache_h) $(value_h) $(gdb_assert_h) \
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [RFA]: Java Inferior Call Take 2
2004-05-17 20:53 [RFA]: Java Inferior Call Take 2 Jeff Johnston
@ 2004-06-11 17:49 ` Jeff Johnston
2004-06-17 3:06 ` Daniel Jacobowitz
1 sibling, 0 replies; 36+ messages in thread
From: Jeff Johnston @ 2004-06-11 17:49 UTC (permalink / raw)
To: Jeff Johnston; +Cc: gdb-patches
Ping.
Jeff Johnston wrote:
> This is the reworked java inferior call patch. My previous attempt
> tried to modify the gdb v3 abi code to handle missing debug information
> from gcj. After a couple of gcc patches from Andrew Haley, the
> gnu-v3-abi.c code doesn't require any tampering.
>
> I had to enhance dwarf2read.c to handle the java vtable name (which is
> vtable) and to modify C++-only code to handle java syntax for class names.
>
> I have included a test case.
>
> Ok to commit?
>
> -- Jeff J.
>
> 2004-05-17 Jeff Johnston <jjohnstn@redhat.com>
>
> * dwarf2read.c (typename_concat): Change prototype to accept dwarf2_cu
> struct pointer as argument. Change function to use new argument to
> determine language. If language is Java, use "." as separator,
> otherwise, use "::".
> (partial_die_parent_scope): Change comment to include java. Check
> language to determine if Java "." or C++ "::" separator should be used.
> (add_partial_symbol): Enhance tests for C++ to also test for Java.
> (guess_structure_name): Ditto.
> (read_subroutine_type): Ditto.
> (new_symbol): Ditto.
> (dwarf2_add_member_fn): Add check for Java when reading member name.
> Java debug info includes full class name which must be stripped off.
> (read_structure_type): Add Java vtable support.
> (read_namespace): Add Java support.
> * jv-exp.y (FuncStart): New pattern.
> (MethodInvocation): Add support for simple function calls. Change
> warning message for other forms of inferior call currently not
> supported.
> * valarith.c (value_subscript): Treat an array with upper-bound
> of -1 as unknown size.
>
> gdb/testsuite/ChangeLog:
>
> 2004-05-17 Jeff Johnston <jjohnstn@redhat.com>
>
> * gdb.java/jprint.exp: New test for java inferior call.
> * gdb.java/jprint.java: Ditto.
>
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [RFA]: Java Inferior Call Take 2
2004-05-17 20:53 [RFA]: Java Inferior Call Take 2 Jeff Johnston
2004-06-11 17:49 ` Jeff Johnston
@ 2004-06-17 3:06 ` Daniel Jacobowitz
2004-06-17 20:52 ` Jeff Johnston
1 sibling, 1 reply; 36+ messages in thread
From: Daniel Jacobowitz @ 2004-06-17 3:06 UTC (permalink / raw)
To: gdb-patches
On Mon, May 17, 2004 at 04:53:32PM -0400, Jeff Johnston wrote:
> This is the reworked java inferior call patch. My previous attempt tried
> to modify the gdb v3 abi code to handle missing debug information from gcj.
> After a couple of gcc patches from Andrew Haley, the gnu-v3-abi.c code
> doesn't require any tampering.
>
> I had to enhance dwarf2read.c to handle the java vtable name (which is
> vtable) and to modify C++-only code to handle java syntax for class names.
>
> I have included a test case.
>
> Ok to commit?
First of all, it doesn't work for me; I'm guessing that's because I
have gcj 3.3 installed. Are the GCC changes in any released version of
GCC yet, so that I can add appropriately versioned XFAILs?
> * valarith.c (value_subscript): Treat an array with upper-bound
> of -1 as unknown size.
I still don't understand why this change is necessary, i.e. why
providing a large upper bound causes the whole memory region to be
loaded from the inferior. That should not happen.
> @@ -3101,7 +3112,29 @@ dwarf2_add_member_fn (struct field_info
> /* Get name of member function. */
> attr = dwarf2_attr (die, DW_AT_name, cu);
> if (attr && DW_STRING (attr))
> - fieldname = DW_STRING (attr);
> + {
> + /* Note: C++ and Java currently differ in how the member function
> + name is stored in the debug info. For Java, the member name is
> + fully qualified with prototype while C++ just has the member
> + name. To get the Java member name, we strip off any dot qualifiers
> + and remove the trailing prototype. */
Other changes have been made to gcj's debug output in order for this to
work; wouldn't this be a good time to fix the above? No one's given a
reason that I recall for GCJ to abuse DW_AT_name in this fashion.
--
Daniel Jacobowitz
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [RFA]: Java Inferior Call Take 2
2004-06-17 3:06 ` Daniel Jacobowitz
@ 2004-06-17 20:52 ` Jeff Johnston
2004-06-19 23:59 ` Daniel Jacobowitz
0 siblings, 1 reply; 36+ messages in thread
From: Jeff Johnston @ 2004-06-17 20:52 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
Daniel Jacobowitz wrote:
> On Mon, May 17, 2004 at 04:53:32PM -0400, Jeff Johnston wrote:
>
>>This is the reworked java inferior call patch. My previous attempt tried
>>to modify the gdb v3 abi code to handle missing debug information from gcj.
>>After a couple of gcc patches from Andrew Haley, the gnu-v3-abi.c code
>>doesn't require any tampering.
>>
>>I had to enhance dwarf2read.c to handle the java vtable name (which is
>>vtable) and to modify C++-only code to handle java syntax for class names.
>>
>>I have included a test case.
>>
>>Ok to commit?
>
>
> First of all, it doesn't work for me; I'm guessing that's because I
> have gcj 3.3 installed. Are the GCC changes in any released version of
> GCC yet, so that I can add appropriately versioned XFAILs?
>
I am using current gcc sources because Andrew Haley only recently added the
fixes. It has to be post 3.4.0 which is the last release but prior to Andrew's
patches.
>
>> * valarith.c (value_subscript): Treat an array with upper-bound
>> of -1 as unknown size.
>
>
> I still don't understand why this change is necessary, i.e. why
> providing a large upper bound causes the whole memory region to be
> loaded from the inferior. That should not happen.
>
>
The change "is" needed or the warning gets issued in value_subscript. C and C++
get away with it because of c_style_arrays.
The other solution is to change the range of the virtual_functions array to have
a large value for an upperbound, but that requires a change to gnu-v3-abi.c
which "you asked me not to change".
static void *
build_gdb_vtable_type (struct gdbarch *arch)
.
.
.
/* void (*virtual_functions[0]) (); */
FIELD_NAME (*field) = "virtual_functions";
FIELD_TYPE (*field)
= create_array_type (0, ptr_to_void_fn_type,
create_range_type (0, builtin_type_int, 0, -1));
FIELD_BITPOS (*field) = offset * TARGET_CHAR_BIT;
offset += TYPE_LENGTH (FIELD_TYPE (*field));
field++;
Changing the -1 above to INT_MAX/4 results in a virtual memory exhausted error
when making a virtual function call. Backtracing, we see:
(outer) bt
#0 internal_error (
file=0x822e740
"/home/jjohnstn/gdb-patches/inf-call-java-may12-2004/src/gdb/utils.c",
line=1036, string=0x822e934 "virtual memory exhausted.")
at /home/jjohnstn/gdb-patches/inf-call-java-may12-2004/src/gdb/utils.c:835
#1 0x08082a0a in nomem (size=-2147483564)
at /home/jjohnstn/gdb-patches/inf-call-java-may12-2004/src/gdb/utils.c:1036
#2 0x08082a42 in xmmalloc (md=0x0, size=2147483732)
#3 0x08082b27 in xmalloc (size=2147483732)
at /home/jjohnstn/gdb-patches/inf-call-java-may12-2004/src/gdb/utils.c:1128
#4 0x080dcd2d in allocate_value (type=0x8358b48)
at /home/jjohnstn/gdb-patches/inf-call-java-may12-2004/src/gdb/values.c:86
#5 0x080e4938 in value_at_lazy (type=0x8358b48, addr=134521984, sect=0x0)
at /home/jjohnstn/gdb-patches/inf-call-java-may12-2004/src/gdb/valops.c:485
#6 0x081878f0 in gnuv3_virtual_fn_field (value_p=0xbfffb28c, f=0x836da8c,
j=0, type=0x834ab18, offset=0)
at /home/jjohnstn/gdb-patches/inf-call-java-may12-2004/src/gdb/gnu-v3-abi.c:332
>>@@ -3101,7 +3112,29 @@ dwarf2_add_member_fn (struct field_info
>> /* Get name of member function. */
>> attr = dwarf2_attr (die, DW_AT_name, cu);
>> if (attr && DW_STRING (attr))
>>- fieldname = DW_STRING (attr);
>>+ {
>>+ /* Note: C++ and Java currently differ in how the member function
>>+ name is stored in the debug info. For Java, the member name is
>>+ fully qualified with prototype while C++ just has the member
>>+ name. To get the Java member name, we strip off any dot qualifiers
>>+ and remove the trailing prototype. */
>
>
> Other changes have been made to gcj's debug output in order for this to
> work; wouldn't this be a good time to fix the above? No one's given a
> reason that I recall for GCJ to abuse DW_AT_name in this fashion.
>
Perhaps, but perfection is always an on-going goal. IMO, this isn't worth
holding up the patch while we discuss this with gcc. The code certainly is not
a problem for anybody to maintain and I am perfectly willing to put a FIXME note
for the time-being.
-- Jeff J.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [RFA]: Java Inferior Call Take 2
2004-06-17 20:52 ` Jeff Johnston
@ 2004-06-19 23:59 ` Daniel Jacobowitz
2004-06-21 10:49 ` Andrew Haley
2004-06-21 15:17 ` Andrew Haley
0 siblings, 2 replies; 36+ messages in thread
From: Daniel Jacobowitz @ 2004-06-19 23:59 UTC (permalink / raw)
To: Jeff Johnston; +Cc: gdb-patches, java
On Thu, Jun 17, 2004 at 04:52:36PM -0400, Jeff Johnston wrote:
> Daniel Jacobowitz wrote:
> >On Mon, May 17, 2004 at 04:53:32PM -0400, Jeff Johnston wrote:
> >
> >>This is the reworked java inferior call patch. My previous attempt tried
> >>to modify the gdb v3 abi code to handle missing debug information from
> >>gcj. After a couple of gcc patches from Andrew Haley, the gnu-v3-abi.c
> >>code doesn't require any tampering.
> >>
> >>I had to enhance dwarf2read.c to handle the java vtable name (which is
> >>vtable) and to modify C++-only code to handle java syntax for class names.
> >>
> >>I have included a test case.
> >>
> >>Ok to commit?
> >
> >
> >First of all, it doesn't work for me; I'm guessing that's because I
> >have gcj 3.3 installed. Are the GCC changes in any released version of
> >GCC yet, so that I can add appropriately versioned XFAILs?
> >
>
> I am using current gcc sources because Andrew Haley only recently added the
> fixes. It has to be post 3.4.0 which is the last release but prior to
> Andrew's patches.
Are you actually using GCC HEAD? Gcj does not even emit debug info for
the local variable "x" in jprint.main using today's CVS.
> >> * valarith.c (value_subscript): Treat an array with upper-bound
> >> of -1 as unknown size.
> >
> >
> >I still don't understand why this change is necessary, i.e. why
> >providing a large upper bound causes the whole memory region to be
> >loaded from the inferior. That should not happen.
> >
> >
>
> The change "is" needed or the warning gets issued in value_subscript. C
> and C++ get away with it because of c_style_arrays.
>
> The other solution is to change the range of the virtual_functions array to
> have a large value for an upperbound, but that requires a change to
> gnu-v3-abi.c which "you asked me not to change".
I wrote:
If you make the debug readers recognize this as the vtable for Java
symbols, then the existing machinery should work, without having to
do all this grubbing around in the v3 ABI code.
That's "these changes should not be necessary", not "keep your hands
off this file"! In any case:
> Changing the -1 above to INT_MAX/4 results in a virtual memory exhausted
> error when making a virtual function call. Backtracing, we see:
> #4 0x080dcd2d in allocate_value (type=0x8358b48)
> at
> /home/jjohnstn/gdb-patches/inf-call-java-may12-2004/src/gdb/values.c:86
> #5 0x080e4938 in value_at_lazy (type=0x8358b48, addr=134521984, sect=0x0)
> at
> /home/jjohnstn/gdb-patches/inf-call-java-may12-2004/src/gdb/valops.c:485
The answer to my earlier question is that lazy values read from the
target lazily, but allocate memory eagerly. So using a large upper
bound won't work. The -1 is OK, I think.
> >Other changes have been made to gcj's debug output in order for this to
> >work; wouldn't this be a good time to fix the above? No one's given a
> >reason that I recall for GCJ to abuse DW_AT_name in this fashion.
> >
>
> Perhaps, but perfection is always an on-going goal. IMO, this isn't worth
> holding up the patch while we discuss this with gcc. The code certainly is
> not a problem for anybody to maintain and I am perfectly willing to put a
> FIXME note for the time-being.
I would prefer this be fixed before the code is included; every hack we
add to accept invalid debug information is a maintenance burden. I was
going to attach a GCC patch to this message, but I can't find a gcj
that "works" for purposes of this test case to base my changes on.
java@ folks:
- the testcase that I'm not getting local variables from is at
http://sources.redhat.com/ml/gdb-patches/2004-05/msg00509.html
Tree-ssa has been merged since Jeff first posted that patch, so
that's probably what broke it.
- Is there any reason to hold on to the DW_AT_name values, which
currently look like "jprint.main(java.lang.String[])" instead of
"main" as DWARF would normally suggest?
--
Daniel Jacobowitz
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [RFA]: Java Inferior Call Take 2
2004-06-19 23:59 ` Daniel Jacobowitz
@ 2004-06-21 10:49 ` Andrew Haley
2004-06-21 15:17 ` Andrew Haley
1 sibling, 0 replies; 36+ messages in thread
From: Andrew Haley @ 2004-06-21 10:49 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: Jeff Johnston, gdb-patches, java
Daniel Jacobowitz writes:
> On Thu, Jun 17, 2004 at 04:52:36PM -0400, Jeff Johnston wrote:
> > Daniel Jacobowitz wrote:
> > >On Mon, May 17, 2004 at 04:53:32PM -0400, Jeff Johnston wrote:
> > >
> > >>This is the reworked java inferior call patch. My previous attempt tried
> > >>to modify the gdb v3 abi code to handle missing debug information from
> > >>gcj. After a couple of gcc patches from Andrew Haley, the gnu-v3-abi.c
> > >>code doesn't require any tampering.
> > >>
> > >>I had to enhance dwarf2read.c to handle the java vtable name (which is
> > >>vtable) and to modify C++-only code to handle java syntax for class names.
> > >>
> > >>I have included a test case.
> > >>
> > >>Ok to commit?
> > >
> > >
> > >First of all, it doesn't work for me; I'm guessing that's because I
> > >have gcj 3.3 installed. Are the GCC changes in any released version of
> > >GCC yet, so that I can add appropriately versioned XFAILs?
> > >
> >
> > I am using current gcc sources because Andrew Haley only recently added the
> > fixes. It has to be post 3.4.0 which is the last release but prior to
> > Andrew's patches.
>
> Are you actually using GCC HEAD? Gcj does not even emit debug info for
> the local variable "x" in jprint.main using today's CVS.
<groan>
Alright, I'll have a look.
Andrew.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [RFA]: Java Inferior Call Take 2
2004-06-19 23:59 ` Daniel Jacobowitz
2004-06-21 10:49 ` Andrew Haley
@ 2004-06-21 15:17 ` Andrew Haley
2004-06-23 11:06 ` Andrew Haley
1 sibling, 1 reply; 36+ messages in thread
From: Andrew Haley @ 2004-06-21 15:17 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: Jeff Johnston, gdb-patches, java, gcc-patches
D'oh!
Andrew.
2004-06-21 Andrew Haley <aph@redhat.com>
* java-gimplify.c (java_gimplify_block): set TREE_USED on the new
block.
Index: java-gimplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/java-gimplify.c,v
retrieving revision 1.4
diff -p -2 -c -r1.4 java-gimplify.c
*** java-gimplify.c 14 May 2004 02:29:32 -0000 1.4
--- java-gimplify.c 21 Jun 2004 15:13:41 -0000
*************** java_gimplify_block (tree java_block)
*** 178,181 ****
--- 178,186 ----
block = make_node (BLOCK);
BLOCK_VARS (block) = decls;
+
+ /* The TREE_USED flag on a block determines whether the debug ouput
+ routines generate info for the variables in that block. */
+ TREE_USED (block) = 1;
+
if (outer != NULL_TREE)
{
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [RFA]: Java Inferior Call Take 2
2004-06-21 15:17 ` Andrew Haley
@ 2004-06-23 11:06 ` Andrew Haley
2004-06-23 13:47 ` Daniel Jacobowitz
0 siblings, 1 reply; 36+ messages in thread
From: Andrew Haley @ 2004-06-23 11:06 UTC (permalink / raw)
To: Daniel Jacobowitz, Jeff Johnston, gdb-patches
This patch is now in mainline. Is there anything else you need?
Andrew.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [RFA]: Java Inferior Call Take 2
2004-06-23 11:06 ` Andrew Haley
@ 2004-06-23 13:47 ` Daniel Jacobowitz
2004-06-23 16:06 ` Andrew Haley
2004-06-23 21:55 ` Jeff Johnston
0 siblings, 2 replies; 36+ messages in thread
From: Daniel Jacobowitz @ 2004-06-23 13:47 UTC (permalink / raw)
To: Andrew Haley; +Cc: Jeff Johnston, gdb-patches
On Wed, Jun 23, 2004 at 12:05:59PM +0100, Andrew Haley wrote:
> This patch is now in mainline. Is there anything else you need?
Yes. Two sets of questions left, one for Jeff and one [plus a little
bit] for you...
Jeff, one test still fails: calling addprint. I think this is mostly a
GDB problem rather than GCC. Before starting the program I see this:
(gdb) ptype jvclass
type = class jvclass : public java::lang::Object {
public:
static int k;
static void addprint(int, int, int);
virtual int addk(int);
}
Then, after starting it:
(gdb) ptype jvclass
type = class jvclass extends java::lang::Object {
public static int k;
void addprint(int, int, int);
int addk(int);
jvclass();
void <clinit>();
}
- Should we suppress jvclass and <clinit> the way we do for C++
artificial methods?
- Why is it java::lang::Object instead of java.lang.Object?
- Why did printing of the type change? There's only one definition
of jvclass in the debug info, and it's marked Java.
[Andrew, I notice that we've lost the 'static' here. There's nothing
in the dwarf output to express it, so this is a GCC problem.]
(gdb) p jvclass.addprint(1,2,3)
There is no field named addprint
Calling x.addprint(1,2,3) works. This is because x.addprint goes
through value_struct_elt to value_fn_field, which falls back to
lookup_minimal_symbol if lookup_symbol fails, and jvclass.addprint goes
through value_aggregate_elt, which doesn't. lookup_symbol fails
because the demangling code in it is specific to C++. So does this
test pass for you, and if so what happens differently? Do we need to
extend the hack in lookup_symbol for Java?
It may be that fixing the missing static in the debug info fixes this
too.
The other question: I looked at fixing the debug info to print field
names correctly. The reason it's wrong is that dwarf2out uses the
decl_printable_name langhook. Java doesn't use the second argument,
which the common code assumes is verbosity. Common code always passes
'2', which matches what Java's does, except in three places: mudflap
(???), the C tree pretty printer, and this call in dwarf2out used to
set the name of decls. Java mostly passes 0 since it knows the value
is ignored. Any reason not to fix up the Java frontend to pass 2,
extend the function to handle smaller values, and thus correct the
debug output?
The only problem I see with this is that class names will lose scope
information, which is nominally right... except that we don't output
anything describing packages. Perhaps we should use DW_TAG_namespace
for that but making it work will be a bit of a stretch. Anyway, for
the moment GDB will work OK without this; it gets it from the demangled
names.
--
Daniel Jacobowitz
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [RFA]: Java Inferior Call Take 2
2004-06-23 13:47 ` Daniel Jacobowitz
@ 2004-06-23 16:06 ` Andrew Haley
2004-06-23 16:08 ` Daniel Jacobowitz
2004-06-23 21:55 ` Jeff Johnston
1 sibling, 1 reply; 36+ messages in thread
From: Andrew Haley @ 2004-06-23 16:06 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: Jeff Johnston, gdb-patches
Daniel Jacobowitz writes:
> On Wed, Jun 23, 2004 at 12:05:59PM +0100, Andrew Haley wrote:
> > This patch is now in mainline. Is there anything else you need?
>
> Yes. Two sets of questions left, one for Jeff and one [plus a little
> bit] for you...
>
>
> Jeff, one test still fails: calling addprint. I think this is mostly a
> GDB problem rather than GCC. Before starting the program I see this:
>
> (gdb) ptype jvclass
> type = class jvclass : public java::lang::Object {
> public:
> static int k;
>
> static void addprint(int, int, int);
> virtual int addk(int);
> }
>
> Then, after starting it:
> (gdb) ptype jvclass
> type = class jvclass extends java::lang::Object {
> public static int k;
>
> void addprint(int, int, int);
> int addk(int);
> jvclass();
> void <clinit>();
> }
>
> - Should we suppress jvclass and <clinit> the way we do for C++
> artificial methods?
>
> - Why is it java::lang::Object instead of java.lang.Object?
>
> - Why did printing of the type change? There's only one definition
> of jvclass in the debug info, and it's marked Java.
>
> [Andrew, I notice that we've lost the 'static' here. There's nothing
> in the dwarf output to express it, so this is a GCC problem.]
OK.
> The other question: I looked at fixing the debug info to print field
> names correctly. The reason it's wrong is that dwarf2out uses the
> decl_printable_name langhook. Java doesn't use the second argument,
> which the common code assumes is verbosity. Common code always passes
> '2', which matches what Java's does, except in three places: mudflap
> (???), the C tree pretty printer, and this call in dwarf2out used to
> set the name of decls. Java mostly passes 0 since it knows the value
> is ignored. Any reason not to fix up the Java frontend to pass 2,
> extend the function to handle smaller values, and thus correct the
> debug output?
Yes, I can do that.
Andrew.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [RFA]: Java Inferior Call Take 2
2004-06-23 16:06 ` Andrew Haley
@ 2004-06-23 16:08 ` Daniel Jacobowitz
0 siblings, 0 replies; 36+ messages in thread
From: Daniel Jacobowitz @ 2004-06-23 16:08 UTC (permalink / raw)
To: Andrew Haley; +Cc: Jeff Johnston, gdb-patches
On Wed, Jun 23, 2004 at 05:05:57PM +0100, Andrew Haley wrote:
> Daniel Jacobowitz writes:
> > The other question: I looked at fixing the debug info to print field
> > names correctly. The reason it's wrong is that dwarf2out uses the
> > decl_printable_name langhook. Java doesn't use the second argument,
> > which the common code assumes is verbosity. Common code always passes
> > '2', which matches what Java's does, except in three places: mudflap
> > (???), the C tree pretty printer, and this call in dwarf2out used to
> > set the name of decls. Java mostly passes 0 since it knows the value
> > is ignored. Any reason not to fix up the Java frontend to pass 2,
> > extend the function to handle smaller values, and thus correct the
> > debug output?
>
> Yes, I can do that.
Great - it'll probably take you a lot less time than it would take me
:) If you can take care of this, I'll make sure GDB still behaves
correctly.
--
Daniel Jacobowitz
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [RFA]: Java Inferior Call Take 2
2004-06-23 13:47 ` Daniel Jacobowitz
2004-06-23 16:06 ` Andrew Haley
@ 2004-06-23 21:55 ` Jeff Johnston
2004-06-23 23:01 ` Daniel Jacobowitz
1 sibling, 1 reply; 36+ messages in thread
From: Jeff Johnston @ 2004-06-23 21:55 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: Andrew Haley, gdb-patches
Daniel Jacobowitz wrote:
> On Wed, Jun 23, 2004 at 12:05:59PM +0100, Andrew Haley wrote:
>
>>This patch is now in mainline. Is there anything else you need?
>
>
> Yes. Two sets of questions left, one for Jeff and one [plus a little
> bit] for you...
>
>
> Jeff, one test still fails: calling addprint. I think this is mostly a
> GDB problem rather than GCC. Before starting the program I see this:
>
Let me take a look at it. It is not failing in my all-patches-applied build.
Perhaps in splitting the patches up, I screwed up and missed something.
> (gdb) ptype jvclass
> type = class jvclass : public java::lang::Object {
> public:
> static int k;
>
> static void addprint(int, int, int);
> virtual int addk(int);
> }
>
> Then, after starting it:
> (gdb) ptype jvclass
> type = class jvclass extends java::lang::Object {
> public static int k;
>
> void addprint(int, int, int);
> int addk(int);
> jvclass();
> void <clinit>();
> }
>
> - Should we suppress jvclass and <clinit> the way we do for C++
> artificial methods?
>
Perhaps remove <clinit>, but jvclass() is the constructor. There could be
multiple constructors and as an end-user, I would want to see the various
prototypes. I can't speak for what C++ does.
> - Why is it java::lang::Object instead of java.lang.Object?
>
This is because we use the C++ class_name_from_physname() function which is
C++-specific. I had submitted another patch that was put out at the same time
which I don't think anybody has looked at which fixes this problem. It has to
do with adding class_name_from_physname to the language vector.
> - Why did printing of the type change? There's only one definition
> of jvclass in the debug info, and it's marked Java.
>
There are checks in the code based on current language. The current language
does not start as java. If you manually change it via set language java, you
will see the same results before and after.
> [Andrew, I notice that we've lost the 'static' here. There's nothing
> in the dwarf output to express it, so this is a GCC problem.]
>
> (gdb) p jvclass.addprint(1,2,3)
> There is no field named addprint
>
> Calling x.addprint(1,2,3) works. This is because x.addprint goes
> through value_struct_elt to value_fn_field, which falls back to
> lookup_minimal_symbol if lookup_symbol fails, and jvclass.addprint goes
> through value_aggregate_elt, which doesn't. lookup_symbol fails
> because the demangling code in it is specific to C++. So does this
> test pass for you, and if so what happens differently? Do we need to
> extend the hack in lookup_symbol for Java?
>
> It may be that fixing the missing static in the debug info fixes this
> too.
>
>
> The other question: I looked at fixing the debug info to print field
> names correctly. The reason it's wrong is that dwarf2out uses the
> decl_printable_name langhook. Java doesn't use the second argument,
> which the common code assumes is verbosity. Common code always passes
> '2', which matches what Java's does, except in three places: mudflap
> (???), the C tree pretty printer, and this call in dwarf2out used to
> set the name of decls. Java mostly passes 0 since it knows the value
> is ignored. Any reason not to fix up the Java frontend to pass 2,
> extend the function to handle smaller values, and thus correct the
> debug output?
>
> The only problem I see with this is that class names will lose scope
> information, which is nominally right... except that we don't output
> anything describing packages. Perhaps we should use DW_TAG_namespace
> for that but making it work will be a bit of a stretch. Anyway, for
> the moment GDB will work OK without this; it gets it from the demangled
> names.
>
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [RFA]: Java Inferior Call Take 2
2004-06-23 21:55 ` Jeff Johnston
@ 2004-06-23 23:01 ` Daniel Jacobowitz
2004-06-24 17:57 ` Tom Tromey
2004-07-06 21:47 ` Jeff Johnston
0 siblings, 2 replies; 36+ messages in thread
From: Daniel Jacobowitz @ 2004-06-23 23:01 UTC (permalink / raw)
To: Jeff Johnston; +Cc: Andrew Haley, gdb-patches
On Wed, Jun 23, 2004 at 05:55:07PM -0400, Jeff Johnston wrote:
> Daniel Jacobowitz wrote:
> >On Wed, Jun 23, 2004 at 12:05:59PM +0100, Andrew Haley wrote:
> >
> >>This patch is now in mainline. Is there anything else you need?
> >
> >
> >Yes. Two sets of questions left, one for Jeff and one [plus a little
> >bit] for you...
> >
> >
> >Jeff, one test still fails: calling addprint. I think this is mostly a
> >GDB problem rather than GCC. Before starting the program I see this:
> >
>
> Let me take a look at it. It is not failing in my all-patches-applied
> build. Perhaps in splitting the patches up, I screwed up and missed
> something.
Thanks.
> > - Should we suppress jvclass and <clinit> the way we do for C++
> > artificial methods?
> >
>
> Perhaps remove <clinit>, but jvclass() is the constructor. There could be
> multiple constructors and as an end-user, I would want to see the various
> prototypes. I can't speak for what C++ does.
In C++, the debug information marks whether a constructor was written
by the user (i.e. the type really contains a constructor) or by the
compiler (i.e. implicit). I imagine Java's debug information has the
same thing. For minimum confusion, we choose not to print the
artificial methods in C++ types; I think we should do the same for
Java.
(This shouldn't affect breakpointing it for users who know the
constructor exists.)
>
> > - Why is it java::lang::Object instead of java.lang.Object?
> >
>
> This is because we use the C++ class_name_from_physname() function which is
> C++-specific. I had submitted another patch that was put out at the same
> time which I don't think anybody has looked at which fixes this problem.
> It has to do with adding class_name_from_physname to the language vector.
OK, thanks. I reviewed it on the 16th. I failed to CC you on the
message, though. Likewise the tab completion patch.
> > - Why did printing of the type change? There's only one definition
> > of jvclass in the debug info, and it's marked Java.
> >
>
> There are checks in the code based on current language. The current
> language does not start as java. If you manually change it via set
> language java, you will see the same results before and after.
Bleeeeeeech. Thanks for explaining; definitely not your problem, but
definitely a bug. If we're printing a type we ought to be using the
type's language.
--
Daniel Jacobowitz
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [RFA]: Java Inferior Call Take 2
2004-06-23 23:01 ` Daniel Jacobowitz
@ 2004-06-24 17:57 ` Tom Tromey
2004-07-06 21:47 ` Jeff Johnston
1 sibling, 0 replies; 36+ messages in thread
From: Tom Tromey @ 2004-06-24 17:57 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: Andrew Haley, gdb-patches
>>>>> "Daniel" == Daniel Jacobowitz <drow@false.org> writes:
Daniel> In C++, the debug information marks whether a constructor was written
Daniel> by the user (i.e. the type really contains a constructor) or by the
Daniel> compiler (i.e. implicit). I imagine Java's debug information has the
Daniel> same thing.
The information is there, though I don't know whether gcj puts it
into the .o.
Daniel> (This shouldn't affect breakpointing it for users who know the
Daniel> constructor exists.)
It is also actually useful on occasion to put a breakpoint on <clinit>.
This can let you see when your class is initialized, and it will let
you step through the static blocks and static field initializers.
Tom
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [RFA]: Java Inferior Call Take 2
2004-06-23 23:01 ` Daniel Jacobowitz
2004-06-24 17:57 ` Tom Tromey
@ 2004-07-06 21:47 ` Jeff Johnston
2004-07-26 19:49 ` Jeff Johnston
2004-08-16 20:35 ` Daniel Jacobowitz
1 sibling, 2 replies; 36+ messages in thread
From: Jeff Johnston @ 2004-07-06 21:47 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: Andrew Haley, gdb-patches
[-- Attachment #1: Type: text/plain, Size: 2307 bytes --]
Daniel Jacobowitz wrote:
> On Wed, Jun 23, 2004 at 05:55:07PM -0400, Jeff Johnston wrote:
>
>>Daniel Jacobowitz wrote:
>>
>>>On Wed, Jun 23, 2004 at 12:05:59PM +0100, Andrew Haley wrote:
>>>
>>>
>>>>This patch is now in mainline. Is there anything else you need?
>>>
>>>
>>>Yes. Two sets of questions left, one for Jeff and one [plus a little
>>>bit] for you...
>>>
>>>
>>>Jeff, one test still fails: calling addprint. I think this is mostly a
>>>GDB problem rather than GCC. Before starting the program I see this:
>>>
>>
>>Let me take a look at it. It is not failing in my all-patches-applied
>>build. Perhaps in splitting the patches up, I screwed up and missed
>>something.
>
>
> Thanks.
>
Ok, I figured out what piece I left out and have remade the patch. I can't
remember where we are on this regarding the workaround for gcc debug-info, but
at least you will be able to run the test with the full functionality now.
Please let me know what is needed next as I want to move this forward.
-- Jeff J.
>
>>> - Should we suppress jvclass and <clinit> the way we do for C++
>>> artificial methods?
>>>
>>
>>Perhaps remove <clinit>, but jvclass() is the constructor. There could be
>>multiple constructors and as an end-user, I would want to see the various
>>prototypes. I can't speak for what C++ does.
>
>
> In C++, the debug information marks whether a constructor was written
> by the user (i.e. the type really contains a constructor) or by the
> compiler (i.e. implicit). I imagine Java's debug information has the
> same thing. For minimum confusion, we choose not to print the
> artificial methods in C++ types; I think we should do the same for
> Java.
>
> (This shouldn't affect breakpointing it for users who know the
> constructor exists.)
>
>
>
>>> - Why did printing of the type change? There's only one definition
>>> of jvclass in the debug info, and it's marked Java.
>>>
>>
>>There are checks in the code based on current language. The current
>>language does not start as java. If you manually change it via set
>>language java, you will see the same results before and after.
>
>
> Bleeeeeeech. Thanks for explaining; definitely not your problem, but
> definitely a bug. If we're printing a type we ought to be using the
> type's language.
>
[-- Attachment #2: java-inferior-call.patch2 --]
[-- Type: text/plain, Size: 15938 bytes --]
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.151
diff -u -p -r1.151 dwarf2read.c
--- dwarf2read.c 7 May 2004 14:29:33 -0000 1.151
+++ dwarf2read.c 6 Jul 2004 21:42:45 -0000
@@ -788,7 +788,8 @@ static void read_type_die (struct die_in
static char *determine_prefix (struct die_info *die, struct dwarf2_cu *);
-static char *typename_concat (const char *prefix, const char *suffix);
+static char *typename_concat (const char *prefix, const char *suffix,
+ struct dwarf2_cu *);
static void read_typedef (struct die_info *, struct dwarf2_cu *);
@@ -1502,7 +1503,8 @@ scan_partial_symbols (struct partial_die
/* Functions used to compute the fully scoped name of a partial DIE.
Normally, this is simple. For C++, the parent DIE's fully scoped
- name is concatenated with "::" and the partial DIE's name.
+ name is concatenated with "::" and the partial DIE's name. For
+ Java, the same thing occurs except that "." is used instead of "::".
Enumerators are an exception; they use the scope of their parent
enumeration type, i.e. the name of the enumeration type is not
prepended to the enumerator.
@@ -1558,7 +1560,7 @@ partial_die_parent_scope (struct partial
parent->scope = parent->name;
else
parent->scope = obconcat (&cu->comp_unit_obstack, grandparent_scope,
- "::", parent->name);
+ cu->language == language_java ? "." : "::", parent->name);
}
else if (parent->tag == DW_TAG_enumeration_type)
/* Enumerators should not get the name of the enumeration as a prefix. */
@@ -1590,7 +1592,11 @@ partial_die_full_name (struct partial_di
if (parent_scope == NULL)
return NULL;
else
- return concat (parent_scope, "::", pdi->name, NULL);
+ {
+ if (cu->language == language_java)
+ return concat (parent_scope, ".", pdi->name, NULL);
+ return concat (parent_scope, "::", pdi->name, NULL);
+ }
}
static void
@@ -1708,14 +1714,16 @@ add_partial_symbol (struct partial_die_i
return;
add_psymbol_to_list (actual_name, strlen (actual_name),
STRUCT_DOMAIN, LOC_TYPEDEF,
- cu->language == language_cplus
+ (cu->language == language_cplus
+ || cu->language == language_java)
? &objfile->global_psymbols
: &objfile->static_psymbols,
0, (CORE_ADDR) 0, cu->language, objfile);
- if (cu->language == language_cplus)
+ if (cu->language == language_cplus
+ || cu->language == language_java)
{
- /* For C++, these implicitly act as typedefs as well. */
+ /* For C++ and Java, these implicitly act as typedefs as well. */
add_psymbol_to_list (actual_name, strlen (actual_name),
VAR_DOMAIN, LOC_TYPEDEF,
&objfile->global_psymbols,
@@ -1725,7 +1733,8 @@ add_partial_symbol (struct partial_die_i
case DW_TAG_enumerator:
add_psymbol_to_list (actual_name, strlen (actual_name),
VAR_DOMAIN, LOC_CONST,
- cu->language == language_cplus
+ (cu->language == language_cplus
+ || cu->language == language_java)
? &objfile->global_psymbols
: &objfile->static_psymbols,
0, (CORE_ADDR) 0, cu->language, objfile);
@@ -1805,7 +1814,8 @@ static void
guess_structure_name (struct partial_die_info *struct_pdi,
struct dwarf2_cu *cu)
{
- if (cu->language == language_cplus
+ if ((cu->language == language_cplus
+ || cu->language == language_java)
&& cu->has_namespace_info == 0
&& struct_pdi->has_children)
{
@@ -2460,7 +2470,8 @@ read_func_scope (struct die_info *die, s
if (name == NULL || !dwarf2_get_pc_bounds (die, &lowpc, &highpc, cu))
return;
- if (cu->language == language_cplus)
+ if (cu->language == language_cplus
+ || cu->language == language_java)
{
struct die_info *spec_die = die_specification (die, cu);
@@ -3101,7 +3112,29 @@ dwarf2_add_member_fn (struct field_info
/* Get name of member function. */
attr = dwarf2_attr (die, DW_AT_name, cu);
if (attr && DW_STRING (attr))
- fieldname = DW_STRING (attr);
+ {
+ /* Note: C++ and Java currently differ in how the member function
+ name is stored in the debug info. For Java, the member name is
+ fully qualified with prototype while C++ just has the member
+ name. To get the Java member name, we strip off any dot qualifiers
+ and remove the trailing prototype. */
+ char *dot_index;
+ char *lparen;
+ fieldname = DW_STRING (attr);
+ if (cu->language == language_java)
+ {
+ dot_index = strchr (fieldname, '.');
+ while (dot_index)
+ {
+ fieldname = dot_index + 1;
+ dot_index = strchr (fieldname, '.');
+ }
+ lparen = strchr (fieldname + 1, '(');
+ if (lparen)
+ fieldname = obsavestring (fieldname, lparen - fieldname,
+ &objfile->objfile_obstack);
+ }
+ }
else
return;
@@ -3292,7 +3325,8 @@ read_structure_type (struct die_info *di
attr = dwarf2_attr (die, DW_AT_name, cu);
if (attr && DW_STRING (attr))
{
- if (cu->language == language_cplus)
+ if (cu->language == language_cplus
+ || cu->language == language_java)
{
char *new_prefix = determine_class_name (die, cu);
TYPE_TAG_NAME (type) = obsavestring (new_prefix,
@@ -3398,6 +3432,9 @@ read_structure_type (struct die_info *di
{
static const char vptr_name[] =
{'_', 'v', 'p', 't', 'r', '\0'};
+ static const char vtable_name[] =
+ {'v', 't', 'a', 'b', 'l', 'e', '\0'};
+
int i;
/* Our own class provides vtbl ptr. */
@@ -3407,10 +3444,18 @@ read_structure_type (struct die_info *di
{
char *fieldname = TYPE_FIELD_NAME (t, i);
- if ((strncmp (fieldname, vptr_name,
- strlen (vptr_name) - 1)
- == 0)
- && is_cplus_marker (fieldname[strlen (vptr_name)]))
+ if (cu->language == language_java
+ && (strncmp (fieldname, vtable_name,
+ strlen (vtable_name) - 1)
+ == 0))
+ {
+ TYPE_VPTR_FIELDNO (type) = i;
+ break;
+ }
+ else if ((strncmp (fieldname, vptr_name,
+ strlen (vptr_name) - 1)
+ == 0)
+ && is_cplus_marker (fieldname[strlen (vptr_name)]))
{
TYPE_VPTR_FIELDNO (type) = i;
break;
@@ -3502,7 +3547,9 @@ read_enumeration_type (struct die_info *
TYPE_TAG_NAME (type) = obconcat (&objfile->objfile_obstack,
processing_current_prefix,
processing_current_prefix[0] == '\0'
- ? "" : "::",
+ ? "" :
+ cu->language == language_java
+ ? "." : "::",
name);
}
else
@@ -3527,7 +3574,7 @@ read_enumeration_type (struct die_info *
}
/* Determine the name of the type represented by DIE, which should be
- a named C++ compound type. Return the name in question; the caller
+ a named C++ or Java compound type. Return the name in question; the caller
is responsible for xfree()'ing it. */
static char *
@@ -3573,7 +3620,8 @@ determine_class_name (struct die_info *d
{
const char *name = dwarf2_name (die, cu);
new_prefix = typename_concat (processing_current_prefix,
- name ? name : "<<anonymous>>");
+ name ? name : "<<anonymous>>",
+ cu);
}
if (back_to != NULL)
@@ -3810,7 +3858,10 @@ read_namespace (struct die_info *die, st
char *temp_name = alloca (strlen (previous_prefix)
+ 2 + strlen(name) + 1);
strcpy (temp_name, previous_prefix);
- strcat (temp_name, "::");
+ if (cu->language == language_java)
+ strcat (temp_name, ".");
+ else
+ strcat (temp_name, "::");
strcat (temp_name, name);
processing_current_prefix = temp_name;
@@ -4099,10 +4150,11 @@ read_subroutine_type (struct die_info *d
type = die_type (die, cu);
ftype = lookup_function_type (type);
- /* All functions in C++ have prototypes. */
+ /* All functions in C++ and Java have prototypes. */
attr = dwarf2_attr (die, DW_AT_prototyped, cu);
if ((attr && (DW_UNSND (attr) != 0))
- || cu->language == language_cplus)
+ || cu->language == language_cplus
+ || cu->language == language_java)
TYPE_FLAGS (ftype) |= TYPE_FLAG_PROTOTYPED;
if (die->child != NULL)
@@ -4753,7 +4805,8 @@ load_partial_dies (bfd *abfd, char *info
else if (building_psymtab)
add_psymbol_to_list (part_die->name, strlen (part_die->name),
VAR_DOMAIN, LOC_CONST,
- cu->language == language_cplus
+ (cu->language == language_cplus
+ || cu->language == language_java)
? &cu->objfile->global_psymbols
: &cu->objfile->static_psymbols,
0, (CORE_ADDR) 0, cu->language, cu->objfile);
@@ -6357,7 +6410,8 @@ new_symbol (struct die_info *die, struct
read_structure_type, and the correct name is saved in
the type. */
- if (cu->language == language_cplus)
+ if (cu->language == language_cplus
+ || cu->language == language_java)
{
struct type *type = SYMBOL_TYPE (sym);
@@ -6374,7 +6428,7 @@ new_symbol (struct die_info *die, struct
}
{
- /* NOTE: carlton/2003-11-10: C++ class symbols shouldn't
+ /* NOTE: carlton/2003-11-10: C++ and Java class symbols shouldn't
really ever be static objects: otherwise, if you try
to, say, break of a class's method and you're in a file
which doesn't mention that class, it won't work unless
@@ -6385,15 +6439,17 @@ new_symbol (struct die_info *die, struct
struct pending **list_to_add;
list_to_add = (cu->list_in_scope == &file_symbols
- && cu->language == language_cplus
+ && (cu->language == language_cplus
+ || cu->language == language_java)
? &global_symbols : cu->list_in_scope);
add_symbol_to_list (sym, list_to_add);
- /* The semantics of C++ state that "struct foo { ... }" also
+ /* The semantics of C++ and Java state that "struct foo { ... }" also
defines a typedef for "foo". Synthesize a typedef symbol so
that "ptype foo" works as expected. */
- if (cu->language == language_cplus)
+ if (cu->language == language_cplus
+ || cu->language == language_java)
{
struct symbol *typedef_sym = (struct symbol *)
obstack_alloc (&objfile->objfile_obstack,
@@ -6415,7 +6471,8 @@ new_symbol (struct die_info *die, struct
{
SYMBOL_LINKAGE_NAME (sym) = obconcat (&objfile->objfile_obstack,
processing_current_prefix,
- "::",
+ cu->language == language_java
+ ? "." : "::",
name);
}
SYMBOL_CLASS (sym) = LOC_TYPEDEF;
@@ -6434,7 +6491,8 @@ new_symbol (struct die_info *die, struct
{
SYMBOL_LINKAGE_NAME (sym) = obconcat (&objfile->objfile_obstack,
processing_current_prefix,
- "::",
+ cu->language == language_java
+ ? "." : "::",
name);
}
attr = dwarf2_attr (die, DW_AT_const_value, cu);
@@ -6449,7 +6507,8 @@ new_symbol (struct die_info *die, struct
struct pending **list_to_add;
list_to_add = (cu->list_in_scope == &file_symbols
- && cu->language == language_cplus
+ && (cu->language == language_cplus
+ || cu->language == language_java)
? &global_symbols : cu->list_in_scope);
add_symbol_to_list (sym, list_to_add);
@@ -6758,7 +6817,8 @@ determine_prefix (struct die_info *die,
{
struct die_info *parent;
- if (cu->language != language_cplus)
+ if (cu->language != language_cplus
+ && cu->language != language_java)
return NULL;
parent = die->parent;
@@ -6784,7 +6844,8 @@ determine_prefix (struct die_info *die,
char *parent_prefix = determine_prefix (parent, cu);
char *retval = typename_concat (parent_prefix,
namespace_name (parent, &dummy,
- cu));
+ cu),
+ cu);
xfree (parent_prefix);
return retval;
}
@@ -6818,11 +6879,11 @@ determine_prefix (struct die_info *die,
}
/* Return a newly-allocated string formed by concatenating PREFIX,
- "::", and SUFFIX, except that if PREFIX is NULL or the empty
+ "::" or ".", and SUFFIX, except that if PREFIX is NULL or the empty
string, just return a copy of SUFFIX. */
static char *
-typename_concat (const char *prefix, const char *suffix)
+typename_concat (const char *prefix, const char *suffix, struct dwarf2_cu *cu)
{
if (prefix == NULL || prefix[0] == '\0')
return xstrdup (suffix);
@@ -6831,7 +6892,10 @@ typename_concat (const char *prefix, con
char *retval = xmalloc (strlen (prefix) + 2 + strlen (suffix) + 1);
strcpy (retval, prefix);
- strcat (retval, "::");
+ if (cu->language == language_java)
+ strcat (retval, ".");
+ else
+ strcat (retval, "::");
strcat (retval, suffix);
return retval;
Index: jv-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/jv-exp.y,v
retrieving revision 1.18
diff -u -p -r1.18 jv-exp.y
--- jv-exp.y 23 Nov 2003 20:41:17 -0000 1.18
+++ jv-exp.y 6 Jul 2004 21:42:45 -0000
@@ -446,13 +446,22 @@ FieldAccess:
/*| SUPER '.' SimpleName { FIXME } */
;
+FuncStart:
+ Name '('
+ { push_expression_name ($1); }
+;
+
MethodInvocation:
- Name '(' ArgumentList_opt ')'
- { error (_("Method invocation not implemented")); }
+ FuncStart
+ { start_arglist(); }
+ ArgumentList_opt ')'
+ { write_exp_elt_opcode (OP_FUNCALL);
+ write_exp_elt_longcst ((LONGEST) end_arglist ());
+ write_exp_elt_opcode (OP_FUNCALL); }
| Primary '.' SimpleName '(' ArgumentList_opt ')'
- { error (_("Method invocation not implemented")); }
+ { error (_("Form of method invocation not implemented")); }
| SUPER '.' SimpleName '(' ArgumentList_opt ')'
- { error (_("Method invocation not implemented")); }
+ { error (_("Form of method invocation not implemented")); }
;
ArrayAccess:
Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.129
diff -u -p -r1.129 symtab.c
--- symtab.c 8 Apr 2004 21:18:13 -0000 1.129
+++ symtab.c 6 Jul 2004 21:42:45 -0000
@@ -932,7 +932,7 @@ lookup_symbol (const char *name, const s
modified_name = name;
- /* If we are using C++ language, demangle the name before doing a lookup, so
+ /* If we are using C++ or Java, demangle the name before doing a lookup, so
we can always binary search. */
if (current_language->la_language == language_cplus)
{
@@ -944,6 +944,17 @@ lookup_symbol (const char *name, const s
needtofreename = 1;
}
}
+ else if (current_language->la_language == language_java)
+ {
+ demangled_name = cplus_demangle (name,
+ DMGL_ANSI | DMGL_PARAMS | DMGL_JAVA);
+ if (demangled_name)
+ {
+ mangled_name = name;
+ modified_name = demangled_name;
+ needtofreename = 1;
+ }
+ }
if (case_sensitivity == case_sensitive_off)
{
Index: valarith.c
===================================================================
RCS file: /cvs/src/src/gdb/valarith.c,v
retrieving revision 1.22
diff -u -p -r1.22 valarith.c
--- valarith.c 1 Apr 2004 12:08:30 -0000 1.22
+++ valarith.c 6 Jul 2004 21:42:49 -0000
@@ -202,7 +202,10 @@ value_subscript (struct value *array, st
LONGEST index = value_as_long (idx);
if (index >= lowerbound && index <= upperbound)
return value_subscripted_rvalue (array, idx, lowerbound);
- warning ("array or string index out of range");
+ /* Emit warning unless we have an array of unknown size.
+ An array of unknown size has lowerbound 0 and upperbound -1. */
+ if (upperbound > -1)
+ warning ("array or string index out of range");
/* fall doing C stuff */
c_style = 1;
}
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [RFA]: Java Inferior Call Take 2
2004-07-06 21:47 ` Jeff Johnston
@ 2004-07-26 19:49 ` Jeff Johnston
2004-07-26 19:51 ` Daniel Jacobowitz
2004-08-16 20:35 ` Daniel Jacobowitz
1 sibling, 1 reply; 36+ messages in thread
From: Jeff Johnston @ 2004-07-26 19:49 UTC (permalink / raw)
To: Jeff Johnston, Daniel Jacobowitz; +Cc: Andrew Haley, gdb-patches
Ping.
Jeff Johnston wrote:
> Daniel Jacobowitz wrote:
>
>> On Wed, Jun 23, 2004 at 05:55:07PM -0400, Jeff Johnston wrote:
>>
>>> Daniel Jacobowitz wrote:
>>>
>>>> On Wed, Jun 23, 2004 at 12:05:59PM +0100, Andrew Haley wrote:
>>>>
>>>>
>>>>> This patch is now in mainline. Is there anything else you need?
>>>>
>>>>
>>>>
>>>> Yes. Two sets of questions left, one for Jeff and one [plus a little
>>>> bit] for you...
>>>>
>>>>
>>>> Jeff, one test still fails: calling addprint. I think this is mostly a
>>>> GDB problem rather than GCC. Before starting the program I see this:
>>>>
>>>
>>> Let me take a look at it. It is not failing in my
>>> all-patches-applied build. Perhaps in splitting the patches up, I
>>> screwed up and missed something.
>>
>>
>>
>> Thanks.
>>
>
> Ok, I figured out what piece I left out and have remade the patch. I
> can't remember where we are on this regarding the workaround for gcc
> debug-info, but at least you will be able to run the test with the full
> functionality now. Please let me know what is needed next as I want to
> move this forward.
>
> -- Jeff J.
>
>>
>>>> - Should we suppress jvclass and <clinit> the way we do for C++
>>>> artificial methods?
>>>>
>>>
>>> Perhaps remove <clinit>, but jvclass() is the constructor. There
>>> could be multiple constructors and as an end-user, I would want to
>>> see the various prototypes. I can't speak for what C++ does.
>>
>>
>>
>> In C++, the debug information marks whether a constructor was written
>> by the user (i.e. the type really contains a constructor) or by the
>> compiler (i.e. implicit). I imagine Java's debug information has the
>> same thing. For minimum confusion, we choose not to print the
>> artificial methods in C++ types; I think we should do the same for
>> Java.
>>
>> (This shouldn't affect breakpointing it for users who know the
>> constructor exists.)
>>
>>
>>
>>>> - Why did printing of the type change? There's only one definition
>>>> of jvclass in the debug info, and it's marked Java.
>>>>
>>>
>>> There are checks in the code based on current language. The current
>>> language does not start as java. If you manually change it via set
>>> language java, you will see the same results before and after.
>>
>>
>>
>> Bleeeeeeech. Thanks for explaining; definitely not your problem, but
>> definitely a bug. If we're printing a type we ought to be using the
>> type's language.
>>
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [RFA]: Java Inferior Call Take 2
2004-07-26 19:49 ` Jeff Johnston
@ 2004-07-26 19:51 ` Daniel Jacobowitz
2004-08-02 10:17 ` Andrew Haley
0 siblings, 1 reply; 36+ messages in thread
From: Daniel Jacobowitz @ 2004-07-26 19:51 UTC (permalink / raw)
To: Jeff Johnston; +Cc: Andrew Haley, gdb-patches
On Mon, Jul 26, 2004 at 03:49:30PM -0400, Jeff Johnston wrote:
> Ping.
I was waiting for Andrew to try fixing up gcj so that we could avoid
the method name problem. Andrew, are you going to have time to do
that, or should we pursue the hack for now after all? I'd much rather
it be fixed.
--
Daniel Jacobowitz
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [RFA]: Java Inferior Call Take 2
2004-07-26 19:51 ` Daniel Jacobowitz
@ 2004-08-02 10:17 ` Andrew Haley
2004-08-02 15:17 ` Andrew Haley
0 siblings, 1 reply; 36+ messages in thread
From: Andrew Haley @ 2004-08-02 10:17 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: Jeff Johnston, gdb-patches
Daniel Jacobowitz writes:
> On Mon, Jul 26, 2004 at 03:49:30PM -0400, Jeff Johnston wrote:
> > Ping.
>
> I was waiting for Andrew to try fixing up gcj so that we could avoid
> the method name problem. Andrew, are you going to have time to do
> that, or should we pursue the hack for now after all? I'd much rather
> it be fixed.
Sorry Daniel, I've been away. You are right: it should be fixed in
gcc. I will do this as soon as I get stuff sorted out.
Andrew.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [RFA]: Java Inferior Call Take 2
2004-08-02 10:17 ` Andrew Haley
@ 2004-08-02 15:17 ` Andrew Haley
2004-08-02 20:20 ` Daniel Jacobowitz
0 siblings, 1 reply; 36+ messages in thread
From: Andrew Haley @ 2004-08-02 15:17 UTC (permalink / raw)
To: Daniel Jacobowitz, Jeff Johnston, gdb-patches
Andrew Haley writes:
> Daniel Jacobowitz writes:
> > On Mon, Jul 26, 2004 at 03:49:30PM -0400, Jeff Johnston wrote:
> > > Ping.
> >
> > I was waiting for Andrew to try fixing up gcj so that we could avoid
> > the method name problem. Andrew, are you going to have time to do
> > that, or should we pursue the hack for now after all? I'd much rather
> > it be fixed.
>
> Sorry Daniel, I've been away. You are right: it should be fixed in
> gcc. I will do this as soon as I get stuff sorted out.
Okay, I've made a patch but I'm not sure it's what you want.
This is a snippet from a typical file:
.long 0x9ca | .long 0x851
.byte 0x1 .byte 0x1
.string "java.lang.Class.forName(java.lang.String)" | .string "forName"
.byte 0x3 .byte 0x3
Is that what you want? I've only made the change for method names;
field names are as before.
Andrew.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [RFA]: Java Inferior Call Take 2
2004-08-02 15:17 ` Andrew Haley
@ 2004-08-02 20:20 ` Daniel Jacobowitz
2004-08-03 18:45 ` Andrew Haley
0 siblings, 1 reply; 36+ messages in thread
From: Daniel Jacobowitz @ 2004-08-02 20:20 UTC (permalink / raw)
To: Andrew Haley; +Cc: Jeff Johnston, gdb-patches
On Mon, Aug 02, 2004 at 04:16:01PM +0100, Andrew Haley wrote:
> Andrew Haley writes:
> > Daniel Jacobowitz writes:
> > > On Mon, Jul 26, 2004 at 03:49:30PM -0400, Jeff Johnston wrote:
> > > > Ping.
> > >
> > > I was waiting for Andrew to try fixing up gcj so that we could avoid
> > > the method name problem. Andrew, are you going to have time to do
> > > that, or should we pursue the hack for now after all? I'd much rather
> > > it be fixed.
> >
> > Sorry Daniel, I've been away. You are right: it should be fixed in
> > gcc. I will do this as soon as I get stuff sorted out.
>
> Okay, I've made a patch but I'm not sure it's what you want.
>
> This is a snippet from a typical file:
>
> .long 0x9ca | .long 0x851
> .byte 0x1 .byte 0x1
> .string "java.lang.Class.forName(java.lang.String)" | .string "forName"
> .byte 0x3 .byte 0x3
>
> Is that what you want? I've only made the change for method names;
> field names are as before.
That's what I had in mind. What do field names look like? I thought
they were already in the shortened form.
If you want to send me the patch to try, I'll put it together with the
Java inferior call support and see if everything lines up right.
--
Daniel Jacobowitz
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [RFA]: Java Inferior Call Take 2
2004-08-02 20:20 ` Daniel Jacobowitz
@ 2004-08-03 18:45 ` Andrew Haley
2004-08-16 13:08 ` Andrew Haley
0 siblings, 1 reply; 36+ messages in thread
From: Andrew Haley @ 2004-08-03 18:45 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: Jeff Johnston, gdb-patches
[-- Attachment #1: message body text --]
[-- Type: text/plain, Size: 307 bytes --]
Daniel Jacobowitz writes:
>
> That's what I had in mind. What do field names look like? I thought
> they were already in the shortened form.
Looks like it.
> If you want to send me the patch to try, I'll put it together with the
> Java inferior call support and see if everything lines up right.
[-- Attachment #2: java-brief-name --]
[-- Type: text/plain, Size: 12502 bytes --]
Index: java/java-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/java-tree.h,v
retrieving revision 1.215
diff -c -2 -p -r1.215 java-tree.h
*** java/java-tree.h 1 Aug 2004 18:04:42 -0000 1.215
--- java/java-tree.h 2 Aug 2004 15:00:38 -0000
*************** extern tree java_mangle_class_field (str
*** 1326,1330 ****
extern tree java_mangle_class_field_from_string (struct obstack *, char *);
extern tree java_mangle_vtable (struct obstack *, tree);
- extern const char *lang_printable_name_wls (tree, int);
extern void append_gpp_mangled_name (const char *, int);
--- 1326,1329 ----
Index: java/lang.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/lang.c,v
retrieving revision 1.156
diff -c -2 -p -r1.156 lang.c
*** java/lang.c 28 Jul 2004 23:44:55 -0000 1.156
--- java/lang.c 2 Aug 2004 15:00:38 -0000
*************** put_decl_node (tree node)
*** 615,636 ****
const char *
! lang_printable_name (tree decl, int v __attribute__ ((__unused__)))
{
decl_bufpos = 0;
! put_decl_node (decl);
! put_decl_string ("", 1);
! return decl_buf;
! }
!
! /* Does the same thing that lang_printable_name, but add a leading
! space to the DECL name string -- With Leading Space. */
!
! const char *
! lang_printable_name_wls (tree decl, int v __attribute__ ((__unused__)))
! {
! decl_bufpos = 1;
! put_decl_node (decl);
put_decl_string ("", 1);
- decl_buf [0] = ' ';
return decl_buf;
}
--- 615,626 ----
const char *
! lang_printable_name (tree decl, int v)
{
decl_bufpos = 0;
! if (v == 0 && TREE_CODE (decl) == FUNCTION_DECL)
! put_decl_node (DECL_NAME (decl));
! else
! put_decl_node (decl);
put_decl_string ("", 1);
return decl_buf;
}
Index: java/parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.497
diff -c -2 -p -r1.497 parse.y
*** java/parse.y 1 Aug 2004 18:04:42 -0000 1.497
--- java/parse.y 2 Aug 2004 15:00:42 -0000
*************** constructor_circularity_msg (tree from,
*** 4823,4828 ****
{
static char string [4096];
! char *t = xstrdup (lang_printable_name (from, 0));
! sprintf (string, "`%s' invokes `%s'", t, lang_printable_name (to, 0));
free (t);
return string;
--- 4823,4828 ----
{
static char string [4096];
! char *t = xstrdup (lang_printable_name (from, 2));
! sprintf (string, "`%s' invokes `%s'", t, lang_printable_name (to, 2));
free (t);
return string;
*************** verify_constructor_circularity (tree met
*** 4856,4860 ****
}
}
! t = xstrdup (lang_printable_name (meth, 0));
parse_error_context (TREE_PURPOSE (c),
"%s: recursive invocation of constructor `%s'",
--- 4856,4860 ----
}
}
! t = xstrdup (lang_printable_name (meth, 2));
parse_error_context (TREE_PURPOSE (c),
"%s: recursive invocation of constructor `%s'",
*************** get_printable_method_name (tree decl)
*** 6081,6085 ****
}
! to_return = lang_printable_name (decl, 0);
if (DECL_CONSTRUCTOR_P (decl))
DECL_NAME (decl) = name;
--- 6081,6085 ----
}
! to_return = lang_printable_name (decl, 2);
if (DECL_CONSTRUCTOR_P (decl))
DECL_NAME (decl) = name;
*************** check_abstract_method_definitions (int d
*** 6188,6192 ****
"Class `%s' doesn't define the abstract method `%s %s' from %s `%s'. This method must be defined or %s `%s' must be declared abstract",
IDENTIFIER_POINTER (DECL_NAME (class_decl)),
! t, lang_printable_name (method, 0),
(CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (method))) ?
"interface" : "class"),
--- 6188,6192 ----
"Class `%s' doesn't define the abstract method `%s %s' from %s `%s'. This method must be defined or %s `%s' must be declared abstract",
IDENTIFIER_POINTER (DECL_NAME (class_decl)),
! t, lang_printable_name (method, 2),
(CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (method))) ?
"interface" : "class"),
*************** java_check_regular_methods (tree class_d
*** 6366,6370 ****
parse_error_context
(method_wfl, "Method `%s' can't be static in inner class `%s'. Only members of interfaces and top-level classes can be static",
! lang_printable_name (method, 0), t);
free (t);
}
--- 6366,6370 ----
parse_error_context
(method_wfl, "Method `%s' can't be static in inner class `%s'. Only members of interfaces and top-level classes can be static",
! lang_printable_name (method, 2), t);
free (t);
}
*************** java_check_regular_methods (tree class_d
*** 6388,6392 ****
parse_error_context (method_wfl, "Class `%s' must override `%s' with a public method in order to implement interface `%s'",
IDENTIFIER_POINTER (DECL_NAME (class_decl)),
! lang_printable_name (method, 0),
IDENTIFIER_POINTER (DECL_NAME (found_decl)));
}
--- 6388,6392 ----
parse_error_context (method_wfl, "Class `%s' must override `%s' with a public method in order to implement interface `%s'",
IDENTIFIER_POINTER (DECL_NAME (class_decl)),
! lang_printable_name (method, 2),
IDENTIFIER_POINTER (DECL_NAME (found_decl)));
}
*************** java_check_regular_methods (tree class_d
*** 6397,6405 ****
{
char *t = xstrdup
! (lang_printable_name (TREE_TYPE (TREE_TYPE (found)), 0));
parse_error_context
(method_wfl,
"Method `%s' was defined with return type `%s' in class `%s'",
! lang_printable_name (found, 0), t,
IDENTIFIER_POINTER
(DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
--- 6397,6405 ----
{
char *t = xstrdup
! (lang_printable_name (TREE_TYPE (TREE_TYPE (found)), 2));
parse_error_context
(method_wfl,
"Method `%s' was defined with return type `%s' in class `%s'",
! lang_printable_name (found, 2), t,
IDENTIFIER_POINTER
(DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
*************** java_check_regular_methods (tree class_d
*** 6419,6423 ****
"%s methods can't be overridden. Method `%s' is %s in class `%s'",
(METHOD_FINAL (found) ? "Final" : "Static"),
! lang_printable_name (found, 0),
(METHOD_FINAL (found) ? "final" : "static"),
IDENTIFIER_POINTER
--- 6419,6423 ----
"%s methods can't be overridden. Method `%s' is %s in class `%s'",
(METHOD_FINAL (found) ? "Final" : "Static"),
! lang_printable_name (found, 2),
(METHOD_FINAL (found) ? "final" : "static"),
IDENTIFIER_POINTER
*************** java_check_regular_methods (tree class_d
*** 6432,6436 ****
(method_wfl,
"Instance methods can't be overridden by a static method. Method `%s' is an instance method in class `%s'",
! lang_printable_name (found, 0),
IDENTIFIER_POINTER
(DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
--- 6432,6436 ----
(method_wfl,
"Instance methods can't be overridden by a static method. Method `%s' is an instance method in class `%s'",
! lang_printable_name (found, 2),
IDENTIFIER_POINTER
(DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
*************** java_check_regular_methods (tree class_d
*** 6454,6458 ****
parse_error_context
(method_wfl,
! "Methods can't be overridden to be more private. Method `%s' is not %s in class `%s'", lang_printable_name (method, 0),
(METHOD_PUBLIC (method) ? "public" :
(METHOD_PRIVATE (method) ? "private" : "protected")),
--- 6454,6458 ----
parse_error_context
(method_wfl,
! "Methods can't be overridden to be more private. Method `%s' is not %s in class `%s'", lang_printable_name (method, 2),
(METHOD_PUBLIC (method) ? "public" :
(METHOD_PRIVATE (method) ? "private" : "protected")),
*************** check_throws_clauses (tree method, tree
*** 6597,6601 ****
(method_wfl, "Invalid checked exception class `%s' in `throws' clause. The exception must be a subclass of an exception thrown by `%s' from class `%s'",
IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (TREE_VALUE (mthrows)))),
! lang_printable_name (found, 0),
IDENTIFIER_POINTER
(DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
--- 6597,6601 ----
(method_wfl, "Invalid checked exception class `%s' in `throws' clause. The exception must be a subclass of an exception thrown by `%s' from class `%s'",
IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (TREE_VALUE (mthrows)))),
! lang_printable_name (found, 2),
IDENTIFIER_POINTER
(DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
*************** java_check_abstract_methods (tree interf
*** 6624,6632 ****
{
char *t;
! t = xstrdup (lang_printable_name (TREE_TYPE (TREE_TYPE (found)), 0));
parse_error_context
(DECL_FUNCTION_WFL (found),
"Method `%s' was defined with return type `%s' in class `%s'",
! lang_printable_name (found, 0), t,
IDENTIFIER_POINTER
(DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
--- 6624,6632 ----
{
char *t;
! t = xstrdup (lang_printable_name (TREE_TYPE (TREE_TYPE (found)), 2));
parse_error_context
(DECL_FUNCTION_WFL (found),
"Method `%s' was defined with return type `%s' in class `%s'",
! lang_printable_name (found, 2), t,
IDENTIFIER_POINTER
(DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
*************** java_check_abstract_methods (tree interf
*** 6654,6658 ****
"Interface `%s' inherits method `%s' from interface `%s'. This method is redefined with a different return type in interface `%s'",
IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (interface))),
! lang_printable_name (found, 0),
IDENTIFIER_POINTER
(DECL_NAME (TYPE_NAME
--- 6654,6658 ----
"Interface `%s' inherits method `%s' from interface `%s'. This method is redefined with a different return type in interface `%s'",
IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (interface))),
! lang_printable_name (found, 2),
IDENTIFIER_POINTER
(DECL_NAME (TYPE_NAME
*************** check_inner_class_access (tree decl, tre
*** 7221,7225 ****
parse_error_context (cl, "Nested %s %s is %s; cannot be accessed from here",
(CLASS_INTERFACE (decl) ? "interface" : "class"),
! lang_printable_name (decl, 0), access);
}
--- 7221,7225 ----
parse_error_context (cl, "Nested %s %s is %s; cannot be accessed from here",
(CLASS_INTERFACE (decl) ? "interface" : "class"),
! lang_printable_name (decl, 2), access);
}
*************** fix_constructors (tree mdecl)
*** 8816,8820 ****
(lookup_cl (TYPE_NAME (class_type)),
"No constructor matching `%s' found in class `%s'",
! lang_printable_name (mdecl, 0), n);
DECL_NAME (mdecl) = save;
}
--- 8816,8820 ----
(lookup_cl (TYPE_NAME (class_type)),
"No constructor matching `%s' found in class `%s'",
! lang_printable_name (mdecl, 2), n);
DECL_NAME (mdecl) = save;
}
*************** patch_method_invocation (tree patch, tre
*** 10278,10282 ****
if (list && !METHOD_STATIC (list))
{
! char *fct_name = xstrdup (lang_printable_name (list, 0));
parse_error_context
(identifier_wfl,
--- 10278,10282 ----
if (list && !METHOD_STATIC (list))
{
! char *fct_name = xstrdup (lang_printable_name (list, 2));
parse_error_context
(identifier_wfl,
*************** patch_return (tree node)
*** 14649,14653 ****
"`return' with%s value from `%s %s'",
(error_found == 1 ? "" : "out"),
! t, lang_printable_name (meth, 0));
free (t);
}
--- 14649,14653 ----
"`return' with%s value from `%s %s'",
(error_found == 1 ? "" : "out"),
! t, lang_printable_name (meth, 2));
free (t);
}
*************** patch_return (tree node)
*** 14655,14659 ****
parse_error_context (wfl_operator,
"`return' with value from constructor `%s'",
! lang_printable_name (meth, 0));
return error_mark_node;
}
--- 14655,14659 ----
parse_error_context (wfl_operator,
"`return' with value from constructor `%s'",
! lang_printable_name (meth, 2));
return error_mark_node;
}
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [RFA]: Java Inferior Call Take 2
2004-08-03 18:45 ` Andrew Haley
@ 2004-08-16 13:08 ` Andrew Haley
2004-08-16 13:18 ` Daniel Jacobowitz
0 siblings, 1 reply; 36+ messages in thread
From: Andrew Haley @ 2004-08-16 13:08 UTC (permalink / raw)
To: Daniel Jacobowitz, Jeff Johnston, gdb-patches
Any news? I'm waiting to commit this.
Andrew.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [RFA]: Java Inferior Call Take 2
2004-08-16 13:08 ` Andrew Haley
@ 2004-08-16 13:18 ` Daniel Jacobowitz
2004-08-16 20:32 ` Daniel Jacobowitz
0 siblings, 1 reply; 36+ messages in thread
From: Daniel Jacobowitz @ 2004-08-16 13:18 UTC (permalink / raw)
To: Andrew Haley; +Cc: Jeff Johnston, gdb-patches
On Mon, Aug 16, 2004 at 02:06:47PM +0100, Andrew Haley wrote:
> Any news? I'm waiting to commit this.
Sorry, I didn't get to try it - I will today!
--
Daniel Jacobowitz
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [RFA]: Java Inferior Call Take 2
2004-08-16 13:18 ` Daniel Jacobowitz
@ 2004-08-16 20:32 ` Daniel Jacobowitz
0 siblings, 0 replies; 36+ messages in thread
From: Daniel Jacobowitz @ 2004-08-16 20:32 UTC (permalink / raw)
To: Andrew Haley, Jeff Johnston, gdb-patches
On Mon, Aug 16, 2004 at 09:18:00AM -0400, Daniel Jacobowitz wrote:
> On Mon, Aug 16, 2004 at 02:06:47PM +0100, Andrew Haley wrote:
> > Any news? I'm waiting to commit this.
>
> Sorry, I didn't get to try it - I will today!
It works great. With it, none of GDB's existing Java tests seem to
change, but Jeff's new test works without trying to parse the method
name out of DW_AT_name. So please go ahead! :-)
--
Daniel Jacobowitz
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [RFA]: Java Inferior Call Take 2
2004-07-06 21:47 ` Jeff Johnston
2004-07-26 19:49 ` Jeff Johnston
@ 2004-08-16 20:35 ` Daniel Jacobowitz
2004-08-24 18:53 ` [RFA]: Java Inferior Call Take 3 Jeff Johnston
1 sibling, 1 reply; 36+ messages in thread
From: Daniel Jacobowitz @ 2004-08-16 20:35 UTC (permalink / raw)
To: Jeff Johnston; +Cc: Andrew Haley, gdb-patches
On Tue, Jul 06, 2004 at 05:47:09PM -0400, Jeff Johnston wrote:
> Daniel Jacobowitz wrote:
> >On Wed, Jun 23, 2004 at 05:55:07PM -0400, Jeff Johnston wrote:
> >
> >>Daniel Jacobowitz wrote:
> >>
> >>>On Wed, Jun 23, 2004 at 12:05:59PM +0100, Andrew Haley wrote:
> >>>
> >>>
> >>>>This patch is now in mainline. Is there anything else you need?
> >>>
> >>>
> >>>Yes. Two sets of questions left, one for Jeff and one [plus a little
> >>>bit] for you...
> >>>
> >>>
> >>>Jeff, one test still fails: calling addprint. I think this is mostly a
> >>>GDB problem rather than GCC. Before starting the program I see this:
> >>>
> >>
> >>Let me take a look at it. It is not failing in my all-patches-applied
> >>build. Perhaps in splitting the patches up, I screwed up and missed
> >>something.
> >
> >
> >Thanks.
> >
>
> Ok, I figured out what piece I left out and have remade the patch. I can't
> remember where we are on this regarding the workaround for gcc debug-info,
> but at least you will be able to run the test with the full functionality
> now. Please let me know what is needed next as I want to move this forward.
Hi Jeff,
With Andrew's latest GCJ change, you can remove the bit I objected to for
method names. After that I'm happy with the patch. A dwarf2read
maintainer will need to have final review on the dwarf2read bits, so
you may want to post a final patch and ping them.
--
Daniel Jacobowitz
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [RFA]: Java Inferior Call Take 3
2004-08-16 20:35 ` Daniel Jacobowitz
@ 2004-08-24 18:53 ` Jeff Johnston
2004-08-24 19:05 ` Michael Chastain
` (2 more replies)
0 siblings, 3 replies; 36+ messages in thread
From: Jeff Johnston @ 2004-08-24 18:53 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 2673 bytes --]
Here is the revised patch.
2004-08-24 Jeff Johnston <jjohnstn@redhat.com>
* dwarf2read.c (typename_concat): Change prototype to accept dwarf2_cu
struct pointer as argument. Change function to use new argument to
determine language. If language is Java, use "." as separator,
otherwise, use "::".
(partial_die_parent_scope): Change comment to include java. Check
language to determine if Java "." or C++ "::" separator should be used.
(add_partial_symbol): Enhance tests for C++ to also test for Java.
(guess_structure_name): Ditto.
(read_subroutine_type): Ditto.
(new_symbol): Ditto.
(read_structure_type): Add Java vtable support.
(read_namespace): Add Java support.
* jv-exp.y (FuncStart): New pattern.
(MethodInvocation): Add support for simple function calls. Change
warning message for other forms of inferior call currently not
supported.
* valarith.c (value_subscript): Treat an array with upper-bound
of -1 as unknown size.
gdb/testsuite/ChangeLog:
2004-08-24 Jeff Johnston <jjohnstn@redhat.com>
* gdb.java/jprint.exp: New test for java inferior call.
* gdb.java/jprint.java: Ditto.
Daniel Jacobowitz wrote:
> On Tue, Jul 06, 2004 at 05:47:09PM -0400, Jeff Johnston wrote:
>
>>Daniel Jacobowitz wrote:
>>
>>>On Wed, Jun 23, 2004 at 05:55:07PM -0400, Jeff Johnston wrote:
>>>
>>>
>>>>Daniel Jacobowitz wrote:
>>>>
>>>>
>>>>>On Wed, Jun 23, 2004 at 12:05:59PM +0100, Andrew Haley wrote:
>>>>>
>>>>>
>>>>>
>>>>>>This patch is now in mainline. Is there anything else you need?
>>>>>
>>>>>
>>>>>Yes. Two sets of questions left, one for Jeff and one [plus a little
>>>>>bit] for you...
>>>>>
>>>>>
>>>>>Jeff, one test still fails: calling addprint. I think this is mostly a
>>>>>GDB problem rather than GCC. Before starting the program I see this:
>>>>>
>>>>
>>>>Let me take a look at it. It is not failing in my all-patches-applied
>>>>build. Perhaps in splitting the patches up, I screwed up and missed
>>>>something.
>>>
>>>
>>>Thanks.
>>>
>>
>>Ok, I figured out what piece I left out and have remade the patch. I can't
>>remember where we are on this regarding the workaround for gcc debug-info,
>>but at least you will be able to run the test with the full functionality
>>now. Please let me know what is needed next as I want to move this forward.
>
>
> Hi Jeff,
>
> With Andrew's latest GCJ change, you can remove the bit I objected to for
> method names. After that I'm happy with the patch. A dwarf2read
> maintainer will need to have final review on the dwarf2read bits, so
> you may want to post a final patch and ping them.
>
[-- Attachment #2: java-call.patch2 --]
[-- Type: text/plain, Size: 13809 bytes --]
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.151
diff -u -p -r1.151 dwarf2read.c
--- dwarf2read.c 7 May 2004 14:29:33 -0000 1.151
+++ dwarf2read.c 24 Aug 2004 18:45:20 -0000
@@ -788,7 +788,8 @@ static void read_type_die (struct die_in
static char *determine_prefix (struct die_info *die, struct dwarf2_cu *);
-static char *typename_concat (const char *prefix, const char *suffix);
+static char *typename_concat (const char *prefix, const char *suffix,
+ struct dwarf2_cu *);
static void read_typedef (struct die_info *, struct dwarf2_cu *);
@@ -1502,7 +1503,8 @@ scan_partial_symbols (struct partial_die
/* Functions used to compute the fully scoped name of a partial DIE.
Normally, this is simple. For C++, the parent DIE's fully scoped
- name is concatenated with "::" and the partial DIE's name.
+ name is concatenated with "::" and the partial DIE's name. For
+ Java, the same thing occurs except that "." is used instead of "::".
Enumerators are an exception; they use the scope of their parent
enumeration type, i.e. the name of the enumeration type is not
prepended to the enumerator.
@@ -1558,7 +1560,7 @@ partial_die_parent_scope (struct partial
parent->scope = parent->name;
else
parent->scope = obconcat (&cu->comp_unit_obstack, grandparent_scope,
- "::", parent->name);
+ cu->language == language_java ? "." : "::", parent->name);
}
else if (parent->tag == DW_TAG_enumeration_type)
/* Enumerators should not get the name of the enumeration as a prefix. */
@@ -1590,7 +1592,11 @@ partial_die_full_name (struct partial_di
if (parent_scope == NULL)
return NULL;
else
- return concat (parent_scope, "::", pdi->name, NULL);
+ {
+ if (cu->language == language_java)
+ return concat (parent_scope, ".", pdi->name, NULL);
+ return concat (parent_scope, "::", pdi->name, NULL);
+ }
}
static void
@@ -1708,14 +1714,16 @@ add_partial_symbol (struct partial_die_i
return;
add_psymbol_to_list (actual_name, strlen (actual_name),
STRUCT_DOMAIN, LOC_TYPEDEF,
- cu->language == language_cplus
+ (cu->language == language_cplus
+ || cu->language == language_java)
? &objfile->global_psymbols
: &objfile->static_psymbols,
0, (CORE_ADDR) 0, cu->language, objfile);
- if (cu->language == language_cplus)
+ if (cu->language == language_cplus
+ || cu->language == language_java)
{
- /* For C++, these implicitly act as typedefs as well. */
+ /* For C++ and Java, these implicitly act as typedefs as well. */
add_psymbol_to_list (actual_name, strlen (actual_name),
VAR_DOMAIN, LOC_TYPEDEF,
&objfile->global_psymbols,
@@ -1725,7 +1733,8 @@ add_partial_symbol (struct partial_die_i
case DW_TAG_enumerator:
add_psymbol_to_list (actual_name, strlen (actual_name),
VAR_DOMAIN, LOC_CONST,
- cu->language == language_cplus
+ (cu->language == language_cplus
+ || cu->language == language_java)
? &objfile->global_psymbols
: &objfile->static_psymbols,
0, (CORE_ADDR) 0, cu->language, objfile);
@@ -1805,7 +1814,8 @@ static void
guess_structure_name (struct partial_die_info *struct_pdi,
struct dwarf2_cu *cu)
{
- if (cu->language == language_cplus
+ if ((cu->language == language_cplus
+ || cu->language == language_java)
&& cu->has_namespace_info == 0
&& struct_pdi->has_children)
{
@@ -2460,7 +2470,8 @@ read_func_scope (struct die_info *die, s
if (name == NULL || !dwarf2_get_pc_bounds (die, &lowpc, &highpc, cu))
return;
- if (cu->language == language_cplus)
+ if (cu->language == language_cplus
+ || cu->language == language_java)
{
struct die_info *spec_die = die_specification (die, cu);
@@ -3292,7 +3303,8 @@ read_structure_type (struct die_info *di
attr = dwarf2_attr (die, DW_AT_name, cu);
if (attr && DW_STRING (attr))
{
- if (cu->language == language_cplus)
+ if (cu->language == language_cplus
+ || cu->language == language_java)
{
char *new_prefix = determine_class_name (die, cu);
TYPE_TAG_NAME (type) = obsavestring (new_prefix,
@@ -3398,6 +3410,9 @@ read_structure_type (struct die_info *di
{
static const char vptr_name[] =
{'_', 'v', 'p', 't', 'r', '\0'};
+ static const char vtable_name[] =
+ {'v', 't', 'a', 'b', 'l', 'e', '\0'};
+
int i;
/* Our own class provides vtbl ptr. */
@@ -3407,10 +3422,18 @@ read_structure_type (struct die_info *di
{
char *fieldname = TYPE_FIELD_NAME (t, i);
- if ((strncmp (fieldname, vptr_name,
- strlen (vptr_name) - 1)
- == 0)
- && is_cplus_marker (fieldname[strlen (vptr_name)]))
+ if (cu->language == language_java
+ && (strncmp (fieldname, vtable_name,
+ strlen (vtable_name) - 1)
+ == 0))
+ {
+ TYPE_VPTR_FIELDNO (type) = i;
+ break;
+ }
+ else if ((strncmp (fieldname, vptr_name,
+ strlen (vptr_name) - 1)
+ == 0)
+ && is_cplus_marker (fieldname[strlen (vptr_name)]))
{
TYPE_VPTR_FIELDNO (type) = i;
break;
@@ -3502,7 +3525,9 @@ read_enumeration_type (struct die_info *
TYPE_TAG_NAME (type) = obconcat (&objfile->objfile_obstack,
processing_current_prefix,
processing_current_prefix[0] == '\0'
- ? "" : "::",
+ ? "" :
+ cu->language == language_java
+ ? "." : "::",
name);
}
else
@@ -3527,7 +3552,7 @@ read_enumeration_type (struct die_info *
}
/* Determine the name of the type represented by DIE, which should be
- a named C++ compound type. Return the name in question; the caller
+ a named C++ or Java compound type. Return the name in question; the caller
is responsible for xfree()'ing it. */
static char *
@@ -3573,7 +3598,8 @@ determine_class_name (struct die_info *d
{
const char *name = dwarf2_name (die, cu);
new_prefix = typename_concat (processing_current_prefix,
- name ? name : "<<anonymous>>");
+ name ? name : "<<anonymous>>",
+ cu);
}
if (back_to != NULL)
@@ -3810,7 +3836,10 @@ read_namespace (struct die_info *die, st
char *temp_name = alloca (strlen (previous_prefix)
+ 2 + strlen(name) + 1);
strcpy (temp_name, previous_prefix);
- strcat (temp_name, "::");
+ if (cu->language == language_java)
+ strcat (temp_name, ".");
+ else
+ strcat (temp_name, "::");
strcat (temp_name, name);
processing_current_prefix = temp_name;
@@ -4099,10 +4128,11 @@ read_subroutine_type (struct die_info *d
type = die_type (die, cu);
ftype = lookup_function_type (type);
- /* All functions in C++ have prototypes. */
+ /* All functions in C++ and Java have prototypes. */
attr = dwarf2_attr (die, DW_AT_prototyped, cu);
if ((attr && (DW_UNSND (attr) != 0))
- || cu->language == language_cplus)
+ || cu->language == language_cplus
+ || cu->language == language_java)
TYPE_FLAGS (ftype) |= TYPE_FLAG_PROTOTYPED;
if (die->child != NULL)
@@ -4753,7 +4783,8 @@ load_partial_dies (bfd *abfd, char *info
else if (building_psymtab)
add_psymbol_to_list (part_die->name, strlen (part_die->name),
VAR_DOMAIN, LOC_CONST,
- cu->language == language_cplus
+ (cu->language == language_cplus
+ || cu->language == language_java)
? &cu->objfile->global_psymbols
: &cu->objfile->static_psymbols,
0, (CORE_ADDR) 0, cu->language, cu->objfile);
@@ -6357,7 +6388,8 @@ new_symbol (struct die_info *die, struct
read_structure_type, and the correct name is saved in
the type. */
- if (cu->language == language_cplus)
+ if (cu->language == language_cplus
+ || cu->language == language_java)
{
struct type *type = SYMBOL_TYPE (sym);
@@ -6374,7 +6406,7 @@ new_symbol (struct die_info *die, struct
}
{
- /* NOTE: carlton/2003-11-10: C++ class symbols shouldn't
+ /* NOTE: carlton/2003-11-10: C++ and Java class symbols shouldn't
really ever be static objects: otherwise, if you try
to, say, break of a class's method and you're in a file
which doesn't mention that class, it won't work unless
@@ -6385,15 +6417,17 @@ new_symbol (struct die_info *die, struct
struct pending **list_to_add;
list_to_add = (cu->list_in_scope == &file_symbols
- && cu->language == language_cplus
+ && (cu->language == language_cplus
+ || cu->language == language_java)
? &global_symbols : cu->list_in_scope);
add_symbol_to_list (sym, list_to_add);
- /* The semantics of C++ state that "struct foo { ... }" also
+ /* The semantics of C++ and Java state that "struct foo { ... }" also
defines a typedef for "foo". Synthesize a typedef symbol so
that "ptype foo" works as expected. */
- if (cu->language == language_cplus)
+ if (cu->language == language_cplus
+ || cu->language == language_java)
{
struct symbol *typedef_sym = (struct symbol *)
obstack_alloc (&objfile->objfile_obstack,
@@ -6415,7 +6449,8 @@ new_symbol (struct die_info *die, struct
{
SYMBOL_LINKAGE_NAME (sym) = obconcat (&objfile->objfile_obstack,
processing_current_prefix,
- "::",
+ cu->language == language_java
+ ? "." : "::",
name);
}
SYMBOL_CLASS (sym) = LOC_TYPEDEF;
@@ -6434,7 +6469,8 @@ new_symbol (struct die_info *die, struct
{
SYMBOL_LINKAGE_NAME (sym) = obconcat (&objfile->objfile_obstack,
processing_current_prefix,
- "::",
+ cu->language == language_java
+ ? "." : "::",
name);
}
attr = dwarf2_attr (die, DW_AT_const_value, cu);
@@ -6449,7 +6485,8 @@ new_symbol (struct die_info *die, struct
struct pending **list_to_add;
list_to_add = (cu->list_in_scope == &file_symbols
- && cu->language == language_cplus
+ && (cu->language == language_cplus
+ || cu->language == language_java)
? &global_symbols : cu->list_in_scope);
add_symbol_to_list (sym, list_to_add);
@@ -6758,7 +6795,8 @@ determine_prefix (struct die_info *die,
{
struct die_info *parent;
- if (cu->language != language_cplus)
+ if (cu->language != language_cplus
+ && cu->language != language_java)
return NULL;
parent = die->parent;
@@ -6784,7 +6822,8 @@ determine_prefix (struct die_info *die,
char *parent_prefix = determine_prefix (parent, cu);
char *retval = typename_concat (parent_prefix,
namespace_name (parent, &dummy,
- cu));
+ cu),
+ cu);
xfree (parent_prefix);
return retval;
}
@@ -6818,11 +6857,11 @@ determine_prefix (struct die_info *die,
}
/* Return a newly-allocated string formed by concatenating PREFIX,
- "::", and SUFFIX, except that if PREFIX is NULL or the empty
+ "::" or ".", and SUFFIX, except that if PREFIX is NULL or the empty
string, just return a copy of SUFFIX. */
static char *
-typename_concat (const char *prefix, const char *suffix)
+typename_concat (const char *prefix, const char *suffix, struct dwarf2_cu *cu)
{
if (prefix == NULL || prefix[0] == '\0')
return xstrdup (suffix);
@@ -6831,7 +6870,10 @@ typename_concat (const char *prefix, con
char *retval = xmalloc (strlen (prefix) + 2 + strlen (suffix) + 1);
strcpy (retval, prefix);
- strcat (retval, "::");
+ if (cu->language == language_java)
+ strcat (retval, ".");
+ else
+ strcat (retval, "::");
strcat (retval, suffix);
return retval;
Index: jv-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/jv-exp.y,v
retrieving revision 1.18
diff -u -p -r1.18 jv-exp.y
--- jv-exp.y 23 Nov 2003 20:41:17 -0000 1.18
+++ jv-exp.y 24 Aug 2004 18:45:20 -0000
@@ -446,13 +446,22 @@ FieldAccess:
/*| SUPER '.' SimpleName { FIXME } */
;
+FuncStart:
+ Name '('
+ { push_expression_name ($1); }
+;
+
MethodInvocation:
- Name '(' ArgumentList_opt ')'
- { error (_("Method invocation not implemented")); }
+ FuncStart
+ { start_arglist(); }
+ ArgumentList_opt ')'
+ { write_exp_elt_opcode (OP_FUNCALL);
+ write_exp_elt_longcst ((LONGEST) end_arglist ());
+ write_exp_elt_opcode (OP_FUNCALL); }
| Primary '.' SimpleName '(' ArgumentList_opt ')'
- { error (_("Method invocation not implemented")); }
+ { error (_("Form of method invocation not implemented")); }
| SUPER '.' SimpleName '(' ArgumentList_opt ')'
- { error (_("Method invocation not implemented")); }
+ { error (_("Form of method invocation not implemented")); }
;
ArrayAccess:
Index: valarith.c
===================================================================
RCS file: /cvs/src/src/gdb/valarith.c,v
retrieving revision 1.22
diff -u -p -r1.22 valarith.c
--- valarith.c 1 Apr 2004 12:08:30 -0000 1.22
+++ valarith.c 24 Aug 2004 18:45:20 -0000
@@ -202,7 +202,10 @@ value_subscript (struct value *array, st
LONGEST index = value_as_long (idx);
if (index >= lowerbound && index <= upperbound)
return value_subscripted_rvalue (array, idx, lowerbound);
- warning ("array or string index out of range");
+ /* Emit warning unless we have an array of unknown size.
+ An array of unknown size has lowerbound 0 and upperbound -1. */
+ if (upperbound > -1)
+ warning ("array or string index out of range");
/* fall doing C stuff */
c_style = 1;
}
[-- Attachment #3: java-call-test.patch2 --]
[-- Type: text/plain, Size: 4892 bytes --]
Index: gdb.java/jprint.exp
===================================================================
RCS file: gdb.java/jprint.exp
diff -N gdb.java/jprint.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gdb.java/jprint.exp 24 Aug 2004 18:52:19 -0000
@@ -0,0 +1,80 @@
+# Copyright 2004 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# This file was written by Jeff Johnston. (jjohnstn@redhat.com)
+#
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+load_lib "java.exp"
+
+set testfile "jprint"
+set srcfile ${srcdir}/$subdir/${testfile}.java
+set binfile ${objdir}/${subdir}/${testfile}
+if { [compile_java_from_source ${srcfile} ${binfile} "-g"] != "" } {
+ untested "Couldn't compile ${srcfile}"
+ return -1
+}
+
+# Set the current language to java. This counts as a test. If it
+# fails, then we skip the other tests.
+
+proc set_lang_java {} {
+ global gdb_prompt
+ global binfile objdir subdir
+
+ verbose "loading file '$binfile'"
+ gdb_load $binfile
+
+ send_gdb "set language java\n"
+ gdb_expect {
+ -re ".*$gdb_prompt $" {}
+ timeout { fail "set language java (timeout)" ; return 0 }
+ }
+
+ return [gdb_test "show language" ".* source language is \"java\".*" \
+ "set language to \"java\""]
+}
+
+set prms_id 0
+set bug_id 0
+
+# Start with a fresh gdb.
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+
+gdb_test "set print sevenbit-strings" ".*"
+
+if ![set_lang_java] then {
+ # Ref PR gdb:java/1565. Don't use the simpler "break jmisc.main".
+ # As of 2004-02-24 it wasn't working and is being tested separatly.
+ runto "\'${testfile}.main(java.lang.String\[\])\'"
+
+ gdb_test "p jvclass.addprint(4,5,6)" "sum is 15\r\n.*" "unambiguous static call"
+
+ gdb_test "next" ""
+ gdb_test "next" ""
+
+ gdb_test "p x.print(44)" "x is 44\r\n.*" "single argument print call"
+ gdb_test "p x.print(22,33)" "y is 33\r\n.*" "double argument print call"
+ gdb_test "call x.dothat(55)" "new value is 58\r\n.*= 62.*" "virtual fn call"
+ gdb_test "p x.addprint(1,2,3)" "sum is 6\r\n.*" "inherited static call"
+ gdb_test "call x.addk(44)" "adding k gives 121\r\n.*= 121.*" "inherited virtual fn call"
+}
Index: gdb.java/jprint.java
===================================================================
RCS file: gdb.java/jprint.java
diff -N gdb.java/jprint.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gdb.java/jprint.java 24 Aug 2004 18:52:19 -0000
@@ -0,0 +1,62 @@
+// jprint.java test program.
+//
+// Copyright 2004
+// Free Software Foundation, Inc.
+//
+// Written by Jeff Johnston <jjohnstn@redhat.com>
+// Contributed by Red Hat
+//
+// This file is part of GDB.
+//
+// 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
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+
+class jvclass {
+ public static int k;
+ static {
+ k = 77;
+ }
+ public static void addprint (int x, int y, int z) {
+ int sum = x + y + z;
+ System.out.println ("sum is " + sum);
+ }
+
+ public int addk (int x) {
+ int sum = x + k;
+ System.out.println ("adding k gives " + sum);
+ return sum;
+ }
+}
+
+public class jprint extends jvclass {
+ public int dothat (int x) {
+ int y = x + 3;
+ System.out.println ("new value is " + y);
+ return y + 4;
+ }
+ public static void print (int x) {
+ System.out.println("x is " + x);
+ }
+ public static void print (int x, int y) {
+ System.out.println("y is " + y);
+ }
+ public static void main(String[] args) {
+ jprint x = new jprint ();
+ x.print (44);
+ print (k, 33);
+ }
+}
+
+
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [RFA]: Java Inferior Call Take 3
2004-08-24 18:53 ` [RFA]: Java Inferior Call Take 3 Jeff Johnston
@ 2004-08-24 19:05 ` Michael Chastain
2004-08-24 19:28 ` Jeff Johnston
2004-08-24 19:10 ` Michael Chastain
2004-09-01 4:51 ` Jim Blandy
2 siblings, 1 reply; 36+ messages in thread
From: Michael Chastain @ 2004-08-24 19:05 UTC (permalink / raw)
To: jjohnstn; +Cc: drow, gdb-patches
The test script + test program look pretty good to me.
What system(s) did you test it on?
> 2004-08-24 Jeff Johnston <jjohnstn@redhat.com>
>
> * gdb.java/jprint.exp: New test for java inferior call.
> * gdb.java/jprint.java: Ditto.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [RFA]: Java Inferior Call Take 3
2004-08-24 18:53 ` [RFA]: Java Inferior Call Take 3 Jeff Johnston
2004-08-24 19:05 ` Michael Chastain
@ 2004-08-24 19:10 ` Michael Chastain
2004-08-24 19:48 ` Andrew Cagney
2004-09-01 4:51 ` Jim Blandy
2 siblings, 1 reply; 36+ messages in thread
From: Michael Chastain @ 2004-08-24 19:10 UTC (permalink / raw)
To: jjohnstn, drow; +Cc: gdb-patches
Jeff Johnston <jjohnstn@redhat.com> wrote:
> gdb/testsuite/ChangeLog:
>
> 2004-08-24 Jeff Johnston <jjohnstn@redhat.com>
>
> * gdb.java/jprint.exp: New test for java inferior call.
> * gdb.java/jprint.java: Ditto.
Bleagh, my bad, gdb.java doesn't belong to me. It belongs to Anthony
Green, who delegated authority to Andrew Cagney a few months ago.
Well I have no objection to this part of this patch.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [RFA]: Java Inferior Call Take 3
2004-08-24 19:05 ` Michael Chastain
@ 2004-08-24 19:28 ` Jeff Johnston
0 siblings, 0 replies; 36+ messages in thread
From: Jeff Johnston @ 2004-08-24 19:28 UTC (permalink / raw)
To: Michael Chastain; +Cc: drow, gdb-patches
Michael Chastain wrote:
> The test script + test program look pretty good to me.
> What system(s) did you test it on?
>
i686 Linux (RHEL3).
>
>>2004-08-24 Jeff Johnston <jjohnstn@redhat.com>
>>
>> * gdb.java/jprint.exp: New test for java inferior call.
>> * gdb.java/jprint.java: Ditto.
>
>
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [RFA]: Java Inferior Call Take 3
2004-08-24 19:10 ` Michael Chastain
@ 2004-08-24 19:48 ` Andrew Cagney
0 siblings, 0 replies; 36+ messages in thread
From: Andrew Cagney @ 2004-08-24 19:48 UTC (permalink / raw)
To: Michael Chastain, jjohnstn; +Cc: drow, gdb-patches
> Jeff Johnston <jjohnstn@redhat.com> wrote:
>
>>> gdb/testsuite/ChangeLog:
>>>
>>> 2004-08-24 Jeff Johnston <jjohnstn@redhat.com>
>>>
>>> * gdb.java/jprint.exp: New test for java inferior call.
>>> * gdb.java/jprint.java: Ditto.
>
>
> Bleagh, my bad, gdb.java doesn't belong to me. It belongs to Anthony
> Green, who delegated authority to Andrew Cagney a few months ago.
>
> Well I have no objection to this part of this patch.
Approved.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [RFA]: Java Inferior Call Take 3
2004-08-24 18:53 ` [RFA]: Java Inferior Call Take 3 Jeff Johnston
2004-08-24 19:05 ` Michael Chastain
2004-08-24 19:10 ` Michael Chastain
@ 2004-09-01 4:51 ` Jim Blandy
2004-09-09 23:41 ` Jeff Johnston
2 siblings, 1 reply; 36+ messages in thread
From: Jim Blandy @ 2004-09-01 4:51 UTC (permalink / raw)
To: Jeff Johnston; +Cc: Daniel Jacobowitz, gdb-patches
Jeff Johnston <jjohnstn@redhat.com> writes:
> Here is the revised patch.
>
> 2004-08-24 Jeff Johnston <jjohnstn@redhat.com>
>
> * dwarf2read.c (typename_concat): Change prototype to accept dwarf2_cu
> struct pointer as argument. Change function to use new argument to
> determine language. If language is Java, use "." as separator,
> otherwise, use "::".
> (partial_die_parent_scope): Change comment to include java. Check
> language to determine if Java "." or C++ "::" separator should be used.
> (add_partial_symbol): Enhance tests for C++ to also test for Java.
> (guess_structure_name): Ditto.
> (read_subroutine_type): Ditto.
> (new_symbol): Ditto.
> (read_structure_type): Add Java vtable support.
> (read_namespace): Add Java support.
> * jv-exp.y (FuncStart): New pattern.
> (MethodInvocation): Add support for simple function calls. Change
> warning message for other forms of inferior call currently not
> supported.
> * valarith.c (value_subscript): Treat an array with upper-bound
> of -1 as unknown size.
For the dwarf2read.c part of this patch:
There are a lot of places where we're selecting the name component
separator based on the language; I'd like compound name construction
abstracted out into its own function. Two possible approaches:
- typename_concat could take, in addition to the cu, a pointer to an
obstack. When the obstack pointer is null, typename_concat would
use xmalloc as it does now; otherwise it'd use obconcat.
- If you don't like overloading the behavior of typename_concat that
way, you could define a new function altogether that takes a prefix,
a name, a cu, and an obstack, and returns the name with the prefix
properly attached, allocated in the obstack.
But once there's a function that does this, I think all the 'if java
then "." else "::"' can be neatened up quite a bit.
In this change:
- /* The semantics of C++ state that "struct foo { ... }" also
+ /* The semantics of C++ and Java state that "struct foo { ... }" also
'struct foo { ... }' isn't valid Java; go ahead and say what you mean:
/* The semantics of C++ state that "struct foo { ... }" also
defines a typedef for "foo". A Java class declaration also
defines a typedef for the class. Synthesize a typedef symbol
so that "ptype foo" works as expected. */
The new comment for typename_concat should explain what its 'cu'
argument is used for.
The vtable pointer recognition code is kind of weird. The use of
'strlen (vptr_name) - 1' looks like a bug: don't we want to include
that last character in the comparison? I've committed the patch
below; could you adapt your patch to apply on top of that?
2004-08-31 Jim Blandy <jimb@redhat.com>
* dwarf2read.c (is_vtable_name): New function, based on logic from
read_structure_type, but passing the correct length to strncmp,
and using 'sizeof' instead of 'strlen'.
(read_structure_type): Call it.
Index: gdb/dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.159
diff -c -p -r1.159 dwarf2read.c
*** gdb/dwarf2read.c 29 Aug 2004 10:12:14 -0000 1.159
--- gdb/dwarf2read.c 31 Aug 2004 22:25:05 -0000
*************** dwarf2_attach_fn_fields_to_type (struct
*** 3265,3270 ****
--- 3265,3287 ----
TYPE_NFN_FIELDS_TOTAL (type) = total_length;
}
+
+ /* Returns non-zero if NAME is the name of a vtable member in CU's
+ language, zero otherwise. */
+ static int
+ is_vtable_name (const char *name, struct dwarf2_cu *cu)
+ {
+ static const char vptr[] = "_vptr";
+
+ /* C++ and some implementations of Java use this name. */
+ if (strncmp (name, vptr, sizeof (vptr) - 1) == 0
+ && is_cplus_marker (name[sizeof (vptr) - 1]))
+ return 1;
+
+ return 0;
+ }
+
+
/* Called when we find the DIE that starts a structure or union scope
(definition) to process all dies that define the members of the
structure or union.
*************** read_structure_type (struct die_info *di
*** 3403,3410 ****
TYPE_VPTR_BASETYPE (type) = t;
if (type == t)
{
- static const char vptr_name[] =
- {'_', 'v', 'p', 't', 'r', '\0'};
int i;
/* Our own class provides vtbl ptr. */
--- 3420,3425 ----
*************** read_structure_type (struct die_info *di
*** 3414,3423 ****
{
char *fieldname = TYPE_FIELD_NAME (t, i);
! if ((strncmp (fieldname, vptr_name,
! strlen (vptr_name) - 1)
! == 0)
! && is_cplus_marker (fieldname[strlen (vptr_name)]))
{
TYPE_VPTR_FIELDNO (type) = i;
break;
--- 3429,3435 ----
{
char *fieldname = TYPE_FIELD_NAME (t, i);
! if (is_vtable_name (fieldname, cu))
{
TYPE_VPTR_FIELDNO (type) = i;
break;
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [RFA]: Java Inferior Call Take 3
2004-09-01 4:51 ` Jim Blandy
@ 2004-09-09 23:41 ` Jeff Johnston
2004-09-10 20:12 ` Jim Blandy
0 siblings, 1 reply; 36+ messages in thread
From: Jeff Johnston @ 2004-09-09 23:41 UTC (permalink / raw)
To: Jim Blandy; +Cc: Daniel Jacobowitz, gdb-patches
[-- Attachment #1: Type: text/plain, Size: 4130 bytes --]
Jim Blandy wrote:
> Jeff Johnston <jjohnstn@redhat.com> writes:
>
>>Here is the revised patch.
>>
>>2004-08-24 Jeff Johnston <jjohnstn@redhat.com>
>>
>> * dwarf2read.c (typename_concat): Change prototype to accept dwarf2_cu
>> struct pointer as argument. Change function to use new argument to
>> determine language. If language is Java, use "." as separator,
>> otherwise, use "::".
>> (partial_die_parent_scope): Change comment to include java. Check
>> language to determine if Java "." or C++ "::" separator should be used.
>> (add_partial_symbol): Enhance tests for C++ to also test for Java.
>> (guess_structure_name): Ditto.
>> (read_subroutine_type): Ditto.
>> (new_symbol): Ditto.
>> (read_structure_type): Add Java vtable support.
>> (read_namespace): Add Java support.
>> * jv-exp.y (FuncStart): New pattern.
>> (MethodInvocation): Add support for simple function calls. Change
>> warning message for other forms of inferior call currently not
>> supported.
>> * valarith.c (value_subscript): Treat an array with upper-bound
>> of -1 as unknown size.
>
>
> For the dwarf2read.c part of this patch:
>
> There are a lot of places where we're selecting the name component
> separator based on the language; I'd like compound name construction
> abstracted out into its own function. Two possible approaches:
>
> - typename_concat could take, in addition to the cu, a pointer to an
> obstack. When the obstack pointer is null, typename_concat would
> use xmalloc as it does now; otherwise it'd use obconcat.
>
> - If you don't like overloading the behavior of typename_concat that
> way, you could define a new function altogether that takes a prefix,
> a name, a cu, and an obstack, and returns the name with the prefix
> properly attached, allocated in the obstack.
>
> But once there's a function that does this, I think all the 'if java
> then "." else "::"' can be neatened up quite a bit.
>
>
> In this change:
>
> - /* The semantics of C++ state that "struct foo { ... }" also
> + /* The semantics of C++ and Java state that "struct foo { ... }" also
>
> 'struct foo { ... }' isn't valid Java; go ahead and say what you mean:
>
> /* The semantics of C++ state that "struct foo { ... }" also
> defines a typedef for "foo". A Java class declaration also
> defines a typedef for the class. Synthesize a typedef symbol
> so that "ptype foo" works as expected. */
>
>
> The new comment for typename_concat should explain what its 'cu'
> argument is used for.
>
> The vtable pointer recognition code is kind of weird. The use of
> 'strlen (vptr_name) - 1' looks like a bug: don't we want to include
> that last character in the comparison? I've committed the patch
> below; could you adapt your patch to apply on top of that?
>
Ok. How about the following revised patch which modifies typename_concat as
suggested above plus incorporates your other comments?
2004-09-09 Jeff Johnston <jjohnstn@redhat.com>
* dwarf2read.c (typename_concat): Change prototype to accept dwarf2_cu
struct pointer and obstack pointer as arguments. Change function to
pick separator based on language and whether prefix/suffix is NULL or
empty. Also support concatenating using the obstack argument.
(partial_die_parent_scope): Change comment to include java. Check
language to determine if Java "." or C++ "::" separator should be used.
(add_partial_symbol): Enhance tests for C++ to also test for Java.
(guess_structure_name): Ditto.
(read_subroutine_type): Ditto.
(new_symbol): Ditto.
(read_structure_type): Add Java vtable support.
(read_namespace): Add Java support.
* jv-exp.y (FuncStart): New pattern.
(MethodInvocation): Add support for simple function calls. Change
warning message for other forms of inferior call currently not
supported.
* valarith.c (value_subscript): Treat an array with upper-bound
of -1 as unknown size.
Ok to commit?
-- Jeff J.
[-- Attachment #2: java-inferior-call.patch3 --]
[-- Type: text/plain, Size: 16231 bytes --]
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.160
diff -u -p -r1.160 dwarf2read.c
--- dwarf2read.c 1 Sep 2004 04:19:21 -0000 1.160
+++ dwarf2read.c 9 Sep 2004 23:36:39 -0000
@@ -791,7 +791,8 @@ static void read_type_die (struct die_in
static char *determine_prefix (struct die_info *die, struct dwarf2_cu *);
-static char *typename_concat (const char *prefix, const char *suffix);
+static char *typename_concat (struct obstack *, const char *prefix, const char *suffix,
+ struct dwarf2_cu *);
static void read_typedef (struct die_info *, struct dwarf2_cu *);
@@ -1511,7 +1512,8 @@ scan_partial_symbols (struct partial_die
/* Functions used to compute the fully scoped name of a partial DIE.
Normally, this is simple. For C++, the parent DIE's fully scoped
- name is concatenated with "::" and the partial DIE's name.
+ name is concatenated with "::" and the partial DIE's name. For
+ Java, the same thing occurs except that "." is used instead of "::".
Enumerators are an exception; they use the scope of their parent
enumeration type, i.e. the name of the enumeration type is not
prepended to the enumerator.
@@ -1566,8 +1568,8 @@ partial_die_parent_scope (struct partial
if (grandparent_scope == NULL)
parent->scope = parent->name;
else
- parent->scope = obconcat (&cu->comp_unit_obstack, grandparent_scope,
- "::", parent->name);
+ parent->scope = typename_concat (&cu->comp_unit_obstack, grandparent_scope,
+ parent->name, cu);
}
else if (parent->tag == DW_TAG_enumeration_type)
/* Enumerators should not get the name of the enumeration as a prefix. */
@@ -1599,7 +1601,11 @@ partial_die_full_name (struct partial_di
if (parent_scope == NULL)
return NULL;
else
- return concat (parent_scope, "::", pdi->name, NULL);
+ {
+ if (cu->language == language_java)
+ return concat (parent_scope, ".", pdi->name, NULL);
+ return concat (parent_scope, "::", pdi->name, NULL);
+ }
}
static void
@@ -1717,14 +1723,16 @@ add_partial_symbol (struct partial_die_i
return;
add_psymbol_to_list (actual_name, strlen (actual_name),
STRUCT_DOMAIN, LOC_TYPEDEF,
- cu->language == language_cplus
+ (cu->language == language_cplus
+ || cu->language == language_java)
? &objfile->global_psymbols
: &objfile->static_psymbols,
0, (CORE_ADDR) 0, cu->language, objfile);
- if (cu->language == language_cplus)
+ if (cu->language == language_cplus
+ || cu->language == language_java)
{
- /* For C++, these implicitly act as typedefs as well. */
+ /* For C++ and Java, these implicitly act as typedefs as well. */
add_psymbol_to_list (actual_name, strlen (actual_name),
VAR_DOMAIN, LOC_TYPEDEF,
&objfile->global_psymbols,
@@ -1734,7 +1742,8 @@ add_partial_symbol (struct partial_die_i
case DW_TAG_enumerator:
add_psymbol_to_list (actual_name, strlen (actual_name),
VAR_DOMAIN, LOC_CONST,
- cu->language == language_cplus
+ (cu->language == language_cplus
+ || cu->language == language_java)
? &objfile->global_psymbols
: &objfile->static_psymbols,
0, (CORE_ADDR) 0, cu->language, objfile);
@@ -1814,7 +1823,8 @@ static void
guess_structure_name (struct partial_die_info *struct_pdi,
struct dwarf2_cu *cu)
{
- if (cu->language == language_cplus
+ if ((cu->language == language_cplus
+ || cu->language == language_java)
&& cu->has_namespace_info == 0
&& struct_pdi->has_children)
{
@@ -2474,7 +2484,8 @@ read_func_scope (struct die_info *die, s
if (name == NULL || !dwarf2_get_pc_bounds (die, &lowpc, &highpc, cu))
return;
- if (cu->language == language_cplus)
+ if (cu->language == language_cplus
+ || cu->language == language_java)
{
struct die_info *spec_die = die_specification (die, cu);
@@ -3272,10 +3283,13 @@ static int
is_vtable_name (const char *name, struct dwarf2_cu *cu)
{
static const char vptr[] = "_vptr";
+ static const char vtable[] = "vtable";
- /* C++ and some implementations of Java use this name. */
- if (strncmp (name, vptr, sizeof (vptr) - 1) == 0
- && is_cplus_marker (name[sizeof (vptr) - 1]))
+ /* Look for the C++ and Java forms of the vtable. */
+ if ((cu->language == language_java
+ && strncmp (name, vtable, sizeof (vtable) - 1) == 0)
+ || (strncmp (name, vptr, sizeof (vptr) - 1) == 0
+ && is_cplus_marker (name[sizeof (vptr) - 1])))
return 1;
return 0;
@@ -3316,7 +3330,8 @@ read_structure_type (struct die_info *di
attr = dwarf2_attr (die, DW_AT_name, cu);
if (attr && DW_STRING (attr))
{
- if (cu->language == language_cplus)
+ if (cu->language == language_cplus
+ || cu->language == language_java)
{
char *new_prefix = determine_class_name (die, cu);
TYPE_TAG_NAME (type) = obsavestring (new_prefix,
@@ -3518,11 +3533,9 @@ read_enumeration_type (struct die_info *
if (processing_has_namespace_info)
{
- TYPE_TAG_NAME (type) = obconcat (&objfile->objfile_obstack,
- processing_current_prefix,
- processing_current_prefix[0] == '\0'
- ? "" : "::",
- name);
+ TYPE_TAG_NAME (type) = typename_concat (&objfile->objfile_obstack,
+ processing_current_prefix,
+ name, cu);
}
else
{
@@ -3546,7 +3559,7 @@ read_enumeration_type (struct die_info *
}
/* Determine the name of the type represented by DIE, which should be
- a named C++ compound type. Return the name in question; the caller
+ a named C++ or Java compound type. Return the name in question; the caller
is responsible for xfree()'ing it. */
static char *
@@ -3593,8 +3606,9 @@ determine_class_name (struct die_info *d
if (new_prefix == NULL)
{
const char *name = dwarf2_name (die, cu);
- new_prefix = typename_concat (processing_current_prefix,
- name ? name : "<<anonymous>>");
+ new_prefix = typename_concat (NULL, processing_current_prefix,
+ name ? name : "<<anonymous>>",
+ cu);
}
if (back_to != NULL)
@@ -3877,7 +3891,10 @@ read_namespace (struct die_info *die, st
char *temp_name = alloca (strlen (previous_prefix)
+ 2 + strlen(name) + 1);
strcpy (temp_name, previous_prefix);
- strcat (temp_name, "::");
+ if (cu->language == language_java)
+ strcat (temp_name, ".");
+ else
+ strcat (temp_name, "::");
strcat (temp_name, name);
processing_current_prefix = temp_name;
@@ -4166,10 +4183,11 @@ read_subroutine_type (struct die_info *d
type = die_type (die, cu);
ftype = lookup_function_type (type);
- /* All functions in C++ have prototypes. */
+ /* All functions in C++ and Java have prototypes. */
attr = dwarf2_attr (die, DW_AT_prototyped, cu);
if ((attr && (DW_UNSND (attr) != 0))
- || cu->language == language_cplus)
+ || cu->language == language_cplus
+ || cu->language == language_java)
TYPE_FLAGS (ftype) |= TYPE_FLAG_PROTOTYPED;
if (die->child != NULL)
@@ -4820,7 +4838,8 @@ load_partial_dies (bfd *abfd, char *info
else if (building_psymtab)
add_psymbol_to_list (part_die->name, strlen (part_die->name),
VAR_DOMAIN, LOC_CONST,
- cu->language == language_cplus
+ (cu->language == language_cplus
+ || cu->language == language_java)
? &cu->objfile->global_psymbols
: &cu->objfile->static_psymbols,
0, (CORE_ADDR) 0, cu->language, cu->objfile);
@@ -6431,7 +6450,8 @@ new_symbol (struct die_info *die, struct
read_structure_type, and the correct name is saved in
the type. */
- if (cu->language == language_cplus)
+ if (cu->language == language_cplus
+ || cu->language == language_java)
{
struct type *type = SYMBOL_TYPE (sym);
@@ -6448,7 +6468,7 @@ new_symbol (struct die_info *die, struct
}
{
- /* NOTE: carlton/2003-11-10: C++ class symbols shouldn't
+ /* NOTE: carlton/2003-11-10: C++ and Java class symbols shouldn't
really ever be static objects: otherwise, if you try
to, say, break of a class's method and you're in a file
which doesn't mention that class, it won't work unless
@@ -6459,15 +6479,18 @@ new_symbol (struct die_info *die, struct
struct pending **list_to_add;
list_to_add = (cu->list_in_scope == &file_symbols
- && cu->language == language_cplus
+ && (cu->language == language_cplus
+ || cu->language == language_java)
? &global_symbols : cu->list_in_scope);
add_symbol_to_list (sym, list_to_add);
/* The semantics of C++ state that "struct foo { ... }" also
- defines a typedef for "foo". Synthesize a typedef symbol so
- that "ptype foo" works as expected. */
- if (cu->language == language_cplus)
+ defines a typedef for "foo". A Java class declaration also
+ defines a typedef for the class. Synthesize a typedef symbol
+ so that "ptype foo" works as expected. */
+ if (cu->language == language_cplus
+ || cu->language == language_java)
{
struct symbol *typedef_sym = (struct symbol *)
obstack_alloc (&objfile->objfile_obstack,
@@ -6487,10 +6510,9 @@ new_symbol (struct die_info *die, struct
if (processing_has_namespace_info
&& processing_current_prefix[0] != '\0')
{
- SYMBOL_LINKAGE_NAME (sym) = obconcat (&objfile->objfile_obstack,
- processing_current_prefix,
- "::",
- name);
+ SYMBOL_LINKAGE_NAME (sym) = typename_concat (&objfile->objfile_obstack,
+ processing_current_prefix,
+ name, cu);
}
SYMBOL_CLASS (sym) = LOC_TYPEDEF;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
@@ -6506,10 +6528,9 @@ new_symbol (struct die_info *die, struct
if (processing_has_namespace_info
&& processing_current_prefix[0] != '\0')
{
- SYMBOL_LINKAGE_NAME (sym) = obconcat (&objfile->objfile_obstack,
- processing_current_prefix,
- "::",
- name);
+ SYMBOL_LINKAGE_NAME (sym) = typename_concat (&objfile->objfile_obstack,
+ processing_current_prefix,
+ name, cu);
}
attr = dwarf2_attr (die, DW_AT_const_value, cu);
if (attr)
@@ -6523,7 +6544,8 @@ new_symbol (struct die_info *die, struct
struct pending **list_to_add;
list_to_add = (cu->list_in_scope == &file_symbols
- && cu->language == language_cplus
+ && (cu->language == language_cplus
+ || cu->language == language_java)
? &global_symbols : cu->list_in_scope);
add_symbol_to_list (sym, list_to_add);
@@ -6832,7 +6854,8 @@ determine_prefix (struct die_info *die,
{
struct die_info *parent;
- if (cu->language != language_cplus)
+ if (cu->language != language_cplus
+ && cu->language != language_java)
return NULL;
parent = die->parent;
@@ -6856,9 +6879,10 @@ determine_prefix (struct die_info *die,
{
int dummy;
char *parent_prefix = determine_prefix (parent, cu);
- char *retval = typename_concat (parent_prefix,
+ char *retval = typename_concat (NULL, parent_prefix,
namespace_name (parent, &dummy,
- cu));
+ cu),
+ cu);
xfree (parent_prefix);
return retval;
}
@@ -6891,25 +6915,47 @@ determine_prefix (struct die_info *die,
}
}
-/* Return a newly-allocated string formed by concatenating PREFIX,
- "::", and SUFFIX, except that if PREFIX is NULL or the empty
- string, just return a copy of SUFFIX. */
+/* Return a newly-allocated string formed by concatenating PREFIX and
+ SUFFIX with appropriate separator. If PREFIX or SUFFIX is NULL or empty, then
+ simply copy the SUFFIX or PREFIX, respectively. If OBS is non-null,
+ perform an obconcat, otherwise allocate storage for the result. The CU argument
+ is used to determine the language and hence, the appropriate separator. */
+
+#define MAX_SEP_LEN 2 /* sizeof ("::") */
static char *
-typename_concat (const char *prefix, const char *suffix)
+typename_concat (struct obstack *obs, const char *prefix, const char *suffix,
+ struct dwarf2_cu *cu)
{
- if (prefix == NULL || prefix[0] == '\0')
- return xstrdup (suffix);
- else
- {
- char *retval = xmalloc (strlen (prefix) + 2 + strlen (suffix) + 1);
+ char *sep;
- strcpy (retval, prefix);
- strcat (retval, "::");
- strcat (retval, suffix);
+ if (suffix == NULL || suffix[0] == '\0' || prefix == NULL || prefix[0] == '\0')
+ sep = "";
+ else if (cu->language == language_java)
+ sep = ".";
+ else
+ sep = "::";
+ if (obs == NULL)
+ {
+ char *retval = xmalloc (strlen (prefix) + MAX_SEP_LEN + strlen (suffix) + 1);
+ retval[0] = '\0';
+
+ if (prefix)
+ {
+ strcpy (retval, prefix);
+ strcat (retval, sep);
+ }
+ if (suffix)
+ strcat (retval, suffix);
+
return retval;
}
+ else
+ {
+ /* We have an obstack. */
+ return obconcat (obs, prefix, sep, suffix);
+ }
}
static struct type *
Index: jv-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/jv-exp.y,v
retrieving revision 1.18
diff -u -p -r1.18 jv-exp.y
--- jv-exp.y 23 Nov 2003 20:41:17 -0000 1.18
+++ jv-exp.y 9 Sep 2004 23:36:39 -0000
@@ -446,13 +446,22 @@ FieldAccess:
/*| SUPER '.' SimpleName { FIXME } */
;
+FuncStart:
+ Name '('
+ { push_expression_name ($1); }
+;
+
MethodInvocation:
- Name '(' ArgumentList_opt ')'
- { error (_("Method invocation not implemented")); }
+ FuncStart
+ { start_arglist(); }
+ ArgumentList_opt ')'
+ { write_exp_elt_opcode (OP_FUNCALL);
+ write_exp_elt_longcst ((LONGEST) end_arglist ());
+ write_exp_elt_opcode (OP_FUNCALL); }
| Primary '.' SimpleName '(' ArgumentList_opt ')'
- { error (_("Method invocation not implemented")); }
+ { error (_("Form of method invocation not implemented")); }
| SUPER '.' SimpleName '(' ArgumentList_opt ')'
- { error (_("Method invocation not implemented")); }
+ { error (_("Form of method invocation not implemented")); }
;
ArrayAccess:
Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.135
diff -u -p -r1.135 symtab.c
--- symtab.c 10 Aug 2004 21:16:13 -0000 1.135
+++ symtab.c 9 Sep 2004 23:36:39 -0000
@@ -1000,7 +1000,7 @@ lookup_symbol (const char *name, const s
modified_name = name;
- /* If we are using C++ language, demangle the name before doing a lookup, so
+ /* If we are using C++ or Java, demangle the name before doing a lookup, so
we can always binary search. */
if (current_language->la_language == language_cplus)
{
@@ -1012,6 +1012,17 @@ lookup_symbol (const char *name, const s
needtofreename = 1;
}
}
+ else if (current_language->la_language == language_java)
+ {
+ demangled_name = cplus_demangle (name,
+ DMGL_ANSI | DMGL_PARAMS | DMGL_JAVA);
+ if (demangled_name)
+ {
+ mangled_name = name;
+ modified_name = demangled_name;
+ needtofreename = 1;
+ }
+ }
if (case_sensitivity == case_sensitive_off)
{
Index: valarith.c
===================================================================
RCS file: /cvs/src/src/gdb/valarith.c,v
retrieving revision 1.23
diff -u -p -r1.23 valarith.c
--- valarith.c 27 Jun 2004 07:57:15 -0000 1.23
+++ valarith.c 9 Sep 2004 23:36:39 -0000
@@ -202,7 +202,10 @@ value_subscript (struct value *array, st
LONGEST index = value_as_long (idx);
if (index >= lowerbound && index <= upperbound)
return value_subscripted_rvalue (array, idx, lowerbound);
- warning ("array or string index out of range");
+ /* Emit warning unless we have an array of unknown size.
+ An array of unknown size has lowerbound 0 and upperbound -1. */
+ if (upperbound > -1)
+ warning ("array or string index out of range");
/* fall doing C stuff */
c_style = 1;
}
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [RFA]: Java Inferior Call Take 3
2004-09-09 23:41 ` Jeff Johnston
@ 2004-09-10 20:12 ` Jim Blandy
2004-09-15 22:58 ` Jeff Johnston
0 siblings, 1 reply; 36+ messages in thread
From: Jim Blandy @ 2004-09-10 20:12 UTC (permalink / raw)
To: Jeff Johnston; +Cc: Daniel Jacobowitz, gdb-patches
Jeff Johnston <jjohnstn@redhat.com> writes:
> Ok. How about the following revised patch which modifies
> typename_concat as suggested above plus incorporates your other
> comments?
Great --- thanks for revising this.
> @@ -1599,7 +1601,11 @@ partial_die_full_name (struct partial_di
> if (parent_scope == NULL)
> return NULL;
> else
> - return concat (parent_scope, "::", pdi->name, NULL);
> + {
> + if (cu->language == language_java)
> + return concat (parent_scope, ".", pdi->name, NULL);
> + return concat (parent_scope, "::", pdi->name, NULL);
> + }
> }
>
> static void
Any reason we're not using typename_concat here, too?
> @@ -3877,7 +3891,10 @@ read_namespace (struct die_info *die, st
> char *temp_name = alloca (strlen (previous_prefix)
> + 2 + strlen(name) + 1);
> strcpy (temp_name, previous_prefix);
> - strcat (temp_name, "::");
> + if (cu->language == language_java)
> + strcat (temp_name, ".");
> + else
> + strcat (temp_name, "::");
> strcat (temp_name, name);
>
> processing_current_prefix = temp_name;
Here, too. I guess you'll need to add a cleanup to free it, since
typename_concat can't use alloca.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [RFA]: Java Inferior Call Take 3
2004-09-10 20:12 ` Jim Blandy
@ 2004-09-15 22:58 ` Jeff Johnston
2004-09-20 18:23 ` Jim Blandy
0 siblings, 1 reply; 36+ messages in thread
From: Jeff Johnston @ 2004-09-15 22:58 UTC (permalink / raw)
To: Jim Blandy; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1384 bytes --]
Jim Blandy wrote:
> Jeff Johnston <jjohnstn@redhat.com> writes:
>
>>Ok. How about the following revised patch which modifies
>>typename_concat as suggested above plus incorporates your other
>>comments?
>
>
> Great --- thanks for revising this.
>
>
>>@@ -1599,7 +1601,11 @@ partial_die_full_name (struct partial_di
>> if (parent_scope == NULL)
>> return NULL;
>> else
>>- return concat (parent_scope, "::", pdi->name, NULL);
>>+ {
>>+ if (cu->language == language_java)
>>+ return concat (parent_scope, ".", pdi->name, NULL);
>>+ return concat (parent_scope, "::", pdi->name, NULL);
>>+ }
>> }
>>
>> static void
>
>
> Any reason we're not using typename_concat here, too?
>
Done.
>
>>@@ -3877,7 +3891,10 @@ read_namespace (struct die_info *die, st
>> char *temp_name = alloca (strlen (previous_prefix)
>> + 2 + strlen(name) + 1);
>> strcpy (temp_name, previous_prefix);
>>- strcat (temp_name, "::");
>>+ if (cu->language == language_java)
>>+ strcat (temp_name, ".");
>>+ else
>>+ strcat (temp_name, "::");
>> strcat (temp_name, name);
>>
>> processing_current_prefix = temp_name;
>
>
> Here, too. I guess you'll need to add a cleanup to free it, since
> typename_concat can't use alloca.
>
>
And done.
Ok now?
Retested on x86-linux with up to date compiler with needed gcj fixes.
-- Jeff J.
[-- Attachment #2: java-inferior-call.patch4 --]
[-- Type: text/plain, Size: 16729 bytes --]
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.160
diff -u -p -r1.160 dwarf2read.c
--- dwarf2read.c 1 Sep 2004 04:19:21 -0000 1.160
+++ dwarf2read.c 15 Sep 2004 22:49:57 -0000
@@ -791,7 +791,8 @@ static void read_type_die (struct die_in
static char *determine_prefix (struct die_info *die, struct dwarf2_cu *);
-static char *typename_concat (const char *prefix, const char *suffix);
+static char *typename_concat (struct obstack *, const char *prefix, const char *suffix,
+ struct dwarf2_cu *);
static void read_typedef (struct die_info *, struct dwarf2_cu *);
@@ -1511,7 +1512,8 @@ scan_partial_symbols (struct partial_die
/* Functions used to compute the fully scoped name of a partial DIE.
Normally, this is simple. For C++, the parent DIE's fully scoped
- name is concatenated with "::" and the partial DIE's name.
+ name is concatenated with "::" and the partial DIE's name. For
+ Java, the same thing occurs except that "." is used instead of "::".
Enumerators are an exception; they use the scope of their parent
enumeration type, i.e. the name of the enumeration type is not
prepended to the enumerator.
@@ -1566,8 +1568,8 @@ partial_die_parent_scope (struct partial
if (grandparent_scope == NULL)
parent->scope = parent->name;
else
- parent->scope = obconcat (&cu->comp_unit_obstack, grandparent_scope,
- "::", parent->name);
+ parent->scope = typename_concat (&cu->comp_unit_obstack, grandparent_scope,
+ parent->name, cu);
}
else if (parent->tag == DW_TAG_enumeration_type)
/* Enumerators should not get the name of the enumeration as a prefix. */
@@ -1599,7 +1601,7 @@ partial_die_full_name (struct partial_di
if (parent_scope == NULL)
return NULL;
else
- return concat (parent_scope, "::", pdi->name, NULL);
+ return typename_concat (NULL, parent_scope, pdi->name, cu);
}
static void
@@ -1717,14 +1719,16 @@ add_partial_symbol (struct partial_die_i
return;
add_psymbol_to_list (actual_name, strlen (actual_name),
STRUCT_DOMAIN, LOC_TYPEDEF,
- cu->language == language_cplus
+ (cu->language == language_cplus
+ || cu->language == language_java)
? &objfile->global_psymbols
: &objfile->static_psymbols,
0, (CORE_ADDR) 0, cu->language, objfile);
- if (cu->language == language_cplus)
+ if (cu->language == language_cplus
+ || cu->language == language_java)
{
- /* For C++, these implicitly act as typedefs as well. */
+ /* For C++ and Java, these implicitly act as typedefs as well. */
add_psymbol_to_list (actual_name, strlen (actual_name),
VAR_DOMAIN, LOC_TYPEDEF,
&objfile->global_psymbols,
@@ -1734,7 +1738,8 @@ add_partial_symbol (struct partial_die_i
case DW_TAG_enumerator:
add_psymbol_to_list (actual_name, strlen (actual_name),
VAR_DOMAIN, LOC_CONST,
- cu->language == language_cplus
+ (cu->language == language_cplus
+ || cu->language == language_java)
? &objfile->global_psymbols
: &objfile->static_psymbols,
0, (CORE_ADDR) 0, cu->language, objfile);
@@ -1814,7 +1819,8 @@ static void
guess_structure_name (struct partial_die_info *struct_pdi,
struct dwarf2_cu *cu)
{
- if (cu->language == language_cplus
+ if ((cu->language == language_cplus
+ || cu->language == language_java)
&& cu->has_namespace_info == 0
&& struct_pdi->has_children)
{
@@ -2474,7 +2480,8 @@ read_func_scope (struct die_info *die, s
if (name == NULL || !dwarf2_get_pc_bounds (die, &lowpc, &highpc, cu))
return;
- if (cu->language == language_cplus)
+ if (cu->language == language_cplus
+ || cu->language == language_java)
{
struct die_info *spec_die = die_specification (die, cu);
@@ -3272,10 +3279,13 @@ static int
is_vtable_name (const char *name, struct dwarf2_cu *cu)
{
static const char vptr[] = "_vptr";
+ static const char vtable[] = "vtable";
- /* C++ and some implementations of Java use this name. */
- if (strncmp (name, vptr, sizeof (vptr) - 1) == 0
- && is_cplus_marker (name[sizeof (vptr) - 1]))
+ /* Look for the C++ and Java forms of the vtable. */
+ if ((cu->language == language_java
+ && strncmp (name, vtable, sizeof (vtable) - 1) == 0)
+ || (strncmp (name, vptr, sizeof (vptr) - 1) == 0
+ && is_cplus_marker (name[sizeof (vptr) - 1])))
return 1;
return 0;
@@ -3316,7 +3326,8 @@ read_structure_type (struct die_info *di
attr = dwarf2_attr (die, DW_AT_name, cu);
if (attr && DW_STRING (attr))
{
- if (cu->language == language_cplus)
+ if (cu->language == language_cplus
+ || cu->language == language_java)
{
char *new_prefix = determine_class_name (die, cu);
TYPE_TAG_NAME (type) = obsavestring (new_prefix,
@@ -3518,11 +3529,9 @@ read_enumeration_type (struct die_info *
if (processing_has_namespace_info)
{
- TYPE_TAG_NAME (type) = obconcat (&objfile->objfile_obstack,
- processing_current_prefix,
- processing_current_prefix[0] == '\0'
- ? "" : "::",
- name);
+ TYPE_TAG_NAME (type) = typename_concat (&objfile->objfile_obstack,
+ processing_current_prefix,
+ name, cu);
}
else
{
@@ -3546,7 +3555,7 @@ read_enumeration_type (struct die_info *
}
/* Determine the name of the type represented by DIE, which should be
- a named C++ compound type. Return the name in question; the caller
+ a named C++ or Java compound type. Return the name in question; the caller
is responsible for xfree()'ing it. */
static char *
@@ -3593,8 +3602,9 @@ determine_class_name (struct die_info *d
if (new_prefix == NULL)
{
const char *name = dwarf2_name (die, cu);
- new_prefix = typename_concat (processing_current_prefix,
- name ? name : "<<anonymous>>");
+ new_prefix = typename_concat (NULL, processing_current_prefix,
+ name ? name : "<<anonymous>>",
+ cu);
}
if (back_to != NULL)
@@ -3861,6 +3871,7 @@ read_namespace (struct die_info *die, st
const char *name;
int is_anonymous;
struct die_info *current_die;
+ struct cleanup *back_to = make_cleanup (null_cleanup, 0);
name = namespace_name (die, &is_anonymous, cu);
@@ -3872,14 +3883,8 @@ read_namespace (struct die_info *die, st
}
else
{
- /* We need temp_name around because processing_current_prefix
- is a const char *. */
- char *temp_name = alloca (strlen (previous_prefix)
- + 2 + strlen(name) + 1);
- strcpy (temp_name, previous_prefix);
- strcat (temp_name, "::");
- strcat (temp_name, name);
-
+ char *temp_name = typename_concat (NULL, previous_prefix, name, cu);
+ make_cleanup (xfree, temp_name);
processing_current_prefix = temp_name;
}
@@ -3919,6 +3924,7 @@ read_namespace (struct die_info *die, st
}
processing_current_prefix = previous_prefix;
+ do_cleanups (back_to);
}
/* Return the name of the namespace represented by DIE. Set
@@ -4166,10 +4172,11 @@ read_subroutine_type (struct die_info *d
type = die_type (die, cu);
ftype = lookup_function_type (type);
- /* All functions in C++ have prototypes. */
+ /* All functions in C++ and Java have prototypes. */
attr = dwarf2_attr (die, DW_AT_prototyped, cu);
if ((attr && (DW_UNSND (attr) != 0))
- || cu->language == language_cplus)
+ || cu->language == language_cplus
+ || cu->language == language_java)
TYPE_FLAGS (ftype) |= TYPE_FLAG_PROTOTYPED;
if (die->child != NULL)
@@ -4820,7 +4827,8 @@ load_partial_dies (bfd *abfd, char *info
else if (building_psymtab)
add_psymbol_to_list (part_die->name, strlen (part_die->name),
VAR_DOMAIN, LOC_CONST,
- cu->language == language_cplus
+ (cu->language == language_cplus
+ || cu->language == language_java)
? &cu->objfile->global_psymbols
: &cu->objfile->static_psymbols,
0, (CORE_ADDR) 0, cu->language, cu->objfile);
@@ -6431,7 +6439,8 @@ new_symbol (struct die_info *die, struct
read_structure_type, and the correct name is saved in
the type. */
- if (cu->language == language_cplus)
+ if (cu->language == language_cplus
+ || cu->language == language_java)
{
struct type *type = SYMBOL_TYPE (sym);
@@ -6448,7 +6457,7 @@ new_symbol (struct die_info *die, struct
}
{
- /* NOTE: carlton/2003-11-10: C++ class symbols shouldn't
+ /* NOTE: carlton/2003-11-10: C++ and Java class symbols shouldn't
really ever be static objects: otherwise, if you try
to, say, break of a class's method and you're in a file
which doesn't mention that class, it won't work unless
@@ -6459,15 +6468,18 @@ new_symbol (struct die_info *die, struct
struct pending **list_to_add;
list_to_add = (cu->list_in_scope == &file_symbols
- && cu->language == language_cplus
+ && (cu->language == language_cplus
+ || cu->language == language_java)
? &global_symbols : cu->list_in_scope);
add_symbol_to_list (sym, list_to_add);
/* The semantics of C++ state that "struct foo { ... }" also
- defines a typedef for "foo". Synthesize a typedef symbol so
- that "ptype foo" works as expected. */
- if (cu->language == language_cplus)
+ defines a typedef for "foo". A Java class declaration also
+ defines a typedef for the class. Synthesize a typedef symbol
+ so that "ptype foo" works as expected. */
+ if (cu->language == language_cplus
+ || cu->language == language_java)
{
struct symbol *typedef_sym = (struct symbol *)
obstack_alloc (&objfile->objfile_obstack,
@@ -6487,10 +6499,9 @@ new_symbol (struct die_info *die, struct
if (processing_has_namespace_info
&& processing_current_prefix[0] != '\0')
{
- SYMBOL_LINKAGE_NAME (sym) = obconcat (&objfile->objfile_obstack,
- processing_current_prefix,
- "::",
- name);
+ SYMBOL_LINKAGE_NAME (sym) = typename_concat (&objfile->objfile_obstack,
+ processing_current_prefix,
+ name, cu);
}
SYMBOL_CLASS (sym) = LOC_TYPEDEF;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
@@ -6506,10 +6517,9 @@ new_symbol (struct die_info *die, struct
if (processing_has_namespace_info
&& processing_current_prefix[0] != '\0')
{
- SYMBOL_LINKAGE_NAME (sym) = obconcat (&objfile->objfile_obstack,
- processing_current_prefix,
- "::",
- name);
+ SYMBOL_LINKAGE_NAME (sym) = typename_concat (&objfile->objfile_obstack,
+ processing_current_prefix,
+ name, cu);
}
attr = dwarf2_attr (die, DW_AT_const_value, cu);
if (attr)
@@ -6523,7 +6533,8 @@ new_symbol (struct die_info *die, struct
struct pending **list_to_add;
list_to_add = (cu->list_in_scope == &file_symbols
- && cu->language == language_cplus
+ && (cu->language == language_cplus
+ || cu->language == language_java)
? &global_symbols : cu->list_in_scope);
add_symbol_to_list (sym, list_to_add);
@@ -6832,7 +6843,8 @@ determine_prefix (struct die_info *die,
{
struct die_info *parent;
- if (cu->language != language_cplus)
+ if (cu->language != language_cplus
+ && cu->language != language_java)
return NULL;
parent = die->parent;
@@ -6856,9 +6868,10 @@ determine_prefix (struct die_info *die,
{
int dummy;
char *parent_prefix = determine_prefix (parent, cu);
- char *retval = typename_concat (parent_prefix,
+ char *retval = typename_concat (NULL, parent_prefix,
namespace_name (parent, &dummy,
- cu));
+ cu),
+ cu);
xfree (parent_prefix);
return retval;
}
@@ -6891,25 +6904,47 @@ determine_prefix (struct die_info *die,
}
}
-/* Return a newly-allocated string formed by concatenating PREFIX,
- "::", and SUFFIX, except that if PREFIX is NULL or the empty
- string, just return a copy of SUFFIX. */
+/* Return a newly-allocated string formed by concatenating PREFIX and
+ SUFFIX with appropriate separator. If PREFIX or SUFFIX is NULL or empty, then
+ simply copy the SUFFIX or PREFIX, respectively. If OBS is non-null,
+ perform an obconcat, otherwise allocate storage for the result. The CU argument
+ is used to determine the language and hence, the appropriate separator. */
+
+#define MAX_SEP_LEN 2 /* sizeof ("::") */
static char *
-typename_concat (const char *prefix, const char *suffix)
+typename_concat (struct obstack *obs, const char *prefix, const char *suffix,
+ struct dwarf2_cu *cu)
{
- if (prefix == NULL || prefix[0] == '\0')
- return xstrdup (suffix);
- else
- {
- char *retval = xmalloc (strlen (prefix) + 2 + strlen (suffix) + 1);
+ char *sep;
- strcpy (retval, prefix);
- strcat (retval, "::");
- strcat (retval, suffix);
+ if (suffix == NULL || suffix[0] == '\0' || prefix == NULL || prefix[0] == '\0')
+ sep = "";
+ else if (cu->language == language_java)
+ sep = ".";
+ else
+ sep = "::";
+ if (obs == NULL)
+ {
+ char *retval = xmalloc (strlen (prefix) + MAX_SEP_LEN + strlen (suffix) + 1);
+ retval[0] = '\0';
+
+ if (prefix)
+ {
+ strcpy (retval, prefix);
+ strcat (retval, sep);
+ }
+ if (suffix)
+ strcat (retval, suffix);
+
return retval;
}
+ else
+ {
+ /* We have an obstack. */
+ return obconcat (obs, prefix, sep, suffix);
+ }
}
static struct type *
Index: jv-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/jv-exp.y,v
retrieving revision 1.18
diff -u -p -r1.18 jv-exp.y
--- jv-exp.y 23 Nov 2003 20:41:17 -0000 1.18
+++ jv-exp.y 15 Sep 2004 22:49:57 -0000
@@ -446,13 +446,22 @@ FieldAccess:
/*| SUPER '.' SimpleName { FIXME } */
;
+FuncStart:
+ Name '('
+ { push_expression_name ($1); }
+;
+
MethodInvocation:
- Name '(' ArgumentList_opt ')'
- { error (_("Method invocation not implemented")); }
+ FuncStart
+ { start_arglist(); }
+ ArgumentList_opt ')'
+ { write_exp_elt_opcode (OP_FUNCALL);
+ write_exp_elt_longcst ((LONGEST) end_arglist ());
+ write_exp_elt_opcode (OP_FUNCALL); }
| Primary '.' SimpleName '(' ArgumentList_opt ')'
- { error (_("Method invocation not implemented")); }
+ { error (_("Form of method invocation not implemented")); }
| SUPER '.' SimpleName '(' ArgumentList_opt ')'
- { error (_("Method invocation not implemented")); }
+ { error (_("Form of method invocation not implemented")); }
;
ArrayAccess:
Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.135
diff -u -p -r1.135 symtab.c
--- symtab.c 10 Aug 2004 21:16:13 -0000 1.135
+++ symtab.c 15 Sep 2004 22:49:57 -0000
@@ -1000,7 +1000,7 @@ lookup_symbol (const char *name, const s
modified_name = name;
- /* If we are using C++ language, demangle the name before doing a lookup, so
+ /* If we are using C++ or Java, demangle the name before doing a lookup, so
we can always binary search. */
if (current_language->la_language == language_cplus)
{
@@ -1012,6 +1012,17 @@ lookup_symbol (const char *name, const s
needtofreename = 1;
}
}
+ else if (current_language->la_language == language_java)
+ {
+ demangled_name = cplus_demangle (name,
+ DMGL_ANSI | DMGL_PARAMS | DMGL_JAVA);
+ if (demangled_name)
+ {
+ mangled_name = name;
+ modified_name = demangled_name;
+ needtofreename = 1;
+ }
+ }
if (case_sensitivity == case_sensitive_off)
{
Index: valarith.c
===================================================================
RCS file: /cvs/src/src/gdb/valarith.c,v
retrieving revision 1.23
diff -u -p -r1.23 valarith.c
--- valarith.c 27 Jun 2004 07:57:15 -0000 1.23
+++ valarith.c 15 Sep 2004 22:49:57 -0000
@@ -202,7 +202,10 @@ value_subscript (struct value *array, st
LONGEST index = value_as_long (idx);
if (index >= lowerbound && index <= upperbound)
return value_subscripted_rvalue (array, idx, lowerbound);
- warning ("array or string index out of range");
+ /* Emit warning unless we have an array of unknown size.
+ An array of unknown size has lowerbound 0 and upperbound -1. */
+ if (upperbound > -1)
+ warning ("array or string index out of range");
/* fall doing C stuff */
c_style = 1;
}
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [RFA]: Java Inferior Call Take 3
2004-09-15 22:58 ` Jeff Johnston
@ 2004-09-20 18:23 ` Jim Blandy
2004-09-20 20:19 ` Jeff Johnston
0 siblings, 1 reply; 36+ messages in thread
From: Jim Blandy @ 2004-09-20 18:23 UTC (permalink / raw)
To: Jeff Johnston; +Cc: gdb-patches
Jeff Johnston <jjohnstn@redhat.com> writes:
> Ok now?
>
> Retested on x86-linux with up to date compiler with needed gcj
> fixes.
Yep, looks great. Thanks!
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [RFA]: Java Inferior Call Take 3
2004-09-20 18:23 ` Jim Blandy
@ 2004-09-20 20:19 ` Jeff Johnston
0 siblings, 0 replies; 36+ messages in thread
From: Jeff Johnston @ 2004-09-20 20:19 UTC (permalink / raw)
To: Jim Blandy; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1876 bytes --]
Jim Blandy wrote:
> Jeff Johnston <jjohnstn@redhat.com> writes:
>
>>Ok now?
>>
>>Retested on x86-linux with up to date compiler with needed gcj
>>fixes.
>
>
> Yep, looks great. Thanks!
>
>
Thanks. With that, all parts have been approved and checked in. I have
included the final patches and ChangeLogs that were checked in.
-- Jeff J.
gdb/ChangeLog:
2004-09-20 Jeff Johnston <jjohnstn@redhat.com>
* dwarf2read.c (typename_concat): Change prototype to accept obstack
and dwarf2_cu struct pointer as arguments. Change function to use
obstack if provided and use dwarf2_cu to determine language-specific
separator.
(partial_die_parent_scope): Change comment to include java. Use
new version of typename_concat instead of obconcat.
(partial_die_full_name): Use typename_concat.
(read_namespace): Ditto.
(read_enumeration_type): Use typename_concat instead of obconcat.
(new_symbol): Ditto.
(add_partial_symbol): Enhance tests for C++ to also test for Java.
(guess_structure_name): Ditto.
(read_subroutine_type): Ditto.
(read_structure_type): Ditto.
(is_vtable_name): Add Java support.
(determine_class_name): Switch to new typename_concat call.
(determine_prefix): Switch to new typename_concat call.
* jv-exp.y (FuncStart): New pattern.
(MethodInvocation): Add support for simple function calls. Change
warning message for other forms of inferior call currently not
supported.
* valarith.c (value_subscript): Treat an array with upper-bound
of -1 as unknown size.
gdb/testsuite/ChangeLog:
2004-09-20 Jeff Johnston <jjohnstn@redhat.com>
* gdb.java/jprint.exp: New test case for java inferior call.
* gdb.java/jprint.java: Ditto.
[-- Attachment #2: java-call-final.patch --]
[-- Type: text/plain, Size: 16727 bytes --]
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.160
diff -u -p -r1.160 dwarf2read.c
--- dwarf2read.c 1 Sep 2004 04:19:21 -0000 1.160
+++ dwarf2read.c 20 Sep 2004 20:02:11 -0000
@@ -791,7 +791,8 @@ static void read_type_die (struct die_in
static char *determine_prefix (struct die_info *die, struct dwarf2_cu *);
-static char *typename_concat (const char *prefix, const char *suffix);
+static char *typename_concat (struct obstack *, const char *prefix, const char *suffix,
+ struct dwarf2_cu *);
static void read_typedef (struct die_info *, struct dwarf2_cu *);
@@ -1511,7 +1512,8 @@ scan_partial_symbols (struct partial_die
/* Functions used to compute the fully scoped name of a partial DIE.
Normally, this is simple. For C++, the parent DIE's fully scoped
- name is concatenated with "::" and the partial DIE's name.
+ name is concatenated with "::" and the partial DIE's name. For
+ Java, the same thing occurs except that "." is used instead of "::".
Enumerators are an exception; they use the scope of their parent
enumeration type, i.e. the name of the enumeration type is not
prepended to the enumerator.
@@ -1566,8 +1568,8 @@ partial_die_parent_scope (struct partial
if (grandparent_scope == NULL)
parent->scope = parent->name;
else
- parent->scope = obconcat (&cu->comp_unit_obstack, grandparent_scope,
- "::", parent->name);
+ parent->scope = typename_concat (&cu->comp_unit_obstack, grandparent_scope,
+ parent->name, cu);
}
else if (parent->tag == DW_TAG_enumeration_type)
/* Enumerators should not get the name of the enumeration as a prefix. */
@@ -1599,7 +1601,7 @@ partial_die_full_name (struct partial_di
if (parent_scope == NULL)
return NULL;
else
- return concat (parent_scope, "::", pdi->name, NULL);
+ return typename_concat (NULL, parent_scope, pdi->name, cu);
}
static void
@@ -1717,14 +1719,16 @@ add_partial_symbol (struct partial_die_i
return;
add_psymbol_to_list (actual_name, strlen (actual_name),
STRUCT_DOMAIN, LOC_TYPEDEF,
- cu->language == language_cplus
+ (cu->language == language_cplus
+ || cu->language == language_java)
? &objfile->global_psymbols
: &objfile->static_psymbols,
0, (CORE_ADDR) 0, cu->language, objfile);
- if (cu->language == language_cplus)
+ if (cu->language == language_cplus
+ || cu->language == language_java)
{
- /* For C++, these implicitly act as typedefs as well. */
+ /* For C++ and Java, these implicitly act as typedefs as well. */
add_psymbol_to_list (actual_name, strlen (actual_name),
VAR_DOMAIN, LOC_TYPEDEF,
&objfile->global_psymbols,
@@ -1734,7 +1738,8 @@ add_partial_symbol (struct partial_die_i
case DW_TAG_enumerator:
add_psymbol_to_list (actual_name, strlen (actual_name),
VAR_DOMAIN, LOC_CONST,
- cu->language == language_cplus
+ (cu->language == language_cplus
+ || cu->language == language_java)
? &objfile->global_psymbols
: &objfile->static_psymbols,
0, (CORE_ADDR) 0, cu->language, objfile);
@@ -1814,7 +1819,8 @@ static void
guess_structure_name (struct partial_die_info *struct_pdi,
struct dwarf2_cu *cu)
{
- if (cu->language == language_cplus
+ if ((cu->language == language_cplus
+ || cu->language == language_java)
&& cu->has_namespace_info == 0
&& struct_pdi->has_children)
{
@@ -2474,7 +2480,8 @@ read_func_scope (struct die_info *die, s
if (name == NULL || !dwarf2_get_pc_bounds (die, &lowpc, &highpc, cu))
return;
- if (cu->language == language_cplus)
+ if (cu->language == language_cplus
+ || cu->language == language_java)
{
struct die_info *spec_die = die_specification (die, cu);
@@ -3272,10 +3279,13 @@ static int
is_vtable_name (const char *name, struct dwarf2_cu *cu)
{
static const char vptr[] = "_vptr";
+ static const char vtable[] = "vtable";
- /* C++ and some implementations of Java use this name. */
- if (strncmp (name, vptr, sizeof (vptr) - 1) == 0
- && is_cplus_marker (name[sizeof (vptr) - 1]))
+ /* Look for the C++ and Java forms of the vtable. */
+ if ((cu->language == language_java
+ && strncmp (name, vtable, sizeof (vtable) - 1) == 0)
+ || (strncmp (name, vptr, sizeof (vptr) - 1) == 0
+ && is_cplus_marker (name[sizeof (vptr) - 1])))
return 1;
return 0;
@@ -3316,7 +3326,8 @@ read_structure_type (struct die_info *di
attr = dwarf2_attr (die, DW_AT_name, cu);
if (attr && DW_STRING (attr))
{
- if (cu->language == language_cplus)
+ if (cu->language == language_cplus
+ || cu->language == language_java)
{
char *new_prefix = determine_class_name (die, cu);
TYPE_TAG_NAME (type) = obsavestring (new_prefix,
@@ -3518,11 +3529,9 @@ read_enumeration_type (struct die_info *
if (processing_has_namespace_info)
{
- TYPE_TAG_NAME (type) = obconcat (&objfile->objfile_obstack,
- processing_current_prefix,
- processing_current_prefix[0] == '\0'
- ? "" : "::",
- name);
+ TYPE_TAG_NAME (type) = typename_concat (&objfile->objfile_obstack,
+ processing_current_prefix,
+ name, cu);
}
else
{
@@ -3546,7 +3555,7 @@ read_enumeration_type (struct die_info *
}
/* Determine the name of the type represented by DIE, which should be
- a named C++ compound type. Return the name in question; the caller
+ a named C++ or Java compound type. Return the name in question; the caller
is responsible for xfree()'ing it. */
static char *
@@ -3593,8 +3602,9 @@ determine_class_name (struct die_info *d
if (new_prefix == NULL)
{
const char *name = dwarf2_name (die, cu);
- new_prefix = typename_concat (processing_current_prefix,
- name ? name : "<<anonymous>>");
+ new_prefix = typename_concat (NULL, processing_current_prefix,
+ name ? name : "<<anonymous>>",
+ cu);
}
if (back_to != NULL)
@@ -3861,6 +3871,7 @@ read_namespace (struct die_info *die, st
const char *name;
int is_anonymous;
struct die_info *current_die;
+ struct cleanup *back_to = make_cleanup (null_cleanup, 0);
name = namespace_name (die, &is_anonymous, cu);
@@ -3872,14 +3883,8 @@ read_namespace (struct die_info *die, st
}
else
{
- /* We need temp_name around because processing_current_prefix
- is a const char *. */
- char *temp_name = alloca (strlen (previous_prefix)
- + 2 + strlen(name) + 1);
- strcpy (temp_name, previous_prefix);
- strcat (temp_name, "::");
- strcat (temp_name, name);
-
+ char *temp_name = typename_concat (NULL, previous_prefix, name, cu);
+ make_cleanup (xfree, temp_name);
processing_current_prefix = temp_name;
}
@@ -3919,6 +3924,7 @@ read_namespace (struct die_info *die, st
}
processing_current_prefix = previous_prefix;
+ do_cleanups (back_to);
}
/* Return the name of the namespace represented by DIE. Set
@@ -4166,10 +4172,11 @@ read_subroutine_type (struct die_info *d
type = die_type (die, cu);
ftype = lookup_function_type (type);
- /* All functions in C++ have prototypes. */
+ /* All functions in C++ and Java have prototypes. */
attr = dwarf2_attr (die, DW_AT_prototyped, cu);
if ((attr && (DW_UNSND (attr) != 0))
- || cu->language == language_cplus)
+ || cu->language == language_cplus
+ || cu->language == language_java)
TYPE_FLAGS (ftype) |= TYPE_FLAG_PROTOTYPED;
if (die->child != NULL)
@@ -4820,7 +4827,8 @@ load_partial_dies (bfd *abfd, char *info
else if (building_psymtab)
add_psymbol_to_list (part_die->name, strlen (part_die->name),
VAR_DOMAIN, LOC_CONST,
- cu->language == language_cplus
+ (cu->language == language_cplus
+ || cu->language == language_java)
? &cu->objfile->global_psymbols
: &cu->objfile->static_psymbols,
0, (CORE_ADDR) 0, cu->language, cu->objfile);
@@ -6431,7 +6439,8 @@ new_symbol (struct die_info *die, struct
read_structure_type, and the correct name is saved in
the type. */
- if (cu->language == language_cplus)
+ if (cu->language == language_cplus
+ || cu->language == language_java)
{
struct type *type = SYMBOL_TYPE (sym);
@@ -6448,7 +6457,7 @@ new_symbol (struct die_info *die, struct
}
{
- /* NOTE: carlton/2003-11-10: C++ class symbols shouldn't
+ /* NOTE: carlton/2003-11-10: C++ and Java class symbols shouldn't
really ever be static objects: otherwise, if you try
to, say, break of a class's method and you're in a file
which doesn't mention that class, it won't work unless
@@ -6459,15 +6468,18 @@ new_symbol (struct die_info *die, struct
struct pending **list_to_add;
list_to_add = (cu->list_in_scope == &file_symbols
- && cu->language == language_cplus
+ && (cu->language == language_cplus
+ || cu->language == language_java)
? &global_symbols : cu->list_in_scope);
add_symbol_to_list (sym, list_to_add);
/* The semantics of C++ state that "struct foo { ... }" also
- defines a typedef for "foo". Synthesize a typedef symbol so
- that "ptype foo" works as expected. */
- if (cu->language == language_cplus)
+ defines a typedef for "foo". A Java class declaration also
+ defines a typedef for the class. Synthesize a typedef symbol
+ so that "ptype foo" works as expected. */
+ if (cu->language == language_cplus
+ || cu->language == language_java)
{
struct symbol *typedef_sym = (struct symbol *)
obstack_alloc (&objfile->objfile_obstack,
@@ -6487,10 +6499,9 @@ new_symbol (struct die_info *die, struct
if (processing_has_namespace_info
&& processing_current_prefix[0] != '\0')
{
- SYMBOL_LINKAGE_NAME (sym) = obconcat (&objfile->objfile_obstack,
- processing_current_prefix,
- "::",
- name);
+ SYMBOL_LINKAGE_NAME (sym) = typename_concat (&objfile->objfile_obstack,
+ processing_current_prefix,
+ name, cu);
}
SYMBOL_CLASS (sym) = LOC_TYPEDEF;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
@@ -6506,10 +6517,9 @@ new_symbol (struct die_info *die, struct
if (processing_has_namespace_info
&& processing_current_prefix[0] != '\0')
{
- SYMBOL_LINKAGE_NAME (sym) = obconcat (&objfile->objfile_obstack,
- processing_current_prefix,
- "::",
- name);
+ SYMBOL_LINKAGE_NAME (sym) = typename_concat (&objfile->objfile_obstack,
+ processing_current_prefix,
+ name, cu);
}
attr = dwarf2_attr (die, DW_AT_const_value, cu);
if (attr)
@@ -6523,7 +6533,8 @@ new_symbol (struct die_info *die, struct
struct pending **list_to_add;
list_to_add = (cu->list_in_scope == &file_symbols
- && cu->language == language_cplus
+ && (cu->language == language_cplus
+ || cu->language == language_java)
? &global_symbols : cu->list_in_scope);
add_symbol_to_list (sym, list_to_add);
@@ -6832,7 +6843,8 @@ determine_prefix (struct die_info *die,
{
struct die_info *parent;
- if (cu->language != language_cplus)
+ if (cu->language != language_cplus
+ && cu->language != language_java)
return NULL;
parent = die->parent;
@@ -6856,9 +6868,10 @@ determine_prefix (struct die_info *die,
{
int dummy;
char *parent_prefix = determine_prefix (parent, cu);
- char *retval = typename_concat (parent_prefix,
+ char *retval = typename_concat (NULL, parent_prefix,
namespace_name (parent, &dummy,
- cu));
+ cu),
+ cu);
xfree (parent_prefix);
return retval;
}
@@ -6891,25 +6904,47 @@ determine_prefix (struct die_info *die,
}
}
-/* Return a newly-allocated string formed by concatenating PREFIX,
- "::", and SUFFIX, except that if PREFIX is NULL or the empty
- string, just return a copy of SUFFIX. */
+/* Return a newly-allocated string formed by concatenating PREFIX and
+ SUFFIX with appropriate separator. If PREFIX or SUFFIX is NULL or empty, then
+ simply copy the SUFFIX or PREFIX, respectively. If OBS is non-null,
+ perform an obconcat, otherwise allocate storage for the result. The CU argument
+ is used to determine the language and hence, the appropriate separator. */
+
+#define MAX_SEP_LEN 2 /* sizeof ("::") */
static char *
-typename_concat (const char *prefix, const char *suffix)
+typename_concat (struct obstack *obs, const char *prefix, const char *suffix,
+ struct dwarf2_cu *cu)
{
- if (prefix == NULL || prefix[0] == '\0')
- return xstrdup (suffix);
- else
- {
- char *retval = xmalloc (strlen (prefix) + 2 + strlen (suffix) + 1);
+ char *sep;
- strcpy (retval, prefix);
- strcat (retval, "::");
- strcat (retval, suffix);
+ if (suffix == NULL || suffix[0] == '\0' || prefix == NULL || prefix[0] == '\0')
+ sep = "";
+ else if (cu->language == language_java)
+ sep = ".";
+ else
+ sep = "::";
+ if (obs == NULL)
+ {
+ char *retval = xmalloc (strlen (prefix) + MAX_SEP_LEN + strlen (suffix) + 1);
+ retval[0] = '\0';
+
+ if (prefix)
+ {
+ strcpy (retval, prefix);
+ strcat (retval, sep);
+ }
+ if (suffix)
+ strcat (retval, suffix);
+
return retval;
}
+ else
+ {
+ /* We have an obstack. */
+ return obconcat (obs, prefix, sep, suffix);
+ }
}
static struct type *
Index: jv-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/jv-exp.y,v
retrieving revision 1.18
diff -u -p -r1.18 jv-exp.y
--- jv-exp.y 23 Nov 2003 20:41:17 -0000 1.18
+++ jv-exp.y 20 Sep 2004 20:02:11 -0000
@@ -446,13 +446,22 @@ FieldAccess:
/*| SUPER '.' SimpleName { FIXME } */
;
+FuncStart:
+ Name '('
+ { push_expression_name ($1); }
+;
+
MethodInvocation:
- Name '(' ArgumentList_opt ')'
- { error (_("Method invocation not implemented")); }
+ FuncStart
+ { start_arglist(); }
+ ArgumentList_opt ')'
+ { write_exp_elt_opcode (OP_FUNCALL);
+ write_exp_elt_longcst ((LONGEST) end_arglist ());
+ write_exp_elt_opcode (OP_FUNCALL); }
| Primary '.' SimpleName '(' ArgumentList_opt ')'
- { error (_("Method invocation not implemented")); }
+ { error (_("Form of method invocation not implemented")); }
| SUPER '.' SimpleName '(' ArgumentList_opt ')'
- { error (_("Method invocation not implemented")); }
+ { error (_("Form of method invocation not implemented")); }
;
ArrayAccess:
Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.138
diff -u -p -r1.138 symtab.c
--- symtab.c 20 Sep 2004 18:31:02 -0000 1.138
+++ symtab.c 20 Sep 2004 20:02:11 -0000
@@ -998,7 +998,7 @@ lookup_symbol (const char *name, const s
modified_name = name;
- /* If we are using C++ language, demangle the name before doing a lookup, so
+ /* If we are using C++ or Java, demangle the name before doing a lookup, so
we can always binary search. */
if (current_language->la_language == language_cplus)
{
@@ -1010,6 +1010,17 @@ lookup_symbol (const char *name, const s
needtofreename = 1;
}
}
+ else if (current_language->la_language == language_java)
+ {
+ demangled_name = cplus_demangle (name,
+ DMGL_ANSI | DMGL_PARAMS | DMGL_JAVA);
+ if (demangled_name)
+ {
+ mangled_name = name;
+ modified_name = demangled_name;
+ needtofreename = 1;
+ }
+ }
if (case_sensitivity == case_sensitive_off)
{
Index: valarith.c
===================================================================
RCS file: /cvs/src/src/gdb/valarith.c,v
retrieving revision 1.23
diff -u -p -r1.23 valarith.c
--- valarith.c 27 Jun 2004 07:57:15 -0000 1.23
+++ valarith.c 20 Sep 2004 20:02:11 -0000
@@ -202,7 +202,10 @@ value_subscript (struct value *array, st
LONGEST index = value_as_long (idx);
if (index >= lowerbound && index <= upperbound)
return value_subscripted_rvalue (array, idx, lowerbound);
- warning ("array or string index out of range");
+ /* Emit warning unless we have an array of unknown size.
+ An array of unknown size has lowerbound 0 and upperbound -1. */
+ if (upperbound > -1)
+ warning ("array or string index out of range");
/* fall doing C stuff */
c_style = 1;
}
[-- Attachment #3: java-call-test-final.patch --]
[-- Type: text/plain, Size: 4892 bytes --]
Index: gdb.java/jprint.exp
===================================================================
RCS file: gdb.java/jprint.exp
diff -N gdb.java/jprint.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gdb.java/jprint.exp 20 Sep 2004 20:03:02 -0000
@@ -0,0 +1,80 @@
+# Copyright 2004 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# This file was written by Jeff Johnston. (jjohnstn@redhat.com)
+#
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+load_lib "java.exp"
+
+set testfile "jprint"
+set srcfile ${srcdir}/$subdir/${testfile}.java
+set binfile ${objdir}/${subdir}/${testfile}
+if { [compile_java_from_source ${srcfile} ${binfile} "-g"] != "" } {
+ untested "Couldn't compile ${srcfile}"
+ return -1
+}
+
+# Set the current language to java. This counts as a test. If it
+# fails, then we skip the other tests.
+
+proc set_lang_java {} {
+ global gdb_prompt
+ global binfile objdir subdir
+
+ verbose "loading file '$binfile'"
+ gdb_load $binfile
+
+ send_gdb "set language java\n"
+ gdb_expect {
+ -re ".*$gdb_prompt $" {}
+ timeout { fail "set language java (timeout)" ; return 0 }
+ }
+
+ return [gdb_test "show language" ".* source language is \"java\".*" \
+ "set language to \"java\""]
+}
+
+set prms_id 0
+set bug_id 0
+
+# Start with a fresh gdb.
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+
+gdb_test "set print sevenbit-strings" ".*"
+
+if ![set_lang_java] then {
+ # Ref PR gdb:java/1565. Don't use the simpler "break jmisc.main".
+ # As of 2004-02-24 it wasn't working and is being tested separatly.
+ runto "\'${testfile}.main(java.lang.String\[\])\'"
+
+ gdb_test "p jvclass.addprint(4,5,6)" "sum is 15\r\n.*" "unambiguous static call"
+
+ gdb_test "next" ""
+ gdb_test "next" ""
+
+ gdb_test "p x.print(44)" "x is 44\r\n.*" "single argument print call"
+ gdb_test "p x.print(22,33)" "y is 33\r\n.*" "double argument print call"
+ gdb_test "call x.dothat(55)" "new value is 58\r\n.*= 62.*" "virtual fn call"
+ gdb_test "p x.addprint(1,2,3)" "sum is 6\r\n.*" "inherited static call"
+ gdb_test "call x.addk(44)" "adding k gives 121\r\n.*= 121.*" "inherited virtual fn call"
+}
Index: gdb.java/jprint.java
===================================================================
RCS file: gdb.java/jprint.java
diff -N gdb.java/jprint.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gdb.java/jprint.java 20 Sep 2004 20:03:02 -0000
@@ -0,0 +1,62 @@
+// jprint.java test program.
+//
+// Copyright 2004
+// Free Software Foundation, Inc.
+//
+// Written by Jeff Johnston <jjohnstn@redhat.com>
+// Contributed by Red Hat
+//
+// This file is part of GDB.
+//
+// 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
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+
+class jvclass {
+ public static int k;
+ static {
+ k = 77;
+ }
+ public static void addprint (int x, int y, int z) {
+ int sum = x + y + z;
+ System.out.println ("sum is " + sum);
+ }
+
+ public int addk (int x) {
+ int sum = x + k;
+ System.out.println ("adding k gives " + sum);
+ return sum;
+ }
+}
+
+public class jprint extends jvclass {
+ public int dothat (int x) {
+ int y = x + 3;
+ System.out.println ("new value is " + y);
+ return y + 4;
+ }
+ public static void print (int x) {
+ System.out.println("x is " + x);
+ }
+ public static void print (int x, int y) {
+ System.out.println("y is " + y);
+ }
+ public static void main(String[] args) {
+ jprint x = new jprint ();
+ x.print (44);
+ print (k, 33);
+ }
+}
+
+
^ permalink raw reply [flat|nested] 36+ messages in thread
end of thread, other threads:[~2004-09-20 20:19 UTC | newest]
Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-17 20:53 [RFA]: Java Inferior Call Take 2 Jeff Johnston
2004-06-11 17:49 ` Jeff Johnston
2004-06-17 3:06 ` Daniel Jacobowitz
2004-06-17 20:52 ` Jeff Johnston
2004-06-19 23:59 ` Daniel Jacobowitz
2004-06-21 10:49 ` Andrew Haley
2004-06-21 15:17 ` Andrew Haley
2004-06-23 11:06 ` Andrew Haley
2004-06-23 13:47 ` Daniel Jacobowitz
2004-06-23 16:06 ` Andrew Haley
2004-06-23 16:08 ` Daniel Jacobowitz
2004-06-23 21:55 ` Jeff Johnston
2004-06-23 23:01 ` Daniel Jacobowitz
2004-06-24 17:57 ` Tom Tromey
2004-07-06 21:47 ` Jeff Johnston
2004-07-26 19:49 ` Jeff Johnston
2004-07-26 19:51 ` Daniel Jacobowitz
2004-08-02 10:17 ` Andrew Haley
2004-08-02 15:17 ` Andrew Haley
2004-08-02 20:20 ` Daniel Jacobowitz
2004-08-03 18:45 ` Andrew Haley
2004-08-16 13:08 ` Andrew Haley
2004-08-16 13:18 ` Daniel Jacobowitz
2004-08-16 20:32 ` Daniel Jacobowitz
2004-08-16 20:35 ` Daniel Jacobowitz
2004-08-24 18:53 ` [RFA]: Java Inferior Call Take 3 Jeff Johnston
2004-08-24 19:05 ` Michael Chastain
2004-08-24 19:28 ` Jeff Johnston
2004-08-24 19:10 ` Michael Chastain
2004-08-24 19:48 ` Andrew Cagney
2004-09-01 4:51 ` Jim Blandy
2004-09-09 23:41 ` Jeff Johnston
2004-09-10 20:12 ` Jim Blandy
2004-09-15 22:58 ` Jeff Johnston
2004-09-20 18:23 ` Jim Blandy
2004-09-20 20:19 ` Jeff Johnston
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox