Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance memory data initialization checks #138

Merged
merged 1 commit into from
Nov 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
ruspl-afed marked this conversation as resolved.
Show resolved Hide resolved
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;
ruspl-afed marked this conversation as resolved.
Show resolved Hide resolved
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