mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 01:36:01 +02:00
Bug 489398 - Support memory spaces in IExpressionDMAdress
When an address is resolved from an expression, the resulting address may carry a memory space provided by the backend to associate this address to a particular memory space. The current interface for the memory space service (e.g. IMemorySpaces2) can be used to parse the memory space contained in the expression. This update adds: 1) A new API method to resolve the memory space of an IExpressionDMAddress instance 2) The use of the memory space service to attempt to resolve the memory space. Note: if there is no memory space service, the memory space defaults to an empty string, which does not affect the default behaviour i.e. when memory spaces are not used. Change-Id: Idfe5669b26f84ee4e3e78f96f229ced75e6ec5c3
This commit is contained in:
parent
7a73b0035f
commit
82b74d3cb6
5 changed files with 68 additions and 7 deletions
|
@ -39,6 +39,8 @@ import org.eclipse.cdt.dsf.debug.service.IExpressions3;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IFormattedValues;
|
import org.eclipse.cdt.dsf.debug.service.IFormattedValues;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IMemory.IMemoryChangedEvent;
|
import org.eclipse.cdt.dsf.debug.service.IMemory.IMemoryChangedEvent;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IMemory.IMemoryDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IMemory.IMemoryDMContext;
|
||||||
|
import org.eclipse.cdt.dsf.debug.service.IMemorySpaces;
|
||||||
|
import org.eclipse.cdt.dsf.debug.service.IMemorySpaces.DecodeResult;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IRegisters.IRegisterDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IRegisters.IRegisterDMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerSuspendedDMEvent;
|
import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerSuspendedDMEvent;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext;
|
||||||
|
@ -74,6 +76,7 @@ import org.eclipse.cdt.dsf.service.DsfServicesTracker;
|
||||||
import org.eclipse.cdt.dsf.service.DsfSession;
|
import org.eclipse.cdt.dsf.service.DsfSession;
|
||||||
import org.eclipse.cdt.utils.Addr32;
|
import org.eclipse.cdt.utils.Addr32;
|
||||||
import org.eclipse.cdt.utils.Addr64;
|
import org.eclipse.cdt.utils.Addr64;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.osgi.framework.BundleContext;
|
import org.osgi.framework.BundleContext;
|
||||||
|
@ -597,6 +600,7 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions,
|
||||||
protected static class ExpressionDMAddress implements IExpressionDMAddress {
|
protected static class ExpressionDMAddress implements IExpressionDMAddress {
|
||||||
IAddress fAddr;
|
IAddress fAddr;
|
||||||
int fSize;
|
int fSize;
|
||||||
|
String fMemSpace = ""; //$NON-NLS-1$
|
||||||
|
|
||||||
public ExpressionDMAddress(IAddress addr, int size) {
|
public ExpressionDMAddress(IAddress addr, int size) {
|
||||||
fAddr = addr;
|
fAddr = addr;
|
||||||
|
@ -615,17 +619,34 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
public ExpressionDMAddress(String addrStr, int size, String memSpace) {
|
||||||
|
this(addrStr, size);
|
||||||
|
fMemSpace = memSpace;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IAddress getAddress() { return fAddr; }
|
public IAddress getAddress() { return fAddr; }
|
||||||
@Override
|
@Override
|
||||||
public int getSize() { return fSize; }
|
public int getSize() { return fSize; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getMemorySpaceID() {
|
||||||
|
return fMemSpace;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(Object other) {
|
||||||
if (other instanceof ExpressionDMAddress) {
|
if (other instanceof ExpressionDMAddress) {
|
||||||
ExpressionDMAddress otherAddr = (ExpressionDMAddress) other;
|
ExpressionDMAddress otherAddr = (ExpressionDMAddress) other;
|
||||||
return (fSize == otherAddr.getSize()) &&
|
boolean sameAddr = fAddr == null ? otherAddr.getAddress() == null : fAddr.equals(otherAddr.getAddress());
|
||||||
(fAddr == null ? otherAddr.getAddress() == null : fAddr.equals(otherAddr.getAddress()));
|
boolean sameMemSpace = fMemSpace == null ? otherAddr.getMemorySpaceID() == null : fMemSpace.equals(otherAddr.getMemorySpaceID());
|
||||||
|
return (fSize == otherAddr.getSize()) && sameAddr && sameMemSpace;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -951,6 +972,7 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions,
|
||||||
* In this case, some errors should not be reported.
|
* In this case, some errors should not be reported.
|
||||||
*/
|
*/
|
||||||
private boolean fTraceVisualization;
|
private boolean fTraceVisualization;
|
||||||
|
private IMemorySpaces fMemorySpaceService;
|
||||||
|
|
||||||
public MIExpressions(DsfSession session) {
|
public MIExpressions(DsfSession session) {
|
||||||
super(session);
|
super(session);
|
||||||
|
@ -1013,6 +1035,8 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions,
|
||||||
|
|
||||||
fCommandFactory = getServicesTracker().getService(IMICommandControl.class).getCommandFactory();
|
fCommandFactory = getServicesTracker().getService(IMICommandControl.class).getCommandFactory();
|
||||||
|
|
||||||
|
fMemorySpaceService = getServicesTracker().getService(IMemorySpaces.class);
|
||||||
|
|
||||||
requestMonitor.done();
|
requestMonitor.done();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1222,7 +1246,7 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions,
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void getExpressionAddressData(
|
public void getExpressionAddressData(
|
||||||
IExpressionDMContext dmc,
|
final IExpressionDMContext dmc,
|
||||||
final DataRequestMonitor<IExpressionDMAddress> rm) {
|
final DataRequestMonitor<IExpressionDMAddress> rm) {
|
||||||
|
|
||||||
if (dmc instanceof MIExpressionDMC) {
|
if (dmc instanceof MIExpressionDMC) {
|
||||||
|
@ -1257,6 +1281,24 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions,
|
||||||
protected void handleSuccess() {
|
protected void handleSuccess() {
|
||||||
String tmpAddrStr = getData().getValue();
|
String tmpAddrStr = getData().getValue();
|
||||||
|
|
||||||
|
DecodeResult memSpaceParsed = null;
|
||||||
|
if (fMemorySpaceService != null) {
|
||||||
|
try {
|
||||||
|
memSpaceParsed = fMemorySpaceService
|
||||||
|
.decodeAddress(tmpAddrStr);
|
||||||
|
} catch (CoreException e1) {
|
||||||
|
// No memory space id found
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String tMemSpace = ""; //$NON-NLS-1$
|
||||||
|
if (memSpaceParsed != null) {
|
||||||
|
tmpAddrStr = memSpaceParsed.getExpression();
|
||||||
|
tMemSpace = memSpaceParsed.getMemorySpaceId();
|
||||||
|
}
|
||||||
|
|
||||||
|
final String memSpaceId = tMemSpace;
|
||||||
|
|
||||||
// Deal with addresses of contents of a char* which is in
|
// Deal with addresses of contents of a char* which is in
|
||||||
// the form of "0x12345678 \"This is a string\""
|
// the form of "0x12345678 \"This is a string\""
|
||||||
int split = tmpAddrStr.indexOf(' ');
|
int split = tmpAddrStr.indexOf(' ');
|
||||||
|
@ -1270,7 +1312,7 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions,
|
||||||
protected void handleSuccess() {
|
protected void handleSuccess() {
|
||||||
try {
|
try {
|
||||||
int size = Integer.parseInt(getData().getValue());
|
int size = Integer.parseInt(getData().getValue());
|
||||||
rm.setData(new ExpressionDMAddress(addrStr, size));
|
rm.setData(new ExpressionDMAddress(addrStr, size, memSpaceId));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_HANDLE,
|
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_HANDLE,
|
||||||
"Unexpected size format from backend: " + getData().getValue(), null)); //$NON-NLS-1$
|
"Unexpected size format from backend: " + getData().getValue(), null)); //$NON-NLS-1$
|
||||||
|
|
11
dsf/org.eclipse.cdt.dsf/.settings/.api_filters
Normal file
11
dsf/org.eclipse.cdt.dsf/.settings/.api_filters
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<component id="org.eclipse.cdt.dsf" version="2">
|
||||||
|
<resource path="src/org/eclipse/cdt/dsf/debug/service/IExpressions.java" type="org.eclipse.cdt.dsf.debug.service.IExpressions$IExpressionDMAddress">
|
||||||
|
<filter id="403804204">
|
||||||
|
<message_arguments>
|
||||||
|
<message_argument value="org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMAddress"/>
|
||||||
|
<message_argument value="getMemorySpaceID()"/>
|
||||||
|
</message_arguments>
|
||||||
|
</filter>
|
||||||
|
</resource>
|
||||||
|
</component>
|
|
@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
|
||||||
Bundle-Name: %pluginName
|
Bundle-Name: %pluginName
|
||||||
Bundle-Vendor: %providerName
|
Bundle-Vendor: %providerName
|
||||||
Bundle-SymbolicName: org.eclipse.cdt.dsf;singleton:=true
|
Bundle-SymbolicName: org.eclipse.cdt.dsf;singleton:=true
|
||||||
Bundle-Version: 2.6.0.qualifier
|
Bundle-Version: 2.7.0.qualifier
|
||||||
Bundle-Activator: org.eclipse.cdt.dsf.internal.DsfPlugin
|
Bundle-Activator: org.eclipse.cdt.dsf.internal.DsfPlugin
|
||||||
Bundle-Localization: plugin
|
Bundle-Localization: plugin
|
||||||
Require-Bundle: org.eclipse.core.runtime,
|
Require-Bundle: org.eclipse.core.runtime,
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<version>2.6.0-SNAPSHOT</version>
|
<version>2.7.0-SNAPSHOT</version>
|
||||||
<artifactId>org.eclipse.cdt.dsf</artifactId>
|
<artifactId>org.eclipse.cdt.dsf</artifactId>
|
||||||
<packaging>eclipse-plugin</packaging>
|
<packaging>eclipse-plugin</packaging>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -98,6 +98,14 @@ public interface IExpressions extends IFormattedValues {
|
||||||
* Returns the size of the address.
|
* Returns the size of the address.
|
||||||
*/
|
*/
|
||||||
int getSize();
|
int getSize();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The memory space
|
||||||
|
* @since 2.7
|
||||||
|
*/
|
||||||
|
default String getMemorySpaceID() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue