From 68dae1a7ece0ecae2dde3133223deb11d906565d Mon Sep 17 00:00:00 2001 From: Mikhail Khodjaiants Date: Tue, 9 Apr 2013 14:09:40 -0400 Subject: [PATCH] Bug 309576 - Memory view doesn't work with 64 bit executables Change-Id: Ie23f1c28b312a8a1b5705dddf0a20664d48b1a2f Reviewed-on: https://git.eclipse.org/r/11529 Reviewed-by: Marc Khouzam IP-Clean: Marc Khouzam Tested-by: Marc Khouzam Reviewed-by: Mikhail Khodjaiants IP-Clean: Mikhail Khodjaiants Tested-by: Mikhail Khodjaiants --- .../gdb/internal/memory/GdbMemoryBlock.java | 22 ++ .../cdt/dsf/gdb/service/GDBMemory.java | 223 ++++++++++++++++++ .../cdt/dsf/gdb/service/GDBMemory_7_0.java | 13 +- .../cdt/dsf/gdb/service/GDBMemory_7_6.java | 2 + .../gdb/service/GdbDebugServicesFactory.java | 3 +- .../cdt/dsf/gdb/service/IGDBMemory.java | 29 +++ .../mi/service/command/CommandFactory.java | 10 + .../command/commands/CLIShowEndian.java | 36 +++ .../command/output/CLIShowEndianInfo.java | 53 +++++ 9 files changed, 386 insertions(+), 5 deletions(-) create mode 100644 dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBMemory.java create mode 100644 dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/IGDBMemory.java create mode 100644 dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/CLIShowEndian.java create mode 100644 dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/CLIShowEndianInfo.java diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/memory/GdbMemoryBlock.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/memory/GdbMemoryBlock.java index 802e89834ec..9ef61b73b12 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/memory/GdbMemoryBlock.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/memory/GdbMemoryBlock.java @@ -27,6 +27,7 @@ import org.eclipse.cdt.dsf.debug.service.IMemory.IMemoryDMContext; import org.eclipse.cdt.dsf.debug.service.IMemorySpaces; import org.eclipse.cdt.dsf.debug.service.IMemorySpaces.IMemorySpaceDMContext; import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin; +import org.eclipse.cdt.dsf.gdb.service.IGDBMemory; import org.eclipse.cdt.utils.Addr64; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; @@ -266,4 +267,25 @@ public class GdbMemoryBlock extends DsfMemoryBlock implements IMemorySpaceAwareM } return super.getExpression(); } + + @Override + public int getAddressSize() throws DebugException { + GdbMemoryBlockRetrieval retrieval = (GdbMemoryBlockRetrieval)getMemoryBlockRetrieval(); + IMemoryDMContext context = null; + if (fMemorySpaceID != null) { + IMemorySpaces memorySpacesService = (IMemorySpaces) retrieval.getMemorySpaceServiceTracker().getService(); + if (memorySpacesService != null) { + context = new MemorySpaceDMContext(memorySpacesService.getSession().getId(), fMemorySpaceID, getContext()); + } + } + else { + context = getContext(); + } + IGDBMemory memoryService = (IGDBMemory)retrieval.getServiceTracker().getService(); + if (memoryService != null) { + return memoryService.getAddressSize(context); + } + + throw new DebugException(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, IDsfStatusConstants.REQUEST_FAILED, Messages.Err_MemoryServiceNotAvailable, null)); + } } 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 new file mode 100644 index 00000000000..ecb4b3276d0 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBMemory.java @@ -0,0 +1,223 @@ +/******************************************************************************* + * Copyright (c) 2013 Mentor Graphics and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Mentor Graphics - Initial API and implementation + * John Dallaway - Add methods to get the endianness and address size (Bug 225609) + *******************************************************************************/ +package org.eclipse.cdt.dsf.gdb.service; + +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Map; + +import org.eclipse.cdt.core.IAddress; +import org.eclipse.cdt.dsf.concurrent.ConfinedToDsfExecutor; +import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; +import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor; +import org.eclipse.cdt.dsf.concurrent.ImmediateRequestMonitor; +import org.eclipse.cdt.dsf.concurrent.RequestMonitor; +import org.eclipse.cdt.dsf.datamodel.DMContexts; +import org.eclipse.cdt.dsf.datamodel.IDMContext; +import org.eclipse.cdt.dsf.debug.service.IExpressions; +import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext; +import org.eclipse.cdt.dsf.debug.service.IMemory; +import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext; +import org.eclipse.cdt.dsf.debug.service.IRunControl.IExitedDMEvent; +import org.eclipse.cdt.dsf.debug.service.IRunControl.IStartedDMEvent; +import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin; +import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl; +import org.eclipse.cdt.dsf.mi.service.MIMemory; +import org.eclipse.cdt.dsf.mi.service.command.CommandFactory; +import org.eclipse.cdt.dsf.mi.service.command.output.CLIShowEndianInfo; +import org.eclipse.cdt.dsf.mi.service.command.output.MIDataEvaluateExpressionInfo; +import org.eclipse.cdt.dsf.service.DsfServiceEventHandler; +import org.eclipse.cdt.dsf.service.DsfSession; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.debug.core.model.MemoryByte; + +/** + * @since 4.2 + */ +public class GDBMemory extends MIMemory implements IGDBMemory { + + private IGDBControl fCommandControl; + + /** + * Cache of the address sizes for each memory context. + */ + private Map fAddressSizes = new HashMap(); + + /** + * We assume the endianness is the same for all processes because GDB supports only one target. + */ + private boolean fIsBigEndian = false; + + public GDBMemory(DsfSession session) { + super(session); + } + + @Override + public void initialize(final RequestMonitor requestMonitor) { + super.initialize(new ImmediateRequestMonitor(requestMonitor) { + @Override + protected void handleSuccess() { + doInitialize(requestMonitor); + } + }); + } + + private void doInitialize(final RequestMonitor requestMonitor) { + fCommandControl = getServicesTracker().getService(IGDBControl.class); + getSession().addServiceEventListener(this, null); + register( + new String[] { + IMemory.class.getName(), + MIMemory.class.getName(), + IGDBMemory.class.getName(), + GDBMemory.class.getName(), + }, + new Hashtable()); + requestMonitor.done(); + } + + @Override + public void shutdown(RequestMonitor requestMonitor) { + unregister(); + getSession().removeServiceEventListener(this); + fAddressSizes.clear(); + super.shutdown(requestMonitor); + } + + @Override + protected void readMemoryBlock(final IDMContext dmc, IAddress address, + long offset, int word_size, int count, final DataRequestMonitor drm) { + super.readMemoryBlock( + dmc, + address, + offset, + word_size, + count, + new DataRequestMonitor(ImmediateExecutor.getInstance(), drm) { + @Override + @ConfinedToDsfExecutor("fExecutor") + protected void handleSuccess() { + IMemoryDMContext memDmc = DMContexts.getAncestorOfType(dmc, IMemoryDMContext.class); + if (memDmc != null) { + boolean bigEndian = isBigEndian(memDmc); + for (MemoryByte b : getData()) { + b.setBigEndian(bigEndian); + b.setEndianessKnown(true); + } + } + drm.setData(getData()); + drm.done(); + } + }); + } + + @DsfServiceEventHandler + public void eventDispatched(IStartedDMEvent event) { + if (event.getDMContext() instanceof IContainerDMContext) { + IMemoryDMContext memContext = DMContexts.getAncestorOfType(event.getDMContext(), IMemoryDMContext.class); + if (memContext != null) { + readAddressSize(memContext); + readEndianness(memContext); + } + } + } + + @DsfServiceEventHandler + public void eventDispatched(IExitedDMEvent event) { + if (event.getDMContext() instanceof IContainerDMContext) { + IMemoryDMContext context = DMContexts.getAncestorOfType(event.getDMContext(), IMemoryDMContext.class); + if (context != null) { + fAddressSizes.remove(context); + } + } + } + + @Override + public int getAddressSize(IMemoryDMContext context) { + Integer addressSize = fAddressSizes.get(context); + return (addressSize != null) ? addressSize.intValue() : 8; + } + + @Override + public boolean isBigEndian(IMemoryDMContext context) { + return fIsBigEndian; + } + + /** + * Retrieves the address size for given memory and execution contexts. + */ + private void readAddressSize(final IMemoryDMContext memContext) { + Integer addrSize = fAddressSizes.get(memContext); + if (addrSize == null) { + doReadAddressSize( + memContext, + new DataRequestMonitor(ImmediateExecutor.getInstance(), null) { + @Override + @ConfinedToDsfExecutor("fExecutor") + protected void handleSuccess() { + fAddressSizes.put(memContext, getData()); + } + }); + } + } + + /** + * Retrieves the endianness for given memory and execution contexts. + */ + private void readEndianness(IMemoryDMContext memContext) { + doReadEndianness( + memContext, + new DataRequestMonitor(ImmediateExecutor.getInstance(), null) { + @Override + @ConfinedToDsfExecutor("fExecutor") + protected void handleSuccess() { + fIsBigEndian = getData(); + } + }); + } + + protected void doReadAddressSize(IMemoryDMContext memContext, final DataRequestMonitor drm) { + IExpressions exprService = getServicesTracker().getService(IExpressions.class); + IExpressionDMContext exprContext = exprService.createExpression(memContext, "sizeof (void*)"); //$NON-NLS-1$ + CommandFactory commandFactory = fCommandControl.getCommandFactory(); + fCommandControl.queueCommand( + commandFactory.createMIDataEvaluateExpression(exprContext), + new DataRequestMonitor(ImmediateExecutor.getInstance(), drm) { + @Override + @ConfinedToDsfExecutor("fExecutor") + protected void handleSuccess() { + try { + drm.setData(Integer.decode(getData().getValue())); + } + catch(NumberFormatException e) { + drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, String.format("Invalid address size: %s", getData().getValue()))); //$NON-NLS-1$ + } + drm.done(); + } + }); + } + + protected void doReadEndianness(IMemoryDMContext memContext, final DataRequestMonitor drm) { + CommandFactory commandFactory = fCommandControl.getCommandFactory(); + fCommandControl.queueCommand( + commandFactory.createCLIShowEndian(memContext), + new DataRequestMonitor(ImmediateExecutor.getInstance(), drm) { + @Override + @ConfinedToDsfExecutor("fExecutor") + protected void handleSuccess() { + drm.setData(Boolean.valueOf(getData().isBigEndian())); + drm.done(); + } + }); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBMemory_7_0.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBMemory_7_0.java index ca41e2bf729..5193c4cd300 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBMemory_7_0.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBMemory_7_0.java @@ -28,7 +28,7 @@ import org.eclipse.cdt.dsf.mi.service.MIMemory; import org.eclipse.cdt.dsf.service.DsfSession; import org.eclipse.debug.core.model.MemoryByte; -public class GDBMemory_7_0 extends MIMemory { +public class GDBMemory_7_0 extends GDBMemory { public GDBMemory_7_0(DsfSession session) { super(session); @@ -45,8 +45,15 @@ public class GDBMemory_7_0 extends MIMemory { } private void doInitialize(final RequestMonitor requestMonitor) { - register(new String[] { MIMemory.class.getName(), IMemory.class.getName(), GDBMemory_7_0.class.getName()}, - new Hashtable()); + register( + new String[] { + MIMemory.class.getName(), + IMemory.class.getName(), + IGDBMemory.class.getName(), + GDBMemory.class.getName(), + GDBMemory_7_0.class.getName() + }, + new Hashtable()); requestMonitor.done(); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBMemory_7_6.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBMemory_7_6.java index 3c4dd5475e2..7b89d4a5293 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBMemory_7_6.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBMemory_7_6.java @@ -61,6 +61,8 @@ public class GDBMemory_7_6 extends GDBMemory_7_0 implements IEventListener { private void doInitialize(final RequestMonitor requestMonitor) { register(new String[] { MIMemory.class.getName(), IMemory.class.getName(), + IGDBMemory.class.getName(), + GDBMemory.class.getName(), GDBMemory_7_0.class.getName(), GDBMemory_7_6.class.getName()}, new Hashtable()); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java index f8abef45c91..738be0af9b7 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java @@ -42,7 +42,6 @@ import org.eclipse.cdt.dsf.mi.service.MIBreakpointsManager; import org.eclipse.cdt.dsf.mi.service.MIBreakpointsSynchronizer; import org.eclipse.cdt.dsf.mi.service.MIDisassembly; import org.eclipse.cdt.dsf.mi.service.MIExpressions; -import org.eclipse.cdt.dsf.mi.service.MIMemory; import org.eclipse.cdt.dsf.mi.service.MIModules; import org.eclipse.cdt.dsf.mi.service.MIRegisters; import org.eclipse.cdt.dsf.mi.service.MIStack; @@ -186,7 +185,7 @@ public class GdbDebugServicesFactory extends AbstractDsfDebugServicesFactory { return new GDBMemory_7_0(session); } - return new MIMemory(session); + return new GDBMemory(session); } @Override diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/IGDBMemory.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/IGDBMemory.java new file mode 100644 index 00000000000..97c146c14e5 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/IGDBMemory.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2013 Mentor Graphics and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Mentor Graphics - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.dsf.gdb.service; + +import org.eclipse.cdt.dsf.debug.service.IMemory; + +/** + * @since 4.2 + */ +public interface IGDBMemory extends IMemory { + + /** + * Returns the address size (in bytes) of the memory specified by the given context. + */ + public int getAddressSize(IMemoryDMContext context); + + /** + * Returns whether the memory specified by the given context is big endian. + */ + public boolean isBigEndian(IMemoryDMContext context); +} diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CommandFactory.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CommandFactory.java index 865f1b8c9fd..10c1ff8b2fb 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CommandFactory.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CommandFactory.java @@ -28,6 +28,7 @@ import org.eclipse.cdt.dsf.datamodel.IDMContext; import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext; import org.eclipse.cdt.dsf.debug.service.IDisassembly.IDisassemblyDMContext; import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext; +import org.eclipse.cdt.dsf.debug.service.IMemory.IMemoryDMContext; import org.eclipse.cdt.dsf.debug.service.IModules.IModuleDMContext; import org.eclipse.cdt.dsf.debug.service.IModules.ISymbolDMContext; import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext; @@ -52,6 +53,7 @@ import org.eclipse.cdt.dsf.mi.service.command.commands.CLIMaintenance; import org.eclipse.cdt.dsf.mi.service.command.commands.CLIPasscount; import org.eclipse.cdt.dsf.mi.service.command.commands.CLIRecord; import org.eclipse.cdt.dsf.mi.service.command.commands.CLIRemoteGet; +import org.eclipse.cdt.dsf.mi.service.command.commands.CLIShowEndian; import org.eclipse.cdt.dsf.mi.service.command.commands.CLISource; import org.eclipse.cdt.dsf.mi.service.command.commands.CLIThread; import org.eclipse.cdt.dsf.mi.service.command.commands.CLITrace; @@ -172,6 +174,7 @@ import org.eclipse.cdt.dsf.mi.service.command.output.CLIInfoBreakInfo; import org.eclipse.cdt.dsf.mi.service.command.output.CLIInfoProgramInfo; import org.eclipse.cdt.dsf.mi.service.command.output.CLIInfoSharedLibraryInfo; import org.eclipse.cdt.dsf.mi.service.command.output.CLIInfoThreadsInfo; +import org.eclipse.cdt.dsf.mi.service.command.output.CLIShowEndianInfo; import org.eclipse.cdt.dsf.mi.service.command.output.CLIThreadInfo; import org.eclipse.cdt.dsf.mi.service.command.output.CLITraceDumpInfo; import org.eclipse.cdt.dsf.mi.service.command.output.CLITraceInfo; @@ -291,6 +294,13 @@ public class CommandFactory { return new CLIRemoteGet(ctx, remoteFile, localFile); } + /** + * @since 4.2 + */ + public ICommand createCLIShowEndian(IMemoryDMContext ctx) { + return new CLIShowEndian(ctx); + } + public ICommand createCLISource(ICommandControlDMContext ctx, String file) { return new CLISource(ctx, file); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/CLIShowEndian.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/CLIShowEndian.java new file mode 100644 index 00000000000..c7a9ae1756b --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/CLIShowEndian.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2013 Mentor Graphics and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Mentor Graphics - Initial API and implementation + * John Dallaway - Add methods to get the endianness and address size (Bug 225609) + *******************************************************************************/ + +package org.eclipse.cdt.dsf.mi.service.command.commands; + +import org.eclipse.cdt.dsf.debug.service.IMemory.IMemoryDMContext; +import org.eclipse.cdt.dsf.mi.service.command.output.CLIShowEndianInfo; +import org.eclipse.cdt.dsf.mi.service.command.output.MIOutput; + +/** + * Returns the endianness of the current GDB target. + * + * @since 4.2 + */ +public class CLIShowEndian extends MIInterpreterExecConsole { + + private static final String SHOW_ENDIAN = "show endian"; //$NON-NLS-1$ + + public CLIShowEndian(IMemoryDMContext ctx) { + super(ctx, SHOW_ENDIAN); + } + + @Override + public CLIShowEndianInfo getResult(MIOutput miResult) { + return new CLIShowEndianInfo(miResult); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/CLIShowEndianInfo.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/CLIShowEndianInfo.java new file mode 100644 index 00000000000..0a6f40e530f --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/CLIShowEndianInfo.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2013 Mentor Graphics and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Mentor Graphics - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.dsf.mi.service.command.output; + +/** + * 'show endian' returns the endianness of the current target. + * + * sample output: + * + * (gdb) show endian + * The target endianness is set automatically (currently little endian) + * + * @since 4.2 + */ +public class CLIShowEndianInfo extends MIInfo { + + final private static String BIG_ENDIAN = "big endian"; //$NON-NLS-1$ + + private boolean fIsBigEndian = false; + + public CLIShowEndianInfo(MIOutput record) { + super(record); + parse(); + } + + protected void parse() { + if (isDone()) { + MIOutput out = getMIOutput(); + for (MIOOBRecord oob : out.getMIOOBRecords()) { + if (oob instanceof MIConsoleStreamOutput) { + String line = ((MIConsoleStreamOutput)oob).getString().trim(); + if (line.indexOf(BIG_ENDIAN) >= 0 ) { + fIsBigEndian = true; + break; + } + } + } + } + } + + public boolean isBigEndian() { + return fIsBigEndian; + } +}