From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27736 invoked by alias); 1 Sep 2004 04:51:07 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 27710 invoked from network); 1 Sep 2004 04:51:05 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org with SMTP; 1 Sep 2004 04:51:05 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.10/8.12.10) with ESMTP id i814otS0019745 for ; Wed, 1 Sep 2004 00:51:00 -0400 Received: from zenia.home.redhat.com (porkchop.devel.redhat.com [172.16.58.2]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i814op331659; Wed, 1 Sep 2004 00:50:52 -0400 To: Jeff Johnston Cc: Daniel Jacobowitz , gdb-patches@sources.redhat.com Subject: Re: [RFA]: Java Inferior Call Take 3 References: <40A9264C.4060404@redhat.com> <20040617030603.GC23443@nevyn.them.org> <40D20494.2020608@redhat.com> <20040619235857.GA18759@nevyn.them.org> <16598.64375.217285.743094@cuddles.cambridge.redhat.com> <16601.25623.949217.642524@cuddles.cambridge.redhat.com> <20040623134742.GA24612@nevyn.them.org> <40D9FC3B.3030700@redhat.com> <20040623230138.GA6426@nevyn.them.org> <40EB1DDD.4070603@redhat.com> <20040816203502.GB14885@nevyn.them.org> <412B8EA3.3090406@redhat.com> From: Jim Blandy Date: Wed, 01 Sep 2004 04:51:00 -0000 In-Reply-To: <412B8EA3.3090406@redhat.com> Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2004-09/txt/msg00005.txt.bz2 Jeff Johnston writes: > Here is the revised patch. > > 2004-08-24 Jeff Johnston > > * 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 * 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;