2

Possible Duplicate:
Program Counter register values for a Java program

Is it possible to obtain the program counter (PC) register values of a running Java application?

Community
  • 1
  • 1
Daanish
  • 1,061
  • 7
  • 18
  • 29
  • 2
    Java was meant to be platform independent. Are you sure your requirement is correct. Are you writing a new code coverage tool? You may start from existing tools like cobertura/eclemma-jacoco – Jayan Sep 03 '12 at 05:21
  • You may want to have a look at http://visualvm.java.net/. – verisimilitude Sep 03 '12 at 05:26

1 Answers1

0

It depends on how you want to go about it. For example, if via the JVM Tool Interface, there is an exposed function named GetFrameLocation. This should be equivalent to the program counter.

jvmtiEnv *penv;
...
jmethodID cur_method;
jlocation cur_loc;
(*penv)->GetFrameLocation(0, 0, &cur_method, &cur_loc);
obataku
  • 29,212
  • 3
  • 44
  • 57