From 39f06893f1b65c9cc7cd5d7a076ef60687ea5a13 Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Sat, 12 Oct 2002 01:21:51 +0000 Subject: [PATCH] Implements the new MixedInstruction methods. --- .../cdt/debug/mi/core/cdi/SourceManager.java | 56 ++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/SourceManager.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/SourceManager.java index b8400ae7d3f..807ef6ba4b8 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/SourceManager.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/SourceManager.java @@ -10,6 +10,7 @@ import java.io.File; import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.ICDISourceManager; import org.eclipse.cdt.debug.core.cdi.model.ICDIInstruction; +import org.eclipse.cdt.debug.core.cdi.model.ICDIMixedInstruction; import org.eclipse.cdt.debug.mi.core.MIException; import org.eclipse.cdt.debug.mi.core.MISession; import org.eclipse.cdt.debug.mi.core.command.CommandFactory; @@ -23,6 +24,7 @@ import org.eclipse.cdt.debug.mi.core.output.MIAsm; import org.eclipse.cdt.debug.mi.core.output.MIDataDisassembleInfo; import org.eclipse.cdt.debug.mi.core.output.MIGDBShowDirectoriesInfo; import org.eclipse.cdt.debug.mi.core.output.MIGDBShowSolibSearchPathInfo; +import org.eclipse.cdt.debug.mi.core.output.MISrcAsm; /** @@ -149,7 +151,7 @@ public class SourceManager extends SessionObject implements ICDISourceManager { } /** - * @see org.eclipse.cdt.debug.core.cdi.ICDISourceManager#getInstructions(String, String) + * @see org.eclipse.cdt.debug.core.cdi.ICDISourceManager#getInstructions(long, long) */ public ICDIInstruction[] getInstructions(long start, long end) throws CDIException { MISession mi = getCSession().getMISession(); @@ -172,4 +174,56 @@ public class SourceManager extends SessionObject implements ICDISourceManager { } } + /** + * @see org.eclipse.cdt.debug.core.cdi.ICDISourceManager#getMixedInstructions(String, int, int) + */ + public ICDIMixedInstruction[] getMixedInstructions(String filename, int linenum, int lines) throws CDIException { + MISession mi = getCSession().getMISession(); + CommandFactory factory = mi.getCommandFactory(); + MIDataDisassemble dis = factory.createMIDataDisassemble(filename, linenum, lines, true); + try { + mi.postCommand(dis); + MIDataDisassembleInfo info = dis.getMIDataDisassembleInfo(); + MISrcAsm[] srcAsm = info.getMISrcAsms(); + ICDIMixedInstruction[] mixed = new ICDIMixedInstruction[srcAsm.length]; + for (int i = 0; i < mixed.length; i++) { + mixed[i] = new MixedInstruction(getCSession().getCTarget(), srcAsm[i]); + } + return mixed; + } catch (MIException e) { + throw new CDIException(e.getMessage()); + } + } + + /** + * @see org.eclipse.cdt.debug.core.cdi.ICDISourceManager#getMixedInstructions(String, int) + */ + public ICDIMixedInstruction[] getMixedInstructions(String filename, int linenum) throws CDIException { + return getMixedInstructions(filename, linenum, -1); + } + + /** + * @see org.eclipse.cdt.debug.core.cdi.ICDISourceManager#getMixedInstructions(long, long) + */ + public ICDIMixedInstruction[] getMixedInstructions(long start, long end) throws CDIException { + MISession mi = getCSession().getMISession(); + CommandFactory factory = mi.getCommandFactory(); + String hex = "0x"; + String sa = hex + Long.toHexString(start); + String ea = hex + Long.toHexString(end); + MIDataDisassemble dis = factory.createMIDataDisassemble(sa, ea, true); + try { + mi.postCommand(dis); + MIDataDisassembleInfo info = dis.getMIDataDisassembleInfo(); + MISrcAsm[] srcAsm = info.getMISrcAsms(); + ICDIMixedInstruction[] mixed = new ICDIMixedInstruction[srcAsm.length]; + for (int i = 0; i < mixed.length; i++) { + mixed[i] = new MixedInstruction(getCSession().getCTarget(), srcAsm[i]); + } + return mixed; + } catch (MIException e) { + throw new CDIException(e.getMessage()); + } + } + }