Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Implement GDB/MI mixed instruction

Use -data-disassemble to implement getting the mixed instruction
for CDI API.


Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/ChangeLog,v
retrieving revision 1.3
diff -u -r1.3 ChangeLog
--- ChangeLog	11 Oct 2002 14:41:35 -0000	1.3
+++ ChangeLog	12 Oct 2002 01:18:52 -0000
@@ -1,6 +1,15 @@
 2002-10-11 Alain Magloire
 
-	cdi/ExpressionManager.java:  Not needed, removed.
+	* cdi/SourceManager (getMixedInstruction):
+	Implement the 3 new methods to return Mixed source
+	and assemby instructions.
+	
+	* cdi/MixedInstruction: New class implements
+	ICDIMixedInstruction.
+
+2002-10-11 Alain Magloire
+
+	* cdi/ExpressionManager.java:  Not needed, removed.
 
 2002-10-10 Alain Magloire
 
Index: src/org/eclipse/cdt/debug/mi/core/cdi/Instruction.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/Instruction.java,v
retrieving revision 1.1
diff -u -r1.1 Instruction.java
--- src/org/eclipse/cdt/debug/mi/core/cdi/Instruction.java	9 Oct 2002 22:09:30 -0000	1.1
+++ src/org/eclipse/cdt/debug/mi/core/cdi/Instruction.java	12 Oct 2002 01:18:52 -0000
@@ -1,3 +1,8 @@
+/*
+ *(c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ * 
+ */
 package org.eclipse.cdt.debug.mi.core.cdi;
 
 import org.eclipse.cdt.debug.core.cdi.model.ICDIInstruction;
Index: src/org/eclipse/cdt/debug/mi/core/cdi/MixedInstruction.java
===================================================================
RCS file: src/org/eclipse/cdt/debug/mi/core/cdi/MixedInstruction.java
diff -N src/org/eclipse/cdt/debug/mi/core/cdi/MixedInstruction.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/debug/mi/core/cdi/MixedInstruction.java	12 Oct 2002 01:18:53 -0000
@@ -0,0 +1,50 @@
+/*
+ *(c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ * 
+ */
+package org.eclipse.cdt.debug.mi.core.cdi;
+
+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.output.MIAsm;
+import org.eclipse.cdt.debug.mi.core.output.MISrcAsm;
+
+/**
+ */
+public class MixedInstruction extends CObject implements ICDIMixedInstruction {
+
+	MISrcAsm srcAsm;
+	
+	public MixedInstruction (CTarget target, MISrcAsm a) {
+		super(target);
+		srcAsm = a;
+	}
+	
+	/**
+	 * @see org.eclipse.cdt.debug.core.cdi.model.ICDIMixedInstruction#getFileName()
+	 */
+	public String getFileName() {
+		return srcAsm.getFile();
+	}
+
+	/**
+	 * @see org.eclipse.cdt.debug.core.cdi.model.ICDIMixedInstruction#getInstructions()
+	 */
+	public ICDIInstruction[] getInstructions() {
+		MIAsm[] asms = srcAsm.getMIAsms();
+		ICDIInstruction[] instructions = new ICDIInstruction[asms.length];
+		for (int i = 0; i < asms.length; i++) {
+			instructions[i] = new Instruction(getCTarget(), asms[i]);
+		}
+		return instructions;
+	}
+
+	/**
+	 * @see org.eclipse.cdt.debug.core.cdi.model.ICDIMixedInstruction#getLineNumber()
+	 */
+	public int getLineNumber() {
+		return srcAsm.getLine();
+	}
+
+}
Index: src/org/eclipse/cdt/debug/mi/core/cdi/SourceManager.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/SourceManager.java,v
retrieving revision 1.14
diff -u -r1.14 SourceManager.java
--- src/org/eclipse/cdt/debug/mi/core/cdi/SourceManager.java	10 Oct 2002 15:18:14 -0000	1.14
+++ src/org/eclipse/cdt/debug/mi/core/cdi/SourceManager.java	12 Oct 2002 01:18:53 -0000
@@ -10,6 +10,7 @@
 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.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 @@
 	}
 
 	/**
-	 * @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();
@@ -167,6 +169,58 @@
 				instructions[i] = new Instruction(getCSession().getCTarget(), asm[i]);
 			}
 			return instructions;
+		} catch (MIException e) {
+			throw new CDIException(e.getMessage());
+		}
+	}
+
+	/**
+	 * @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());
 		}



Back to the top