Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Eclipse/IDEA/etc. debugger obtain the information about local variable values and watch expression values?

I always thought that varibales are mapped to stack locations once your Java source is compiled; additionally, they may include the info about the variable names and their scope in classfiles, but that's optional AFAIK.

The question is - how do my Eclipse/IDEA IDEs allow me to set a watch expression containing the local variable name? To me, it's hard to understand :)

like image 424
Bubba88 Avatar asked May 22 '26 20:05

Bubba88


1 Answers

All those IDE base their debug services on top of the JavaTM Platform Debugger Architecture (JPDA).
More precisely, they are all using the Java Virtual Machine Tool Interface (JVM TI), which replaced from JDK5 the experimental JVMPI (Java Virtual Machine Profiling Interface).

That JVMTI includes a Watched Field function and a SetFieldModificationWatch function.

But that doesn't include local variable: there is actually an RFE opened since quite some time now: bug 4228507.
So in the case of local variable, chances are some kind of BCI is used (Byte Code Instrumentation) (like the TPTP Eclipse module does).

like image 103
VonC Avatar answered May 24 '26 10:05

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!