diff options
author | Darin Wright | 2005-01-25 06:40:03 +0000 |
---|---|---|
committer | Darin Wright | 2005-01-25 06:40:03 +0000 |
commit | 2f77c1ac5d64793634fb3ab2817e4a843b522180 (patch) | |
tree | 6778d9dcf89fe9caf22e95e8213b715fc7136d22 | |
parent | d0ed86874c9b78e3a097b9068cb40e3a63409b7b (diff) | |
download | eclipse.platform.debug-2f77c1ac5d64793634fb3ab2817e4a843b522180.tar.gz eclipse.platform.debug-2f77c1ac5d64793634fb3ab2817e4a843b522180.tar.xz eclipse.platform.debug-2f77c1ac5d64793634fb3ab2817e4a843b522180.zip |
abstract debug element API - draft
3 files changed, 205 insertions, 0 deletions
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.properties b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.properties index 2d3cdc1ac..3d0f7befd 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.properties +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.properties @@ -32,6 +32,7 @@ DebugPlugin.An_exception_occurred_while_filtering_debug_events._3=An exception o DebugPlugin.31=Invalid process factory extension contributed by {0}; id: {1} DebugPlugin.0=Exception processing debug async queue DebugPlugin.1=Debug Event Dispatch +DebugTarget.0=Memory block retrieval not supported EnvironmentVariableResolver.0=Environment variable not specified diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugElement.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugElement.java index 53fd618f7..f7671b95a 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugElement.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugElement.java @@ -10,8 +10,11 @@ *******************************************************************************/ package org.eclipse.debug.internal.core; +import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.PlatformObject; +import org.eclipse.core.runtime.Status; import org.eclipse.debug.core.DebugEvent; +import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.model.IDebugElement; @@ -132,4 +135,28 @@ public abstract class DebugElement extends PlatformObject implements IDebugEleme protected void fireTerminateEvent() { fireEvent(new DebugEvent(this, DebugEvent.TERMINATE)); } + + /** + * Throws a debug exception with a status code of <code>TARGET_REQUEST_FAILED</code>. + * + * @param message exception message + * @param e underlying exception or <code>null</code> + * @throws DebugException + */ + protected void requestFailed(String message, Throwable e) throws DebugException { + throw new DebugException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), + DebugException.TARGET_REQUEST_FAILED, message, e)); + } + + /** + * Throws a debug exception with a status code of <code>NOT_SUPPORTED</code>. + * + * @param message exception message + * @param e underlying exception or <code>null</code> + * @throws DebugException + */ + protected void notSupported(String message, Throwable e) throws DebugException { + throw new DebugException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), + DebugException.NOT_SUPPORTED, message, e)); + } } diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugTarget.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugTarget.java new file mode 100644 index 000000000..54b1e7930 --- /dev/null +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugTarget.java @@ -0,0 +1,177 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.debug.internal.core; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.model.IBreakpoint; +import org.eclipse.debug.core.model.IDebugTarget; +import org.eclipse.debug.core.model.IMemoryBlock; +import org.eclipse.debug.core.model.IProcess; +import org.eclipse.debug.core.model.IThread; + +/** + * Implementation of common function for debug targets. + * <p> + * Clients may subclass this class. + * </p> + * @since 3.1 + */ +public abstract class DebugTarget extends DebugElement implements IDebugTarget { + + private IProcess fProcess; + private ILaunch fLaunch; + private String fName; + private List fThreads; + + /** + * Constructs a new debug target in the given launch associated + * with the given process. + * + * @param launch launch the target is contained in + * @param process associated process or <code>null</code> + */ + public DebugTarget(ILaunch launch, IProcess process) { + super(null); + fLaunch = launch; + fProcess = process; + fThreads = new ArrayList(); + } + + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IDebugTarget#getProcess() + */ + public IProcess getProcess() { + return fProcess; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IDebugElement#getDebugTarget() + */ + public IDebugTarget getDebugTarget() { + return this; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IDebugElement#getLaunch() + */ + public ILaunch getLaunch() { + return fLaunch; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IDebugTarget#getThreads() + */ + public IThread[] getThreads() throws DebugException { + synchronized (fThreads) { + return (IThread[]) fThreads.toArray(new IThread[fThreads.size()]); + } + } + + /** + * Adds the given thread to this target's list of threads. + * Has no effect if an equivalent thread is already registered. + * + * @param thread thread to add + */ + protected void addThread(IThread thread) { + synchronized (fThreads) { + if (!fThreads.contains(thread)) { + fThreads.add(thread); + } + } + } + + /** + * Removes the given thread from this target's list of threads. + * Has no effect if an equivalent thread is not already + * registered. + * + * @param thread thread to remove + */ + protected void removeThread(IThread thread) { + synchronized (fThreads) { + fThreads.remove(thread); + } + } + + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IDebugTarget#hasThreads() + */ + public boolean hasThreads() throws DebugException { + synchronized (fThreads) { + return !fThreads.isEmpty(); + } + } + + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IDebugTarget#getName() + */ + public String getName() throws DebugException { + return fName; + } + + /** + * Sets the name of this debug target. + * + * @param name + */ + protected void setName(String name) { + fName = name; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IDebugTarget#supportsBreakpoint(org.eclipse.debug.core.model.IBreakpoint) + */ + public boolean supportsBreakpoint(IBreakpoint breakpoint) { + return !isTerminated() && !isDisconnected() && breakpoint.getModelIdentifier().equals(getModelIdentifier()); + } + + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.ITerminate#canTerminate() + */ + public boolean canTerminate() { + return !isTerminated() && !isDisconnected(); + } + + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.ISuspendResume#canResume() + */ + public boolean canResume() { + return isSuspended(); + } + + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.ISuspendResume#canSuspend() + */ + public boolean canSuspend() { + return !isSuspended(); + } + + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IMemoryBlockRetrieval#supportsStorageRetrieval() + */ + public boolean supportsStorageRetrieval() { + return false; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IMemoryBlockRetrieval#getMemoryBlock(long, long) + */ + public IMemoryBlock getMemoryBlock(long startAddress, long length) throws DebugException { + notSupported(DebugCoreMessages.getString("DebugTarget.0"), null); //$NON-NLS-1$ + return null; + } + +} |