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
27 * program at a specific location when a program is running
28 * in debug mode. Each breakpoint has an associated marker which
29 * stores and persists all attributes associated with a breakpoint.
31 * A breakpoint is defined in two parts:
33 * <li>By an extension of kind <code>"org.eclipse.debug.core.breakpoints"</code></li>
34 * <li>By a marker definition that corresponds to the above breakpoint extension</li>
37 * For example, following is a definition of corresponding breakpoint
38 * and breakpoint marker definitions. Note that the <code>markerType</code>
39 * attribute defined by the breakpoint extension corresponds to the
40 * type of the marker definition.
42 * <extension point="org.eclipse.debug.core.breakpoints">
44 * id="com.example.Breakpoint"
45 * class="com.example.Breakpoint"
46 * markerType="com.example.BreakpointMarker">
49 * <extension point="org.eclipse.core.resources.markers">
51 * id="com.example.BreakpointMarker"
52 * super type="org.eclipse.debug.core.breakpointMarker"
53 * attribute name ="exampleAttribute">
58 * The breakpoint manager instantiates persisted breakpoints by
59 * traversing all markers that are a subtype of
60 * <code>"org.eclipse.debug.core.breakpointMarker"</code>, and
61 * instantiating the class defined by the <code>class</code> attribute
62 * on the associated breakpoint extension. The method <code>setMarker</code>
63 * is then called to associate a marker with the breakpoint.
66 * Breakpoints may or may not be registered with the breakpoint manager, and
67 * are persisted and restored as such. Since marker definitions only allow
68 * all or none of a specific marker type to be persisted, breakpoints define
69 * a <code>PERSISTED</code> attribute for selective persistence of breakpoints
76 public abstract class PHPBreakpoint extends Breakpoint implements IBreakpoint {
79 * Breakpoint attribute storing a breakpoint's hit count value
80 * (value <code>"net.sourceforge.phpeclipse.debug.hitCount"</code>). This attribute is stored as an
83 protected static final String HIT_COUNT = "net.sourceforge.phpeclipse.debug.hitCount"; //$NON-NLS-1$
86 * Breakpoint attribute storing the fully qualified name of the type
87 * this breakpoint is located in.
88 * (value <code>"net.sourceforge.phpeclipse.debug.typeName"</code>). This attribute is a <code>String</code>.
90 protected static final String TYPE_NAME = "net.sourceforge.phpeclipse.debug.typeName"; //$NON-NLS-1$
93 * Root breakpoint marker type
94 * (value <code>"org.eclipse.debug.core.breakpoint"</code>).
96 public static final String BREAKPOINT_MARKER = DebugPlugin.getUniqueIdentifier() + ".breakpointMarker"; //$NON-NLS-1$
99 * Line breakpoint marker type
100 * (value <code>"org.eclipse.debug.core.lineBreakpoint"</code>).
102 public static final String LINE_BREAKPOINT_MARKER = DebugPlugin.getUniqueIdentifier() + ".lineBreakpointMarker"; //$NON-NLS-1$
105 * Enabled breakpoint marker attribute (value <code>"org.eclipse.debug.core.enabled"</code>).
106 * The attribute is a <code>boolean</code> corresponding to the
107 * enabled state of a breakpoint.
109 * @see org.eclipse.core.resources.IMarker#getAttribute(String, boolean)
111 public static final String ENABLED= "org.eclipse.debug.core.enabled"; //$NON-NLS-1$
114 * Debug model identifier breakpoint marker attribute (value <code>"org.eclipse.debug.core.id"</code>).
115 * The attribute is a <code>String</code> corresponding to the
116 * identifier of the debug model a breakpoint is associated with.
118 public static final String ID= "org.eclipse.debug.core.id"; //$NON-NLS-1$
121 * Registered breakpoint marker attribute (value <code>"org.eclipse.debug.core.registered"</code>).
122 * The attribute is a <code>boolean</code> corresponding to
123 * whether a breakpoint has been registered with the breakpoint manager.
125 * @see org.eclipse.core.resources.IMarker#getAttribute(String, boolean)
127 public static final String REGISTERED= "org.eclipse.debug.core.registered"; //$NON-NLS-1$
130 * Persisted breakpoint marker attribute (value <code>"org.eclipse.debug.core.persisted"</code>).
131 * The attribute is a <code>boolean</code> corresponding to
132 * whether a breakpoint is to be persisted accross workspace
135 * @see org.eclipse.core.resources.IMarker#getAttribute(String, boolean)
137 public static final String PERSISTED= "org.eclipse.debug.core.persisted"; //$NON-NLS-1$
139 private int DBGBpNo=0;
141 public PHPBreakpoint() {
145 * @see IBreakpoint#setMarker(IMarker)
147 public void setMarker(IMarker marker) throws CoreException {
148 super.setMarker(marker);
152 * Add this breakpoint to the breakpoint manager,
153 * or sets it as unregistered.
155 protected void register(boolean register) throws CoreException {
157 DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(this);
159 setRegistered(false);
164 * Execute the given workspace runnable
166 protected void run(IWorkspaceRunnable wr) throws DebugException {
168 ResourcesPlugin.getWorkspace().run(wr, null);
169 } catch (CoreException e) {
170 throw new DebugException(e.getStatus());
175 * @see IBreakpoint#getModelIdentifier()
177 public String getModelIdentifier() {
178 return PHPDebugCorePlugin.getUniqueIdentifier();
181 public void setDBGBpNo(int bpNo) {
185 public int getDBGBpNo() {