src/hotspot/share/services/diagnosticArgument.cpp
author coleenp
Wed, 13 Feb 2019 06:48:34 -0500
changeset 53738 7f3b27d9c22d
parent 50600 8e17fffa0a4b
child 53882 ca682d9d8db5
permissions -rw-r--r--
8212988: add recent class unloading events to the hs_err log Summary: also moved class unloading logging in expected place. Reviewed-by: never, stuefe
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
     1
/*
50600
8e17fffa0a4b 8204958: Minor cleanups for the diagnostic framework
stuefe
parents: 48157
diff changeset
     2
 * Copyright (c) 2011, 2018, 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
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    25
#include "precompiled.hpp"
47765
b7c7428eaab9 8189610: Reconcile jvm.h and all jvm_md.h between java.base and hotspot
coleenp
parents: 47216
diff changeset
    26
#include "jvm.h"
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    27
#include "memory/allocation.inline.hpp"
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 16697
diff changeset
    28
#include "memory/resourceArea.hpp"
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    29
#include "runtime/thread.hpp"
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    30
#include "services/diagnosticArgument.hpp"
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    31
48157
7c4d43c26352 8192061: Clean up allocation.inline.hpp includes
stefank
parents: 47765
diff changeset
    32
StringArrayArgument::StringArrayArgument() {
7c4d43c26352 8192061: Clean up allocation.inline.hpp includes
stefank
parents: 47765
diff changeset
    33
  _array = new(ResourceObj::C_HEAP, mtInternal)GrowableArray<char *>(32, true);
7c4d43c26352 8192061: Clean up allocation.inline.hpp includes
stefank
parents: 47765
diff changeset
    34
  assert(_array != NULL, "Sanity check");
7c4d43c26352 8192061: Clean up allocation.inline.hpp includes
stefank
parents: 47765
diff changeset
    35
}
7c4d43c26352 8192061: Clean up allocation.inline.hpp includes
stefank
parents: 47765
diff changeset
    36
7c4d43c26352 8192061: Clean up allocation.inline.hpp includes
stefank
parents: 47765
diff changeset
    37
StringArrayArgument::~StringArrayArgument() {
7c4d43c26352 8192061: Clean up allocation.inline.hpp includes
stefank
parents: 47765
diff changeset
    38
  for (int i=0; i<_array->length(); i++) {
7c4d43c26352 8192061: Clean up allocation.inline.hpp includes
stefank
parents: 47765
diff changeset
    39
    if(_array->at(i) != NULL) { // Safety check
7c4d43c26352 8192061: Clean up allocation.inline.hpp includes
stefank
parents: 47765
diff changeset
    40
      FREE_C_HEAP_ARRAY(char, _array->at(i));
7c4d43c26352 8192061: Clean up allocation.inline.hpp includes
stefank
parents: 47765
diff changeset
    41
    }
7c4d43c26352 8192061: Clean up allocation.inline.hpp includes
stefank
parents: 47765
diff changeset
    42
  }
7c4d43c26352 8192061: Clean up allocation.inline.hpp includes
stefank
parents: 47765
diff changeset
    43
  delete _array;
7c4d43c26352 8192061: Clean up allocation.inline.hpp includes
stefank
parents: 47765
diff changeset
    44
}
7c4d43c26352 8192061: Clean up allocation.inline.hpp includes
stefank
parents: 47765
diff changeset
    45
7c4d43c26352 8192061: Clean up allocation.inline.hpp includes
stefank
parents: 47765
diff changeset
    46
void StringArrayArgument::add(const char* str, size_t len) {
7c4d43c26352 8192061: Clean up allocation.inline.hpp includes
stefank
parents: 47765
diff changeset
    47
  if (str != NULL) {
7c4d43c26352 8192061: Clean up allocation.inline.hpp includes
stefank
parents: 47765
diff changeset
    48
    char* ptr = NEW_C_HEAP_ARRAY(char, len+1, mtInternal);
7c4d43c26352 8192061: Clean up allocation.inline.hpp includes
stefank
parents: 47765
diff changeset
    49
    strncpy(ptr, str, len);
7c4d43c26352 8192061: Clean up allocation.inline.hpp includes
stefank
parents: 47765
diff changeset
    50
    ptr[len] = 0;
7c4d43c26352 8192061: Clean up allocation.inline.hpp includes
stefank
parents: 47765
diff changeset
    51
    _array->append(ptr);
7c4d43c26352 8192061: Clean up allocation.inline.hpp includes
stefank
parents: 47765
diff changeset
    52
  }
7c4d43c26352 8192061: Clean up allocation.inline.hpp includes
stefank
parents: 47765
diff changeset
    53
}
7c4d43c26352 8192061: Clean up allocation.inline.hpp includes
stefank
parents: 47765
diff changeset
    54
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    55
void GenDCmdArgument::read_value(const char* str, size_t len, TRAPS) {
11776
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
    56
  /* NOTE:Some argument types doesn't require a value,
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
    57
   * for instance boolean arguments: "enableFeatureX". is
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
    58
   * equivalent to "enableFeatureX=true". In these cases,
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
    59
   * str will be null. This is perfectly valid.
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
    60
   * All argument types must perform null checks on str.
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
    61
   */
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
    62
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
    63
  if (is_set() && !allow_multiple()) {
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    64
    THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
11776
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
    65
            "Duplicates in diagnostic command arguments\n");
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    66
  }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    67
  parse_value(str, len, CHECK);
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    68
  set_is_set(true);
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    69
}
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
    70
