1 /* |
1 /* |
2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
258 |
258 |
259 FILE* os::open(int fd, const char* mode) { |
259 FILE* os::open(int fd, const char* mode) { |
260 return ::fdopen(fd, mode); |
260 return ::fdopen(fd, mode); |
261 } |
261 } |
262 |
262 |
|
263 void* os::get_default_process_handle() { |
|
264 return (void*)::dlopen(NULL, RTLD_LAZY); |
|
265 } |
|
266 |
|
267 // Builds a platform dependent Agent_OnLoad_<lib_name> function name |
|
268 // which is used to find statically linked in agents. |
|
269 // Parameters: |
|
270 // sym_name: Symbol in library we are looking for |
|
271 // lib_name: Name of library to look in, NULL for shared libs. |
|
272 // is_absolute_path == true if lib_name is absolute path to agent |
|
273 // such as "/a/b/libL.so" |
|
274 // == false if only the base name of the library is passed in |
|
275 // such as "L" |
|
276 char* os::build_agent_function_name(const char *sym_name, const char *lib_name, |
|
277 bool is_absolute_path) { |
|
278 char *agent_entry_name; |
|
279 size_t len; |
|
280 size_t name_len; |
|
281 size_t prefix_len = strlen(JNI_LIB_PREFIX); |
|
282 size_t suffix_len = strlen(JNI_LIB_SUFFIX); |
|
283 const char *start; |
|
284 |
|
285 if (lib_name != NULL) { |
|
286 len = name_len = strlen(lib_name); |
|
287 if (is_absolute_path) { |
|
288 // Need to strip path, prefix and suffix |
|
289 if ((start = strrchr(lib_name, *os::file_separator())) != NULL) { |
|
290 lib_name = ++start; |
|
291 } |
|
292 if (len <= (prefix_len + suffix_len)) { |
|
293 return NULL; |
|
294 } |
|
295 lib_name += prefix_len; |
|
296 name_len = strlen(lib_name) - suffix_len; |
|
297 } |
|
298 } |
|
299 len = (lib_name != NULL ? name_len : 0) + strlen(sym_name) + 2; |
|
300 agent_entry_name = NEW_C_HEAP_ARRAY_RETURN_NULL(char, len, mtThread); |
|
301 if (agent_entry_name == NULL) { |
|
302 return NULL; |
|
303 } |
|
304 strcpy(agent_entry_name, sym_name); |
|
305 if (lib_name != NULL) { |
|
306 strcat(agent_entry_name, "_"); |
|
307 strncat(agent_entry_name, lib_name, name_len); |
|
308 } |
|
309 return agent_entry_name; |
|
310 } |
|
311 |
263 os::WatcherThreadCrashProtection::WatcherThreadCrashProtection() { |
312 os::WatcherThreadCrashProtection::WatcherThreadCrashProtection() { |
264 assert(Thread::current()->is_Watcher_thread(), "Must be WatcherThread"); |
313 assert(Thread::current()->is_Watcher_thread(), "Must be WatcherThread"); |
265 } |
314 } |
266 |
315 |
267 /* |
316 /* |