提交 2fda406b 编写于 作者: B bpittore

8024007: Misc. cleanup of static agent code

Summary: Minor cleanup of static agent code from 8014135
Reviewed-by: dcubed, sspitsyn
上级 f6012b7b
...@@ -5429,7 +5429,7 @@ char* os::build_agent_function_name(const char *sym_name, const char *lib_name, ...@@ -5429,7 +5429,7 @@ char* os::build_agent_function_name(const char *sym_name, const char *lib_name,
if ((start = strrchr(lib_name, *os::file_separator())) != NULL) { if ((start = strrchr(lib_name, *os::file_separator())) != NULL) {
lib_name = ++start; lib_name = ++start;
} else { } else {
// Need to check for C: // Need to check for drive prefix
if ((start = strchr(lib_name, ':')) != NULL) { if ((start = strchr(lib_name, ':')) != NULL) {
lib_name = ++start; lib_name = ++start;
} }
......
...@@ -458,8 +458,10 @@ ...@@ -458,8 +458,10 @@
the same name from being loaded dynamically. the same name from being loaded dynamically.
<p/> <p/>
The VM will invoke the Agent_OnUnload_L function of the agent, if such The VM will invoke the Agent_OnUnload_L function of the agent, if such
a function is exported, at the same point during startup as it would a function is exported, at the same point during VM execution as it would
have called the dynamic entry point Agent_OnUnLoad. have called the dynamic entry point Agent_OnUnLoad. A statically loaded
agent cannot be unloaded. The Agent_OnUnload_L function will still be
called to do any other agent shutdown related tasks.
If a <i>statically linked</i> agent L exports a function called If a <i>statically linked</i> agent L exports a function called
Agent_OnUnLoad_L and a function called Agent_OnUnLoad, the Agent_OnUnLoad Agent_OnUnLoad_L and a function called Agent_OnUnLoad, the Agent_OnUnLoad
function will be ignored. function will be ignored.
......
...@@ -144,7 +144,7 @@ public: ...@@ -144,7 +144,7 @@ public:
void set_os_lib(void* os_lib) { _os_lib = os_lib; } void set_os_lib(void* os_lib) { _os_lib = os_lib; }
AgentLibrary* next() const { return _next; } AgentLibrary* next() const { return _next; }
bool is_static_lib() const { return _is_static_lib; } bool is_static_lib() const { return _is_static_lib; }
void set_static_lib(bool static_lib) { _is_static_lib = static_lib; } void set_static_lib(bool is_static_lib) { _is_static_lib = is_static_lib; }
bool valid() { return (_state == agent_valid); } bool valid() { return (_state == agent_valid); }
void set_valid() { _state = agent_valid; } void set_valid() { _state = agent_valid; }
void set_invalid() { _state = agent_invalid; } void set_invalid() { _state = agent_invalid; }
......
...@@ -454,6 +454,7 @@ void* os::native_java_library() { ...@@ -454,6 +454,7 @@ void* os::native_java_library() {
*/ */
void* os::find_agent_function(AgentLibrary *agent_lib, bool check_lib, void* os::find_agent_function(AgentLibrary *agent_lib, bool check_lib,
const char *syms[], size_t syms_len) { const char *syms[], size_t syms_len) {
assert(agent_lib != NULL, "sanity check");
const char *lib_name; const char *lib_name;
void *handle = agent_lib->os_lib(); void *handle = agent_lib->os_lib();
void *entryName = NULL; void *entryName = NULL;
...@@ -484,6 +485,7 @@ bool os::find_builtin_agent(AgentLibrary *agent_lib, const char *syms[], ...@@ -484,6 +485,7 @@ bool os::find_builtin_agent(AgentLibrary *agent_lib, const char *syms[],
void *proc_handle; void *proc_handle;
void *save_handle; void *save_handle;
assert(agent_lib != NULL, "sanity check");
if (agent_lib->name() == NULL) { if (agent_lib->name() == NULL) {
return false; return false;
} }
...@@ -493,14 +495,13 @@ bool os::find_builtin_agent(AgentLibrary *agent_lib, const char *syms[], ...@@ -493,14 +495,13 @@ bool os::find_builtin_agent(AgentLibrary *agent_lib, const char *syms[],
// We want to look in this process' symbol table. // We want to look in this process' symbol table.
agent_lib->set_os_lib(proc_handle); agent_lib->set_os_lib(proc_handle);
ret = find_agent_function(agent_lib, true, syms, syms_len); ret = find_agent_function(agent_lib, true, syms, syms_len);
agent_lib->set_os_lib(save_handle);
if (ret != NULL) { if (ret != NULL) {
// Found an entry point like Agent_OnLoad_lib_name so we have a static agent // Found an entry point like Agent_OnLoad_lib_name so we have a static agent
agent_lib->set_os_lib(proc_handle);
agent_lib->set_valid(); agent_lib->set_valid();
agent_lib->set_static_lib(true); agent_lib->set_static_lib(true);
return true; return true;
} }
agent_lib->set_os_lib(save_handle);
return false; return false;
} }
......
...@@ -3714,7 +3714,7 @@ static OnLoadEntry_t lookup_on_load(AgentLibrary* agent, const char *on_load_sym ...@@ -3714,7 +3714,7 @@ static OnLoadEntry_t lookup_on_load(AgentLibrary* agent, const char *on_load_sym
const char *name = agent->name(); const char *name = agent->name();
const char *msg = "Could not find agent library "; const char *msg = "Could not find agent library ";
// First check to see if agent is statcally linked into executable // First check to see if agent is statically linked into executable
if (os::find_builtin_agent(agent, on_load_symbols, num_symbol_entries)) { if (os::find_builtin_agent(agent, on_load_symbols, num_symbol_entries)) {
library = agent->os_lib(); library = agent->os_lib();
} else if (agent->is_absolute_path()) { } else if (agent->is_absolute_path()) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册