< prev index next >

src/jdk.jdwp.agent/share/native/libjdwp/transport.c

Print this page
rev 12879 : 8136556: Add the ability to perform static builds of MacOSX x64 binaries
Reviewed-by: ihse, bdelsart, gadams, lfoltan, rriggs, hseigel, twisti
   1 /*
   2  * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  84 
  85 /* Find OnLoad symbol */
  86 static jdwpTransport_OnLoad_t
  87 findTransportOnLoad(void *handle)
  88 {
  89     jdwpTransport_OnLoad_t onLoad;
  90 
  91     onLoad = (jdwpTransport_OnLoad_t)NULL;
  92     if (handle == NULL) {
  93         return onLoad;
  94     }
  95     onLoad = (jdwpTransport_OnLoad_t)
  96                  dbgsysFindLibraryEntry(handle, "jdwpTransport_OnLoad");
  97     return onLoad;
  98 }
  99 
 100 /* Load transport library (directory=="" means do system search) */
 101 static void *
 102 loadTransportLibrary(const char *libdir, const char *name)
 103 {


 104     void *handle;
 105     char libname[MAXPATHLEN+2];
 106     char buf[MAXPATHLEN*2+100];
 107     const char *plibdir;
 108 
 109     /* Convert libdir from UTF-8 to platform encoding */
 110     plibdir = NULL;
 111     if ( libdir != NULL ) {
 112         int  len;
 113 
 114         len = (int)strlen(libdir);
 115         (void)utf8ToPlatform((jbyte*)libdir, len, buf, (int)sizeof(buf));
 116         plibdir = buf;
 117     }
 118 
 119     /* Construct library name (simple name or full path) */
 120     dbgsysBuildLibName(libname, sizeof(libname), plibdir, name);
 121     if (strlen(libname) == 0) {
 122         return NULL;
 123     }
 124 
 125     /* dlopen (unix) / LoadLibrary (windows) the transport library */
 126     handle = dbgsysLoadLibrary(libname, buf, sizeof(buf));
 127     return handle;



 128 }
 129 
 130 /*
 131  * loadTransport() is adapted from loadJVMHelperLib() in
 132  * JDK 1.2 javai.c v1.61
 133  */
 134 static jdwpError
 135 loadTransport(const char *name, jdwpTransportEnv **transportPtr)
 136 {
 137     JNIEnv                 *env;
 138     jdwpTransport_OnLoad_t  onLoad;
 139     void                   *handle;
 140     const char             *libdir;
 141 
 142     /* Make sure library name is not empty */
 143     if (name == NULL) {
 144         ERROR_MESSAGE(("library name is empty"));
 145         return JDWP_ERROR(TRANSPORT_LOAD);
 146     }
 147 


   1 /*
   2  * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  84 
  85 /* Find OnLoad symbol */
  86 static jdwpTransport_OnLoad_t
  87 findTransportOnLoad(void *handle)
  88 {
  89     jdwpTransport_OnLoad_t onLoad;
  90 
  91     onLoad = (jdwpTransport_OnLoad_t)NULL;
  92     if (handle == NULL) {
  93         return onLoad;
  94     }
  95     onLoad = (jdwpTransport_OnLoad_t)
  96                  dbgsysFindLibraryEntry(handle, "jdwpTransport_OnLoad");
  97     return onLoad;
  98 }
  99 
 100 /* Load transport library (directory=="" means do system search) */
 101 static void *
 102 loadTransportLibrary(const char *libdir, const char *name)
 103 {
 104     char buf[MAXPATHLEN*2+100];
 105 #ifndef STATIC_BUILD
 106     void *handle;
 107     char libname[MAXPATHLEN+2];

 108     const char *plibdir;
 109 
 110     /* Convert libdir from UTF-8 to platform encoding */
 111     plibdir = NULL;
 112     if ( libdir != NULL ) {
 113         int  len;
 114 
 115         len = (int)strlen(libdir);
 116         (void)utf8ToPlatform((jbyte*)libdir, len, buf, (int)sizeof(buf));
 117         plibdir = buf;
 118     }
 119 
 120     /* Construct library name (simple name or full path) */
 121     dbgsysBuildLibName(libname, sizeof(libname), plibdir, name);
 122     if (strlen(libname) == 0) {
 123         return NULL;
 124     }
 125 
 126     /* dlopen (unix) / LoadLibrary (windows) the transport library */
 127     handle = dbgsysLoadLibrary(libname, buf, sizeof(buf));
 128     return handle;
 129 #else
 130     return (dbgsysLoadLibrary(NULL, buf, sizeof(buf)));
 131 #endif
 132 }
 133 
 134 /*
 135  * loadTransport() is adapted from loadJVMHelperLib() in
 136  * JDK 1.2 javai.c v1.61
 137  */
 138 static jdwpError
 139 loadTransport(const char *name, jdwpTransportEnv **transportPtr)
 140 {
 141     JNIEnv                 *env;
 142     jdwpTransport_OnLoad_t  onLoad;
 143     void                   *handle;
 144     const char             *libdir;
 145 
 146     /* Make sure library name is not empty */
 147     if (name == NULL) {
 148         ERROR_MESSAGE(("library name is empty"));
 149         return JDWP_ERROR(TRANSPORT_LOAD);
 150     }
 151 


< prev index next >