Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikhail Khodjaiants2002-08-06 18:56:39 +0000
committerMikhail Khodjaiants2002-08-06 18:56:39 +0000
commitaa3d2c911cc076d6966abe70add306431416bf0e (patch)
treea5928f4eba52dfe4e38da538da7ea74df4733be2 /debug/org.eclipse.cdt.debug.core
parent385d59ed689e6f731109a972776be5814717c6f7 (diff)
downloadorg.eclipse.cdt-aa3d2c911cc076d6966abe70add306431416bf0e.tar.gz
org.eclipse.cdt-aa3d2c911cc076d6966abe70add306431416bf0e.tar.xz
org.eclipse.cdt-aa3d2c911cc076d6966abe70add306431416bf0e.zip
Added the implementation of the UI adapters.
Diffstat (limited to 'debug/org.eclipse.cdt.debug.core')
-rw-r--r--debug/org.eclipse.cdt.debug.core/.classpath1
-rw-r--r--debug/org.eclipse.cdt.debug.core/.project63
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java61
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java37
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/IFormattedMemoryBlock.java89
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/IFormattedMemoryBlockRow.java37
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/IFormattedMemoryRetrieval.java52
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/IInstructionStep.java50
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/IRestart.java30
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/IState.java31
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/model/ICArgument.java17
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/model/ICTarget.java2
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDebugElement.java246
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDebugTarget.java985
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CThread.java283
15 files changed, 1952 insertions, 32 deletions
diff --git a/debug/org.eclipse.cdt.debug.core/.classpath b/debug/org.eclipse.cdt.debug.core/.classpath
index 303dfc90c8f..2a63a6d3792 100644
--- a/debug/org.eclipse.cdt.debug.core/.classpath
+++ b/debug/org.eclipse.cdt.debug.core/.classpath
@@ -2,6 +2,7 @@
<classpath>
<classpathentry kind="src" path="src/"/>
<classpathentry kind="src" path="/org.eclipse.core.resources"/>
+ <classpathentry kind="src" path="/org.eclipse.debug.core"/>
<classpathentry kind="src" path="/org.eclipse.core.runtime"/>
<classpathentry kind="src" path="/org.eclipse.core.boot"/>
<classpathentry kind="var" path="JRE_LIB" rootpath="JRE_SRCROOT" sourcepath="JRE_SRC"/>
diff --git a/debug/org.eclipse.cdt.debug.core/.project b/debug/org.eclipse.cdt.debug.core/.project
index f83b3ea87b3..80d525ded05 100644
--- a/debug/org.eclipse.cdt.debug.core/.project
+++ b/debug/org.eclipse.cdt.debug.core/.project
@@ -1,31 +1,32 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.cdt.debug.core</name>
- <comment></comment>
- <projects>
- <project>org.eclipse.core.boot</project>
- <project>org.eclipse.core.resources</project>
- <project>org.eclipse.core.runtime</project>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.eclipse.pde.PluginNature</nature>
- </natures>
-</projectDescription>
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.cdt.debug.core</name>
+ <comment></comment>
+ <projects>
+ <project>org.eclipse.core.boot</project>
+ <project>org.eclipse.core.resources</project>
+ <project>org.eclipse.core.runtime</project>
+ <project>org.eclipse.debug.core</project>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ </natures>
+</projectDescription>
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java
index 62416e40e95..e4646a388da 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java
@@ -9,13 +9,21 @@ package org.eclipse.cdt.debug.core;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPluginDescriptor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugException;
/**
* The main plugin class to be used in the desktop.
*/
public class CDebugCorePlugin extends Plugin
{
+ /**
+ * Status code indicating an unexpected internal error.
+ */
+ public static final int INTERNAL_ERROR = 1000;
+
//The shared instance.
private static CDebugCorePlugin plugin;
@@ -30,6 +38,8 @@ public class CDebugCorePlugin extends Plugin
/**
* Returns the shared instance.
+ *
+ * @return the shared instance
*/
public static CDebugCorePlugin getDefault()
{
@@ -38,9 +48,60 @@ public class CDebugCorePlugin extends Plugin
/**
* Returns the workspace instance.
+ *
+ * @return the workspace instance
*/
public static IWorkspace getWorkspace()
{
return ResourcesPlugin.getWorkspace();
}
+
+ /**
+ * Convenience method which returns the unique identifier of this plugin.
+ *
+ * @return the unique identifier of this plugin
+ */
+ public static String getUniqueIdentifier()
+ {
+ if ( getDefault() == null )
+ {
+ // If the default instance is not yet initialized,
+ // return a static identifier. This identifier must
+ // match the plugin id defined in plugin.xml
+ return "org.eclipse.cdt.debug.core"; //$NON-NLS-1$
+ }
+ return getDefault().getDescriptor().getUniqueIdentifier();
+ }
+
+ /**
+ * Logs the specified throwable with this plug-in's log.
+ *
+ * @param t throwable to log
+ */
+ public static void log( Throwable t )
+ {
+ Throwable top = t;
+ if ( t instanceof DebugException )
+ {
+ DebugException de = (DebugException)t;
+ IStatus status = de.getStatus();
+ if ( status.getException() != null )
+ {
+ top = status.getException();
+ }
+ }
+ // this message is intentionally not internationalized, as an exception may
+ // be due to the resource bundle itself
+ log( new Status( IStatus.ERROR, getUniqueIdentifier(), INTERNAL_ERROR, "Internal error logged from CDI Debug: ", top ) ); //$NON-NLS-1$
+ }
+
+ /**
+ * Logs the specified status with this plug-in's log.
+ *
+ * @param status status to log
+ */
+ public static void log( IStatus status )
+ {
+ getDefault().getLog().log( status );
+ }
}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java
new file mode 100644
index 00000000000..621e830dd67
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java
@@ -0,0 +1,37 @@
+/*
+ *(c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ *
+ */
+
+package org.eclipse.cdt.debug.core;
+
+
+
+/**
+ *
+ * Provides utility methods for creating debug sessions, targets and
+ * breakpoints specific to the CDI debug model.
+ *
+ * @since Aug 1, 2002
+ */
+public class CDebugModel
+{
+ /**
+ * Constructor for CDebugModel.
+ */
+ public CDebugModel()
+ {
+ super();
+ }
+
+ /**
+ * Returns the identifier for the CDI debug model plug-in
+ *
+ * @return plugin identifier
+ */
+ public static String getPluginIdentifier()
+ {
+ return CDebugCorePlugin.getUniqueIdentifier();
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/IFormattedMemoryBlock.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/IFormattedMemoryBlock.java
new file mode 100644
index 00000000000..b97d6cc6f31
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/IFormattedMemoryBlock.java
@@ -0,0 +1,89 @@
+/*
+ *(c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ *
+ */
+package org.eclipse.cdt.debug.core;
+
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IDebugElement;
+
+/**
+ *
+ * A contiguos segment of memory in an execution context represented
+ * as a table of values.
+ *
+ * @since Jul 31, 2002
+ */
+public interface IFormattedMemoryBlock extends IDebugElement
+{
+ /**
+ * Returns the start address of this memory block.
+ *
+ * @return the start address of this memory block
+ */
+ long getStartAddress();
+
+ /**
+ * Returns the format of the memory words of this block.
+ *
+ * @return The format of the memory words of this block
+ */
+ int getFormat();
+
+ /**
+ * Returns the size of each memory word in bytes.
+ *
+ * @return the size of each memory word in bytes
+ */
+ int getWordSize();
+
+ /**
+ * Returns the number of rows in the output table.
+ *
+ * @return the number of rows in the output table
+ */
+ int getNumberOfRows();
+
+ /**
+ * Returns the number of columns in the output table.
+ *
+ * @return the number of columns in the output table
+ */
+ int getNumberOfColumns();
+
+ /**
+ * Returns whether each row should include an ASCII dump.
+ *
+ * @return whether each row should include an ASCII dump
+ */
+ boolean displayASCII();
+
+ /**
+ * Returns the array of rows.
+ *
+ * @return the array of rows
+ */
+ IFormattedMemoryBlockRow[] getRows();
+
+ long nextRowAddress();
+
+ long previousRowAddress();
+
+ long nextPageAddress();
+
+ long previousPageAddress();
+
+ void reformat( long startAddress,
+ int format,
+ int wordSize,
+ int numberOfRows,
+ int numberOfColumns ) throws DebugException;
+
+ void reformat( long startAddress,
+ int format,
+ int wordSize,
+ int numberOfRows,
+ int numberOfColumns,
+ char paddingChar ) throws DebugException;
+}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/IFormattedMemoryBlockRow.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/IFormattedMemoryBlockRow.java
new file mode 100644
index 00000000000..249869a9f4d
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/IFormattedMemoryBlockRow.java
@@ -0,0 +1,37 @@
+/*
+ *(c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ *
+ */
+
+package org.eclipse.cdt.debug.core;
+
+/**
+ *
+ * Represents a row in the output table of formatted memory block.
+ *
+ * @since Jul 31, 2002
+ */
+public interface IFormattedMemoryBlockRow
+{
+ /**
+ * Returns the address of this row.
+ *
+ * @return the address of this row
+ */
+ long getAddress();
+
+ /**
+ * Returns the array of memory words.
+ *
+ * @return the array of memory words
+ */
+ String[] getData();
+
+ /**
+ * Returns the ASCII dump for this row.
+ *
+ * @return the ASCII dump for this row
+ */
+ String getASCII();
+}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/IFormattedMemoryRetrieval.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/IFormattedMemoryRetrieval.java
new file mode 100644
index 00000000000..50c36e5d1f3
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/IFormattedMemoryRetrieval.java
@@ -0,0 +1,52 @@
+/*
+ *(c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ *
+ */
+package org.eclipse.cdt.debug.core;
+
+import org.eclipse.debug.core.DebugException;
+
+/**
+ *
+ * Supports the retrieval of formatted blocks of memory.
+ *
+ * @since Jul 31, 2002
+ */
+public interface IFormattedMemoryRetrieval
+{
+ public static final int MEMORY_SIZE_BYTE = 1;
+ public static final int MEMORY_SIZE_HALF_WORD = 2;
+ public static final int MEMORY_SIZE_WORD = 4;
+ public static final int MEMORY_SIZE_DOUBLE_WORD = 8;
+ public static final int MEMORY_SIZE_FLOAT = 8;
+ public static final int MEMORY_SIZE_DOUBLE_FLOAT = 16;
+
+ public static final int MEMORY_FORMAT_HEX = 0;
+ public static final int MEMORY_FORMAT_BINARY = 1;
+ public static final int MEMORY_FORMAT_OCTAL = 2;
+ public static final int MEMORY_FORMAT_SIGNED_DECIMAL = 3;
+ public static final int MEMORY_FORMAT_UNSIGNED_DECIMAL = 4;
+
+ public static final int MEMORY_BYTES_PER_ROW_4 = 4;
+ public static final int MEMORY_BYTES_PER_ROW_8 = 8;
+ public static final int MEMORY_BYTES_PER_ROW_16 = 16;
+ public static final int MEMORY_BYTES_PER_ROW_32 = 32;
+ public static final int MEMORY_BYTES_PER_ROW_64 = 64;
+ public static final int MEMORY_BYTES_PER_ROW_128 = 128;
+
+ int[] getSupportedFormats() throws DebugException;
+
+ IFormattedMemoryBlock getFormattedMemoryBlock( long startAddress,
+ int format,
+ int wordSize,
+ int numberOfRows,
+ int numberOfColumns ) throws DebugException;
+
+ IFormattedMemoryBlock getFormattedMemoryBlock( long startAddress,
+ int format,
+ int wordSize,
+ int numberOfRows,
+ int numberOfColumns,
+ char paddingChar ) throws DebugException;
+}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/IInstructionStep.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/IInstructionStep.java
new file mode 100644
index 00000000000..08f8061386f
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/IInstructionStep.java
@@ -0,0 +1,50 @@
+/*
+ *(c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ *
+ */
+
+package org.eclipse.cdt.debug.core;
+import org.eclipse.debug.core.DebugException;
+
+/**
+ * Provides the ability to step into and over machine instruction
+ * at the current execution location.
+ *
+ */
+public interface IInstructionStep
+{
+ /**
+ * Returns whether this element can currently perform a step
+ * into the instruction.
+ *
+ * @return whether this element can currently perform a step
+ * into the instruction
+ */
+ boolean canStepIntoInstruction();
+
+ /**
+ * Returns whether this element can currently perform a step
+ * over the instruction (nexti command).
+ *
+ * @return whether this element can currently perform a step
+ * over the instruction
+ */
+ boolean canStepOverInstruction();
+
+ /**
+ * Steps into the current instruction.
+ *
+ * @exception DebugException on failure. Reasons include:<ul>
+ * </ul>
+ */
+ void stepIntoInstruction() throws DebugException;
+
+ /**
+ * Steps over the current instruction.
+ *
+ * @exception DebugException on failure. Reasons include:<ul>
+ * </ul>
+ */
+ void stepOverInstruction() throws DebugException;
+}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/IRestart.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/IRestart.java
new file mode 100644
index 00000000000..d6e163fa2d7
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/IRestart.java
@@ -0,0 +1,30 @@
+/*
+ *(c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ *
+ */
+
+package org.eclipse.cdt.debug.core;
+
+import org.eclipse.debug.core.DebugException;
+/**
+ * Provides the ability to restart a debug target.
+ *
+ */
+public interface IRestart
+{
+ /**
+ * Returns whether this element can currently be restarted.
+ *
+ * @return whether this element can currently be restarted
+ */
+ public boolean canRestart();
+
+ /**
+ * Causes this element to restart its execution.
+ *
+ * @exception DebugException on failure. Reasons include:
+ */
+ public void restart() throws DebugException;
+}
+
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/IState.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/IState.java
new file mode 100644
index 00000000000..1af1a37ae5f
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/IState.java
@@ -0,0 +1,31 @@
+/*
+ *(c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ *
+ */
+
+package org.eclipse.cdt.debug.core;
+
+/**
+ *
+ * Represents the current state of debug element.
+ *
+ * @since Aug 6, 2002
+ */
+public interface IState
+{
+ public static final int UNKNOWN = 0;
+ public static final int NOT_RESPONDING = 1;
+ public static final int STARTING = 2;
+ public static final int ATTACHING = 3;
+ public static final int DISCONNECTING = 4;
+ public static final int RUNNING = 5;
+ public static final int STEPPING = 6;
+ public static final int SUSPENDED = 7;
+ public static final int EXITED = 8;
+ public static final int DISCONNECTED = 9;
+ public static final int TERMINATED = 10;
+ public static final int CORE_DUMP_FILE = 11;
+
+ int getCurrentState();
+}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/model/ICArgument.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/model/ICArgument.java
new file mode 100644
index 00000000000..0b7a23e9f1c
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/model/ICArgument.java
@@ -0,0 +1,17 @@
+/*
+ *(c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ *
+ */
+
+package org.eclipse.cdt.debug.core.cdi.model;
+
+/**
+ *
+ * Represents an argument in the stack frame.
+ *
+ * @since Jul 22, 2002
+ */
+public interface ICArgument extends ICVariable
+{
+}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/model/ICTarget.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/model/ICTarget.java
index 17d09ffbd9b..1f4e0e4d07a 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/model/ICTarget.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/model/ICTarget.java
@@ -61,7 +61,7 @@ public interface ICTarget extends ICObject
* @throws CDIException if this method fails. Reasons include:
*/
ICSharedLibrary[] getSharedLibraries() throws CDIException;
-
+
/**
* Returns the threads contained in this target.
* An empty collection is returned if this target contains no
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDebugElement.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDebugElement.java
new file mode 100644
index 00000000000..81df8c7637f
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDebugElement.java
@@ -0,0 +1,246 @@
+/*
+ *(c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ *
+ */
+
+package org.eclipse.cdt.debug.internal.core;
+
+import org.eclipse.cdt.debug.core.CDebugCorePlugin;
+import org.eclipse.cdt.debug.core.CDebugModel;
+import org.eclipse.cdt.debug.core.cdi.CDIException;
+import org.eclipse.cdt.debug.core.cdi.ICSession;
+import org.eclipse.cdt.debug.core.cdi.model.ICTarget;
+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;
+import org.eclipse.debug.core.model.IDebugTarget;
+
+/**
+ *
+ * Enter type comment.
+ *
+ * @since Aug 1, 2002
+ */
+public class CDebugElement extends PlatformObject
+ implements IDebugElement
+{
+ private CDebugTarget fDebugTarget;
+
+ /**
+ * Constructor for CDebugElement.
+ */
+ public CDebugElement( CDebugTarget target )
+ {
+ setDebugTarget( target );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IDebugElement#getModelIdentifier()
+ */
+ public String getModelIdentifier()
+ {
+ return CDebugModel.getPluginIdentifier();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IDebugElement#getDebugTarget()
+ */
+ public IDebugTarget getDebugTarget()
+ {
+ return fDebugTarget;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IDebugElement#getLaunch()
+ */
+ public ILaunch getLaunch()
+ {
+ return getDebugTarget().getLaunch();
+ }
+
+ protected void setDebugTarget( CDebugTarget target )
+ {
+ fDebugTarget = target;
+ }
+
+ /**
+ * Logs the given exception.
+ *
+ * @param e the internal exception
+ */
+ public void internalError( Exception e )
+ {
+ logError( e );
+ }
+
+ /**
+ * Convenience method to log errors
+ *
+ */
+ protected void logError( Exception e )
+ {
+ CDebugCorePlugin.log( e );
+ }
+
+ /**
+ * Fires a debug event
+ *
+ * @param event The debug event to be fired to the listeners
+ * @see org.eclipse.debug.core.DebugEvent
+ */
+ protected void fireEvent(DebugEvent event)
+ {
+ DebugPlugin.getDefault().fireDebugEventSet( new DebugEvent[] { event } );
+ }
+
+ /**
+ * Fires a debug event marking the creation of this element.
+ */
+ protected void fireCreationEvent()
+ {
+ fireEvent( new DebugEvent( this, DebugEvent.CREATE ) );
+ }
+
+ /**
+ * Fires a debug event marking the RESUME of this element with
+ * the associated detail.
+ *
+ * @param detail The int detail of the event
+ * @see org.eclipse.debug.core.DebugEvent
+ */
+ public void fireResumeEvent( int detail )
+ {
+ fireEvent( new DebugEvent( this, DebugEvent.RESUME, detail ) );
+ }
+
+ /**
+ * Fires a debug event marking the SUSPEND of this element with
+ * the associated detail.
+ *
+ * @param detail The int detail of the event
+ * @see org.eclipse.debug.core.DebugEvent
+ */
+ public void fireSuspendEvent( int detail )
+ {
+ fireEvent( new DebugEvent( this, DebugEvent.SUSPEND, detail ) );
+ }
+
+ /**
+ * Fires a debug event marking the termination of this element.
+ */
+ protected void fireTerminateEvent()
+ {
+ fireEvent( new DebugEvent( this, DebugEvent.TERMINATE ) );
+ }
+
+ /**
+ * Fires a debug event marking the CHANGE of this element
+ * with the specifed detail code.
+ *
+ * @param detail one of <code>STATE</code> or <code>CONTENT</code>
+ */
+ public void fireChangeEvent( int detail )
+ {
+ fireEvent( new DebugEvent( this, DebugEvent.CHANGE, detail ) );
+ }
+
+ /**
+ * Returns the CDI session associated with this element.
+ *
+ * @return the CDI session
+ */
+ public ICSession getCDISession()
+ {
+ return getCDITarget().getSession();
+ }
+
+ /**
+ * Returns the underlying CDI target associated with this element.
+ *
+ * @return the underlying CDI target
+ */
+ public ICTarget getCDITarget()
+ {
+ return (ICTarget)getDebugTarget().getAdapter( ICTarget.class );
+ }
+
+ /**
+ * Throws a new debug exception with a status code of <code>REQUEST_FAILED</code>.
+ *
+ * @param message Failure message
+ * @param e Exception that has occurred (<code>can be null</code>)
+ * @throws DebugException The exception with a status code of <code>REQUEST_FAILED</code>
+ */
+ public void requestFailed( String message, Exception e ) throws DebugException
+ {
+ requestFailed( message, e, DebugException.REQUEST_FAILED );
+ }
+
+ /**
+ * Throws a new debug exception with a status code of <code>TARGET_REQUEST_FAILED</code>
+ * with the given underlying exception. If the underlying exception is not a JDI
+ * exception, the original exception is thrown.
+ *
+ * @param message Failure message
+ * @param e underlying exception that has occurred
+ * @throws DebugException The exception with a status code of <code>TARGET_REQUEST_FAILED</code>
+ */
+ public void targetRequestFailed( String message, CDIException e ) throws DebugException
+ {
+ requestFailed( message, e, DebugException.TARGET_REQUEST_FAILED );
+ }
+
+ /**
+ * Throws a new debug exception with the given status code.
+ *
+ * @param message Failure message
+ * @param e Exception that has occurred (<code>can be null</code>)
+ * @param code status code
+ * @throws DebugException a new exception with given status code
+ */
+ public void requestFailed( String message, Throwable e, int code ) throws DebugException
+ {
+ throwDebugException( message, code, e );
+ }
+
+ /**
+ * Throws a new debug exception with a status code of <code>TARGET_REQUEST_FAILED</code>.
+ *
+ * @param message Failure message
+ * @param e Throwable that has occurred
+ * @throws DebugException The exception with a status code of <code>TARGET_REQUEST_FAILED</code>
+ */
+ public void targetRequestFailed( String message, Throwable e ) throws DebugException
+ {
+ throwDebugException( message, DebugException.TARGET_REQUEST_FAILED, e );
+ }
+
+ /**
+ * Throws a new debug exception with a status code of <code>NOT_SUPPORTED</code>.
+ *
+ * @param message Failure message
+ * @throws DebugException The exception with a status code of <code>NOT_SUPPORTED</code>.
+ */
+ public void notSupported(String message) throws DebugException {
+ throwDebugException(message, DebugException.NOT_SUPPORTED, null);
+ }
+
+ /**
+ * Throws a debug exception with the given message, error code, and underlying
+ * exception.
+ */
+ protected void throwDebugException( String message, int code, Throwable exception ) throws DebugException
+ {
+ throw new DebugException( new Status( IStatus.ERROR,
+ CDebugModel.getPluginIdentifier(),
+ code,
+ message,
+ exception ) );
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDebugTarget.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDebugTarget.java
new file mode 100644
index 00000000000..0b9745e3189
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDebugTarget.java
@@ -0,0 +1,985 @@
+/*
+ *(c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ *
+ */
+package org.eclipse.cdt.debug.internal.core;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.cdt.debug.core.CDebugModel;
+import org.eclipse.cdt.debug.core.IFormattedMemoryBlock;
+import org.eclipse.cdt.debug.core.IFormattedMemoryRetrieval;
+import org.eclipse.cdt.debug.core.IInstructionStep;
+import org.eclipse.cdt.debug.core.IRestart;
+import org.eclipse.cdt.debug.core.IState;
+import org.eclipse.cdt.debug.core.cdi.CDIException;
+import org.eclipse.cdt.debug.core.cdi.ICBreakpoint;
+import org.eclipse.cdt.debug.core.cdi.ICEndSteppingRange;
+import org.eclipse.cdt.debug.core.cdi.ICSession;
+import org.eclipse.cdt.debug.core.cdi.ICSessionObject;
+import org.eclipse.cdt.debug.core.cdi.ICSignal;
+import org.eclipse.cdt.debug.core.cdi.event.ICChangedEvent;
+import org.eclipse.cdt.debug.core.cdi.event.ICCreatedEvent;
+import org.eclipse.cdt.debug.core.cdi.event.ICDisconnectedEvent;
+import org.eclipse.cdt.debug.core.cdi.event.ICEvent;
+import org.eclipse.cdt.debug.core.cdi.event.ICEventListener;
+import org.eclipse.cdt.debug.core.cdi.event.ICExitedEvent;
+import org.eclipse.cdt.debug.core.cdi.event.ICLoadedEvent;
+import org.eclipse.cdt.debug.core.cdi.event.ICRestartedEvent;
+import org.eclipse.cdt.debug.core.cdi.event.ICResumedEvent;
+import org.eclipse.cdt.debug.core.cdi.event.ICSteppingEvent;
+import org.eclipse.cdt.debug.core.cdi.event.ICSuspendedEvent;
+import org.eclipse.cdt.debug.core.cdi.event.ICTerminatedEvent;
+import org.eclipse.cdt.debug.core.cdi.model.ICObject;
+import org.eclipse.cdt.debug.core.cdi.model.ICTarget;
+import org.eclipse.cdt.debug.core.cdi.model.ICThread;
+import org.eclipse.core.resources.IMarkerDelta;
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IBreakpointManager;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchListener;
+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;
+
+/**
+ *
+ * Enter type comment.
+ *
+ * @since Aug 1, 2002
+ */
+public class CDebugTarget extends CDebugElement
+ implements IDebugTarget,
+ ICEventListener,
+ IRestart,
+ IInstructionStep,
+ IFormattedMemoryRetrieval,
+ IState,
+ ILaunchListener
+{
+ /**
+ * Threads contained in this debug target. When a thread
+ * starts it is added to the list. When a thread ends it
+ * is removed from the list.
+ */
+ private ArrayList fThreads;
+
+ /**
+ * Associated system process, or <code>null</code> if not available.
+ */
+ private IProcess fProcess;
+
+ /**
+ * Underlying CDI target.
+ */
+ private ICTarget fCDITarget;
+
+ /**
+ * The name of this target.
+ */
+ private String fName;
+
+ /**
+ * Whether this target is suspended.
+ */
+ private boolean fSuspended = true;
+
+ /**
+ * Whether terminated
+ */
+ private boolean fTerminated;
+
+ /**
+ * Whether in the process of terminating
+ */
+ private boolean fTerminating;
+
+ /**
+ * Whether disconnected
+ */
+ private boolean fDisconnected;
+
+ /**
+ * Whether the target should be resumed on startup
+ */
+ private boolean fResumeOnStartup = false;
+
+ /**
+ * The launch this target is contained in
+ */
+ private ILaunch fLaunch;
+
+ /**
+ * Whether terminate is supported.
+ */
+ private boolean fSupportsTerminate;
+
+ /**
+ * Whether disconnect is supported.
+ */
+ private boolean fSupportsDisconnect;
+
+ /**
+ * Constructor for CDebugTarget.
+ * @param target
+ */
+ public CDebugTarget( ILaunch launch,
+ ICTarget cdiTarget,
+ String name,
+ IProcess process,
+ boolean resume )
+ {
+ super( null );
+ setLaunch( launch );
+ setDebugTarget( this );
+ setName( name );
+ setProcess( process );
+ setCDITarget( cdiTarget );
+ setThreadList( new ArrayList( 5 ) );
+ initialize();
+ DebugPlugin.getDefault().getLaunchManager().addLaunchListener( this );
+ getCDISession().getEventManager().addEventListener( this );
+ }
+
+ /**
+ * Initialize state from the underlying debug session.
+ *
+ */
+ protected void initialize()
+ {
+ initializeState();
+ initializeBreakpoints();
+ getLaunch().addDebugTarget( this );
+ fireCreationEvent();
+ }
+
+ /**
+ * Adds all of the pre-existing threads to this debug target.
+ */
+ protected void initializeState()
+ {
+ ICThread[] threads = new ICThread[0];
+ try
+ {
+ threads = getCDITarget().getThreads();
+ }
+ catch( CDIException e )
+ {
+ internalError( e );
+ }
+ for ( int i = 0; i < threads.length; ++i )
+ createRunningThread( threads[i] );
+
+ if ( isResumeOnStartup() )
+ {
+ setSuspended( false );
+ }
+ }
+
+ /**
+ * Installs all C/C++ breakpoints that currently exist in
+ * the breakpoint manager.
+ *
+ */
+ protected void initializeBreakpoints()
+ {
+ IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
+ manager.addBreakpointListener( this );
+ IBreakpoint[] bps = (IBreakpoint[])manager.getBreakpoints( CDebugModel.getPluginIdentifier() );
+ for ( int i = 0; i < bps.length; i++ )
+ {
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IDebugTarget#getProcess()
+ */
+ public IProcess getProcess()
+ {
+ return fProcess;
+ }
+
+ /**
+ * Sets the process associated with this debug target,
+ * possibly <code>null</code>. Set on creation.
+ *
+ * @param process the system process associated with the
+ * underlying CDI target, or <code>null</code> if no process is
+ * associated with this debug target (for example, a core dump debugging).
+ */
+ protected void setProcess( IProcess process )
+ {
+ fProcess = process;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IDebugTarget#getThreads()
+ */
+ public IThread[] getThreads()
+ {
+ List threads = getThreadList();
+ return (IThread[])threads.toArray( new IThread[threads.size()] );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IDebugTarget#hasThreads()
+ */
+ public boolean hasThreads() throws DebugException
+ {
+ return getThreadList().size() > 0;
+ }
+
+ /* (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 the name of this debug target
+ */
+ protected void setName( String name )
+ {
+ fName = name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IDebugTarget#supportsBreakpoint(IBreakpoint)
+ */
+ public boolean supportsBreakpoint( IBreakpoint breakpoint )
+ {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.ILaunchListener#launchRemoved(ILaunch)
+ */
+ public void launchRemoved( ILaunch launch )
+ {
+ if ( !isAvailable() )
+ {
+ return;
+ }
+ if ( launch.equals( getLaunch() ) )
+ {
+ // This target has been deregistered, but it hasn't successfully terminated.
+ // Update internal state to reflect that it is disconnected
+ disconnected();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.ILaunchListener#launchAdded(ILaunch)
+ */
+ public void launchAdded( ILaunch launch )
+ {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.ILaunchListener#launchChanged(ILaunch)
+ */
+ public void launchChanged( ILaunch launch )
+ {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ITerminate#canTerminate()
+ */
+ public boolean canTerminate()
+ {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ITerminate#isTerminated()
+ */
+ public boolean isTerminated()
+ {
+ return fTerminated;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ITerminate#terminate()
+ */
+ public void terminate() throws DebugException
+ {
+ }
+
+ /**
+ * Sets whether this debug target is terminated
+ *
+ * @param terminated <code>true</code> if this debug
+ * target is terminated, otherwise <code>false</code>
+ */
+ protected void setTerminated( boolean terminated )
+ {
+ fTerminated = terminated;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#canResume()
+ */
+ public boolean canResume()
+ {
+ return isSuspended() && isAvailable();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#canSuspend()
+ */
+ public boolean canSuspend()
+ {
+ if ( !isSuspended() && isAvailable() )
+ {
+ // only allow suspend if no threads are currently suspended
+ IThread[] threads = getThreads();
+ for ( int i = 0; i < threads.length; i++ )
+ {
+ if ( threads[i].isSuspended() )
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#isSuspended()
+ */
+ public boolean isSuspended()
+ {
+ return fSuspended;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#resume()
+ */
+ public void resume() throws DebugException
+ {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#suspend()
+ */
+ public void suspend() throws DebugException
+ {
+ if ( isSuspended() )
+ {
+ return;
+ }
+ try
+ {
+ setSuspended( true );
+ fireSuspendEvent( DebugEvent.CLIENT_REQUEST );
+ getCDITarget().suspend();
+ suspendThreads();
+ }
+ catch( CDIException e )
+ {
+ setSuspended( false );
+ fireResumeEvent( DebugEvent.CLIENT_REQUEST );
+ targetRequestFailed( MessageFormat.format( "{0} occurred suspending target.", new String[] { e.toString()} ), e );
+ }
+ }
+
+ /**
+ * Notifies threads that they have been suspended.
+ *
+ */
+ protected void suspendThreads()
+ {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.IBreakpointListener#breakpointAdded(IBreakpoint)
+ */
+ public void breakpointAdded( IBreakpoint breakpoint )
+ {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.IBreakpointListener#breakpointRemoved(IBreakpoint, IMarkerDelta)
+ */
+ public void breakpointRemoved( IBreakpoint breakpoint, IMarkerDelta delta )
+ {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.IBreakpointListener#breakpointChanged(IBreakpoint, IMarkerDelta)
+ */
+ public void breakpointChanged( IBreakpoint breakpoint, IMarkerDelta delta )
+ {
+ }
+
+ /* (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
+ {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IDisconnect#isDisconnected()
+ */
+ public boolean isDisconnected()
+ {
+ return fDisconnected;
+ }
+
+ /**
+ * Sets whether this debug target is disconnected
+ *
+ * @param disconnected <code>true</code> if this debug
+ * target is disconnected, otherwise <code>false</code>
+ */
+ protected void setDisconnected( boolean disconnected )
+ {
+ fDisconnected = disconnected;
+ }
+
+ /* (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
+ {
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.debug.core.model.IDebugElement#getLaunch()
+ */
+ public ILaunch getLaunch()
+ {
+ return fLaunch;
+ }
+
+ /**
+ * Sets the launch this target is contained in
+ *
+ * @param launch the launch this target is contained in
+ */
+ private void setLaunch( ILaunch launch )
+ {
+ fLaunch = launch;
+ }
+
+ /**
+ * Returns the list of threads contained in this debug target.
+ *
+ * @return list of threads
+ */
+ protected ArrayList getThreadList()
+ {
+ return fThreads;
+ }
+
+ /**
+ * Sets the list of threads contained in this debug target.
+ * Set to an empty collection on creation. Threads are
+ * added and removed as they start and end. On termination
+ * this collection is set to the immutable singleton empty list.
+ *
+ * @param threads empty list
+ */
+ private void setThreadList( ArrayList threads )
+ {
+ fThreads = threads;
+ }
+
+ private void setCDITarget( ICTarget cdiTarget )
+ {
+ fCDITarget = cdiTarget;
+ }
+
+ /* (non-Javadoc)
+ * @see IAdaptable#getAdapter(Class)
+ */
+ public Object getAdapter( Class adapter )
+ {
+ if ( adapter.equals( IDebugTarget.class ) )
+ return this;
+ if ( adapter.equals( ICTarget.class ) )
+ return fCDITarget;
+ return super.getAdapter( adapter );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.cdi.event.ICEventListener#handleDebugEvent(ICEvent)
+ */
+ public void handleDebugEvent( ICEvent event )
+ {
+ ICObject source = event.getSource();
+ if ( source.getCDITarget().equals( this ) )
+ {
+ if ( event instanceof ICCreatedEvent )
+ {
+ if ( source instanceof ICThread )
+ {
+ handleThreadCreatedEvent( (ICCreatedEvent)event );
+ }
+ }
+ else if ( event instanceof ICSuspendedEvent )
+ {
+ if ( source instanceof ICTarget )
+ {
+ handleSuspendedEvent( (ICSuspendedEvent)event );
+ }
+ }
+ else if ( event instanceof ICResumedEvent )
+ {
+ if ( source instanceof ICTarget )
+ {
+ handleResumedEvent( (ICResumedEvent)event );
+ }
+ }
+ else if ( event instanceof ICExitedEvent )
+ {
+ if ( source instanceof ICTarget )
+ {
+ handleExitedEvent( (ICExitedEvent)event );
+ }
+ }
+ else if ( event instanceof ICTerminatedEvent )
+ {
+ if ( source instanceof ICTarget )
+ {
+ handleTerminatedEvent( (ICTerminatedEvent)event );
+ }
+ else if ( source instanceof ICThread )
+ {
+ handleThreadTerminatedEvent( (ICTerminatedEvent)event );
+ }
+ }
+ else if ( event instanceof ICDisconnectedEvent )
+ {
+ if ( source instanceof ICTarget )
+ {
+ handleDisconnectedEvent( (ICDisconnectedEvent)event );
+ }
+ }
+ else if ( event instanceof ICChangedEvent )
+ {
+ if ( source instanceof ICTarget )
+ {
+ handleChangedEvent( (ICChangedEvent)event );
+ }
+ }
+ else if ( event instanceof ICLoadedEvent )
+ {
+ if ( source instanceof ICTarget )
+ {
+ handleLoadedEvent( (ICLoadedEvent)event );
+ }
+ }
+ else if ( event instanceof ICRestartedEvent )
+ {
+ if ( source instanceof ICTarget )
+ {
+ handleRestartedEvent( (ICRestartedEvent)event );
+ }
+ }
+ else if ( event instanceof ICSteppingEvent )
+ {
+ if ( source instanceof ICTarget )
+ {
+ handleSteppingEvent( (ICSteppingEvent)event );
+ }
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.IRestart#canRestart()
+ */
+ public boolean canRestart()
+ {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.IRestart#restart()
+ */
+ public void restart() throws DebugException
+ {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.IInstructionStep#canStepIntoInstruction()
+ */
+ public boolean canStepIntoInstruction()
+ {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.IInstructionStep#canStepOverInstruction()
+ */
+ public boolean canStepOverInstruction()
+ {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.IInstructionStep#stepIntoInstruction()
+ */
+ public void stepIntoInstruction() throws DebugException
+ {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.IInstructionStep#stepOverInstruction()
+ */
+ public void stepOverInstruction() throws DebugException
+ {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.IFormattedMemoryRetrieval#getFormattedMemoryBlock(long, int, int, int, int, char)
+ */
+ public IFormattedMemoryBlock getFormattedMemoryBlock( long startAddress,
+ int format,
+ int wordSize,
+ int numberOfRows,
+ int numberOfColumns,
+ char paddingChar ) throws DebugException
+ {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.IFormattedMemoryRetrieval#getFormattedMemoryBlock(long, int, int, int, int)
+ */
+ public IFormattedMemoryBlock getFormattedMemoryBlock( long startAddress,
+ int format,
+ int wordSize,
+ int numberOfRows,
+ int numberOfColumns ) throws DebugException
+ {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.IFormattedMemoryRetrieval#getSupportedFormats()
+ */
+ public int[] getSupportedFormats() throws DebugException
+ {
+ return null;
+ }
+
+ /**
+ * Returns whether this target is available to handle client
+ * requests.
+ *
+ * @return whether this target is available to handle client requests
+ */
+ public boolean isAvailable()
+ {
+ return false;
+ }
+
+ /**
+ * Sets whether this target is suspended.
+ *
+ * @param suspended whether this target is suspended
+ */
+ private void setSuspended( boolean suspended )
+ {
+ fSuspended = suspended;
+ }
+
+ /**
+ * Returns whether this target is in the process of terminating.
+ *
+ * @return whether this target is terminating
+ */
+ protected boolean isTerminating()
+ {
+ return fTerminating;
+ }
+
+ /**
+ * Sets whether this target is in the process of terminating.
+ *
+ * @param terminating whether this target is terminating
+ */
+ protected void setTerminating( boolean terminating )
+ {
+ fTerminating = terminating;
+ }
+
+ /**
+ * Updates the state of this target to be terminated,
+ * if not already terminated.
+ */
+ protected void terminated()
+ {
+ setTerminating( false );
+ if ( !isTerminated() )
+ {
+ setTerminated( true );
+ setDisconnected( true );
+ cleanup();
+ fireTerminateEvent();
+ }
+ }
+
+ /**
+ * Updates the state of this target for disconnection
+ * from the VM.
+ */
+ protected void disconnected()
+ {
+ if ( !isDisconnected() )
+ {
+ setDisconnected( true );
+ cleanup();
+ fireTerminateEvent();
+ }
+ }
+
+ /**
+ * Cleans up the internal state of this debug target as a result
+ * of a session ending.
+ *
+ */
+ protected void cleanup()
+ {
+ removeAllThreads();
+ getCDISession().getEventManager().removeEventListener( this );
+ DebugPlugin.getDefault().getBreakpointManager().removeBreakpointListener( this );
+ DebugPlugin.getDefault().getLaunchManager().removeLaunchListener( this );
+ removeAllBreakpoints();
+ }
+
+ /**
+ * Removes all threads from this target's collection
+ * of threads, firing a terminate event for each.
+ *
+ */
+ protected void removeAllThreads()
+ {
+ }
+
+ /**
+ * Removes all breakpoints from this target.
+ *
+ */
+ protected void removeAllBreakpoints()
+ {
+ }
+
+ /**
+ * Creates, adds and returns a thread for the given underlying
+ * CDI thread. A creation event is fired for the thread.
+ * Returns <code>null</code> if during the creation of the thread
+ * this target is set to the disconnected state.
+ *
+ * @param thread the underlying CDI thread
+ * @return model thread
+ */
+ protected CThread createThread( ICThread cdiThread )
+ {
+ CThread thread = null;
+ thread = new CThread( this, cdiThread );
+ if ( isDisconnected() )
+ {
+ return null;
+ }
+ getThreadList().add( thread );
+ thread.fireCreationEvent();
+ return thread;
+ }
+
+ /**
+ * Creates a new thread from the given CDI thread and initializes
+ * its state to "Running".
+ *
+ * @see CDebugTarget#createThread(ICThread)
+ */
+ protected CThread createRunningThread( ICThread cdiThread )
+ {
+ CThread thread = null;
+ thread = new CThread( this, cdiThread );
+ if ( isDisconnected() )
+ {
+ return null;
+ }
+ thread.setRunning( true );
+ getThreadList().add( thread );
+ thread.fireCreationEvent();
+ return thread;
+ }
+
+ /**
+ * Sets whether this target should be resumed on startup.
+ *
+ * @param resume whether this target should be resumed on startup
+ */
+ private void setResumeOnStartup( boolean resume )
+ {
+ fResumeOnStartup = resume;
+ }
+
+ /**
+ * Returns whether this target should be resumed on startup.
+ *
+ * @return whether this target should be resumed on startup
+ */
+ protected boolean isResumeOnStartup()
+ {
+ return fResumeOnStartup;
+ }
+
+ private void handleSuspendedEvent( ICSuspendedEvent event )
+ {
+ setSuspended( true );
+ ICSessionObject reason = event.getReason();
+ if ( reason instanceof ICEndSteppingRange )
+ {
+ handleEndSteppingRange( (ICEndSteppingRange)reason );
+ }
+ else if ( reason instanceof ICBreakpoint )
+ {
+ handleBreakpointHit( (ICBreakpoint)reason );
+ }
+ else if ( reason instanceof ICSignal )
+ {
+ handleSuspendedBySignal( (ICSignal)reason );
+ }
+ }
+
+ private void handleResumedEvent( ICResumedEvent event )
+ {
+ setSuspended( false );
+ fireResumeEvent( DebugEvent.UNSPECIFIED );
+ }
+
+ private void handleEndSteppingRange( ICEndSteppingRange endSteppingRange )
+ {
+ fireSuspendEvent( DebugEvent.UNSPECIFIED );
+ }
+
+ private void handleBreakpointHit( ICBreakpoint breakpoint )
+ {
+ fireSuspendEvent( DebugEvent.BREAKPOINT );
+ }
+
+ private void handleSuspendedBySignal( ICSignal signal )
+ {
+ fireSuspendEvent( DebugEvent.UNSPECIFIED );
+ }
+
+ private void handleExitedEvent( ICExitedEvent event )
+ {
+ fireChangeEvent( DebugEvent.STATE );
+ }
+
+ private void handleTerminatedEvent( ICTerminatedEvent event )
+ {
+ terminated();
+ }
+
+ private void handleDisconnectedEvent( ICDisconnectedEvent event )
+ {
+ disconnected();
+ }
+
+ private void handleChangedEvent( ICChangedEvent event )
+ {
+ }
+
+ private void handleLoadedEvent( ICLoadedEvent event )
+ {
+ }
+
+ private void handleRestartedEvent( ICRestartedEvent event )
+ {
+ }
+
+ private void handleSteppingEvent( ICSteppingEvent event )
+ {
+ }
+
+ private void handleThreadCreatedEvent( ICCreatedEvent event )
+ {
+ ICThread cdiThread = (ICThread)event.getSource();
+ CThread thread= findThread( cdiThread );
+ if ( thread == null )
+ {
+ createThread( cdiThread );
+ }
+ else
+ {
+ thread.disposeStackFrames();
+ thread.fireChangeEvent( DebugEvent.CONTENT );
+ }
+ }
+
+ private void handleThreadTerminatedEvent( ICTerminatedEvent event )
+ {
+ ICThread cdiThread = (ICThread)event.getSource();
+ CThread thread = findThread( cdiThread );
+ if ( thread != null)
+ {
+ getThreadList().remove( thread );
+ thread.terminated();
+ }
+ }
+
+ /**
+ * Finds and returns the model thread for the associated CDI thread,
+ * or <code>null</code> if not found.
+ *
+ * @param the underlying CDI thread
+ * @return the associated model thread
+ */
+ public CThread findThread( ICThread cdiThread )
+ {
+ List threads = getThreadList();
+ for ( int i = 0; i < threads.size(); i++ )
+ {
+ CThread t = (CThread)threads.get( i );
+ if ( t.getCDIThread().equals( cdiThread ) )
+ return t;
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.IState#getCurrentState()
+ */
+ public int getCurrentState()
+ {
+ return IState.UNKNOWN;
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CThread.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CThread.java
new file mode 100644
index 00000000000..3a8d0b99b8f
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CThread.java
@@ -0,0 +1,283 @@
+/*
+ *(c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ *
+ */
+
+package org.eclipse.cdt.debug.internal.core;
+
+import org.eclipse.cdt.debug.core.IState;
+import org.eclipse.cdt.debug.core.cdi.event.ICEvent;
+import org.eclipse.cdt.debug.core.cdi.event.ICEventListener;
+import org.eclipse.cdt.debug.core.cdi.model.ICThread;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IBreakpoint;
+import org.eclipse.debug.core.model.IStackFrame;
+import org.eclipse.debug.core.model.IThread;
+
+/**
+ *
+ * A thread in a C/C++ debug target.
+ *
+ * @since Aug 2, 2002
+ */
+public class CThread extends CDebugElement
+ implements IThread,
+ IState,
+ ICEventListener
+{
+ /**
+ * Underlying CDI target.
+ */
+ private ICThread fCDIThread;
+
+ /**
+ * Constructor for CThread.
+ * @param target
+ */
+ public CThread( CDebugTarget target, ICThread cdiThread )
+ {
+ super( target );
+ setCDIThread( cdiThread );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IThread#getStackFrames()
+ */
+ public IStackFrame[] getStackFrames() throws DebugException
+ {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IThread#hasStackFrames()
+ */
+ public boolean hasStackFrames() throws DebugException
+ {
+ return false;
+ }
+
+ /* (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#getTopStackFrame()
+ */
+ public IStackFrame getTopStackFrame() throws DebugException
+ {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IThread#getName()
+ */
+ public String getName() throws DebugException
+ {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IThread#getBreakpoints()
+ */
+ public IBreakpoint[] getBreakpoints()
+ {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.cdi.event.ICEventListener#handleDebugEvent(ICEvent)
+ */
+ public void handleDebugEvent( ICEvent event )
+ {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#canResume()
+ */
+ public boolean canResume()
+ {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#canSuspend()
+ */
+ public boolean canSuspend()
+ {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#isSuspended()
+ */
+ public boolean isSuspended()
+ {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#resume()
+ */
+ public void resume() throws DebugException
+ {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#suspend()
+ */
+ public void suspend() throws DebugException
+ {
+ }
+
+ /* (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 false;
+ }
+
+ /* (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 boolean isStepping()
+ {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStep#stepInto()
+ */
+ public void stepInto() throws DebugException
+ {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStep#stepOver()
+ */
+ public void stepOver() throws DebugException
+ {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStep#stepReturn()
+ */
+ public void stepReturn() throws DebugException
+ {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ITerminate#canTerminate()
+ */
+ public boolean canTerminate()
+ {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ITerminate#isTerminated()
+ */
+ public boolean isTerminated()
+ {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ITerminate#terminate()
+ */
+ public void terminate() throws DebugException
+ {
+ }
+
+ /**
+ * Sets the underlying CDI thread that this model object is
+ * a proxy to.
+ *
+ * @param thread the underlying CDI thread
+ */
+ protected void setCDIThread( ICThread cdiThread )
+ {
+ fCDIThread = cdiThread;
+ }
+
+ /**
+ * Returns the underlying CDI thread that this model object is
+ * a proxy to.
+ *
+ * @return the underlying CDI thread
+ */
+ protected ICThread getCDIThread()
+ {
+ return fCDIThread;
+ }
+
+ /**
+ * Sets whether this thread is currently executing.
+ *
+ * @param running whether this thread is executing
+ */
+ protected void setRunning( boolean running )
+ {
+ }
+
+ /**
+ * Sets whether this thread is terminated
+ *
+ * @param terminated whether this thread is terminated
+ */
+ protected void setTerminated( boolean terminated )
+ {
+ }
+
+ /**
+ * Disposes stack frames, to be completely re-computed on
+ * the next suspend event. This method should be called before
+ * this thread is resumed when stack frames are not to be re-used
+ * on the next suspend.
+ *
+ */
+ protected synchronized void disposeStackFrames()
+ {
+ }
+
+ /**
+ * Notification this thread has terminated - update state
+ * and fire a terminate event.
+ */
+ protected void terminated()
+ {
+ setTerminated( true );
+ setRunning( false );
+ fireTerminateEvent();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.IState#getCurrentState()
+ */
+ public int getCurrentState()
+ {
+ return IState.UNKNOWN;
+ }
+
+}

Back to the top