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]

[gcjx] Patch: FYI: fix -g option


I'm checking this in on the gcjx branch.

Mark pointed out that gcjx doesn't follow the JDK when parsing the
'-g' option.  This fixes the parsing and the bytecode back end to
follow.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	* main.cc (argument_parser::parse_args): Fully handle -g.
	(argument_parser::parse_debug_option): New method.
	(argument_parser::help_options): Updated.
	* bytecode/classwriter.cc (write): Handle new debug flag.
	* bytecode/generate.cc (generate): Handle different debug flags.
	* compiler.cc (compiler): Updated.
	* compiler.hh (compiler::target_debug): Removed.
	(compiler::target_debug_source, compiler::target_debug_lines,
	compiler::target_debug_vars): New flags.

Index: main.cc
===================================================================
--- main.cc	(revision 108950)
+++ main.cc	(working copy)
@@ -1,6 +1,6 @@
 // Main program, at least for testing.
 
-// Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+// Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
 //
 // This file is part of GCC.
 //
@@ -239,22 +239,22 @@
        << std::endl
        << std::endl;
 
-    print ("-bootclasspath PATH", "set boot classpath", 3);
-    print ("-classpath PATH", "set user classpath (default '.')", 3);
-    print ("-IDIR", "append DIR to class path", 3);
+    print ("-bootclasspath PATH", "set boot classpath", 4);
+    print ("-classpath PATH", "set user classpath (default '.')", 4);
+    print ("-IDIR", "append DIR to class path", 4);
 
-    print ("-encoding NAME", "set source file encoding", 3);
-    print ("-tabs WIDTH", "set tab width (default 8)", 3);
-    print ("-d DIR", "set output directory", 3);
-    print ("-deprecation", "like -Wdeprecated (javac compatibility)", 3);
-    print ("-verbose", "be verbose", 3);
-    print ("-error", "treat all warnings as errors", 3);
-    print ("-pedantic", "be pedantically correct", 3);
-    print ("-source 1.[345]", "choose source code compatibility", 3);
-    print ("-target 1.[345]", "choose target VM compatibility", 3);
-    print ("-g", "generate debugging information", 3);
+    print ("-encoding NAME", "set source file encoding", 4);
+    print ("-tabs WIDTH", "set tab width (default 8)", 4);
+    print ("-d DIR", "set output directory", 4);
+    print ("-deprecation", "like -Wdeprecated (javac compatibility)", 4);
+    print ("-verbose", "be verbose", 4);
+    print ("-error", "treat all warnings as errors", 4);
+    print ("-pedantic", "be pedantically correct", 4);
+    print ("-source 1.[345]", "choose source code compatibility", 4);
+    print ("-target 1.[345]", "choose target VM compatibility", 4);
+    print ("-g[:lines,vars,source]", "generate debugging information", 4);
     if (concurrence::available ())
-      print ("-j N", "use N worker threads", 3);
+      print ("-j N", "use N worker threads", 4);
 
     os << std::endl;
 
@@ -392,6 +392,28 @@
 	% name;
   }
 