50600
8e17fffa0a4b 8204958: Minor cleanups for the diagnostic framework
stuefe
parents: 48157
diff changeset
    71
void GenDCmdArgument::to_string(jlong l, char* buf, size_t len) const {
12262
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents: 11776
diff changeset
    72
  jio_snprintf(buf, len, INT64_FORMAT, l);
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents: 11776
diff changeset
    73
}
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents: 11776
diff changeset
    74
50600
8e17fffa0a4b 8204958: Minor cleanups for the diagnostic framework
stuefe
parents: 48157
diff changeset
    75
void GenDCmdArgument::to_string(bool b, char* buf, size_t len) const {
12262
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents: 11776
diff changeset
    76
  jio_snprintf(buf, len, b ? "true" : "false");
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents: 11776
diff changeset
    77
}
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents: 11776
diff changeset
    78
50600
8e17fffa0a4b 8204958: Minor cleanups for the diagnostic framework
stuefe
parents: 48157
diff changeset
    79
void GenDCmdArgument::to_string(NanoTimeArgument n, char* buf, size_t len) const {
12262
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents: 11776
diff changeset
    80
  jio_snprintf(buf, len, INT64_FORMAT, n._nanotime);
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents: 11776
diff changeset
    81
}
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents: 11776
diff changeset
    82
50600
8e17fffa0a4b 8204958: Minor cleanups for the diagnostic framework
stuefe
parents: 48157
diff changeset
    83
void GenDCmdArgument::to_string(MemorySizeArgument m, char* buf, size_t len) const {
12262
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents: 11776
diff changeset
    84
  jio_snprintf(buf, len, INT64_FORMAT, m._size);
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents: 11776
diff changeset
    85
}
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents: 11776
diff changeset
    86
50600
8e17fffa0a4b 8204958: Minor cleanups for the diagnostic framework
stuefe
parents: 48157
diff changeset
    87
void GenDCmdArgument::to_string(char* c, char* buf, size_t len) const {
20061
cf6e850c26db 7196151: ParserTest SEGv on solaris
allwin
parents: 18073
diff changeset
    88
  jio_snprintf(buf, len, "%s", (c != NULL) ? c : "");
12262
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents: 11776
diff changeset
    89
}
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents: 11776
diff changeset
    90
50600
8e17fffa0a4b 8204958: Minor cleanups for the diagnostic framework
stuefe
parents: 48157
diff changeset
    91
