523 // when Thread::current() does not work yet so we cannot create a
524 // ThreadsListHandle that is common to both thread-specific and
525 // global code paths.
526
527 // event_type must be valid
528 if (!JvmtiEventController::is_valid_event_type(event_type)) {
529 return JVMTI_ERROR_INVALID_EVENT_TYPE;
530 }
531
532 bool enabled = (mode == JVMTI_ENABLE);
533
534 // assure that needed capabilities are present
535 if (enabled && !JvmtiUtil::has_event_capability(event_type, get_capabilities())) {
536 return JVMTI_ERROR_MUST_POSSESS_CAPABILITY;
537 }
538
539 if (event_type == JVMTI_EVENT_CLASS_FILE_LOAD_HOOK && enabled) {
540 record_class_file_load_hook_enabled();
541 }
542
543 if (event_type == JVMTI_EVENT_SAMPLED_OBJECT_ALLOC) {
544 if (enabled) {
545 ThreadHeapSampler::enable();
546 } else {
547 ThreadHeapSampler::disable();
548 }
549 }
550 JvmtiEventController::set_user_enabled(this, (JavaThread*) NULL, event_type, enabled);
551 } else {
552 // We have a specified event_thread.
553 JavaThread* java_thread = NULL;
554 ThreadsListHandle tlh;
555 jvmtiError err = JvmtiExport::cv_external_thread_to_JavaThread(tlh.list(), event_thread, &java_thread, NULL);
556 if (err != JVMTI_ERROR_NONE) {
557 return err;
558 }
559
560 // event_type must be valid
561 if (!JvmtiEventController::is_valid_event_type(event_type)) {
562 return JVMTI_ERROR_INVALID_EVENT_TYPE;
563 }
564
565 // global events cannot be controlled at thread level.
566 if (JvmtiEventController::is_global_event(event_type)) {
567 return JVMTI_ERROR_ILLEGAL_ARGUMENT;
568 }
569
|
523 // when Thread::current() does not work yet so we cannot create a
524 // ThreadsListHandle that is common to both thread-specific and
525 // global code paths.
526
527 // event_type must be valid
528 if (!JvmtiEventController::is_valid_event_type(event_type)) {
529 return JVMTI_ERROR_INVALID_EVENT_TYPE;
530 }
531
532 bool enabled = (mode == JVMTI_ENABLE);
533
534 // assure that needed capabilities are present
535 if (enabled && !JvmtiUtil::has_event_capability(event_type, get_capabilities())) {
536 return JVMTI_ERROR_MUST_POSSESS_CAPABILITY;
537 }
538
539 if (event_type == JVMTI_EVENT_CLASS_FILE_LOAD_HOOK && enabled) {
540 record_class_file_load_hook_enabled();
541 }
542
543 JvmtiEventController::set_user_enabled(this, (JavaThread*) NULL, event_type, enabled);
544 } else {
545 // We have a specified event_thread.
546 JavaThread* java_thread = NULL;
547 ThreadsListHandle tlh;
548 jvmtiError err = JvmtiExport::cv_external_thread_to_JavaThread(tlh.list(), event_thread, &java_thread, NULL);
549 if (err != JVMTI_ERROR_NONE) {
550 return err;
551 }
552
553 // event_type must be valid
554 if (!JvmtiEventController::is_valid_event_type(event_type)) {
555 return JVMTI_ERROR_INVALID_EVENT_TYPE;
556 }
557
558 // global events cannot be controlled at thread level.
559 if (JvmtiEventController::is_global_event(event_type)) {
560 return JVMTI_ERROR_ILLEGAL_ARGUMENT;
561 }
562
|