在调试期间,例如在 Eclipse 中,可以评估监视表达式或条件断点。通常,这些是在客户端评估的。例如,当从 Eclipse 内进行调试时,是 Eclipse 本身而不是调试目标 VM 计算这些表达式。这可能是相当昂贵的,特别是在条件断点的情况下,因为调试VM(即Eclipse)需要在每次断点命中时激活,即使条件评估为假。
我现在的问题是调试协议是否允许它在调试目标虚拟机中计算此类表达式或条件断点,以便目标虚拟机仅在表达式/条件真正计算为 TRUE 时通知调试虚拟机。
During debugging, e.g. in Eclipse, one can evaluate Watch Expressions or Conditional Breakpoints. Typically, these are evaluated on the client side. For instance, when debugging from within Eclipse, it is Eclipse itself, not the debug target VM that evaluates these expressions. This can be quite costly, especially in the case of conditional breakpoints because the debugging VM (i.e. Eclipse) needs to become active on every breakpoint hit, even if the condition evaluates to false.
My question is now whether the debug protocol permits it to instead evaluate such expressions or conditional breakpoints in the debug target VM, such that the target VM only notifies the debugging VM when the expression/condition really evaluated to TRUE.
发布评论
评论(1)
除了 IDE (ab) 使用热代码替换将方法体替换为带有空 if 块的方法体并在其中放置(条件)断点之外,我在 http://download.oracle.com/javase/1.5.0/docs/guide/ jpda/jdwp/jdwp-protocol.html 这可能有助于做到这一点。
EventRequest.Set 中有一个
exprId
,它被记录为“用于未来”,并且没有通过 JDI BreakpointRequest 公开,所以我认为这已经或永远不会起作用。顺便说一句,评估发生在目标虚拟机内部(即,如果您在表达式中使用 equals(),equals() 将在目标虚拟机中运行),但评估将从调试虚拟机触发。
Apart from the IDE (ab)using Hot Code Replacement to replace the method body by a body with an empty if block and putting the (conditional) breakpoint in there, I cannot find anything in http://download.oracle.com/javase/1.5.0/docs/guide/jpda/jdwp/jdwp-protocol.html that might help for doing this.
There is an
exprId
in EventRequest.Set which is documented as "for the future" and not exposed wia JDI BreakpointRequest, so I don't think this has or will ever work.By the way, the evaluation happens inside the target VM (i. e. if you use equals() in your expression, equals() will run in your target vm), but the evaluation will be triggered from the debugging VM.