mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 06:32:10 +02:00
Bug 432597 - GDB Memory services should report address size in octets
Change-Id: Ifaa39b5fbd1237408cd38284682e1cb25345e6bc Signed-off-by: Teodor Madan <teodor.madan@freescale.com> Reviewed-on: https://git.eclipse.org/r/24849 Tested-by: Hudson CI Reviewed-by: Marc Khouzam <marc.khouzam@ericsson.com>
This commit is contained in:
parent
63cb636c7a
commit
839905a802
2 changed files with 16 additions and 3 deletions
|
@ -344,7 +344,17 @@ public class GDBMemory extends MIMemory implements IGDBMemory2 {
|
||||||
return fIsBigEndian;
|
return fIsBigEndian;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void readAddressSize(IMemoryDMContext memContext, final DataRequestMonitor<Integer> drm) {
|
/**
|
||||||
|
* Address size is determined by space, in octets, used to store an address value (e.g. a pointer) on a target system.
|
||||||
|
*
|
||||||
|
* <p>NOTE: Implementation requires addressable memory size to be known</p>
|
||||||
|
* @param memContext
|
||||||
|
* @param drm
|
||||||
|
*
|
||||||
|
* @see IGDBMemory#getAddressSize(org.eclipse.cdt.dsf.debug.service.IMemory.IMemoryDMContext)
|
||||||
|
* @see GDBMemory#readAddressableSize(org.eclipse.cdt.dsf.debug.service.IMemory.IMemoryDMContext, DataRequestMonitor)
|
||||||
|
*/
|
||||||
|
protected void readAddressSize(final IMemoryDMContext memContext, final DataRequestMonitor<Integer> drm) {
|
||||||
IExpressions exprService = getServicesTracker().getService(IExpressions.class);
|
IExpressions exprService = getServicesTracker().getService(IExpressions.class);
|
||||||
IExpressionDMContext exprContext = exprService.createExpression(memContext, "sizeof (void*)"); //$NON-NLS-1$
|
IExpressionDMContext exprContext = exprService.createExpression(memContext, "sizeof (void*)"); //$NON-NLS-1$
|
||||||
CommandFactory commandFactory = fCommandControl.getCommandFactory();
|
CommandFactory commandFactory = fCommandControl.getCommandFactory();
|
||||||
|
@ -354,7 +364,10 @@ public class GDBMemory extends MIMemory implements IGDBMemory2 {
|
||||||
@Override
|
@Override
|
||||||
protected void handleSuccess() {
|
protected void handleSuccess() {
|
||||||
try {
|
try {
|
||||||
drm.setData(Integer.decode(getData().getValue()));
|
// 'sizeof' returns number of bytes (aka 'chars').
|
||||||
|
// Multiply with byte size in octets to get storage required to hold a pointer.
|
||||||
|
Integer ptrBytes = Integer.decode(getData().getValue());
|
||||||
|
drm.setData(ptrBytes * getAddressableSize(memContext));
|
||||||
}
|
}
|
||||||
catch(NumberFormatException e) {
|
catch(NumberFormatException e) {
|
||||||
drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, String.format("Invalid address size: %s", getData().getValue()))); //$NON-NLS-1$
|
drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, String.format("Invalid address size: %s", getData().getValue()))); //$NON-NLS-1$
|
||||||
|
|
|
@ -27,7 +27,7 @@ public interface IGDBMemory extends IMemory {
|
||||||
public void initializeMemoryData(IMemoryDMContext ctx, RequestMonitor rm);
|
public void initializeMemoryData(IMemoryDMContext ctx, RequestMonitor rm);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the address size (in bytes) of the memory specified by the given context.
|
* Returns the address size (in octets) of the memory specified by the given context.
|
||||||
*/
|
*/
|
||||||
public int getAddressSize(IMemoryDMContext context);
|
public int getAddressSize(IMemoryDMContext context);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue