src/share/vm/services/attachListener.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 8024545 Sdiff src/share/vm/services

src/share/vm/services/attachListener.cpp

Print this page




 228     live_objects_only = strcmp(arg0, "-live") == 0;
 229   }
 230   VM_GC_HeapInspection heapop(out, live_objects_only /* request full gc */);
 231   VMThread::execute(&heapop);
 232   return JNI_OK;
 233 }
 234 
 235 // set a boolean global flag using value from AttachOperation
 236 static jint set_bool_flag(const char* name, AttachOperation* op, outputStream* out) {
 237   bool value = true;
 238   const char* arg1;
 239   if ((arg1 = op->arg(1)) != NULL) {
 240     int tmp;
 241     int n = sscanf(arg1, "%d", &tmp);
 242     if (n != 1) {
 243       out->print_cr("flag value must be a boolean (1 or 0)");
 244       return JNI_ERR;
 245     }
 246     value = (tmp != 0);
 247   }
 248   bool res = CommandLineFlags::boolAtPut((char*)name, &value, ATTACH_ON_DEMAND);
 249   if (! res) {
 250     out->print_cr("setting flag %s failed", name);
 251   }
 252   return res? JNI_OK : JNI_ERR;
 253 }
 254 
 255 // set a intx global flag using value from AttachOperation
 256 static jint set_intx_flag(const char* name, AttachOperation* op, outputStream* out) {
 257   intx value;
 258   const char* arg1;
 259   if ((arg1 = op->arg(1)) != NULL) {
 260     int n = sscanf(arg1, INTX_FORMAT, &value);
 261     if (n != 1) {
 262       out->print_cr("flag value must be an integer");
 263       return JNI_ERR;
 264     }
 265   }
 266   bool res = CommandLineFlags::intxAtPut((char*)name, &value, ATTACH_ON_DEMAND);
 267   if (! res) {
 268     out->print_cr("setting flag %s failed", name);
 269   }
 270 
 271   return res? JNI_OK : JNI_ERR;
 272 }
 273 
 274 // set a uintx global flag using value from AttachOperation
 275 static jint set_uintx_flag(const char* name, AttachOperation* op, outputStream* out) {
 276   uintx value;
 277   const char* arg1;
 278   if ((arg1 = op->arg(1)) != NULL) {
 279     int n = sscanf(arg1, UINTX_FORMAT, &value);
 280     if (n != 1) {
 281       out->print_cr("flag value must be an unsigned integer");
 282       return JNI_ERR;
 283     }
 284   }
 285   bool res = CommandLineFlags::uintxAtPut((char*)name, &value, ATTACH_ON_DEMAND);
 286   if (! res) {
 287     out->print_cr("setting flag %s failed", name);
 288   }
 289 
 290   return res? JNI_OK : JNI_ERR;
 291 }
 292 
 293 // set a uint64_t global flag using value from AttachOperation
 294 static jint set_uint64_t_flag(const char* name, AttachOperation* op, outputStream* out) {
 295   uint64_t value;
 296   const char* arg1;
 297   if ((arg1 = op->arg(1)) != NULL) {
 298     int n = sscanf(arg1, UINT64_FORMAT, &value);
 299     if (n != 1) {
 300       out->print_cr("flag value must be an unsigned 64-bit integer");
 301       return JNI_ERR;
 302     }
 303   }
 304   bool res = CommandLineFlags::uint64_tAtPut((char*)name, &value, ATTACH_ON_DEMAND);
 305   if (! res) {
 306     out->print_cr("setting flag %s failed", name);
 307   }
 308 
 309   return res? JNI_OK : JNI_ERR;
 310 }
 311 
 312 // set a string global flag using value from AttachOperation
 313 static jint set_ccstr_flag(const char* name, AttachOperation* op, outputStream* out) {
 314   const char* value;
 315   if ((value = op->arg(1)) == NULL) {
 316     out->print_cr("flag value must be a string");
 317     return JNI_ERR;
 318   }
 319   bool res = CommandLineFlags::ccstrAtPut((char*)name, &value, ATTACH_ON_DEMAND);
 320   if (res) {
 321     FREE_C_HEAP_ARRAY(char, value, mtInternal);
 322   } else {
 323     out->print_cr("setting flag %s failed", name);
 324   }
 325 
 326   return res? JNI_OK : JNI_ERR;
 327 }
 328 
 329 // Implementation of "setflag" command
 330 static jint set_flag(AttachOperation* op, outputStream* out) {
 331 
 332   const char* name = NULL;
 333   if ((name = op->arg(0)) == NULL) {
 334     out->print_cr("flag name is missing");
 335     return JNI_ERR;
 336   }
 337 
 338   Flag* f = Flag::find_flag((char*)name, strlen(name));
 339   if (f && f->is_external() && f->is_writeable()) {




 228     live_objects_only = strcmp(arg0, "-live") == 0;
 229   }
 230   VM_GC_HeapInspection heapop(out, live_objects_only /* request full gc */);
 231   VMThread::execute(&heapop);
 232   return JNI_OK;
 233 }
 234 
 235 // set a boolean global flag using value from AttachOperation
 236 static jint set_bool_flag(const char* name, AttachOperation* op, outputStream* out) {
 237   bool value = true;
 238   const char* arg1;
 239   if ((arg1 = op->arg(1)) != NULL) {
 240     int tmp;
 241     int n = sscanf(arg1, "%d", &tmp);
 242     if (n != 1) {
 243       out->print_cr("flag value must be a boolean (1 or 0)");
 244       return JNI_ERR;
 245     }
 246     value = (tmp != 0);
 247   }
 248   bool res = CommandLineFlags::boolAtPut((char*)name, &value, Flag::ATTACH_ON_DEMAND);
 249   if (! res) {
 250     out->print_cr("setting flag %s failed", name);
 251   }
 252   return res? JNI_OK : JNI_ERR;
 253 }
 254 
 255 // set a intx global flag using value from AttachOperation
 256 static jint set_intx_flag(const char* name, AttachOperation* op, outputStream* out) {
 257   intx value;
 258   const char* arg1;
 259   if ((arg1 = op->arg(1)) != NULL) {
 260     int n = sscanf(arg1, INTX_FORMAT, &value);
 261     if (n != 1) {
 262       out->print_cr("flag value must be an integer");
 263       return JNI_ERR;
 264     }
 265   }
 266   bool res = CommandLineFlags::intxAtPut((char*)name, &value, Flag::ATTACH_ON_DEMAND);
 267   if (! res) {
 268     out->print_cr("setting flag %s failed", name);
 269   }
 270 
 271   return res? JNI_OK : JNI_ERR;
 272 }
 273 
 274 // set a uintx global flag using value from AttachOperation
 275 static jint set_uintx_flag(const char* name, AttachOperation* op, outputStream* out) {
 276   uintx value;
 277   const char* arg1;
 278   if ((arg1 = op->arg(1)) != NULL) {
 279     int n = sscanf(arg1, UINTX_FORMAT, &value);
 280     if (n != 1) {
 281       out->print_cr("flag value must be an unsigned integer");
 282       return JNI_ERR;
 283     }
 284   }
 285   bool res = CommandLineFlags::uintxAtPut((char*)name, &value, Flag::ATTACH_ON_DEMAND);
 286   if (! res) {
 287     out->print_cr("setting flag %s failed", name);
 288   }
 289 
 290   return res? JNI_OK : JNI_ERR;
 291 }
 292 
 293 // set a uint64_t global flag using value from AttachOperation
 294 static jint set_uint64_t_flag(const char* name, AttachOperation* op, outputStream* out) {
 295   uint64_t value;
 296   const char* arg1;
 297   if ((arg1 = op->arg(1)) != NULL) {
 298     int n = sscanf(arg1, UINT64_FORMAT, &value);
 299     if (n != 1) {
 300       out->print_cr("flag value must be an unsigned 64-bit integer");
 301       return JNI_ERR;
 302     }
 303   }
 304   bool res = CommandLineFlags::uint64_tAtPut((char*)name, &value, Flag::ATTACH_ON_DEMAND);
 305   if (! res) {
 306     out->print_cr("setting flag %s failed", name);
 307   }
 308 
 309   return res? JNI_OK : JNI_ERR;
 310 }
 311 
 312 // set a string global flag using value from AttachOperation
 313 static jint set_ccstr_flag(const char* name, AttachOperation* op, outputStream* out) {
 314   const char* value;
 315   if ((value = op->arg(1)) == NULL) {
 316     out->print_cr("flag value must be a string");
 317     return JNI_ERR;
 318   }
 319   bool res = CommandLineFlags::ccstrAtPut((char*)name, &value, Flag::ATTACH_ON_DEMAND);
 320   if (res) {
 321     FREE_C_HEAP_ARRAY(char, value, mtInternal);
 322   } else {
 323     out->print_cr("setting flag %s failed", name);
 324   }
 325 
 326   return res? JNI_OK : JNI_ERR;
 327 }
 328 
 329 // Implementation of "setflag" command
 330 static jint set_flag(AttachOperation* op, outputStream* out) {
 331 
 332   const char* name = NULL;
 333   if ((name = op->arg(0)) == NULL) {
 334     out->print_cr("flag name is missing");
 335     return JNI_ERR;
 336   }
 337 
 338   Flag* f = Flag::find_flag((char*)name, strlen(name));
 339   if (f && f->is_external() && f->is_writeable()) {


src/share/vm/services/attachListener.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File