This is the mail archive of the gdb-prs@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: java/1413: gdb loses java type information


The following reply was made to PR java/1413; it has been noted by GNATS.

From: David Carlton <carlton@kealia.com>
To: GNATS Filer <gdb-gnats@sources.redhat.com>
Cc:  
Subject: Re: java/1413: gdb loses java type information
Date: Thu, 09 Oct 2003 08:51:10 -0700

 On 9 Oct 2003 14:58:01 -0000, Andrew Cagney <ac131313@redhat.com> said:
  
 >  2. Must GDB obey language rules?
 >  For the function:
 >    public static Object doit(Object x)
 >     {
 >       Object y = x;
 >       return y;
 >     }
 >  must GDB follow language rules when evaluating expressions.
  
 >  This, I think, is Tom's concern and the answer is no, GDB does not need 
 >  to obey language rules.
 
 A very good point.
  
 >  The user should expect a debugger, such as GDB, to provide ways of 
 >  getting under the hood (bonnet in some countries) and examine/manipulate 
 >  the underlying data.  To that end, if GDB can determine an objects 
 >  underlying type, I see no reason for not allowing the operations that 
 >  apply to that type.
 
 That could cause problems in C++ (and, I think, in Java).  For
 example, if we're trying to call f->foo( x ), where f has static type
 A and dynamic type B, then if both A and B have members named foo, but
 B has more of them than A does, then an unambiguous call can turn into
 an ambiguous call (or into a call that is still unambiguous but means
 something different from what the language rules tell us).
 
 If you're doing a lot of operations on the same object, then something
 that should work (I think I've done this when debugging C++, if it
 doesn't work for Java then it's a GDB bug) is to do
 
 (gdb) p (Foo) y
 $1 = (y of type Foo)
 
 and then refer to $1 in subsequent expressions.  The output of "p
 (Foo) y" may look just like the output of "p y", but I think that GDB
 will treat the former as having static type Foo in subsequent
 expressions.
 
 Having said that, I'm sympathetic to Tom's concerns.  (Especially
 given that dynamic casting is more much frequent in Java than in C++.)
 It would be nice if we could find a happy medium, and, as Andrew
 points out, it's fine if GDB is more generous than the language
 requires, but it's a bit delicate.


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