src/hotspot/share/services/diagnosticFramework.cpp
changeset 54623 1126f0607c70
parent 52448 bc5c7f63dbae
child 58503 726a3945e934
equal deleted inserted replaced
54622:a8dcacf95bff 54623:1126f0607c70
     1 /*
     1 /*
     2  * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
   435 GrowableArray<DCmdArgumentInfo*>* DCmdWithParser::argument_info_array() const {
   435 GrowableArray<DCmdArgumentInfo*>* DCmdWithParser::argument_info_array() const {
   436   return _dcmdparser.argument_info_array();
   436   return _dcmdparser.argument_info_array();
   437 }
   437 }
   438 
   438 
   439 void DCmdFactory::push_jmx_notification_request() {
   439 void DCmdFactory::push_jmx_notification_request() {
   440   MutexLockerEx ml(Service_lock, Mutex::_no_safepoint_check_flag);
   440   MutexLocker ml(Service_lock, Mutex::_no_safepoint_check_flag);
   441   _has_pending_jmx_notification = true;
   441   _has_pending_jmx_notification = true;
   442   Service_lock->notify_all();
   442   Service_lock->notify_all();
   443 }
   443 }
   444 
   444 
   445 void DCmdFactory::send_notification(TRAPS) {
   445 void DCmdFactory::send_notification(TRAPS) {
   453 void DCmdFactory::send_notification_internal(TRAPS) {
   453 void DCmdFactory::send_notification_internal(TRAPS) {
   454   ResourceMark rm(THREAD);
   454   ResourceMark rm(THREAD);
   455   HandleMark hm(THREAD);
   455   HandleMark hm(THREAD);
   456   bool notif = false;
   456   bool notif = false;
   457   {
   457   {
   458     MutexLockerEx ml(Service_lock, Mutex::_no_safepoint_check_flag);
   458     MutexLocker ml(Service_lock, Mutex::_no_safepoint_check_flag);
   459     notif = _has_pending_jmx_notification;
   459     notif = _has_pending_jmx_notification;
   460     _has_pending_jmx_notification = false;
   460     _has_pending_jmx_notification = false;
   461   }
   461   }
   462   if (notif) {
   462   if (notif) {
   463 
   463 
   492 }
   492 }
   493 
   493 
   494 bool DCmdFactory::_send_jmx_notification = false;
   494 bool DCmdFactory::_send_jmx_notification = false;
   495 
   495 
   496 DCmdFactory* DCmdFactory::factory(DCmdSource source, const char* name, size_t len) {
   496 DCmdFactory* DCmdFactory::factory(DCmdSource source, const char* name, size_t len) {
   497   MutexLockerEx ml(DCmdFactory_lock, Mutex::_no_safepoint_check_flag);
   497   MutexLocker ml(DCmdFactory_lock, Mutex::_no_safepoint_check_flag);
   498   DCmdFactory* factory = _DCmdFactoryList;
   498   DCmdFactory* factory = _DCmdFactoryList;
   499   while (factory != NULL) {
   499   while (factory != NULL) {
   500     if (strlen(factory->name()) == len &&
   500     if (strlen(factory->name()) == len &&
   501         strncmp(name, factory->name(), len) == 0) {
   501         strncmp(name, factory->name(), len) == 0) {
   502       if(factory->export_flags() & source) {
   502       if(factory->export_flags() & source) {
   509   }
   509   }
   510   return NULL;
   510   return NULL;
   511 }
   511 }
   512 
   512 
   513 int DCmdFactory::register_DCmdFactory(DCmdFactory* factory) {
   513 int DCmdFactory::register_DCmdFactory(DCmdFactory* factory) {
   514   MutexLockerEx ml(DCmdFactory_lock, Mutex::_no_safepoint_check_flag);
   514   MutexLocker ml(DCmdFactory_lock, Mutex::_no_safepoint_check_flag);
   515   factory->_next = _DCmdFactoryList;
   515   factory->_next = _DCmdFactoryList;
   516   _DCmdFactoryList = factory;
   516   _DCmdFactoryList = factory;
   517   if (_send_jmx_notification && !factory->_hidden
   517   if (_send_jmx_notification && !factory->_hidden
   518       && (factory->_export_flags & DCmd_Source_MBean)) {
   518       && (factory->_export_flags & DCmd_Source_MBean)) {
   519     DCmdFactory::push_jmx_notification_request();
   519     DCmdFactory::push_jmx_notification_request();
   534   THROW_MSG_NULL(vmSymbols::java_lang_IllegalArgumentException(),
   534   THROW_MSG_NULL(vmSymbols::java_lang_IllegalArgumentException(),
   535              "Unknown diagnostic command");
   535              "Unknown diagnostic command");
   536 }
   536 }
   537 
   537 
   538 GrowableArray<const char*>* DCmdFactory::DCmd_list(DCmdSource source) {
   538 GrowableArray<const char*>* DCmdFactory::DCmd_list(DCmdSource source) {
   539   MutexLockerEx ml(DCmdFactory_lock, Mutex::_no_safepoint_check_flag);
   539   MutexLocker ml(DCmdFactory_lock, Mutex::_no_safepoint_check_flag);
   540   GrowableArray<const char*>* array = new GrowableArray<const char*>();
   540   GrowableArray<const char*>* array = new GrowableArray<const char*>();
   541   DCmdFactory* factory = _DCmdFactoryList;
   541   DCmdFactory* factory = _DCmdFactoryList;
   542   while (factory != NULL) {
   542   while (factory != NULL) {
   543     if (!factory->is_hidden() && (factory->export_flags() & source)) {
   543     if (!factory->is_hidden() && (factory->export_flags() & source)) {
   544       array->append(factory->name());
   544       array->append(factory->name());
   547   }
   547   }
   548   return array;
   548   return array;
   549 }
   549 }
   550 
   550 
   551 GrowableArray<DCmdInfo*>* DCmdFactory::DCmdInfo_list(DCmdSource source ) {
   551 GrowableArray<DCmdInfo*>* DCmdFactory::DCmdInfo_list(DCmdSource source ) {
   552   MutexLockerEx ml(DCmdFactory_lock, Mutex::_no_safepoint_check_flag);
   552   MutexLocker ml(DCmdFactory_lock, Mutex::_no_safepoint_check_flag);
   553   GrowableArray<DCmdInfo*>* array = new GrowableArray<DCmdInfo*>();
   553   GrowableArray<DCmdInfo*>* array = new GrowableArray<DCmdInfo*>();
   554   DCmdFactory* factory = _DCmdFactoryList;
   554   DCmdFactory* factory = _DCmdFactoryList;
   555   while (factory != NULL) {
   555   while (factory != NULL) {
   556     if (!factory->is_hidden() && (factory->export_flags() & source)) {
   556     if (!factory->is_hidden() && (factory->export_flags() & source)) {
   557       array->append(new DCmdInfo(factory->name(),
   557       array->append(new DCmdInfo(factory->name(),