src/os/posix/vm/os_posix.cpp

Print this page

        

@@ -1,7 +1,7 @@
 /*
-* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 1999, 2013, 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
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.

@@ -258,10 +258,50 @@
 
 FILE* os::open(int fd, const char* mode) {
   return ::fdopen(fd, mode);
 }
 
+void* os::getDefaultProcessHandle() {
+  return (void*)::dlopen(NULL, RTLD_LAZY);
+}
+
+char* os::buildAgentFunctionName(const char *symName, const char *name,
+                                 bool is_absolute_path) {
+  char *agentEntryName;
+  size_t len;
+  size_t nameLen;
+  size_t prefixLen = strlen(JNI_LIB_PREFIX);
+  size_t suffixLen = strlen(JNI_LIB_SUFFIX);
+  const char *start;
+
+  if (name != NULL) {
+    len = nameLen = strlen(name);
+    if (is_absolute_path) {
+      // Need to strip path, prefix and suffix
+      if ((start = strrchr(name, *os::file_separator())) != NULL) {
+        name = ++start;
+      }
+      if (len <= (prefixLen + suffixLen)) {
+        return NULL;
+      }
+      name += prefixLen;
+      nameLen = strlen(name) - suffixLen;
+    }
+  }
+  len = (name != NULL ? nameLen : 0) + strlen(symName) + 2;
+  agentEntryName = NEW_C_HEAP_ARRAY(char, len, mtThread);
+  if (agentEntryName == NULL) {
+    return NULL;
+  }
+  strcpy(agentEntryName, symName);
+  if (name != NULL) {
+    strcat(agentEntryName, "_");
+    strncat(agentEntryName, name, nameLen);
+  }
+  return agentEntryName;
+}
+
 os::WatcherThreadCrashProtection::WatcherThreadCrashProtection() {
   assert(Thread::current()->is_Watcher_thread(), "Must be WatcherThread");
 }
 
 /*