简体   繁体   中英

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 :)

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 ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM