221 // instance. Allocation in the C-heap is required when the diagnostic command
222 // is accessed by several threads (for instance to perform asynchronous
223 // execution).
224 // To ensure a proper cleanup, it's highly recommended to use a DCmdMark for
225 // each diagnostic command instance. In case of a C-heap allocated diagnostic
226 // command instance, the DCmdMark must be created in the context of the last
227 // thread that will access the instance.
228 class DCmd : public ResourceObj {
229 protected:
230 outputStream* _output;
231 bool _is_heap_allocated;
232 public:
233 DCmd(outputStream* output, bool heap_allocated) {
234 _output = output;
235 _is_heap_allocated = heap_allocated;
236 }
237
238 static const char* name() { return "No Name";}
239 static const char* description() { return "No Help";}
240 static const char* disabled_message() { return "Diagnostic command currently disabled"; }
241 static const char* impact() { return "Low: No impact"; }
242 static int num_arguments() { return 0; }
243 outputStream* output() { return _output; }
244 bool is_heap_allocated() { return _is_heap_allocated; }
245 virtual void print_help(const char* name) {
246 output()->print_cr("Syntax: %s", name);
247 }
248 virtual void parse(CmdLine* line, char delim, TRAPS) {
249 DCmdArgIter iter(line->args_addr(), line->args_len(), delim);
250 bool has_arg = iter.next(CHECK);
251 if (has_arg) {
252 THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
253 "Unknown argument in diagnostic command");
254 }
255 }
256 virtual void execute(TRAPS) { }
257 virtual void reset(TRAPS) { }
258 virtual void cleanup() { }
259
260 // support for the JMX interface
261 virtual GrowableArray<const char*>* argument_name_array() {
262 GrowableArray<const char*>* array = new GrowableArray<const char*>(0);
263 return array;
264 }
265 virtual GrowableArray<DCmdArgumentInfo*>* argument_info_array() {
266 GrowableArray<DCmdArgumentInfo*>* array = new GrowableArray<DCmdArgumentInfo*>(0);
267 return array;
268 }
269
270 // main method to invoke the framework
271 static void parse_and_execute(outputStream* out, const char* cmdline,
272 char delim, TRAPS);
273 };
|
221 // instance. Allocation in the C-heap is required when the diagnostic command
222 // is accessed by several threads (for instance to perform asynchronous
223 // execution).
224 // To ensure a proper cleanup, it's highly recommended to use a DCmdMark for
225 // each diagnostic command instance. In case of a C-heap allocated diagnostic
226 // command instance, the DCmdMark must be created in the context of the last
227 // thread that will access the instance.
228 class DCmd : public ResourceObj {
229 protected:
230 outputStream* _output;
231 bool _is_heap_allocated;
232 public:
233 DCmd(outputStream* output, bool heap_allocated) {
234 _output = output;
235 _is_heap_allocated = heap_allocated;
236 }
237
238 static const char* name() { return "No Name";}
239 static const char* description() { return "No Help";}
240 static const char* disabled_message() { return "Diagnostic command currently disabled"; }
241 // The impact() method returns a description of the intrusiveness of the diagnostic
242 // command on the Java Virtual Machine behavior. The rational for this method is that some
243 // diagnostic commands can seriously disrupt the behavior of the Java Virtual Machine
244 // (for instance a Thread Dump for an application with several tens of thousands of threads,
245 // or a Head Dump with a 40GB+ heap size) and other diagnostic commands have no serious
246 // impact on the JVM (for instance, getting the command line arguments or the JVM version).
247 // The recommended format for the description is <impact level>: [longer description],
248 // where the impact level is selected among this list: {Low, Medium, High}. The optional
249 // longer description can provide more specific details like the fact that Thread Dump
250 // impact depends on the heap size.
251 static const char* impact() { return "Low: No impact"; }
252 static int num_arguments() { return 0; }
253 outputStream* output() { return _output; }
254 bool is_heap_allocated() { return _is_heap_allocated; }
255 virtual void print_help(const char* name) {
256 output()->print_cr("Syntax: %s", name);
257 }
258 virtual void parse(CmdLine* line, char delim, TRAPS) {
259 DCmdArgIter iter(line->args_addr(), line->args_len(), delim);
260 bool has_arg = iter.next(CHECK);
261 if (has_arg) {
262 THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
263 "Argument list of diagnostic command should be empty.");
264 }
265 }
266 virtual void execute(TRAPS) { }
267 virtual void reset(TRAPS) { }
268 virtual void cleanup() { }
269
270 // support for the JMX interface
271 virtual GrowableArray<const char*>* argument_name_array() {
272 GrowableArray<const char*>* array = new GrowableArray<const char*>(0);
273 return array;
274 }
275 virtual GrowableArray<DCmdArgumentInfo*>* argument_info_array() {
276 GrowableArray<DCmdArgumentInfo*>* array = new GrowableArray<DCmdArgumentInfo*>(0);
277 return array;
278 }
279
280 // main method to invoke the framework
281 static void parse_and_execute(outputStream* out, const char* cmdline,
282 char delim, TRAPS);
283 };
|