src/os/linux/vm/os_linux.cpp

Print this page
rev 2110 : [mq]: is-debugger-present


2196   if (buflen < MAXPATHLEN) {
2197     assert(false, "must use a large-enough buffer");
2198     buf[0] = '\0';
2199     return;
2200   }
2201   // Lazy resolve the path to current module.
2202   if (saved_jvm_path[0] != 0) {
2203     strcpy(buf, saved_jvm_path);
2204     return;
2205   }
2206 
2207   char dli_fname[MAXPATHLEN];
2208   bool ret = dll_address_to_library_name(
2209                 CAST_FROM_FN_PTR(address, os::jvm_path),
2210                 dli_fname, sizeof(dli_fname), NULL);
2211   assert(ret != 0, "cannot locate libjvm");
2212   char *rp = realpath(dli_fname, buf);
2213   if (rp == NULL)
2214     return;
2215 
2216   if (strcmp(Arguments::sun_java_launcher(), "gamma") == 0) {
2217     // Support for the gamma launcher.  Typical value for buf is
2218     // "<JAVA_HOME>/jre/lib/<arch>/<vmtype>/libjvm.so".  If "/jre/lib/" appears at
2219     // the right place in the string, then assume we are installed in a JDK and
2220     // we're done.  Otherwise, check for a JAVA_HOME environment variable and fix
2221     // up the path so it looks like libjvm.so is installed there (append a
2222     // fake suffix hotspot/libjvm.so).
2223     const char *p = buf + strlen(buf) - 1;
2224     for (int count = 0; p > buf && count < 5; ++count) {
2225       for (--p; p > buf && *p != '/'; --p)
2226         /* empty */ ;
2227     }
2228 
2229     if (strncmp(p, "/jre/lib/", 9) != 0) {
2230       // Look for JAVA_HOME in the environment.
2231       char* java_home_var = ::getenv("JAVA_HOME");
2232       if (java_home_var != NULL && java_home_var[0] != 0) {
2233         char* jrelib_p;
2234         int len;
2235 
2236         // Check the current module name "libjvm.so" or "libjvm_g.so".




2196   if (buflen < MAXPATHLEN) {
2197     assert(false, "must use a large-enough buffer");
2198     buf[0] = '\0';
2199     return;
2200   }
2201   // Lazy resolve the path to current module.
2202   if (saved_jvm_path[0] != 0) {
2203     strcpy(buf, saved_jvm_path);
2204     return;
2205   }
2206 
2207   char dli_fname[MAXPATHLEN];
2208   bool ret = dll_address_to_library_name(
2209                 CAST_FROM_FN_PTR(address, os::jvm_path),
2210                 dli_fname, sizeof(dli_fname), NULL);
2211   assert(ret != 0, "cannot locate libjvm");
2212   char *rp = realpath(dli_fname, buf);
2213   if (rp == NULL)
2214     return;
2215 
2216   if (Arguments::created_by_gamma_launcher()) {
2217     // Support for the gamma launcher.  Typical value for buf is
2218     // "<JAVA_HOME>/jre/lib/<arch>/<vmtype>/libjvm.so".  If "/jre/lib/" appears at
2219     // the right place in the string, then assume we are installed in a JDK and
2220     // we're done.  Otherwise, check for a JAVA_HOME environment variable and fix
2221     // up the path so it looks like libjvm.so is installed there (append a
2222     // fake suffix hotspot/libjvm.so).
2223     const char *p = buf + strlen(buf) - 1;
2224     for (int count = 0; p > buf && count < 5; ++count) {
2225       for (--p; p > buf && *p != '/'; --p)
2226         /* empty */ ;
2227     }
2228 
2229     if (strncmp(p, "/jre/lib/", 9) != 0) {
2230       // Look for JAVA_HOME in the environment.
2231       char* java_home_var = ::getenv("JAVA_HOME");
2232       if (java_home_var != NULL && java_home_var[0] != 0) {
2233         char* jrelib_p;
2234         int len;
2235 
2236         // Check the current module name "libjvm.so" or "libjvm_g.so".