diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /libjava/testsuite/libjava.jvmti/interp | |
download | cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2 cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'libjava/testsuite/libjava.jvmti/interp')
15 files changed, 708 insertions, 0 deletions
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 Binary files differnew file mode 100644 index 000000000..4b92216fc --- /dev/null +++ b/libjava/testsuite/libjava.jvmti/interp/getargssize.jar 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 Binary files differnew file mode 100644 index 000000000..9fffb928d --- /dev/null +++ b/libjava/testsuite/libjava.jvmti/interp/getlocalvartable.jar 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 Binary files differnew file mode 100644 index 000000000..14b084a4d --- /dev/null +++ b/libjava/testsuite/libjava.jvmti/interp/getstacktrace.jar 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); + } + } +} |