hotspot/src/share/vm/runtime/os.cpp
changeset 20006 9dc2add3103b
parent 19986 33d188c66ed9
parent 19973 d98623e1f50b
child 22838 82c7497fbad4
child 22201 9c2ccfa3a5fe
equal deleted inserted replaced
20005:6fb8070af25d 20006:9dc2add3103b
   457  * executable if agent_lib->is_static_lib() == true or in the shared library
   457  * executable if agent_lib->is_static_lib() == true or in the shared library
   458  * referenced by 'handle'.
   458  * referenced by 'handle'.
   459  */
   459  */
   460 void* os::find_agent_function(AgentLibrary *agent_lib, bool check_lib,
   460 void* os::find_agent_function(AgentLibrary *agent_lib, bool check_lib,
   461                               const char *syms[], size_t syms_len) {
   461                               const char *syms[], size_t syms_len) {
       
   462   assert(agent_lib != NULL, "sanity check");
   462   const char *lib_name;
   463   const char *lib_name;
   463   void *handle = agent_lib->os_lib();
   464   void *handle = agent_lib->os_lib();
   464   void *entryName = NULL;
   465   void *entryName = NULL;
   465   char *agent_function_name;
   466   char *agent_function_name;
   466   size_t i;
   467   size_t i;
   487                             size_t syms_len) {
   488                             size_t syms_len) {
   488   void *ret;
   489   void *ret;
   489   void *proc_handle;
   490   void *proc_handle;
   490   void *save_handle;
   491   void *save_handle;
   491 
   492 
       
   493   assert(agent_lib != NULL, "sanity check");
   492   if (agent_lib->name() == NULL) {
   494   if (agent_lib->name() == NULL) {
   493     return false;
   495     return false;
   494   }
   496   }
   495   proc_handle = get_default_process_handle();
   497   proc_handle = get_default_process_handle();
   496   // Check for Agent_OnLoad/Attach_lib_name function
   498   // Check for Agent_OnLoad/Attach_lib_name function
   497   save_handle = agent_lib->os_lib();
   499   save_handle = agent_lib->os_lib();
   498   // We want to look in this process' symbol table.
   500   // We want to look in this process' symbol table.
   499   agent_lib->set_os_lib(proc_handle);
   501   agent_lib->set_os_lib(proc_handle);
   500   ret = find_agent_function(agent_lib, true, syms, syms_len);
   502   ret = find_agent_function(agent_lib, true, syms, syms_len);
   501   agent_lib->set_os_lib(save_handle);
       
   502   if (ret != NULL) {
   503   if (ret != NULL) {
   503     // Found an entry point like Agent_OnLoad_lib_name so we have a static agent
   504     // Found an entry point like Agent_OnLoad_lib_name so we have a static agent
   504     agent_lib->set_os_lib(proc_handle);
       
   505     agent_lib->set_valid();
   505     agent_lib->set_valid();
   506     agent_lib->set_static_lib(true);
   506     agent_lib->set_static_lib(true);
   507     return true;
   507     return true;
   508   }
   508   }
       
   509   agent_lib->set_os_lib(save_handle);
   509   return false;
   510   return false;
   510 }
   511 }
   511 
   512 
   512 // --------------------- heap allocation utilities ---------------------
   513 // --------------------- heap allocation utilities ---------------------
   513 
   514