Patch: FYI: gcj-dbtool -p

Tom Tromey tromey@redhat.com
Fri Mar 11 19:33:00 GMT 2005


I'm checking this in on the trunk and the 4.0 branch.

This sets the default .db file for libgcj, and it arranges to build
and install an empty .db (for native builds).  This also adds a '-p'
option to gcj-dbtool.  This option can be used to find the name of the
built-in database.

Tom

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

	* gnu/gcj/tools/gcj_dbtool/Main.java (main): Handle '-p'.
	(usage): Document '-p'.
	* Makefile.in: Rebuilt.
	* Makefile.am (dbexecdir): New variable.
	(db_name): Likewise.
	(dbexec_DATA): Likewise.
	($(db_name)): New target.
	(AM_CXXFLAGS): Define LIBGCJ_DEFAULT_DATABASE.
	* java/lang/natRuntime.cc (insertSystemProperties): Set default
	system database.

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

	* gcj.texi (Invoking gcj-dbtool): Document 'gcj-dbtool -p'.
	(libgcj Runtime Properties): Document the default .db.

Index: gcc/java/gcj.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/gcj.texi,v
retrieving revision 1.73.2.1
diff -u -r1.73.2.1 gcj.texi
--- gcc/java/gcj.texi 7 Mar 2005 20:20:44 -0000 1.73.2.1
+++ gcc/java/gcj.texi 11 Mar 2005 16:50:14 -0000
@@ -991,7 +991,7 @@
 gcj-dbtool @option{OPTION} @var{DBFILE} [@option{MORE}] @dots{}
 
 gcj-dbtool [@option{-n}] [@option{-a}] [@option{-f}]
-  [@option{-t}] [@option{-l}]
+  [@option{-t}] [@option{-l}] [@option{-p}]
   [@option{-v}] [@option{--version}] [@option{--help}]
 
 @c man end
@@ -1043,6 +1043,10 @@
 @item -l @var{DBFILE}
 List the contents of a database.
 
+@item -p
+Print the name of the default database.  If there is no default
+database, this prints a blank line.
+
 @item --help
 Print a help message, then exit.
 
@@ -2531,7 +2535,8 @@
 This is a sequence of file names, each referring to a file created by
 @command{gcj-dbtool}.  These files will be used by @code{libgcj} to
 find shared libraries corresponding to classes that are loaded from
-bytecode.
+bytecode.  @code{libgcj} often has a built-in default database; it
+can be queried using @code{gcj-dbtool -p}.
 
 @end table
 
Index: libjava/Makefile.am
===================================================================
RCS file: /cvs/gcc/gcc/libjava/Makefile.am,v
retrieving revision 1.455.2.2
diff -u -r1.455.2.2 Makefile.am
--- libjava/Makefile.am 6 Mar 2005 20:15:21 -0000 1.455.2.2
+++ libjava/Makefile.am 11 Mar 2005 16:50:22 -0000
@@ -123,9 +123,18 @@
 ## Where to install default logging property file.
 propdir = $(libdir)
 
+## Where the standard .db file is found.
+dbexecdir = $(libdir)/gcj-@gcc_version@
+## Name of the default .db.
+db_name = classmap.db
+
 ## For now, only on native systems.  FIXME.
 if NATIVE
 bin_PROGRAMS = jv-convert gij grmic grmiregistry gcj-dbtool
+
+## It is convenient to actually build and install the default database
+## when gcj-dbtool is available.
+dbexec_DATA = $(db_name)
 endif
 
 bin_SCRIPTS = addr2name.awk
@@ -171,7 +180,8 @@
 	-DPREFIX="\"$(prefix)\"" \
 	-DLIBDIR="\"$(libdir)\"" \
 	-DBOOT_CLASS_PATH="\"$(jardir)/$(jar_DATA)\"" \
-	-DJAVA_EXT_DIRS="\"$(jardir)/ext\""
+	-DJAVA_EXT_DIRS="\"$(jardir)/ext\"" \
+	-DLIBGCJ_DEFAULT_DATABASE="\"$(dbexecdir)/$(db_name)\""
 
 AM_GCJFLAGS = \
 	@LIBGCJ_JAVAFLAGS@ \
@@ -250,6 +260,17 @@
 	$(libgcj_la_LIBADD)
 libgcj_la_LINK = $(LIBLINK)
 
+
+## The .db file.  This rule is only used for native builds, so it is
+## safe to invoke gcj-dbtool.
+$(db_name): gcj-dbtool
+## In case it exists already.
+	@rm -f $(db_name)
+## We don't actually care if it fails -- if it does, just make an
+## empty file.  This is simpler than trying to discover when mmap is
+## not available.
+	./gcj-dbtool -n $(db_name) || touch $(db_name)
+
 # Gtk/Cairo JNI sources.
 if GTK_CAIRO
 gtk_cairo_c_source_files = \
Index: libjava/gnu/gcj/tools/gcj_dbtool/Main.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/gcj/tools/gcj_dbtool/Main.java,v
retrieving revision 1.5.2.1
diff -u -r1.5.2.1 Main.java
--- libjava/gnu/gcj/tools/gcj_dbtool/Main.java 7 Mar 2005 20:20:52 -0000 1.5.2.1
+++ libjava/gnu/gcj/tools/gcj_dbtool/Main.java 11 Mar 2005 16:50:29 -0000
@@ -256,7 +256,16 @@
 	  }	    
 	return;
       }
-    
+
+    if (s[0].equals("-p"))
+      {
+	insist (s.length == 1);
+	String result = System.getProperty("gnu.gcj.precompiled.db.path",
+					   "");
+	System.out.println (result);
+	return;
+      }
+
     usage(System.err);
     System.exit(1);	    
   }
@@ -284,6 +293,7 @@
        + "    gcj-dbtool -t file.gcjdb            - Test a gcj map database\n"
        + "    gcj-dbtool -l file.gcjdb            - List a gcj map database\n"
        + "    gcj-dbtool -m dest.gcjdb [source.gcjdb]...\n"
+       + "    gcj-dbtool -p                       - Print default database name\n"
        + "             - Merge gcj map databases into dest\n"
        + "               Replaces dest\n"
        + "               To add to dest, include dest in the list of sources");
Index: libjava/java/lang/natRuntime.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/natRuntime.cc,v
retrieving revision 1.47.2.1
diff -u -r1.47.2.1 natRuntime.cc
--- libjava/java/lang/natRuntime.cc 9 Mar 2005 20:59:04 -0000 1.47.2.1
+++ libjava/java/lang/natRuntime.cc 11 Mar 2005 16:50:30 -0000
@@ -553,6 +553,9 @@
   // The path to libgcj's boot classes
   SET ("sun.boot.class.path", BOOT_CLASS_PATH);
 
+  // If there is a default system database, set it.
+  SET ("gnu.gcj.precompiled.db.path", LIBGCJ_DEFAULT_DATABASE);
+
   // Set some properties according to whatever was compiled in with
   // `-D'.  Important: after this point, the only properties that
   // should be set are those which either the user cannot meaningfully



More information about the Java-patches mailing list