Patch (Java): Remove Custom Encoding of Line Numbers for Function Decls Before Emitting Code

Ranjit Mathew rmathew@hotmail.com
Thu Dec 5 04:35:00 GMT 2002


Hi,

     The Java front-end uses a custom 16+16 bits encoding
scheme to remember the last and the first line,
respectively, of a function in a single 32-bit number.
(See DECL_SOURCE_LINE_MERGE, DECL_SOURCE_LINE_FIRST
and DECL_SOURCE_LINE_LAST in "gcc/java/parse.h".)

The problem is that this encoding is passed as is
to the back end - the stabs debug output generator
for example, emits this as a rather large line number
for the symbol representing the function. This
problem is made apparent when using a newer binutils
(2.13 or later) which complains that the 16-bit stabs
"description" field cannot hold this large value. See
the thread started by this message for more details
and the trail to this solution:

     http://gcc.gnu.org/ml/java/2002-11/msg00385.html

The following patch proposes to reset/sanitise
the line number before the function decl is passed
to the back end:

ChangeLog:

2002-12-05  Ranjit Mathew <rmathew@hotmail.com>
             Andrew Haley <aph@redhat.com>

     * parse.y (source_end_java_method): Remove custom
     encoding of line numbers for a function decl before
     passing it to the back end.

(Andrew was the one who suggested the specific patch and
that's why his name appears above.)
--------------------------- 8< ---------------------------
--- parse.y     Thu Dec  5 17:34:58 2002
+++ parse.y     Thu Dec  5 17:39:10 2002
@@ -7505,4 +7505,6 @@
        expand_function_end (input_filename, lineno, 0);

+      DECL_SOURCE_LINE (fndecl) = DECL_SOURCE_LINE_FIRST (fndecl);
+
        /* Run the optimizers and output assembler code for this function. */
        rest_of_compilation (fndecl);
--------------------------- 8< ---------------------------

Sincerely Yours,
Ranjit.

-- 
Ranjit Mathew          Email: rmathew AT hotmail DOT com

Bangalore, INDIA.      Web: http://ranjitmathew.tripod.com/





More information about the Java-patches mailing list