OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [testsuite/] [libjava.jvmti/] [interp/] [natgetlocalvartable.cc] - Blame information for rev 765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 765 jeremybenn
#include <jni.h>
2
 
3
#include <jvmti.h>
4
#include <stdio.h>
5
#include <stdlib.h>
6
 
7
#include "getlocalvartable.h"
8
 
9
JNIEXPORT jint JNICALL Java_getlocalvartable_do_1getlocalvartable_1tests
10
(JNIEnv *env, jclass klass)
11
{
12
  JavaVM *vm;
13
  jint err = env->GetJavaVM (&vm);
14
  if (err < 0)
15
    {
16
      fprintf (stderr, "error getting VM\n");
17
      exit (1);
18
    }
19
 
20
  jvmtiEnv *jvmti = NULL;
21
  vm->GetEnv ((void **) &jvmti, JVMTI_VERSION_1_0);
22
 
23
  if (jvmti == NULL)
24
    {
25
      fprintf (stderr, "error getting jvmti environment\n");
26
      exit (1);
27
    }
28
 
29
  jint entrys;
30
  jvmtiLocalVariableEntry *var_table;
31
 
32
  jvmtiError jerr;
33
 
34
  jmethodID meth_ids[3];
35
 
36
  meth_ids[0] = env->GetMethodID (klass, "aMethod", "(FF)D");
37
  meth_ids[1] = env->GetMethodID (klass, "bMethod", "(II)J");
38
  meth_ids[2] = env->GetMethodID (klass, "cMethod",
39
                                  "(Ljava/lang/Object;)Ljava/lang/Object;");
40
  for (int i = 0; i < 3; i++)
41
    {
42
      jerr = jvmti->GetLocalVariableTable (meth_ids[i], &entrys, &var_table);
43
      if (jerr != JVMTI_ERROR_NONE)
44
        {
45
          char *error_name;
46
          jvmti->GetErrorName (jerr, &error_name);
47
          fprintf (stderr, "JVMTI Error: %s\n", error_name);
48
          jvmti->Deallocate (reinterpret_cast<unsigned char *> (error_name));
49
        }
50
      else
51
        {
52
          for (int j = 0; j < entrys; j++)
53
            {
54
              printf ("Slot: %d\n", static_cast<int> (var_table[j].slot));
55
              printf ("  Name: %s\n", var_table[j].name);
56
              jvmti->Deallocate (reinterpret_cast<unsigned char *> (var_table[j].name));
57
              printf ("  Sig: %s\n", var_table[j].signature);
58
              jvmti->Deallocate (reinterpret_cast<unsigned char *> (var_table[j].signature));
59
              printf ("  Gen Sig: %s\n", var_table[j].generic_signature);
60
              jvmti->Deallocate (reinterpret_cast<unsigned char *> (var_table[j].generic_signature));
61
              printf ("  Start Loc: %ld\n", static_cast<long> (var_table[j].start_location));
62
              printf ("  Length: %d\n", static_cast<int> (var_table[j].length));
63
            }
64
 
65
          jvmti->Deallocate (reinterpret_cast<unsigned char *> (var_table));
66
        }
67
    }
68
 
69
    return 0;
70
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.