From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13783 invoked by alias); 9 Feb 2013 00:38:27 -0000 Received: (qmail 13637 invoked by uid 22791); 9 Feb 2013 00:38:26 -0000 X-SWARE-Spam-Status: No, hits=-5.3 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,TW_GC X-Spam-Check-By: sourceware.org Received: from mail-ie0-f178.google.com (HELO mail-ie0-f178.google.com) (209.85.223.178) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 09 Feb 2013 00:38:19 +0000 Received: by mail-ie0-f178.google.com with SMTP id c13so5669591ieb.37 for ; Fri, 08 Feb 2013 16:38:19 -0800 (PST) X-Received: by 10.43.7.7 with SMTP id om7mr12330628icb.25.1360370298900; Fri, 08 Feb 2013 16:38:18 -0800 (PST) Received: from dl.caveonetworks.com (64.2.3.195.ptr.us.xo.net. [64.2.3.195]) by mx.google.com with ESMTPS id fb10sm17779421igb.1.2013.02.08.16.38.17 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 08 Feb 2013 16:38:18 -0800 (PST) Message-ID: <51159A78.9030204@gmail.com> Date: Sat, 09 Feb 2013 00:38:00 -0000 From: David Daney User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Tom Tromey , Michael Haupt CC: java@gcc.gnu.org Subject: Re: gcj and debugging References: <87y5f0ufko.fsf@fleche.redhat.com> In-Reply-To: <87y5f0ufko.fsf@fleche.redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact java-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: java-owner@gcc.gnu.org X-SW-Source: 2013-02/txt/msg00004.txt.bz2 On 02/07/2013 10:47 AM, Tom Tromey wrote: >>>>>> "Michael" == Michael Haupt writes: > > Michael> in a research project, I'm generating DWARF debugging info for machine > Michael> code generated from Java. I looked at some of the DWARF debug info > Michael> generated by gcj (including that contained in libgcj.so). > > I think the first thing to realize is that the gdb support for Java was > all written to target gcj specifically, and also written long ago and > then barely updated. > > It isn't very general or done the way it would be done now. > It was never updated for the gcj binary compatibility ABI. > > Michael> Java arrays are all merely declared in the DWARF; structural > Michael> information about Java array objects is not given. In libgcj's > Michael> array.h, there are two classes, __JArray and JArray (inheriting > Michael> from __Jarray), that hold a length field and, in addition, a T* > Michael> array[0]. > > Michael> The debug info for libgcj does not contain any structural information > Michael> about these two classes. > > Michael> How does gdb determine that there is a length field, and how many > Michael> elements there are if the length is assigned dynamically? I reckon the > Michael> latter can be done by describing the length as a DWARF exprloc, but > Michael> the description is nowhere to be found. > > I thought things like "print array[0]" used to work, but even that seems > to fail for me now. There is definitely some code for this in gdb, see > jv-valprint.c:java_value_print. It seems to know a bit about array > layout and then goes from there (though the code looks somewhat bogus to > me...). See also jv-lang.c:evaluate_subexp_java for the code that tries > to do array subscripting. > > Without debugging more I couldn't say why it is broken. > > Michael> How does the DWARF description of a Java array look? > Michael> Is this generated at run-time somehow? > Michael> Do gcj-generated binaries and gdb interact in some other ways than > Michael> through DWARF when it comes to meta-info exchange? > > I believe gdb can also read some of the gcj runtime metadata and > construct type information from this. The code here seems pretty > minimal though. > > Michael> Likewise, how does gdb know how to display a java.lang.String as a, > Michael> well, string? > > gdb has special code for this. It looks for a type named > "java.lang.String" and then knows what fields it has. > Yes. IIRC, from gdb you have to do: call degug_???? The exact names of the debug helpers escape me at the moment. David Daney > Yucky. > > Nowadays I'd be more tempted to implement string-printing using Python. > _Jv_Utf8Const could be handled this way too. > > Tom > >