re PR debug/43260 (Java static class members lack DWARF location info)
authorJakub Jelinek <jakub@redhat.com>
Tue, 25 May 2010 16:19:11 +0000 (18:19 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 25 May 2010 16:19:11 +0000 (18:19 +0200)
PR debug/43260
* java-tree.h (pending_static_fields): New extern declaration.
(java_write_globals): New prototype.
* lang.c (LANG_HOOKS_WRITE_GLOBALS): Define.
* decl.c (java_mark_class_local): When clearing DECL_EXTERNAL
of a static field push it into pending_static_fields vector.
* class.c (pending_static_fields): New variable.
(add_field): If static field is not DECL_EXTERNAL, push it into
pending_static_fields vector.
(java_write_globals): New function.

From-SVN: r159828

gcc/java/ChangeLog
gcc/java/class.c
gcc/java/decl.c
gcc/java/java-tree.h
gcc/java/lang.c

index b0382bb87316d34bc36d1760dcbe7a7026dc27a9..ce1a98b192e7646c00225843a0787a0a3d42dcda 100644 (file)
@@ -1,3 +1,16 @@
+2010-05-25  Jakub Jelinek  <jakub@redhat.com>
+
+       PR debug/43260
+       * java-tree.h (pending_static_fields): New extern declaration.
+       (java_write_globals): New prototype.
+       * lang.c (LANG_HOOKS_WRITE_GLOBALS): Define.
+       * decl.c (java_mark_class_local): When clearing DECL_EXTERNAL
+       of a static field push it into pending_static_fields vector.
+       * class.c (pending_static_fields): New variable.
+       (add_field): If static field is not DECL_EXTERNAL, push it into
+       pending_static_fields vector.
+       (java_write_globals): New function.
+
 2010-05-24  Nathan Froyd  <froydnj@codesourcery.com>
 
        * expr.c (quick_stack): Change type to a VEC.  Update comment.
index 83759a56becca595472de928ef1a9b2bbd955f81..919d698de0fa02386e82fc983d1370557ec95c93 100644 (file)
@@ -1,6 +1,6 @@
 /* Functions related to building classes and their related objects.
    Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+   2005, 2006, 2007, 2008, 2010 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -109,6 +109,10 @@ static GTY(()) VEC(tree,gc) *registered_class;
    currently being compiled.  */
 static GTY(()) tree this_classdollar;
 
+/* A list of static class fields.  This is to emit proper debug
+   info for them.  */
+VEC(tree,gc) *pending_static_fields;
+
 /* Return the node that most closely represents the class whose name
    is IDENT.  Start the search from NODE (followed by its siblings).
    Return NULL if an appropriate node does not exist.  */
@@ -873,6 +877,8 @@ add_field (tree klass, tree name, tree field_type, int flags)
       /* Considered external unless we are compiling it into this
         object file.  */
       DECL_EXTERNAL (field) = (is_compiled_class (klass) != 2);
+      if (!DECL_EXTERNAL (field))
+       VEC_safe_push (tree, gc, pending_static_fields, field);
     }
 
   return field;
@@ -3224,4 +3230,17 @@ in_same_package (tree name1, tree name2)
   return (pkg1 == pkg2);
 }
 
+/* lang_hooks.decls.final_write_globals: perform final processing on
+   global variables.  */
+
+void
+java_write_globals (void)
+{
+  tree *vec = VEC_address (tree, pending_static_fields);
+  int len = VEC_length (tree, pending_static_fields);
+  write_global_declarations ();
+  emit_debug_global_declarations (vec, len);
+  VEC_free (tree, gc, pending_static_fields);
+}
+
 #include "gt-java-class.h"
index 9cb3c75076e9280902751dc516a6751cc2e556eb..f78d68359eba1b7a242e6b680defaf89536b90fb 100644 (file)
@@ -2000,7 +2000,11 @@ java_mark_class_local (tree klass)
 
   for (t = TYPE_FIELDS (klass); t ; t = TREE_CHAIN (t))
     if (FIELD_STATIC (t))
-      java_mark_decl_local (t);
+      {
+       if (DECL_EXTERNAL (t))
+         VEC_safe_push (tree, gc, pending_static_fields, t);
+       java_mark_decl_local (t);
+      }
 
   for (t = TYPE_METHODS (klass); t ; t = TREE_CHAIN (t))
     if (!METHOD_ABSTRACT (t))
index fad667d5f4934021878aabd1483712c8eb7c570f..dc16eb2bc10064c051858232233d932372a5e31a 100644 (file)
@@ -1,7 +1,7 @@
 /* Definitions for parsing and type checking for the GNU compiler for
    the Java(TM) language.
    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+   2005, 2006, 2007, 2008, 2010 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -1231,6 +1231,10 @@ extern void rewrite_reflection_indexes (void *);
 
 int cxx_keyword_p (const char *name, int length);
 
+extern GTY(()) VEC(tree,gc) *pending_static_fields;
+
+extern void java_write_globals (void);   
+
 #define DECL_FINAL(DECL) DECL_LANG_FLAG_3 (DECL)
 
 /* Access flags etc for a method (a FUNCTION_DECL): */
index a85f68a3316419cba11a4b0b80b92877bfb84099..c55b5e0510f355068a256d152ab2d98931eafc2b 100644 (file)
@@ -1,6 +1,6 @@
 /* Java(TM) language-specific utility routines.
    Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+   2005, 2006, 2007, 2008, 2010 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -136,6 +136,8 @@ struct GTY(()) language_function {
 #define LANG_HOOKS_DECL_PRINTABLE_NAME lang_printable_name
 #undef LANG_HOOKS_PRINT_ERROR_FUNCTION
 #define LANG_HOOKS_PRINT_ERROR_FUNCTION        java_print_error_function
+#undef LANG_HOOKS_WRITE_GLOBALS
+#define LANG_HOOKS_WRITE_GLOBALS java_write_globals
 
 #undef LANG_HOOKS_TYPE_FOR_MODE
 #define LANG_HOOKS_TYPE_FOR_MODE java_type_for_mode