author | allwin |
Fri, 12 Jul 2013 18:43:27 +0200 | |
changeset 18931 | 5de3638104b4 |
parent 15484 | 7395ace8a11a |
child 22197 | 41ea552a447d |
permissions | -rw-r--r-- |
1 | 1 |
/* |
15432 | 2 |
* Copyright (c) 2005, 2013, 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" |
|
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
13977
diff
changeset
|
31 |
#include "utilities/macros.hpp" |
7397 | 32 |
|
1 | 33 |
// The AttachListener thread services a queue of operations that are enqueued |
34 |
// by client tools. Each operation is identified by a name and has up to 3 |
|
35 |
// arguments. The operation name is mapped to a function which performs the |
|
36 |
// operation. The function is called with an outputStream which is can use to |
|
37 |
// write any result data (for examples the properties command serializes |
|
38 |
// properties names and values to the output stream). When the function |
|
39 |
// complets the result value and any result data is returned to the client |
|
40 |
// tool. |
|
41 |
||
42 |
class AttachOperation; |
|
43 |
||
44 |
typedef jint (*AttachOperationFunction)(AttachOperation* op, outputStream* out); |
|
45 |
||
46 |
struct AttachOperationFunctionInfo { |
|
47 |
const char* name; |
|
48 |
AttachOperationFunction func; |
|
49 |
}; |
|
50 |
||
51 |
class AttachListener: AllStatic { |
|
52 |
public: |
|
18931
5de3638104b4
7162400: Intermittent java.io.IOException: Bad file number during HotSpotVirtualMachine.executeCommand
allwin
parents:
15484
diff
changeset
|
53 |
static void vm_start() NOT_SERVICES_RETURN; |
13975
2f7431485cfa
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
13195
diff
changeset
|
54 |
static void init() NOT_SERVICES_RETURN; |
2f7431485cfa
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
13195
diff
changeset
|
55 |
static void abort() NOT_SERVICES_RETURN; |
1 | 56 |
|
57 |
// invoke to perform clean-up tasks when all clients detach |
|
13975
2f7431485cfa
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
13195
diff
changeset
|
58 |
static void detachall() NOT_SERVICES_RETURN; |
1 | 59 |
|
60 |
// indicates if the Attach Listener needs to be created at startup |
|
13975
2f7431485cfa
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
13195
diff
changeset
|
61 |
static bool init_at_startup() NOT_SERVICES_RETURN_(false); |
1 | 62 |
|
63 |
// indicates if we have a trigger to start the Attach Listener |
|
13975
2f7431485cfa
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
13195
diff
changeset
|
64 |
static bool is_init_trigger() NOT_SERVICES_RETURN_(false); |
1 | 65 |
|
13975
2f7431485cfa
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
13195
diff
changeset
|
66 |
#if !INCLUDE_SERVICES |
1 | 67 |
static bool is_attach_supported() { return false; } |
13975
2f7431485cfa
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
13195
diff
changeset
|
68 |
#else |
1 | 69 |
private: |
70 |
static volatile bool _initialized; |
|
71 |
||
72 |
public: |
|
73 |
static bool is_initialized() { return _initialized; } |
|
74 |
static void set_initialized() { _initialized = true; } |
|
75 |
||
76 |
// indicates if this VM supports attach-on-demand |
|
77 |
static bool is_attach_supported() { return !DisableAttachMechanism; } |
|
78 |
||
79 |
// platform specific initialization |
|
80 |
static int pd_init(); |
|
81 |
||
82 |
// platform specific operation |
|
83 |
static AttachOperationFunctionInfo* pd_find_operation(const char* name); |
|
84 |
||
85 |
// platform specific flag change |
|
86 |
static jint pd_set_flag(AttachOperation* op, outputStream* out); |
|
87 |
||
88 |
// platform specific detachall |
|
89 |
static void pd_detachall(); |
|
90 |
||
91 |
// platform specific data dump |
|
92 |
static void pd_data_dump(); |
|
93 |
||
94 |
// dequeue the next operation |
|
95 |
static AttachOperation* dequeue(); |
|
13975
2f7431485cfa
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
13195
diff
changeset
|
96 |
#endif // !INCLUDE_SERVICES |
1 | 97 |
}; |
98 |
||
13975
2f7431485cfa
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
13195
diff
changeset
|
99 |
#if INCLUDE_SERVICES |
13195 | 100 |
class AttachOperation: public CHeapObj<mtInternal> { |
1 | 101 |
public: |
102 |
enum { |
|
103 |
name_length_max = 16, // maximum length of name |
|
104 |
arg_length_max = 1024, // maximum length of argument |
|
105 |
arg_count_max = 3 // maximum number of arguments |
|
106 |
}; |
|
107 |
||
108 |
// name of special operation that can be enqueued when all |
|
109 |
// clients detach |
|
110 |
static char* detachall_operation_name() { return (char*)"detachall"; } |
|
111 |
||
112 |
private: |
|
113 |
char _name[name_length_max+1]; |
|
114 |
char _arg[arg_count_max][arg_length_max+1]; |
|
115 |
||
116 |
public: |
|
117 |
const char* name() const { return _name; } |
|
118 |
||
119 |
// set the operation name |
|
120 |
void set_name(char* name) { |
|
121 |
assert(strlen(name) <= name_length_max, "exceeds maximum name length"); |
|
122 |
strcpy(_name, name); |
|
123 |
} |
|
124 |
||
125 |
// get an argument value |
|
126 |
const char* arg(int i) const { |
|
127 |
assert(i>=0 && i<arg_count_max, "invalid argument index"); |
|
128 |
return _arg[i]; |
|
129 |
} |
|
130 |
||
131 |
// set an argument value |
|
132 |
void set_arg(int i, char* arg) { |
|
133 |
assert(i>=0 && i<arg_count_max, "invalid argument index"); |
|
134 |
if (arg == NULL) { |
|
135 |
_arg[i][0] = '\0'; |
|
136 |
} else { |
|
137 |
assert(strlen(arg) <= arg_length_max, "exceeds maximum argument length"); |
|
138 |
strcpy(_arg[i], arg); |
|
139 |
} |
|
140 |
} |
|
141 |
||
142 |
// create an operation of a given name |
|
143 |
AttachOperation(char* name) { |
|
144 |
set_name(name); |
|
145 |
for (int i=0; i<arg_count_max; i++) { |
|
146 |
set_arg(i, NULL); |
|
147 |
} |
|
148 |
} |
|
149 |
||
150 |
// complete operation by sending result code and any result data to the client |
|
151 |
virtual void complete(jint result, bufferedStream* result_stream) = 0; |
|
152 |
}; |
|
13975
2f7431485cfa
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
13195
diff
changeset
|
153 |
#endif // INCLUDE_SERVICES |
7397 | 154 |
|
155 |
#endif // SHARE_VM_SERVICES_ATTACHLISTENER_HPP |