1 /**********************************************************************
2 Copyright (c) 2000, 2002 IBM Corp. and others.
3 All rights reserved. This program and the accompanying materials
4 are made available under the terms of the Common Public License v1.0
5 which accompanies this distribution, and is available at
6 http://www.eclipse.org/legal/cpl-v10.html
9 IBM Corporation - Initial implementation
10 Vicente Fernando - www.alfersoft.com.ar
11 **********************************************************************/
12 package net.sourceforge.phpdt.internal.debug.core.breakpoints;
14 import net.sourceforge.phpdt.internal.debug.core.PHPDebugCorePlugin;
16 import org.eclipse.core.resources.IMarker;
17 import org.eclipse.core.resources.IWorkspaceRunnable;
18 import org.eclipse.core.resources.ResourcesPlugin;
19 import org.eclipse.core.runtime.CoreException;
20 import org.eclipse.debug.core.DebugException;
21 import org.eclipse.debug.core.DebugPlugin;
22 import org.eclipse.debug.core.model.Breakpoint;
23 import org.eclipse.debug.core.model.IBreakpoint;
26 * A breakpoint is capable of suspending the execution of a program at a
27 * specific location when a program is running in debug mode. Each breakpoint
28 * has an associated marker which stores and persists all attributes associated
31 * A breakpoint is defined in two parts:
33 * <li>By an extension of kind
34 * <code>"org.eclipse.debug.core.breakpoints"</code></li>
35 * <li>By a marker definition that corresponds to the above breakpoint
39 * For example, following is a definition of corresponding breakpoint and
40 * breakpoint marker definitions. Note that the <code>markerType</code>
41 * attribute defined by the breakpoint extension corresponds to the type of the
45 * <extension point="org.eclipse.debug.core.breakpoints">
47 * id="com.example.Breakpoint"
48 * class="com.example.Breakpoint"
49 * markerType="com.example.BreakpointMarker">
52 * <extension point="org.eclipse.core.resources.markers">
54 * id="com.example.BreakpointMarker"
55 * super type="org.eclipse.debug.core.breakpointMarker"
56 * attribute name ="exampleAttribute">
62 * The breakpoint manager instantiates persisted breakpoints by traversing all
63 * markers that are a subtype of
64 * <code>"org.eclipse.debug.core.breakpointMarker"</code>, and instantiating
65 * the class defined by the <code>class</code> attribute on the associated
66 * breakpoint extension. The method <code>setMarker</code> is then called to
67 * associate a marker with the breakpoint.
70 * Breakpoints may or may not be registered with the breakpoint manager, and are
71 * persisted and restored as such. Since marker definitions only allow all or
72 * none of a specific marker type to be persisted, breakpoints define a
73 * <code>PERSISTED</code> attribute for selective persistence of breakpoints
80 public abstract class PHPBreakpoint extends Breakpoint implements IBreakpoint {
83 * Breakpoint attribute storing a breakpoint's hit count value (value
84 * <code>"net.sourceforge.phpeclipse.debug.hitCount"</code>). This
85 * attribute is stored as an <code>int</code>.
87 * For DBG the hit count is really a skip count. Explanation: A hit count of
88 * e.g. 4 would break on the fourth occurence of the breakpoint. A skip
89 * count means skip the first four occurences of the breakpoint, and break
90 * on the fifth occurence.
92 protected static final String HIT_COUNT = "net.sourceforge.phpeclipse.debug.hitCount"; //$NON-NLS-1$
95 * Breakpoint attribute storing a breakpoint's changeID. This is used for
96 * checking whether the breakpoint properties menu was finished with a
97 * OK-button. Which means a possible change of breakpoint condition or skip
98 * count. This is necessary because in method breakpointChanged in class
99 * PHPDebugTarget we need to know, whether the breakpoint has changed or not
100 * (breakpointChanged is called also when a PHP source file is modified and
103 protected static final String CHANGE_ID = "net.sourceforge.phpeclipse.debug.changeID"; //$NON-NLS-1$
106 * Breakpoint attribute storing a breakpoint's condition (value
107 * <code>"net.sourceforge.phpeclipse.debug.condition"</code>). This
108 * attribute is stored as an <code>string</code>.
110 protected static final String CONDITION = "net.sourceforge.phpeclipse.debug.condition"; //$NON-NLS-1$
113 * Breakpoint attribute storing whether a breakpoint's condition is enabled
115 * <code>"net.sourceforge.phpeclipse.debug.conditionEnabled"</code>).
116 * This attribute is stored as an <code>boolean</code>.
118 protected static final String CONDITION_ENABLED = "net.sourceforge.phpeclipse.debug.conditionEnabled"; //$NON-NLS-1$
121 * Breakpoint attribute storing the fully qualified name of the type this
122 * breakpoint is located in. (value
123 * <code>"net.sourceforge.phpeclipse.debug.typeName"</code>). This
124 * attribute is a <code>String</code>.
126 protected static final String TYPE_NAME = "net.sourceforge.phpeclipse.debug.typeName"; //$NON-NLS-1$
129 * Root breakpoint marker type (value
130 * <code>"org.eclipse.debug.core.breakpoint"</code>).
132 public static final String BREAKPOINT_MARKER = DebugPlugin
133 .getUniqueIdentifier()
134 + ".breakpointMarker"; //$NON-NLS-1$
137 * Line breakpoint marker type (value
138 * <code>"org.eclipse.debug.core.lineBreakpoint"</code>).
140 public static final String LINE_BREAKPOINT_MARKER = DebugPlugin
141 .getUniqueIdentifier()
142 + ".lineBreakpointMarker"; //$NON-NLS-1$
145 * Enabled breakpoint marker attribute (value
146 * <code>"org.eclipse.debug.core.enabled"</code>). The attribute is a
147 * <code>boolean</code> corresponding to the enabled state of a
150 * @see org.eclipse.core.resources.IMarker#getAttribute(String, boolean)
152 public static final String ENABLED = "org.eclipse.debug.core.enabled"; //$NON-NLS-1$
155 * Debug model identifier breakpoint marker attribute (value
156 * <code>"org.eclipse.debug.core.id"</code>). The attribute is a
157 * <code>String</code> corresponding to the identifier of the debug model
158 * a breakpoint is associated with.
160 public static final String ID = "org.eclipse.debug.core.id"; //$NON-NLS-1$
163 * Registered breakpoint marker attribute (value
164 * <code>"org.eclipse.debug.core.registered"</code>). The attribute is a
165 * <code>boolean</code> corresponding to whether a breakpoint has been
166 * registered with the breakpoint manager.
168 * @see org.eclipse.core.resources.IMarker#getAttribute(String, boolean)
170 public static final String REGISTERED = "org.eclipse.debug.core.registered"; //$NON-NLS-1$
173 * Persisted breakpoint marker attribute (value
174 * <code>"org.eclipse.debug.core.persisted"</code>). The attribute is a
175 * <code>boolean</code> corresponding to whether a breakpoint is to be
176 * persisted accross workspace invocations.
178 * @see org.eclipse.core.resources.IMarker#getAttribute(String, boolean)
180 public static final String PERSISTED = "org.eclipse.debug.core.persisted"; //$NON-NLS-1$
182 private int DBGBpNo = 0;
184 public PHPBreakpoint() {
188 * @see IBreakpoint#setMarker(IMarker)
190 public void setMarker(IMarker marker) throws CoreException {
191 super.setMarker(marker);
195 * Add this breakpoint to the breakpoint manager, or sets it as
198 protected void register(boolean register) throws CoreException {
200 DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(this);
202 setRegistered(false);
207 * Execute the given workspace runnable
209 protected void run(IWorkspaceRunnable wr) throws DebugException {
211 ResourcesPlugin.getWorkspace().run(wr, null);
212 } catch (CoreException e) {
213 throw new DebugException(e.getStatus());
218 * @see IBreakpoint#getModelIdentifier()
220 public String getModelIdentifier() {
221 return PHPDebugCorePlugin.getUniqueIdentifier();
224 public void setDBGBpNo(int bpNo) {
228 public int getDBGBpNo() {
232 public int getHitCount() throws CoreException {
233 return getMarker().getAttribute(HIT_COUNT, -1);
236 public void setHitCount(int hitCount) throws CoreException {
239 getMarker().setAttribute(ENABLED, true);
243 getMarker().setAttribute(HIT_COUNT, hitCount);