Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRandy Rohrbach2013-01-14 22:19:44 +0000
committerRandy Rohrbach2013-01-14 22:27:05 +0000
commitdc114aff98849341abb32e858cb23018ea9ebd48 (patch)
treef614f6c5788911e8cf51f39dedd469ed53ace8d9
parent997f7b660705a717b99f3e97b6bb76d28be76c6c (diff)
downloadorg.eclipse.cdt-dc114aff98849341abb32e858cb23018ea9ebd48.tar.gz
org.eclipse.cdt-dc114aff98849341abb32e858cb23018ea9ebd48.tar.xz
org.eclipse.cdt-dc114aff98849341abb32e858cb23018ea9ebd48.zip
Bug 398136 - ILaunchable is confusing
Bug 398137 - Exporters/Importers should be filterable based on the address size they support
-rw-r--r--debug/org.eclipse.cdt.debug.ui/plugin.xml6
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/InvalidLaunchableAdapterFactory.java88
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/LaunchMessages.properties3
-rw-r--r--memory/org.eclipse.cdt.debug.ui.memory.transport/plugin.xml24
-rw-r--r--memory/org.eclipse.cdt.debug.ui.memory.transport/schema/MemoryTransport.exsd14
-rw-r--r--memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/ExportMemoryDialog.java32
-rw-r--r--memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/ImportMemoryDialog.java25
-rw-r--r--memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/PlainTextExporter.java15
8 files changed, 191 insertions, 16 deletions
diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml
index fa6769bbf67..0188aa81f49 100644
--- a/debug/org.eclipse.cdt.debug.ui/plugin.xml
+++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml
@@ -128,17 +128,17 @@
<!-- Adapters for contextual launch -->
<extension point="org.eclipse.core.runtime.adapters">
<factory
- class=""
+ class="org.eclipse.cdt.debug.internal.ui.launch.InvalidLaunchableAdapterFactory"
adaptableType="org.eclipse.cdt.core.model.IBinary">
<adapter type="org.eclipse.debug.ui.actions.ILaunchable"/>
</factory>
<factory
- class=""
+ class="org.eclipse.cdt.debug.internal.ui.launch.InvalidLaunchableAdapterFactory"
adaptableType="org.eclipse.core.resources.IResource">
<adapter type="org.eclipse.debug.ui.actions.ILaunchable"/>
</factory>
<factory
- class=""
+ class="org.eclipse.cdt.debug.internal.ui.launch.InvalidLaunchableAdapterFactory"
adaptableType="org.eclipse.cdt.core.model.ICProject">
<adapter type="org.eclipse.debug.ui.actions.ILaunchable"/>
</factory>
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/InvalidLaunchableAdapterFactory.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/InvalidLaunchableAdapterFactory.java
new file mode 100644
index 00000000000..10ff510a19f
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/InvalidLaunchableAdapterFactory.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Wind River Systems, Inc. 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:
+ * Wind River Systems - initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.debug.internal.ui.launch;
+
+import java.util.ArrayList;
+
+import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.ui.actions.ILaunchable;
+
+/**
+ * This is an invalid Adapter factory which insures that there are no false
+ * usages of this class when defining ILaunchable contexts. Please reference
+ * the ILaunchable interface and Bugzilla : 396822.
+ */
+public class InvalidLaunchableAdapterFactory implements IAdapterFactory {
+
+ private static final Class<?>[] TYPES = { ILaunchable.class };
+
+ private static ArrayList<String> currentTraces = new ArrayList<String>();
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
+ */
+ @Override
+ @SuppressWarnings("rawtypes")
+ public Object getAdapter(Object adaptableObject, Class adapterType) {
+ /*
+ * Calculate the trace to see if we already have seen this one. We only
+ * want to report new instances of the violation.
+ */
+ String trace = getStackTrace();
+
+ if ( ! currentTraces.contains( trace ) ) {
+ /*
+ * Note we have seen this one for the first time.
+ */
+ currentTraces.add( trace );
+
+ /*
+ * Generate a message for this in the log file.
+ */
+ String msg = LaunchMessages.getString("Launch.ILaunchable.Interface.Error"); //$NON-NLS-1$
+
+ CDebugUIPlugin.log( new Status( IStatus.INFO, CDebugUIPlugin.PLUGIN_ID, 0, msg, new Throwable( "" ) ) ); //$NON-NLS-1$
+ }
+
+ /*
+ * We do not actually provide an adapter factory for this.
+ */
+ return null;
+ }
+
+ /*
+ * Constructs the stack trace for comparison to see if we have seen this exact trace before.
+ * We only report each unique instance once.
+ */
+ private String getStackTrace() {
+ String trace = ""; //$NON-NLS-1$
+ for (StackTraceElement elem : new Throwable().getStackTrace()) {
+ trace += elem.getClassName() + elem.getMethodName() + elem.getFileName() + elem.getLineNumber();
+ }
+ return trace;
+ }
+
+ /*
+ * Indicates that we are adapting ILaunchable.
+ *
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
+ */
+ @Override
+ @SuppressWarnings("rawtypes")
+ public Class[] getAdapterList() {
+ return TYPES;
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/LaunchMessages.properties b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/LaunchMessages.properties
index 65d1b918bef..d83a53bd822 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/LaunchMessages.properties
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/LaunchMessages.properties
@@ -32,3 +32,6 @@ CApplicationLaunchShortcut.Launch_failed_no_project_selected=Launch failed no pr
Launch.common.BinariesColon=Binaries:
Launch.common.QualifierColon=Qualifier:
+
+Launch.ILaunchable.Interface.Error=An attempt to instantiate an adapter factory for ILaunchable. By API specification this is not allowed. Use hasAdapter() to determine existense.
+
diff --git a/memory/org.eclipse.cdt.debug.ui.memory.transport/plugin.xml b/memory/org.eclipse.cdt.debug.ui.memory.transport/plugin.xml
index 10e7c942abb..abb815d87b5 100644
--- a/memory/org.eclipse.cdt.debug.ui.memory.transport/plugin.xml
+++ b/memory/org.eclipse.cdt.debug.ui.memory.transport/plugin.xml
@@ -8,17 +8,6 @@
point="org.eclipse.cdt.debug.ui.memory.transport.memoryTransport">
<importer
- name="%importer.name.0"
- id="org.eclipse.cdt.debug.ui.memory.transport.SRecordImporter"
- class="org.eclipse.cdt.debug.ui.memory.transport.SRecordImporter">
- </importer>
- <exporter
- name="%exporter.name.0"
- id="org.eclipse.cdt.debug.ui.memory.transport.SRecordExporter"
- class="org.eclipse.cdt.debug.ui.memory.transport.SRecordExporter">
- </exporter>
-
- <importer
name="%importer.name.1"
id="org.eclipse.cdt.debug.ui.memory.transport.PlainTextImporter"
class="org.eclipse.cdt.debug.ui.memory.transport.PlainTextImporter">
@@ -40,6 +29,19 @@
class="org.eclipse.cdt.debug.ui.memory.transport.RAWBinaryExporter">
</exporter>
+ <importer
+ name="%importer.name.0"
+ id="org.eclipse.cdt.debug.ui.memory.transport.SRecordImporter"
+ maxmemorysize="32"
+ class="org.eclipse.cdt.debug.ui.memory.transport.SRecordImporter">
+ </importer>
+ <exporter
+ name="%exporter.name.0"
+ id="org.eclipse.cdt.debug.ui.memory.transport.SRecordExporter"
+ maxmemorysize="32"
+ class="org.eclipse.cdt.debug.ui.memory.transport.SRecordExporter">
+ </exporter>
+
</extension>
<extension point="org.eclipse.ui.viewActions">
diff --git a/memory/org.eclipse.cdt.debug.ui.memory.transport/schema/MemoryTransport.exsd b/memory/org.eclipse.cdt.debug.ui.memory.transport/schema/MemoryTransport.exsd
index cf963b11f26..ec7304db8f9 100644
--- a/memory/org.eclipse.cdt.debug.ui.memory.transport/schema/MemoryTransport.exsd
+++ b/memory/org.eclipse.cdt.debug.ui.memory.transport/schema/MemoryTransport.exsd
@@ -77,6 +77,13 @@
</appInfo>
</annotation>
</attribute>
+ <attribute name="maxmemorysize" type="string">
+ <annotation>
+ <documentation>
+ Maximum size of the addressable memory this exporter can support in bits.
+ </documentation>
+ </annotation>
+ </attribute>
</complexType>
</element>
@@ -109,6 +116,13 @@
</appInfo>
</annotation>
</attribute>
+ <attribute name="maxmemorysize" type="string">
+ <annotation>
+ <documentation>
+ Maximum size of the addressable memory this importer can support in bits.
+ </documentation>
+ </annotation>
+ </attribute>
</complexType>
</element>
diff --git a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/ExportMemoryDialog.java b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/ExportMemoryDialog.java
index f279b04e2de..af4f639a596 100644
--- a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/ExportMemoryDialog.java
+++ b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/ExportMemoryDialog.java
@@ -23,6 +23,7 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IMemoryBlock;
+import org.eclipse.debug.core.model.IMemoryBlockExtension;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.swt.SWT;
@@ -180,19 +181,46 @@ public class ExportMemoryDialog extends SelectionDialog
registry.getExtensionPoint("org.eclipse.cdt.debug.ui.memory.transport.memoryTransport"); //$NON-NLS-1$
IConfigurationElement points[] =
extensionPoint.getConfigurationElements();
-
+
for (int i = 0; i < points.length; i++)
{
IConfigurationElement element = points[i];
if("exporter".equals(element.getName())) //$NON-NLS-1$
{
+ String maxSizeStr = element.getAttribute("maxmemorysize");
+ if ( maxSizeStr != null ) {
+ if ( fMemoryBlock instanceof IMemoryBlockExtension ) {
+ IMemoryBlockExtension memBlock = (IMemoryBlockExtension) fMemoryBlock;
+ try {
+ BigInteger endAddress = memBlock.getBigBaseAddress();
+ BigInteger length = memBlock.getBigLength();
+ if ( length != null && ! length.equals(new BigInteger("-1",10) ) ) {
+ endAddress = endAddress.add( length ) ;
+ }
+ int maxAddressSizeInBits = endAddress.bitLength();
+ int maxSupportedAddressSizeInBits = Integer.decode(maxSizeStr);
+ if ( maxAddressSizeInBits > maxSupportedAddressSizeInBits ) {
+ continue;
+ }
+ } catch (DebugException e1) {
+ continue;
+ }
+ }
+ else {
+ int maxSupportedAddressSizeInBits = Integer.decode(maxSizeStr);
+ if ( maxSupportedAddressSizeInBits < 32 ) {
+ continue;
+ }
+ }
+ }
+
try
{
exporters.addElement((IMemoryExporter) element.createExecutableExtension("class")); //$NON-NLS-1$
}
catch(Exception e) {
MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
- DebugException.INTERNAL_ERROR, "Failure", e)); //$NON-NLS-1$
+ DebugException.INTERNAL_ERROR, "Failure", e)); //$NON-NLS-1$
}
}
}
diff --git a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/ImportMemoryDialog.java b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/ImportMemoryDialog.java
index 32d12aec9ce..4d91238617e 100644
--- a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/ImportMemoryDialog.java
+++ b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/ImportMemoryDialog.java
@@ -25,6 +25,7 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IMemoryBlock;
+import org.eclipse.debug.core.model.IMemoryBlockExtension;
import org.eclipse.debug.ui.memory.IMemoryRendering;
import org.eclipse.debug.ui.memory.IMemoryRenderingContainer;
import org.eclipse.debug.ui.memory.IMemoryRenderingSite;
@@ -219,6 +220,30 @@ public class ImportMemoryDialog extends SelectionDialog
IConfigurationElement element = points[i];
if("importer".equals(element.getName())) //$NON-NLS-1$
{
+ String maxSizeStr = element.getAttribute("maxmemorysize");
+ if ( maxSizeStr != null ) {
+ if ( fMemoryBlock instanceof IMemoryBlockExtension ) {
+ IMemoryBlockExtension memBlock = (IMemoryBlockExtension) fMemoryBlock;
+ try {
+ int maxAddressSizeInBits = memBlock.getAddressSize() * 8;
+ int maxSupportedAddressSizeInBits = Integer.decode(maxSizeStr);
+ if ( maxAddressSizeInBits > maxSupportedAddressSizeInBits ) {
+ continue;
+ }
+ } catch (DebugException e1) {
+ continue;
+ }
+ }
+ else {
+ int maxSupportedAddressSizeInBits = Integer.decode(maxSizeStr);
+ if ( maxSupportedAddressSizeInBits < 32 ) {
+ continue;
+ }
+ }
+ }
+
+
+
try
{
importers.addElement(element.createExecutableExtension("class")); //$NON-NLS-1$
diff --git a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/PlainTextExporter.java b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/PlainTextExporter.java
index 2ad02b2260c..d5698f91bb1 100644
--- a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/PlainTextExporter.java
+++ b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/PlainTextExporter.java
@@ -280,6 +280,21 @@ public class PlainTextExporter implements IMemoryExporter {
composite.pack();
+ /*
+ * We need to perform a validation. If we do it immediately we will get an exception
+ * because things are not totally setup. So we schedule an immediate running of the
+ * validation. For a very brief time the view logically may show a state which does
+ * not reflect the true state of affairs. But the validate immediately corrects the
+ * info. In practice the user never sees the invalid state displayed, because of the
+ * speed of the draw of the dialog.
+ */
+ Display.getDefault().asyncExec(new Runnable(){
+ public void run()
+ {
+ validate();
+ }
+ });
+
return composite;
}

Back to the top