[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Implementing sourcemanager new methods.
|
Implementing the new ICDISourceManager methods.
Index: Instruction.java
===================================================================
RCS file: Instruction.java
diff -N Instruction.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Instruction.java 9 Oct 2002 22:06:04 -0000
@@ -0,0 +1,44 @@
+package org.eclipse.cdt.debug.mi.core.cdi;
+
+import org.eclipse.cdt.debug.core.cdi.model.ICDIInstruction;
+import org.eclipse.cdt.debug.mi.core.output.MIAsm;
+
+/**
+ */
+public class Instruction extends CObject implements ICDIInstruction {
+
+ MIAsm asm;
+
+ public Instruction(CTarget target, MIAsm a) {
+ super(target);
+ asm = a;
+ }
+ /**
+ * @see org.eclipse.cdt.debug.core.cdi.model.ICDIInstruction#getAdress()
+ */
+ public long getAdress() {
+ return asm.getAddress();
+ }
+
+ /**
+ * @see org.eclipse.cdt.debug.core.cdi.model.ICDIInstruction#getFuntionName()
+ */
+ public String getFuntionName() {
+ return asm.getFunction();
+ }
+
+ /**
+ * @see org.eclipse.cdt.debug.core.cdi.model.ICDIInstruction#getInstruction()
+ */
+ public String getInstruction() {
+ return asm.getInstruction();
+ }
+
+ /**
+ * @see org.eclipse.cdt.debug.core.cdi.model.ICDIInstruction#getOffset()
+ */
+ public long getOffset() {
+ return asm.getOffset();
+ }
+
+}
Index: 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.12
diff -u -r1.12 SourceManager.java
--- SourceManager.java 9 Oct 2002 14:08:42 -0000 1.12
+++ SourceManager.java 9 Oct 2002 22:06:04 -0000
@@ -9,14 +9,18 @@
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.mi.core.MIException;
import org.eclipse.cdt.debug.mi.core.MISession;
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
+import org.eclipse.cdt.debug.mi.core.command.MIDataDisassemble;
import org.eclipse.cdt.debug.mi.core.command.MIEnvironmentDirectory;
import org.eclipse.cdt.debug.mi.core.command.MIGDBSetAutoSolib;
import org.eclipse.cdt.debug.mi.core.command.MIGDBSetSolibSearchPath;
import org.eclipse.cdt.debug.mi.core.command.MIGDBShowDirectories;
import org.eclipse.cdt.debug.mi.core.command.MIGDBShowSolibSearchPath;
+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;
@@ -111,6 +115,55 @@
try {
mi.postCommand(solib);
solib.getMIInfo();
+ } catch (MIException e) {
+ throw new CDIException(e.getMessage());
+ }
+ }
+
+ /**
+ * @see org.eclipse.cdt.debug.core.cdi.ICDISourceManager#getInstructions(String, int, int)
+ */
+ public ICDIInstruction[] getInstructions(String filename, int linenum, int lines) throws CDIException {
+ MISession mi = getCSession().getMISession();
+ CommandFactory factory = mi.getCommandFactory();
+ MIDataDisassemble dis = factory.createMIDataDisassemble(filename, linenum, lines, false);
+ try {
+ mi.postCommand(dis);
+ MIDataDisassembleInfo info = dis.getMIDataDisassembleInfo();
+ MIAsm[] asm = info.getMIAsms();
+ Instruction[] instructions = new Instruction[asm.length];
+ for (int i = 0; i < instructions.length; i++) {
+ 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#getInstructions(String, int)
+ */
+ public ICDIInstruction[] getInstructions(String filename, int linenum) throws CDIException {
+ return getInstructions(filename, linenum, -1);
+ }
+
+ /**
+ * @see org.eclipse.cdt.debug.core.cdi.ICDISourceManager#getInstructions(String, String)
+ */
+ public ICDIInstruction[] getInstructions(String sa, String ea) throws CDIException {
+ MISession mi = getCSession().getMISession();
+ CommandFactory factory = mi.getCommandFactory();
+ MIDataDisassemble dis = factory.createMIDataDisassemble(sa, ea, false);
+ try {
+ mi.postCommand(dis);
+ MIDataDisassembleInfo info = dis.getMIDataDisassembleInfo();
+ MIAsm[] asm = info.getMIAsms();
+ Instruction[] instructions = new Instruction[asm.length];
+ for (int i = 0; i < instructions.length; i++) {
+ instructions[i] = new Instruction(getCSession().getCTarget(), asm[i]);
+ }
+ return instructions;
} catch (MIException e) {
throw new CDIException(e.getMessage());
}