comparison src/share/vm/runtime/os.cpp @ 14412:e2722a66aba7

Merge
author kvn
date Thu, 05 Sep 2013 11:04:39 -0700
parents 94c202aa2646 f92b82d454fa
children 2b8e28fdf503
comparison
equal deleted inserted replaced
14411:bdd155477289 14412:e2722a66aba7
441 } 441 }
442 } 442 }
443 return _native_java_library; 443 return _native_java_library;
444 } 444 }
445 445
446 /*
447 * Support for finding Agent_On(Un)Load/Attach<_lib_name> if it exists.
448 * If check_lib == true then we are looking for an
449 * Agent_OnLoad_lib_name or Agent_OnAttach_lib_name function to determine if
450 * this library is statically linked into the image.
451 * If check_lib == false then we will look for the appropriate symbol in the
452 * executable if agent_lib->is_static_lib() == true or in the shared library
453 * referenced by 'handle'.
454 */
455 void* os::find_agent_function(AgentLibrary *agent_lib, bool check_lib,
456 const char *syms[], size_t syms_len) {
457 const char *lib_name;
458 void *handle = agent_lib->os_lib();
459 void *entryName = NULL;
460 char *agent_function_name;
461 size_t i;
462
463 // If checking then use the agent name otherwise test is_static_lib() to
464 // see how to process this lookup
465 lib_name = ((check_lib || agent_lib->is_static_lib()) ? agent_lib->name() : NULL);
466 for (i = 0; i < syms_len; i++) {
467 agent_function_name = build_agent_function_name(syms[i], lib_name, agent_lib->is_absolute_path());
468 if (agent_function_name == NULL) {
469 break;
470 }
471 entryName = dll_lookup(handle, agent_function_name);
472 FREE_C_HEAP_ARRAY(char, agent_function_name, mtThread);
473 if (entryName != NULL) {
474 break;
475 }
476 }
477 return entryName;
478 }
479
480 // See if the passed in agent is statically linked into the VM image.
481 bool os::find_builtin_agent(AgentLibrary *agent_lib, const char *syms[],
482 size_t syms_len) {
483 void *ret;
484 void *proc_handle;
485 void *save_handle;
486
487 if (agent_lib->name() == NULL) {
488 return false;
489 }
490 proc_handle = get_default_process_handle();
491 // Check for Agent_OnLoad/Attach_lib_name function
492 save_handle = agent_lib->os_lib();
493 // We want to look in this process' symbol table.
494 agent_lib->set_os_lib(proc_handle);
495 ret = find_agent_function(agent_lib, true, syms, syms_len);
496 agent_lib->set_os_lib(save_handle);
497 if (ret != NULL) {
498 // Found an entry point like Agent_OnLoad_lib_name so we have a static agent
499 agent_lib->set_os_lib(proc_handle);
500 agent_lib->set_valid();
501 agent_lib->set_static_lib(true);
502 return true;
503 }
504 return false;
505 }
506
446 // --------------------- heap allocation utilities --------------------- 507 // --------------------- heap allocation utilities ---------------------
447 508
448 char *os::strdup(const char *str, MEMFLAGS flags) { 509 char *os::strdup(const char *str, MEMFLAGS flags) {
449 size_t size = strlen(str); 510 size_t size = strlen(str);
450 char *dup_str = (char *)malloc(size + 1, flags); 511 char *dup_str = (char *)malloc(size + 1, flags);