1 /* src/native/vm/VMMethod.c - jdwp->jvmti interface
3 Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
4 C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5 E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6 J. Wenninger, Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 Contact: cacao@cacaojvm.org
27 Authors: Samuel Vinson
38 #include "native/jni.h"
39 #include "native/include/gnu_classpath_jdwp_VMMethod.h"
40 #include "native/jvmti/jvmti.h"
41 #include "native/jvmti/VMjdwp.h"
44 * Class: gnu/classpath/jdwp/VMMethod
46 * Signature: ()Ljava/lang/String;
48 JNIEXPORT struct java_lang_String* JNICALL Java_gnu_classpath_jdwp_VMMethod_getName(JNIEnv *env, struct gnu_classpath_jdwp_VMMethod* this)
52 char *name, *signature, *generic;
55 if (JVMTI_ERROR_NONE != (err= (*jvmtienv)->
56 GetMethodName(jvmtienv, (jmethodID)this->_methodId,
57 &name, &signature, &generic))) {
58 (*jvmtienv)->GetErrorName(jvmtienv,err, &errdesc);
59 fprintf(stderr,"jvmti error: %s\n",errdesc);
61 (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)errdesc);
65 stringname = (*env)->NewStringUTF(env,name);
66 (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)name);
67 (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)signature);
68 (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)generic);
75 * Class: gnu/classpath/jdwp/VMMethod
76 * Method: getSignature
77 * Signature: ()Ljava/lang/String;
79 JNIEXPORT struct java_lang_String* JNICALL Java_gnu_classpath_jdwp_VMMethod_getSignature(JNIEnv *env, struct gnu_classpath_jdwp_VMMethod* this)
83 char *name, *signature, *generic;
84 struct java_lang_String* stringsignature;
86 if (JVMTI_ERROR_NONE != (err= (*jvmtienv)->
87 GetMethodName(jvmtienv, (jmethodID)this->_methodId,
88 &name, &signature, &generic))) {
89 (*jvmtienv)->GetErrorName(jvmtienv,err, &errdesc);
90 fprintf(stderr,"jvmti error: %s\n",errdesc);
92 (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)errdesc);
96 stringsignature = (*env)->NewStringUTF(env,signature);
97 (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)name);
98 (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)signature);
99 (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)generic);
101 return stringsignature;
106 * Class: gnu/classpath/jdwp/VMMethod
107 * Method: getModifiers
110 JNIEXPORT s4 JNICALL Java_gnu_classpath_jdwp_VMMethod_getModifiers(JNIEnv *env, struct gnu_classpath_jdwp_VMMethod* this)
116 if (JVMTI_ERROR_NONE != (err= (*jvmtienv)->
117 GetMethodModifiers(jvmtienv,
118 (jmethodID) this->_methodId,
120 (*jvmtienv)->GetErrorName(jvmtienv,err, &errdesc);
121 fprintf(stderr,"jvmti error: %s\n",errdesc);
123 (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)errdesc);
132 * Class: gnu/classpath/jdwp/VMMethod
133 * Method: getLineTable
134 * Signature: ()Lgnu/classpath/jdwp/util/LineTable;
136 JNIEXPORT struct gnu_classpath_jdwp_util_LineTable* JNICALL Java_gnu_classpath_jdwp_VMMethod_getLineTable(JNIEnv *env, struct gnu_classpath_jdwp_VMMethod* this)
146 jvmtiLineNumberEntry *lne;
152 if (JVMTI_ERROR_NONE != (err= (*jvmtienv)->
153 GetLineNumberTable(jvmtienv,
154 (jmethodID)this->_methodId,
156 (*jvmtienv)->GetErrorName(jvmtienv,err, &errdesc);
157 fprintf(stderr,"jvmti error: %s\n",errdesc);
159 (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)errdesc);
163 cl = (*env)->FindClass(env,"gnu.classpath.jdwp.util.LineTable");
164 if (!cl) return NULL;
166 m = (*env)->GetMethodID(env, cl, "<init>", "(JJ[I[J)V");
169 jlineNum = (*env)->NewIntArray(env, count);
170 if (!jlineNum) return NULL;
171 jlineCI = (*env)->NewLongArray(env, count);
172 if (!jlineCI) return NULL;
173 lineNum = (*env)->GetIntArrayElements(env, jlineNum, NULL);
174 lineCI = (*env)->GetLongArrayElements(env, jlineCI, NULL);
175 for (i = 0; i < count; ++i) {
176 lineNum[i] = lne[i].line_number;
177 lineCI[i] = lne[i].start_location;
179 (*env)->ReleaseLongArrayElements(env, jlineCI, lineCI, 0);
180 (*env)->ReleaseIntArrayElements(env, jlineNum, lineNum, 0);
181 (*jvmtienv)->Deallocate(jvmtienv,lne);
183 if (JVMTI_ERROR_NONE != (err= (*jvmtienv)->
184 GetMethodLocation(jvmtienv,
185 (jmethodID)this->_methodId,
187 (*jvmtienv)->GetErrorName(jvmtienv,err, &errdesc);
188 fprintf(stderr,"jvmti error: %s\n",errdesc);
190 (*jvmtienv)->Deallocate(jvmtienv,(unsigned char*)errdesc);
194 ol = (*env)->NewObject(env, cl, m, start,
195 end, jlineNum, jlineCI);
197 return (struct gnu_classpath_jdwp_util_LineTable*)ol;
203 * Class: gnu/classpath/jdwp/VMMethod
204 * Method: getVariableTable
205 * Signature: ()Lgnu/classpath/jdwp/util/VariableTable;
207 JNIEXPORT struct gnu_classpath_jdwp_util_VariableTable* JNICALL Java_gnu_classpath_jdwp_VMMethod_getVariableTable(JNIEnv *env, struct gnu_classpath_jdwp_VMMethod* this)
209 fprintf(stderr,"VMMethod_getVariableTable: IMPLEMENT ME!!!");
214 * These are local overrides for various environment variables in Emacs.
215 * Please do not remove this and leave it at the end of the file, where
216 * Emacs will automagically detect them.
217 * ---------------------------------------------------------------------
220 * indent-tabs-mode: t