author | trims |
Tue, 05 Apr 2011 14:12:31 -0700 | |
changeset 8921 | 14bfe81f2a9d |
parent 8110 | c992c8d52344 |
child 13195 | be27e1b6a4b9 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
8921
14bfe81f2a9d
7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass
trims
parents:
8110
diff
changeset
|
2 |
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#ifndef SHARE_VM_SERVICES_ATTACHLISTENER_HPP |
26 |
#define SHARE_VM_SERVICES_ATTACHLISTENER_HPP |
|
27 |
||
28 |
#include "memory/allocation.hpp" |
|
29 |
#include "utilities/debug.hpp" |
|
30 |
#include "utilities/ostream.hpp" |
|
31 |
||
1 | 32 |
// The AttachListener thread services a queue of operations that are enqueued |
33 |
// by client tools. Each operation is identified by a name and has up to 3 |
|
34 |
// arguments. The operation name is mapped to a function which performs the |
|
35 |
// operation. The function is called with an outputStream which is can use to |
|
36 |
// write any result data (for examples the properties command serializes |
|
37 |
// properties names and values to the output stream). When the function |
|
38 |
// complets the result value and any result data is returned to the client |
|
39 |
// tool. |
|
40 |
||
41 |
#ifndef SERVICES_KERNEL |
|
42 |
||
43 |
class AttachOperation; |
|
44 |
||
45 |
typedef jint (*AttachOperationFunction)(AttachOperation* op, outputStream* out); |
|
46 |
||
47 |
struct AttachOperationFunctionInfo { |
|
48 |
const char* name; |
|
49 |
AttachOperationFunction func; |
|
50 |
}; |
|
51 |
#endif // SERVICES_KERNEL |
|
52 |
||
53 |
class AttachListener: AllStatic { |
|
54 |
public: |
|
55 |
static void init() KERNEL_RETURN; |
|
56 |
static void abort() KERNEL_RETURN; |
|
57 |
||
58 |
// invoke to perform clean-up tasks when all clients detach |
|
59 |
static void detachall() KERNEL_RETURN; |
|
60 |
||
61 |
// indicates if the Attach Listener needs to be created at startup |
|
8110
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7397
diff
changeset
|
62 |
static bool init_at_startup() KERNEL_RETURN_(false); |
1 | 63 |
|
64 |
// indicates if we have a trigger to start the Attach Listener |
|
8110
c992c8d52344
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
7397
diff
changeset
|
65 |
static bool is_init_trigger() KERNEL_RETURN_(false); |
1 | 66 |
|
67 |
#ifdef SERVICES_KERNEL |
|
68 |
static bool is_attach_supported() { return false; } |
|
69 |
#else // SERVICES_KERNEL |
|
70 |
private: |
|
71 |
static volatile bool _initialized; |
|
72 |
||
73 |
public: |
|
74 |
static bool is_initialized() { return _initialized; } |
|
75 |
static void set_initialized() { _initialized = true; } |
|
76 |
||
77 |
// indicates if this VM supports attach-on-demand |
|
78 |
static bool is_attach_supported() { return !DisableAttachMechanism; } |
|
79 |
||
80 |
// platform specific initialization |
|
81 |
static int pd_init(); |
|
82 |
||
83 |
// platform specific operation |
|
84 |
static AttachOperationFunctionInfo* pd_find_operation(const char* name); |
|
85 |
||
86 |
// platform specific flag change |
|
87 |
static jint pd_set_flag(AttachOperation* op, outputStream* out); |
|
88 |
||
89 |
// platform specific detachall |
|
90 |
static void pd_detachall(); |
|
91 |
||
92 |
// platform specific data dump |
|
93 |
static void pd_data_dump(); |
|
94 |
||
95 |
// dequeue the next operation |
|
96 |
static AttachOperation* dequeue(); |
|
97 |
#endif // SERVICES_KERNEL |
|
98 |
}; |
|
99 |
||
100 |
#ifndef SERVICES_KERNEL |
|
101 |
class AttachOperation: public CHeapObj { |
|
102 |
public: |
|
103 |
enum { |
|
104 |
name_length_max = 16, // maximum length of name |
|
105 |
arg_length_max = 1024, // maximum length of argument |
|
106 |
arg_count_max = 3 // maximum number of arguments |
|
107 |
}; |
|
108 |
||
109 |
// name of special operation that can be enqueued when all |
|
110 |
// clients detach |
|
111 |
static char* detachall_operation_name() { return (char*)"detachall"; } |
|
112 |
||
113 |
private: |
|
114 |
char _name[name_length_max+1]; |
|
115 |
char _arg[arg_count_max][arg_length_max+1]; |
|
116 |
||
117 |
public: |
|
118 |
const char* name() const { return _name; } |
|
119 |
||
120 |
// set the operation name |
|
121 |
void set_name(char* name) { |
|
122 |
assert(strlen(name) <= name_length_max, "exceeds maximum name length"); |
|
123 |
strcpy(_name, name); |
|
124 |
} |
|
125 |
||
126 |
// get an argument value |
|
127 |
const char* arg(int i) const { |
|
128 |
assert(i>=0 && i<arg_count_max, "invalid argument index"); |
|
129 |
return _arg[i]; |
|
130 |
} |
|
131 |
||
132 |
// set an argument value |
|
133 |
void set_arg(int i, char* arg) { |
|
134 |
assert(i>=0 && i<arg_count_max, "invalid argument index"); |
|
135 |
if (arg == NULL) { |
|
136 |
_arg[i][0] = '\0'; |
|
137 |
} else { |
|
138 |
assert(strlen(arg) <= arg_length_max, "exceeds maximum argument length"); |
|
139 |
strcpy(_arg[i], arg); |
|
140 |
} |
|
141 |
} |
|
142 |
||
143 |
// create an operation of a given name |
|
144 |
AttachOperation(char* name) { |
|
145 |
set_name(name); |
|
146 |
for (int i=0; i<arg_count_max; i++) { |
|
147 |
set_arg(i, NULL); |
|
148 |
} |
|
149 |
} |
|
150 |
||
151 |
// complete operation by sending result code and any result data to the client |
|
152 |
virtual void complete(jint result, bufferedStream* result_stream) = 0; |
|
153 |
}; |
|
154 |
#endif // SERVICES_KERNEL |
|
7397 | 155 |
|
156 |
#endif // SHARE_VM_SERVICES_ATTACHLISTENER_HPP |