src/hotspot/share/services/diagnosticArgument.hpp
author coleenp
Thu, 10 Jan 2019 15:13:51 -0500
changeset 53244 9807daeb47c4
parent 50600 8e17fffa0a4b
permissions -rw-r--r--
8216167: Update include guards to reflect correct directories Summary: Use script and some manual fixup to fix directores names in include guards. Reviewed-by: lfoltan, eosterlund, kbarrett
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 50600
diff changeset
     2
 * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
     4
 *
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
     7
 * published by the Free Software Foundation.
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
     8
 *
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    13
 * accompanied this code).
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    14
 *
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    18
 *
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    21
 * questions.
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    22
 *
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    23
 */
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    24
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 50600
diff changeset
    25
#ifndef SHARE_SERVICES_DIAGNOSTICARGUMENT_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 50600
diff changeset
    26
#define SHARE_SERVICES_DIAGNOSTICARGUMENT_HPP
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    27
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    28
#include "classfile/vmSymbols.hpp"
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    29
#include "memory/allocation.hpp"
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    30
#include "runtime/os.hpp"
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    31
#include "runtime/thread.hpp"
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    32
#include "utilities/exceptions.hpp"
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    33
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 12262
diff changeset
    34
class StringArrayArgument : public CHeapObj<mtInternal> {
11776
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11209
diff changeset
    35
private:
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11209
diff changeset
    36
  GrowableArray<char*>* _array;
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11209
diff changeset
    37
public:
48157
7c4d43c26352 8192061: Clean up allocation.inline.hpp includes
stefank
parents: 47216
diff changeset
    38
  StringArrayArgument();
7c4d43c26352 8192061: Clean up allocation.inline.hpp includes
stefank
parents: 47216
diff changeset
    39
  ~StringArrayArgument();
7c4d43c26352 8192061: Clean up allocation.inline.hpp includes
stefank
parents: 47216
diff changeset
    40
7c4d43c26352 8192061: Clean up allocation.inline.hpp includes
stefank
parents: 47216
diff changeset
    41
  void add(const char* str, size_t len);
7c4d43c26352 8192061: Clean up allocation.inline.hpp includes
stefank
parents: 47216
diff changeset
    42
11776
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11209
diff changeset
    43
  GrowableArray<char*>* array() {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11209
diff changeset
    44
    return _array;
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11209
diff changeset
    45
  }
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11209
diff changeset
    46
};
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11209
diff changeset
    47
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11209
diff changeset
    48
class NanoTimeArgument {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11209
diff changeset
    49
public:
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11209
diff changeset
    50
  jlong _nanotime;
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11209
diff changeset
    51
  jlong _time;
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11209
diff changeset
    52
  char _unit[3];
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11209
diff changeset
    53
};
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11209
diff changeset
    54
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11209
diff changeset
    55
