39 THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), |
39 THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), |
40 "Duplicates in diagnostic command arguments\n"); |
40 "Duplicates in diagnostic command arguments\n"); |
41 } |
41 } |
42 parse_value(str, len, CHECK); |
42 parse_value(str, len, CHECK); |
43 set_is_set(true); |
43 set_is_set(true); |
|
44 } |
|
45 |
|
46 void GenDCmdArgument::to_string(jlong l, char* buf, size_t len) { |
|
47 jio_snprintf(buf, len, INT64_FORMAT, l); |
|
48 } |
|
49 |
|
50 void GenDCmdArgument::to_string(bool b, char* buf, size_t len) { |
|
51 jio_snprintf(buf, len, b ? "true" : "false"); |
|
52 } |
|
53 |
|
54 void GenDCmdArgument::to_string(NanoTimeArgument n, char* buf, size_t len) { |
|
55 jio_snprintf(buf, len, INT64_FORMAT, n._nanotime); |
|
56 } |
|
57 |
|
58 void GenDCmdArgument::to_string(MemorySizeArgument m, char* buf, size_t len) { |
|
59 jio_snprintf(buf, len, INT64_FORMAT, m._size); |
|
60 } |
|
61 |
|
62 void GenDCmdArgument::to_string(char* c, char* buf, size_t len) { |
|
63 jio_snprintf(buf, len, "%s", c); |
|
64 } |
|
65 |
|
66 void GenDCmdArgument::to_string(StringArrayArgument* f, char* buf, size_t len) { |
|
67 int length = f->array()->length(); |
|
68 size_t written = 0; |
|
69 buf[0] = 0; |
|
70 for (int i = 0; i < length; i++) { |
|
71 char* next_str = f->array()->at(i); |
|
72 size_t next_size = strlen(next_str); |
|
73 //Check if there's room left to write next element |
|
74 if (written + next_size > len) { |
|
75 return; |
|
76 } |
|
77 //Actually write element |
|
78 strcat(buf, next_str); |
|
79 written += next_size; |
|
80 //Check if there's room left for the comma |
|
81 if (i < length-1 && len - written > 0) { |
|
82 strcat(buf, ","); |
|
83 } |
|
84 } |
44 } |
85 } |
45 |
86 |
46 template <> void DCmdArgument<jlong>::parse_value(const char* str, |
87 template <> void DCmdArgument<jlong>::parse_value(const char* str, |
47 size_t len, TRAPS) { |
88 size_t len, TRAPS) { |
48 if (str == NULL || sscanf(str, INT64_FORMAT, &_value) != 1) { |
89 if (str == NULL || sscanf(str, INT64_FORMAT, &_value) != 1) { |