This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java 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]

[tree-ssa] fix java debug line numbers


Problem 1: It was possible for the DECL_SOURCE_LINE_MERGE hack to 
escape.  Looking at .debug_line dumps for the Array_1 test case,
many line numbers were >64k.

Fixed by using the existing DECL_FUNCTION_LAST_LINE during parsing;
which at the moment was completely unused for unknown reasons.
Then initializing cfun->function_end_locus once we've got enough
stuff setup that we can think about calling allocate_struct_function.

Problem 2: Most code actually got associated with the end-of-class
line number.  

Fixed by not applying EXPR_WITH_FILE_LOCATION to just the first
contained statement, but to all contained statements.  This required
some minor surgery in gimplify_expr to make sure we didn't try to
apply WFL to *more* than the contained statements.

Problem 3: Prologue code (e.g. class init) associated with the
end-of-class line.

Fixed by setting input_location to DECL_SOURCE_LOCATION at the
beginning of gimplify_body.


I'm having issues with the version of dejagnu installed on the
machine and the gdb testsuite; about half the testsuite runs,
and then I get some tcl error and it stops.  Dunno how much in
the way of java testing there is in there anyway...

Committed in the meantime, since it does mean that it might now
be possible to debug some of the other java testsuite failures.



r~


        * gimplify.c (gimplify_body): Save and restore input_location;
        initialize input_location to DECL_SOURCE_LOCATION.
        (gimplify_expr): Always save and restore input_location.
java/
        * decl.c (finish_method): Set cfun->function_end_locus.
        * java-gimplify.c (java_gimplify_expr): Set input_location
        for EXPR_WITH_FILE_LOCATION.  Use annotate_all_with_locus.
        * parse.h (DECL_SOURCE_LINE_MERGE): Remove.
        (DECL_SOURCE_LINE_FIRST, DECL_SOURCE_LINE_LAST): Remove.
        * parse.y (missing_return_error): Use DECL_FUNCTION_LAST_LINE.
        (finish_method_declaration): Likewise.
        (start_artificial_method_body): Likewise.
        (lookup_cl): Use DECL_SOURCE_LINE.
        (start_complete_expand_method): Likewise.
        (java_complete_lhs): Fix IS_EXPR_CODE_CLASS check.

Index: gimplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/gimplify.c,v
retrieving revision 1.1.2.93
diff -u -p -r1.1.2.93 gimplify.c
--- gimplify.c	14 Oct 2003 00:12:58 -0000	1.1.2.93
+++ gimplify.c	14 Oct 2003 07:07:36 -0000
@@ -256,12 +256,14 @@ gimplify_body (tree *body_p, tree fndecl
   location_t saved_location = input_location;
 
   timevar_push (TV_TREE_GIMPLIFY);
-
   push_gimplify_context ();
 
   /* Unshare most shared trees in the body.  */
   unshare_all_trees (*body_p);
 
+  /* Make sure input_location isn't set to something wierd.  */
+  input_location = DECL_SOURCE_LOCATION (fndecl);
+
   /* Gimplify the function's body.  */
   done = gimplify_stmt (body_p);
 
@@ -271,19 +273,17 @@ gimplify_body (tree *body_p, tree fndecl
   /* If there isn't an outer BIND_EXPR, add one.  */
   if (TREE_CODE (*body_p) != BIND_EXPR)
     {
-      *body_p = build (BIND_EXPR, void_type_node, NULL_TREE, *body_p, NULL_TREE);
+      *body_p = build (BIND_EXPR, void_type_node, NULL_TREE,
+		       *body_p, NULL_TREE);
       TREE_SIDE_EFFECTS (*body_p) = 1;
-      input_location = DECL_SOURCE_LOCATION (fndecl);
     }
-  else
-    input_location = saved_location;
 
   /* Declare the new temporary variables.  */
   declare_tmp_vars (gimplify_ctxp->temps, *body_p);
 
   pop_gimplify_context ();
-
   timevar_pop (TV_TREE_GIMPLIFY);
+  input_location = saved_location;
 
   return done;
 }
@@ -355,13 +355,10 @@ gimplify_expr (tree *expr_p, tree *pre_p
   if (post_p == NULL)
     post_p = &internal_post;
 
+  saved_location = input_location;
   locus = EXPR_LOCUS (*expr_p);
-
   if (locus)
-    {
-      saved_location = input_location;
-      input_location = *locus;
-    }
+    input_location = *locus;
 
   /* Loop over the specific gimplifiers until the toplevel node remains the
      same.  */
@@ -768,10 +765,7 @@ gimplify_expr (tree *expr_p, tree *pre_p
     }
 
  out:
-
-  if (locus)
-    input_location = saved_location;
-
+  input_location = saved_location;
   return 1;
 }
 
Index: java/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/decl.c,v
retrieving revision 1.128.2.27
diff -u -p -r1.128.2.27 decl.c
--- java/decl.c	14 Oct 2003 00:13:00 -0000	1.128.2.27
+++ java/decl.c	14 Oct 2003 07:07:38 -0000
@@ -1862,8 +1862,16 @@ finish_method (tree fndecl)
   /* Convert function tree to GENERIC prior to inlining.  */
   java_genericize (fndecl);
 
-  /* In unit-at-a-time mode, defer inlining, expansion to the
-     cgraph optimizers.  */
+  /* Store the end of the function, so that we get good line number
+     info for the epilogue.  */
+  if (DECL_SAVED_INSNS (fndecl))
+    cfun = DECL_SAVED_INSNS (fndecl);
+  else
+    allocate_struct_function (fndecl);
+  cfun->function_end_locus.file = DECL_SOURCE_FILE (fndecl);
+  cfun->function_end_locus.line = DECL_FUNCTION_LAST_LINE (fndecl);
+
+  /* Defer inlining and expansion to the cgraph optimizers.  */
   cgraph_finalize_function (fndecl, false);
 }
 
