From: Jim Blandy <jimb@redhat.com>
To: Jeff Johnston <jjohnstn@redhat.com>
Cc: Daniel Jacobowitz <drow@false.org>, gdb-patches@sources.redhat.com
Subject: Re: [RFA]: Java Inferior Call Take 3
Date: Wed, 01 Sep 2004 04:51:00 -0000 [thread overview]
Message-ID: <vt2r7pm3844.fsf@zenia.home> (raw)
In-Reply-To: <412B8EA3.3090406@redhat.com>
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;
next prev parent reply other threads:[~2004-09-01 4:51 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=vt2r7pm3844.fsf@zenia.home \
--to=jimb@redhat.com \
--cc=drow@false.org \
--cc=gdb-patches@sources.redhat.com \
--cc=jjohnstn@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox