From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29970 invoked by alias); 20 Feb 2006 14:47:03 -0000 Received: (qmail 29954 invoked by uid 22791); 20 Feb 2006 14:47:03 -0000 X-Spam-Check-By: sourceware.org Received: from mta08-winn.ispmail.ntl.com (HELO mta08-winn.ispmail.ntl.com) (81.103.221.48) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 20 Feb 2006 14:47:02 +0000 Received: from aamta10-winn.ispmail.ntl.com ([81.103.221.35]) by mta08-winn.ispmail.ntl.com with ESMTP id <20060220144659.TSUG29066.mta08-winn.ispmail.ntl.com@aamta10-winn.ispmail.ntl.com>; Mon, 20 Feb 2006 14:46:59 +0000 Received: from zapata.pink ([82.16.12.164]) by aamta10-winn.ispmail.ntl.com with ESMTP id <20060220144659.IEOW6973.aamta10-winn.ispmail.ntl.com@zapata.pink>; Mon, 20 Feb 2006 14:46:59 +0000 Received: from zapata.pink (localhost.localdomain [127.0.0.1]) by zapata.pink (8.13.1/8.13.1) with ESMTP id k1KEmn3P011373; Mon, 20 Feb 2006 14:48:50 GMT Received: (from aph@localhost) by zapata.pink (8.13.1/8.13.1/Submit) id k1KEmn2A011370; Mon, 20 Feb 2006 14:48:49 GMT MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <17401.54993.460309.919785@zapata.pink> Date: Mon, 20 Feb 2006 14:47:00 -0000 From: Andrew Haley To: java-patches@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: Fix debugging info in .class file compilation X-IsSubscribed: yes Mailing-List: contact java-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: java-patches-owner@gcc.gnu.org X-SW-Source: 2006-q1/txt/msg00227.txt.bz2 This is a rather odd bug that leads to strange behviour when debugging compiled .class files with gdb. Without this patch, a trivial program like this: public class tt { static final private void poo(int n) { System.out.println (n); } static public final void main (String[] argv) { poo(); } } gets you a gdb session like this: -------------------------------------------------------------------------------------- (gdb) b tt.main Breakpoint 1 at 0x400c0a: file java/io/OutputStream.java, line 9. (gdb) r Breakpoint 1, _ZN2tt4mainEJvP6JArrayIPN4java4lang6StringEE (argv=@2aaab00a4f70) at java/io/OutputStream.java:9 9 java/io/OutputStream.java: No such file or directory. in java/io/OutputStream.java -------------------------------------------------------------------------------------- The line number is right, but the filename isn't. It turns out that there is a trivial fix for this: at the start of every method set the input_location from the class currently being compiled, rather than from file_start_location. file_start_location is the most recent file we parsed, not necessarily the file we're emitting code for. This results in: -------------------------------------------------------------------------------------- (gdb) b tt.main Breakpoint 1 at 0x400c04: file tt.java, line 8. (gdb) r Breakpoint 1, _ZN2tt4mainEJvP6JArrayIPN4java4lang6StringEE (argv=@2aaab00a4f70) at tt.java:8 8 { -------------------------------------------------------------------------------------- Andrew. 2006-02-20 Andrew Haley * jcf-parse.c (parse_class_file): Set input_location from current_class. =================================================================== --- jcf-parse.c (revision 111299) +++ jcf-parse.c (working copy) @@ -898,7 +898,7 @@ continue; } - input_location = file_start_location; + input_location = DECL_SOURCE_LOCATION (TYPE_NAME (current_class)); if (DECL_LINENUMBERS_OFFSET (method)) { int i;