/******************************************************************************* * Copyright (c) 2005, 2015 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation * Bjorn Freeman-Benson - initial API and implementation * Wind River Systems - adopted to use with DSF *******************************************************************************/ package org.eclipse.cdt.examples.dsf.pda.breakpoints; import org.eclipse.cdt.examples.dsf.pda.PDAPlugin; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspaceRunnable; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.debug.core.model.IBreakpoint; import org.eclipse.debug.core.model.LineBreakpoint; /** * PDA line breakpoint * <p> * This class is identical to the corresponding in PDA debugger implemented in * org.eclipse.debug.examples. * </p> */ public class PDALineBreakpoint extends LineBreakpoint { /** * Default constructor is required for the breakpoint manager * to re-create persisted breakpoints. After instantiating a breakpoint, * the <code>setMarker(...)</code> method is called to restore * this breakpoint's attributes. */ public PDALineBreakpoint() { } /** * Constructs a line breakpoint on the given resource at the given * line number. The line number is 1-based (i.e. the first line of a * file is line number 1). The PDA VM uses 0-based line numbers, * so this line number translation is done at breakpoint install time. * * @param resource file on which to set the breakpoint * @param lineNumber 1-based line number of the breakpoint * @throws CoreException if unable to create the breakpoint */ public PDALineBreakpoint(final IResource resource, final int lineNumber) throws CoreException { IWorkspaceRunnable runnable = new IWorkspaceRunnable() { @Override public void run(IProgressMonitor monitor) throws CoreException { IMarker marker = resource.createMarker("org.eclipse.cdt.examples.dsf.pda.markerType.lineBreakpoint"); setMarker(marker); marker.setAttribute(IBreakpoint.ENABLED, Boolean.TRUE); marker.setAttribute(IMarker.LINE_NUMBER, lineNumber); marker.setAttribute(IBreakpoint.ID, getModelIdentifier()); marker.setAttribute(IMarker.MESSAGE, "Line Breakpoint: " + resource.getName() + " [line: " + lineNumber + "]"); } }; run(getMarkerRule(resource), runnable); } /* (non-Javadoc) * @see org.eclipse.debug.core.model.IBreakpoint#getModelIdentifier() */ @Override public String getModelIdentifier() { return PDAPlugin.ID_PDA_DEBUG_MODEL; } /** * Returns whether this breakpoint is a run-to-line breakpoint * * @return whether this breakpoint is a run-to-line breakpoint */ public boolean isRunToLineBreakpoint() { return false; } }