Mercurial > hg > graal-compiler
annotate src/share/vm/services/attachListener.hpp @ 8002:8391fdd36e1f
Merge
author | dlong |
---|---|
date | Sun, 27 Jan 2013 01:07:09 -0800 |
parents | db9981fd3124 |
children | 3c9bc17b9403 |
rev | line source |
---|---|
0 | 1 /* |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6197
diff
changeset
|
2 * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 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" | |
8001
db9981fd3124
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
6856
diff
changeset
|
31 #include "utilities/macros.hpp" |
1972 | 32 |
0 | 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 #ifndef SERVICES_KERNEL | |
43 | |
44 class AttachOperation; | |
45 | |
46 typedef jint (*AttachOperationFunction)(AttachOperation* op, outputStream* out); | |
47 | |
48 struct AttachOperationFunctionInfo { | |
49 const char* name; | |
50 AttachOperationFunction func; | |
51 }; | |
52 #endif // SERVICES_KERNEL | |
53 | |
54 class AttachListener: AllStatic { | |
55 public: | |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6197
diff
changeset
|
56 static void init() NOT_SERVICES_RETURN; |
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6197
diff
changeset
|
57 static void abort() NOT_SERVICES_RETURN; |
0 | 58 |
59 // invoke to perform clean-up tasks when all clients detach | |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6197
diff
changeset
|
60 static void detachall() NOT_SERVICES_RETURN; |
0 | 61 |
62 // indicates if the Attach Listener needs to be created at startup | |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6197
diff
changeset
|
63 static bool init_at_startup() NOT_SERVICES_RETURN_(false); |
0 | 64 |
65 // indicates if we have a trigger to start the Attach Listener | |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6197
diff
changeset
|
66 static bool is_init_trigger() NOT_SERVICES_RETURN_(false); |
0 | 67 |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6197
diff
changeset
|
68 #if !INCLUDE_SERVICES |
0 | 69 static bool is_attach_supported() { return false; } |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6197
diff
changeset
|
70 #else |
0 | 71 private: |
72 static volatile bool _initialized; | |
73 | |
74 public: | |
75 static bool is_initialized() { return _initialized; } | |
76 static void set_initialized() { _initialized = true; } | |
77 | |
78 // indicates if this VM supports attach-on-demand | |
79 static bool is_attach_supported() { return !DisableAttachMechanism; } | |
80 | |
81 // platform specific initialization | |
82 static int pd_init(); | |
83 | |
84 // platform specific operation | |
85 static AttachOperationFunctionInfo* pd_find_operation(const char* name); | |
86 | |
87 // platform specific flag change | |
88 static jint pd_set_flag(AttachOperation* op, outputStream* out); | |
89 | |
90 // platform specific detachall | |
91 static void pd_detachall(); | |
92 | |
93 // platform specific data dump | |
94 static void pd_data_dump(); | |
95 | |
96 // dequeue the next operation | |
97 static AttachOperation* dequeue(); | |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6197
diff
changeset
|
98 #endif // !INCLUDE_SERVICES |
0 | 99 }; |
100 | |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6197
diff
changeset
|
101 #if INCLUDE_SERVICES |
6197 | 102 class AttachOperation: public CHeapObj<mtInternal> { |
0 | 103 public: |
104 enum { | |
105 name_length_max = 16, // maximum length of name | |
106 arg_length_max = 1024, // maximum length of argument | |
107 arg_count_max = 3 // maximum number of arguments | |
108 }; | |
109 | |
110 // name of special operation that can be enqueued when all | |
111 // clients detach | |
112 static char* detachall_operation_name() { return (char*)"detachall"; } | |
113 | |
114 private: | |
115 char _name[name_length_max+1]; | |
116 char _arg[arg_count_max][arg_length_max+1]; | |
117 | |
118 public: | |
119 const char* name() const { return _name; } | |
120 | |
121 // set the operation name | |
122 void set_name(char* name) { | |
123 assert(strlen(name) <= name_length_max, "exceeds maximum name length"); | |
124 strcpy(_name, name); | |
125 } | |
126 | |
127 // get an argument value | |
128 const char* arg(int i) const { | |
129 assert(i>=0 && i<arg_count_max, "invalid argument index"); | |
130 return _arg[i]; | |
131 } | |
132 | |
133 // set an argument value | |
134 void set_arg(int i, char* arg) { | |
135 assert(i>=0 && i<arg_count_max, "invalid argument index"); | |
136 if (arg == NULL) { | |
137 _arg[i][0] = '\0'; | |
138 } else { | |
139 assert(strlen(arg) <= arg_length_max, "exceeds maximum argument length"); | |
140 strcpy(_arg[i], arg); | |
141 } | |
142 } | |
143 | |
144 // create an operation of a given name | |
145 AttachOperation(char* name) { | |
146 set_name(name); | |
147 for (int i=0; i<arg_count_max; i++) { | |
148 set_arg(i, NULL); | |
149 } | |
150 } | |
151 | |
152 // complete operation by sending result code and any result data to the client | |
153 virtual void complete(jint result, bufferedStream* result_stream) = 0; | |
154 }; | |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6197
diff
changeset
|
155 #endif // INCLUDE_SERVICES |
1972 | 156 |
157 #endif // SHARE_VM_SERVICES_ATTACHLISTENER_HPP |