Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlvaro Sanchez-Leon2013-12-05 20:20:44 +0000
committerMarc Khouzam2014-01-15 14:06:21 +0000
commitf1639f8a859821bd2767f1ca7decc8eff3fa3d18 (patch)
tree695eefa3dff60bdeeebc2444e93a7bdadfdac723 /dsf-gdb
parent54a0b2dd06a48c470bd210a5b98296240218b888 (diff)
downloadorg.eclipse.cdt-f1639f8a859821bd2767f1ca7decc8eff3fa3d18.tar.gz
org.eclipse.cdt-f1639f8a859821bd2767f1ca7decc8eff3fa3d18.tar.xz
org.eclipse.cdt-f1639f8a859821bd2767f1ca7decc8eff3fa3d18.zip
Bug 250323 - Each memory context needs a different memory retrieval
Change-Id: I7874d84e5831aeb36be508a5b6b83c1623fcc5ab Signed-off-by: Alvaro Sanchez-Leon <alvsan09@gmail.com> Reviewed-on: https://git.eclipse.org/r/19453 Reviewed-by: Mikhail Khodjaiants <mikhailkhod@googlemail.com> IP-Clean: Mikhail Khodjaiants <mikhailkhod@googlemail.com> Tested-by: Mikhail Khodjaiants <mikhailkhod@googlemail.com> Tested-by: Hudson CI Reviewed-by: Marc Khouzam <marc.khouzam@ericsson.com> IP-Clean: Marc Khouzam <marc.khouzam@ericsson.com> Tested-by: Marc Khouzam <marc.khouzam@ericsson.com>
Diffstat (limited to 'dsf-gdb')
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/GdbPlugin.java17
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/memory/GdbMemoryBlockRetrieval.java42
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/memory/GdbMemoryBlockRetrievalManager.java43
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java40
4 files changed, 76 insertions, 66 deletions
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/GdbPlugin.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/GdbPlugin.java
index f58229748eb..32b3a8f4540 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/GdbPlugin.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/GdbPlugin.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2012 Wind River Systems and others.
+ * Copyright (c) 2006, 2013 Wind River Systems 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
@@ -9,6 +9,7 @@
* Wind River Systems - initial API and implementation
* Abeer Bagul (Tensilica) - Updated error message (Bug 339048)
* Jason Litton (Sage Electronic Engineering, LLC) - Added support for dynamic tracing option (Bug 379169)
+ * Alvaro Sanchez-Leon (Ericsson AB) - Each memory context needs a different MemoryRetrieval (Bug 250323)
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.internal;
@@ -17,8 +18,12 @@ import java.util.concurrent.RejectedExecutionException;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.Query;
+import org.eclipse.cdt.dsf.datamodel.IDMContext;
+import org.eclipse.cdt.dsf.debug.internal.provisional.model.MemoryBlockRetrievalFactory;
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch;
+import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugPlugin;
@@ -38,6 +43,8 @@ public class GdbPlugin extends Plugin {
private static BundleContext fgBundleContext;
+ private IAdapterFactory fMemoryRetrievalFactory = null;
+
/**
* The constructor
*/
@@ -55,6 +62,9 @@ public class GdbPlugin extends Plugin {
plugin = this;
new GdbDebugOptions(context);
+
+ fMemoryRetrievalFactory = new MemoryBlockRetrievalFactory();
+ Platform.getAdapterManager().registerAdapters(fMemoryRetrievalFactory, IDMContext.class);
}
/*
@@ -65,6 +75,11 @@ public class GdbPlugin extends Plugin {
public void stop(BundleContext context) throws Exception {
shutdownActiveLaunches();
plugin = null;
+
+ if (fMemoryRetrievalFactory != null) {
+ Platform.getAdapterManager().unregisterAdapters(fMemoryRetrievalFactory, IDMContext.class);
+ }
+
super.stop(context);
fgBundleContext = null;
}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/memory/GdbMemoryBlockRetrieval.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/memory/GdbMemoryBlockRetrieval.java
index 551923c5954..8fa44d5a422 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/memory/GdbMemoryBlockRetrieval.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/memory/GdbMemoryBlockRetrieval.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, Texas Instruments, Freescale Semiconductor and others.
+ * Copyright (c) 2010, 2013 Texas Instruments, Freescale Semiconductor 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
@@ -7,6 +7,7 @@
*
* Contributors:
* Texas Instruments, Freescale Semiconductor - initial API and implementation
+ * Alvaro Sanchez-Leon (Ericsson AB) - Each memory context needs a different MemoryRetrieval (Bug 250323)
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.internal.memory;
@@ -24,23 +25,16 @@ import org.eclipse.cdt.dsf.debug.model.DsfMemoryBlock;
import org.eclipse.cdt.dsf.debug.model.DsfMemoryBlockRetrieval;
import org.eclipse.cdt.dsf.debug.service.IMemory.IMemoryDMContext;
import org.eclipse.cdt.dsf.debug.service.IMemorySpaces;
-import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
-import org.eclipse.cdt.dsf.debug.service.IRunControl.IExitedDMEvent;
-import org.eclipse.cdt.dsf.debug.service.IRunControl.IStartedDMEvent;
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
-import org.eclipse.cdt.dsf.service.DsfServiceEventHandler;
import org.eclipse.cdt.dsf.service.DsfServices;
import org.eclipse.cdt.dsf.service.DsfSession;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.IMemoryBlockManager;
import org.eclipse.debug.core.model.IMemoryBlock;
import org.eclipse.debug.core.model.IMemoryBlockExtension;
import org.osgi.framework.BundleContext;
@@ -95,6 +89,7 @@ public class GdbMemoryBlockRetrieval extends DsfMemoryBlockRetrieval implements
GdbPlugin.PLUGIN_ID, DebugException.INTERNAL_ERROR,
"Error creating service filter.", e)); //$NON-NLS-1$
}
+
fMemorySpaceServiceTracker.open();
}
@@ -388,35 +383,4 @@ public class GdbMemoryBlockRetrieval extends DsfMemoryBlockRetrieval implements
}
return false;
}
-
- @DsfServiceEventHandler
- public void eventDispatched(IStartedDMEvent event) {
- if (event.getDMContext() instanceof IContainerDMContext) {
- IMemoryDMContext memoryDmc = DMContexts.getAncestorOfType(event.getDMContext(), IMemoryDMContext.class);
- if (memoryDmc != null) {
- initialize(memoryDmc);
- }
- }
- }
-
- @DsfServiceEventHandler
- public void eventDispatched(IExitedDMEvent event) {
- if (event.getDMContext() instanceof IContainerDMContext) {
- IMemoryDMContext memoryDmc = DMContexts.getAncestorOfType(event.getDMContext(), IMemoryDMContext.class);
- if (memoryDmc != null) {
- saveMemoryBlocks();
- Job removeJob = new Job("Removing memory blocks") { //$NON-NLS-1$
-
- @Override
- protected IStatus run( IProgressMonitor monitor ) {
- IMemoryBlockManager mbm = DebugPlugin.getDefault().getMemoryBlockManager();
- IMemoryBlock[] deletedMemoryBlocks = mbm.getMemoryBlocks(GdbMemoryBlockRetrieval.this);
- mbm.removeMemoryBlocks(deletedMemoryBlocks);
- return Status.OK_STATUS;
- }
- };
- removeJob.schedule();
- }
- }
- }
}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/memory/GdbMemoryBlockRetrievalManager.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/memory/GdbMemoryBlockRetrievalManager.java
new file mode 100644
index 00000000000..be5860366f8
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/memory/GdbMemoryBlockRetrievalManager.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Ericsson 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:
+ * Alvaro Sanchez-Leon (Ericsson AB) - Each memory context needs a different MemoryRetrieval (Bug 250323)
+ *******************************************************************************/
+package org.eclipse.cdt.dsf.gdb.internal.memory;
+
+import org.eclipse.cdt.dsf.debug.internal.provisional.model.MemoryBlockRetrievalManager;
+import org.eclipse.cdt.dsf.debug.model.DsfMemoryBlockRetrieval;
+import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
+import org.eclipse.cdt.dsf.service.DsfSession;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.model.IMemoryBlockRetrieval;
+
+public class GdbMemoryBlockRetrievalManager extends MemoryBlockRetrievalManager {
+
+ public GdbMemoryBlockRetrievalManager(String modelId, ILaunchConfiguration config, DsfSession session) {
+ super(modelId, config, session);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.dsf.debug.internal.provisional.model.MemoryBlockRetrievalManager#createMemoryBlockRetrieval(java.lang.String, org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.cdt.dsf.service.DsfSession)
+ */
+ @Override
+ protected IMemoryBlockRetrieval createMemoryBlockRetrieval(String model, ILaunchConfiguration config, DsfSession session) {
+ DsfMemoryBlockRetrieval memRetrieval = null;
+
+ try {
+ memRetrieval = new GdbMemoryBlockRetrieval(model, config, session);
+ } catch (DebugException e) {
+ GdbPlugin.getDefault().getLog().log(e.getStatus());
+ }
+
+ return memRetrieval;
+ }
+
+}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java
index 175d36cfd94..d64778f1150 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2012 Wind River Systems and others.
+ * Copyright (c) 2006, 2013 Wind River Systems 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
@@ -9,6 +9,7 @@
* Wind River Systems - initial API and implementation
* Marc Khouzam (Ericsson) - Fix NPE for partial launches (Bug 368597)
* Marc Khouzam (Ericsson) - Create the gdb process through the process factory (Bug 210366)
+ * Alvaro Sanchez-Leon (Ericsson AB) - Each memory context needs a different MemoryRetrieval (Bug 250323)
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.launching;
@@ -32,13 +33,13 @@ import org.eclipse.cdt.dsf.concurrent.Sequence;
import org.eclipse.cdt.dsf.concurrent.Sequence.Step;
import org.eclipse.cdt.dsf.concurrent.ThreadSafe;
import org.eclipse.cdt.dsf.concurrent.ThreadSafeAndProhibitedFromDsfExecutor;
+import org.eclipse.cdt.dsf.debug.internal.provisional.model.IMemoryBlockRetrievalManager;
import org.eclipse.cdt.dsf.debug.model.DsfLaunch;
-import org.eclipse.cdt.dsf.debug.model.DsfMemoryBlockRetrieval;
import org.eclipse.cdt.dsf.debug.service.IDsfDebugServicesFactory;
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlShutdownDMEvent;
import org.eclipse.cdt.dsf.gdb.IGdbDebugConstants;
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
-import org.eclipse.cdt.dsf.gdb.internal.memory.GdbMemoryBlockRetrieval;
+import org.eclipse.cdt.dsf.gdb.internal.memory.GdbMemoryBlockRetrievalManager;
import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl;
import org.eclipse.cdt.dsf.mi.service.command.AbstractCLIProcess;
import org.eclipse.cdt.dsf.service.DsfServiceEventHandler;
@@ -49,14 +50,12 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Platform;
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.ILaunchConfiguration;
import org.eclipse.debug.core.commands.ITerminateHandler;
import org.eclipse.debug.core.model.IDisconnect;
-import org.eclipse.debug.core.model.IMemoryBlockRetrieval;
import org.eclipse.debug.core.model.ISourceLocator;
import org.eclipse.debug.core.model.ITerminate;
@@ -72,8 +71,7 @@ public class GdbLaunch extends DsfLaunch
private DsfServicesTracker fTracker;
private boolean fInitialized = false;
private boolean fShutDown = false;
-
- private DsfMemoryBlockRetrieval fMemRetrieval;
+ private IMemoryBlockRetrievalManager fMemRetrievalManager;
private IDsfDebugServicesFactory fServiceFactory;
public GdbLaunch(ILaunchConfiguration launchConfiguration, String mode, ISourceLocator locator) {
@@ -125,15 +123,15 @@ public class GdbLaunch extends DsfLaunch
public void initializeControl()
throws CoreException
{
- // Create a memory retrieval and register it with the session
+ // Create a memory retrieval manager and register it with the session
+ // To maintain a mapping of memory contexts to the corresponding memory retrieval in this session
try {
fExecutor.submit( new Callable<Object>() {
@Override
public Object call() throws CoreException {
- fMemRetrieval = new GdbMemoryBlockRetrieval(
- GdbLaunchDelegate.GDB_DEBUG_MODEL_ID, getLaunchConfiguration(), fSession);
- fSession.registerModelAdapter(IMemoryBlockRetrieval.class, fMemRetrieval);
- fSession.addServiceEventListener(fMemRetrieval, null);
+ fMemRetrievalManager = new GdbMemoryBlockRetrievalManager(GdbLaunchDelegate.GDB_DEBUG_MODEL_ID, getLaunchConfiguration(), fSession);
+ fSession.registerModelAdapter(IMemoryBlockRetrievalManager.class, fMemRetrievalManager);
+ fSession.addServiceEventListener(fMemRetrievalManager, null);
return null;
}
}).get();
@@ -244,8 +242,10 @@ public class GdbLaunch extends DsfLaunch
new RequestMonitor(fSession.getExecutor(), rm) {
@Override
public void handleCompleted() {
- if (fMemRetrieval != null)
- fSession.removeServiceEventListener(fMemRetrieval);
+ if (fMemRetrievalManager != null) {
+ fSession.removeServiceEventListener(fMemRetrievalManager);
+ fMemRetrievalManager.dispose();
+ }
fSession.removeServiceEventListener(GdbLaunch.this);
if (!isSuccess()) {
@@ -256,18 +256,6 @@ public class GdbLaunch extends DsfLaunch
fTracker.dispose();
fTracker = null;
DsfSession.endSession(fSession);
-
- // The memory retrieval can be null if the launch was aborted
- // in the middle. We saw this when doing an automatic remote
- // launch with an invalid gdbserver
- // Bug 368597
- if (fMemRetrieval != null) {
-
- // Fire a terminate event for the memory retrieval object so
- // that the hosting memory views can clean up. See 255120 and
- // 283586
- DebugPlugin.getDefault().fireDebugEventSet( new DebugEvent[] { new DebugEvent(fMemRetrieval, DebugEvent.TERMINATE) });
- }
// 'fireTerminate()' removes this launch from the list of 'DebugEvent'
// listeners. The launch may not be terminated at this point: the inferior

Back to the top