49 #include "prims/nativeLookup.hpp"
50 #include "prims/privilegedStack.hpp"
51 #include "runtime/arguments.hpp"
52 #include "runtime/dtraceJSDT.hpp"
53 #include "runtime/handles.inline.hpp"
54 #include "runtime/init.hpp"
55 #include "runtime/interfaceSupport.hpp"
56 #include "runtime/java.hpp"
57 #include "runtime/javaCalls.hpp"
58 #include "runtime/jfieldIDWorkaround.hpp"
59 #include "runtime/orderAccess.inline.hpp"
60 #include "runtime/os.hpp"
61 #include "runtime/perfData.hpp"
62 #include "runtime/reflection.hpp"
63 #include "runtime/vframe.hpp"
64 #include "runtime/vm_operations.hpp"
65 #include "services/attachListener.hpp"
66 #include "services/management.hpp"
67 #include "services/threadService.hpp"
68 #include "trace/tracing.hpp"
69 #include "utilities/copy.hpp"
70 #include "utilities/defaultStream.hpp"
71 #include "utilities/dtrace.hpp"
72 #include "utilities/events.hpp"
73 #include "utilities/histogram.hpp"
74 #include "utilities/top.hpp"
75 #include "utilities/utf8.hpp"
76 #ifdef TARGET_OS_FAMILY_linux
77 # include "jvm_linux.h"
78 #endif
79 #ifdef TARGET_OS_FAMILY_solaris
80 # include "jvm_solaris.h"
81 #endif
82 #ifdef TARGET_OS_FAMILY_windows
83 # include "jvm_windows.h"
84 #endif
85 #ifdef TARGET_OS_FAMILY_aix
86 # include "jvm_aix.h"
87 #endif
88 #ifdef TARGET_OS_FAMILY_bsd
3332 }
3333 Handle h_obj(THREAD, JNIHandles::resolve(obj));
3334 return ObjectSynchronizer::current_thread_holds_lock((JavaThread*)THREAD, h_obj);
3335 JVM_END
3336
3337
3338 JVM_ENTRY(void, JVM_DumpAllStacks(JNIEnv* env, jclass))
3339 JVMWrapper("JVM_DumpAllStacks");
3340 VM_PrintThreads op;
3341 VMThread::execute(&op);
3342 if (JvmtiExport::should_post_data_dump()) {
3343 JvmtiExport::post_data_dump();
3344 }
3345 JVM_END
3346
3347 JVM_ENTRY(void, JVM_SetNativeThreadName(JNIEnv* env, jobject jthread, jstring name))
3348 JVMWrapper("JVM_SetNativeThreadName");
3349 ResourceMark rm(THREAD);
3350 oop java_thread = JNIHandles::resolve_non_null(jthread);
3351 JavaThread* thr = java_lang_Thread::thread(java_thread);
3352 // Thread naming only supported for the current thread, doesn't work for
3353 // target threads.
3354 if (Thread::current() == thr && !thr->has_attached_via_jni()) {
3355 // we don't set the name of an attached thread to avoid stepping
3356 // on other programs
3357 const char *thread_name = java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name));
3358 os::set_native_thread_name(thread_name);
3359 }
3360 JVM_END
3361
3362 // java.lang.SecurityManager ///////////////////////////////////////////////////////////////////////
3363
3364 static bool is_trusted_frame(JavaThread* jthread, vframeStream* vfst) {
3365 assert(jthread->is_Java_thread(), "must be a Java thread");
3366 if (jthread->privileged_stack_top() == NULL) return false;
3367 if (jthread->privileged_stack_top()->frame_id() == vfst->frame_id()) {
3368 oop loader = jthread->privileged_stack_top()->class_loader();
3369 if (loader == NULL) return true;
3370 bool trusted = java_lang_ClassLoader::is_trusted_loader(loader);
3371 if (trusted) return true;
|
49 #include "prims/nativeLookup.hpp"
50 #include "prims/privilegedStack.hpp"
51 #include "runtime/arguments.hpp"
52 #include "runtime/dtraceJSDT.hpp"
53 #include "runtime/handles.inline.hpp"
54 #include "runtime/init.hpp"
55 #include "runtime/interfaceSupport.hpp"
56 #include "runtime/java.hpp"
57 #include "runtime/javaCalls.hpp"
58 #include "runtime/jfieldIDWorkaround.hpp"
59 #include "runtime/orderAccess.inline.hpp"
60 #include "runtime/os.hpp"
61 #include "runtime/perfData.hpp"
62 #include "runtime/reflection.hpp"
63 #include "runtime/vframe.hpp"
64 #include "runtime/vm_operations.hpp"
65 #include "services/attachListener.hpp"
66 #include "services/management.hpp"
67 #include "services/threadService.hpp"
68 #include "trace/tracing.hpp"
69 #include "evtrace/traceEvents.hpp"
70 #include "utilities/copy.hpp"
71 #include "utilities/defaultStream.hpp"
72 #include "utilities/dtrace.hpp"
73 #include "utilities/events.hpp"
74 #include "utilities/histogram.hpp"
75 #include "utilities/top.hpp"
76 #include "utilities/utf8.hpp"
77 #ifdef TARGET_OS_FAMILY_linux
78 # include "jvm_linux.h"
79 #endif
80 #ifdef TARGET_OS_FAMILY_solaris
81 # include "jvm_solaris.h"
82 #endif
83 #ifdef TARGET_OS_FAMILY_windows
84 # include "jvm_windows.h"
85 #endif
86 #ifdef TARGET_OS_FAMILY_aix
87 # include "jvm_aix.h"
88 #endif
89 #ifdef TARGET_OS_FAMILY_bsd
3333 }
3334 Handle h_obj(THREAD, JNIHandles::resolve(obj));
3335 return ObjectSynchronizer::current_thread_holds_lock((JavaThread*)THREAD, h_obj);
3336 JVM_END
3337
3338
3339 JVM_ENTRY(void, JVM_DumpAllStacks(JNIEnv* env, jclass))
3340 JVMWrapper("JVM_DumpAllStacks");
3341 VM_PrintThreads op;
3342 VMThread::execute(&op);
3343 if (JvmtiExport::should_post_data_dump()) {
3344 JvmtiExport::post_data_dump();
3345 }
3346 JVM_END
3347
3348 JVM_ENTRY(void, JVM_SetNativeThreadName(JNIEnv* env, jobject jthread, jstring name))
3349 JVMWrapper("JVM_SetNativeThreadName");
3350 ResourceMark rm(THREAD);
3351 oop java_thread = JNIHandles::resolve_non_null(jthread);
3352 JavaThread* thr = java_lang_Thread::thread(java_thread);
3353 if (EnableEventTracing) {
3354 TraceEvents::write_thread_name_change(thr);
3355 }
3356 // Thread naming only supported for the current thread, doesn't work for
3357 // target threads.
3358 if (Thread::current() == thr && !thr->has_attached_via_jni()) {
3359 // we don't set the name of an attached thread to avoid stepping
3360 // on other programs
3361 const char *thread_name = java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name));
3362 os::set_native_thread_name(thread_name);
3363 }
3364 JVM_END
3365
3366 // java.lang.SecurityManager ///////////////////////////////////////////////////////////////////////
3367
3368 static bool is_trusted_frame(JavaThread* jthread, vframeStream* vfst) {
3369 assert(jthread->is_Java_thread(), "must be a Java thread");
3370 if (jthread->privileged_stack_top() == NULL) return false;
3371 if (jthread->privileged_stack_top()->frame_id() == vfst->frame_id()) {
3372 oop loader = jthread->privileged_stack_top()->class_loader();
3373 if (loader == NULL) return true;
3374 bool trusted = java_lang_ClassLoader::is_trusted_loader(loader);
3375 if (trusted) return true;
|