From dc464b9488f7a9be21dc16df4c475a53c824483a Mon Sep 17 00:00:00 2001 From: kgallowa Date: Tue, 6 Mar 2007 21:09:22 +0000 Subject: 2007-03-06 Kyle Galloway * classpath/gnu/classpath/jdwp/exception/AbsentInformationException.java: New file. * classpath/lib/gnu/classpath/jdwp/exception/AbsentInformationException.class: Ditto. * gnu/classpath/jdwp/exception/AbsentInformationException.h: Ditto. * gnu/classpath/jdwp/natVMMethod.cc: Add CHECK_INTERP_CLASS macro. (VMMethod::getLineTable): Use new macro. (VMMethod::getVariableTable): Implement. * sources.am: Regenerated. * Makefile.in: Ditto. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@122639 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/gnu/classpath/jdwp/natVMMethod.cc | 97 ++++++++++++++++++++++++++++--- 1 file changed, 90 insertions(+), 7 deletions(-) (limited to 'libjava/gnu/classpath/jdwp/natVMMethod.cc') diff --git a/libjava/gnu/classpath/jdwp/natVMMethod.cc b/libjava/gnu/classpath/jdwp/natVMMethod.cc index 07d5622c704..76fd0a64168 100644 --- a/libjava/gnu/classpath/jdwp/natVMMethod.cc +++ b/libjava/gnu/classpath/jdwp/natVMMethod.cc @@ -15,10 +15,25 @@ details. */ #include "jvmti-int.h" #include +#include +#include #include #include #include +using namespace java::lang; + +#define CHECK_INTERP_CLASS() \ +do \ + { \ + if (!_Jv_IsInterpretedClass (getDeclaringClass ())) \ + { \ + ::java::lang::String *msg = JvNewStringLatin1 ("native class"); \ + throw new exception::JdwpInternalErrorException (msg); \ + } \ + } \ +while (0) + jstring gnu::classpath::jdwp::VMMethod::getName () { @@ -56,12 +71,7 @@ gnu::classpath::jdwp::VMMethod::getModifiers () gnu::classpath::jdwp::util::LineTable * gnu::classpath::jdwp::VMMethod::getLineTable () { - if (!_Jv_IsInterpretedClass (getDeclaringClass ())) - { - // this should not happen - ::java::lang::String *msg = JvNewStringLatin1 ("native class"); - throw new exception::JdwpInternalErrorException (msg); - } + CHECK_INTERP_CLASS (); jmethodID desired_method = reinterpret_cast (_methodId); @@ -97,5 +107,78 @@ gnu::classpath::jdwp::VMMethod::getLineTable () gnu::classpath::jdwp::util::VariableTable* gnu::classpath::jdwp::VMMethod::getVariableTable () { - return NULL; + using namespace gnu::classpath::jdwp::util; + + jvmtiEnv *env = _Jv_GetJDWP_JVMTIEnv (); + + CHECK_INTERP_CLASS (); + + jmethodID meth = reinterpret_cast (_methodId); + jvmtiLocalVariableEntry *var_table; + jint num_slots, args_len; + + jvmtiError jerr = env->GetLocalVariableTable (meth, &num_slots, &var_table); + + if (jerr != JVMTI_ERROR_NONE) + goto error; + + jerr = env->GetArgumentsSize (meth, &args_len); + + if (jerr != JVMTI_ERROR_NONE) + { + error: + using namespace gnu::classpath::jdwp::exception; + char *error; + env->GetErrorName (jerr, &error); + String *msg = JvNewStringUTF (error); + env->Deallocate (reinterpret_cast (error)); + + if (jerr == JVMTI_ERROR_NATIVE_METHOD) + throw new AbsentInformationException (msg); + else if (jerr == JVMTI_ERROR_INVALID_METHODID) + throw new InvalidMethodException (_methodId); + else + throw new JdwpInternalErrorException (msg); + } + + jlongArray start_pcs = JvNewLongArray (num_slots); + jlong *start_pcs_ptr = elements (start_pcs); + jintArray lengths = JvNewIntArray (num_slots); + jint *lengths_ptr = elements (lengths); + jintArray slots = JvNewIntArray (num_slots); + jint *slots_ptr = elements (slots); + JArray *names = reinterpret_cast *> + (JvNewObjectArray (num_slots, + &String::class$, NULL)); + jstring *names_ptr = elements (names); + JArray *signatures = reinterpret_cast *> + (JvNewObjectArray (num_slots, + &String::class$, NULL)); + jstring *signatures_ptr = elements (signatures); + + // Get the information out of the JVMTI strucutre and Deallocate the strings. + for (int i = 0; i < num_slots; i++) + { + start_pcs_ptr[i] = var_table[i].start_location; + lengths_ptr[i] = var_table[i].length; + slots_ptr[i] = var_table[i].slot; + names_ptr[i] = JvNewStringUTF (var_table[i].name); + env->Deallocate (reinterpret_cast + (var_table[i].name)); + signatures_ptr[i] = JvNewStringUTF (var_table[i].signature); + env->Deallocate (reinterpret_cast + (var_table[i].signature)); + env->Deallocate (reinterpret_cast + (var_table[i].generic_signature)); + } + + // Now Deallocate the table since it's strings have already been freed. + env->Deallocate (reinterpret_cast (var_table)); + + // Create the new JDWP VariableTable to return with the now filled arrays. + VariableTable* jdwp_vtable = new VariableTable (args_len, num_slots, + start_pcs, names, signatures, + lengths, slots); + + return jdwp_vtable; } -- cgit v1.2.3