class MemorySizeArgument {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11209
diff changeset
    56
public:
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11209
diff changeset
    57
  u8 _size;
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11209
diff changeset
    58
  u8 _val;
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11209
diff changeset
    59
  char _multiplier;
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11209
diff changeset
    60
};
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11209
diff changeset
    61
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    62
class GenDCmdArgument : public ResourceObj {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    63
protected:
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    64
  GenDCmdArgument* _next;
50600
8e17fffa0a4b 8204958: Minor cleanups for the diagnostic framework
stuefe
parents: 48157
diff changeset
    65
  const char* const _name;
8e17fffa0a4b 8204958: Minor cleanups for the diagnostic framework
stuefe
parents: 48157
diff changeset
    66
  const char* const _description;
8e17fffa0a4b 8204958: Minor cleanups for the diagnostic framework
stuefe
parents: 48157
diff changeset
    67
  const char* const _type;
8e17fffa0a4b 8204958: Minor cleanups for the diagnostic framework
stuefe
parents: 48157
diff changeset
    68
  const char* const _default_string;
8e17fffa0a4b 8204958: Minor cleanups for the diagnostic framework
stuefe
parents: 48157
diff changeset
    69
  bool              _is_set;
8e17fffa0a4b 8204958: Minor cleanups for the diagnostic framework
stuefe
parents: 48157
diff changeset
    70
  const bool        _is_mandatory;
11776
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11209
diff changeset
    71
  bool             _allow_multiple;
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    72
  GenDCmdArgument(const char* name, const char* description, const char* type,
50600
8e17fffa0a4b 8204958: Minor cleanups for the diagnostic framework
stuefe
parents: 48157
diff changeset
    73
                  const char* default_string, bool mandatory)
8e17fffa0a4b 8204958: Minor cleanups for the diagnostic framework
stuefe
parents: 48157
diff changeset
    74
    : _next(NULL), _name(name), _description(description), _type(type),
8e17fffa0a4b 8204958: Minor cleanups for the diagnostic framework
stuefe
parents: 48157
diff changeset
    75
      _default_string(default_string), _is_set(false), _is_mandatory(mandatory),
8e17fffa0a4b 8204958: Minor cleanups for the diagnostic framework
stuefe
parents: 48157
diff changeset
    76
      _allow_multiple(false) {}
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    77
public:
50600
8e17fffa0a4b 8204958: Minor cleanups for the diagnostic framework
stuefe
parents: 48157
diff changeset
    78
  const char* name() const        { return _name; }
8e17fffa0a4b 8204958: Minor cleanups for the diagnostic framework
stuefe
parents: 48157
diff changeset
    79
  const char* description() const { return _description; }
8e17fffa0a4b 8204958: Minor cleanups for the diagnostic framework
stuefe
parents: 48157
diff changeset
    80
  const char* type() const        { return _type; }
8e17fffa0a4b 8204958: Minor cleanups for the diagnostic framework
stuefe
parents: 48157
diff changeset
    81
  const char* default_string() const { return _default_string; }
8e17fffa0a4b 8204958: Minor cleanups for the diagnostic framework
stuefe
parents: 48157
diff changeset
    82
  bool is_set() const             { return _is_set; }
8e17fffa0a4b 8204958: Minor cleanups for the diagnostic framework
stuefe
parents: 48157
diff changeset
    83
  void set_is_set(bool b)         { _is_set = b; }
8e17fffa0a4b 8204958: Minor cleanups for the diagnostic framework
stuefe
parents: 48157
diff changeset
    84
  bool allow_multiple() const     { return _allow_multiple; }
8e17fffa0a4b 8204958: Minor cleanups for the diagnostic framework
stuefe
parents: 48157
diff changeset
    85
  bool is_mandatory() const       { return _is_mandatory; }
8e17fffa0a4b 8204958: Minor cleanups for the diagnostic framework
stuefe
parents: 48157
diff changeset
    86
  bool has_value() const          { return _is_set || _default_string != NULL; }
8e17fffa0a4b 8204958: Minor cleanups for the diagnostic framework
stuefe
parents: 48157
diff changeset
    87
  bool has_default() const        { return _default_string != NULL; }
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    88
  void read_value(const char* str, size_t len, TRAPS);
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    89
  virtual void parse_value(const char* str, size_t len, TRAPS) = 0;
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    90
  virtual void init_value(TRAPS) = 0;
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    91
  virtual void reset(TRAPS) = 0;
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    92
  virtual void cleanup() = 0;
50600
8e17fffa0a4b 8204958: Minor cleanups for the diagnostic framework
stuefe
parents: 48157
diff changeset
    93
  virtual void value_as_str(char* buf, size_t len) const = 0;
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    94
  void set_next(GenDCmdArgument* arg) {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    95
    _next = arg;
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    96
  }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    97
  GenDCmdArgument* next() {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    98
    return _next;
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    99
  }
12262
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents: 11776
diff changeset
   100
50600
8e17fffa0a4b 8204958: Minor cleanups for the diagnostic framework
stuefe
parents: 48157
diff changeset
   101
  void to_string(jlong l, char* buf, size_t len) const;
8e17fffa0a4b 8204958: Minor cleanups for the diagnostic framework
stuefe
parents: 48157
diff changeset
   102
  void to_string(bool b, char* buf, size_t len) const;
8e17fffa0a4b 8204958: Minor cleanups for the diagnostic framework
stuefe
parents: 48157
diff changeset
   103
  void to_string(char* c, char* buf, size_t len) const;
8e17fffa0a4b 8204958: Minor cleanups for the diagnostic framework
stuefe
parents: 48157
diff changeset
   104
  void to_string(NanoTimeArgument n, char* buf, size_t len) const;
8e17fffa0a4b 8204958: Minor cleanups for the diagnostic framework
stuefe
parents: 48157
diff changeset
   105
  void to_string(MemorySizeArgument f, char* buf, size_t len) const;
8e17fffa0a4b 8204958: Minor cleanups for the diagnostic framework
stuefe
parents: 48157
diff changeset
   106
  void to_string(StringArrayArgument* s, char* buf, size_t len) const;
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   107
};
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   108
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   109
template <class ArgType> class DCmdArgument: public GenDCmdArgument {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   110
private:
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   111
  ArgType _value;
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   112
public:
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   113
  DCmdArgument(const char* name, const char* description, const char* type,
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   114
               bool mandatory) :
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   115
               GenDCmdArgument(name, description, type, NULL, mandatory) { }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   116
  DCmdArgument(const char* name, const char* description, const char* type,
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   117
               bool mandatory, const char* defaultvalue) :
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   118
               GenDCmdArgument(name, description, type, defaultvalue, mandatory)
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   119
               { }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   120
  ~DCmdArgument() { destroy_value(); }
50600
8e17fffa0a4b 8204958: Minor cleanups for the diagnostic framework
stuefe
parents: 48157
diff changeset
   121
  ArgType value() const { return _value;}
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   122
  void set_value(ArgType v) { _value = v; }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   123
  void reset(TRAPS) {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   124
    destroy_value();
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   125
    init_value(CHECK);
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   126
    _is_set = false;
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   127
  }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   128
  void cleanup() {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   129
    destroy_value();
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   130
  }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   131
  void parse_value(const char* str, size_t len, TRAPS);
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   132
  void init_value(TRAPS);
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   133
  void destroy_value();
50600
8e17fffa0a4b 8204958: Minor cleanups for the diagnostic framework
stuefe
parents: 48157
diff changeset
   134
  void value_as_str(char *buf, size_t len) const { to_string(_value, buf, len);}
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   135
};
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   136
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 50600
diff changeset
   137
#endif // SHARE_SERVICES_DIAGNOSTICARGUMENT_HPP