public inbox for java-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Fix debugging info in .class file compilation
@ 2006-02-20 14:47 Andrew Haley
  0 siblings, 0 replies; only message in thread
From: Andrew Haley @ 2006-02-20 14:47 UTC (permalink / raw)
  To: java-patches, gcc-patches

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  <aph@redhat.com>

	* 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;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-02-20 14:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-20 14:47 Fix debugging info in .class file compilation Andrew Haley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).