Skip to content

Commit

Permalink
Enhance memory data initialization checks (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
jld01 authored Nov 6, 2022
1 parent 369ddea commit 1bb0cf0
Showing 1 changed file with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;

Expand Down Expand Up @@ -100,6 +101,7 @@ public void shutdown(RequestMonitor requestMonitor) {
getSession().removeServiceEventListener(this);
fAddressableSizes.clear();
fAddressSizes.clear();
fIsBigEndian.clear();
super.shutdown(requestMonitor);
}

Expand Down Expand Up @@ -314,7 +316,13 @@ public void eventDispatched(IExitedDMEvent event) {
@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();
}

/**
Expand All @@ -323,7 +331,13 @@ public int getAddressSize(IMemoryDMContext context) {
@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
Expand Down

0 comments on commit 1bb0cf0

Please sign in to comment.