1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +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:
Teodor Madan 2014-04-11 15:01:32 +03:00
parent 63cb636c7a
commit 839905a802
2 changed files with 16 additions and 3 deletions

View file

@ -344,7 +344,17 @@ public class GDBMemory extends MIMemory implements IGDBMemory2 {
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);
IExpressionDMContext exprContext = exprService.createExpression(memContext, "sizeof (void*)"); //$NON-NLS-1$
CommandFactory commandFactory = fCommandControl.getCommandFactory();
@ -354,7 +364,10 @@ public class GDBMemory extends MIMemory implements IGDBMemory2 {
@Override
protected void handleSuccess() {
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) {
drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, String.format("Invalid address size: %s", getData().getValue()))); //$NON-NLS-1$

View file

@ -27,7 +27,7 @@ public interface IGDBMemory extends IMemory {
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);