From 231ec3e5403c88aa45b79e7001762e5c83bde04f Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Mon, 11 Jun 2018 13:50:30 +0100 Subject: [PATCH] Bug #535767: Store endianess per memory context Change-Id: Ib4beea9a2b54bc26f5357c199ffd6154f49b96dc --- .../eclipse/cdt/dsf/gdb/service/GDBMemory.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBMemory.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBMemory.java index 620ab12edef..1f00bcf3541 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBMemory.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBMemory.java @@ -65,9 +65,9 @@ public class GDBMemory extends MIMemory implements IGDBMemory2 { private Map fAddressableSizes = new HashMap(); /** - * We assume the endianness is the same for all processes because GDB supports only one target. + * Cache of the endianness for each memory context. */ - private Boolean fIsBigEndian; + private Map fIsBigEndian = new HashMap<>(); public GDBMemory(DsfSession session) { super(session); @@ -272,7 +272,7 @@ public class GDBMemory extends MIMemory implements IGDBMemory2 { } - if (fIsBigEndian == null) { + if (fIsBigEndian.get(memContext) == null) { stepsList.add( new Step() { // read endianness @@ -284,7 +284,7 @@ public class GDBMemory extends MIMemory implements IGDBMemory2 { @Override protected void handleCompleted() { if (isSuccess()) { - fIsBigEndian = getData(); + fIsBigEndian.put(memContext, getData()); } // Accept failure requestMonitor.done(); @@ -336,12 +336,13 @@ public class GDBMemory extends MIMemory implements IGDBMemory2 { @Override public boolean isBigEndian(IMemoryDMContext context) { - assert fIsBigEndian != null; - if (fIsBigEndian == null) { - GdbPlugin.log(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, "Endianness was never initialized!")); //$NON-NLS-1$ + Boolean isBigEndian = fIsBigEndian.get(context); + assert isBigEndian != null; + if (isBigEndian == null) { + GdbPlugin.log(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, "Endianness was never initialized for " + context)); //$NON-NLS-1$ return false; } - return fIsBigEndian; + return isBigEndian.booleanValue(); } /**