Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/jfr/dcmd/jfrDcmds.cpp
38920 views
/*1* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "classfile/javaClasses.hpp"26#include "classfile/vmSymbols.hpp"27#include "jfr/jfr.hpp"28#include "jfr/dcmd/jfrDcmds.hpp"29#include "jfr/jni/jfrJavaSupport.hpp"30#include "jfr/recorder/jfrRecorder.hpp"31#include "jfr/recorder/service/jfrOptionSet.hpp"32#include "memory/resourceArea.hpp"33#include "oops/oop.inline.hpp"34#include "oops/symbol.hpp"35#include "runtime/handles.inline.hpp"36#include "services/diagnosticArgument.hpp"37#include "services/diagnosticFramework.hpp"38#include "utilities/globalDefinitions.hpp"3940#ifdef _WINDOWS41#define JFR_FILENAME_EXAMPLE "C:\\Users\\user\\My Recording.jfr"42#endif4344#ifdef __APPLE__45#define JFR_FILENAME_EXAMPLE "/Users/user/My Recording.jfr"46#endif4748#ifndef JFR_FILENAME_EXAMPLE49#define JFR_FILENAME_EXAMPLE "/home/user/My Recording.jfr"50#endif5152// JNIHandle management5354// ------------------------------------------------------------------55// push_jni_handle_block56//57// Push on a new block of JNI handles.58static void push_jni_handle_block(Thread* const thread) {59DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_vm(thread));6061// Allocate a new block for JNI handles.62// Inlined code from jni_PushLocalFrame()63JNIHandleBlock* prev_handles = thread->active_handles();64JNIHandleBlock* entry_handles = JNIHandleBlock::allocate_block(thread);65assert(entry_handles != NULL && prev_handles != NULL, "should not be NULL");66entry_handles->set_pop_frame_link(prev_handles); // make sure prev handles get gc'd.67thread->set_active_handles(entry_handles);68}6970// ------------------------------------------------------------------71// pop_jni_handle_block72//73// Pop off the current block of JNI handles.74static void pop_jni_handle_block(Thread* const thread) {75DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_vm(thread));7677// Release our JNI handle block78JNIHandleBlock* entry_handles = thread->active_handles();79JNIHandleBlock* prev_handles = entry_handles->pop_frame_link();80// restore81thread->set_active_handles(prev_handles);82entry_handles->set_pop_frame_link(NULL);83JNIHandleBlock::release_block(entry_handles, thread); // may block84}8586class JNIHandleBlockManager : public StackObj {87private:88Thread* const _thread;89public:90JNIHandleBlockManager(Thread* thread) : _thread(thread) {91push_jni_handle_block(_thread);92}9394~JNIHandleBlockManager() {95pop_jni_handle_block(_thread);96}97};9899static bool is_disabled(outputStream* output) {100if (Jfr::is_disabled()) {101if (output != NULL) {102output->print_cr("Flight Recorder is disabled.\n");103}104return true;105}106return false;107}108109static bool is_recorder_instance_created(outputStream* output) {110if (!JfrRecorder::is_created()) {111if (output != NULL) {112output->print_cr("No available recordings.\n");113output->print_cr("Use JFR.start to start a recording.\n");114}115return false;116}117return true;118}119120static bool invalid_state(outputStream* out, TRAPS) {121DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_vm(THREAD));122return is_disabled(out);123}124125static void print_pending_exception(outputStream* output, oop throwable) {126assert(throwable != NULL, "invariant");127128oop msg = java_lang_Throwable::message(throwable);129130if (msg != NULL) {131char* text = java_lang_String::as_utf8_string(msg);132output->print_raw_cr(text);133}134}135136static void print_message(outputStream* output, const char* message) {137if (message != NULL) {138output->print_raw(message);139}140}141142static void handle_dcmd_result(outputStream* output,143const oop result,144const DCmdSource source,145TRAPS) {146DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_vm(THREAD));147assert(output != NULL, "invariant");148if (HAS_PENDING_EXCEPTION) {149print_pending_exception(output, PENDING_EXCEPTION);150// Don't clear excption on startup, JVM should fail initialization.151if (DCmd_Source_Internal != source) {152CLEAR_PENDING_EXCEPTION;153}154return;155}156157assert(!HAS_PENDING_EXCEPTION, "invariant");158159if (result != NULL) {160const char* result_chars = java_lang_String::as_utf8_string(result);161print_message(output, result_chars);162}163}164165static oop construct_dcmd_instance(JfrJavaArguments* args, TRAPS) {166assert(args != NULL, "invariant");167DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_vm(THREAD));168assert(args->klass() != NULL, "invariant");169args->set_name("<init>", CHECK_NULL);170args->set_signature("()V", CHECK_NULL);171JfrJavaSupport::new_object(args, CHECK_NULL);172return (oop)args->result()->get_jobject();173}174175JfrDumpFlightRecordingDCmd::JfrDumpFlightRecordingDCmd(outputStream* output,176bool heap) : DCmdWithParser(output, heap),177_name("name", "Recording name, e.g. \\\"My Recording\\\"", "STRING", false, NULL),178_filename("filename", "Copy recording data to file, e.g. \\\"" JFR_FILENAME_EXAMPLE "\\\"", "STRING", false),179_maxage("maxage", "Maximum duration to dump, in (s)econds, (m)inutes, (h)ours, or (d)ays, e.g. 60m, or 0 for no limit", "NANOTIME", false, "0"),180_maxsize("maxsize", "Maximum amount of bytes to dump, in (M)B or (G)B, e.g. 500M, or 0 for no limit", "MEMORY SIZE", false, "0"),181_begin("begin", "Point in time to dump data from, e.g. 09:00, 21:35:00, 2018-06-03T18:12:56.827Z, 2018-06-03T20:13:46.832, -10m, -3h, or -1d", "STRING", false),182_end("end", "Point in time to dump data to, e.g. 09:00, 21:35:00, 2018-06-03T18:12:56.827Z, 2018-06-03T20:13:46.832, -10m, -3h, or -1d", "STRING", false),183_path_to_gc_roots("path-to-gc-roots", "Collect path to GC roots", "BOOLEAN", false, "false") {184_dcmdparser.add_dcmd_option(&_name);185_dcmdparser.add_dcmd_option(&_filename);186_dcmdparser.add_dcmd_option(&_maxage);187_dcmdparser.add_dcmd_option(&_maxsize);188_dcmdparser.add_dcmd_option(&_begin);189_dcmdparser.add_dcmd_option(&_end);190_dcmdparser.add_dcmd_option(&_path_to_gc_roots);191};192193int JfrDumpFlightRecordingDCmd::num_arguments() {194ResourceMark rm;195JfrDumpFlightRecordingDCmd* dcmd = new JfrDumpFlightRecordingDCmd(NULL, false);196if (dcmd != NULL) {197DCmdMark mark(dcmd);198return dcmd->_dcmdparser.num_arguments();199}200return 0;201}202203void JfrDumpFlightRecordingDCmd::execute(DCmdSource source, TRAPS) {204DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_vm(THREAD));205206if (invalid_state(output(), THREAD) || !is_recorder_instance_created(output())) {207return;208}209210ResourceMark rm(THREAD);211HandleMark hm(THREAD);212JNIHandleBlockManager jni_handle_management(THREAD);213214JavaValue result(T_OBJECT);215JfrJavaArguments constructor_args(&result);216constructor_args.set_klass("jdk/jfr/internal/dcmd/DCmdDump", CHECK);217const oop dcmd = construct_dcmd_instance(&constructor_args, CHECK);218Handle h_dcmd_instance(THREAD, dcmd);219assert(h_dcmd_instance.not_null(), "invariant");220221jstring name = NULL;222if (_name.is_set() && _name.value() != NULL) {223name = JfrJavaSupport::new_string(_name.value(), CHECK);224}225226jstring filepath = NULL;227if (_filename.is_set() && _filename.value() != NULL) {228filepath = JfrJavaSupport::new_string(_filename.value(), CHECK);229}230231jobject maxage = NULL;232if (_maxage.is_set()) {233maxage = JfrJavaSupport::new_java_lang_Long(_maxage.value()._nanotime, CHECK);234}235236jobject maxsize = NULL;237if (_maxsize.is_set()) {238maxsize = JfrJavaSupport::new_java_lang_Long(_maxsize.value()._size, CHECK);239}240241jstring begin = NULL;242if (_begin.is_set() && _begin.value() != NULL) {243begin = JfrJavaSupport::new_string(_begin.value(), CHECK);244}245246jstring end = NULL;247if (_end.is_set() && _end.value() != NULL) {248end = JfrJavaSupport::new_string(_end.value(), CHECK);249}250251jobject path_to_gc_roots = NULL;252if (_path_to_gc_roots.is_set()) {253path_to_gc_roots = JfrJavaSupport::new_java_lang_Boolean(_path_to_gc_roots.value(), CHECK);254}255256static const char klass[] = "jdk/jfr/internal/dcmd/DCmdDump";257static const char method[] = "execute";258static const char signature[] = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Long;Ljava/lang/Long;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Boolean;)Ljava/lang/String;";259260JfrJavaArguments execute_args(&result, klass, method, signature, CHECK);261execute_args.set_receiver(h_dcmd_instance);262263// arguments264execute_args.push_jobject(name);265execute_args.push_jobject(filepath);266execute_args.push_jobject(maxage);267execute_args.push_jobject(maxsize);268execute_args.push_jobject(begin);269execute_args.push_jobject(end);270execute_args.push_jobject(path_to_gc_roots);271272JfrJavaSupport::call_virtual(&execute_args, THREAD);273handle_dcmd_result(output(), (oop)result.get_jobject(), source, THREAD);274}275276JfrCheckFlightRecordingDCmd::JfrCheckFlightRecordingDCmd(outputStream* output, bool heap) : DCmdWithParser(output, heap),277_name("name","Recording name, e.g. \\\"My Recording\\\" or omit to see all recordings","STRING",false, NULL),278_verbose("verbose","Print event settings for the recording(s)","BOOLEAN",279false, "false") {280_dcmdparser.add_dcmd_option(&_name);281_dcmdparser.add_dcmd_option(&_verbose);282};283284int JfrCheckFlightRecordingDCmd::num_arguments() {285ResourceMark rm;286JfrCheckFlightRecordingDCmd* dcmd = new JfrCheckFlightRecordingDCmd(NULL, false);287if (dcmd != NULL) {288DCmdMark mark(dcmd);289return dcmd->_dcmdparser.num_arguments();290}291return 0;292}293294void JfrCheckFlightRecordingDCmd::execute(DCmdSource source, TRAPS) {295DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_vm(THREAD));296297if (invalid_state(output(), THREAD) || !is_recorder_instance_created(output())) {298return;299}300301ResourceMark rm(THREAD);302HandleMark hm(THREAD);303JNIHandleBlockManager jni_handle_management(THREAD);304305JavaValue result(T_OBJECT);306JfrJavaArguments constructor_args(&result);307constructor_args.set_klass("jdk/jfr/internal/dcmd/DCmdCheck", CHECK);308const oop dcmd = construct_dcmd_instance(&constructor_args, CHECK);309Handle h_dcmd_instance(THREAD, dcmd);310assert(h_dcmd_instance.not_null(), "invariant");311312jstring name = NULL;313if (_name.is_set() && _name.value() != NULL) {314name = JfrJavaSupport::new_string(_name.value(), CHECK);315}316317jobject verbose = NULL;318if (_verbose.is_set()) {319verbose = JfrJavaSupport::new_java_lang_Boolean(_verbose.value(), CHECK);320}321322static const char klass[] = "jdk/jfr/internal/dcmd/DCmdCheck";323static const char method[] = "execute";324static const char signature[] = "(Ljava/lang/String;Ljava/lang/Boolean;)Ljava/lang/String;";325326JfrJavaArguments execute_args(&result, klass, method, signature, CHECK);327execute_args.set_receiver(h_dcmd_instance);328329// arguments330execute_args.push_jobject(name);331execute_args.push_jobject(verbose);332333JfrJavaSupport::call_virtual(&execute_args, THREAD);334handle_dcmd_result(output(), (oop)result.get_jobject(), source, THREAD);335}336337JfrStartFlightRecordingDCmd::JfrStartFlightRecordingDCmd(outputStream* output,338bool heap) : DCmdWithParser(output, heap),339_name("name", "Name that can be used to identify recording, e.g. \\\"My Recording\\\"", "STRING", false, NULL),340_settings("settings", "Settings file(s), e.g. profile or default. See JRE_HOME/lib/jfr", "STRING SET", false),341_delay("delay", "Delay recording start with (s)econds, (m)inutes), (h)ours), or (d)ays, e.g. 5h.", "NANOTIME", false, "0"),342_duration("duration", "Duration of recording in (s)econds, (m)inutes, (h)ours, or (d)ays, e.g. 300s.", "NANOTIME", false, "0"),343_filename("filename", "Resulting recording filename, e.g. \\\"" JFR_FILENAME_EXAMPLE "\\\"", "STRING", false),344_disk("disk", "Recording should be persisted to disk", "BOOLEAN", false),345_maxage("maxage", "Maximum time to keep recorded data (on disk) in (s)econds, (m)inutes, (h)ours, or (d)ays, e.g. 60m, or 0 for no limit", "NANOTIME", false, "0"),346_maxsize("maxsize", "Maximum amount of bytes to keep (on disk) in (k)B, (M)B or (G)B, e.g. 500M, or 0 for no limit", "MEMORY SIZE", false, "0"),347_dump_on_exit("dumponexit", "Dump running recording when JVM shuts down", "BOOLEAN", false),348_path_to_gc_roots("path-to-gc-roots", "Collect path to GC roots", "BOOLEAN", false, "false") {349_dcmdparser.add_dcmd_option(&_name);350_dcmdparser.add_dcmd_option(&_settings);351_dcmdparser.add_dcmd_option(&_delay);352_dcmdparser.add_dcmd_option(&_duration);353_dcmdparser.add_dcmd_option(&_disk);354_dcmdparser.add_dcmd_option(&_filename);355_dcmdparser.add_dcmd_option(&_maxage);356_dcmdparser.add_dcmd_option(&_maxsize);357_dcmdparser.add_dcmd_option(&_dump_on_exit);358_dcmdparser.add_dcmd_option(&_path_to_gc_roots);359};360361int JfrStartFlightRecordingDCmd::num_arguments() {362ResourceMark rm;363JfrStartFlightRecordingDCmd* dcmd = new JfrStartFlightRecordingDCmd(NULL, false);364if (dcmd != NULL) {365DCmdMark mark(dcmd);366return dcmd->_dcmdparser.num_arguments();367}368return 0;369}370371void JfrStartFlightRecordingDCmd::execute(DCmdSource source, TRAPS) {372DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_vm(THREAD));373374if (invalid_state(output(), THREAD)) {375return;376}377378ResourceMark rm(THREAD);379HandleMark hm(THREAD);380JNIHandleBlockManager jni_handle_management(THREAD);381382JavaValue result(T_OBJECT);383JfrJavaArguments constructor_args(&result);384constructor_args.set_klass("jdk/jfr/internal/dcmd/DCmdStart", THREAD);385const oop dcmd = construct_dcmd_instance(&constructor_args, CHECK);386Handle h_dcmd_instance(THREAD, dcmd);387assert(h_dcmd_instance.not_null(), "invariant");388389jstring name = NULL;390if (_name.is_set() && _name.value() != NULL) {391name = JfrJavaSupport::new_string(_name.value(), CHECK);392}393394jstring filename = NULL;395if (_filename.is_set() && _filename.value() != NULL) {396filename = JfrJavaSupport::new_string(_filename.value(), CHECK);397}398399jobject maxage = NULL;400if (_maxage.is_set()) {401maxage = JfrJavaSupport::new_java_lang_Long(_maxage.value()._nanotime, CHECK);402}403404jobject maxsize = NULL;405if (_maxsize.is_set()) {406maxsize = JfrJavaSupport::new_java_lang_Long(_maxsize.value()._size, CHECK);407}408409jobject duration = NULL;410if (_duration.is_set()) {411duration = JfrJavaSupport::new_java_lang_Long(_duration.value()._nanotime, CHECK);412}413414jobject delay = NULL;415if (_delay.is_set()) {416delay = JfrJavaSupport::new_java_lang_Long(_delay.value()._nanotime, CHECK);417}418419jobject disk = NULL;420if (_disk.is_set()) {421disk = JfrJavaSupport::new_java_lang_Boolean(_disk.value(), CHECK);422}423424jobject dump_on_exit = NULL;425if (_dump_on_exit.is_set()) {426dump_on_exit = JfrJavaSupport::new_java_lang_Boolean(_dump_on_exit.value(), CHECK);427}428429jobject path_to_gc_roots = NULL;430if (_path_to_gc_roots.is_set()) {431path_to_gc_roots = JfrJavaSupport::new_java_lang_Boolean(_path_to_gc_roots.value(), CHECK);432}433434jobjectArray settings = NULL;435if (_settings.is_set()) {436int length = _settings.value()->array()->length();437if (length == 1) {438const char* c_str = _settings.value()->array()->at(0);439if (strcmp(c_str, "none") == 0) {440length = 0;441}442}443settings = JfrJavaSupport::new_string_array(length, CHECK);444assert(settings != NULL, "invariant");445for (int i = 0; i < length; ++i) {446jobject element = JfrJavaSupport::new_string(_settings.value()->array()->at(i), CHECK);447assert(element != NULL, "invariant");448JfrJavaSupport::set_array_element(settings, element, i, CHECK);449}450} else {451settings = JfrJavaSupport::new_string_array(1, CHECK);452assert(settings != NULL, "invariant");453jobject element = JfrJavaSupport::new_string("default", CHECK);454assert(element != NULL, "invariant");455JfrJavaSupport::set_array_element(settings, element, 0, CHECK);456}457458static const char klass[] = "jdk/jfr/internal/dcmd/DCmdStart";459static const char method[] = "execute";460static const char signature[] = "(Ljava/lang/String;[Ljava/lang/String;Ljava/lang/Long;"461"Ljava/lang/Long;Ljava/lang/Boolean;Ljava/lang/String;"462"Ljava/lang/Long;Ljava/lang/Long;Ljava/lang/Boolean;Ljava/lang/Boolean;)Ljava/lang/String;";463464JfrJavaArguments execute_args(&result, klass, method, signature, CHECK);465execute_args.set_receiver(h_dcmd_instance);466467// arguments468execute_args.push_jobject(name);469execute_args.push_jobject(settings);470execute_args.push_jobject(delay);471execute_args.push_jobject(duration);472execute_args.push_jobject(disk);473execute_args.push_jobject(filename);474execute_args.push_jobject(maxage);475execute_args.push_jobject(maxsize);476execute_args.push_jobject(dump_on_exit);477execute_args.push_jobject(path_to_gc_roots);478479JfrJavaSupport::call_virtual(&execute_args, THREAD);480handle_dcmd_result(output(), (oop)result.get_jobject(), source, THREAD);481}482483JfrStopFlightRecordingDCmd::JfrStopFlightRecordingDCmd(outputStream* output,484bool heap) : DCmdWithParser(output, heap),485_name("name", "Recording text,.e.g \\\"My Recording\\\"", "STRING", true, NULL),486_filename("filename", "Copy recording data to file, e.g. \\\"" JFR_FILENAME_EXAMPLE "\\\"", "STRING", false, NULL) {487_dcmdparser.add_dcmd_option(&_name);488_dcmdparser.add_dcmd_option(&_filename);489};490491int JfrStopFlightRecordingDCmd::num_arguments() {492ResourceMark rm;493JfrStopFlightRecordingDCmd* dcmd = new JfrStopFlightRecordingDCmd(NULL, false);494if (dcmd != NULL) {495DCmdMark mark(dcmd);496return dcmd->_dcmdparser.num_arguments();497}498return 0;499}500501void JfrStopFlightRecordingDCmd::execute(DCmdSource source, TRAPS) {502DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_vm(THREAD));503504if (invalid_state(output(), THREAD) || !is_recorder_instance_created(output())) {505return;506}507508ResourceMark rm(THREAD);509HandleMark hm(THREAD);510JNIHandleBlockManager jni_handle_management(THREAD);511512JavaValue result(T_OBJECT);513JfrJavaArguments constructor_args(&result);514constructor_args.set_klass("jdk/jfr/internal/dcmd/DCmdStop", CHECK);515const oop dcmd = construct_dcmd_instance(&constructor_args, CHECK);516Handle h_dcmd_instance(THREAD, dcmd);517assert(h_dcmd_instance.not_null(), "invariant");518519jstring name = NULL;520if (_name.is_set() && _name.value() != NULL) {521name = JfrJavaSupport::new_string(_name.value(), CHECK);522}523524jstring filepath = NULL;525if (_filename.is_set() && _filename.value() != NULL) {526filepath = JfrJavaSupport::new_string(_filename.value(), CHECK);527}528529static const char klass[] = "jdk/jfr/internal/dcmd/DCmdStop";530static const char method[] = "execute";531static const char signature[] = "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;";532533JfrJavaArguments execute_args(&result, klass, method, signature, CHECK);534execute_args.set_receiver(h_dcmd_instance);535536// arguments537execute_args.push_jobject(name);538execute_args.push_jobject(filepath);539540JfrJavaSupport::call_virtual(&execute_args, THREAD);541handle_dcmd_result(output(), (oop)result.get_jobject(), source, THREAD);542}543544JfrConfigureFlightRecorderDCmd::JfrConfigureFlightRecorderDCmd(outputStream* output,545bool heap) : DCmdWithParser(output, heap),546_repository_path("repositorypath", "Path to repository,.e.g \\\"My Repository\\\"", "STRING", false, NULL),547_dump_path("dumppath", "Path to dump,.e.g \\\"My Dump path\\\"", "STRING", false, NULL),548_stack_depth("stackdepth", "Stack Depth", "JULONG", false, "64"),549_global_buffer_count("globalbuffercount", "Number of global buffers,", "JULONG", false, "20"),550_global_buffer_size("globalbuffersize", "Size of a global buffers,", "MEMORY SIZE", false, "512k"),551_thread_buffer_size("thread_buffer_size", "Size of a thread buffer", "MEMORY SIZE", false, "8k"),552_memory_size("memorysize", "Overall memory size, ", "MEMORY SIZE", false, "10m"),553_max_chunk_size("maxchunksize", "Size of an individual disk chunk", "MEMORY SIZE", false, "12m"),554_sample_threads("samplethreads", "Activate Thread sampling", "BOOLEAN", false, "true") {555_dcmdparser.add_dcmd_option(&_repository_path);556_dcmdparser.add_dcmd_option(&_dump_path);557_dcmdparser.add_dcmd_option(&_stack_depth);558_dcmdparser.add_dcmd_option(&_global_buffer_count);559_dcmdparser.add_dcmd_option(&_global_buffer_size);560_dcmdparser.add_dcmd_option(&_thread_buffer_size);561_dcmdparser.add_dcmd_option(&_memory_size);562_dcmdparser.add_dcmd_option(&_max_chunk_size);563_dcmdparser.add_dcmd_option(&_sample_threads);564};565566int JfrConfigureFlightRecorderDCmd::num_arguments() {567ResourceMark rm;568JfrConfigureFlightRecorderDCmd* dcmd = new JfrConfigureFlightRecorderDCmd(NULL, false);569if (dcmd != NULL) {570DCmdMark mark(dcmd);571return dcmd->_dcmdparser.num_arguments();572}573return 0;574}575576void JfrConfigureFlightRecorderDCmd::execute(DCmdSource source, TRAPS) {577DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_vm(THREAD));578579if (invalid_state(output(), THREAD)) {580return;581}582583ResourceMark rm(THREAD);584HandleMark hm(THREAD);585JNIHandleBlockManager jni_handle_management(THREAD);586587JavaValue result(T_OBJECT);588JfrJavaArguments constructor_args(&result);589constructor_args.set_klass("jdk/jfr/internal/dcmd/DCmdConfigure", CHECK);590const oop dcmd = construct_dcmd_instance(&constructor_args, CHECK);591Handle h_dcmd_instance(THREAD, dcmd);592assert(h_dcmd_instance.not_null(), "invariant");593594jstring repository_path = NULL;595if (_repository_path.is_set() && _repository_path.value() != NULL) {596repository_path = JfrJavaSupport::new_string(_repository_path.value(), CHECK);597}598599jstring dump_path = NULL;600if (_dump_path.is_set() && _dump_path.value() != NULL) {601dump_path = JfrJavaSupport::new_string(_dump_path.value(), CHECK);602}603604jobject stack_depth = NULL;605if (_stack_depth.is_set()) {606stack_depth = JfrJavaSupport::new_java_lang_Integer((jint)_stack_depth.value(), CHECK);607}608609jobject global_buffer_count = NULL;610if (_global_buffer_count.is_set()) {611global_buffer_count = JfrJavaSupport::new_java_lang_Long(_global_buffer_count.value(), CHECK);612}613614jobject global_buffer_size = NULL;615if (_global_buffer_size.is_set()) {616global_buffer_size = JfrJavaSupport::new_java_lang_Long(_global_buffer_size.value()._size, CHECK);617}618619jobject thread_buffer_size = NULL;620if (_thread_buffer_size.is_set()) {621thread_buffer_size = JfrJavaSupport::new_java_lang_Long(_thread_buffer_size.value()._size, CHECK);622}623624jobject max_chunk_size = NULL;625if (_max_chunk_size.is_set()) {626max_chunk_size = JfrJavaSupport::new_java_lang_Long(_max_chunk_size.value()._size, CHECK);627}628629jobject memory_size = NULL;630if (_memory_size.is_set()) {631memory_size = JfrJavaSupport::new_java_lang_Long(_memory_size.value()._size, CHECK);632}633634jobject sample_threads = NULL;635if (_sample_threads.is_set()) {636sample_threads = JfrJavaSupport::new_java_lang_Boolean(_sample_threads.value(), CHECK);637}638639static const char klass[] = "jdk/jfr/internal/dcmd/DCmdConfigure";640static const char method[] = "execute";641static const char signature[] = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;"642"Ljava/lang/Long;Ljava/lang/Long;Ljava/lang/Long;Ljava/lang/Long;"643"Ljava/lang/Long;Ljava/lang/Boolean;)Ljava/lang/String;";644645JfrJavaArguments execute_args(&result, klass, method, signature, CHECK);646execute_args.set_receiver(h_dcmd_instance);647648// params649execute_args.push_jobject(repository_path);650execute_args.push_jobject(dump_path);651execute_args.push_jobject(stack_depth);652execute_args.push_jobject(global_buffer_count);653execute_args.push_jobject(global_buffer_size);654execute_args.push_jobject(thread_buffer_size);655execute_args.push_jobject(memory_size);656execute_args.push_jobject(max_chunk_size);657execute_args.push_jobject(sample_threads);658659JfrJavaSupport::call_virtual(&execute_args, THREAD);660handle_dcmd_result(output(), (oop)result.get_jobject(), source, THREAD);661}662663bool register_jfr_dcmds() {664uint32_t full_export = DCmd_Source_Internal | DCmd_Source_AttachAPI | DCmd_Source_MBean;665DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JfrCheckFlightRecordingDCmd>(full_export, true, false));666DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JfrDumpFlightRecordingDCmd>(full_export, true, false));667DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JfrStartFlightRecordingDCmd>(full_export, true, false));668DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JfrStopFlightRecordingDCmd>(full_export, true, false));669DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JfrConfigureFlightRecorderDCmd>(full_export, true, false));670671DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JfrUnlockCommercialFeaturesDCmd>(full_export, true, false));672return true;673}674675676677