Commit ebf29cf6 by Keith Seitz Committed by Keith Seitz

jvmti.cc (_Jv_JVMTI_DisposeEnvironment): Check for enabled events.

        * jvmti.cc (_Jv_JVMTI_DisposeEnvironment): Check for enabled
        events.
        (check_enabled_event): New function.
        (check_enabled_events): New function.
        (post_event): New function.
        (_Jv_JVMTI_SetEventNotificationMode): New function.
        (_Jv_JVMTI_SetEventCallbacks): New function.
        (_Jv_JVMTI_Interface): Define SetEventNotificationMode and
        SetEventCallbacks members.
        * include/jvmti-int.h: New file.
        * include/jvmti_md.h (EVENT_SLOTS) [__GCJ_JNI_IMP__]: Define.
        (_CLASSPATH_JVMTIENV_CONTENTS) [__GCJ_JNI_IMPL__]: Define.
        * testsuite/libjava.jvmti/events.java: New file.
        * testsuite/libjava.jvmti/events.out: New file.
        * testsuite/libjava.jvmti/natevents.cc: New file.

From-SVN: r117133
parent 14c71489
2006-09-21 Keith Seitz <keiths@redhat.com>
* jvmti.cc (_Jv_JVMTI_DisposeEnvironment): Check for enabled
events.
(check_enabled_event): New function.
(check_enabled_events): New function.
(post_event): New function.
(_Jv_JVMTI_SetEventNotificationMode): New function.
(_Jv_JVMTI_SetEventCallbacks): New function.
(_Jv_JVMTI_Interface): Define SetEventNotificationMode and
SetEventCallbacks members.
* include/jvmti-int.h: New file.
* include/jvmti_md.h (EVENT_SLOTS) [__GCJ_JNI_IMP__]: Define.
(_CLASSPATH_JVMTIENV_CONTENTS) [__GCJ_JNI_IMPL__]: Define.
* testsuite/libjava.jvmti/events.java: New file.
* testsuite/libjava.jvmti/events.out: New file.
* testsuite/libjava.jvmti/natevents.cc: New file.
2006-09-21 Sandro Tolaini <tolaini@libero.it>
* configure.ac: Don't use darwin-signal.h as signal handler for
......
/* jvmti-int.h -- Internal JVMTI definitions
Copyright (C) 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath 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 for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
#ifndef __GCJ_JVTMI_INT_H__
#define __GCJ_JVMTI_INT_H__
/* A macro to map jvmtiEvent to an index in thread[] and enabled[]
in the jvmtiEnv. This will only work if the order of events listed
in jvmtiEvent and jvmtiEventCallbacks is kept the same (which should
not be a problem). */
#define EVENT_INDEX(jvmtievent) (int)(jvmtievent - JVMTI_EVENT_VM_INIT)
/* A few globals to help limit the impact of JVMTI on normal operations.
False means no JVMTI environment requested that event type. */
namespace JVMTI
{
bool VMInit;
bool VMDeath;
bool ThreadStart;
bool ThreadEnd;
bool ClassFileLoadHook;
bool ClassLoad;
bool ClassPrepare;
bool VMStart;
bool Exception;
bool ExceptionCatch;
bool SingleStep;
bool FramePop;
bool Breakpoint;
bool FieldAccess;
bool FieldModification;
bool MethodEntry;
bool MethodExit;
bool NativeMethodBind;
bool CompiledMethodLoad;
bool CompiledMethodUnload;
bool DynamicCodeGenerated;
bool DataDumpRequest;
bool reserved72;
bool MonitorWait;
bool MonitorWaited;
bool MonitorContendedEnter;
bool MonitorContendedEntered;
bool reserved77;
bool reserved78;
bool reserved79;
bool reserved80;
bool GarbageCollectionStart;
bool GarbageCollectionFinish;
bool ObjectFree;
bool VMObjectAlloc;
};
/* A macro to test whether an event should be posted to JVMTI.*/
#define JVMTI_REQUESTED_EVENT(Event) __builtin_expect (JVMTI::Event, false)
/* Post the event to requesting JVMTI environments.
For speed, this function should only be called after
JVMTI_REQUESTED_EVENT is checked. */
extern void _Jv_JVMTI_PostEvent (jvmtiEvent type, jthread event_thread, ...);
#endif /* __GCJ_JVMTI_INT_H__ */
......@@ -27,6 +27,32 @@ executable file might be covered by the GNU General Public License. */
#ifndef __GCJ_JVMTI_MD_H__
#define __GCJ_JVMTI_MD_H__
// nothing
#ifdef __GCJ_JNI_IMPL__
/* If __GCJ_JNI_IMPL__ is defined, then we assume that we're building
libgcj itself, and we include functions which should not be exposed
to JVMTI users. */
/* The number of event slots needed to keep track of event reporting
constraints for an environment. This will only work if the order of
events listed in jvmtiEvent and jvmtiEventCallbacks is kept the same
(which should not be a problem). */
#define EVENT_SLOTS \
(int)(JVMTI_EVENT_VM_OBJECT_ALLOC - JVMTI_EVENT_VM_INIT + 1)
/* Contents of the jvmtiEnv; but only inside the implementation. */
#define _CLASSPATH_JVMTIENV_CONTENTS \
/* Event handlers registered via SetEventCallbacks */ \
jvmtiEventCallbacks callbacks; \
\
/* Array of event thread for which to report event. */ \
/* NULL means all threads. One for each callback. */ \
jthread thread[EVENT_SLOTS]; \
\
/* Array of notification modes for callbacks. */ \
/* One for each callback. */ \
bool enabled[EVENT_SLOTS];
#endif /* __GCJ_JNI_IMPL__ */
#endif /* __GCJ_JVMTI_MD_H__ */
// Test JVMTI event notifications
public class events
{
public static native void do_events_tests ();
public static void main (String[] args)
{
System.out.println ("JVMTI event notification tests");
do_events_tests ();
}
}
JVMTI event notification tests
- enable tests -
created JVMTI environment #0
created JVMTI environment #1
created JVMTI environment #2
setting callbacks for envs
RequestedEvents:
enable VM_INIT for env0, env1, env2
RequestedEvents: VMInit,
enable VM_DEATH for env1,env2
RequestedEvents: VMInit,VMDeath,
enable THREAD_END for env2
RequestedEvents: VMInit,VMDeath,ThreadEnd,
disposing of env1
RequestedEvents: VMInit,VMDeath,ThreadEnd,
disposing of env0
RequestedEvents: VMInit,VMDeath,ThreadEnd,
disable VMInit in env2
RequestedEvents: VMDeath,ThreadEnd,
clear VMDeath callback in env2
RequestedEvents: ThreadEnd,
sending VMInit
sending ThreadEnd
ThreadEndCB jni_env=0x5678 thread=0x1234
sending VMDeath
disposing of env2
RequestedEvents:
- callback arg tests -
RequestedEvents: VMInit,VMDeath,ThreadStart,ThreadEnd,ClassFileLoadHook,ClassLoad,ClassPrepare,VMStart,Exception,ExceptionCatch,SingleStep,FramePop,Breakpoint,FieldAccess,FieldModification,MethodEntry,MethodExit,NativeMethodBind,CompiledMethodLoad,CompiledMethodUnload,DynamicCodeGenerated,DataDumpRequest,MonitorWait,MonitorWaited,MonitorContendedEnter,MonitorContendedEntered,GarbageCollectionStart,GarbageCollectionFinish,ObjectFree,VMObjectAlloc,
VMInitCB jni_env=0x1 thread=0x2
VMDeathCB jni_env=0x1
ThreadStartCB jni_env=0x1 thread=0x2
ThreadEndCB jni_env=0x1 thread=0x2
ClassFileLoadHookCB jni_env=0x1 class_being_redefined=0x2 loader=0x3 name=4 protection_domain=0x5 class_data_len=6 class_data=0x7 new_class_data_len=0x8 new_class_data=0x9
ClassLoadCB jni_env=0x1 thread=0x2 klass=0x3
ClassPrepareCB jni_env=0x1 thread=0x2 klass=0x3
VMStartCB jni_env=0x1
ExceptionCB jni_env=0x1 thread=0x2 method=0x3 location=0x4 exception=0x5 catch_method=0x6 catch_location=0x7
ExceptionCatchCB jni_env=0x1 thread=0x2 method=0x3 location=0x4 exception=0x5
SingleStepCB jni_env=0x1 thread=0x2 method=0x3 location=0x4
FramePopCB jni_env=0x1 thread=0x2 method=0x3 was_pooped_by_exception=1
BreakpointCB jni_env=0x1 thread=0x2 method=0x3 location=0x4
FieldAccessCB jni_env=0x1 thread=0x2 method=0x3 location=0x4 field_klass=0x5 object=0x6 field=0x7
FieldModificationCB jni_env=0x1 thread=0x2 method=0x3 location=0x4 field_klass=0x5 object=0x6 field=0x7 signature_type=8 new_value=9
MethodEntryCB jni_env=0x1 thread=0x2 method=0x3
MethodExitCB jni_env=0x1 thread=0x2 method=0x3 was_popped_by_exception=1 return_value=5
NativeMethodBindCB jni_env=0x1 thread=0x2 method=0x3 address=0x4 new_address_ptr=0x5
CompiledMethodLoadCB method=0x1 code_size=0x2 code_addr=0x3 map_length=4 map=0x5 compile_info=0x6
CompiledMethodUnloadCB method=0x1 code_addr=0x2
DynamicCodeGeneratedCB name=1 address=0x2 length=3
DataDumpRequestCB
MonitorWaitCB jni_env=0x1 thread=0x2 object=0x3 timeout=4
MonitorWaitedCB jni_env=0x1 thread=0x2 object=0x3 timed_out=1
MonitorContendedEnterCB jni_env=0x1 thread=0x2 object=0x3
MonitorContendedEnteredCB jni_env=0x1 thread=0x2 object=0x3
GarbageCollectionStartCB
GarbageCollectionFinishCB
ObjectFreeCB tag=1
VMObjectAllocCB jni_env=0x1 thread=0x2 object=0x3 object_klass=0x4 size=5
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment