summaryrefslogtreecommitdiff
path: root/libjava/testsuite/libjava.jvmti
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/testsuite/libjava.jvmti')
-rw-r--r--libjava/testsuite/libjava.jvmti/dummyagent.c10
-rw-r--r--libjava/testsuite/libjava.jvmti/events.h27
-rw-r--r--libjava/testsuite/libjava.jvmti/events.jarbin0 -> 751 bytes
-rw-r--r--libjava/testsuite/libjava.jvmti/events.java12
-rw-r--r--libjava/testsuite/libjava.jvmti/events.out59
-rw-r--r--libjava/testsuite/libjava.jvmti/getallthreads.h35
-rw-r--r--libjava/testsuite/libjava.jvmti/getallthreads.jarbin0 -> 1228 bytes
-rw-r--r--libjava/testsuite/libjava.jvmti/getallthreads.java80
-rw-r--r--libjava/testsuite/libjava.jvmti/getallthreads.out23
-rw-r--r--libjava/testsuite/libjava.jvmti/geterrorname.h27
-rw-r--r--libjava/testsuite/libjava.jvmti/geterrorname.jarbin0 -> 716 bytes
-rw-r--r--libjava/testsuite/libjava.jvmti/geterrorname.java12
-rw-r--r--libjava/testsuite/libjava.jvmti/geterrorname.out49
-rw-r--r--libjava/testsuite/libjava.jvmti/getmethodname.h27
-rw-r--r--libjava/testsuite/libjava.jvmti/getmethodname.jarbin0 -> 765 bytes
-rw-r--r--libjava/testsuite/libjava.jvmti/getmethodname.java10
-rw-r--r--libjava/testsuite/libjava.jvmti/getmethodname.out59
-rw-r--r--libjava/testsuite/libjava.jvmti/interp/getargssize.h19
-rw-r--r--libjava/testsuite/libjava.jvmti/interp/getargssize.jarbin0 -> 1111 bytes
-rw-r--r--libjava/testsuite/libjava.jvmti/interp/getargssize.java36
-rw-r--r--libjava/testsuite/libjava.jvmti/interp/getargssize.out5
-rw-r--r--libjava/testsuite/libjava.jvmti/interp/getlocalvartable.h19
-rw-r--r--libjava/testsuite/libjava.jvmti/interp/getlocalvartable.jarbin0 -> 1370 bytes
-rw-r--r--libjava/testsuite/libjava.jvmti/interp/getlocalvartable.java63
-rw-r--r--libjava/testsuite/libjava.jvmti/interp/getlocalvartable.out109
-rw-r--r--libjava/testsuite/libjava.jvmti/interp/getstacktrace.h21
-rw-r--r--libjava/testsuite/libjava.jvmti/interp/getstacktrace.jarbin0 -> 1237 bytes
-rw-r--r--libjava/testsuite/libjava.jvmti/interp/getstacktrace.java88
-rw-r--r--libjava/testsuite/libjava.jvmti/interp/getstacktrace.out76
-rw-r--r--libjava/testsuite/libjava.jvmti/interp/natgetargssize.cc58
-rw-r--r--libjava/testsuite/libjava.jvmti/interp/natgetlocalvartable.cc70
-rw-r--r--libjava/testsuite/libjava.jvmti/interp/natgetstacktrace.cc144
-rw-r--r--libjava/testsuite/libjava.jvmti/jvmti-interp.exp188
-rw-r--r--libjava/testsuite/libjava.jvmti/jvmti.exp126
-rw-r--r--libjava/testsuite/libjava.jvmti/natevents.cc578
-rw-r--r--libjava/testsuite/libjava.jvmti/natgetallthreads.cc55
-rw-r--r--libjava/testsuite/libjava.jvmti/natgeterrorname.cc76
-rw-r--r--libjava/testsuite/libjava.jvmti/natgetmethodname.cc116
38 files changed, 2277 insertions, 0 deletions
diff --git a/libjava/testsuite/libjava.jvmti/dummyagent.c b/libjava/testsuite/libjava.jvmti/dummyagent.c
new file mode 100644
index 000000000..96541b98a
--- /dev/null
+++ b/libjava/testsuite/libjava.jvmti/dummyagent.c
@@ -0,0 +1,10 @@
+#include <jvmti.h>
+
+JNIEXPORT jint JNICALL
+Agent_OnLoad (JavaVM *vm, char *options, void *reserved)
+{
+ // nothing -- this is just a stub to get JVMTI properly
+ // initialized
+ return 0;
+}
+
diff --git a/libjava/testsuite/libjava.jvmti/events.h b/libjava/testsuite/libjava.jvmti/events.h
new file mode 100644
index 000000000..2f81b63fe
--- /dev/null
+++ b/libjava/testsuite/libjava.jvmti/events.h
@@ -0,0 +1,27 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __events__
+#define __events__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ class events;
+}
+
+class events : public ::java::lang::Object
+{
+
+public:
+ events();
+ static void do_events_tests();
+ static void main(JArray< ::java::lang::String * > *);
+ static ::java::lang::Class class$;
+};
+
+#endif // __events__
diff --git a/libjava/testsuite/libjava.jvmti/events.jar b/libjava/testsuite/libjava.jvmti/events.jar
new file mode 100644
index 000000000..48a69dc7e
--- /dev/null
+++ b/libjava/testsuite/libjava.jvmti/events.jar
Binary files differ
diff --git a/libjava/testsuite/libjava.jvmti/events.java b/libjava/testsuite/libjava.jvmti/events.java
new file mode 100644
index 000000000..05deeeb23
--- /dev/null
+++ b/libjava/testsuite/libjava.jvmti/events.java
@@ -0,0 +1,12 @@
+// 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 ();
+ }
+}
diff --git a/libjava/testsuite/libjava.jvmti/events.out b/libjava/testsuite/libjava.jvmti/events.out
new file mode 100644
index 000000000..7b51cafe8
--- /dev/null
+++ b/libjava/testsuite/libjava.jvmti/events.out
@@ -0,0 +1,59 @@
+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=0x9
+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
diff --git a/libjava/testsuite/libjava.jvmti/getallthreads.h b/libjava/testsuite/libjava.jvmti/getallthreads.h
new file mode 100644
index 000000000..7579892f3
--- /dev/null
+++ b/libjava/testsuite/libjava.jvmti/getallthreads.h
@@ -0,0 +1,35 @@
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __getallthreads__
+#define __getallthreads__
+
+#pragma interface
+
+#include <java/lang/Thread.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ class getallthreads;
+}
+
+class getallthreads : public ::java::lang::Thread
+{
+public:
+ getallthreads ();
+ static void do_getallthreads_tests ();
+ virtual void run ();
+ virtual void natPlaceholder ();
+ virtual void natRunner ();
+ virtual void placeholder ();
+ virtual void runner ();
+ static void main (JArray< ::java::lang::String *> *);
+ static jint thread_num;
+ static ::java::util::ArrayList *threads;
+ jint __attribute__((aligned(__alignof__( ::java::lang::Thread )))) ex_frames;
+ jboolean done;
+
+ static ::java::lang::Class class$;
+};
+
+#endif /* __getallthreads__ */
diff --git a/libjava/testsuite/libjava.jvmti/getallthreads.jar b/libjava/testsuite/libjava.jvmti/getallthreads.jar
new file mode 100644
index 000000000..3e59ccdc3
--- /dev/null
+++ b/libjava/testsuite/libjava.jvmti/getallthreads.jar
Binary files differ
diff --git a/libjava/testsuite/libjava.jvmti/getallthreads.java b/libjava/testsuite/libjava.jvmti/getallthreads.java
new file mode 100644
index 000000000..00be3a75c
--- /dev/null
+++ b/libjava/testsuite/libjava.jvmti/getallthreads.java
@@ -0,0 +1,80 @@
+// Test JVMTI GetAllThreads
+
+import java.util.ArrayList;
+
+public class getallthreads extends Thread
+{
+ public static int thread_num;
+ public static ArrayList threads;
+
+ public int ex_frames;
+ public boolean done = false;
+
+ public static native void do_getallthreads_tests ();
+
+ public void run ()
+ {
+ ex_frames = thread_num;
+ thread_num++;
+
+ if (ex_frames > 0)
+ {
+ if ((ex_frames % 2) == 0)
+ placeholder ();
+ else
+ natPlaceholder ();
+ }
+ else
+ runner ();
+ }
+
+ public native void natPlaceholder ();
+ public native void natRunner ();
+
+ public void placeholder ()
+ {
+ ex_frames--;
+
+ if (ex_frames > 0)
+ {
+ if ((thread_num % 2) == 0)
+ placeholder ();
+ else
+ natPlaceholder ();
+ }
+ else
+ runner ();
+ }
+
+ public void runner ()
+ {
+ done = true;
+ while (done)
+ yield ();
+ }
+
+ public static void main (String[] args)
+ {
+ System.out.println ("JVMTI GetAllThreads tests");
+ threads = new ArrayList (20);
+
+ getallthreads t;
+
+ for (int i = 0; i < 20; i++)
+ {
+ t = new getallthreads ();
+ threads.add (t);
+ t.start ();
+ while (!t.done)
+ yield ();
+ }
+
+ do_getallthreads_tests ();
+
+ for (int i = 0; i < 20; i++)
+ {
+ t = (getallthreads) threads.get(i);
+ t.done = false;
+ }
+ }
+}
diff --git a/libjava/testsuite/libjava.jvmti/getallthreads.out b/libjava/testsuite/libjava.jvmti/getallthreads.out
new file mode 100644
index 000000000..8e05c4a4b
--- /dev/null
+++ b/libjava/testsuite/libjava.jvmti/getallthreads.out
@@ -0,0 +1,23 @@
+JVMTI GetAllThreads tests
+Found thread 1
+Found thread 2
+Found thread 3
+Found thread 4
+Found thread 5
+Found thread 6
+Found thread 7
+Found thread 8
+Found thread 9
+Found thread 10
+Found thread 11
+Found thread 12
+Found thread 13
+Found thread 14
+Found thread 15
+Found thread 16
+Found thread 17
+Found thread 18
+Found thread 19
+Found thread 20
+Found thread 21
+Found thread 22
diff --git a/libjava/testsuite/libjava.jvmti/geterrorname.h b/libjava/testsuite/libjava.jvmti/geterrorname.h
new file mode 100644
index 000000000..957e1c23b
--- /dev/null
+++ b/libjava/testsuite/libjava.jvmti/geterrorname.h
@@ -0,0 +1,27 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __geterrorname__
+#define __geterrorname__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ class geterrorname;
+}
+
+class geterrorname : public ::java::lang::Object
+{
+
+public:
+ geterrorname();
+ static void do_errorname_tests();
+ static void main(JArray< ::java::lang::String * > *);
+ static ::java::lang::Class class$;
+};
+
+#endif // __geterrorname__
diff --git a/libjava/testsuite/libjava.jvmti/geterrorname.jar b/libjava/testsuite/libjava.jvmti/geterrorname.jar
new file mode 100644
index 000000000..a0c5ae052
--- /dev/null
+++ b/libjava/testsuite/libjava.jvmti/geterrorname.jar
Binary files differ
diff --git a/libjava/testsuite/libjava.jvmti/geterrorname.java b/libjava/testsuite/libjava.jvmti/geterrorname.java
new file mode 100644
index 000000000..b809b22d6
--- /dev/null
+++ b/libjava/testsuite/libjava.jvmti/geterrorname.java
@@ -0,0 +1,12 @@
+// Test JVMTI GetErrorName
+
+public class geterrorname
+{
+ public static native void do_errorname_tests ();
+
+ public static void main (String[] args)
+ {
+ System.out.println ("JVMTI GetErrorName tests");
+ do_errorname_tests ();
+ }
+}
diff --git a/libjava/testsuite/libjava.jvmti/geterrorname.out b/libjava/testsuite/libjava.jvmti/geterrorname.out
new file mode 100644
index 000000000..3b993d3b6
--- /dev/null
+++ b/libjava/testsuite/libjava.jvmti/geterrorname.out
@@ -0,0 +1,49 @@
+JVMTI GetErrorName tests
+none
+null pointer
+out of memory
+access denied
+wrong phase
+internal error
+unattached thread
+invalid environment
+invalid priority
+thread not suspended
+thread suspended
+thread not alive
+class not prepared
+no more frames
+opaque frame
+duplicate
+not found
+not monitor owner
+interrupted
+unmodifiable class
+not available
+absent information
+invalid event type
+native method
+invalid thread
+invalid thread group
+invalid object
+invalid class
+invalid method ID
+invalid location
+invalid field ID
+type mismatch
+invalid slot
+invalid monitor
+invalid class format
+circular class definition
+unsupported redefinition: method added
+unsupported redefinition: schema changed
+invalid type state
+fails verification
+unsupported redefinition: hierarchy changed
+unsupported redefinition: method deleted
+unsupported version
+names do not match
+unsupported redefinition: class modifiers changed
+unsupported redefinition: method modifiers changed
+must possess capability
+illegal argument
diff --git a/libjava/testsuite/libjava.jvmti/getmethodname.h b/libjava/testsuite/libjava.jvmti/getmethodname.h
new file mode 100644
index 000000000..e66898f33
--- /dev/null
+++ b/libjava/testsuite/libjava.jvmti/getmethodname.h
@@ -0,0 +1,27 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __getmethodname__
+#define __getmethodname__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ class getmethodname;
+}
+
+class getmethodname : public ::java::lang::Object
+{
+
+public:
+ getmethodname();
+ static void do_getmethodname_tests();
+ static void main(JArray< ::java::lang::String * > *);
+ static ::java::lang::Class class$;
+};
+
+#endif // __getmethodname__
diff --git a/libjava/testsuite/libjava.jvmti/getmethodname.jar b/libjava/testsuite/libjava.jvmti/getmethodname.jar
new file mode 100644
index 000000000..833629122
--- /dev/null
+++ b/libjava/testsuite/libjava.jvmti/getmethodname.jar
Binary files differ
diff --git a/libjava/testsuite/libjava.jvmti/getmethodname.java b/libjava/testsuite/libjava.jvmti/getmethodname.java
new file mode 100644
index 000000000..a0e00a98c
--- /dev/null
+++ b/libjava/testsuite/libjava.jvmti/getmethodname.java
@@ -0,0 +1,10 @@
+public class getmethodname
+{
+ public static native void do_getmethodname_tests ();
+
+ public static void main (String[] args)
+ {
+ System.out.println ("JVMTI GetMethodName tests");
+ do_getmethodname_tests ();
+ }
+}
diff --git a/libjava/testsuite/libjava.jvmti/getmethodname.out b/libjava/testsuite/libjava.jvmti/getmethodname.out
new file mode 100644
index 000000000..3f1a9ca14
--- /dev/null
+++ b/libjava/testsuite/libjava.jvmti/getmethodname.out
@@ -0,0 +1,59 @@
+JVMTI GetMethodName tests
+null jmethodID: invalid method ID
+GetClassMethods: none
+GetMethodName - name: none
+GetMethodName - signature: none
+GetMethodName - generic: none
+GetMethodName - name: none
+GetMethodName - signature: none
+GetMethodName - generic: none
+GetMethodName - name: none
+GetMethodName - signature: none
+GetMethodName - generic: none
+GetMethodName - name: none
+GetMethodName - signature: none
+GetMethodName - generic: none
+GetMethodName - name: none
+GetMethodName - signature: none
+GetMethodName - generic: none
+GetMethodName - name: none
+GetMethodName - signature: none
+GetMethodName - generic: none
+GetMethodName - name: none
+GetMethodName - signature: none
+GetMethodName - generic: none
+GetMethodName - name: none
+GetMethodName - signature: none
+GetMethodName - generic: none
+name=clone, signature=()Ljava.lang.Object;, generic=null
+names match
+signatures match
+generic not yet
+name=equals, signature=(Ljava.lang.Object;)Z, generic=null
+names match
+signatures match
+generic not yet
+name=finalize, signature=()V, generic=null
+names match
+signatures match
+generic not yet
+name=getClass, signature=()Ljava.lang.Class;, generic=null
+names match
+signatures match
+generic not yet
+name=hashCode, signature=()I, generic=null
+names match
+signatures match
+generic not yet
+name=notify, signature=()V, generic=null
+names match
+signatures match
+generic not yet
+name=notifyAll, signature=()V, generic=null
+names match
+signatures match
+generic not yet
+name=toString, signature=()Ljava.lang.String;, generic=null
+names match
+signatures match
+generic not yet
diff --git a/libjava/testsuite/libjava.jvmti/interp/getargssize.h b/libjava/testsuite/libjava.jvmti/interp/getargssize.h
new file mode 100644
index 000000000..e1e176761
--- /dev/null
+++ b/libjava/testsuite/libjava.jvmti/interp/getargssize.h
@@ -0,0 +1,19 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __getargssize__
+#define __getargssize__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT jint JNICALL Java_getargssize_do_1getargssize_1tests (JNIEnv *env, jclass);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __getargssize__ */
diff --git a/libjava/testsuite/libjava.jvmti/interp/getargssize.jar b/libjava/testsuite/libjava.jvmti/interp/getargssize.jar
new file mode 100644
index 000000000..4b92216fc
--- /dev/null
+++ b/libjava/testsuite/libjava.jvmti/interp/getargssize.jar
Binary files differ
diff --git a/libjava/testsuite/libjava.jvmti/interp/getargssize.java b/libjava/testsuite/libjava.jvmti/interp/getargssize.java
new file mode 100644
index 000000000..f5a2f25ca
--- /dev/null
+++ b/libjava/testsuite/libjava.jvmti/interp/getargssize.java
@@ -0,0 +1,36 @@
+public class getargssize
+{
+ static
+ {
+ System.loadLibrary("natgetargssize");
+ }
+
+ public int aMethod (float fone, int ione)
+ {
+ return 0;
+ }
+
+ public long bMethod (long lone, double done, int ione)
+ {
+ return 0;
+ }
+
+ public static boolean cMethod ()
+ {
+ return false;
+ }
+
+ public static Object dMethod (Object op)
+ {
+ return op;
+ }
+
+ public static native int do_getargssize_tests ();
+
+ public static void main (String[] args)
+ {
+ System.out.println ("JVMTI getargssize Interpreted Test");
+
+ do_getargssize_tests ();
+ }
+}
diff --git a/libjava/testsuite/libjava.jvmti/interp/getargssize.out b/libjava/testsuite/libjava.jvmti/interp/getargssize.out
new file mode 100644
index 000000000..cd9106623
--- /dev/null
+++ b/libjava/testsuite/libjava.jvmti/interp/getargssize.out
@@ -0,0 +1,5 @@
+JVMTI getargssize Interpreted Test
+Method 0 requires 3 slots for its arguments
+Method 1 requires 6 slots for its arguments
+Method 2 requires 0 slots for its arguments
+Method 3 requires 1 slots for its arguments
diff --git a/libjava/testsuite/libjava.jvmti/interp/getlocalvartable.h b/libjava/testsuite/libjava.jvmti/interp/getlocalvartable.h
new file mode 100644
index 000000000..8d4cb3bed
--- /dev/null
+++ b/libjava/testsuite/libjava.jvmti/interp/getlocalvartable.h
@@ -0,0 +1,19 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __getlocalvartable__
+#define __getlocalvartable__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT jint JNICALL Java_getlocalvartable_do_1getlocalvartable_1tests (JNIEnv *env, jclass);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __getlocalvartable__ */
diff --git a/libjava/testsuite/libjava.jvmti/interp/getlocalvartable.jar b/libjava/testsuite/libjava.jvmti/interp/getlocalvartable.jar
new file mode 100644
index 000000000..9fffb928d
--- /dev/null
+++ b/libjava/testsuite/libjava.jvmti/interp/getlocalvartable.jar
Binary files differ
diff --git a/libjava/testsuite/libjava.jvmti/interp/getlocalvartable.java b/libjava/testsuite/libjava.jvmti/interp/getlocalvartable.java
new file mode 100644
index 000000000..e0f3b31b8
--- /dev/null
+++ b/libjava/testsuite/libjava.jvmti/interp/getlocalvartable.java
@@ -0,0 +1,63 @@
+public class getlocalvartable
+{
+ public boolean done = false;
+
+ // num_frames is the number of frames > the original run () call so if
+ // num_frames = 1, the thread will have 2 frames, the original Thread.run
+ // call, plus one additional
+ public int num_frames, thread_num;
+
+ public static int num_threads = 1;
+
+ static
+ {
+ System.loadLibrary("natgetlocalvartable");
+ }
+
+ public double aMethod (float pone, float ptwo)
+ {
+ float fone, ftwo;
+ double done, dtwo;
+
+ fone = pone;
+ ftwo = 2 * ptwo;
+
+ done = 5 * fone;
+ dtwo = 6 * ftwo;
+
+ return done + dtwo;
+ }
+
+ public long bMethod (int ipone, int iptwo)
+ {
+ int ione, itwo;
+ long lone, ltwo;
+
+ ione = ipone;
+ itwo = 5 * iptwo;
+
+ lone = ione;
+ ltwo = 8 * itwo;
+
+ return lone + ltwo;
+ }
+
+ public Object cMethod (Object op)
+ {
+ Object oone, otwo;
+ oone = op;
+ otwo = oone;
+ oone = null;
+
+ return otwo;
+ }
+
+ public static native int do_getlocalvartable_tests ();
+
+ public static void main (String[] args)
+ {
+ System.out.println ("JVMTI getlocalvartable Interpreted Test");
+
+ do_getlocalvartable_tests ();
+ }
+}
diff --git a/libjava/testsuite/libjava.jvmti/interp/getlocalvartable.out b/libjava/testsuite/libjava.jvmti/interp/getlocalvartable.out
new file mode 100644
index 000000000..46c551318
--- /dev/null
+++ b/libjava/testsuite/libjava.jvmti/interp/getlocalvartable.out
@@ -0,0 +1,109 @@
+JVMTI getlocalvartable Interpreted Test
+Slot: 0
+ Name: this
+ Sig: Lgetlocalvartable;
+ Gen Sig: Lgetlocalvartable;
+ Start Loc: 0
+ Length: 29
+Slot: 1
+ Name: pone
+ Sig: F
+ Gen Sig: F
+ Start Loc: 0
+ Length: 29
+Slot: 2
+ Name: ptwo
+ Sig: F
+ Gen Sig: F
+ Start Loc: 0
+ Length: 29
+Slot: 3
+ Name: fone
+ Sig: F
+ Gen Sig: F
+ Start Loc: 2
+ Length: 27
+Slot: 4
+ Name: ftwo
+ Sig: F
+ Gen Sig: F
+ Start Loc: 7
+ Length: 22
+Slot: 5
+ Name: done
+ Sig: D
+ Gen Sig: D
+ Start Loc: 14
+ Length: 15
+Slot: 7
+ Name: dtwo
+ Sig: D
+ Gen Sig: D
+ Start Loc: 22
+ Length: 7
+Slot: 0
+ Name: this
+ Sig: Lgetlocalvartable;
+ Gen Sig: Lgetlocalvartable;
+ Start Loc: 0
+ Length: 26
+Slot: 1
+ Name: ipone
+ Sig: I
+ Gen Sig: I
+ Start Loc: 0
+ Length: 26
+Slot: 2
+ Name: iptwo
+ Sig: I
+ Gen Sig: I
+ Start Loc: 0
+ Length: 26
+Slot: 3
+ Name: ione
+ Sig: I
+ Gen Sig: I
+ Start Loc: 2
+ Length: 24
+Slot: 4
+ Name: itwo
+ Sig: I
+ Gen Sig: I
+ Start Loc: 7
+ Length: 19
+Slot: 5
+ Name: lone
+ Sig: J
+ Gen Sig: J
+ Start Loc: 11
+ Length: 15
+Slot: 7
+ Name: ltwo
+ Sig: J
+ Gen Sig: J
+ Start Loc: 19
+ Length: 7
+Slot: 0
+ Name: this
+ Sig: Lgetlocalvartable;
+ Gen Sig: Lgetlocalvartable;
+ Start Loc: 0
+ Length: 9
+Slot: 1
+ Name: op
+ Sig: Ljava/lang/Object;
+ Gen Sig: Ljava/lang/Object;
+ Start Loc: 0
+ Length: 9
+Slot: 2
+ Name: oone
+ Sig: Ljava/lang/Object;
+ Gen Sig: Ljava/lang/Object;
+ Start Loc: 2
+ Length: 7
+Slot: 3
+ Name: otwo
+ Sig: Ljava/lang/Object;
+ Gen Sig: Ljava/lang/Object;
+ Start Loc: 4
+ Length: 5
diff --git a/libjava/testsuite/libjava.jvmti/interp/getstacktrace.h b/libjava/testsuite/libjava.jvmti/interp/getstacktrace.h
new file mode 100644
index 000000000..6e5e8774e
--- /dev/null
+++ b/libjava/testsuite/libjava.jvmti/interp/getstacktrace.h
@@ -0,0 +1,21 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __getstacktrace__
+#define __getstacktrace__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_getstacktrace_natPlaceholder (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_getstacktrace_natRunner (JNIEnv *env, jobject);
+JNIEXPORT jint JNICALL Java_getstacktrace_do_1getstacktrace_1tests (JNIEnv *env, jclass, jobjectArray);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __getstacktrace__ */
diff --git a/libjava/testsuite/libjava.jvmti/interp/getstacktrace.jar b/libjava/testsuite/libjava.jvmti/interp/getstacktrace.jar
new file mode 100644
index 000000000..14b084a4d
--- /dev/null
+++ b/libjava/testsuite/libjava.jvmti/interp/getstacktrace.jar
Binary files differ
diff --git a/libjava/testsuite/libjava.jvmti/interp/getstacktrace.java b/libjava/testsuite/libjava.jvmti/interp/getstacktrace.java
new file mode 100644
index 000000000..21a21f0fb
--- /dev/null
+++ b/libjava/testsuite/libjava.jvmti/interp/getstacktrace.java
@@ -0,0 +1,88 @@
+public class getstacktrace
+ extends Thread
+{
+ public boolean done = false;
+
+ // num_frames is the number of frames > the original run () call so if
+ // num_frames = 1, the thread will have 2 frames, the original Thread.run
+ // call, plus one additional
+ public int num_frames, thread_num;
+
+ public static int num_threads = 1;
+
+ static
+ {
+ System.loadLibrary("natgetstacktrace");
+ }
+
+ public void run ()
+ {
+ thread_num = num_threads++;
+ num_frames = thread_num;
+
+ if (num_frames <= 1)
+ {
+ natRunner ();
+ }
+ else
+ {
+ if (thread_num % 2 == 0)
+ natPlaceholder ();
+ else
+ placeholder ();
+ }
+ }
+
+ public void placeholder ()
+ {
+ num_frames--;
+ if (num_frames <= 1)
+ {
+ if (thread_num % 2 == 1)
+ natRunner ();
+ else
+ runner ();
+ }
+ else
+ {
+ if (thread_num % 2 == 0)
+ natPlaceholder ();
+ else
+ placeholder ();
+ }
+ }
+
+ public void runner ()
+ {
+ done = true;
+ while (done)
+ yield ();
+ }
+
+ public native void natPlaceholder ();
+ public native void natRunner ();
+
+ public static native int do_getstacktrace_tests (Thread[] threads);
+
+ public static void main (String[] args)
+ {
+ System.out.println ("JVMTI GetStackTrace Interpreted Test");
+
+ getstacktrace[] threads = new getstacktrace[10];
+
+ for (int i = 0; i < threads.length; i++)
+ {
+ threads[i] = new getstacktrace ();
+ threads[i].start ();
+ while (!threads[i].done)
+ yield ();
+ }
+
+ do_getstacktrace_tests (threads);
+
+ for (int i = 0; i < threads.length; i++)
+ {
+ threads[i].done = false;
+ }
+ }
+}
diff --git a/libjava/testsuite/libjava.jvmti/interp/getstacktrace.out b/libjava/testsuite/libjava.jvmti/interp/getstacktrace.out
new file mode 100644
index 000000000..5134e6eab
--- /dev/null
+++ b/libjava/testsuite/libjava.jvmti/interp/getstacktrace.out
@@ -0,0 +1,76 @@
+JVMTI GetStackTrace Interpreted Test
+Thread has 2 frames
+Frame 0 is native
+Frame 1 is interpreted
+Thread has 3 frames
+Frame 0 is interpreted
+Frame 1 is native
+Frame 2 is interpreted
+Thread has 4 frames
+Frame 0 is native
+Frame 1 is interpreted
+Frame 2 is interpreted
+Frame 3 is interpreted
+Thread has 5 frames
+Frame 0 is interpreted
+Frame 1 is native
+Frame 2 is native
+Frame 3 is native
+Frame 4 is interpreted
+Thread has 6 frames
+Frame 0 is native
+Frame 1 is interpreted
+Frame 2 is interpreted
+Frame 3 is interpreted
+Frame 4 is interpreted
+Frame 5 is interpreted
+Thread has 7 frames
+Frame 0 is interpreted
+Frame 1 is native
+Frame 2 is native
+Frame 3 is native
+Frame 4 is native
+Frame 5 is native
+Frame 6 is interpreted
+Thread has 8 frames
+Frame 0 is native
+Frame 1 is interpreted
+Frame 2 is interpreted
+Frame 3 is interpreted
+Frame 4 is interpreted
+Frame 5 is interpreted
+Frame 6 is interpreted
+Frame 7 is interpreted
+Thread has 9 frames
+Frame 0 is interpreted
+Frame 1 is native
+Frame 2 is native
+Frame 3 is native
+Frame 4 is native
+Frame 5 is native
+Frame 6 is native
+Frame 7 is native
+Frame 8 is interpreted
+Thread has 10 frames
+Frame 0 is native
+Frame 1 is interpreted
+Frame 2 is interpreted
+Frame 3 is interpreted
+Frame 4 is interpreted
+Frame 5 is interpreted
+Frame 6 is interpreted
+Frame 7 is interpreted
+Frame 8 is interpreted
+Frame 9 is interpreted
+Thread has 11 frames
+Frame 0 is interpreted
+Frame 1 is native
+Frame 2 is native
+Frame 3 is native
+Frame 4 is native
+Frame 5 is native
+Frame 6 is native
+Frame 7 is native
+Frame 8 is native
+Frame 9 is native
+Frame 10 is interpreted
diff --git a/libjava/testsuite/libjava.jvmti/interp/natgetargssize.cc b/libjava/testsuite/libjava.jvmti/interp/natgetargssize.cc
new file mode 100644
index 000000000..326b5a68c
--- /dev/null
+++ b/libjava/testsuite/libjava.jvmti/interp/natgetargssize.cc
@@ -0,0 +1,58 @@
+#include <jni.h>
+
+#include <jvmti.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "getargssize.h"
+
+JNIEXPORT jint JNICALL Java_getargssize_do_1getargssize_1tests
+(JNIEnv *env, jclass klass)
+{
+ JavaVM *vm;
+ jint err = env->GetJavaVM (&vm);
+ if (err < 0)
+ {
+ fprintf (stderr, "error getting VM\n");
+ exit (1);
+ }
+
+ jvmtiEnv *jvmti = NULL;
+ vm->GetEnv ((void **) &jvmti, JVMTI_VERSION_1_0);
+
+ if (jvmti == NULL)
+ {
+ fprintf (stderr, "error getting jvmti environment\n");
+ exit (1);
+ }
+
+ jint args_size;
+
+ jvmtiError jerr;
+
+ jmethodID meth_ids[4];
+
+ meth_ids[0] = env->GetMethodID (klass, "aMethod", "(FI)I");
+ meth_ids[1] = env->GetMethodID (klass, "bMethod", "(JDI)J");
+ meth_ids[2] = env->GetStaticMethodID (klass, "cMethod", "()Z");
+ meth_ids[3] = env->GetStaticMethodID (klass, "dMethod",
+ "(Ljava/lang/Object;)Ljava/lang/Object;");
+ for (int i = 0; i < 4; i++)
+ {
+ jerr = jvmti->GetArgumentsSize (meth_ids[i], &args_size);
+ if (jerr != JVMTI_ERROR_NONE)
+ {
+ char *error_name;
+ jvmti->GetErrorName (jerr, &error_name);
+ fprintf (stderr, "JVMTI Error: %s\n", error_name);
+ jvmti->Deallocate (reinterpret_cast<unsigned char *> (error_name));
+ }
+ else
+ {
+ printf ("Method %d requires %d slots for its arguments\n", i,
+ args_size);
+ }
+ }
+
+ return 0;
+}
diff --git a/libjava/testsuite/libjava.jvmti/interp/natgetlocalvartable.cc b/libjava/testsuite/libjava.jvmti/interp/natgetlocalvartable.cc
new file mode 100644
index 000000000..8899bac3b
--- /dev/null
+++ b/libjava/testsuite/libjava.jvmti/interp/natgetlocalvartable.cc
@@ -0,0 +1,70 @@
+#include <jni.h>
+
+#include <jvmti.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "getlocalvartable.h"
+
+JNIEXPORT jint JNICALL Java_getlocalvartable_do_1getlocalvartable_1tests
+(JNIEnv *env, jclass klass)
+{
+ JavaVM *vm;
+ jint err = env->GetJavaVM (&vm);
+ if (err < 0)
+ {
+ fprintf (stderr, "error getting VM\n");
+ exit (1);
+ }
+
+ jvmtiEnv *jvmti = NULL;
+ vm->GetEnv ((void **) &jvmti, JVMTI_VERSION_1_0);
+
+ if (jvmti == NULL)
+ {
+ fprintf (stderr, "error getting jvmti environment\n");
+ exit (1);
+ }
+
+ jint entrys;
+ jvmtiLocalVariableEntry *var_table;
+
+ jvmtiError jerr;
+
+ jmethodID meth_ids[3];
+
+ meth_ids[0] = env->GetMethodID (klass, "aMethod", "(FF)D");
+ meth_ids[1] = env->GetMethodID (klass, "bMethod", "(II)J");
+ meth_ids[2] = env->GetMethodID (klass, "cMethod",
+ "(Ljava/lang/Object;)Ljava/lang/Object;");
+ for (int i = 0; i < 3; i++)
+ {
+ jerr = jvmti->GetLocalVariableTable (meth_ids[i], &entrys, &var_table);
+ if (jerr != JVMTI_ERROR_NONE)
+ {
+ char *error_name;
+ jvmti->GetErrorName (jerr, &error_name);
+ fprintf (stderr, "JVMTI Error: %s\n", error_name);
+ jvmti->Deallocate (reinterpret_cast<unsigned char *> (error_name));
+ }
+ else
+ {
+ for (int j = 0; j < entrys; j++)
+ {
+ printf ("Slot: %d\n", static_cast<int> (var_table[j].slot));
+ printf (" Name: %s\n", var_table[j].name);
+ jvmti->Deallocate (reinterpret_cast<unsigned char *> (var_table[j].name));
+ printf (" Sig: %s\n", var_table[j].signature);
+ jvmti->Deallocate (reinterpret_cast<unsigned char *> (var_table[j].signature));
+ printf (" Gen Sig: %s\n", var_table[j].generic_signature);
+ jvmti->Deallocate (reinterpret_cast<unsigned char *> (var_table[j].generic_signature));
+ printf (" Start Loc: %ld\n", static_cast<long> (var_table[j].start_location));
+ printf (" Length: %d\n", static_cast<int> (var_table[j].length));
+ }
+
+ jvmti->Deallocate (reinterpret_cast<unsigned char *> (var_table));
+ }
+ }
+
+ return 0;
+}
diff --git a/libjava/testsuite/libjava.jvmti/interp/natgetstacktrace.cc b/libjava/testsuite/libjava.jvmti/interp/natgetstacktrace.cc
new file mode 100644
index 000000000..cfd7c48c0
--- /dev/null
+++ b/libjava/testsuite/libjava.jvmti/interp/natgetstacktrace.cc
@@ -0,0 +1,144 @@
+#include <jni.h>
+
+#include <jvmti.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <unistd.h>
+
+#include "getstacktrace.h"
+
+void
+printStackTrace (jvmtiFrameInfo *frames, jint frame_cnt)
+{
+ printf ("Thread has %d frames\n", static_cast<int> (frame_cnt));
+
+ for (int i = 0; i < frame_cnt; i++)
+ {
+ jmethodID method = frames[i].method;
+ jlocation location = frames[i].location;
+
+ if (location == -1)
+ {
+ printf ("Frame %d is native\n", i);
+ }
+ else
+ {
+ printf ("Frame %d is interpreted\n", i);
+ }
+ }
+}
+
+
+JNIEXPORT void JNICALL Java_getstacktrace_natPlaceholder (JNIEnv *env, jobject obj)
+{
+ jclass klass = env->GetObjectClass (obj);
+ jfieldID done_id = env->GetFieldID (klass, "done", "Z");
+ jfieldID num_frames_id = env->GetFieldID (klass, "num_frames", "I");
+ jfieldID thread_num_id = env->GetFieldID (klass, "thread_num", "I");
+
+ // num_frames--
+ jint n_frames = env->GetIntField (obj, num_frames_id);
+ n_frames--;
+ env->SetIntField (obj, num_frames_id, n_frames);
+
+ jint t_num = env->GetIntField (obj, thread_num_id);
+
+ if (n_frames <= 1)
+ {
+ if (t_num % 2 == 1)
+ {
+ jmethodID natRunner_id = env->GetMethodID (klass, "natRunner", "()V");
+ env->CallVoidMethod (obj, natRunner_id);
+ }
+ else
+ {
+ jmethodID runner_id = env->GetMethodID (klass, "runner", "()V");
+ env->CallVoidMethod (obj, runner_id);
+ }
+ }
+ else
+ {
+ if (t_num % 2 == 0)
+ {
+ jmethodID natPlaceholder_id = env->GetMethodID (klass,
+ "natPlaceholder",
+ "()V");
+ env->CallVoidMethod (obj, natPlaceholder_id);
+ }
+ else
+ {
+ jmethodID placeholder_id = env->GetMethodID (klass, "placeholder",
+ "()V");
+ env->CallVoidMethod (obj, placeholder_id);
+ }
+ }
+}
+
+JNIEXPORT void JNICALL Java_getstacktrace_natRunner (JNIEnv *env, jobject obj)
+{
+ jclass klass = env->GetObjectClass (obj);
+ jfieldID done_id = env->GetFieldID (klass, "done", "Z");
+
+
+ jboolean done;
+ done = true;
+ env->SetBooleanField (obj, done_id, done);
+
+ do
+ {
+ done = env->GetBooleanField (obj, done_id);
+ if (done == false)
+ break;
+ usleep (40);
+ }
+ while (done != false);
+}
+
+JNIEXPORT jint JNICALL Java_getstacktrace_do_1getstacktrace_1tests
+(JNIEnv *env, jclass klass, jobjectArray thr_arr)
+{
+ JavaVM *vm;
+ jint err = env->GetJavaVM (&vm);
+ if (err < 0)
+ {
+ fprintf (stderr, "error getting VM\n");
+ exit (1);
+ }
+
+ jvmtiEnv *jvmti = NULL;
+ vm->GetEnv ((void **) &jvmti, JVMTI_VERSION_1_0);
+
+ if (jvmti == NULL)
+ {
+ fprintf (stderr, "error getting jvmti environment\n");
+ exit (1);
+ }
+
+ jint frame_cnt;
+ jvmtiFrameInfo frames[30];
+
+ jvmtiError jerr;
+ jthread thr;
+
+ jsize num_threads = env->GetArrayLength (thr_arr);
+
+ for (int i = 0; i < num_threads; i++)
+ {
+ thr = reinterpret_cast<jthread>
+ (env->GetObjectArrayElement (thr_arr, static_cast<jsize> (i)));
+ fflush (stdout);
+ jerr = jvmti->GetStackTrace (thr, 0, 30, frames, &frame_cnt);
+ if (jerr != JVMTI_ERROR_NONE)
+ {
+ char *error_name;
+ jvmti->GetErrorName (jerr, &error_name);
+ fprintf (stderr, "JVMTI Error: %s\n", error_name);
+ jvmti->Deallocate (reinterpret_cast<unsigned char *> (error_name));
+ }
+ else
+ {
+ printStackTrace (frames, frame_cnt);
+ }
+ }
+}
diff --git a/libjava/testsuite/libjava.jvmti/jvmti-interp.exp b/libjava/testsuite/libjava.jvmti/jvmti-interp.exp
new file mode 100644
index 000000000..fd660f351
--- /dev/null
+++ b/libjava/testsuite/libjava.jvmti/jvmti-interp.exp
@@ -0,0 +1,188 @@
+# Interpreted Tests for JVMTI code.
+# These tests are used to test JVMTI functions in a purley interpreted setting
+# This file compiles the JNI code into a shared object, then invokes gij to run
+# the test.
+
+
+# Compile a single C file and produce a .so file. OPTIONS is a list
+# of options to pass to the compiler. Returns 0 on failure, 1 on
+# success.
+proc gcj_jni_compile_c_to_so {file {options {}}} {
+ global srcdir subdir
+ global host_triplet
+ verbose "options: $options"
+ set options_cxx $options
+ set options ""
+
+# Apple uses a different extension for shared/dynamic libraries
+# so we check against powerpc-apple-darwin and set them to
+# dylib.
+# HP-UX uses sl, so we check this too, otherwise we take so.
+
+ if { [istarget "*-*-darwin*"] } {
+ set so_extension "dylib"
+ set so_flag "-dynamiclib"
+ } elseif { [istarget "hppa*-hp-hpux*"] } {
+ set so_extension "sl"
+ set so_flag "-shared"
+ } elseif { [istarget "*-*-cygwin*"] || [istarget "*-*-mingw*"] } {
+ set so_extension "dll"
+ set so_flag "-shared"
+ } else {
+ set so_extension "so"
+ set so_flag "-shared"
+ }
+
+ # ARM C++ emits an ABI warning for varargs.
+ if { [istarget "arm*"] } {
+ lappend options "additional_flags=-Wno-abi"
+ }
+ # Tru64 UNIX requires <pthread.h> to be compiled with -pthread.
+ if { [istarget "alpha*-dec-osf*"] } {
+ lappend options "additional_flags=-pthread"
+ }
+
+ set filename [file tail $file]
+ set name [file rootname $filename]
+ set soname lib${name}.${so_extension}
+
+ lappend options "additional_flags=${so_flag} -fPIC"
+ # Find the generated header.
+ lappend options "additional_flags=-I. -I.. -I$srcdir/$subdir"
+
+ # Ensure that the generated header has correct prototypes.
+ set cfile [file rootname $file].c
+ if { [file exists $cfile] } {
+ # This option is only valid for C sources.
+ lappend options "additional_flags=-Wmissing-prototypes"
+ }
+
+ # Find jni.h and jni_md.h.
+ lappend options "additional_flags=-I$srcdir/../include \
+ -I$srcdir/../classpath/include -fdollars-in-identifiers"
+
+ # Append C++ options
+ lappend options "additional_flags=$options_cxx"
+
+ set x [libjava_prune_warnings \
+ [target_compile $file $soname executable $options]]
+ if {$x != ""} {
+ verbose "target_compile failed: $x" 2
+ fail "$filename compilation"
+ return 0
+ }
+
+ pass "$filename compilation"
+ return 1
+}
+
+# Do all the work for a single JVMTI test. Return 0 on failure.
+proc gij_jvmti_test_one {file} {
+ global runtests
+
+ # The base name. We use it for several purposes.
+ set main [file rootname [file tail $file]]
+ if {! [runtest_file_p $runtests $main] } {
+ # Simply skip it.
+ return 1
+ }
+
+# if {! [bytecompile_file $file [pwd]] } {
+# fail "bytecompile $file"
+# # FIXME - should use `untested' on all remaining tests.
+# # But that is hard.
+# return 0
+# }
+# pass "bytecompile $file"
+
+# if {! [gcj_jvmti_build_headers $file] } {
+# # FIXME
+# return 0
+# }
+
+ set cfile [file join [file dirname $file] nat$main.c]
+ set cxxflags ""
+ set cxxldlibflags {}
+ # If there is no `.c' file, assume there is a `.cc' file.
+ if {! [file exists $cfile] } {
+ set cfile [file join [file dirname $file] nat$main.cc]
+
+ set cxxflaglist {}
+ foreach arg [split [libjava_find_lib libstdc++-v3/src stdc++] " "] {
+ switch -glob -- $arg {
+ "-L*" {
+ set arg [string range $arg 2 end]
+ lappend cxxldlibflags $arg
+ # Strip the `.libs' directory; we link with libtool which
+ # doesn't need it.
+ set arg "-L[file dirname $arg]"
+ }
+ }
+
+ lappend cxxflaglist $arg
+ # In case the libstdc++ is not installed yet, we pass the build
+ # directory of it to the cxxflaglist.
+ lappend cxxflaglist "-L$cxxldlibflags"
+ }
+ # If you're building the compiler with --prefix set to a place
+ # where it's not yet installed, then the linker won't be able to
+ # find the libgcc used by libgcj.dylib/libstdc++.dylib. We could pass
+ # the -dylib_file option, but that's complicated, and it's much easier
+ # to just make the linker find libgcc using -L options.
+ if { [istarget "*-*-darwin*"] } {
+ lappend cxxflaglist "-shared-libgcc -lstdc++"
+ } else {
+ lappend cxxflaglist "-lstdc++"
+ }
+ set cxxflags [join $cxxflaglist]
+ }
+
+ if {! [gcj_jni_compile_c_to_so $cfile $cxxflags] } {
+ # FIXME
+ return 0
+ }
+
+ libjava_arguments
+
+ set jarfile [file join [file dirname $file] $main.jar]
+ set gij_flags {-agentlib:dummyagent}
+ if {! [exec_gij $jarfile [file rootname $file].out $cxxldlibflags $gij_flags] } {
+ return 0
+ }
+
+ # When we succeed we remove all our clutter.
+ eval gcj_cleanup [glob -nocomplain -- ${main}.*] \
+ [list $main.class libnat$main.so]
+
+ return 1
+}
+
+# Run the JVMTI tests.
+proc gij_jvmti_run {} {
+ global srcdir subdir
+ global build_triplet host_triplet
+
+ # For now we only test JVMTI on native builds.
+ if {$build_triplet == $host_triplet} {
+
+ # Build our dummy JVMTI agent library
+ if {![gcj_jni_compile_c_to_so [file join $srcdir $subdir dummyagent.c]]} {
+ fail "compiling dummy JVMTI agent"
+ } else {
+ pass "compiling dummy JVMTI agent"
+
+ catch {lsort [glob -nocomplain ${srcdir}/${subdir}/interp/*.jar]} \
+ srcfiles
+
+ foreach x $srcfiles {
+ gij_jvmti_test_one $x
+ }
+
+ gcj_cleanup libdummyagent.so
+ }
+ } else {
+ verbose "JVMTI tests not run in cross-compilation environment"
+ }
+}
+
+gij_jvmti_run
diff --git a/libjava/testsuite/libjava.jvmti/jvmti.exp b/libjava/testsuite/libjava.jvmti/jvmti.exp
new file mode 100644
index 000000000..2d939852e
--- /dev/null
+++ b/libjava/testsuite/libjava.jvmti/jvmti.exp
@@ -0,0 +1,126 @@
+# Tests for JVMTI code.
+
+# Compile a single C++ file and produce a .o file. OPTIONS is a list
+# of options to pass to the compiler. Returns 0 on failure, 1 on
+# success.
+proc gcj_jvmti_compile_cxx_to_o {file {options {}}} {
+ global srcdir
+ global objdir
+
+ set name [file rootname [file tail $file]]
+ set oname ${name}.o
+
+ # Find the generated header.
+ lappend options "additional_flags=-g -I. -I.. -fdollars-in-identifiers"
+ # Find libgcj headers.
+ lappend options "additional_flags=-I$srcdir/.."
+ # Find jvmti.h, jvmti_md.h, jvmti-int.h, jvm.h requirements
+ lappend options "additional_flags=-I$srcdir/../include -I$srcdir/../classpath/include -I$objdir/../include -I$objdir/../../boehm-gc/include "
+ # ARM C++ emits an ABI warning for varargs.
+ if { [istarget "arm*"] } {
+ lappend options "additional_flags=-Wno-abi"
+ }
+ # Tru64 UNIX requires <pthread.h> to be compiled with -pthread.
+ if { [istarget "alpha*-dec-osf*"] } {
+ lappend options "additional_flags=-pthread"
+ }
+
+ set x [libjava_prune_warnings \
+ [target_compile $file $oname object $options]]
+ if {$x != ""} {
+ verbose "target_compile failed: $x" 2
+ fail "[file tail $file] compilation"
+ return 0
+ }
+
+ pass "[file tail $file] compilation"
+ return 1
+}
+
+# Build header files given name of .java file. Return 0 on failure.
+proc gcj_jvmti_build_headers {file} {
+ global libgcj_jar
+
+ set gcjh [find_gcjh]
+
+ # Currently we only build a header file for the main class from the
+ # .java file. If we need more than this, we'll have to figure
+ # something out.
+ set file [file rootname [file tail $file]]
+
+ set x [string trim [libjava_prune_warnings \
+ [lindex [local_exec "$gcjh -cni -force -classpath .:$libgcj_jar $file" "" "" 300] 1]]]
+ if {$x != ""} {
+ verbose "local_exec failed: $x" 2
+ fail "$file header generation"
+ return 0
+ }
+
+ pass "$file header generation"
+ return 1
+}
+
+# Do all the work for a single JVMTI test. Return 0 on failure.
+proc gcj_jvmti_test_one {file} {
+ global runtests
+
+ # The base name. We use it for several purposes.
+ set main [file rootname [file tail $file]]
+ if {! [runtest_file_p $runtests $main]} {
+ # Simply skip it.
+ return 1
+ }
+
+# if {! [bytecompile_file $file [pwd]]} {
+# fail "bytecompile $file"
+# # FIXME - should use `untested' on all remaining tests.
+# # But that is hard.
+# return 0
+# }
+# pass "bytecompile $file"
+
+# if {! [gcj_jvmti_build_headers $file]} {
+# # FIXME
+# return 0
+# }
+
+ set cfile [file join [file dirname $file] nat$main.cc]
+ if {! [gcj_jvmti_compile_cxx_to_o $cfile]} {
+ # FIXME
+ return 0
+ }
+
+ if {! [gcj_link $main $main [list $file nat$main.o]]} {
+ # FIXME
+ return 0
+ }
+
+ if {! [gcj_invoke $main [file rootname $file].out {}]} {
+ # FIXME
+ return 0
+ }
+
+ # When we succeed we remove all our clutter.
+ eval gcj_cleanup [glob -nocomplain -- ${main}.*] [list $main nat$main.o]
+
+ return 1
+}
+
+# Run the JVMTI tests.
+proc gcj_jvmti_run {} {
+ global srcdir subdir
+ global build_triplet host_triplet
+
+ # For now we only test JVMTI on native builds.
+ if {$build_triplet == $host_triplet} {
+ catch { lsort [glob -nocomplain ${srcdir}/${subdir}/*.jar] } srcfiles
+
+ foreach x $srcfiles {
+ gcj_jvmti_test_one $x
+ }
+ } else {
+ verbose "JVMTI tests not run in cross-compilation environment"
+ }
+}
+
+gcj_jvmti_run
diff --git a/libjava/testsuite/libjava.jvmti/natevents.cc b/libjava/testsuite/libjava.jvmti/natevents.cc
new file mode 100644
index 000000000..71c6489d8
--- /dev/null
+++ b/libjava/testsuite/libjava.jvmti/natevents.cc
@@ -0,0 +1,578 @@
+#include <gcj/cni.h>
+
+#include <jvm.h>
+#include <jvmti.h>
+#include <stdio.h>
+
+#include "jvmti-int.h"
+#include "events.h"
+
+void
+print_events ()
+{
+#define DO(X) \
+ do \
+ { \
+ if (JVMTI_REQUESTED_EVENT (X)) \
+ printf (#X ","); \
+ } \
+ while (0)
+
+ printf ("RequestedEvents: ");
+ DO (VMInit);
+ DO (VMDeath);
+ DO (ThreadStart);
+ DO (ThreadEnd);
+ DO (ClassFileLoadHook);
+ DO (ClassLoad);
+ DO (ClassPrepare);
+ DO (VMStart);
+ DO (Exception);
+ DO (ExceptionCatch);
+ DO (SingleStep);
+ DO (FramePop);
+ DO (Breakpoint);
+ DO (FieldAccess);
+ DO (FieldModification);
+ DO (MethodEntry);
+ DO (MethodExit);
+ DO (NativeMethodBind);
+ DO (CompiledMethodLoad);
+ DO (CompiledMethodUnload);
+ DO (DynamicCodeGenerated);
+ DO (DataDumpRequest);
+ DO (MonitorWait);
+ DO (MonitorWaited);
+ DO (MonitorContendedEnter);
+ DO (MonitorContendedEntered);
+ DO (GarbageCollectionStart);
+ DO (GarbageCollectionFinish);
+ DO (ObjectFree);
+ DO (VMObjectAlloc);
+ printf ("\n");
+#undef DO
+}
+
+static void
+VMInitCB (jvmtiEnv *env, JNIEnv *jni_env, jthread thread)
+{
+ printf ("VMInitCB jni_env=%#llx thread=%#llx\n",
+ (unsigned long long) jni_env, (unsigned long long) thread);
+}
+
+static void
+VMDeathCB (jvmtiEnv *env, JNIEnv *jni_env)
+{
+ printf ("VMDeathCB jni_env=%#llx\n", (unsigned long long) jni_env);
+}
+
+static void
+ThreadStartCB (jvmtiEnv *env, JNIEnv *jni_env, jthread thread)
+{
+ printf ("ThreadStartCB jni_env=%#llx thread=%#llx\n",
+ (unsigned long long) jni_env, (unsigned long long) thread);
+}
+
+static void
+ThreadEndCB (jvmtiEnv *env, JNIEnv *jni_env, jthread thread)
+{
+ printf ("ThreadEndCB jni_env=%#llx thread=%#llx\n",
+ (unsigned long long) jni_env, (unsigned long long) thread);
+}
+
+static void
+ClassFileLoadHookCB (jvmtiEnv *env, JNIEnv *jni_env,
+ jclass class_being_redefined, jobject loader,
+ const char *name, jobject protection_domain,
+ jint class_data_len, const unsigned char *class_data,
+ jint *new_class_data_len, unsigned char **new_class_data)
+{
+ printf ("ClassFileLoadHookCB jni_env=%#llx class_being_redefined=%#llx"
+ " loader=%#llx", (unsigned long long) jni_env, (unsigned long long)
+ class_being_redefined, (unsigned long long) loader);
+ printf (" name=%s protection_domain=%#llx class_data_len=%d class_data=%#llx",
+ name, (unsigned long long) protection_domain, (int) class_data_len,
+ (unsigned long long) class_data);
+ printf (" new_class_data_len=%#llx new_class_data=%#llx\n",
+ (unsigned long long) new_class_data_len, (unsigned long long)
+ new_class_data);
+}
+
+static void
+ClassLoadCB (jvmtiEnv *env, JNIEnv *jni_env, jthread thread, jclass klass)
+{
+ printf ("ClassLoadCB jni_env=%#llx thread=%#llx klass=%#llx\n",
+ (unsigned long long) jni_env, (unsigned long long) thread,
+ (unsigned long long) klass);
+}
+
+static void
+ClassPrepareCB (jvmtiEnv *env, JNIEnv *jni_env, jthread thread, jclass klass)
+{
+ printf ("ClassPrepareCB jni_env=%#llx thread=%#llx klass=%#llx\n",
+ (unsigned long long)jni_env, (unsigned long long) thread,
+ (unsigned long long) klass);
+}
+
+static void
+VMStartCB (jvmtiEnv *env, JNIEnv *jni_env)
+{
+ printf ("VMStartCB jni_env=%#llx\n", (unsigned long long) jni_env);
+}
+
+static void
+ExceptionCB (jvmtiEnv *env, JNIEnv *jni_env, jthread thread, jmethodID method,
+ jlocation location, jobject exception, jmethodID catch_method,
+ jlocation catch_location)
+{
+ printf ("ExceptionCB jni_env=%#llx thread=%#llx method=%#llx location=%#llx",
+ (unsigned long long) jni_env, (unsigned long long) thread,
+ (unsigned long long) method, (unsigned long long) location);
+ printf (" exception=%#llx catch_method=%#llx catch_location=%#llx\n",
+ (unsigned long long) exception, (unsigned long long) catch_method,
+ (unsigned long long) catch_location);
+}
+
+static void
+ExceptionCatchCB (jvmtiEnv *env, JNIEnv *jni_env, jthread thread,
+ jmethodID method, jlocation location, jobject exception)
+{
+ printf ("ExceptionCatchCB jni_env=%#llx thread=%#llx method=%#llx"
+ " location=%#llx",
+ (unsigned long long) jni_env, (unsigned long long) thread,
+ (unsigned long long) method, (unsigned long long) location);
+ printf (" exception=%#llx\n", (unsigned long long) exception);
+}
+
+static void
+SingleStepCB (jvmtiEnv *env, JNIEnv *jni_env, jthread thread, jmethodID method,
+ jlocation location)
+{
+ printf ("SingleStepCB jni_env=%#llx thread=%#llx method=%#llx"
+ " location=%#llx\n",
+ (unsigned long long) jni_env, (unsigned long long) thread,
+ (unsigned long long) method, (unsigned long long) location);
+}
+
+static void
+FramePopCB (jvmtiEnv *env, JNIEnv *jni_env, jthread thread, jmethodID method,
+ jboolean was_popped_by_exception)
+{
+ printf ("FramePopCB jni_env=%#llx thread=%#llx method=%#llx",
+ (unsigned long long) jni_env, (unsigned long long) thread,
+ (unsigned long long) method);
+ printf (" was_pooped_by_exception=%d\n", (was_popped_by_exception ?
+ 1 : 0));
+}
+
+static void
+BreakpointCB (jvmtiEnv *env, JNIEnv *jni_env, jthread thread, jmethodID method,
+ jlocation location)
+{
+ printf ("BreakpointCB jni_env=%#llx thread=%#llx method=%#llx"
+ " location=%#llx\n", (unsigned long long) jni_env,
+ (unsigned long long) thread, (unsigned long long) method,
+ (unsigned long long) location);
+}
+
+static void
+FieldAccessCB (jvmtiEnv *env, JNIEnv *jni_env, jthread thread,
+ jmethodID method, jlocation location, jclass field_klass,
+ jobject object, jfieldID field)
+{
+ printf ("FieldAccessCB jni_env=%#llx thread=%#llx method=%#llx"
+ " location=%#llx", (unsigned long long) jni_env, (unsigned long long)
+ thread, (unsigned long long) method, (unsigned long long) location);
+ printf (" field_klass=%#llx object=%#llx field=%#llx\n", (unsigned long long)
+ field_klass, (unsigned long long) object, (unsigned long long) field);
+}
+
+static void
+FieldModificationCB (jvmtiEnv *env, JNIEnv *jni_env, jthread thread,
+ jmethodID method, jlocation location, jclass field_klass,
+ jobject object, jfieldID field, char signature_type,
+ jvalue new_value)
+
+{
+ printf ("FieldModificationCB jni_env=%#llx thread=%#llx method=%#llx"
+ " location=%#llx", (unsigned long long) jni_env, (unsigned long long)
+ thread, (unsigned long long) method, (unsigned long long) location);
+ printf (" field_klass=%#llx object=%#llx field=%#llx signature_type=%c",
+ (unsigned long long) field_klass, (unsigned long long) object,
+ (unsigned long long) field, signature_type);
+ printf (" new_value=%#llx\n", (unsigned long long) new_value.l);
+}
+
+static void
+MethodEntryCB (jvmtiEnv *env, JNIEnv *jni_env, jthread thread,
+ jmethodID method)
+{
+ printf ("MethodEntryCB jni_env=%#llx thread=%#llx method=%#llx\n",
+ (unsigned long long) jni_env, (unsigned long long) thread,
+ (unsigned long long) method);
+}
+
+static void
+MethodExitCB (jvmtiEnv *env, JNIEnv *jni_env, jthread thread,
+ jmethodID method, jboolean was_popped_by_exception,
+ jvalue return_value)
+{
+ printf ("MethodExitCB jni_env=%#llx thread=%#llx method=%#llx",
+ (unsigned long long) jni_env, (unsigned long long) thread,
+ (unsigned long long) method);
+ printf (" was_popped_by_exception=%d return_value=%d\n",
+ (was_popped_by_exception) ? 1 : 0, (int) return_value.i);
+}
+
+static void
+NativeMethodBindCB (jvmtiEnv *env, JNIEnv *jni_env, jthread thread,
+ jmethodID method, void *address, void **new_address_ptr)
+{
+ printf ("NativeMethodBindCB jni_env=%#llx thread=%#llx method=%#llx",
+ (unsigned long long) jni_env, (unsigned long long) thread,
+ (unsigned long long) method);
+ printf (" address=%#llx new_address_ptr=%#llx\n", (unsigned long long)
+ address, (unsigned long long) new_address_ptr);
+}
+
+static void
+CompiledMethodLoadCB (jvmtiEnv *env, jmethodID method, jint code_size,
+ const void *code_addr, jint map_length,
+ const jvmtiAddrLocationMap *map,
+ const void *compile_info)
+{
+ printf ("CompiledMethodLoadCB method=%#llx code_size=%#llx code_addr=%#llx",
+ (unsigned long long) method, (unsigned long long) code_size,
+ (unsigned long long) code_addr);
+ printf (" map_length=%d map=%#llx compile_info=%#llx\n", (int) map_length,
+ (unsigned long long) map, (unsigned long long) compile_info);
+}
+
+static void
+CompiledMethodUnloadCB (jvmtiEnv *env, jmethodID method, const void *code_addr)
+{
+ printf ("CompiledMethodUnloadCB method=%#llx code_addr=%#llx\n",
+ (unsigned long long) method, (unsigned long long) code_addr);
+}
+
+static void
+DynamicCodeGeneratedCB (jvmtiEnv *env, const char *name, const void *address,
+ jint length)
+{
+ printf ("DynamicCodeGeneratedCB name=%s address=%#llx length=%d\n", name,
+ (unsigned long long) address, (int) length);
+}
+
+static void
+DataDumpRequestCB (jvmtiEnv *env)
+{
+ printf ("DataDumpRequestCB\n");
+}
+
+static void
+MonitorWaitCB (jvmtiEnv *env, JNIEnv *jni_env, jthread thread, jobject object,
+ jlong timeout)
+{
+ printf ("MonitorWaitCB jni_env=%#llx thread=%#llx object=%#llx timeout=%ld\n",
+ (unsigned long long) jni_env, (unsigned long long) thread,
+ (unsigned long long) object, (long) timeout);
+}
+
+static void
+MonitorWaitedCB (jvmtiEnv *env, JNIEnv *jni_env, jthread thread,
+ jobject object, jboolean timed_out)
+{
+ printf ("MonitorWaitedCB jni_env=%#llx thread=%#llx object=%#llx"
+ " timed_out=%d\n", (unsigned long long) jni_env, (unsigned long long)
+ thread, (unsigned long long) object, (timed_out) ? 1 : 0);
+}
+
+static void
+MonitorContendedEnterCB (jvmtiEnv *env, JNIEnv *jni_env, jthread thread,
+ jobject object)
+{
+ printf ("MonitorContendedEnterCB jni_env=%#llx thread=%#llx object=%#llx\n",
+ (unsigned long long) jni_env, (unsigned long long) thread,
+ (unsigned long long) object);
+}
+
+static void
+MonitorContendedEnteredCB (jvmtiEnv *env, JNIEnv *jni_env, jthread thread,
+ jobject object)
+{
+ printf ("MonitorContendedEnteredCB jni_env=%#llx thread=%#llx object=%#llx\n",
+ (unsigned long long) jni_env, (unsigned long long) thread,
+ (unsigned long long) object);
+}
+
+static void
+GarbageCollectionStartCB (jvmtiEnv *env)
+{
+ printf ("GarbageCollectionStartCB\n");
+}
+
+static void
+GarbageCollectionFinishCB (jvmtiEnv *env)
+{
+ printf ("GarbageCollectionFinishCB\n");
+}
+
+static void
+ObjectFreeCB (jvmtiEnv *env, jlong tag)
+{
+ printf ("ObjectFreeCB tag=%ld\n", (long) tag);
+}
+
+static void
+VMObjectAllocCB (jvmtiEnv *env, JNIEnv *jni_env, jthread thread,
+ jobject object, jclass object_klass, jlong size)
+{
+ printf ("VMObjectAllocCB jni_env=%#llx thread=%#llx object=%#llx",
+ (unsigned long long) jni_env, (unsigned long long) thread,
+ (unsigned long long) object);
+ printf (" object_klass=%#llx size=%ld\n", (unsigned long long) object_klass,
+ (long) size);
+}
+
+static void
+do_enable_tests ()
+{
+ printf ("- enable tests -\n");
+ JavaVM *vm = _Jv_GetJavaVM ();
+ jvmtiEnv *env[3];
+ int i;
+ for (i = 0; i < 3; ++i)
+ {
+ vm->GetEnv (reinterpret_cast<void **> (&env[i]), JVMTI_VERSION_1_0);
+ printf ("created JVMTI environment #%d\n", i);
+ }
+
+ jvmtiEventCallbacks callbacks;
+ memset (&callbacks, 0, sizeof (jvmtiEventCallbacks));
+
+ printf ("setting callbacks for envs\n");
+ callbacks.VMInit = VMInitCB;
+ env[0]->SetEventCallbacks (&callbacks, sizeof (callbacks));
+ callbacks.VMDeath = VMDeathCB;
+ env[1]->SetEventCallbacks (&callbacks, sizeof (callbacks));
+ callbacks.ThreadEnd = ThreadEndCB;
+ env[2]->SetEventCallbacks (&callbacks, sizeof (callbacks));
+ print_events ();
+
+ printf ("enable VM_INIT for env0, env1, env2\n");
+ env[0]->SetEventNotificationMode (JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL);
+ env[1]->SetEventNotificationMode (JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL);
+ env[2]->SetEventNotificationMode (JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL);
+ print_events ();
+
+ printf ("enable VM_DEATH for env1,env2\n");
+ env[1]->SetEventNotificationMode (JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL);
+ env[2]->SetEventNotificationMode (JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL);
+ print_events ();
+
+ /* Used to use a non-NULL event thread, but that causes problems
+ when SetEventNotificationMode tries to validate the thread. */
+ printf ("enable THREAD_END for env2\n");
+ env[2]->SetEventNotificationMode (JVMTI_ENABLE, JVMTI_EVENT_THREAD_END,
+ NULL);
+ print_events ();
+
+ printf ("disposing of env1\n");
+ env[1]->DisposeEnvironment ();
+ print_events ();
+
+ printf ("disposing of env0\n");
+ env[0]->DisposeEnvironment ();
+ print_events ();
+
+ printf ("disable VMInit in env2\n");
+ env[2]->SetEventNotificationMode (JVMTI_DISABLE, JVMTI_EVENT_VM_INIT, NULL);
+ print_events ();
+
+ printf ("clear VMDeath callback in env2\n");
+ callbacks.VMDeath = NULL;
+ env[2]->SetEventCallbacks (&callbacks, sizeof (callbacks));
+ print_events ();
+
+ printf ("sending VMInit\n");
+ _Jv_JVMTI_PostEvent (JVMTI_EVENT_VM_INIT, (jthread) 0x1234,
+ (JNIEnv *) 0x5678);
+
+ printf ("sending ThreadEnd\n");
+ _Jv_JVMTI_PostEvent (JVMTI_EVENT_THREAD_END, (jthread) 0x1234,
+ (JNIEnv *) 0x5678);
+
+ /* See comment above re: SetEventNotificationMode and validity
+ checking
+ printf ("sending ThreadEnd (no match)\n");
+ _Jv_JVMTI_PostEvent (JVMTI_EVENT_THREAD_END, (jthread) 0x4321,
+ (JNIEnv *) 0x5678);
+ */
+
+ printf ("sending VMDeath\n");
+ _Jv_JVMTI_PostEvent (JVMTI_EVENT_VM_DEATH, (jthread) NULL,
+ (JNIEnv *) 0x5678);
+
+ printf ("disposing of env2\n");
+ env[2]->DisposeEnvironment ();
+ print_events ();
+}
+
+static void
+do_callback_arg_tests ()
+{
+ printf ("- callback arg tests -\n");
+ JavaVM *vm = _Jv_GetJavaVM ();
+ jvmtiEnv *env;
+ vm->GetEnv (reinterpret_cast<void **> (&env), JVMTI_VERSION_1_0);
+
+ // Define all the callbacks
+#define DEFINE(Event) callbacks.Event = Event ## CB;
+ jvmtiEventCallbacks callbacks;
+ DEFINE(VMInit);
+ DEFINE(VMDeath);
+ DEFINE(ThreadStart);
+ DEFINE(ThreadEnd);
+ DEFINE(ClassFileLoadHook);
+ DEFINE(ClassLoad);
+ DEFINE(ClassPrepare);
+ DEFINE(VMStart);
+ DEFINE(Exception);
+ DEFINE(ExceptionCatch);
+ DEFINE(SingleStep);
+ DEFINE(FramePop);
+ DEFINE(Breakpoint);
+ DEFINE(FieldAccess);
+ DEFINE(FieldModification);
+ DEFINE(MethodEntry);
+ DEFINE(MethodExit);
+ DEFINE(NativeMethodBind);
+ DEFINE(CompiledMethodLoad);
+ DEFINE(CompiledMethodUnload);
+ DEFINE(DynamicCodeGenerated);
+ DEFINE(DataDumpRequest);
+ DEFINE(MonitorWait);
+ DEFINE(MonitorWaited);
+ DEFINE(MonitorContendedEnter);
+ DEFINE(MonitorContendedEntered);
+ DEFINE(GarbageCollectionStart);
+ DEFINE(GarbageCollectionFinish);
+ DEFINE(ObjectFree);
+ DEFINE(VMObjectAlloc);
+#undef DEFINE
+ env->SetEventCallbacks (&callbacks, sizeof (callbacks));
+
+ // Enable all the callbacks
+#define ENABLE(Event) \
+ env->SetEventNotificationMode (JVMTI_ENABLE, JVMTI_EVENT_ ## Event, NULL)
+ ENABLE (VM_INIT);
+ ENABLE (VM_DEATH);
+ ENABLE (THREAD_START);
+ ENABLE (THREAD_END);
+ ENABLE (CLASS_FILE_LOAD_HOOK);
+ ENABLE (CLASS_LOAD);
+ ENABLE (CLASS_PREPARE);
+ ENABLE (VM_START);
+ ENABLE (EXCEPTION);
+ ENABLE (EXCEPTION_CATCH);
+ ENABLE (SINGLE_STEP);
+ ENABLE (FRAME_POP);
+ ENABLE (BREAKPOINT);
+ ENABLE (FIELD_ACCESS);
+ ENABLE (FIELD_MODIFICATION);
+ ENABLE (METHOD_ENTRY);
+ ENABLE (METHOD_EXIT);
+ ENABLE (NATIVE_METHOD_BIND);
+ ENABLE (COMPILED_METHOD_LOAD);
+ ENABLE (COMPILED_METHOD_UNLOAD);
+ ENABLE (DYNAMIC_CODE_GENERATED);
+ ENABLE (DATA_DUMP_REQUEST);
+ ENABLE (MONITOR_WAIT);
+ ENABLE (MONITOR_WAITED);
+ ENABLE (MONITOR_CONTENDED_ENTER);
+ ENABLE (MONITOR_CONTENDED_ENTERED);
+ ENABLE (GARBAGE_COLLECTION_START);
+ ENABLE (GARBAGE_COLLECTION_FINISH);
+ ENABLE (OBJECT_FREE);
+ ENABLE (VM_OBJECT_ALLOC);
+
+ // All events should now be enabled.
+ print_events ();
+
+ _Jv_JVMTI_PostEvent (JVMTI_EVENT_VM_INIT, (jthread) 0x2, (JNIEnv *) 0x1);
+ _Jv_JVMTI_PostEvent (JVMTI_EVENT_VM_DEATH, (jthread) 0x2, (JNIEnv *) 0x1);
+ _Jv_JVMTI_PostEvent (JVMTI_EVENT_THREAD_START, (jthread) 0x2,
+ (JNIEnv *) 0x1);
+ _Jv_JVMTI_PostEvent (JVMTI_EVENT_THREAD_END, (jthread) 0x2,
+ (JNIEnv *) 0x1);
+ _Jv_JVMTI_PostEvent (JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, (jthread) 0xb00,
+ (JNIEnv *) 0x1, (jclass) 0x2, (jobject) 0x3,
+ "4", (jobject) 0x5, (jint) 6,
+ (const unsigned char *) 0x7, (jint *) 0x8,
+ (unsigned char **) 0x9);
+ _Jv_JVMTI_PostEvent (JVMTI_EVENT_CLASS_LOAD, (jthread) 0x2, (JNIEnv *) 0x1,
+ (jclass) 0x3);
+ _Jv_JVMTI_PostEvent (JVMTI_EVENT_CLASS_PREPARE, (jthread) 0x2,
+ (JNIEnv *) 0x1, (jclass) 0x3);
+ _Jv_JVMTI_PostEvent (JVMTI_EVENT_VM_START, (jthread) 0xb00, (JNIEnv *) 0x1);
+ _Jv_JVMTI_PostEvent (JVMTI_EVENT_EXCEPTION, (jthread) 0x2, (JNIEnv *) 0x1,
+ (jmethodID) 0x3, (jlocation) 0x4, (jobject) 0x5,
+ (jmethodID) 0x6, (jlocation) 0x7);
+ _Jv_JVMTI_PostEvent (JVMTI_EVENT_EXCEPTION_CATCH, (jthread) 0x2,
+ (JNIEnv *) 0x1, (jmethodID) 0x3, (jlocation) 0x4,
+ (jobject) 0x5);
+ _Jv_JVMTI_PostEvent (JVMTI_EVENT_SINGLE_STEP, (jthread) 0x2, (JNIEnv *) 0x1,
+ (jmethodID) 0x3, (jlocation) 0x4);
+ _Jv_JVMTI_PostEvent (JVMTI_EVENT_FRAME_POP, (jthread) 0x2, (JNIEnv *) 0x1,
+ (jmethodID) 0x3, 4);
+ _Jv_JVMTI_PostEvent (JVMTI_EVENT_BREAKPOINT, (jthread) 0x2, (JNIEnv *) 0x1,
+ (jmethodID) 0x3, (jlocation) 0x4);
+ _Jv_JVMTI_PostEvent (JVMTI_EVENT_FIELD_ACCESS, (jthread) 0x2,
+ (JNIEnv *) 0x1, (jmethodID) 0x3, (jlocation) 0x4,
+ (jclass) 0x5, (jobject) 0x6, (jfieldID) 0x7);
+ jvalue value;
+ value.l = (jobject) 0x9;
+ _Jv_JVMTI_PostEvent (JVMTI_EVENT_FIELD_MODIFICATION, (jthread) 0x2,
+ (JNIEnv *) 0x1, (jmethodID) 0x3, (jlocation) 0x4,
+ (jclass) 0x5, (jobject) 0x6, (jfieldID) 0x7,
+ (int) '8', value);
+ _Jv_JVMTI_PostEvent (JVMTI_EVENT_METHOD_ENTRY, (jthread) 0x2,
+ (JNIEnv *) 0x1, (jmethodID) 0x3);
+ jvalue value2;
+ value2.i = 5;
+ _Jv_JVMTI_PostEvent (JVMTI_EVENT_METHOD_EXIT, (jthread) 0x2,
+ (JNIEnv *) 0x1, (jmethodID) 0x3, 4, value2);
+ _Jv_JVMTI_PostEvent (JVMTI_EVENT_NATIVE_METHOD_BIND, (jthread) 0x2,
+ (JNIEnv *) 0x1, (jmethodID) 0x3, (void *) 0x4,
+ (void **) 0x5);
+ _Jv_JVMTI_PostEvent (JVMTI_EVENT_COMPILED_METHOD_LOAD, (jthread) 0xb00,
+ (jmethodID) 0x1, (jint) 2, (const void *) 0x3,
+ (jint) 4, (const jvmtiAddrLocationMap *) 0x5,
+ (const void *) 0x6);
+ _Jv_JVMTI_PostEvent (JVMTI_EVENT_COMPILED_METHOD_UNLOAD, (jthread) 0xb00,
+ (jmethodID) 0x1, (const void *) 0x2);
+ _Jv_JVMTI_PostEvent (JVMTI_EVENT_DYNAMIC_CODE_GENERATED, (jthread) 0xb00,
+ "1", (const void *) 0x2, (jint) 3);
+ _Jv_JVMTI_PostEvent (JVMTI_EVENT_DATA_DUMP_REQUEST, (jthread) 0xb00);
+ _Jv_JVMTI_PostEvent (JVMTI_EVENT_MONITOR_WAIT, (jthread) 0x2,
+ (JNIEnv *) 0x1, (jobject) 0x3, (jlong) 4);
+ _Jv_JVMTI_PostEvent (JVMTI_EVENT_MONITOR_WAITED, (jthread) 0x2,
+ (JNIEnv *) 0x1, (jobject) 0x3, (int) 4);
+ _Jv_JVMTI_PostEvent (JVMTI_EVENT_MONITOR_CONTENDED_ENTER, (jthread) 0x2,
+ (JNIEnv *) 0x1, (jobject) 0x3);
+ _Jv_JVMTI_PostEvent (JVMTI_EVENT_MONITOR_CONTENDED_ENTERED, (jthread) 0x2,
+ (JNIEnv *) 0x1, (jobject) 0x3);
+ _Jv_JVMTI_PostEvent (JVMTI_EVENT_GARBAGE_COLLECTION_START, (jthread) 0xb00);
+ _Jv_JVMTI_PostEvent (JVMTI_EVENT_GARBAGE_COLLECTION_FINISH, (jthread) 0xb00);
+ _Jv_JVMTI_PostEvent (JVMTI_EVENT_OBJECT_FREE, (jthread) 0xb00, (jlong) 1);
+ _Jv_JVMTI_PostEvent (JVMTI_EVENT_VM_OBJECT_ALLOC, (jthread) 0x2,
+ (JNIEnv *) 0x1, (jobject) 0x3, (jclass) 0x4,
+ (jlong) 5);
+}
+
+void
+events::do_events_tests ()
+{
+ do_enable_tests ();
+ do_callback_arg_tests ();
+}
diff --git a/libjava/testsuite/libjava.jvmti/natgetallthreads.cc b/libjava/testsuite/libjava.jvmti/natgetallthreads.cc
new file mode 100644
index 000000000..9c4d69cde
--- /dev/null
+++ b/libjava/testsuite/libjava.jvmti/natgetallthreads.cc
@@ -0,0 +1,55 @@
+#include <gcj/cni.h>
+
+#include <jvm.h>
+#include <jvmti.h>
+#include <stdio.h>
+
+#include "jvmti-int.h"
+#include "getallthreads.h"
+
+void
+getallthreads::natPlaceholder ()
+{
+ ex_frames--;
+
+ if (ex_frames > 0)
+ {
+ if ((getallthreads::thread_num % 2) == 0)
+ placeholder ();
+ else
+ natPlaceholder ();
+ }
+ else
+ natRunner ();
+}
+
+void
+getallthreads::natRunner ()
+{
+ done = true;
+ while (done)
+ yield ();
+}
+
+void
+getallthreads::do_getallthreads_tests ()
+{
+ jvmtiEnv *env;
+ JavaVM *vm = _Jv_GetJavaVM ();
+ vm->GetEnv (reinterpret_cast<void **> (&env), JVMTI_VERSION_1_0);
+
+ jint num_threads;
+ jthread *thread_arr;
+
+ jvmtiError jerr = env->GetAllThreads (&num_threads, &thread_arr);
+ if (jerr != JVMTI_ERROR_NONE)
+ {
+ printf ("Test Failed, JVMTI Error!\n");
+ return;
+ }
+ env->Deallocate (reinterpret_cast<unsigned char *> (thread_arr));
+
+ for (int i = 0; i < num_threads; i++)
+ printf ("Found thread %d\n", i+1 );
+}
+
diff --git a/libjava/testsuite/libjava.jvmti/natgeterrorname.cc b/libjava/testsuite/libjava.jvmti/natgeterrorname.cc
new file mode 100644
index 000000000..46e2590ae
--- /dev/null
+++ b/libjava/testsuite/libjava.jvmti/natgeterrorname.cc
@@ -0,0 +1,76 @@
+#include <gcj/cni.h>
+
+#include <jvm.h>
+#include <jvmti.h>
+#include <stdio.h>
+
+#include "jvmti-int.h"
+#include "geterrorname.h"
+
+static void
+get_error (jvmtiEnv *env, jvmtiError err)
+{
+ char *s;
+ env->GetErrorName (err, &s);
+ printf ("%s\n", s);
+ env->Deallocate (reinterpret_cast<unsigned char *> (s));
+}
+
+void
+geterrorname::do_errorname_tests ()
+{
+ jvmtiEnv *env;
+ JavaVM *vm = _Jv_GetJavaVM ();
+ vm->GetEnv (reinterpret_cast<void **> (&env), JVMTI_VERSION_1_0);
+
+ get_error (env, JVMTI_ERROR_NONE);
+ get_error (env, JVMTI_ERROR_NULL_POINTER);
+ get_error (env, JVMTI_ERROR_OUT_OF_MEMORY);
+ get_error (env, JVMTI_ERROR_ACCESS_DENIED);
+ get_error (env, JVMTI_ERROR_WRONG_PHASE);
+ get_error (env, JVMTI_ERROR_INTERNAL);
+ get_error (env, JVMTI_ERROR_UNATTACHED_THREAD);
+ get_error (env, JVMTI_ERROR_INVALID_ENVIRONMENT);
+ get_error (env, JVMTI_ERROR_INVALID_PRIORITY);
+ get_error (env, JVMTI_ERROR_THREAD_NOT_SUSPENDED);
+ get_error (env, JVMTI_ERROR_THREAD_SUSPENDED);
+ get_error (env, JVMTI_ERROR_THREAD_NOT_ALIVE);
+ get_error (env, JVMTI_ERROR_CLASS_NOT_PREPARED);
+ get_error (env, JVMTI_ERROR_NO_MORE_FRAMES);
+ get_error (env, JVMTI_ERROR_OPAQUE_FRAME);
+ get_error (env, JVMTI_ERROR_DUPLICATE);
+ get_error (env, JVMTI_ERROR_NOT_FOUND);
+ get_error (env, JVMTI_ERROR_NOT_MONITOR_OWNER);
+ get_error (env, JVMTI_ERROR_INTERRUPT);
+ get_error (env, JVMTI_ERROR_UNMODIFIABLE_CLASS);
+ get_error (env, JVMTI_ERROR_NOT_AVAILABLE);
+ get_error (env, JVMTI_ERROR_ABSENT_INFORMATION);
+ get_error (env, JVMTI_ERROR_INVALID_EVENT_TYPE);
+ get_error (env, JVMTI_ERROR_NATIVE_METHOD);
+ get_error (env, JVMTI_ERROR_INVALID_THREAD);
+ get_error (env, JVMTI_ERROR_INVALID_THREAD_GROUP);
+ get_error (env, JVMTI_ERROR_INVALID_OBJECT);
+ get_error (env, JVMTI_ERROR_INVALID_CLASS);
+ get_error (env, JVMTI_ERROR_INVALID_METHODID);
+ get_error (env, JVMTI_ERROR_INVALID_LOCATION);
+ get_error (env, JVMTI_ERROR_INVALID_FIELDID);
+ get_error (env, JVMTI_ERROR_TYPE_MISMATCH);
+ get_error (env, JVMTI_ERROR_INVALID_SLOT);
+ get_error (env, JVMTI_ERROR_INVALID_MONITOR);
+ get_error (env, JVMTI_ERROR_INVALID_CLASS_FORMAT);
+ get_error (env, JVMTI_ERROR_CIRCULAR_CLASS_DEFINITION);
+ get_error (env, JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_ADDED);
+ get_error (env, JVMTI_ERROR_UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED);
+ get_error (env, JVMTI_ERROR_INVALID_TYPESTATE);
+ get_error (env, JVMTI_ERROR_FAILS_VERIFICATION);
+ get_error (env, JVMTI_ERROR_UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED);
+ get_error (env, JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_DELETED);
+ get_error (env, JVMTI_ERROR_UNSUPPORTED_VERSION);
+ get_error (env, JVMTI_ERROR_NAMES_DONT_MATCH);
+ get_error (env,
+ JVMTI_ERROR_UNSUPPORTED_REDEFINITION_CLASS_MODIFIERS_CHANGED);
+ get_error (env,
+ JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_MODIFIERS_CHANGED);
+ get_error (env, JVMTI_ERROR_MUST_POSSESS_CAPABILITY);
+ get_error (env, JVMTI_ERROR_ILLEGAL_ARGUMENT);
+}
diff --git a/libjava/testsuite/libjava.jvmti/natgetmethodname.cc b/libjava/testsuite/libjava.jvmti/natgetmethodname.cc
new file mode 100644
index 000000000..3d759d58d
--- /dev/null
+++ b/libjava/testsuite/libjava.jvmti/natgetmethodname.cc
@@ -0,0 +1,116 @@
+#include <gcj/cni.h>
+
+#include <jvm.h>
+#include <jvmti.h>
+#include <stdio.h>
+
+#include <java/lang/Object.h>
+
+#include "getmethodname.h"
+
+static void
+print_error (jvmtiEnv *env, const char *msg, jvmtiError err)
+{
+ char *error_msg;
+ env->GetErrorName (err, &error_msg);
+ printf ("%s: %s\n", msg, error_msg);
+ env->Deallocate (reinterpret_cast<unsigned char *> (error_msg));
+}
+
+#define NUM_METHODS 8
+static const char *function_names[] = { "clone",
+ "equals",
+ "finalize",
+ "getClass",
+ "hashCode",
+ "notify",
+ "notifyAll",
+ "toString" };
+static int
+function_index (const char *name)
+{
+ for (int i = 0; i < NUM_METHODS; ++i)
+ {
+ if (strcmp (function_names[i], name) == 0)
+ return i;
+ }
+
+ return -1;
+}
+
+void
+getmethodname::do_getmethodname_tests ()
+{
+ jvmtiEnv *env;
+ JavaVM *vm = _Jv_GetJavaVM ();
+ vm->GetEnv (reinterpret_cast<void **> (&env), JVMTI_VERSION_1_0);
+
+ jvmtiError err;
+ err = env->GetMethodName (reinterpret_cast<jmethodID> (NULL),
+ reinterpret_cast<char **> (NULL),
+ reinterpret_cast<char **> (NULL),
+ reinterpret_cast<char **> (NULL));
+ print_error (env, "null jmethodID", err);
+
+ jint count;
+ jmethodID *methods;
+ err = env->GetClassMethods (&java::lang::Object::class$, &count, &methods);
+ print_error (env, "GetClassMethods", err);
+
+ char *names[NUM_METHODS], *solo_names[NUM_METHODS];
+ char *signatures[NUM_METHODS], *solo_signatures[NUM_METHODS];
+ char *generics[NUM_METHODS], *solo_generics[NUM_METHODS];
+
+ for (jint i = 0; i < count; ++i)
+ {
+ char *name, *n;
+ char *signature, *s;
+ char *generic, *g;
+ err = env->GetMethodName (methods[i], &name, &signature, &generic);
+
+ int idx = -1;
+ if (err != JVMTI_ERROR_NONE)
+ {
+ print_error (env, "GetMethodName - all fields", err);
+ continue;
+ }
+
+ idx = function_index (name);
+ if (idx == -1)
+ continue;
+
+ names[idx] = name;
+ signatures[idx] = signature;
+ generics[idx] = generic;
+
+ err = env->GetMethodName (methods[i], &n, NULL, NULL);
+ print_error (env, "GetMethodName - name", err);
+ solo_names[idx] = n;
+
+ err = env->GetMethodName (methods[i], NULL, &s, NULL);
+ print_error (env, "GetMethodName - signature", err);
+ solo_signatures[idx] = s;
+
+ err = env->GetMethodName (methods[i], NULL, NULL, &g);
+ print_error (env, "GetMethodName - generic", err);
+ solo_generics[idx] = g;
+ }
+
+#define WRAP(X) ((X) == NULL ? "null" : (X))
+#define MATCH(X,Y) (strcmp ((X),(Y)) == 0 ? "match" : "do not match")
+ for (int i = 0; i < NUM_METHODS; ++i)
+ {
+ printf ("name=%s, signature=%s, generic=%s\n",
+ WRAP (names[i]), WRAP (signatures[i]), WRAP (generics[i]));
+ printf ("names %s\n", MATCH (solo_names[i], names[i]));
+ printf ("signatures %s\n", MATCH (solo_signatures[i], signatures[i]));
+ printf ("generic %s\n", "not yet");
+
+ env->Deallocate (reinterpret_cast<unsigned char *> (names[i]));
+ env->Deallocate (reinterpret_cast<unsigned char *> (solo_names[i]));
+ env->Deallocate (reinterpret_cast<unsigned char *> (signatures[i]));
+ env->Deallocate (reinterpret_cast<unsigned char *> (solo_signatures[i]));
+ env->Deallocate (reinterpret_cast<unsigned char *> (generics[i]));
+ env->Deallocate (reinterpret_cast<unsigned char *> (solo_generics[i]));
+ }
+}