]> gcc.gnu.org Git - gcc.git/commitdiff
[multiple changes]
authorAndrew Haley <aph@gcc.gnu.org>
Mon, 10 Mar 2003 19:45:30 +0000 (19:45 +0000)
committerAndrew Haley <aph@gcc.gnu.org>
Mon, 10 Mar 2003 19:45:30 +0000 (19:45 +0000)
2003-03-10  2003-02-27  Mohan Embar  <gnustuff@thisiscool.com>

        * include/jvm.h: removed declaration of _Jv_ThisExecutable()
        setter; made return value of getter const char* instead of char*
        * prims.cc: removed all references to _Jv_ThisExecutable().
        These are in the platform-specific sections now.
        * posix.cc: define platform-specific _Jv_ThisExecutable().
        Handle DISABLE_MAIN_ARGS and HAVE_PROC_SELF_EXE cases
        * win32.cc: define platform-specific _Jv_ThisExecutable()
        using GetModuleFilename()
        * java/lang/natRuntime.cc: set gnu.gcj.progname property
        to argv[0] instead of _Jv_ThisExecutable()

2003-03-10  Ranjit Mathew  <rmathew@hotmail.com>

        * gnu/gcj/runtime/NameFinder.java (usingAddr2name): New flag
        that is set if we are using addr2name.awk instead of addr2line.
        (NameFinder): Set usingAddr2name if using addr2name.awk.
        (getExternalLabel): New native method to convert a method
        name to an external label.
        (lookup): Convert name given by addr2line to an external label
        before demangling.

        * gnu/gcj/runtime/natNameFinder.cc (LABEL_PREFIX): New string
        constant representing the prefix attached to method names to
        convert them to an external label.
        (gnu::gcj::runtime::NameFinder::getExternalLabel): Define
        using LABEL_PREFIX.

From-SVN: r64111

libjava/ChangeLog
libjava/gnu/gcj/runtime/NameFinder.java
libjava/gnu/gcj/runtime/natNameFinder.cc
libjava/include/jvm.h
libjava/java/lang/natRuntime.cc
libjava/posix.cc
libjava/prims.cc
libjava/win32.cc

index 9c02954e09dbdcc9e695eec00eaf417c1cfff43a..7fd8e12fa31ac1706c8a2f2acd72b46542e1487c 100644 (file)
@@ -1,3 +1,32 @@
+2003-03-10  2003-02-27  Mohan Embar  <gnustuff@thisiscool.com>
+
+       * include/jvm.h: removed declaration of _Jv_ThisExecutable()
+       setter; made return value of getter const char* instead of char*
+       * prims.cc: removed all references to _Jv_ThisExecutable().
+       These are in the platform-specific sections now.
+       * posix.cc: define platform-specific _Jv_ThisExecutable().
+       Handle DISABLE_MAIN_ARGS and HAVE_PROC_SELF_EXE cases
+       * win32.cc: define platform-specific _Jv_ThisExecutable()
+       using GetModuleFilename()
+       * java/lang/natRuntime.cc: set gnu.gcj.progname property
+       to argv[0] instead of _Jv_ThisExecutable()
+
+2003-03-10  Ranjit Mathew  <rmathew@hotmail.com>
+
+       * gnu/gcj/runtime/NameFinder.java (usingAddr2name): New flag
+       that is set if we are using addr2name.awk instead of addr2line.
+       (NameFinder): Set usingAddr2name if using addr2name.awk.
+       (getExternalLabel): New native method to convert a method 
+       name to an external label.
+       (lookup): Convert name given by addr2line to an external label
+       before demangling.
+
+       * gnu/gcj/runtime/natNameFinder.cc (LABEL_PREFIX): New string
+       constant representing the prefix attached to method names to
+       convert them to an external label.
+       (gnu::gcj::runtime::NameFinder::getExternalLabel): Define 
+       using LABEL_PREFIX.
+
 2003-03-10  Tom Tromey  <tromey@redhat.com>
 
        * Makefile.in: Rebuilt.
index 4089411e84b72e2519c7a52759acabee3548a006..19820c1bd6bb28e9284440ae498a42805d0bba9a 100644 (file)
@@ -102,6 +102,11 @@ public class NameFinder
   private BufferedWriter addr2lineOut;
   private BufferedReader addr2lineIn;
 
