452 * executable if agent_lib->is_static_lib() == true or in the shared library |
452 * executable if agent_lib->is_static_lib() == true or in the shared library |
453 * referenced by 'handle'. |
453 * referenced by 'handle'. |
454 */ |
454 */ |
455 void* os::find_agent_function(AgentLibrary *agent_lib, bool check_lib, |
455 void* os::find_agent_function(AgentLibrary *agent_lib, bool check_lib, |
456 const char *syms[], size_t syms_len) { |
456 const char *syms[], size_t syms_len) { |
|
457 assert(agent_lib != NULL, "sanity check"); |
457 const char *lib_name; |
458 const char *lib_name; |
458 void *handle = agent_lib->os_lib(); |
459 void *handle = agent_lib->os_lib(); |
459 void *entryName = NULL; |
460 void *entryName = NULL; |
460 char *agent_function_name; |
461 char *agent_function_name; |
461 size_t i; |
462 size_t i; |
482 size_t syms_len) { |
483 size_t syms_len) { |
483 void *ret; |
484 void *ret; |
484 void *proc_handle; |
485 void *proc_handle; |
485 void *save_handle; |
486 void *save_handle; |
486 |
487 |
|
488 assert(agent_lib != NULL, "sanity check"); |
487 if (agent_lib->name() == NULL) { |
489 if (agent_lib->name() == NULL) { |
488 return false; |
490 return false; |
489 } |
491 } |
490 proc_handle = get_default_process_handle(); |
492 proc_handle = get_default_process_handle(); |
491 // Check for Agent_OnLoad/Attach_lib_name function |
493 // Check for Agent_OnLoad/Attach_lib_name function |
492 save_handle = agent_lib->os_lib(); |
494 save_handle = agent_lib->os_lib(); |
493 // We want to look in this process' symbol table. |
495 // We want to look in this process' symbol table. |
494 agent_lib->set_os_lib(proc_handle); |
496 agent_lib->set_os_lib(proc_handle); |
495 ret = find_agent_function(agent_lib, true, syms, syms_len); |
497 ret = find_agent_function(agent_lib, true, syms, syms_len); |
496 agent_lib->set_os_lib(save_handle); |
|
497 if (ret != NULL) { |
498 if (ret != NULL) { |
498 // Found an entry point like Agent_OnLoad_lib_name so we have a static agent |
499 // 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(); |
500 agent_lib->set_valid(); |
501 agent_lib->set_static_lib(true); |
501 agent_lib->set_static_lib(true); |
502 return true; |
502 return true; |
503 } |
503 } |
|
504 agent_lib->set_os_lib(save_handle); |
504 return false; |
505 return false; |
505 } |
506 } |
506 |
507 |
507 // --------------------- heap allocation utilities --------------------- |
508 // --------------------- heap allocation utilities --------------------- |
508 |
509 |