1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-10 12:03:16 +02:00

Enhance memory data initialization checks (#138)

This commit is contained in:
John Dallaway 2022-11-06 12:34:32 +00:00 committed by GitHub
parent 369ddea39c
commit 1bb0cf0a37
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2013, 2014 Mentor Graphics and others.
* Copyright (c) 2013, 2022 Mentor Graphics and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@ -13,6 +13,7 @@
* John Dallaway - Add methods to get the endianness and address size (Bug 225609)
* Philippe Gil (AdaCore) - Switch to c language when getting sizeof(void *) when required (Bug 421541)
* Alvaro Sanchez-Leon (Ericsson AB) - [Memory] Support 16 bit addressable size (Bug 426730)
* John Dallaway - Enhance memory data initialization checks (#138)
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.service;
@ -100,6 +101,7 @@ public class GDBMemory extends MIMemory implements IGDBMemory2 {
getSession().removeServiceEventListener(this);
fAddressableSizes.clear();
fAddressSizes.clear();
fIsBigEndian.clear();
super.shutdown(requestMonitor);
}
@ -314,7 +316,13 @@ public class GDBMemory extends MIMemory implements IGDBMemory2 {
@Override
public int getAddressSize(IMemoryDMContext context) {
Integer addressSize = fAddressSizes.get(context);
return (addressSize != null) ? addressSize.intValue() : 8;
assert addressSize != null;
if (addressSize == null) {
GdbPlugin.log(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID,
"Address size was never initialized for " + context)); //$NON-NLS-1$
return 8;
}
return addressSize.intValue();
}
/**
@ -323,7 +331,13 @@ public class GDBMemory extends MIMemory implements IGDBMemory2 {
@Override
public int getAddressableSize(IMemoryDMContext context) {
Integer addressableSize = fAddressableSizes.get(context);
return (addressableSize != null) ? addressableSize.intValue() : 1;
assert addressableSize != null;
if (addressableSize == null) {
GdbPlugin.log(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID,
"Addressable size was never initialized for " + context)); //$NON-NLS-1$
return super.getAddressableSize(context);
}
return addressableSize.intValue();
}
@Override