aboutsummaryrefslogtreecommitdiff
path: root/libjava/jvmti.cc
diff options
context:
space:
mode:
authorKyle Galloway <kgallowa@redhat.com>2007-02-15 15:08:27 +0000
committerKyle Galloway <kgallowa@gcc.gnu.org>2007-02-15 15:08:27 +0000
commitfe60528edc81e6aaccb5b49b7108853f30ea6278 (patch)
treed582917d66a2280e29d258af271b3d5500823c60 /libjava/jvmti.cc
parented765125f2981bc0c2976b5650ba54abc3cb5f2e (diff)
downloadgcc-fe60528edc81e6aaccb5b49b7108853f30ea6278.zip
gcc-fe60528edc81e6aaccb5b49b7108853f30ea6278.tar.gz
gcc-fe60528edc81e6aaccb5b49b7108853f30ea6278.tar.bz2
defineclass.cc (_Jv_ClassReader::read_one_code_attribute): Added LocalVariableTable attribute handling.
2007-02-15 Kyle Galloway <kgallowa@redhat.com> * defineclass.cc (_Jv_ClassReader::read_one_code_attribute): Added LocalVariableTable attribute handling. (_Jv_ClassReader::pool_Utf8_to_char_arr): New method. * jvmti.cc (_Jv_JVMTI_GetLocalVariableTable): New method. * include/java-interp.h: Added local_var_table and local_var_table_len fields to _Jv_InterpMethod. (_Jv_InterpMethod::get_local_var_table): New method. * testsuite/libjava.jvmti/interp/getlocalvartable.java: New test. * testsuite/libjava.jvmti/interp/getlocalvartable.jar: New test. * testsuite/libjava.jvmti/interp/getlocalvartable.out: Output for new test. * testsuite/libjava.jvmti/interp/getlocalvartable.h: New test. * testsuite/libjava.jvmti/interp/natgetlocalvartable.cc: New test. From-SVN: r121999
Diffstat (limited to 'libjava/jvmti.cc')
-rw-r--r--libjava/jvmti.cc87
1 files changed, 84 insertions, 3 deletions
diff --git a/libjava/jvmti.cc b/libjava/jvmti.cc
index 37e6727..ae906a0 100644
--- a/libjava/jvmti.cc
+++ b/libjava/jvmti.cc
@@ -704,6 +704,88 @@ _Jv_JVMTI_GetLineNumberTable (jvmtiEnv *env, jmethodID method,
}
static jvmtiError JNICALL
+_Jv_JVMTI_GetLocalVariableTable (MAYBE_UNUSED jvmtiEnv *env, jmethodID method,
+ jint *num_locals,
+ jvmtiLocalVariableEntry **locals)
+{
+ REQUIRE_PHASE (env, JVMTI_PHASE_LIVE);
+ NULL_CHECK (num_locals);
+ NULL_CHECK (locals);
+
+ CHECK_FOR_NATIVE_METHOD(method);
+
+ jclass klass;
+ jvmtiError jerr = env->GetMethodDeclaringClass (method, &klass);
+ if (jerr != JVMTI_ERROR_NONE)
+ return jerr;
+
+ _Jv_InterpMethod *imeth = reinterpret_cast<_Jv_InterpMethod *>
+ (_Jv_FindInterpreterMethod (klass, method));
+
+ if (imeth == NULL)
+ return JVMTI_ERROR_INVALID_METHODID;
+
+ jerr = env->GetMaxLocals (method, num_locals);
+ if (jerr != JVMTI_ERROR_NONE)
+ return jerr;
+
+ jerr = env->Allocate (static_cast<jlong>
+ ((*num_locals) * sizeof (jvmtiLocalVariableEntry)),
+ reinterpret_cast<unsigned char **> (locals));
+
+ if (jerr != JVMTI_ERROR_NONE)
+ return jerr;
+
+ //the slot in the methods local_var_table to get
+ int table_slot = 0;
+ char *name;
+ char *sig;
+ char *generic_sig;
+
+ while (table_slot < *num_locals
+ && imeth->get_local_var_table (&name, &sig, &generic_sig,
+ &((((*locals)[table_slot].start_location))),
+ &((*locals)[table_slot].length),
+ &((*locals)[table_slot].slot),
+ table_slot)
+ >= 0)
+ {
+ jerr = env->Allocate (static_cast<jlong> (strlen (name) + 1),
+ reinterpret_cast<unsigned char **>
+ (&(*locals)[table_slot].name));
+ if (jerr != JVMTI_ERROR_NONE)
+ return jerr;
+ strcpy ((*locals)[table_slot].name, name);
+
+ jerr = env->Allocate (static_cast<jlong> (strlen (name) + 1),
+ reinterpret_cast<unsigned char **>
+ (&(*locals)[table_slot].signature));
+ if (jerr != JVMTI_ERROR_NONE)
+ return jerr;
+ strcpy ((*locals)[table_slot].signature, sig);
+
+ jerr = env->Allocate (static_cast<jlong> (strlen (name) + 1),
+ reinterpret_cast<unsigned char **>
+ (&(*locals)[table_slot].generic_signature));
+ if (jerr != JVMTI_ERROR_NONE)
+ return jerr;
+ strcpy ((*locals)[table_slot].generic_signature, generic_sig);
+
+ table_slot++;
+ }
+
+ if (table_slot == 0)
+ return JVMTI_ERROR_ABSENT_INFORMATION;
+
+ // If there are double or long variables in the table, the the table will be
+ // smaller than the max number of slots, so correct for this here.
+ if ((table_slot) < *num_locals)
+ *num_locals = table_slot;
+
+ return JVMTI_ERROR_NONE;
+}
+
+static jvmtiError JNICALL
_Jv_JVMTI_IsMethodNative (MAYBE_UNUSED jvmtiEnv *env, jmethodID method,
jboolean *result)
{
@@ -733,8 +815,7 @@ _Jv_JVMTI_IsMethodSynthetic (MAYBE_UNUSED jvmtiEnv *env, jmethodID method,
}
static jvmtiError JNICALL
-_Jv_JVMTI_GetMaxLocals (MAYBE_UNUSED jvmtiEnv *env, jmethodID method,
- jint *max_locals)
+_Jv_JVMTI_GetMaxLocals (jvmtiEnv *env, jmethodID method, jint *max_locals)
{
REQUIRE_PHASE (env, JVMTI_PHASE_START | JVMTI_PHASE_LIVE);
NULL_CHECK (max_locals);
@@ -1686,7 +1767,7 @@ struct _Jv_jvmtiEnv _Jv_JVMTI_Interface =
UNIMPLEMENTED, // GetArgumentsSize
_Jv_JVMTI_GetLineNumberTable, // GetLineNumberTable
UNIMPLEMENTED, // GetMethodLocation
- UNIMPLEMENTED, // GetLocalVariableTable
+ _Jv_JVMTI_GetLocalVariableTable, // GetLocalVariableTable
RESERVED, // reserved73
RESERVED, // reserved74
UNIMPLEMENTED, // GetBytecodes