mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Update GdbMemoryBlockRetrieval and DsfMemoryBlockRetrieval to fix
warnings. Change-Id: I57a352b92b46f1e381185a72e41d534bc4f3ca45 Signed-off-by: Marc Khouzam <marc.khouzam@ericsson.com> Reviewed-on: https://git.eclipse.org/r/22582 Reviewed-by: Alvaro Sanchez-Leon <alvsan09@gmail.com>
This commit is contained in:
parent
37166d6194
commit
d786838a0a
4 changed files with 37 additions and 33 deletions
|
@ -142,7 +142,7 @@ public class GdbMemoryBlock extends DsfMemoryBlock implements IMemorySpaceAwareM
|
||||||
// we need to create an enhanced context
|
// we need to create an enhanced context
|
||||||
IMemoryDMContext context = null;
|
IMemoryDMContext context = null;
|
||||||
if (fMemorySpaceID != null) {
|
if (fMemorySpaceID != null) {
|
||||||
IMemorySpaces memoryService = (IMemorySpaces) retrieval.getMemorySpaceServiceTracker().getService();
|
IMemorySpaces memoryService = retrieval.getMemorySpaceServiceTracker().getService();
|
||||||
if (memoryService != null) {
|
if (memoryService != null) {
|
||||||
context = new MemorySpaceDMContext(memoryService.getSession().getId(), fMemorySpaceID, getContext());
|
context = new MemorySpaceDMContext(memoryService.getSession().getId(), fMemorySpaceID, getContext());
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,7 @@ public class GdbMemoryBlock extends DsfMemoryBlock implements IMemorySpaceAwareM
|
||||||
context = getContext();
|
context = getContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
IMemory memoryService = (IMemory) retrieval.getServiceTracker().getService();
|
IMemory memoryService = retrieval.getServiceTracker().getService();
|
||||||
if (memoryService != null) {
|
if (memoryService != null) {
|
||||||
// Go for it
|
// Go for it
|
||||||
memoryService.getMemory(
|
memoryService.getMemory(
|
||||||
|
@ -217,7 +217,7 @@ public class GdbMemoryBlock extends DsfMemoryBlock implements IMemorySpaceAwareM
|
||||||
// we need to create an enhanced context
|
// we need to create an enhanced context
|
||||||
IMemoryDMContext context = null;
|
IMemoryDMContext context = null;
|
||||||
if (fMemorySpaceID != null) {
|
if (fMemorySpaceID != null) {
|
||||||
IMemorySpaces memoryService = (IMemorySpaces) retrieval.getMemorySpaceServiceTracker().getService();
|
IMemorySpaces memoryService = retrieval.getMemorySpaceServiceTracker().getService();
|
||||||
if (memoryService != null) {
|
if (memoryService != null) {
|
||||||
context = new MemorySpaceDMContext(memoryService.getSession().getId(), fMemorySpaceID, getContext());
|
context = new MemorySpaceDMContext(memoryService.getSession().getId(), fMemorySpaceID, getContext());
|
||||||
}
|
}
|
||||||
|
@ -230,7 +230,7 @@ public class GdbMemoryBlock extends DsfMemoryBlock implements IMemorySpaceAwareM
|
||||||
else {
|
else {
|
||||||
context = getContext();
|
context = getContext();
|
||||||
}
|
}
|
||||||
IMemory memoryService = (IMemory) retrieval.getServiceTracker().getService();
|
IMemory memoryService = retrieval.getServiceTracker().getService();
|
||||||
if (memoryService != null) {
|
if (memoryService != null) {
|
||||||
// Go for it
|
// Go for it
|
||||||
memoryService.setMemory(
|
memoryService.setMemory(
|
||||||
|
@ -285,7 +285,7 @@ public class GdbMemoryBlock extends DsfMemoryBlock implements IMemorySpaceAwareM
|
||||||
GdbMemoryBlockRetrieval retrieval = (GdbMemoryBlockRetrieval)getMemoryBlockRetrieval();
|
GdbMemoryBlockRetrieval retrieval = (GdbMemoryBlockRetrieval)getMemoryBlockRetrieval();
|
||||||
IMemoryDMContext context = null;
|
IMemoryDMContext context = null;
|
||||||
if (fMemorySpaceID != null) {
|
if (fMemorySpaceID != null) {
|
||||||
IMemorySpaces memorySpacesService = (IMemorySpaces) retrieval.getMemorySpaceServiceTracker().getService();
|
IMemorySpaces memorySpacesService = retrieval.getMemorySpaceServiceTracker().getService();
|
||||||
if (memorySpacesService != null) {
|
if (memorySpacesService != null) {
|
||||||
context = new MemorySpaceDMContext(memorySpacesService.getSession().getId(), fMemorySpaceID, getContext());
|
context = new MemorySpaceDMContext(memorySpacesService.getSession().getId(), fMemorySpaceID, getContext());
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,11 +15,12 @@ package org.eclipse.cdt.dsf.gdb.internal.memory;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.RejectedExecutionException;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.model.provisional.IMemorySpaceAwareMemoryBlock;
|
import org.eclipse.cdt.debug.core.model.provisional.IMemorySpaceAwareMemoryBlock;
|
||||||
import org.eclipse.cdt.debug.core.model.provisional.IMemorySpaceAwareMemoryBlockRetrieval;
|
import org.eclipse.cdt.debug.core.model.provisional.IMemorySpaceAwareMemoryBlockRetrieval;
|
||||||
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
||||||
import org.eclipse.cdt.dsf.concurrent.Query;
|
import org.eclipse.cdt.dsf.concurrent.DsfRunnable;
|
||||||
import org.eclipse.cdt.dsf.datamodel.DMContexts;
|
import org.eclipse.cdt.dsf.datamodel.DMContexts;
|
||||||
import org.eclipse.cdt.dsf.datamodel.IDMContext;
|
import org.eclipse.cdt.dsf.datamodel.IDMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.model.DsfMemoryBlock;
|
import org.eclipse.cdt.dsf.debug.model.DsfMemoryBlock;
|
||||||
|
@ -58,7 +59,7 @@ import org.w3c.dom.NodeList;
|
||||||
public class GdbMemoryBlockRetrieval extends DsfMemoryBlockRetrieval implements
|
public class GdbMemoryBlockRetrieval extends DsfMemoryBlockRetrieval implements
|
||||||
IMemorySpaceAwareMemoryBlockRetrieval {
|
IMemorySpaceAwareMemoryBlockRetrieval {
|
||||||
|
|
||||||
private final ServiceTracker fMemorySpaceServiceTracker;
|
private final ServiceTracker<IMemorySpaces, IMemorySpaces> fMemorySpaceServiceTracker;
|
||||||
|
|
||||||
// No need to use the constants in our base class. Serializing and
|
// No need to use the constants in our base class. Serializing and
|
||||||
// recreating the blocks is done entirely by us
|
// recreating the blocks is done entirely by us
|
||||||
|
@ -85,7 +86,7 @@ public class GdbMemoryBlockRetrieval extends DsfMemoryBlockRetrieval implements
|
||||||
// Create a tracker for the memory spaces service
|
// Create a tracker for the memory spaces service
|
||||||
String filter = DsfServices.createServiceFilter(IMemorySpaces.class, session.getId());
|
String filter = DsfServices.createServiceFilter(IMemorySpaces.class, session.getId());
|
||||||
try {
|
try {
|
||||||
fMemorySpaceServiceTracker = new ServiceTracker(
|
fMemorySpaceServiceTracker = new ServiceTracker<>(
|
||||||
bundle, bundle.createFilter(filter), null);
|
bundle, bundle.createFilter(filter), null);
|
||||||
} catch (InvalidSyntaxException e) {
|
} catch (InvalidSyntaxException e) {
|
||||||
throw new DebugException(new Status(IStatus.ERROR,
|
throw new DebugException(new Status(IStatus.ERROR,
|
||||||
|
@ -193,18 +194,19 @@ public class GdbMemoryBlockRetrieval extends DsfMemoryBlockRetrieval implements
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void getMemorySpaces(final Object context, final GetMemorySpacesRequest request) {
|
public void getMemorySpaces(final Object context, final GetMemorySpacesRequest request) {
|
||||||
Query<String[]> query = new Query<String[]>() {
|
try {
|
||||||
|
getExecutor().execute(new DsfRunnable() {
|
||||||
@Override
|
@Override
|
||||||
protected void execute(final DataRequestMonitor<String[]> drm) {
|
public void run() {
|
||||||
IDMContext dmc = null;
|
IDMContext dmc = null;
|
||||||
if (context instanceof IAdaptable) {
|
if (context instanceof IAdaptable) {
|
||||||
dmc = (IDMContext)((IAdaptable)context).getAdapter(IDMContext.class);
|
dmc = (IDMContext)((IAdaptable)context).getAdapter(IDMContext.class);
|
||||||
if (dmc != null) {
|
if (dmc != null) {
|
||||||
IMemorySpaces service = (IMemorySpaces)fMemorySpaceServiceTracker.getService();
|
IMemorySpaces service = fMemorySpaceServiceTracker.getService();
|
||||||
if (service != null) {
|
if (service != null) {
|
||||||
service.getMemorySpaces(
|
service.getMemorySpaces(
|
||||||
dmc,
|
dmc,
|
||||||
new DataRequestMonitor<String[]>(getExecutor(), drm) {
|
new DataRequestMonitor<String[]>(getExecutor(), null) {
|
||||||
@Override
|
@Override
|
||||||
protected void handleCompleted() {
|
protected void handleCompleted() {
|
||||||
// Store the result
|
// Store the result
|
||||||
|
@ -215,20 +217,22 @@ public class GdbMemoryBlockRetrieval extends DsfMemoryBlockRetrieval implements
|
||||||
request.setStatus(getStatus());
|
request.setStatus(getStatus());
|
||||||
}
|
}
|
||||||
request.done();
|
request.done();
|
||||||
drm.done(); // don't bother with status; we don't check it below
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
return;
|
||||||
else {
|
|
||||||
request.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, DebugException.INTERNAL_ERROR, Messages.Err_MemoryServiceNotAvailable, null));
|
|
||||||
request.done();
|
|
||||||
drm.done();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we get here, something didn't work as expected
|
||||||
|
request.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, DebugException.INTERNAL_ERROR, "Unable to get memory spaces", null)); //$NON-NLS-1$
|
||||||
|
request.done();
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
getExecutor().execute(query);
|
} catch (RejectedExecutionException e) {
|
||||||
|
request.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, DebugException.INTERNAL_ERROR, "Unable to get memory spaces", null)); //$NON-NLS-1$
|
||||||
|
request.done();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -237,7 +241,7 @@ public class GdbMemoryBlockRetrieval extends DsfMemoryBlockRetrieval implements
|
||||||
@Override
|
@Override
|
||||||
public String encodeAddress(String expression, String memorySpaceID) {
|
public String encodeAddress(String expression, String memorySpaceID) {
|
||||||
String result = null;
|
String result = null;
|
||||||
IMemorySpaces service = (IMemorySpaces)fMemorySpaceServiceTracker.getService();
|
IMemorySpaces service = fMemorySpaceServiceTracker.getService();
|
||||||
if (service != null) {
|
if (service != null) {
|
||||||
// the service can tell us to use our default encoding by returning null
|
// the service can tell us to use our default encoding by returning null
|
||||||
result = service.encodeAddress(expression, memorySpaceID);
|
result = service.encodeAddress(expression, memorySpaceID);
|
||||||
|
@ -254,7 +258,7 @@ public class GdbMemoryBlockRetrieval extends DsfMemoryBlockRetrieval implements
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public DecodeResult decodeAddress(String str) throws CoreException {
|
public DecodeResult decodeAddress(String str) throws CoreException {
|
||||||
IMemorySpaces service = (IMemorySpaces)fMemorySpaceServiceTracker.getService();
|
IMemorySpaces service = fMemorySpaceServiceTracker.getService();
|
||||||
if (service != null) {
|
if (service != null) {
|
||||||
final IMemorySpaces.DecodeResult result = service.decodeAddress(str);
|
final IMemorySpaces.DecodeResult result = service.decodeAddress(str);
|
||||||
if (result != null) { // service can return null to tell use to use default decoding
|
if (result != null) { // service can return null to tell use to use default decoding
|
||||||
|
@ -284,7 +288,7 @@ public class GdbMemoryBlockRetrieval extends DsfMemoryBlockRetrieval implements
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ServiceTracker getMemorySpaceServiceTracker() {
|
ServiceTracker<IMemorySpaces, IMemorySpaces> getMemorySpaceServiceTracker() {
|
||||||
return fMemorySpaceServiceTracker;
|
return fMemorySpaceServiceTracker;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,7 +384,7 @@ public class GdbMemoryBlockRetrieval extends DsfMemoryBlockRetrieval implements
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean creatingBlockRequiresMemorySpaceID() {
|
public boolean creatingBlockRequiresMemorySpaceID() {
|
||||||
IMemorySpaces service = (IMemorySpaces)fMemorySpaceServiceTracker.getService();
|
IMemorySpaces service = fMemorySpaceServiceTracker.getService();
|
||||||
if (service != null) {
|
if (service != null) {
|
||||||
return service.creatingBlockRequiresMemorySpaceID();
|
return service.creatingBlockRequiresMemorySpaceID();
|
||||||
}
|
}
|
||||||
|
@ -402,7 +406,7 @@ public class GdbMemoryBlockRetrieval extends DsfMemoryBlockRetrieval implements
|
||||||
private IMemoryDMContext resolveMemSpaceContext(IMemoryDMContext aContext, String aMemorySpaceID) {
|
private IMemoryDMContext resolveMemSpaceContext(IMemoryDMContext aContext, String aMemorySpaceID) {
|
||||||
IMemoryDMContext context = aContext;
|
IMemoryDMContext context = aContext;
|
||||||
if (aMemorySpaceID != null && aMemorySpaceID.length() > 0) {
|
if (aMemorySpaceID != null && aMemorySpaceID.length() > 0) {
|
||||||
IMemorySpaces memorySpacesService = (IMemorySpaces) getMemorySpaceServiceTracker().getService();
|
IMemorySpaces memorySpacesService = getMemorySpaceServiceTracker().getService();
|
||||||
if (memorySpacesService != null) {
|
if (memorySpacesService != null) {
|
||||||
context = new MemorySpaceDMContext(memorySpacesService.getSession().getId(), aMemorySpaceID, aContext);
|
context = new MemorySpaceDMContext(memorySpacesService.getSession().getId(), aMemorySpaceID, aContext);
|
||||||
}
|
}
|
||||||
|
|
|
@ -621,7 +621,7 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
|
||||||
Query<MemoryByte[]> query = new Query<MemoryByte[]>() {
|
Query<MemoryByte[]> query = new Query<MemoryByte[]>() {
|
||||||
@Override
|
@Override
|
||||||
protected void execute(final DataRequestMonitor<MemoryByte[]> drm) {
|
protected void execute(final DataRequestMonitor<MemoryByte[]> drm) {
|
||||||
IMemory memoryService = (IMemory) fRetrieval.getServiceTracker().getService();
|
IMemory memoryService = fRetrieval.getServiceTracker().getService();
|
||||||
if (memoryService != null) {
|
if (memoryService != null) {
|
||||||
// Go for it
|
// Go for it
|
||||||
memoryService.getMemory(
|
memoryService.getMemory(
|
||||||
|
@ -677,7 +677,7 @@ public class DsfMemoryBlock extends PlatformObject implements IMemoryBlockExtens
|
||||||
Query<MemoryByte[]> query = new Query<MemoryByte[]>() {
|
Query<MemoryByte[]> query = new Query<MemoryByte[]>() {
|
||||||
@Override
|
@Override
|
||||||
protected void execute(final DataRequestMonitor<MemoryByte[]> drm) {
|
protected void execute(final DataRequestMonitor<MemoryByte[]> drm) {
|
||||||
IMemory memoryService = (IMemory) fRetrieval.getServiceTracker().getService();
|
IMemory memoryService = fRetrieval.getServiceTracker().getService();
|
||||||
if (memoryService != null) {
|
if (memoryService != null) {
|
||||||
// Go for it
|
// Go for it
|
||||||
memoryService.setMemory(
|
memoryService.setMemory(
|
||||||
|
|
|
@ -81,8 +81,8 @@ public class DsfMemoryBlockRetrieval extends PlatformObject implements IMemoryBl
|
||||||
private final DsfSession fSession;
|
private final DsfSession fSession;
|
||||||
private final DsfExecutor fExecutor;
|
private final DsfExecutor fExecutor;
|
||||||
private final String fContextString;
|
private final String fContextString;
|
||||||
private final ServiceTracker fMemoryServiceTracker;
|
private final ServiceTracker<IMemory, IMemory> fMemoryServiceTracker;
|
||||||
private final ServiceTracker fExpressionServiceTracker;
|
private final ServiceTracker<IExpressions, IExpressions> fExpressionServiceTracker;
|
||||||
|
|
||||||
private final ILaunchConfiguration fLaunchConfig;
|
private final ILaunchConfiguration fLaunchConfig;
|
||||||
private final ILaunch fLaunch;
|
private final ILaunch fLaunch;
|
||||||
|
@ -129,7 +129,7 @@ public class DsfMemoryBlockRetrieval extends PlatformObject implements IMemoryBl
|
||||||
String memoryServiceFilter = DsfServices.createServiceFilter(IMemory.class, session.getId());
|
String memoryServiceFilter = DsfServices.createServiceFilter(IMemory.class, session.getId());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fMemoryServiceTracker = new ServiceTracker(
|
fMemoryServiceTracker = new ServiceTracker<>(
|
||||||
bundle, bundle.createFilter(memoryServiceFilter), null);
|
bundle, bundle.createFilter(memoryServiceFilter), null);
|
||||||
} catch (InvalidSyntaxException e) {
|
} catch (InvalidSyntaxException e) {
|
||||||
throw new DebugException(new Status(IStatus.ERROR,
|
throw new DebugException(new Status(IStatus.ERROR,
|
||||||
|
@ -148,7 +148,7 @@ public class DsfMemoryBlockRetrieval extends PlatformObject implements IMemoryBl
|
||||||
")"; //$NON-NLS-1$
|
")"; //$NON-NLS-1$
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fExpressionServiceTracker = new ServiceTracker(
|
fExpressionServiceTracker = new ServiceTracker<>(
|
||||||
bundle, bundle.createFilter(expressionServiceFilter), null);
|
bundle, bundle.createFilter(expressionServiceFilter), null);
|
||||||
} catch (InvalidSyntaxException e) {
|
} catch (InvalidSyntaxException e) {
|
||||||
throw new DebugException(new Status(IStatus.ERROR,
|
throw new DebugException(new Status(IStatus.ERROR,
|
||||||
|
@ -328,7 +328,7 @@ public class DsfMemoryBlockRetrieval extends PlatformObject implements IMemoryBl
|
||||||
return fExecutor;
|
return fExecutor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServiceTracker getServiceTracker() {
|
public ServiceTracker<IMemory, IMemory> getServiceTracker() {
|
||||||
return fMemoryServiceTracker;
|
return fMemoryServiceTracker;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -485,7 +485,7 @@ public class DsfMemoryBlockRetrieval extends PlatformObject implements IMemoryBl
|
||||||
@Override
|
@Override
|
||||||
protected void execute(final DataRequestMonitor<BigInteger> drm) {
|
protected void execute(final DataRequestMonitor<BigInteger> drm) {
|
||||||
// Lookup for the ExpressionService
|
// Lookup for the ExpressionService
|
||||||
final IExpressions expressionService = (IExpressions) fExpressionServiceTracker.getService();
|
final IExpressions expressionService = fExpressionServiceTracker.getService();
|
||||||
if (expressionService != null) {
|
if (expressionService != null) {
|
||||||
// Create the expression
|
// Create the expression
|
||||||
final IExpressionDMContext expressionDMC = expressionService.createExpression(dmc, expression);
|
final IExpressionDMContext expressionDMC = expressionService.createExpression(dmc, expression);
|
||||||
|
|
Loading…
Add table
Reference in a new issue