hotspot/src/jdk.hotspot.agent/solaris/native/libsaproc/saproc.cpp
changeset 42035 10e6e31dc1aa
parent 35217 ce4b5303a813
--- a/hotspot/src/jdk.hotspot.agent/solaris/native/libsaproc/saproc.cpp	Fri Oct 21 10:27:32 2016 +0200
+++ b/hotspot/src/jdk.hotspot.agent/solaris/native/libsaproc/saproc.cpp	Fri Oct 21 12:30:12 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,9 +24,6 @@
 
 #include "salibproc.h"
 #include "sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal.h"
-#ifndef SOLARIS_11_B159_OR_LATER
-#include <sys/utsname.h>
-#endif
 #include <thread_db.h>
 #include <strings.h>
 #include <limits.h>
@@ -45,20 +42,6 @@
 
 // debug modes
 static int _libsaproc_debug = 0;
-#ifndef SOLARIS_11_B159_OR_LATER
-static bool _Pstack_iter_debug = false;
-
-static void dprintf_2(const char* format,...) {
-  if (_Pstack_iter_debug) {
-    va_list alist;
-
-    va_start(alist, format);
-    fputs("Pstack_iter DEBUG: ", stderr);
-    vfprintf(stderr, format, alist);
-    va_end(alist);
-  }
-}
-#endif // !SOLARIS_11_B159_OR_LATER
 
 static void print_debug(const char* format,...) {
   if (_libsaproc_debug) {
@@ -757,7 +740,8 @@
 #endif
 
   // connect to process/core
-  struct ps_prochandle* ph = proc_arg_grab(cmdLine_cstr, (isProcess? PR_ARG_PIDS : PR_ARG_CORES), PGRAB_FORCE, &gcode);
+  ps_prochandle_t* ph = proc_arg_grab(cmdLine_cstr, (isProcess? PR_ARG_PIDS : PR_ARG_CORES), PGRAB_FORCE, &gcode, NULL);
+
   env->ReleaseStringUTFChars(cmdLine, cmdLine_cstr);
   if (! ph) {
      if (gcode > 0 && gcode < sizeof(proc_arg_grab_errmsgs)/sizeof(const char*)) {
@@ -997,11 +981,6 @@
                    TD_THR_ANY_STATE, TD_THR_LOWEST_PRIORITY, TD_SIGNO_MASK, TD_THR_ANY_USER_FLAGS);
 }
 
-#ifndef SOLARIS_11_B159_OR_LATER
-// building on Nevada-B158 or earlier so more hoops to jump through
-static bool has_newer_Pstack_iter = false;  // older version by default
-#endif
-
 /*
  * Class:       sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal
  * Method:      fillCFrameList0
@@ -1030,23 +1009,8 @@
   env->ReleaseLongArrayElements(regsArray, ptr, JNI_ABORT);
   CHECK_EXCEPTION_(0);
 
-#ifdef SOLARIS_11_B159_OR_LATER
-  // building on Nevada-B159 or later so use the new callback
   Pstack_iter((struct ps_prochandle*) p_ps_prochandle, gregs,
               wrapper_fill_cframe_list, &dbgo2);
-#else
-  // building on Nevada-B158 or earlier so figure out which callback to use
-
-  if (has_newer_Pstack_iter) {
-    // Since we're building on Nevada-B158 or earlier, we have to
-    // cast wrapper_fill_cframe_list to make the compiler happy.
-    Pstack_iter((struct ps_prochandle*) p_ps_prochandle, gregs,
-                (proc_stack_f *)wrapper_fill_cframe_list, &dbgo2);
-  } else {
-    Pstack_iter((struct ps_prochandle*) p_ps_prochandle, gregs,
-                fill_cframe_list, &dbgo2);
-  }
-#endif // SOLARIS_11_B159_OR_LATER
   return dbgo2.obj;
 }
 
@@ -1236,7 +1200,8 @@
    char nameBuf[SYMBOL_BUF_SIZE + 1];
    GElf_Sym sym;
    int res = Plookup_by_addr((struct ps_prochandle*) p_ps_prochandle, (uintptr_t) address,
-                                 nameBuf, sizeof(nameBuf), &sym);
+                             nameBuf, sizeof(nameBuf), &sym, NULL);
+
    if (res != 0) { // failed
       return 0;
    }
@@ -1268,102 +1233,6 @@
   return res;
 }
 
-#ifndef SOLARIS_11_B159_OR_LATER
-// Determine if the OS we're running on has the newer version
-// of libproc's Pstack_iter.
-//
-// Set env var PSTACK_ITER_DEBUG=true to debug this logic.
-// Set env var PSTACK_ITER_DEBUG_RELEASE to simulate a 'release' value.
-// Set env var PSTACK_ITER_DEBUG_VERSION to simulate a 'version' value.
-//
-// frankenputer 'uname -r -v': 5.10 Generic_141445-09
-// jurassic 'uname -r -v':     5.11 snv_164
-// lonepeak 'uname -r -v':     5.11 snv_127
-//
-static void set_has_newer_Pstack_iter(JNIEnv *env) {
-  static bool done_set = false;
-
-  if (done_set) {
-    // already set has_newer_Pstack_iter
-    return;
-  }
-
-  struct utsname name;
-  if (uname(&name) == -1) {
-    THROW_NEW_DEBUGGER_EXCEPTION("uname() failed!");
-  }
-  dprintf_2("release='%s'  version='%s'\n", name.release, name.version);
-
-  if (_Pstack_iter_debug) {
-    char *override = getenv("PSTACK_ITER_DEBUG_RELEASE");
-    if (override != NULL) {
-      strncpy(name.release, override, SYS_NMLN - 1);
-      name.release[SYS_NMLN - 2] = '\0';
-      dprintf_2("overriding with release='%s'\n", name.release);
-    }
-    override = getenv("PSTACK_ITER_DEBUG_VERSION");
-    if (override != NULL) {
-      strncpy(name.version, override, SYS_NMLN - 1);
-      name.version[SYS_NMLN - 2] = '\0';
-      dprintf_2("overriding with version='%s'\n", name.version);
-    }
-  }
-
-  // the major number corresponds to the old SunOS major number
-  int major = atoi(name.release);
-  if (major >= 6) {
-    dprintf_2("release is SunOS 6 or later\n");
-    has_newer_Pstack_iter = true;
-    done_set = true;
-    return;
-  }
-  if (major < 5) {
-    dprintf_2("release is SunOS 4 or earlier\n");
-    done_set = true;
-    return;
-  }
-
-  // some SunOS 5.* build so now check for Solaris versions
-  char *dot = strchr(name.release, '.');
-  int minor = 0;
-  if (dot != NULL) {
-    // release is major.minor format
-    *dot = NULL;
-    minor = atoi(dot + 1);
-  }
-
-  if (minor <= 10) {
-    dprintf_2("release is Solaris 10 or earlier\n");
-    done_set = true;
-    return;
-  } else if (minor >= 12) {
-    dprintf_2("release is Solaris 12 or later\n");
-    has_newer_Pstack_iter = true;
-    done_set = true;
-    return;
-  }
-
-  // some Solaris 11 build so now check for internal build numbers
-  if (strncmp(name.version, "snv_", 4) != 0) {
-    dprintf_2("release is Solaris 11 post-GA or later\n");
-    has_newer_Pstack_iter = true;
-    done_set = true;
-    return;
-  }
-
-  // version begins with "snv_" so a pre-GA build of Solaris 11
-  int build = atoi(&name.version[4]);
-  if (build >= 159) {
-    dprintf_2("release is Nevada-B159 or later\n");
-    has_newer_Pstack_iter = true;
-  } else {
-    dprintf_2("release is Nevada-B158 or earlier\n");
-  }
-
-  done_set = true;
-}
-#endif // !SOLARIS_11_B159_OR_LATER
-
 /*
  * Class:       sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal
  * Method:      initIDs
@@ -1383,14 +1252,6 @@
   if (libproc_handle == 0)
      THROW_NEW_DEBUGGER_EXCEPTION("can't load libproc.so, if you are using Solaris 5.7 or below, copy libproc.so from 5.8!");
 
-#ifndef SOLARIS_11_B159_OR_LATER
-  _Pstack_iter_debug = getenv("PSTACK_ITER_DEBUG") != NULL;
-
-  set_has_newer_Pstack_iter(env);
-  CHECK_EXCEPTION;
-  dprintf_2("has_newer_Pstack_iter=%d\n", has_newer_Pstack_iter);
-#endif
-
   p_ps_prochandle_ID = env->GetFieldID(clazz, "p_ps_prochandle", "J");
   CHECK_EXCEPTION;