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