断点

断点允许用户在特定位置暂挂程序的执行。断点通常与源代码一起显示在用户界面中。可将 IBreakpointListener 添加至 IBreakpointManager,以便在添加或除去断点时获得通知。当在执行程序期间遇到断点时,程序将暂挂并触发 SUSPEND 调试事件,以 BREAKPOINT 作为原因。

定义自已的调试模型和启动配置的插件经常需要定义它们自已的断点类型。可以通过定义实现 IBreakpoint 的类来为特定调试模型实现断点。

使用资源标记来实现断点。记住,资源标记允许您以命名属性的形式关联关于资源的元信息。通过使用标记来实现断点,调试模型可以利用编辑器中的所有现有标记功能(例如,持久性、搜索、添加、删除和显示)。

为什么在使用断点时必须了解标记?创建断点类型时,还必须指定相关联的标记类型。org.eclipse.debug.core.breakpoints 的每个扩展都必须带有 org.eclipse.core.resources.markers 的扩展。通过查看 Java 断点的 Java 工具定义的扩展可以最好地说明这一点。

<extension id="javaBreakpointMarker" point="org.eclipse.core.resources.markers">
<super type="org.eclipse.debug.core.breakpointMarker"/>
  </extension>

<extension id="javaExceptionBreakpointMarker" point="org.eclipse.core.resources.markers">
<super type="org.eclipse.jdt.debug.javaBreakpointMarker"/>
<persistent value="true"/>
<attribute name="org.eclipse.jdt.debug.core.caught"/>
<attribute name="org.eclipse.jdt.debug.core.uncaught"/>
<attribute name="org.eclipse.jdt.debug.core.checked"/>
 </extension>
<extension point="org.eclipse.debug.core.breakpoints">
<breakpoint
id="javaExceptionBreakpoint"
markerType="org.eclipse.jdt.debug.javaExceptionBreakpointMarker"
class="org.eclipse.jdt.internal.debug.core.breakpoints.JavaExceptionBreakpoint">
</breakpoint>
 </extension>

调试插件定义特殊类型的标记 org.eclipse.debug.core.breakpointMarker。定义标记时,应使用此标记作为超类型来声明它。这允许调试模型通过搜索源文件的标记的子类型来查找源文件内所有可能的断点。在上面的示例中,javaExceptionBreakpointMarker 具有超类型 javaBreakpointMarker,其超类型的超类型为 breakpointMarkerjavaExceptionBreakpoint(在断点扩展中定义)指定 javaExceptionBreakpointMarker 作为它的标记。

所有这些都意味着什么?当调试代码获取源代码资源时,它可以搜索其超类型为 org.eclipse.debug.core.breakpointMarker 的所有标记。找到所有标记以后,它就使用插件注册表来将标记映射至它们的关联断点类。这样,平台调试代码通常就可以找到已对特定源文件设置的所有断点类型。

 

Copyright IBM Corporation and others 2000, 2003.