Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Inspecting Java Processes within the JVM  RSS feed

 
John Pa
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Is it possible to access the internal variables of a JVM, which is executing a Java process. I understand that the JVM treats each process as a separate thread. The solution I would appreciate should allow me a run time inspection rather than using gdb and getting a dump .Thanks in advance
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi John,
Welcome to JavaRanch!
I don't really understand the details of what you're asking; for example, not sure what you mean when you say "a Java process." But jdb can attach to a running process and pull debug info out of it, as can the debuggers built into IDEs like Eclipse, IDEA, and JBuilder.
 
John Pa
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ernest,Thanks for the quick reply. I am working with Mobile Agents which use a JVM to execute. An agent is a Java Thread.I want to see what is happening to the agent when it executes (by looking at the JVM).To do so i am sendng another agent in.So what we have is a Java thread attempting to access the internal variables of another thread. Not sure of how this is possible.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, the best way to do this would be to make it an official part of the agent interface, yes? Have an inspect() method or some such. This would eaily let one agent get ahold of the state variables of another.
I don't think there's really any way to get access to the stack variables of another thread (or the program counter, for that matter) from within a single JVM. One JVM can grab that kind of info from another JVM using the VM debugging interfaces (JDPA, JDI, JVMDI). Not for the faint of heart, though!
 
John Pa
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, using the JAVA reflection API I can see the public variables of the second agent but as you guessed, I am more interested in getting access to the private variables (I know it violates the access control protocol and the securitymanager will throw a fit)& to the stack variables of the agent.Any links / ideas will help. I am new at this Thanks
[ October 14, 2003: Message edited by: John Pa ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!