This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: make gcj -v print class path
- To: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Subject: Patch: make gcj -v print class path
- From: Tom Tromey <tromey at redhat dot com>
- Date: 16 Aug 2001 12:31:31 -0600
- Cc: Java Patch List <java-patches at gcc dot gnu dot org>
- Reply-To: tromey at redhat dot com
Right now there is no way to get gcj to print the class path it is
using. This is sometimes useful for debugging; the C and C++
compilers do it when `-v' is given. This patch adds this capability
to gcj.
Ok?
I tested this on x86 Red Hat Linux 6.2.
Tom
Index: java/ChangeLog
from Tom Tromey <tromey@redhat.com>
* jcf-dump.c (main): Updated for change to jcf_path_seal.
* gjavah.c (main): Updated for change to jcf_path_seal.
* lang.c (version_flag): New global.
(java_decode_option): Recognize `-version'.
(java_init): Update for change to jcf_path_seal.
* jcf.h (jcf_path_seal): Added `print' argument.
* jcf-path.c (jcf_path_seal): Added `print' argument.
Index: java/gjavah.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/gjavah.c,v
retrieving revision 1.70
diff -u -r1.70 gjavah.c
--- java/gjavah.c 2001/03/23 05:16:13 1.70
+++ java/gjavah.c 2001/08/16 17:53:37
@@ -1,7 +1,7 @@
/* Program to write C++-suitable header files from a Java(TM) .class
file. This is similar to SUN's javah.
-Copyright (C) 1996, 1998, 1999, 2000 Free Software Foundation, Inc.
+Copyright (C) 1996, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -2171,7 +2171,7 @@
usage ();
}
- jcf_path_seal ();
+ jcf_path_seal (verbose);
if (output_file && emit_dependencies)
{
Index: java/jcf-dump.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-dump.c,v
retrieving revision 1.36
diff -u -r1.36 jcf-dump.c
--- java/jcf-dump.c 2001/01/12 17:28:23 1.36
+++ java/jcf-dump.c 2001/08/16 17:53:38
@@ -1,7 +1,7 @@
/* Program to dump out a Java(TM) .class file.
Functionally similar to Sun's javap.
- Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -902,7 +902,7 @@
usage ();
}
- jcf_path_seal ();
+ jcf_path_seal (verbose);
if (flag_print_main)
{
Index: java/jcf-path.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-path.c,v
retrieving revision 1.16
diff -u -r1.16 jcf-path.c
--- java/jcf-path.c 2000/12/10 05:32:49 1.16
+++ java/jcf-path.c 2001/08/16 17:53:38
@@ -1,6 +1,6 @@
/* Handle CLASSPATH, -classpath, and path searching.
- Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -311,9 +311,11 @@
}
/* We `seal' the path by linking everything into one big list. Then
- we provide a way to iterate through the sealed list. */
+ we provide a way to iterate through the sealed list. If PRINT is
+ true then we print the final class path to stderr. */
void
-jcf_path_seal ()
+jcf_path_seal (print)
+ int print;
{
int do_system = 1;
struct entry *secondary;
@@ -351,6 +353,21 @@
}
else
free_entry (&sys_dirs);
+
+ if (print)
+ {
+ struct entry *ent;
+ fprintf (stderr, "Class path starts here:\n");
+ for (ent = sealed; ent; ent = ent->next)
+ {
+ fprintf (stderr, " %s", ent->name);
+ if ((ent->flags & FLAG_SYSTEM))
+ fprintf (stderr, " (system)");
+ if ((ent->flags & FLAG_ZIP))
+ fprintf (stderr, " (zip)");
+ fprintf (stderr, "\n");
+ }
+ }
}
void *
Index: java/jcf.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf.h,v
retrieving revision 1.24
diff -u -r1.24 jcf.h
--- java/jcf.h 2001/07/05 22:33:44 1.24
+++ java/jcf.h 2001/08/16 17:53:39
@@ -1,6 +1,6 @@
/* Utility macros to read Java(TM) .class files and byte codes.
- Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -273,7 +273,7 @@
extern void jcf_path_classpath_arg PARAMS ((const char *));
extern void jcf_path_CLASSPATH_arg PARAMS ((const char *));
extern void jcf_path_include_arg PARAMS ((const char *));
-extern void jcf_path_seal PARAMS ((void));
+extern void jcf_path_seal PARAMS ((int));
extern void *jcf_path_start PARAMS ((void));
extern void *jcf_path_next PARAMS ((void *));
extern char *jcf_path_name PARAMS ((void *));
Index: java/lang.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/lang.c,v
retrieving revision 1.68
diff -u -r1.68 lang.c
--- java/lang.c 2001/08/09 04:19:12 1.68
+++ java/lang.c 2001/08/16 17:53:39
@@ -150,6 +150,9 @@
be tested alone, use STATIC_CLASS_INITIALIZATION_OPTIMIZATION_P instead. */
int flag_optimize_sci = 1;
+/* When non zero, print extra version information. */
+static int version_flag = 0;
+
/* Table of language-dependent -f options.
STRING is the option name. VARIABLE is the address of the variable.
ON_VALUE is the value to store in VARIABLE
@@ -236,6 +239,13 @@
{
char *p = argv[0];
+ if (strcmp (p, "-version") == 0)
+ {
+ version_flag = 1;
+ /* We return 0 so that the caller can process this. */
+ return 0;
+ }
+
#define CLARG "-fassume-compiled="
if (strncmp (p, CLARG, sizeof (CLARG) - 1) == 0)
{
@@ -655,7 +665,7 @@
#endif
jcf_path_init ();
- jcf_path_seal ();
+ jcf_path_seal (version_flag);
decl_printable_name = lang_printable_name;
print_error_function = lang_print_error;