116 |
116 |
117 |
117 |
118 // For use by -agentlib, -agentpath and -Xrun |
118 // For use by -agentlib, -agentpath and -Xrun |
119 class AgentLibrary : public CHeapObj<mtInternal> { |
119 class AgentLibrary : public CHeapObj<mtInternal> { |
120 friend class AgentLibraryList; |
120 friend class AgentLibraryList; |
|
121 public: |
|
122 // Is this library valid or not. Don't rely on os_lib == NULL as statically |
|
123 // linked lib could have handle of RTLD_DEFAULT which == 0 on some platforms |
|
124 enum AgentState { |
|
125 agent_invalid = 0, |
|
126 agent_valid = 1 |
|
127 }; |
|
128 |
121 private: |
129 private: |
122 char* _name; |
130 char* _name; |
123 char* _options; |
131 char* _options; |
124 void* _os_lib; |
132 void* _os_lib; |
125 bool _is_absolute_path; |
133 bool _is_absolute_path; |
|
134 bool _is_static_lib; |
|
135 AgentState _state; |
126 AgentLibrary* _next; |
136 AgentLibrary* _next; |
127 |
137 |
128 public: |
138 public: |
129 // Accessors |
139 // Accessors |
130 const char* name() const { return _name; } |
140 const char* name() const { return _name; } |
131 char* options() const { return _options; } |
141 char* options() const { return _options; } |
132 bool is_absolute_path() const { return _is_absolute_path; } |
142 bool is_absolute_path() const { return _is_absolute_path; } |
133 void* os_lib() const { return _os_lib; } |
143 void* os_lib() const { return _os_lib; } |
134 void set_os_lib(void* os_lib) { _os_lib = os_lib; } |
144 void set_os_lib(void* os_lib) { _os_lib = os_lib; } |
135 AgentLibrary* next() const { return _next; } |
145 AgentLibrary* next() const { return _next; } |
|
146 bool is_static_lib() const { return _is_static_lib; } |
|
147 void set_static_lib(bool static_lib) { _is_static_lib = static_lib; } |
|
148 bool valid() { return (_state == agent_valid); } |
|
149 void set_valid() { _state = agent_valid; } |
|
150 void set_invalid() { _state = agent_invalid; } |
136 |
151 |
137 // Constructor |
152 // Constructor |
138 AgentLibrary(const char* name, const char* options, bool is_absolute_path, void* os_lib) { |
153 AgentLibrary(const char* name, const char* options, bool is_absolute_path, void* os_lib) { |
139 _name = AllocateHeap(strlen(name)+1, mtInternal); |
154 _name = AllocateHeap(strlen(name)+1, mtInternal); |
140 strcpy(_name, name); |
155 strcpy(_name, name); |
145 strcpy(_options, options); |
160 strcpy(_options, options); |
146 } |
161 } |
147 _is_absolute_path = is_absolute_path; |
162 _is_absolute_path = is_absolute_path; |
148 _os_lib = os_lib; |
163 _os_lib = os_lib; |
149 _next = NULL; |
164 _next = NULL; |
|
165 _state = agent_invalid; |
|
166 _is_static_lib = false; |
150 } |
167 } |
151 }; |
168 }; |
152 |
169 |
153 // maintain an order of entry list of AgentLibrary |
170 // maintain an order of entry list of AgentLibrary |
154 class AgentLibraryList VALUE_OBJ_CLASS_SPEC { |
171 class AgentLibraryList VALUE_OBJ_CLASS_SPEC { |
274 static AgentLibraryList _agentList; |
291 static AgentLibraryList _agentList; |
275 static void add_init_agent(const char* name, char* options, bool absolute_path) |
292 static void add_init_agent(const char* name, char* options, bool absolute_path) |
276 { _agentList.add(new AgentLibrary(name, options, absolute_path, NULL)); } |
293 { _agentList.add(new AgentLibrary(name, options, absolute_path, NULL)); } |
277 |
294 |
278 // Late-binding agents not started via arguments |
295 // Late-binding agents not started via arguments |
|
296 static void add_loaded_agent(AgentLibrary *agentLib) |
|
297 { _agentList.add(agentLib); } |
279 static void add_loaded_agent(const char* name, char* options, bool absolute_path, void* os_lib) |
298 static void add_loaded_agent(const char* name, char* options, bool absolute_path, void* os_lib) |
280 { _agentList.add(new AgentLibrary(name, options, absolute_path, os_lib)); } |
299 { _agentList.add(new AgentLibrary(name, options, absolute_path, os_lib)); } |
281 |
300 |
282 // Operation modi |
301 // Operation modi |
283 static Mode _mode; |
302 static Mode _mode; |