73
74 // string type aliases used only in this file
75 typedef const char* ccstr;
76 typedef const char* ccstrlist; // represents string arguments which accumulate
77
78 enum FlagValueOrigin {
79 DEFAULT = 0,
80 COMMAND_LINE = 1,
81 ENVIRON_VAR = 2,
82 CONFIG_FILE = 3,
83 MANAGEMENT = 4,
84 ERGONOMIC = 5,
85 ATTACH_ON_DEMAND = 6,
86 INTERNAL = 99
87 };
88
89 struct Flag {
90 const char *type;
91 const char *name;
92 void* addr;
93 const char *kind;
94 FlagValueOrigin origin;
95
96 // points to all Flags static array
97 static Flag *flags;
98
99 // number of flags
100 static size_t numFlags;
101
102 static Flag* find_flag(char* name, size_t length);
103
104 bool is_bool() const { return strcmp(type, "bool") == 0; }
105 bool get_bool() const { return *((bool*) addr); }
106 void set_bool(bool value) { *((bool*) addr) = value; }
107
108 bool is_intx() const { return strcmp(type, "intx") == 0; }
109 intx get_intx() const { return *((intx*) addr); }
110 void set_intx(intx value) { *((intx*) addr) = value; }
111
112 bool is_uintx() const { return strcmp(type, "uintx") == 0; }
114 void set_uintx(uintx value) { *((uintx*) addr) = value; }
115
116 bool is_uint64_t() const { return strcmp(type, "uint64_t") == 0; }
117 uint64_t get_uint64_t() const { return *((uint64_t*) addr); }
118 void set_uint64_t(uint64_t value) { *((uint64_t*) addr) = value; }
119
120 bool is_double() const { return strcmp(type, "double") == 0; }
121 double get_double() const { return *((double*) addr); }
122 void set_double(double value) { *((double*) addr) = value; }
123
124 bool is_ccstr() const { return strcmp(type, "ccstr") == 0 || strcmp(type, "ccstrlist") == 0; }
125 bool ccstr_accumulates() const { return strcmp(type, "ccstrlist") == 0; }
126 ccstr get_ccstr() const { return *((ccstr*) addr); }
127 void set_ccstr(ccstr value) { *((ccstr*) addr) = value; }
128
129 bool is_unlocker() const;
130 bool is_unlocked() const;
131 bool is_writeable() const;
132 bool is_external() const;
133
134 void print_on(outputStream* st);
135 void print_as_flag(outputStream* st);
136 };
137
138 // debug flags control various aspects of the VM and are global accessible
139
140 // use FlagSetting to temporarily change some debug flag
141 // e.g. FlagSetting fs(DebugThisAndThat, true);
142 // restored to previous value upon leaving scope
143 class FlagSetting {
144 bool val;
145 bool* flag;
146 public:
147 FlagSetting(bool& fl, bool newValue) { flag = &fl; val = fl; fl = newValue; }
148 ~FlagSetting() { *flag = val; }
149 };
150
151
152 class CounterSetting {
153 intx* counter;
154 public:
194
195 static bool uint64_tAt(char* name, size_t len, uint64_t* value);
196 static bool uint64_tAt(char* name, uint64_t* value) { return uint64_tAt(name, strlen(name), value); }
197 static bool uint64_tAtPut(char* name, size_t len, uint64_t* value, FlagValueOrigin origin);
198 static bool uint64_tAtPut(char* name, uint64_t* value, FlagValueOrigin origin) { return uint64_tAtPut(name, strlen(name), value, origin); }
199
200 static bool doubleAt(char* name, size_t len, double* value);
201 static bool doubleAt(char* name, double* value) { return doubleAt(name, strlen(name), value); }
202 static bool doubleAtPut(char* name, size_t len, double* value, FlagValueOrigin origin);
203 static bool doubleAtPut(char* name, double* value, FlagValueOrigin origin) { return doubleAtPut(name, strlen(name), value, origin); }
204
205 static bool ccstrAt(char* name, size_t len, ccstr* value);
206 static bool ccstrAt(char* name, ccstr* value) { return ccstrAt(name, strlen(name), value); }
207 static bool ccstrAtPut(char* name, size_t len, ccstr* value, FlagValueOrigin origin);
208 static bool ccstrAtPut(char* name, ccstr* value, FlagValueOrigin origin) { return ccstrAtPut(name, strlen(name), value, origin); }
209
210 // Returns false if name is not a command line flag.
211 static bool wasSetOnCmdline(const char* name, bool* value);
212 static void printSetFlags();
213
214 static void printFlags();
215
216 static void verify() PRODUCT_RETURN;
217 };
218
219 // use this for flags that are true by default in the debug version but
220 // false in the optimized version, and vice versa
221 #ifdef ASSERT
222 #define trueInDebug true
223 #define falseInDebug false
224 #else
225 #define trueInDebug false
226 #define falseInDebug true
227 #endif
228
229 // use this for flags that are true per default in the product build
230 // but false in development builds, and vice versa
231 #ifdef PRODUCT
232 #define trueInProduct true
233 #define falseInProduct false
234 #else
2389 "Generate extra debugging info for non-safepoints in nmethods") \
2390 \
2391 diagnostic(bool, DebugInlinedCalls, true, \
2392 "If false, restricts profiled locations to the root method only") \
2393 \
2394 product(bool, PrintVMOptions, trueInDebug, \
2395 "Print flags that appeared on the command line") \
2396 \
2397 product(bool, IgnoreUnrecognizedVMOptions, false, \
2398 "Ignore unrecognized VM options") \
2399 \
2400 product(bool, PrintCommandLineFlags, false, \
2401 "Print flags specified on command line or set by ergonomics") \
2402 \
2403 product(bool, PrintFlagsInitial, false, \
2404 "Print all VM flags before argument processing and exit VM") \
2405 \
2406 product(bool, PrintFlagsFinal, false, \
2407 "Print all VM flags after argument and ergonomic processing") \
2408 \
2409 diagnostic(bool, SerializeVMOutput, true, \
2410 "Use a mutex to serialize output to tty and hotspot.log") \
2411 \
2412 diagnostic(bool, DisplayVMOutput, true, \
2413 "Display all VM output on the tty, independently of LogVMOutput") \
2414 \
2415 diagnostic(bool, LogVMOutput, trueInDebug, \
2416 "Save VM output to hotspot.log, or to LogFile") \
2417 \
2418 diagnostic(ccstr, LogFile, NULL, \
2419 "If LogVMOutput is on, save VM output to this file [hotspot.log]") \
2420 \
2421 product(ccstr, ErrorFile, NULL, \
2422 "If an error occurs, save the error data to this file " \
2423 "[default: ./hs_err_pid%p.log] (%p replaced with pid)") \
2424 \
2425 product(bool, DisplayVMOutputToStderr, false, \
2426 "If DisplayVMOutput is true, display all VM output to stderr") \
2427 \
2428 product(bool, DisplayVMOutputToStdout, false, \
|
73
74 // string type aliases used only in this file
75 typedef const char* ccstr;
76 typedef const char* ccstrlist; // represents string arguments which accumulate
77
78 enum FlagValueOrigin {
79 DEFAULT = 0,
80 COMMAND_LINE = 1,
81 ENVIRON_VAR = 2,
82 CONFIG_FILE = 3,
83 MANAGEMENT = 4,
84 ERGONOMIC = 5,
85 ATTACH_ON_DEMAND = 6,
86 INTERNAL = 99
87 };
88
89 struct Flag {
90 const char *type;
91 const char *name;
92 void* addr;
93
94 NOT_PRODUCT(const char *doc;)
95
96 const char *kind;
97 FlagValueOrigin origin;
98
99 // points to all Flags static array
100 static Flag *flags;
101
102 // number of flags
103 static size_t numFlags;
104
105 static Flag* find_flag(char* name, size_t length);
106
107 bool is_bool() const { return strcmp(type, "bool") == 0; }
108 bool get_bool() const { return *((bool*) addr); }
109 void set_bool(bool value) { *((bool*) addr) = value; }
110
111 bool is_intx() const { return strcmp(type, "intx") == 0; }
112 intx get_intx() const { return *((intx*) addr); }
113 void set_intx(intx value) { *((intx*) addr) = value; }
114
115 bool is_uintx() const { return strcmp(type, "uintx") == 0; }
117 void set_uintx(uintx value) { *((uintx*) addr) = value; }
118
119 bool is_uint64_t() const { return strcmp(type, "uint64_t") == 0; }
120 uint64_t get_uint64_t() const { return *((uint64_t*) addr); }
121 void set_uint64_t(uint64_t value) { *((uint64_t*) addr) = value; }
122
123 bool is_double() const { return strcmp(type, "double") == 0; }
124 double get_double() const { return *((double*) addr); }
125 void set_double(double value) { *((double*) addr) = value; }
126
127 bool is_ccstr() const { return strcmp(type, "ccstr") == 0 || strcmp(type, "ccstrlist") == 0; }
128 bool ccstr_accumulates() const { return strcmp(type, "ccstrlist") == 0; }
129 ccstr get_ccstr() const { return *((ccstr*) addr); }
130 void set_ccstr(ccstr value) { *((ccstr*) addr) = value; }
131
132 bool is_unlocker() const;
133 bool is_unlocked() const;
134 bool is_writeable() const;
135 bool is_external() const;
136
137 void print_on(outputStream* st, bool withComments = false );
138 void print_as_flag(outputStream* st);
139 };
140
141 // debug flags control various aspects of the VM and are global accessible
142
143 // use FlagSetting to temporarily change some debug flag
144 // e.g. FlagSetting fs(DebugThisAndThat, true);
145 // restored to previous value upon leaving scope
146 class FlagSetting {
147 bool val;
148 bool* flag;
149 public:
150 FlagSetting(bool& fl, bool newValue) { flag = &fl; val = fl; fl = newValue; }
151 ~FlagSetting() { *flag = val; }
152 };
153
154
155 class CounterSetting {
156 intx* counter;
157 public:
197
198 static bool uint64_tAt(char* name, size_t len, uint64_t* value);
199 static bool uint64_tAt(char* name, uint64_t* value) { return uint64_tAt(name, strlen(name), value); }
200 static bool uint64_tAtPut(char* name, size_t len, uint64_t* value, FlagValueOrigin origin);
201 static bool uint64_tAtPut(char* name, uint64_t* value, FlagValueOrigin origin) { return uint64_tAtPut(name, strlen(name), value, origin); }
202
203 static bool doubleAt(char* name, size_t len, double* value);
204 static bool doubleAt(char* name, double* value) { return doubleAt(name, strlen(name), value); }
205 static bool doubleAtPut(char* name, size_t len, double* value, FlagValueOrigin origin);
206 static bool doubleAtPut(char* name, double* value, FlagValueOrigin origin) { return doubleAtPut(name, strlen(name), value, origin); }
207
208 static bool ccstrAt(char* name, size_t len, ccstr* value);
209 static bool ccstrAt(char* name, ccstr* value) { return ccstrAt(name, strlen(name), value); }
210 static bool ccstrAtPut(char* name, size_t len, ccstr* value, FlagValueOrigin origin);
211 static bool ccstrAtPut(char* name, ccstr* value, FlagValueOrigin origin) { return ccstrAtPut(name, strlen(name), value, origin); }
212
213 // Returns false if name is not a command line flag.
214 static bool wasSetOnCmdline(const char* name, bool* value);
215 static void printSetFlags();
216
217 static void printFlags(bool withComments = false );
218
219 static void verify() PRODUCT_RETURN;
220 };
221
222 // use this for flags that are true by default in the debug version but
223 // false in the optimized version, and vice versa
224 #ifdef ASSERT
225 #define trueInDebug true
226 #define falseInDebug false
227 #else
228 #define trueInDebug false
229 #define falseInDebug true
230 #endif
231
232 // use this for flags that are true per default in the product build
233 // but false in development builds, and vice versa
234 #ifdef PRODUCT
235 #define trueInProduct true
236 #define falseInProduct false
237 #else
2392 "Generate extra debugging info for non-safepoints in nmethods") \
2393 \
2394 diagnostic(bool, DebugInlinedCalls, true, \
2395 "If false, restricts profiled locations to the root method only") \
2396 \
2397 product(bool, PrintVMOptions, trueInDebug, \
2398 "Print flags that appeared on the command line") \
2399 \
2400 product(bool, IgnoreUnrecognizedVMOptions, false, \
2401 "Ignore unrecognized VM options") \
2402 \
2403 product(bool, PrintCommandLineFlags, false, \
2404 "Print flags specified on command line or set by ergonomics") \
2405 \
2406 product(bool, PrintFlagsInitial, false, \
2407 "Print all VM flags before argument processing and exit VM") \
2408 \
2409 product(bool, PrintFlagsFinal, false, \
2410 "Print all VM flags after argument and ergonomic processing") \
2411 \
2412 notproduct(bool, PrintFlagsWithComments, false, \
2413 "Print all VM flags with default values and descriptions and exit")\
2414 \
2415 diagnostic(bool, SerializeVMOutput, true, \
2416 "Use a mutex to serialize output to tty and hotspot.log") \
2417 \
2418 diagnostic(bool, DisplayVMOutput, true, \
2419 "Display all VM output on the tty, independently of LogVMOutput") \
2420 \
2421 diagnostic(bool, LogVMOutput, trueInDebug, \
2422 "Save VM output to hotspot.log, or to LogFile") \
2423 \
2424 diagnostic(ccstr, LogFile, NULL, \
2425 "If LogVMOutput is on, save VM output to this file [hotspot.log]") \
2426 \
2427 product(ccstr, ErrorFile, NULL, \
2428 "If an error occurs, save the error data to this file " \
2429 "[default: ./hs_err_pid%p.log] (%p replaced with pid)") \
2430 \
2431 product(bool, DisplayVMOutputToStderr, false, \
2432 "If DisplayVMOutput is true, display all VM output to stderr") \
2433 \
2434 product(bool, DisplayVMOutputToStdout, false, \
|