void GenDCmdArgument::to_string(StringArrayArgument* f, char* buf, size_t len) const {
12262
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents: 11776
diff changeset
    92
  int length = f->array()->length();
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents: 11776
diff changeset
    93
  size_t written = 0;
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents: 11776
diff changeset
    94
  buf[0] = 0;
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents: 11776
diff changeset
    95
  for (int i = 0; i < length; i++) {
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents: 11776
diff changeset
    96
    char* next_str = f->array()->at(i);
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents: 11776
diff changeset
    97
    size_t next_size = strlen(next_str);
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents: 11776
diff changeset
    98
    //Check if there's room left to write next element
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents: 11776
diff changeset
    99
    if (written + next_size > len) {
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents: 11776
diff changeset
   100
      return;
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents: 11776
diff changeset
   101
    }
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents: 11776
diff changeset
   102
    //Actually write element
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents: 11776
diff changeset
   103
    strcat(buf, next_str);
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents: 11776
diff changeset
   104
    written += next_size;
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents: 11776
diff changeset
   105
    //Check if there's room left for the comma
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents: 11776
diff changeset
   106
    if (i < length-1 && len - written > 0) {
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents: 11776
diff changeset
   107
      strcat(buf, ",");
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents: 11776
diff changeset
   108
    }
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents: 11776
diff changeset
   109
  }
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents: 11776
diff changeset
   110
}
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents: 11776
diff changeset
   111
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   112
template <> void DCmdArgument<jlong>::parse_value(const char* str,
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   113
                                                  size_t len, TRAPS) {
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 16697
diff changeset
   114
  int scanned = -1;
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 16697
diff changeset
   115
  if (str == NULL
31592
43f48e165466 8081202: Hotspot compile warning: "Invalid suffix on literal; C++11 requires a space between literal and identifier"
bpittore
parents: 27880
diff changeset
   116
      || sscanf(str, JLONG_FORMAT "%n", &_value, &scanned) != 1
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 16697
diff changeset
   117
      || (size_t)scanned != len)
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 16697
diff changeset
   118
  {
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 16697
diff changeset
   119
    ResourceMark rm;
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 16697
diff changeset
   120
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 16697
diff changeset
   121
    char* buf = NEW_RESOURCE_ARRAY(char, len + 1);
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 16697
diff changeset
   122
    strncpy(buf, str, len);
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 16697
diff changeset
   123
    buf[len] = '\0';
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 16697
diff changeset
   124
    Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbols::java_lang_IllegalArgumentException(),
39964
7e00eb091e5a 8159901: missing newline char in the exception messages in diagnosticArgument.cpp
ccheung
parents: 39413
diff changeset
   125
      "Integer parsing error in command argument '%s'. Could not parse: %s.\n", _name, buf);
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   126
  }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   127
}
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   128
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   129
template <> void DCmdArgument<jlong>::init_value(TRAPS) {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   130
  if (has_default()) {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   131
    this->parse_value(_default_string, strlen(_default_string), THREAD);
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   132
    if (HAS_PENDING_EXCEPTION) {
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 16697
diff changeset
   133
      fatal("Default string must be parseable");
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   134
    }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   135
  } else {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   136
    set_value(0);
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   137
  }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   138
}
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   139
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   140
template <> void DCmdArgument<jlong>::destroy_value() { }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   141
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   142
template <> void DCmdArgument<bool>::parse_value(const char* str,
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   143
                                                 size_t len, TRAPS) {
11596
3b9802e6c6a2 7131346: Parsing of boolean arguments to diagnostic commands is broken
fparain
parents: 11209
diff changeset
   144
  // len is the length of the current token starting at str
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   145
  if (len == 0) {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   146
    set_value(true);
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   147
  } else {
11596
3b9802e6c6a2 7131346: Parsing of boolean arguments to diagnostic commands is broken
fparain
parents: 11209
diff changeset
   148
    if (len == strlen("true") && strncasecmp(str, "true", len) == 0) {
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   149
       set_value(true);
11596
3b9802e6c6a2 7131346: Parsing of boolean arguments to diagnostic commands is broken
fparain
parents: 11209
diff changeset
   150
    } else if (len == strlen("false") && strncasecmp(str, "false", len) == 0) {
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   151
       set_value(false);
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   152
    } else {
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 16697
diff changeset
   153
      ResourceMark rm;
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 16697
diff changeset
   154
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 16697
diff changeset
   155
      char* buf = NEW_RESOURCE_ARRAY(char, len + 1);
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 16697
diff changeset
   156
      strncpy(buf, str, len);
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 16697
diff changeset
   157
      buf[len] = '\0';
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 16697
diff changeset
   158
      Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbols::java_lang_IllegalArgumentException(),
39964
7e00eb091e5a 8159901: missing newline char in the exception messages in diagnosticArgument.cpp
ccheung
parents: 39413
diff changeset
   159
        "Boolean parsing error in command argument '%s'. Could not parse: %s.\n", _name, buf);
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   160
    }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   161
  }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   162
}
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   163
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   164
template <> void DCmdArgument<bool>::init_value(TRAPS) {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   165
  if (has_default()) {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   166
    this->parse_value(_default_string, strlen(_default_string), THREAD);
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   167
    if (HAS_PENDING_EXCEPTION) {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   168
      fatal("Default string must be parsable");
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   169
    }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   170
  } else {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   171
    set_value(false);
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   172
  }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   173
}
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   174
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   175
template <> void DCmdArgument<bool>::destroy_value() { }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   176
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   177
template <> void DCmdArgument<char*>::parse_value(const char* str,
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   178
                                                  size_t len, TRAPS) {
11776
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   179
  if (str == NULL) {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   180
    _value = NULL;
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   181
  } else {
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 12262
diff changeset
   182
    _value = NEW_C_HEAP_ARRAY(char, len+1, mtInternal);
11776
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   183
    strncpy(_value, str, len);
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   184
    _value[len] = 0;
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   185
  }
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   186
}
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   187
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   188
template <> void DCmdArgument<char*>::init_value(TRAPS) {
11776
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   189
  if (has_default() && _default_string != NULL) {
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   190
    this->parse_value(_default_string, strlen(_default_string), THREAD);
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   191
    if (HAS_PENDING_EXCEPTION) {
11776
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   192
     fatal("Default string must be parsable");
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   193
    }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   194
  } else {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   195
    set_value(NULL);
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   196
  }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   197
}
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   198
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   199
template <> void DCmdArgument<char*>::destroy_value() {
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   200
  if (_value != NULL) {
27880
afb974a04396 8060074: os::free() takes MemoryTrackingLevel but doesn't need it
coleenp
parents: 20061
diff changeset
   201
    FREE_C_HEAP_ARRAY(char, _value);
11209
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   202
    set_value(NULL);
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   203
  }
110525ac80b0 7104647: Adding a diagnostic command framework
fparain
parents:
diff changeset
   204
}
11776
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   205
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   206
template <> void DCmdArgument<NanoTimeArgument>::parse_value(const char* str,
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   207
                                                 size_t len, TRAPS) {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   208
  if (str == NULL) {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   209
    THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
39964
7e00eb091e5a 8159901: missing newline char in the exception messages in diagnosticArgument.cpp
ccheung
parents: 39413
diff changeset
   210
              "Integer parsing error nanotime value: syntax error, value is null\n");
11776
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   211
  }
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   212
15228
e92acc84ade3 7102489: RFE: cleanup jlong typedef on __APPLE__and _LLP64 systems.
hseigel
parents: 13195
diff changeset
   213
  int argc = sscanf(str, JLONG_FORMAT, &_value._time);
