Mercurial > hg > truffle
comparison src/share/vm/runtime/globals.cpp @ 103:38a50dd839cf
6619271: The -Xprintflags causes the VM to segv
Summary: add null checks
Reviewed-by: jrose, kvn
author | never |
---|---|
date | Thu, 03 Apr 2008 10:20:44 -0700 |
parents | 183f41cf8bfe |
children | ba764ed4b6f2 |
comparison
equal
deleted
inserted
replaced
102:f96100ac3d12 | 103:38a50dd839cf |
---|---|
66 if (is_bool()) st->print("%-16s", get_bool() ? "true" : "false"); | 66 if (is_bool()) st->print("%-16s", get_bool() ? "true" : "false"); |
67 if (is_intx()) st->print("%-16ld", get_intx()); | 67 if (is_intx()) st->print("%-16ld", get_intx()); |
68 if (is_uintx()) st->print("%-16lu", get_uintx()); | 68 if (is_uintx()) st->print("%-16lu", get_uintx()); |
69 if (is_ccstr()) { | 69 if (is_ccstr()) { |
70 const char* cp = get_ccstr(); | 70 const char* cp = get_ccstr(); |
71 const char* eol; | 71 if (cp != NULL) { |
72 while ((eol = strchr(cp, '\n')) != NULL) { | 72 const char* eol; |
73 char format_buffer[FORMAT_BUFFER_LEN]; | 73 while ((eol = strchr(cp, '\n')) != NULL) { |
74 size_t llen = pointer_delta(eol, cp, sizeof(char)); | 74 char format_buffer[FORMAT_BUFFER_LEN]; |
75 jio_snprintf(format_buffer, FORMAT_BUFFER_LEN, | 75 size_t llen = pointer_delta(eol, cp, sizeof(char)); |
76 "%%." SIZE_FORMAT "s", llen); | 76 jio_snprintf(format_buffer, FORMAT_BUFFER_LEN, |
77 st->print(format_buffer, cp); | 77 "%%." SIZE_FORMAT "s", llen); |
78 st->cr(); | 78 st->print(format_buffer, cp); |
79 cp = eol+1; | 79 st->cr(); |
80 st->print("%5s %-35s += ", "", name); | 80 cp = eol+1; |
81 st->print("%5s %-35s += ", "", name); | |
82 } | |
83 st->print("%-16s", cp); | |
81 } | 84 } |
82 st->print("%-16s", cp); | |
83 } | 85 } |
84 st->print(" %s", kind); | 86 st->print(" %s", kind); |
85 st->cr(); | 87 st->cr(); |
86 } | 88 } |
87 | 89 |
92 st->print("-XX:%s=" INTX_FORMAT, name, get_intx()); | 94 st->print("-XX:%s=" INTX_FORMAT, name, get_intx()); |
93 } else if (is_uintx()) { | 95 } else if (is_uintx()) { |
94 st->print("-XX:%s=" UINTX_FORMAT, name, get_uintx()); | 96 st->print("-XX:%s=" UINTX_FORMAT, name, get_uintx()); |
95 } else if (is_ccstr()) { | 97 } else if (is_ccstr()) { |
96 st->print("-XX:%s=", name); | 98 st->print("-XX:%s=", name); |
97 // Need to turn embedded '\n's back into separate arguments | 99 const char* cp = get_ccstr(); |
98 // Not so efficient to print one character at a time, | 100 if (cp != NULL) { |
99 // but the choice is to do the transformation to a buffer | 101 // Need to turn embedded '\n's back into separate arguments |
100 // and print that. And this need not be efficient. | 102 // Not so efficient to print one character at a time, |
101 for (const char* cp = get_ccstr(); *cp != '\0'; cp += 1) { | 103 // but the choice is to do the transformation to a buffer |
102 switch (*cp) { | 104 // and print that. And this need not be efficient. |
103 default: | 105 for (; *cp != '\0'; cp += 1) { |
104 st->print("%c", *cp); | 106 switch (*cp) { |
105 break; | 107 default: |
106 case '\n': | 108 st->print("%c", *cp); |
107 st->print(" -XX:%s=", name); | 109 break; |
108 break; | 110 case '\n': |
111 st->print(" -XX:%s=", name); | |
112 break; | |
113 } | |
109 } | 114 } |
110 } | 115 } |
111 } else { | 116 } else { |
112 ShouldNotReachHere(); | 117 ShouldNotReachHere(); |
113 } | 118 } |