mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-02-15 07:29:31 +08:00
natVMVirtualMachine (getFrames): Implement.
2007-02-15 Kyle Galloway <kgallowa@redhat.com> * gnu/classpath/jdwp/natVMVirtualMachine (getFrames): Implement. From-SVN: r121997
This commit is contained in:
parent
02bba3c417
commit
fc01261a60
@ -1,3 +1,7 @@
|
||||
2007-02-15 Kyle Galloway <kgallowa@redhat.com>
|
||||
|
||||
* gnu/classpath/jdwp/natVMVirtualMachine (getFrames): Implement.
|
||||
|
||||
2007-02-13 Keith Seitz <keiths@redhat.com>
|
||||
|
||||
* gnu/classpath/jdwp/natVMVirtualMachine.cc
|
||||
|
@ -486,11 +486,49 @@ getClassMethod (jclass klass, jlong id)
|
||||
}
|
||||
|
||||
java::util::ArrayList *
|
||||
gnu::classpath::jdwp::VMVirtualMachine::getFrames (MAYBE_UNUSED Thread *thread,
|
||||
MAYBE_UNUSED jint start,
|
||||
MAYBE_UNUSED jint length)
|
||||
gnu::classpath::jdwp::VMVirtualMachine::getFrames (Thread *thread, jint start,
|
||||
jint length)
|
||||
{
|
||||
return NULL;
|
||||
jint frame_count = getFrameCount (thread);
|
||||
::java::util::ArrayList *frame_list;
|
||||
|
||||
// Calculate the max number of frames to be returned.
|
||||
jint num_frames = frame_count - start;
|
||||
|
||||
// Check if num_frames is valid.
|
||||
if (num_frames < 0)
|
||||
num_frames = 0;
|
||||
|
||||
// Check if there are more than length frames left after start.
|
||||
// If length ios -1 return all remaining frames.
|
||||
if (length != -1 && num_frames > length)
|
||||
num_frames = length;
|
||||
|
||||
frame_list = new ::java::util::ArrayList (num_frames);
|
||||
|
||||
_Jv_Frame *vm_frame = reinterpret_cast<_Jv_Frame *> (thread->frame);
|
||||
|
||||
// Take start frames off the top of the stack
|
||||
while (vm_frame != NULL && start > 0)
|
||||
{
|
||||
start--;
|
||||
vm_frame = vm_frame->next;
|
||||
}
|
||||
|
||||
// Use as a counter for the number of frames returned.
|
||||
num_frames = 0;
|
||||
|
||||
while (vm_frame != NULL && (num_frames < length || length == -1))
|
||||
{
|
||||
jlong frameId = reinterpret_cast<jlong> (vm_frame);
|
||||
|
||||
VMFrame *frame = getFrame (thread, frameId);
|
||||
frame_list->add (frame);
|
||||
vm_frame = vm_frame->next;
|
||||
num_frames++;
|
||||
}
|
||||
|
||||
return frame_list;
|
||||
}
|
||||
|
||||
gnu::classpath::jdwp::VMFrame *
|
||||
|
19
libjava/testsuite/libjava.jvmti/interp/getlocalvartable.h
Normal file
19
libjava/testsuite/libjava.jvmti/interp/getlocalvartable.h
Normal file
@ -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__ */
|
BIN
libjava/testsuite/libjava.jvmti/interp/getlocalvartable.jar
Normal file
BIN
libjava/testsuite/libjava.jvmti/interp/getlocalvartable.jar
Normal file
Binary file not shown.
63
libjava/testsuite/libjava.jvmti/interp/getlocalvartable.java
Normal file
63
libjava/testsuite/libjava.jvmti/interp/getlocalvartable.java
Normal file
@ -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 ();
|
||||
}
|
||||
}
|
109
libjava/testsuite/libjava.jvmti/interp/getlocalvartable.out
Normal file
109
libjava/testsuite/libjava.jvmti/interp/getlocalvartable.out
Normal file
@ -0,0 +1,109 @@
|
||||
JVMTI getlocalvartable Interpreted Test
|
||||
Slot: 0
|
||||
Name: this
|
||||
Sig: Lgetlocalvartable;
|
||||
Gen Sig: Lgetlocalvartable;
|
||||
Start Loc: 0
|
||||
Length: 28
|
||||
Slot: 1
|
||||
Name: pone
|
||||
Sig: F
|
||||
Gen Sig: F
|
||||
Start Loc: 0
|
||||
Length: 28
|
||||
Slot: 2
|
||||
Name: ptwo
|
||||
Sig: F
|
||||
Gen Sig: F
|
||||
Start Loc: 0
|
||||
Length: 28
|
||||
Slot: 3
|
||||
Name: fone
|
||||
Sig: F
|
||||
Gen Sig: F
|
||||
Start Loc: 2
|
||||
Length: 26
|
||||
Slot: 4
|
||||
Name: ftwo
|
||||
Sig: F
|
||||
Gen Sig: F
|
||||
Start Loc: 7
|
||||
Length: 21
|
||||
Slot: 5
|
||||
Name: done
|
||||
Sig: D
|
||||
Gen Sig: D
|
||||
Start Loc: 14
|
||||
Length: 14
|
||||
Slot: 7
|
||||
Name: dtwo
|
||||
Sig: D
|
||||
Gen Sig: D
|
||||
Start Loc: 22
|
||||
Length: 6
|
||||
Slot: 0
|
||||
Name: this
|
||||
Sig: Lgetlocalvartable;
|
||||
Gen Sig: Lgetlocalvartable;
|
||||
Start Loc: 0
|
||||
Length: 25
|
||||
Slot: 1
|
||||
Name: ipone
|
||||
Sig: I
|
||||
Gen Sig: I
|
||||
Start Loc: 0
|
||||
Length: 25
|
||||
Slot: 2
|
||||
Name: iptwo
|
||||
Sig: I
|
||||
Gen Sig: I
|
||||
Start Loc: 0
|
||||
Length: 25
|
||||
Slot: 3
|
||||
Name: ione
|
||||
Sig: I
|
||||
Gen Sig: I
|
||||
Start Loc: 2
|
||||
Length: 23
|
||||
Slot: 4
|
||||
Name: itwo
|
||||
Sig: I
|
||||
Gen Sig: I
|
||||
Start Loc: 7
|
||||
Length: 18
|
||||
Slot: 5
|
||||
Name: lone
|
||||
Sig: J
|
||||
Gen Sig: J
|
||||
Start Loc: 11
|
||||
Length: 14
|
||||
Slot: 7
|
||||
Name: ltwo
|
||||
Sig: J
|
||||
Gen Sig: J
|
||||
Start Loc: 19
|
||||
Length: 6
|
||||
Slot: 0
|
||||
Name: this
|
||||
Sig: Lgetlocalvartable;
|
||||
Gen Sig: Lgetlocalvartable;
|
||||
Start Loc: 0
|
||||
Length: 8
|
||||
Slot: 1
|
||||
Name: op
|
||||
Sig: Ljava/lang/Object;
|
||||
Gen Sig: Ljava/lang/Object;
|
||||
Start Loc: 0
|
||||
Length: 8
|
||||
Slot: 2
|
||||
Name: oone
|
||||
Sig: Ljava/lang/Object;
|
||||
Gen Sig: Ljava/lang/Object;
|
||||
Start Loc: 2
|
||||
Length: 6
|
||||
Slot: 3
|
||||
Name: otwo
|
||||
Sig: Ljava/lang/Object;
|
||||
Gen Sig: Ljava/lang/Object;
|
||||
Start Loc: 4
|
||||
Length: 4
|
@ -0,0 +1,67 @@
|
||||
#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);
|
||||
printf (" Sig: %s\n", var_table[j].signature);
|
||||
printf (" Gen Sig: %s\n", 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user