11776
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   214
  if (argc != 1) {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   215
    THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
39964
7e00eb091e5a 8159901: missing newline char in the exception messages in diagnosticArgument.cpp
ccheung
parents: 39413
diff changeset
   216
              "Integer parsing error nanotime value: syntax error\n");
11776
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   217
  }
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   218
  size_t idx = 0;
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   219
  while(idx < len && isdigit(str[idx])) {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   220
    idx++;
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   221
  }
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   222
  if (idx == len) {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   223
    // only accept missing unit if the value is 0
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   224
    if (_value._time != 0) {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   225
      THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
39964
7e00eb091e5a 8159901: missing newline char in the exception messages in diagnosticArgument.cpp
ccheung
parents: 39413
diff changeset
   226
                "Integer parsing error nanotime value: unit required\n");
11776
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   227
    } else {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   228
      _value._nanotime = 0;
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   229
      strcpy(_value._unit, "ns");
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   230
      return;
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   231
    }
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   232
  } else if(len - idx > 2) {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   233
    THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
39964
7e00eb091e5a 8159901: missing newline char in the exception messages in diagnosticArgument.cpp
ccheung
parents: 39413
diff changeset
   234
              "Integer parsing error nanotime value: illegal unit\n");
11776
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   235
  } else {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   236
    strncpy(_value._unit, &str[idx], len - idx);
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   237
    /*Write an extra null termination. This is safe because _value._unit
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   238
     * is declared as char[3], and length is checked to be not larger than
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   239
     * two above. Also, this is necessary, since length might be 1, and the
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   240
     * default value already in the string is ns, which is two chars.
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   241
     */
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   242
    _value._unit[len-idx] = '\0';
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   243
  }
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   244
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   245
  if (strcmp(_value._unit, "ns") == 0) {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   246
    _value._nanotime = _value._time;
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   247
  } else if (strcmp(_value._unit, "us") == 0) {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   248
    _value._nanotime = _value._time * 1000;
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   249
  } else if (strcmp(_value._unit, "ms") == 0) {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   250
    _value._nanotime = _value._time * 1000 * 1000;
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   251
  } else if (strcmp(_value._unit, "s") == 0) {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   252
    _value._nanotime = _value._time * 1000 * 1000 * 1000;
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   253
  } else if (strcmp(_value._unit, "m") == 0) {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   254
    _value._nanotime = _value._time * 60 * 1000 * 1000 * 1000;
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   255
  } else if (strcmp(_value._unit, "h") == 0) {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   256
    _value._nanotime = _value._time * 60 * 60 * 1000 * 1000 * 1000;
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   257
  } else if (strcmp(_value._unit, "d") == 0) {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   258
    _value._nanotime = _value._time * 24 * 60 * 60 * 1000 * 1000 * 1000;
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   259
  } else {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   260
     THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
39964
7e00eb091e5a 8159901: missing newline char in the exception messages in diagnosticArgument.cpp
ccheung
parents: 39413
diff changeset
   261
               "Integer parsing error nanotime value: illegal unit\n");
