Questions tagged [jdi]

The Java Debug Interface (JDI) is a high level Java API providing information useful for debuggers and similar systems needing access to the running state of a (usually remote) virtual machine.

The Java Debug Interface (JDI) is a high level Java API providing information useful for debuggers and similar systems needing access to the running state of a (usually remote) virtual machine. It provides information useful for debuggers and similar systems needing access to the running state of a (usually remote) virtual machine.

The JDI provides introspective access to a running virtual machine's state, Class, Array, Interface, and primitive types, and instances of those types.

The JDI also provides explicit control over a virtual machine's execution. The ability to suspend and resume threads, and to set breakpoints, watchpoints, ... Notification of exceptions, class loading, thread creation... The ability to inspect a suspended thread's state, local variables, stack backtrace...

JDI is the highest-layer of the Java Platform Debugger Architecture (JPDA). For more information on the Java Platform Debugger Architecture, see the Java Platform Debugger Architecture documentation for this release and the Java Platform Debugger Architecture website.

107 questions
2
votes
1 answer

How to debug a class loaded by a custom classloader in JDI

Using arguments -Xdebug, -agentlib:jdwp=transport=dt_socket, server=y, suspend=n, address=4404 Start target program. Debug the target program using the com.sun.jdi related class. The classesByName method of the VirtualMachine class. The class that…
Channe
  • 109
  • 1
  • 1
  • 8
2
votes
1 answer

JDI ThreadReference.frame() causes IncompatibleThreadStateException

Currently I am trying to extract some execution data via the JDI. Therefore I first start a java vm manually with the command java -agentlib:jdwp=transport=dt_socket,server=y,address=8000 DebugDummy My DebugDummy.java: public class DebugDummy { …
Vetterjack
  • 2,227
  • 4
  • 19
  • 31
2
votes
0 answers

Dispose JDI will hang at some situation

I'm working with JDI, and find out that call com.sun.jdi.VirtualMachine#dispose will hang at some situation. The thread stack is : "qtp1764345202-39" prio=5 tid=0x00007f830a14f000 nid=0x10d03 in Object.wait() [0x0000000128ea6000] …
Wang Jun
  • 595
  • 6
  • 16
2
votes
0 answers

how to detect jdi invoke calls?

I have a breakpoint that has some logic attached to it that I want to skip if the method it was in was invoked from JDI. i.e. in the client jvm foo.barr(); should cause the code associated with the breakpoint to be run but…
ILOVEPIE
  • 177
  • 1
  • 10
2
votes
1 answer

com.sun.jdi.VMDisconnectedException: Got IOException from Virtual Machine

I am having trouble trying to get rid of this exception. I wrote a program to attach the debugger to a remote server using "com.sun.jdi.SocketAttach" as the attaching connector and once connection is made, I added a debug Target. vm =…
user3457017
  • 55
  • 1
  • 6
2
votes
1 answer

How do you get the enclosing instance of an instance? (com.sun.jdi)

com.sun.jdi is a package that lets you get information about a running VM, add breakpoints, look through stack frames, etc. How can I get the enclosing instance of another instance? For example, here is some code that creates 4 instances of the…
daveagp
  • 2,599
  • 2
  • 20
  • 19
2
votes
1 answer

Using jpda to connect to weblogic

I am building a utility/tool to profile/trace the method calls in a Java EE application deployed in Weblogic 10 (java 6). The intention is to quickly understand the flow of events in our huge enterprise application. (Going through the code is…
MVK
  • 125
  • 2
  • 9
1
vote
0 answers

JDI reporting 12th bit set on field modifiers?

I am currently working with the JDI first time and examining the field modifiers of the local variables in a stack frame gave me interesting results. (Using JDK 17.0.6) Here is the simplified code I use to acquire said modifier bits: StackFrame…
1
vote
1 answer

JDI/JPDA Event Filtering

In JDI, there is the API to exclude events from processed events in JVM used by JPDA. This is done using: addExclusionFilter(String) to exclude some pattern; e.g. addExclusionFilter("java.*") addClassFilter(String) to include some pattern; e.g.…
nobeh
  • 9,784
  • 10
  • 49
  • 66
1
vote
1 answer

Get number of instances of a given Java class using a Java agent?

Is it possible to use a Java agent to get the number of instances of any Java class? For example if we have class Apple { ... } The Java agent will return how many Apple instances are there in the JVM. If it's not possible with a Java agent, is it…
Nfff3
  • 321
  • 8
  • 24
1
vote
0 answers

How to instrument invokedynamic and scalac 2.12 output code with JDI

I want to instrument ScalaCheck compiled with/for scala 2.12, using JDI. By running javap I have concluded that scalac 2.12.x emits invokedynamic instructions (for some values of x) where scala 2.11 used to generate inner classes, in particular for…
Jonas Kölker
  • 7,680
  • 3
  • 44
  • 51
1
vote
0 answers

How do I determine the jvm arguments to run a scala programs?

TL;DR: What's the kosher way of launching Scala programs through JDI? I want to use JDI to implement a debugger-of-sorts for Scala. In particular I want use a LaunchingConnector. And ideally I want the user to specify whether I should launch Scala…
Jonas Kölker
  • 7,680
  • 3
  • 44
  • 51
1
vote
0 answers

When to use INVOKE_SINGLE_THREADED or INVOKE_NONVIRTUAL when invoking method on com.sun.jdi.ObjectReference?

When invoking a method on an com.sun.jdi.ObjectReference instance, you have to provide some options: either INVOKE_SINGLE_THREADED, or INVOKE_NONVIRTUAL. invokeMethod​(ThreadReference thread, Method method, List arguments, int…
Nfff3
  • 321
  • 8
  • 24
1
vote
0 answers

How to handle input for a Java Console application debugged with Java JDI?

I'm working on writing my own debugger with JDI for a uni project. With this debugger I want to log the executed lines of code and the attributes of a target program. Later I want to visualize the log file. I got the debugger to the point, where it…
GreenTea26
  • 13
  • 2
1
vote
0 answers

Where is JVMTI's Breakpoint event called?

I cloned OpenJDK8's source code and wanted to check where exactly JVMTI's Breakpoint callback is called. What I found is that all the breakpoints are stored in a list of type JvmtiBreakpoint. What I couldn't find was where exactly the breakpoint…
Nfff3
  • 321
  • 8
  • 24