This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Java in General and the fly likes Program Counter values of an executing Java Program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "Program Counter values of an executing Java Program " Watch "Program Counter values of an executing Java Program " New topic
Author

Program Counter values of an executing Java Program

Daanish Suhail
Greenhorn

Joined: Aug 24, 2012
Posts: 10
Is it possible to obtain the program counter (PC) register values of a running Java application?

I want to use the values of PC to get the execution path of a Java Program... I don't want to use the stackTrace .

Is there any other method to get the path of execution of a java program?

Thank you
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30580
    
154

A debugger? You might want to describe why stack trace doesn't meet your needs to get a more useful suggestion.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1763
    
    7

As of Java 5 there's the JVMTI if you want to create a native application that communicates with a JVM.
I'm not quite sure that's what you're after, though.


Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39044
    
  23
Moving discussion as too difficult for “beginning”.
Daanish Suhail
Greenhorn

Joined: Aug 24, 2012
Posts: 10
StackTrace is a problem because time is an issue for me...and for all i've heard and been told is not to use StackTrace...
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

Well, yeah, stack traces aren't going to tell you what you say you need to know. That's because stack traces tell you things about your Java code. But that isn't what you say you want. You say you want to know what memory locations in the compiled version of the Java byte-code are executed.

At least that's what you say. I can't imagine why you need to know that or what you plan to do with it -- especially since the volume of output is going to be enormous. If you have a 1 gigabyte processor, that means that your machine can execute 1 billion operations per second. So the debugging you say you want is going to output 1 billion pieces of information every second. And those billion pieces of information aren't going to be very useful either -- what can you do with something which says "Executed the instruction at location 3055802"?

As you might have guessed, I don't think that is really what you need to know. Or perhaps I misunderstood what you were asking. Perhaps you could go back a step and describe the problem you are trying to solve with this unique debugging technique?
Daanish Suhail
Greenhorn

Joined: Aug 24, 2012
Posts: 10
Jelle Klap wrote:As of Java 5 there's the JVMTI if you want to create a native application that communicates with a JVM.
I'm not quite sure that's what you're after, though.

I'm basically developing a code coverage tool. So I thought of using the PC's values to perform code coverage.
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7892
    
  21

Daanish Suhail wrote:I'm basically developing a code coverage tool. So I thought of using the PC's values to perform code coverage.

I fear that you may be re-inventing the wheel. This page lists 12 such products for Java.

Winston


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
 
GeeCON Prague 2014
 
subject: Program Counter values of an executing Java Program