author | l12wang |
Wed, 11 Nov 2009 16:36:23 -0600 | |
changeset 114 | ecab18a5e4de |
parent 37 | c2bce6dd59e7 |
permissions | -rw-r--r-- |
37 | 1 |
/******************************************************************************* |
2 |
* Copyright (c) 2005, 2009 IBM Corporation and others. |
|
3 |
* All rights reserved. This program and the accompanying materials |
|
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
|
5 |
* which accompanies this distribution, and is available at |
|
6 |
* http://www.eclipse.org/legal/epl-v10.html |
|
7 |
* |
|
8 |
* Contributors: |
|
9 |
* IBM Corporation - initial API and implementation |
|
10 |
* Bjorn Freeman-Benson - initial API and implementation |
|
11 |
* Wind River Systems - adopted to use with DSF |
|
12 |
*******************************************************************************/ |
|
13 |
package org.eclipse.cdt.examples.dsf.pda.breakpoints; |
|
14 |
||
15 |
import org.eclipse.cdt.examples.dsf.pda.PDAPlugin; |
|
16 |
import org.eclipse.core.resources.IMarker; |
|
17 |
import org.eclipse.core.resources.IResource; |
|
18 |
import org.eclipse.core.resources.IWorkspaceRunnable; |
|
19 |
import org.eclipse.core.runtime.CoreException; |
|
20 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
21 |
import org.eclipse.debug.core.model.IBreakpoint; |
|
22 |
import org.eclipse.debug.core.model.LineBreakpoint; |
|
23 |
||
24 |
||
25 |
/** |
|
26 |
* PDA line breakpoint |
|
27 |
* <p> |
|
28 |
* This class is identical to the corresponding in PDA debugger implemented in |
|
29 |
* org.eclipse.debug.examples. |
|
30 |
* </p> |
|
31 |
*/ |
|
32 |
public class PDALineBreakpoint extends LineBreakpoint { |
|
33 |
||
114
ecab18a5e4de
Changes corresponding to BreakpointsMediator change.
l12wang
parents:
37
diff
changeset
|
34 |
public static final String INSTALLED = "INSTALLED"; |
ecab18a5e4de
Changes corresponding to BreakpointsMediator change.
l12wang
parents:
37
diff
changeset
|
35 |
|
37 | 36 |
/** |
37 |
* Default constructor is required for the breakpoint manager |
|
38 |
* to re-create persisted breakpoints. After instantiating a breakpoint, |
|
39 |
* the <code>setMarker(...)</code> method is called to restore |
|
40 |
* this breakpoint's attributes. |
|
41 |
*/ |
|
42 |
public PDALineBreakpoint() { |
|
43 |
} |
|
44 |
||
45 |
/** |
|
46 |
* Constructs a line breakpoint on the given resource at the given |
|
47 |
* line number. The line number is 1-based (i.e. the first line of a |
|
48 |
* file is line number 1). The PDA VM uses 0-based line numbers, |
|
49 |
* so this line number translation is done at breakpoint install time. |
|
50 |
* |
|
51 |
* @param resource file on which to set the breakpoint |
|
52 |
* @param lineNumber 1-based line number of the breakpoint |
|
53 |
* @throws CoreException if unable to create the breakpoint |
|
54 |
*/ |
|
55 |
public PDALineBreakpoint(final IResource resource, final int lineNumber) throws CoreException { |
|
56 |
IWorkspaceRunnable runnable = new IWorkspaceRunnable() { |
|
57 |
public void run(IProgressMonitor monitor) throws CoreException { |
|
58 |
IMarker marker = resource.createMarker("org.eclipse.cdt.examples.dsf.pda.markerType.lineBreakpoint"); |
|
59 |
setMarker(marker); |
|
60 |
marker.setAttribute(IBreakpoint.ENABLED, Boolean.TRUE); |
|
61 |
marker.setAttribute(IMarker.LINE_NUMBER, lineNumber); |
|
62 |
marker.setAttribute(IBreakpoint.ID, getModelIdentifier()); |
|
63 |
marker.setAttribute(IMarker.MESSAGE, "Line Breakpoint: " + resource.getName() + " [line: " + lineNumber + "]"); |
|
64 |
} |
|
65 |
}; |
|
66 |
run(getMarkerRule(resource), runnable); |
|
67 |
} |
|
68 |
||
69 |
/* (non-Javadoc) |
|
70 |
* @see org.eclipse.debug.core.model.IBreakpoint#getModelIdentifier() |
|
71 |
*/ |
|
72 |
public String getModelIdentifier() { |
|
73 |
return PDAPlugin.ID_PDA_DEBUG_MODEL; |
|
74 |
} |
|
75 |
||
76 |
/** |
|
77 |
* Returns whether this breakpoint is a run-to-line breakpoint |
|
78 |
* |
|
79 |
* @return whether this breakpoint is a run-to-line breakpoint |
|
80 |
*/ |
|
81 |
public boolean isRunToLineBreakpoint() { |
|
82 |
return false; |
|
83 |
} |
|
114
ecab18a5e4de
Changes corresponding to BreakpointsMediator change.
l12wang
parents:
37
diff
changeset
|
84 |
|
ecab18a5e4de
Changes corresponding to BreakpointsMediator change.
l12wang
parents:
37
diff
changeset
|
85 |
public void setInstalled(boolean installed) throws CoreException { |
ecab18a5e4de
Changes corresponding to BreakpointsMediator change.
l12wang
parents:
37
diff
changeset
|
86 |
setAttribute(INSTALLED, installed); |
ecab18a5e4de
Changes corresponding to BreakpointsMediator change.
l12wang
parents:
37
diff
changeset
|
87 |
} |
ecab18a5e4de
Changes corresponding to BreakpointsMediator change.
l12wang
parents:
37
diff
changeset
|
88 |
|
ecab18a5e4de
Changes corresponding to BreakpointsMediator change.
l12wang
parents:
37
diff
changeset
|
89 |
public boolean getInstalled() throws CoreException { |
ecab18a5e4de
Changes corresponding to BreakpointsMediator change.
l12wang
parents:
37
diff
changeset
|
90 |
return ensureMarker().getAttribute(INSTALLED, false); |
ecab18a5e4de
Changes corresponding to BreakpointsMediator change.
l12wang
parents:
37
diff
changeset
|
91 |
} |
37 | 92 |
|
93 |
} |