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/natgetlocalvartable.cc | |
download | cbb-gcc-4.6.4-upstream.tar.bz2 cbb-gcc-4.6.4-upstream.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/natgetlocalvartable.cc')
-rw-r--r-- | libjava/testsuite/libjava.jvmti/interp/natgetlocalvartable.cc | 70 |
1 files changed, 70 insertions, 0 deletions
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; +} |