+  /**
+   * Flag set if using addr2name.awk instead of addr2line from binutils.
+   */
+  private boolean usingAddr2name = false;
+
   /**
    * Creates a new NameFinder. Call close to get rid of any resources
    * created while using the <code>lookup</code> methods.
@@ -142,6 +147,7 @@ public class NameFinder
              {
                String[] exec = new String[] {"addr2name.awk", executable};
                addr2line = runtime.exec(exec);
+               usingAddr2name = true;
              }
            catch (IOException ioe2) { addr2line = null; }
          }
@@ -180,6 +186,11 @@ public class NameFinder
    */
   native private String getAddrAsString(RawData addrs, int n);
 
+  /**
+   * Returns the label that is exported for the given method name.
+   */
+  native private String getExternalLabel(String name);
+
   /**
    * If nth element of stack is an interpreted frame, return the
    * element representing the method being interpreted.
@@ -212,6 +223,15 @@ public class NameFinder
                addr2lineOut.flush();
                name = addr2lineIn.readLine();
                file = addr2lineIn.readLine();
+
+                // addr2line uses symbolic debugging information instead
+                // of the actually exported labels as addr2name.awk does.
+                // This name might need some modification, depending on 
+                // the system, to make it a label like that returned 
+                // by addr2name.awk or dladdr.
+                if (! usingAddr2name)
+                  if (name != null && ! "??".equals (name))
+                    name = getExternalLabel (name);
              }
            catch (IOException ioe) { addr2line = null; }
          }
index 29687cb5bb9a377915dbc06eb23862384d1bb8ba..6605e38059110fc8cf32a17a630d4fcf07c608e3 100644 (file)
@@ -15,6 +15,8 @@ details.  */
 
 #include <config.h>
 
+#include <string.h>
+
 #include <gcj/cni.h>
 #include <jvm.h>
 #include <java/lang/String.h>
@@ -28,6 +30,37 @@ details.  */
 #include <dlfcn.h>
 #endif
 
+// On some systems, a prefix is attached to a method name before
+// it is exported as a label. The GCC preprocessor predefines 
+// this prefix as the macro __USER_LABEL_PREFIX__ which expands to
+// a string (not string constant) representing the prefix, if any.
+#undef LABEL_PREFIX
+#ifdef __USER_LABEL_PREFIX__
+
+#define USER_LABEL_PREFIX_STRING_0(s) #s
+#define USER_LABEL_PREFIX_STRING(s) USER_LABEL_PREFIX_STRING_0(s)
+
+#define LABEL_PREFIX USER_LABEL_PREFIX_STRING(__USER_LABEL_PREFIX__)
+
+#else /* __USER_LABEL_PREFIX__ */
+
+#define LABEL_PREFIX ""
+
+#endif /* ! __USER_LABEL_PREFIX__ */
+
+java::lang::String*
+gnu::gcj::runtime::NameFinder::getExternalLabel (java::lang::String* name)
+{
+  jsize nameLen = JvGetStringUTFLength (name);
+  jsize pfxLen = strlen (LABEL_PREFIX);
+  char *newName = (char *) JvMalloc (pfxLen + nameLen + 1);
+  *(newName + 0) = '\0';
+  strcpy (newName, LABEL_PREFIX);
+  JvGetStringUTFRegion (name, 0, nameLen, newName + pfxLen);
+  *(newName + pfxLen + nameLen) = '\0';
+  return JvNewStringLatin1 (newName);
+}
+
 java::lang::String*
 gnu::gcj::runtime::NameFinder::getExecutable (void)
 {
index 1e604980e0e6948af464da1e2bf08463b510fd1c..38f675a1fefec016d1f86f413bd208ecf8c9544c 100644 (file)
@@ -352,9 +352,8 @@ extern "C"
   jlong _Jv_remJ (jlong, jlong);
 }
 
-/* get/set the name of the running executable. */
-extern char *_Jv_ThisExecutable (void);
-extern void _Jv_ThisExecutable (const char *);
+/* Get the name of the running executable. */
+extern const char *_Jv_ThisExecutable (void);
 
 /* Return a pointer to a symbol in executable or loaded library.  */
 void *_Jv_FindSymbolInExecutable (const char *);
index dee95114538b556f21d8a70acd0c54005f78b6d2..237b0d1be4b7007d5991fc8ad6252004389078ce 100644 (file)
@@ -108,6 +108,10 @@ _Jv_SetDLLSearchPath (const char *)
 
 \f
 
+extern int _Jv_argc;
+extern const char **_Jv_argv;
+  // our process' command line arguments
+
 void
 java::lang::Runtime::exitInternal (jint status)
 {
@@ -582,7 +586,7 @@ java::lang::Runtime::insertSystemProperties (java::util::Properties *newprops)
     }
 
   // The name used to invoke this process (argv[0] in C).
