< prev index next >

src/share/vm/services/diagnosticArgument.cpp

Print this page
rev 8910 : full patch for jfr
   1 /*
   2  * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
   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  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 263 
 264 template <> void DCmdArgument<StringArrayArgument*>::init_value(TRAPS) {
 265   _value = new StringArrayArgument();
 266   _allow_multiple = true;
 267   if (has_default()) {
 268     fatal("StringArrayArgument cannot have default value");
 269   }
 270 }
 271 
 272 template <> void DCmdArgument<StringArrayArgument*>::destroy_value() {
 273   if (_value != NULL) {
 274     delete _value;
 275     set_value(NULL);
 276   }
 277 }
 278 
 279 template <> void DCmdArgument<MemorySizeArgument>::parse_value(const char* str,
 280                                                   size_t len, TRAPS) {
 281   if (str == NULL) {
 282     THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
 283               "Integer parsing error nanotime value: syntax error");
 284   }
 285 
 286   if (*str == '-') {
 287     THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
 288                "Parsing error memory size value: negative values not allowed");
 289   }
 290   int res = sscanf(str, UINT64_FORMAT "%c", &_value._val, &_value._multiplier);
 291   if (res == 2) {
 292      switch (_value._multiplier) {
 293       case 'k': case 'K':
 294          _value._size = _value._val * 1024;
 295          break;
 296       case 'm': case 'M':
 297          _value._size = _value._val * 1024 * 1024;
 298          break;
 299       case 'g': case 'G':
 300          _value._size = _value._val * 1024 * 1024 * 1024;
 301          break;
 302        default:
 303          _value._size = _value._val;


   1 /*
   2  * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
   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  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 263 
 264 template <> void DCmdArgument<StringArrayArgument*>::init_value(TRAPS) {
 265   _value = new StringArrayArgument();
 266   _allow_multiple = true;
 267   if (has_default()) {
 268     fatal("StringArrayArgument cannot have default value");
 269   }
 270 }
 271 
 272 template <> void DCmdArgument<StringArrayArgument*>::destroy_value() {
 273   if (_value != NULL) {
 274     delete _value;
 275     set_value(NULL);
 276   }
 277 }
 278 
 279 template <> void DCmdArgument<MemorySizeArgument>::parse_value(const char* str,
 280                                                   size_t len, TRAPS) {
 281   if (str == NULL) {
 282     THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
 283               "Parsing error memory size value: syntax error, value is null\n");
 284   }
 285 
 286   if (*str == '-') {
 287     THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
 288                "Parsing error memory size value: negative values not allowed");
 289   }
 290   int res = sscanf(str, UINT64_FORMAT "%c", &_value._val, &_value._multiplier);
 291   if (res == 2) {
 292      switch (_value._multiplier) {
 293       case 'k': case 'K':
 294          _value._size = _value._val * 1024;
 295          break;
 296       case 'm': case 'M':
 297          _value._size = _value._val * 1024 * 1024;
 298          break;
 299       case 'g': case 'G':
 300          _value._size = _value._val * 1024 * 1024 * 1024;
 301          break;
 302        default:
 303          _value._size = _value._val;


< prev index next >