/* * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
void JvmtiTrace::initialize() { if (_initialized) { return;
}
SafeResourceMark rm;
constchar *very_end; constchar *curr; if (TraceJVMTI != NULL) {
curr = TraceJVMTI;
} else {
curr = ""; // hack in fixed tracing here
}
// Enable UL for JVMTI tracing if (strlen(curr) > 0) { if (!log_is_enabled(Trace, jvmti)) {
log_warning(arguments)("-XX:+TraceJVMTI specified, " "but no log output configured for the 'jvmti' tag on Trace level. " "Defaulting to -Xlog:jvmti=trace");
LogConfiguration::configure_stdout(LogLevel::Trace, true, LOG_TAGS(jvmti));
}
}
int exclude_index = 0; if (domain & FUNC) { if (domain & ALL_FUNC) { if (domain & EXCLUDE) {
log_trace(jvmti)("Tracing all significant functions");
} else {
log_trace(jvmti)("Tracing all functions");
}
} for (int i = 0; i <= _max_function_index; ++i) { if (domain & EXCLUDE && i == _exclude_functions[exclude_index]) {
++exclude_index;
} else { bool do_op = false; if (domain & ALL_FUNC) {
do_op = true;
} else { constchar *fname = function_name(i); if (fname != NULL) {
size_t fnlen = strlen(fname); if (len==fnlen && strncmp(curr, fname, fnlen)==0) {
log_trace(jvmti)("Tracing the function: %s", fname);
do_op = true;
}
}
} if (do_op) { if (op == '+') {
_trace_flags[i] |= bits;
} else {
_trace_flags[i] &= ~bits;
}
_on = true;
}
}
}
} if (domain & EVENT) { if (domain & ALL_EVENT) {
log_trace(jvmti)("Tracing all events");
} for (int i = 0; i <= _max_event_index; ++i) { bool do_op = false; if (domain & ALL_EVENT) {
do_op = true;
} else { constchar *ename = event_name(i); if (ename != NULL) {
size_t evtlen = strlen(ename); if (len==evtlen && strncmp(curr, ename, evtlen)==0) {
log_trace(jvmti)("Tracing the event: %s", ename);
do_op = true;
}
}
} if (do_op) { if (op == '+') {
_event_trace_flags[i] |= bits;
} else {
_event_trace_flags[i] &= ~bits;
}
_on = true;
}
}
} if (!_on && (domain & (FUNC|EVENT))) {
log_warning(jvmti)("Trace domain not found");
}
curr = curr_end + 1;
}
_initialized = true;
}
void JvmtiTrace::shutdown() { int i;
_on = false;
_trace_event_controller = false; for (i = 0; i <= _max_function_index; ++i) {
_trace_flags[i] = 0;
} for (i = 0; i <= _max_event_index; ++i) {
_event_trace_flags[i] = 0;
}
}
constchar* JvmtiTrace::enum_name(constchar** names, const jint* values, jint value) { for (int index = 0; names[index] != 0; ++index) { if (values[index] == value) { return names[index];
}
} return"*INVALID-ENUM-VALUE*";
}
// return a valid string no matter what state the thread is in constchar *JvmtiTrace::safe_get_thread_name(Thread *thread) { if (thread == NULL) { return"NULL";
} if (!thread->is_Java_thread()) { return thread->name();
}
JavaThread* java_thread = JavaThread::cast(thread);
oop threadObj = java_thread->jvmti_vthread(); if (threadObj == NULL) {
threadObj = java_thread->threadObj();
} if (threadObj == NULL) { return"NULL";
}
oop name = java_lang_Thread::name(threadObj); if (name == NULL) { return"";
} return java_lang_String::as_utf8_string(name);
}
// return the name of the current thread constchar *JvmtiTrace::safe_get_current_thread_name() { if (JvmtiEnv::is_vm_live()) { return JvmtiTrace::safe_get_thread_name(Thread::current_or_null());
} else { return"VM not live";
}
}
// return a valid string no matter what the state of k_mirror constchar * JvmtiTrace::get_class_name(oop k_mirror) { if (java_lang_Class::is_primitive(k_mirror)) { return"primitive";
}
Klass* k_oop = java_lang_Class::as_Klass(k_mirror); if (k_oop == NULL) { return"INVALID";
} return k_oop->external_name();
}
#endif/*JVMTI_TRACE */
¤ Dauer der Verarbeitung: 0.34 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.