11776
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   262
  }
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   263
}
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   264
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   265
template <> void DCmdArgument<NanoTimeArgument>::init_value(TRAPS) {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   266
  if (has_default()) {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   267
    this->parse_value(_default_string, strlen(_default_string), THREAD);
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   268
    if (HAS_PENDING_EXCEPTION) {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   269
      fatal("Default string must be parsable");
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   270
    }
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   271
  } else {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   272
    _value._time = 0;
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   273
    _value._nanotime = 0;
18073
f02460441ddc 8014431: cleanup warnings indicated by the -Wunused-value compiler option on linux
ccheung
parents: 18025
diff changeset
   274
    strcpy(_value._unit, "ns");
11776
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   275
  }
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   276
}
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   277
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   278
template <> void DCmdArgument<NanoTimeArgument>::destroy_value() { }
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   279
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   280
// WARNING StringArrayArgument can only be used as an option, it cannot be
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   281
// used as an argument with the DCmdParser
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   282
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   283
template <> void DCmdArgument<StringArrayArgument*>::parse_value(const char* str,
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   284
                                                  size_t len, TRAPS) {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   285
  _value->add(str,len);
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   286
}
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   287
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   288
template <> void DCmdArgument<StringArrayArgument*>::init_value(TRAPS) {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   289
  _value = new StringArrayArgument();
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   290
  _allow_multiple = true;
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   291
  if (has_default()) {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   292
    fatal("StringArrayArgument cannot have default value");
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   293
  }
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   294
}
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   295
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   296
template <> void DCmdArgument<StringArrayArgument*>::destroy_value() {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   297
  if (_value != NULL) {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   298
    delete _value;
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   299
    set_value(NULL);
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   300
  }
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   301
}
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   302
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   303
template <> void DCmdArgument<MemorySizeArgument>::parse_value(const char* str,
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   304
                                                  size_t len, TRAPS) {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   305
  if (str == NULL) {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   306
    THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
39964
7e00eb091e5a 8159901: missing newline char in the exception messages in diagnosticArgument.cpp
ccheung
parents: 39413
diff changeset
   307
               "Parsing error memory size value: syntax error, value is null\n");
11776
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   308
  }
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   309
  if (*str == '-') {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   310
    THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
39964
7e00eb091e5a 8159901: missing newline char in the exception messages in diagnosticArgument.cpp
ccheung
parents: 39413
diff changeset
   311
               "Parsing error memory size value: negative values not allowed\n");
11776
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   312
  }
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   313
  int res = sscanf(str, UINT64_FORMAT "%c", &_value._val, &_value._multiplier);
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   314
  if (res == 2) {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   315
     switch (_value._multiplier) {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   316
      case 'k': case 'K':
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   317
         _value._size = _value._val * 1024;
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   318
         break;
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   319
      case 'm': case 'M':
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   320
         _value._size = _value._val * 1024 * 1024;
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   321
         break;
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   322
      case 'g': case 'G':
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   323
         _value._size = _value._val * 1024 * 1024 * 1024;
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   324
         break;
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   325
       default:
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   326
         _value._size = _value._val;
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   327
         _value._multiplier = ' ';
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   328
         //default case should be to break with no error, since user
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   329
         //can write size in bytes, or might have a delimiter and next arg
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   330
         break;
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   331
     }
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   332
   } else if (res == 1) {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   333
     _value._size = _value._val;
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   334
   } else {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   335
     THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
39964
7e00eb091e5a 8159901: missing newline char in the exception messages in diagnosticArgument.cpp
ccheung
parents: 39413
diff changeset
   336
               "Parsing error memory size value: invalid value\n");
11776
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   337
   }
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   338
}
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   339
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   340
template <> void DCmdArgument<MemorySizeArgument>::init_value(TRAPS) {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   341
  if (has_default()) {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   342
    this->parse_value(_default_string, strlen(_default_string), THREAD);
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   343
    if (HAS_PENDING_EXCEPTION) {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   344
      fatal("Default string must be parsable");
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   345
    }
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   346
  } else {
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   347
    _value._size = 0;
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   348
    _value._val = 0;
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   349
    _value._multiplier = ' ';
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   350
  }
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   351
}
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   352
519643dbbefb 7145243: Need additional specializations for argument parsing framework
fparain
parents: 11596
diff changeset
   353
template <> void DCmdArgument<MemorySizeArgument>::destroy_value() { }