-  SET ("gnu.gcj.progname", _Jv_ThisExecutable());
+  SET ("gnu.gcj.progname", _Jv_argv[0]);
 
   // Allow platform specific settings and overrides.
   _Jv_platform_initProperties (newprops);
index ebff1c9ec79606088e1ef2ebe246d27f32eb3e74..2f808334d7c8c237d98103d2e493ac2b854641b8 100644 (file)
@@ -25,6 +25,26 @@ details.  */
 extern "C" unsigned long long _clock (void);
 #endif
 
+// platform-specific executable name
+extern const char **_Jv_argv;
+
+#if defined(HAVE_PROC_SELF_EXE)
+static char exec_name[20];
+  // initialized in _Jv_platform_initialize()
+#endif
+
+const char *_Jv_ThisExecutable (void)
+{
+#if defined(DISABLE_MAIN_ARGS)
+  return "[Embedded App]";
+#elif defined(HAVE_PROC_SELF_EXE)
+  return exec_name;
+    // initialized in _Jv_platform_initialize()
+#else
+  return _Jv_argv[0];
+#endif
+}
+
 // gettimeofday implementation.
 jlong
 _Jv_platform_gettimeofday ()
@@ -62,6 +82,11 @@ _Jv_platform_initialize (void)
 #else
   signal (SIGPIPE, SIG_IGN);
 #endif
+
+#if defined (HAVE_PROC_SELF_EXE)
+  // Compute our executable name
+  sprintf (exec_name, "/proc/%d/exe", getpid ());
+#endif
 }
 
 // Set platform-specific System properties.
index 61c66540831d4564673e7cfb205c983fc8346cc3..dc05d4b96ffda60c11ae4d95db303e2c21f65d4a 100644 (file)
@@ -86,9 +86,6 @@ const char *_Jv_Jar_Class_Path;
 property_pair *_Jv_Environment_Properties;
 #endif
 
-// The name of this executable.
-static char *_Jv_execName;
-
 // Stash the argv pointer to benefit native libraries that need it.
 const char **_Jv_argv;
 int _Jv_argc;
@@ -707,22 +704,6 @@ static JArray<jstring> *arg_vec;
 // The primary thread.
 static java::lang::Thread *main_thread;
 
-char *
-_Jv_ThisExecutable (void)
-{
-  return _Jv_execName;
-}
-
-void
-_Jv_ThisExecutable (const char *name)
-{
-  if (name)
-    {
-      _Jv_execName = (char *) _Jv_Malloc (strlen (name) + 1);
-      strcpy (_Jv_execName, name);
-    }
-}
-
 #ifndef DISABLE_GETENV_PROPERTIES
 
 static char *
@@ -960,19 +941,6 @@ _Jv_RunMain (jclass klass, const char *name, int argc, const char **argv,
 
   java::lang::Runtime *runtime = NULL;
 
-
-#ifdef DISABLE_MAIN_ARGS
-  _Jv_ThisExecutable ("[Embedded App]");
-#else
-#ifdef HAVE_PROC_SELF_EXE
-  char exec_name[20];
-  sprintf (exec_name, "/proc/%d/exe", getpid ());
-  _Jv_ThisExecutable (exec_name);
-#else
-  _Jv_ThisExecutable (argv[0]);
-#endif /* HAVE_PROC_SELF_EXE */
-#endif /* DISABLE_MAIN_ARGS */
-
   try
     {
       // Set this very early so that it is seen when java.lang.System
index 59c3be244b6eda83f74539b11dfcd569d103260b..6fc2de08760c8bca5e023823852faed1d5791d32 100644 (file)
@@ -28,6 +28,15 @@ win32_exception_handler (LPEXCEPTION_POINTERS e)
     return EXCEPTION_CONTINUE_SEARCH;
 }
 
+// Platform-specific executable name
+static char exec_name[MAX_PATH];
+  // initialized in _Jv_platform_initialize()
+
+const char *_Jv_ThisExecutable (void)
+{
+  return exec_name;
+}
+
 // Platform-specific VM initialization.
 void
 _Jv_platform_initialize (void)
@@ -37,8 +46,12 @@ _Jv_platform_initialize (void)
   if (WSAStartup (MAKEWORD (1, 1), &data))
     MessageBox (NULL, "Error initialising winsock library.", "Error",
                MB_OK | MB_ICONEXCLAMATION);
+  
   // Install exception handler
   SetUnhandledExceptionFilter (win32_exception_handler);
+  
+  // Initialize our executable name
+  GetModuleFileName(NULL, exec_name, sizeof(exec_name));
 }
 
 // gettimeofday implementation.
This page took 0.122683 seconds and 5 git commands to generate.