+  void
+  parse_debug_option (const std::string &value)
+  {
+    std::string::size_type start = 0;
+    while (start < value.length ())
+      {
+	std::string::size_type end = value.find (',', start);
+	if (end == std::string::npos)
+	  end = value.length ();
+	std::string option = value.substr (start, end - start);
+	if (option == "lines")
+	  comp->target_debug_lines = true;
+	else if (option == "vars")
+	  comp->target_debug_vars = true;
+	else if (option == "source")
+	  comp->target_debug_source = true;
+	else
+	  throw make_error ("unrecognized %<-g%> argument %1") % option;
+	start = end + 1;
+      }
+  }
+
   std::deque<std::string>
   parse_args ()
   {
@@ -447,14 +469,20 @@
 	  comp->warnings_are_errors = true;
         else if (arg == "-pedantic")
 	  comp->pedantic = true;
-	else if (arg.length () >= 2 && ! strncmp (arg.c_str (), "-g" , 2))
+	else if (arg == "-g:none")
 	  {
-	    // The real form is -g:none, or
-	    // -g:{lines,vars,source}.
-	    // Currently we don't differentiate this in the back end,
-	    // so we just handle all-or-nothing.
-	    comp->target_debug = (arg != "-g:none");
+	    comp->target_debug_source = false;
+	    comp->target_debug_lines = false;
+	    comp->target_debug_vars = false;
 	  }
+	else if (arg == "-g")
+	  {
+	    comp->target_debug_source = true;
+	    comp->target_debug_lines = true;
+	    comp->target_debug_vars = true;
+	  }
+	else if (arg.length () >= 2 && ! strncmp (arg.c_str (), "-g:" , 3))
+	  parse_debug_option (arg.substr (3));
         else if (arg == "-d")
 	  output = get_next_arg (it, arg);
 	else if (is_form_of (it, "-bootclasspath"))
Index: bytecode/generate.cc
===================================================================
--- bytecode/generate.cc	(revision 108950)
+++ bytecode/generate.cc	(working copy)
@@ -1,6 +1,6 @@
 // Bytecode generation.
 
-// Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+// Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
 //
 // This file is part of GCC.
 //
@@ -173,20 +173,17 @@
       cpool->add (hand.type);
     }
 
-  if (global->get_compiler ()->target_debug ())
-    {
-      if (line_count > 0)
-	attributes.push_back (new line_table_attribute (cpool, this));
+  if (global->get_compiler ()->target_debug_lines () && line_count > 0)
+    attributes.push_back (new line_table_attribute (cpool, this));
 
-      if (vars.update ())
-	{
-	  attributes.push_back (new local_variable_table_attribute (cpool,
-								    &vars,
-								    false));
-	  if (global->get_compiler ()->target_15 ()
-	      && vars.any_parameterized_p ())
-	    attributes.push_back (new local_variable_table_attribute (cpool, &vars, true));
-	}
+  if (global->get_compiler ()->target_debug_vars () && vars.update ())
+    {
+      attributes.push_back (new local_variable_table_attribute (cpool,
+								&vars,
+								false));
+      if (global->get_compiler ()->target_15 ()
+	  && vars.any_parameterized_p ())
+	attributes.push_back (new local_variable_table_attribute (cpool, &vars, true));
     }
 }
 
Index: bytecode/classwriter.cc
===================================================================
--- bytecode/classwriter.cc	(revision 108950)
+++ bytecode/classwriter.cc	(working copy)
@@ -1,6 +1,6 @@
 // Write a class file.
 
-// Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+// Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
 //
 // This file is part of GCC.
 //
@@ -229,7 +229,7 @@
 							sig));
     }
 
-  if (global->get_compiler ()->target_debug ())
+  if (global->get_compiler ()->target_debug_source ())
     {
       std::string filename
 	= the_class->get_compilation_unit ()->get_file_name ();
Index: compiler.cc
===================================================================
--- compiler.cc	(revision 108950)
+++ compiler.cc	(working copy)
@@ -1,6 +1,6 @@
 // A single compilation.
 
-// Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+// Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
 //
 // This file is part of GCC.
 //
@@ -142,7 +142,9 @@
     feature_varargs (false),
     feature_annotations (false),
     target_assert (true),
-    target_debug (false),
+    target_debug_source (true),
+    target_debug_lines (true),
+    target_debug_vars (false),
     target_15 (false),
     // For now this is the default.
     target_14 (true),
Index: compiler.hh
===================================================================
--- compiler.hh	(revision 108950)
+++ compiler.hh	(working copy)
@@ -1,6 +1,6 @@
 // A single compilation, perhaps of multiple files.
 
-// Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+// Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
 //
 // This file is part of GCC.
 //
@@ -306,7 +306,9 @@
 
   // These control aspects of code generation.
   compiler_flag target_assert;
-  compiler_flag target_debug;
+  compiler_flag target_debug_source;
+  compiler_flag target_debug_lines;
+  compiler_flag target_debug_vars;
 
   // Flags used only when compiling to bytecode.
   compiler_flag target_15;


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