Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Program Counter values of an executing Java Program

 
Daanish Suhail
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34099
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A debugger? You might want to describe why stack trace doesn't meet your needs to get a more useful suggestion.
 
Jelle Klap
Bartender
Posts: 1951
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Campbell Ritchie
Sheriff
Posts: 48454
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving discussion as too difficult for “beginning”.
 
Daanish Suhail
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20776
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 10111
56
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic