Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Wright2009-01-11 04:17:29 +0000
committerDarin Wright2009-01-11 04:17:29 +0000
commit8f6f0b0b845dabaffb14b870cc1c6e05e0c3bfa8 (patch)
tree0de05cf63e1e1636106fe979d62bbbe509939449
parentbf55a0b74f14ad5ff08ea624ddcddb8d0619406f (diff)
downloadeclipse.platform.debug-8f6f0b0b845dabaffb14b870cc1c6e05e0c3bfa8.tar.gz
eclipse.platform.debug-8f6f0b0b845dabaffb14b870cc1c6e05e0c3bfa8.tar.xz
eclipse.platform.debug-8f6f0b0b845dabaffb14b870cc1c6e05e0c3bfa8.zip
counting example
-rw-r--r--org.eclipse.debug.examples.core/plugin.xml6
-rw-r--r--org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/counter/CounterDebugElement.java39
-rw-r--r--org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/counter/CounterDebugTarget.java216
-rw-r--r--org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/counter/CounterLaunchDelegate.java32
-rw-r--r--org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/counter/CounterStackFrame.java221
-rw-r--r--org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/counter/CounterThread.java273
-rw-r--r--org.eclipse.debug.examples.ui/plugin.xml7
-rw-r--r--org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/counter/CounterTabGroup.java32
8 files changed, 826 insertions, 0 deletions
diff --git a/org.eclipse.debug.examples.core/plugin.xml b/org.eclipse.debug.examples.core/plugin.xml
index 86e5280b5..1226b9547 100644
--- a/org.eclipse.debug.examples.core/plugin.xml
+++ b/org.eclipse.debug.examples.core/plugin.xml
@@ -35,6 +35,12 @@
modes="run"
name="Ping Example">
</launchConfigurationType>
+ <launchConfigurationType
+ delegate="org.eclipse.debug.examples.core.counter.CounterLaunchDelegate"
+ id="counter.launchType"
+ modes="run, debug"
+ name="Counter Example">
+ </launchConfigurationType>
</extension>
<!--#ifdef ex4-->
diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/counter/CounterDebugElement.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/counter/CounterDebugElement.java
new file mode 100644
index 000000000..cac01aa52
--- /dev/null
+++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/counter/CounterDebugElement.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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
+ *******************************************************************************/
+package org.eclipse.debug.examples.core.counter;
+
+import org.eclipse.debug.core.model.DebugElement;
+import org.eclipse.debug.core.model.IDebugTarget;
+
+/**
+ * Common function for elements from the example counter debug model.
+ */
+public abstract class CounterDebugElement extends DebugElement {
+
+ /**
+ * Constructs a debug element for the counter debug model.
+ *
+ * @param target debug target
+ */
+ public CounterDebugElement(IDebugTarget target) {
+ super(target);
+ }
+
+ public static final String COUNTER_MODEL_ID = "counter.debugModel";
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IDebugElement#getModelIdentifier()
+ */
+ public String getModelIdentifier() {
+ return COUNTER_MODEL_ID;
+ }
+
+}
diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/counter/CounterDebugTarget.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/counter/CounterDebugTarget.java
new file mode 100644
index 000000000..0688e8faa
--- /dev/null
+++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/counter/CounterDebugTarget.java
@@ -0,0 +1,216 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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
+ *******************************************************************************/
+package org.eclipse.debug.examples.core.counter;
+
+import org.eclipse.core.resources.IMarkerDelta;
+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;
+
+/**
+ * Debug target for the counter model.
+ */
+public class CounterDebugTarget extends CounterDebugElement implements IDebugTarget {
+
+ /**
+ * The single thread in this target
+ */
+ private IThread fThread;
+
+ /**
+ * The launch this target is part of;
+ */
+ private ILaunch fLaunch;
+
+ /**
+ * Constructs the counting target with a single thread.
+ */
+ public CounterDebugTarget(ILaunch launch) {
+ super(null);
+ fLaunch = launch;
+ fThread = new CounterThread(this);
+ fireCreationEvent();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.DebugElement#getDebugTarget()
+ */
+ public IDebugTarget getDebugTarget() {
+ return this;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.DebugElement#getLaunch()
+ */
+ public ILaunch getLaunch() {
+ return fLaunch;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IDebugTarget#getName()
+ */
+ public String getName() throws DebugException {
+ return "Counting Target";
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IDebugTarget#getProcess()
+ */
+ public IProcess getProcess() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IDebugTarget#getThreads()
+ */
+ public IThread[] getThreads() throws DebugException {
+ if (isTerminated()) {
+ return new IThread[0];
+ }
+ return new IThread[]{fThread};
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IDebugTarget#hasThreads()
+ */
+ public boolean hasThreads() throws DebugException {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IDebugTarget#supportsBreakpoint(org.eclipse.debug.core.model.IBreakpoint)
+ */
+ public boolean supportsBreakpoint(IBreakpoint breakpoint) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ITerminate#canTerminate()
+ */
+ public boolean canTerminate() {
+ return fThread.canTerminate();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ITerminate#isTerminated()
+ */
+ public boolean isTerminated() {
+ return fThread.isTerminated();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ITerminate#terminate()
+ */
+ public void terminate() throws DebugException {
+ fThread.terminate();
+ fireTerminateEvent();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#canResume()
+ */
+ public boolean canResume() {
+ return fThread.canResume();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#canSuspend()
+ */
+ public boolean canSuspend() {
+ return fThread.canSuspend();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#isSuspended()
+ */
+ public boolean isSuspended() {
+ return fThread.isSuspended();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#resume()
+ */
+ public void resume() throws DebugException {
+ fThread.resume();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#suspend()
+ */
+ public void suspend() throws DebugException {
+ fThread.suspend();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.IBreakpointListener#breakpointAdded(org.eclipse.debug.core.model.IBreakpoint)
+ */
+ public void breakpointAdded(IBreakpoint breakpoint) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.IBreakpointListener#breakpointChanged(org.eclipse.debug.core.model.IBreakpoint, org.eclipse.core.resources.IMarkerDelta)
+ */
+ public void breakpointChanged(IBreakpoint breakpoint, IMarkerDelta delta) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.IBreakpointListener#breakpointRemoved(org.eclipse.debug.core.model.IBreakpoint, org.eclipse.core.resources.IMarkerDelta)
+ */
+ public void breakpointRemoved(IBreakpoint breakpoint, IMarkerDelta delta) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IDisconnect#canDisconnect()
+ */
+ public boolean canDisconnect() {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IDisconnect#disconnect()
+ */
+ public void disconnect() throws DebugException {
+ notSupported("disconnect not supported", null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IDisconnect#isDisconnected()
+ */
+ public boolean isDisconnected() {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IMemoryBlockRetrieval#getMemoryBlock(long, long)
+ */
+ public IMemoryBlock getMemoryBlock(long startAddress, long length) throws DebugException {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IMemoryBlockRetrieval#supportsStorageRetrieval()
+ */
+ public boolean supportsStorageRetrieval() {
+ return false;
+ }
+
+}
diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/counter/CounterLaunchDelegate.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/counter/CounterLaunchDelegate.java
new file mode 100644
index 000000000..5212a0123
--- /dev/null
+++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/counter/CounterLaunchDelegate.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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
+ *******************************************************************************/
+package org.eclipse.debug.examples.core.counter;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
+
+/**
+ * Launch delegate for the counter debug example.
+ */
+public class CounterLaunchDelegate extends LaunchConfigurationDelegate {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
+ CounterDebugTarget target = new CounterDebugTarget(launch);
+ launch.addDebugTarget(target);
+ }
+
+}
diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/counter/CounterStackFrame.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/counter/CounterStackFrame.java
new file mode 100644
index 000000000..05ceb4396
--- /dev/null
+++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/counter/CounterStackFrame.java
@@ -0,0 +1,221 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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
+ *******************************************************************************/
+package org.eclipse.debug.examples.core.counter;
+
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IRegisterGroup;
+import org.eclipse.debug.core.model.IStackFrame;
+import org.eclipse.debug.core.model.IThread;
+import org.eclipse.debug.core.model.IVariable;
+
+/**
+ * Stack frame for the counting debug example.
+ */
+public class CounterStackFrame extends CounterDebugElement implements IStackFrame {
+
+ private CounterThread fThread;
+
+ /**
+ * Constructs a stack frame for the counter example for the given thread.
+ *
+ * @param target
+ */
+ public CounterStackFrame(CounterThread thread) {
+ super(thread.getDebugTarget());
+ fThread = thread;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStackFrame#getCharEnd()
+ */
+ public int getCharEnd() throws DebugException {
+ return -1;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStackFrame#getCharStart()
+ */
+ public int getCharStart() throws DebugException {
+ return -1;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStackFrame#getLineNumber()
+ */
+ public int getLineNumber() throws DebugException {
+ return fThread.fCount;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStackFrame#getName()
+ */
+ public String getName() throws DebugException {
+ return "Count: " + getLineNumber();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStackFrame#getRegisterGroups()
+ */
+ public IRegisterGroup[] getRegisterGroups() throws DebugException {
+ return new IRegisterGroup[0];
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStackFrame#getThread()
+ */
+ public IThread getThread() {
+ return fThread;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStackFrame#getVariables()
+ */
+ public IVariable[] getVariables() throws DebugException {
+ return new IVariable[0];
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStackFrame#hasRegisterGroups()
+ */
+ public boolean hasRegisterGroups() throws DebugException {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStackFrame#hasVariables()
+ */
+ public boolean hasVariables() throws DebugException {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStep#canStepInto()
+ */
+ public boolean canStepInto() {
+ return fThread.canStepInto();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStep#canStepOver()
+ */
+ public boolean canStepOver() {
+ return fThread.canStepOver();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStep#canStepReturn()
+ */
+ public boolean canStepReturn() {
+ return fThread.canStepReturn();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStep#isStepping()
+ */
+ public boolean isStepping() {
+ return fThread.isStepping();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStep#stepInto()
+ */
+ public void stepInto() throws DebugException {
+ fThread.stepInto();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStep#stepOver()
+ */
+ public void stepOver() throws DebugException {
+ fThread.stepOver();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStep#stepReturn()
+ */
+ public void stepReturn() throws DebugException {
+ fThread.stepReturn();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#canResume()
+ */
+ public boolean canResume() {
+ return fThread.canResume();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#canSuspend()
+ */
+ public boolean canSuspend() {
+ return fThread.canSuspend();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#isSuspended()
+ */
+ public boolean isSuspended() {
+ return fThread.isSuspended();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#resume()
+ */
+ public void resume() throws DebugException {
+ fThread.resume();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#suspend()
+ */
+ public void suspend() throws DebugException {
+ fThread.suspend();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ITerminate#canTerminate()
+ */
+ public boolean canTerminate() {
+ return fThread.canTerminate();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ITerminate#isTerminated()
+ */
+ public boolean isTerminated() {
+ return fThread.isTerminated();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ITerminate#terminate()
+ */
+ public void terminate() throws DebugException {
+ fThread.terminate();
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object obj) {
+ if (obj instanceof CounterStackFrame) {
+ CounterStackFrame frame = (CounterStackFrame) obj;
+ return fThread.equals(frame.fThread);
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode() {
+ return getClass().hashCode() + fThread.hashCode();
+ }
+}
diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/counter/CounterThread.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/counter/CounterThread.java
new file mode 100644
index 000000000..3af3a86c9
--- /dev/null
+++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/counter/CounterThread.java
@@ -0,0 +1,273 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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
+ *******************************************************************************/
+package org.eclipse.debug.examples.core.counter;
+
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IBreakpoint;
+import org.eclipse.debug.core.model.IDebugTarget;
+import org.eclipse.debug.core.model.IStackFrame;
+import org.eclipse.debug.core.model.IThread;
+
+/**
+ * Thread for the counting debug model example.
+ */
+public class CounterThread extends CounterDebugElement implements IThread {
+
+ // Thread state
+ private boolean fTerminated = false;
+ private boolean fSuspended = false;
+ private boolean fStepping = false;
+
+ // Counter
+ int fCount = 0;
+
+ // simulates an executing thread
+ class Execution implements Runnable {
+ /* (non-Javadoc)
+ * @see java.lang.Runnable#run()
+ */
+ public void run() {
+ while (true) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ return;
+ }
+ fCount++;
+ }
+ }
+
+ }
+
+ // the execution and its thread
+ private Execution fExecution;
+ private Thread fExecThread;
+
+ // simulates a step over
+ class StepOver implements Runnable {
+
+ /* (non-Javadoc)
+ * @see java.lang.Runnable#run()
+ */
+ public void run() {
+ fireResumeEvent(DebugEvent.STEP_OVER);
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ synchronized (CounterThread.this) {
+ fStepping = false;
+ fSuspended = true;
+ }
+ fireSuspendEvent(DebugEvent.CLIENT_REQUEST);
+ return;
+ }
+ fCount++;
+ synchronized (CounterThread.this) {
+ fStepping = false;
+ fSuspended = true;
+ }
+ fireSuspendEvent(DebugEvent.STEP_END);
+ }
+
+ }
+
+ /**
+ * Constructs a thread in the given target.
+ *
+ * @param target debug target
+ */
+ public CounterThread(IDebugTarget target) {
+ super(target);
+ fExecution = new Execution();
+ fExecThread = new Thread(fExecution);
+ fExecThread.start();
+ fireCreationEvent();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IThread#getBreakpoints()
+ */
+ public IBreakpoint[] getBreakpoints() {
+ // TODO:
+ return new IBreakpoint[0];
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IThread#getName()
+ */
+ public String getName() throws DebugException {
+ return "Counting Thread";
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IThread#getPriority()
+ */
+ public int getPriority() throws DebugException {
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IThread#getStackFrames()
+ */
+ public IStackFrame[] getStackFrames() throws DebugException {
+ synchronized (this) {
+ if (isSuspended()) {
+ return new IStackFrame[]{new CounterStackFrame(this)};
+ }
+ }
+ return new IStackFrame[0];
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IThread#getTopStackFrame()
+ */
+ public IStackFrame getTopStackFrame() throws DebugException {
+ synchronized (this) {
+ if (isSuspended()) {
+ return new CounterStackFrame(this);
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IThread#hasStackFrames()
+ */
+ public boolean hasStackFrames() throws DebugException {
+ return isSuspended();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#canResume()
+ */
+ public synchronized boolean canResume() {
+ return isSuspended();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#canSuspend()
+ */
+ public synchronized boolean canSuspend() {
+ return !isTerminated() && !isSuspended();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#isSuspended()
+ */
+ public synchronized boolean isSuspended() {
+ return fSuspended && !isTerminated();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#resume()
+ */
+ public void resume() throws DebugException {
+ synchronized (this) {
+ fExecThread = new Thread(fExecution);
+ fExecThread.start();
+ fSuspended = false;
+ }
+ fireResumeEvent(DebugEvent.CLIENT_REQUEST);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#suspend()
+ */
+ public void suspend() throws DebugException {
+ synchronized (this) {
+ fExecThread.interrupt();
+ fSuspended = true;
+ }
+ fireSuspendEvent(DebugEvent.CLIENT_REQUEST);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStep#canStepInto()
+ */
+ public boolean canStepInto() {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStep#canStepOver()
+ */
+ public boolean canStepOver() {
+ return isSuspended();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStep#canStepReturn()
+ */
+ public boolean canStepReturn() {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStep#isStepping()
+ */
+ public synchronized boolean isStepping() {
+ return fStepping;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStep#stepInto()
+ */
+ public void stepInto() throws DebugException {
+ notSupported("Step into not supported", null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStep#stepOver()
+ */
+ public void stepOver() throws DebugException {
+ synchronized (this) {
+ StepOver step = new StepOver();
+ fExecThread = new Thread(step);
+ fStepping = true;
+ fSuspended = false;
+ fExecThread.start();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStep#stepReturn()
+ */
+ public void stepReturn() throws DebugException {
+ notSupported("Step return not supported", null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ITerminate#canTerminate()
+ */
+ public boolean canTerminate() {
+ return !isTerminated();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ITerminate#isTerminated()
+ */
+ public synchronized boolean isTerminated() {
+ return fTerminated;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ITerminate#terminate()
+ */
+ public void terminate() throws DebugException {
+ synchronized (this) {
+ fExecThread.interrupt();
+ fTerminated = true;
+ }
+ fireTerminateEvent();
+ }
+
+}
diff --git a/org.eclipse.debug.examples.ui/plugin.xml b/org.eclipse.debug.examples.ui/plugin.xml
index d98ab83be..717acdf7d 100644
--- a/org.eclipse.debug.examples.ui/plugin.xml
+++ b/org.eclipse.debug.examples.ui/plugin.xml
@@ -17,8 +17,15 @@
type="midi.launchType"/>
<launchConfigurationTabGroup
class="org.eclipse.debug.examples.ui.ping.PingTabGroup"
+ description="Ping an IP address or domain name"
id="ping.tabGroup"
type="ping.launchType">
+ </launchConfigurationTabGroup>
+ <launchConfigurationTabGroup
+ class="org.eclipse.debug.examples.ui.counter.CounterTabGroup"
+ description="Count forever"
+ id="counter.tabGroup"
+ type="counter.launchType">
</launchConfigurationTabGroup>
</extension>
<extension
diff --git a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/counter/CounterTabGroup.java b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/counter/CounterTabGroup.java
new file mode 100644
index 000000000..65fe27272
--- /dev/null
+++ b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/counter/CounterTabGroup.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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
+ *******************************************************************************/
+package org.eclipse.debug.examples.ui.counter;
+
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
+import org.eclipse.debug.ui.CommonTab;
+import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+
+/**
+ * Tab group for the ping example.
+ */
+public class CounterTabGroup extends AbstractLaunchConfigurationTabGroup {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTabGroup#createTabs(org.eclipse.debug.ui.ILaunchConfigurationDialog, java.lang.String)
+ */
+ public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
+ setTabs(new ILaunchConfigurationTab[]{
+ new CommonTab()
+ });
+ }
+
+}

Back to the top