8166012: [linux] Remove remnants of LinuxThreads from Linux attach framework
authorstuefe
Wed, 14 Sep 2016 14:29:39 +0200
changeset 40943 46cd6d4f353f
parent 40942 7a81fdff5752
child 40944 dba53de83476
8166012: [linux] Remove remnants of LinuxThreads from Linux attach framework Reviewed-by: dholmes, alanb
jdk/make/mapfiles/libattach/mapfile-linux
jdk/src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java
jdk/src/jdk.attach/linux/native/libattach/VirtualMachineImpl.c
--- a/jdk/make/mapfiles/libattach/mapfile-linux	Wed Sep 14 11:06:26 2016 +0800
+++ b/jdk/make/mapfiles/libattach/mapfile-linux	Wed Sep 14 14:29:39 2016 +0200
@@ -30,8 +30,6 @@
 	    Java_sun_tools_attach_VirtualMachineImpl_checkPermissions;
 	    Java_sun_tools_attach_VirtualMachineImpl_close;
 	    Java_sun_tools_attach_VirtualMachineImpl_connect;
-	    Java_sun_tools_attach_VirtualMachineImpl_getLinuxThreadsManager;
-	    Java_sun_tools_attach_VirtualMachineImpl_isLinuxThreads;
 	    Java_sun_tools_attach_VirtualMachineImpl_open;
 	    Java_sun_tools_attach_VirtualMachineImpl_sendQuitTo;
             Java_sun_tools_attach_VirtualMachineImpl_sendQuitToChildrenOf;
--- a/jdk/src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java	Wed Sep 14 11:06:26 2016 +0800
+++ b/jdk/src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java	Wed Sep 14 14:29:39 2016 +0200
@@ -308,10 +308,6 @@
 
     //-- native methods
 
-    static native boolean isLinuxThreads();
-
-    static native int getLinuxThreadsManager(int pid) throws IOException;
-
     static native void sendQuitToChildrenOf(int pid) throws IOException;
 
     static native void sendQuitTo(int pid) throws IOException;
--- a/jdk/src/jdk.attach/linux/native/libattach/VirtualMachineImpl.c	Wed Sep 14 11:06:26 2016 +0800
+++ b/jdk/src/jdk.attach/linux/native/libattach/VirtualMachineImpl.c	Wed Sep 14 14:29:39 2016 +0200
@@ -195,113 +195,6 @@
 }
 
 /*
- * Class:     sun_tools_attach_VirtualMachineImpl
- * Method:    isLinuxThreads
- * Signature: ()V
- */
-JNIEXPORT jboolean JNICALL Java_sun_tools_attach_VirtualMachineImpl_isLinuxThreads
-  (JNIEnv *env, jclass cls)
-{
-# ifndef _CS_GNU_LIBPTHREAD_VERSION
-# define _CS_GNU_LIBPTHREAD_VERSION 3
-# endif
-    size_t n;
-    char* s;
-    jboolean res;
-
-    n = confstr(_CS_GNU_LIBPTHREAD_VERSION, NULL, 0);
-    if (n <= 0) {
-       /* glibc before 2.3.2 only has LinuxThreads */
-       return JNI_TRUE;
-    }
-
-    s = (char *)malloc(n);
-    if (s == NULL) {
-        JNU_ThrowOutOfMemoryError(env, "malloc failed");
-        return JNI_TRUE;
-    }
-    confstr(_CS_GNU_LIBPTHREAD_VERSION, s, n);
-
-    /*
-     * If the LIBPTHREAD version include "NPTL" then we know we
-     * have the new threads library and not LinuxThreads
-     */
-    res = (jboolean)(strstr(s, "NPTL") == NULL);
-    free(s);
-    return res;
-}
-
-/*
- * Structure and callback function used to count the children of
- * a given process, and record the pid of the "manager thread".
- */
-typedef struct {
-    pid_t ppid;
-    int count;
-    pid_t mpid;
-} ChildCountContext;
-
-static void ChildCountCallback(const pid_t pid, void* user_data) {
-    ChildCountContext* context = (ChildCountContext*)user_data;
-    if (getParent(pid) == context->ppid) {
-        context->count++;
-        /*
-         * Remember the pid of the first child. If the final count is
-         * one then this is the pid of the LinuxThreads manager.
-         */
-        if (context->count == 1) {
-            context->mpid = pid;
-        }
-    }
-}
-
-/*
- * Class:     sun_tools_attach_VirtualMachineImpl
- * Method:    getLinuxThreadsManager
- * Signature: (I)I
- */
-JNIEXPORT jint JNICALL Java_sun_tools_attach_VirtualMachineImpl_getLinuxThreadsManager
-  (JNIEnv *env, jclass cls, jint pid)
-{
-    ChildCountContext context;
-
-    /*
-     * Iterate over all processes to find how many children 'pid' has
-     */
-    context.ppid = pid;
-    context.count = 0;
-    context.mpid = (pid_t)0;
-    forEachProcess(ChildCountCallback, (void*)&context);
-
-    /*
-     * If there's no children then this is likely the pid of the primordial
-     * created by the launcher - in that case the LinuxThreads manager is the
-     * parent of this process.
-     */
-    if (context.count == 0) {
-        pid_t parent = getParent(pid);
-        if ((int)parent > 0) {
-            return (jint)parent;
-        }
-    }
-
-    /*
-     * There's one child so this is likely the embedded VM case where the
-     * the primordial thread == LinuxThreads initial thread. The LinuxThreads
-     * manager in that case is the child.
-     */
-    if (context.count == 1) {
-        return (jint)context.mpid;
-    }
-
-    /*
-     * If we get here it's most likely we were given the wrong pid
-     */
-    JNU_ThrowIOException(env, "Unable to get pid of LinuxThreads manager thread");
-    return -1;
-}
-
-/*
  * Structure and callback function used to send a QUIT signal to all
  * children of a given process
  */