Mercurial > hg > truffle
annotate src/share/vm/services/diagnosticArgument.cpp @ 5274:e72dd6533eb9
documented importance of nmethod::_graal_compiled_method wrt code unloading and GC
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 23 Apr 2012 15:42:30 +0200 |
parents | f1cb6f9cfe21 |
children | 51612f0c0a79 |
rev | line source |
---|---|
4133 | 1 /* |
4849
520830f632e7
7131346: Parsing of boolean arguments to diagnostic commands is broken
fparain
parents:
4133
diff
changeset
|
2 * Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved. |
4133 | 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 * | |
23 */ | |
24 | |
25 #include "precompiled.hpp" | |
26 #include "memory/allocation.inline.hpp" | |
27 #include "runtime/thread.hpp" | |
28 #include "services/diagnosticArgument.hpp" | |
29 | |
30 void GenDCmdArgument::read_value(const char* str, size_t len, TRAPS) { | |
4932
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
31 /* NOTE:Some argument types doesn't require a value, |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
32 * for instance boolean arguments: "enableFeatureX". is |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
33 * equivalent to "enableFeatureX=true". In these cases, |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
34 * str will be null. This is perfectly valid. |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
35 * All argument types must perform null checks on str. |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
36 */ |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
37 |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
38 if (is_set() && !allow_multiple()) { |
4133 | 39 THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), |
4932
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
40 "Duplicates in diagnostic command arguments\n"); |
4133 | 41 } |
42 parse_value(str, len, CHECK); | |
43 set_is_set(true); | |
44 } | |
45 | |
46 template <> void DCmdArgument<jlong>::parse_value(const char* str, | |
47 size_t len, TRAPS) { | |
4932
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
48 if (str == NULL || sscanf(str, INT64_FORMAT, &_value) != 1) { |
4133 | 49 THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), |
4932
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
50 "Integer parsing error in diagnostic command arguments\n"); |
4133 | 51 } |
52 } | |
53 | |
54 template <> void DCmdArgument<jlong>::init_value(TRAPS) { | |
55 if (has_default()) { | |
56 this->parse_value(_default_string, strlen(_default_string), THREAD); | |
57 if (HAS_PENDING_EXCEPTION) { | |
58 fatal("Default string must be parsable"); | |
59 } | |
60 } else { | |
61 set_value(0); | |
62 } | |
63 } | |
64 | |
65 template <> void DCmdArgument<jlong>::destroy_value() { } | |
66 | |
67 template <> void DCmdArgument<bool>::parse_value(const char* str, | |
68 size_t len, TRAPS) { | |
4849
520830f632e7
7131346: Parsing of boolean arguments to diagnostic commands is broken
fparain
parents:
4133
diff
changeset
|
69 // len is the length of the current token starting at str |
4133 | 70 if (len == 0) { |
71 set_value(true); | |
72 } else { | |
4849
520830f632e7
7131346: Parsing of boolean arguments to diagnostic commands is broken
fparain
parents:
4133
diff
changeset
|
73 if (len == strlen("true") && strncasecmp(str, "true", len) == 0) { |
4133 | 74 set_value(true); |
4849
520830f632e7
7131346: Parsing of boolean arguments to diagnostic commands is broken
fparain
parents:
4133
diff
changeset
|
75 } else if (len == strlen("false") && strncasecmp(str, "false", len) == 0) { |
4133 | 76 set_value(false); |
77 } else { | |
78 THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), | |
79 "Boolean parsing error in diagnostic command arguments"); | |
80 } | |
81 } | |
82 } | |
83 | |
84 template <> void DCmdArgument<bool>::init_value(TRAPS) { | |
85 if (has_default()) { | |
86 this->parse_value(_default_string, strlen(_default_string), THREAD); | |
87 if (HAS_PENDING_EXCEPTION) { | |
88 fatal("Default string must be parsable"); | |
89 } | |
90 } else { | |
91 set_value(false); | |
92 } | |
93 } | |
94 | |
95 template <> void DCmdArgument<bool>::destroy_value() { } | |
96 | |
97 template <> void DCmdArgument<char*>::parse_value(const char* str, | |
98 size_t len, TRAPS) { | |
4932
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
99 if (str == NULL) { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
100 _value = NULL; |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
101 } else { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
102 _value = NEW_C_HEAP_ARRAY(char, len+1); |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
103 strncpy(_value, str, len); |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
104 _value[len] = 0; |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
105 } |
4133 | 106 } |
107 | |
108 template <> void DCmdArgument<char*>::init_value(TRAPS) { | |
4932
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
109 if (has_default() && _default_string != NULL) { |
4133 | 110 this->parse_value(_default_string, strlen(_default_string), THREAD); |
111 if (HAS_PENDING_EXCEPTION) { | |
4932
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
112 fatal("Default string must be parsable"); |
4133 | 113 } |
114 } else { | |
115 set_value(NULL); | |
116 } | |
117 } | |
118 | |
119 template <> void DCmdArgument<char*>::destroy_value() { | |
120 if (_value != NULL) { | |
121 FREE_C_HEAP_ARRAY(char, _value); | |
122 set_value(NULL); | |
123 } | |
124 } | |
4932
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
125 |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
126 template <> void DCmdArgument<NanoTimeArgument>::parse_value(const char* str, |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
127 size_t len, TRAPS) { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
128 if (str == NULL) { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
129 THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
130 "Integer parsing error nanotime value: syntax error"); |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
131 } |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
132 |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
133 int argc = sscanf(str, INT64_FORMAT , &_value._time); |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
134 if (argc != 1) { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
135 THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
136 "Integer parsing error nanotime value: syntax error"); |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
137 } |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
138 size_t idx = 0; |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
139 while(idx < len && isdigit(str[idx])) { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
140 idx++; |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
141 } |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
142 if (idx == len) { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
143 // only accept missing unit if the value is 0 |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
144 if (_value._time != 0) { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
145 THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
146 "Integer parsing error nanotime value: unit required"); |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
147 } else { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
148 _value._nanotime = 0; |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
149 strcpy(_value._unit, "ns"); |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
150 return; |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
151 } |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
152 } else if(len - idx > 2) { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
153 THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
154 "Integer parsing error nanotime value: illegal unit"); |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
155 } else { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
156 strncpy(_value._unit, &str[idx], len - idx); |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
157 /*Write an extra null termination. This is safe because _value._unit |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
158 * is declared as char[3], and length is checked to be not larger than |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
159 * two above. Also, this is necessary, since length might be 1, and the |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
160 * default value already in the string is ns, which is two chars. |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
161 */ |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
162 _value._unit[len-idx] = '\0'; |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
163 } |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
164 |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
165 if (strcmp(_value._unit, "ns") == 0) { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
166 _value._nanotime = _value._time; |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
167 } else if (strcmp(_value._unit, "us") == 0) { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
168 _value._nanotime = _value._time * 1000; |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
169 } else if (strcmp(_value._unit, "ms") == 0) { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
170 _value._nanotime = _value._time * 1000 * 1000; |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
171 } else if (strcmp(_value._unit, "s") == 0) { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
172 _value._nanotime = _value._time * 1000 * 1000 * 1000; |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
173 } else if (strcmp(_value._unit, "m") == 0) { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
174 _value._nanotime = _value._time * 60 * 1000 * 1000 * 1000; |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
175 } else if (strcmp(_value._unit, "h") == 0) { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
176 _value._nanotime = _value._time * 60 * 60 * 1000 * 1000 * 1000; |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
177 } else if (strcmp(_value._unit, "d") == 0) { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
178 _value._nanotime = _value._time * 24 * 60 * 60 * 1000 * 1000 * 1000; |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
179 } else { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
180 THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
181 "Integer parsing error nanotime value: illegal unit"); |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
182 } |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
183 } |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
184 |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
185 template <> void DCmdArgument<NanoTimeArgument>::init_value(TRAPS) { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
186 if (has_default()) { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
187 this->parse_value(_default_string, strlen(_default_string), THREAD); |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
188 if (HAS_PENDING_EXCEPTION) { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
189 fatal("Default string must be parsable"); |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
190 } |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
191 } else { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
192 _value._time = 0; |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
193 _value._nanotime = 0; |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
194 strcmp(_value._unit, "ns"); |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
195 } |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
196 } |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
197 |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
198 template <> void DCmdArgument<NanoTimeArgument>::destroy_value() { } |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
199 |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
200 // WARNING StringArrayArgument can only be used as an option, it cannot be |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
201 // used as an argument with the DCmdParser |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
202 |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
203 template <> void DCmdArgument<StringArrayArgument*>::parse_value(const char* str, |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
204 size_t len, TRAPS) { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
205 _value->add(str,len); |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
206 } |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
207 |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
208 template <> void DCmdArgument<StringArrayArgument*>::init_value(TRAPS) { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
209 _value = new StringArrayArgument(); |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
210 _allow_multiple = true; |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
211 if (has_default()) { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
212 fatal("StringArrayArgument cannot have default value"); |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
213 } |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
214 } |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
215 |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
216 template <> void DCmdArgument<StringArrayArgument*>::destroy_value() { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
217 if (_value != NULL) { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
218 delete _value; |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
219 set_value(NULL); |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
220 } |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
221 } |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
222 |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
223 template <> void DCmdArgument<MemorySizeArgument>::parse_value(const char* str, |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
224 size_t len, TRAPS) { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
225 if (str == NULL) { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
226 THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
227 "Integer parsing error nanotime value: syntax error"); |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
228 } |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
229 |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
230 if (*str == '-') { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
231 THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
232 "Parsing error memory size value: negative values not allowed"); |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
233 } |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
234 int res = sscanf(str, UINT64_FORMAT "%c", &_value._val, &_value._multiplier); |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
235 if (res == 2) { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
236 switch (_value._multiplier) { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
237 case 'k': case 'K': |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
238 _value._size = _value._val * 1024; |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
239 break; |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
240 case 'm': case 'M': |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
241 _value._size = _value._val * 1024 * 1024; |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
242 break; |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
243 case 'g': case 'G': |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
244 _value._size = _value._val * 1024 * 1024 * 1024; |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
245 break; |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
246 default: |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
247 _value._size = _value._val; |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
248 _value._multiplier = ' '; |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
249 //default case should be to break with no error, since user |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
250 //can write size in bytes, or might have a delimiter and next arg |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
251 break; |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
252 } |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
253 } else if (res == 1) { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
254 _value._size = _value._val; |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
255 } else { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
256 THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
257 "Parsing error memory size value: invalid value"); |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
258 } |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
259 } |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
260 |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
261 template <> void DCmdArgument<MemorySizeArgument>::init_value(TRAPS) { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
262 if (has_default()) { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
263 this->parse_value(_default_string, strlen(_default_string), THREAD); |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
264 if (HAS_PENDING_EXCEPTION) { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
265 fatal("Default string must be parsable"); |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
266 } |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
267 } else { |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
268 _value._size = 0; |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
269 _value._val = 0; |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
270 _value._multiplier = ' '; |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
271 } |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
272 } |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
273 |
f1cb6f9cfe21
7145243: Need additional specializations for argument parsing framework
fparain
parents:
4849
diff
changeset
|
274 template <> void DCmdArgument<MemorySizeArgument>::destroy_value() { } |