Index: java/java-gimplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/java-gimplify.c,v
retrieving revision 1.1.2.5
diff -u -p -r1.1.2.5 java-gimplify.c
--- java/java-gimplify.c	8 Oct 2003 14:31:49 -0000	1.1.2.5
+++ java/java-gimplify.c	14 Oct 2003 07:07:38 -0000
@@ -70,12 +70,10 @@ java_gimplify_expr (tree *expr_p, tree *
       return 1;
 
     case EXPR_WITH_FILE_LOCATION:
-      {
-	tree wfl = *expr_p;
-	*expr_p = EXPR_WFL_NODE (wfl);
-	annotate_with_file_line (*expr_p, EXPR_WFL_FILENAME (wfl),
-				 EXPR_WFL_LINENO (wfl));
-      }
+      input_location.file = EXPR_WFL_FILENAME (*expr_p);
+      input_location.line = EXPR_WFL_LINENO (*expr_p);
+      *expr_p = EXPR_WFL_NODE (*expr_p);
+      annotate_all_with_locus (expr_p, input_location);
       return 1;
 
     case CASE_EXPR:
Index: java/parse.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.h,v
retrieving revision 1.84.2.7
diff -u -p -r1.84.2.7 parse.h
--- java/parse.h	3 Oct 2003 06:16:03 -0000	1.84.2.7
+++ java/parse.h	14 Oct 2003 07:07:39 -0000
@@ -610,14 +610,6 @@ typedef struct jdeplist_s jdeplist;
 #define GET_CURRENT_BLOCK(F) ((F) ? DECL_FUNCTION_BODY ((F)) :	\
 			     current_static_block)
 
-/* Merge an other line to the source line number of a decl. Used to
-   remember function's end. */
-#define DECL_SOURCE_LINE_MERGE(DECL,NO) DECL_SOURCE_LINE(DECL) |= (NO << 16)
-
-/* Retrieve those two info separately. */
-#define DECL_SOURCE_LINE_FIRST(DECL)    (DECL_SOURCE_LINE(DECL) & 0x0000ffff)
-#define DECL_SOURCE_LINE_LAST(DECL)     (DECL_SOURCE_LINE(DECL) >> 16)
-
 /* Retrieve line/column from a WFL. */
 #define EXPR_WFL_GET_LINECOL(V,LINE,COL)	\
   {						\
Index: java/parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.387.2.36
diff -u -p -r1.387.2.36 parse.y
--- java/parse.y	12 Oct 2003 19:43:38 -0000	1.387.2.36
+++ java/parse.y	14 Oct 2003 07:07:51 -0000
@@ -3135,7 +3135,7 @@ find_expr_with_wfl (tree node)
 static void
 missing_return_error (tree method)
 {
-  EXPR_WFL_SET_LINECOL (wfl_operator, DECL_SOURCE_LINE_LAST (method), -2);
+  EXPR_WFL_SET_LINECOL (wfl_operator, DECL_FUNCTION_LAST_LINE (method), -2);
   parse_error_context (wfl_operator, "Missing return statement");
 }
 
@@ -4766,7 +4766,7 @@ finish_method_declaration (tree method_b
   /* Merge last line of the function with first line, directly in the
      function decl. It will be used to emit correct debug info. */
   if (!flag_emit_xref)
-    DECL_SOURCE_LINE_MERGE (current_function_decl, ctxp->last_ccb_indent1);
+    DECL_FUNCTION_LAST_LINE (current_function_decl) = ctxp->last_ccb_indent1;
 
   /* Since function's argument's list are shared, reset the
      ARG_FINAL_P parameter that might have been set on some of this
@@ -6715,7 +6715,7 @@ lookup_cl (tree decl)
     }
 
   EXPR_WFL_FILENAME_NODE (cl_v) = get_identifier (DECL_SOURCE_FILE (decl));
-  EXPR_WFL_SET_LINECOL (cl_v, DECL_SOURCE_LINE_FIRST (decl), -1);
+  EXPR_WFL_SET_LINECOL (cl_v, DECL_SOURCE_LINE (decl), -1);
 
   line = java_get_line_col (EXPR_WFL_FILENAME (cl_v),
 			    EXPR_WFL_LINENO (cl_v), EXPR_WFL_COLNO (cl_v));
@@ -7424,7 +7424,7 @@ static void
 start_artificial_method_body (tree mdecl)
 {
   DECL_SOURCE_LINE (mdecl) = 1;
-  DECL_SOURCE_LINE_MERGE (mdecl, 1);
+  DECL_FUNCTION_LAST_LINE (mdecl) = 1;
   source_start_java_method (mdecl);
   enter_block ();
 }
@@ -7966,7 +7966,7 @@ start_complete_expand_method (tree mdecl
       TREE_CHAIN (tem) = next;
     }
   pushdecl_force_head (DECL_ARGUMENTS (mdecl));
-  input_line = DECL_SOURCE_LINE_FIRST (mdecl);
+  input_line = DECL_SOURCE_LINE (mdecl);
   build_result_decl (mdecl);
 }
 
@@ -11995,7 +11995,7 @@ java_complete_lhs (tree node)
 	    arguments = TREE_VALUE (TREE_OPERAND (node, 1));
 	  else
 	    arguments = NULL_TREE;
-	  if (IS_EXPR_CODE_CLASS (node))
+	  if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (node))))
 	    check_thrown_exceptions (EXPR_WFL_LINECOL (node), decl,
 				     arguments);
 	  /* If we call this(...), register signature and positions */


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