1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 14:12:10 +02:00

Implement ICDIRegisterObject.

This commit is contained in:
Alain Magloire 2002-08-28 01:43:12 +00:00
parent ed14a106db
commit 039b06c5df
15 changed files with 212 additions and 16 deletions

View file

@ -0,0 +1,16 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
package org.eclipse.cdt.debug.core.cdi;
/**
* Format constants.
*/
public interface ICDIFormat {
public static int NATURAL = 0;
public static int DECIMAL = 1;
public static int BINARY = 2;
public static int OCTAL = 3;
public static int HEXADECIMAL = 4;
}

View file

@ -0,0 +1,19 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.core.cdi;
/**
*
* Represents a break condition.
*
* @since Jul 9, 2002
*/
public interface ICDIRegisterObject {
/**
* Return the name of the register.
*/
String getName();
}

View file

@ -8,6 +8,7 @@ package org.eclipse.cdt.debug.core.cdi.model;
import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDILocation; import org.eclipse.cdt.debug.core.cdi.ICDILocation;
import org.eclipse.cdt.debug.core.cdi.ICDIRegisterObject;
/** /**
* *
@ -45,6 +46,13 @@ public interface ICDIStackFrame extends ICDIObject
*/ */
ICDIArgument[] getArguments() throws CDIException; ICDIArgument[] getArguments() throws CDIException;
/**
* Returns the Registers
* @return a collection of registers
* @throws CDIException if this method fails:
*/
ICDIRegister[] getRegisters(ICDIRegisterObject[] regs);
/** /**
* Returns the level of the stack frame. * Returns the level of the stack frame.
* *

View file

@ -6,10 +6,8 @@
package org.eclipse.cdt.debug.core.cdi.model; package org.eclipse.cdt.debug.core.cdi.model;
import java.io.InputStream;
import java.io.OutputStream;
import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDIRegisterObject;
import org.eclipse.cdt.debug.core.cdi.ICDISession; import org.eclipse.cdt.debug.core.cdi.ICDISession;
/** /**
@ -69,12 +67,12 @@ public interface ICDITarget extends ICDIObject {
throws CDIException; throws CDIException;
/** /**
* Returns the register groups associated with this target. * Returns the register associated with this target.
* *
* @return a collection of register groups * @return a collection of register groups
* @throws CDIException if this method fails. Reasons include: * @throws CDIException if this method fails. Reasons include:
*/ */
ICDIRegisterGroup[] getRegisterGroups() throws CDIException; ICDIRegisterObject[] getRegisterObjects() throws CDIException;
/** /**
* Returns a collection of global variables associated with * Returns a collection of global variables associated with

View file

@ -1,3 +1,8 @@
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.mi.core.cdi; package org.eclipse.cdt.debug.mi.core.cdi;
import org.eclipse.cdt.debug.core.cdi.ICDIBreakpointHit; import org.eclipse.cdt.debug.core.cdi.ICDIBreakpointHit;

View file

@ -9,10 +9,10 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDIRegisterObject;
import org.eclipse.cdt.debug.core.cdi.ICDISession; import org.eclipse.cdt.debug.core.cdi.ICDISession;
import org.eclipse.cdt.debug.core.cdi.model.ICDIGlobalVariable; import org.eclipse.cdt.debug.core.cdi.model.ICDIGlobalVariable;
import org.eclipse.cdt.debug.core.cdi.model.ICDIMemoryBlock; import org.eclipse.cdt.debug.core.cdi.model.ICDIMemoryBlock;
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegisterGroup;
import org.eclipse.cdt.debug.core.cdi.model.ICDISharedLibrary; import org.eclipse.cdt.debug.core.cdi.model.ICDISharedLibrary;
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
import org.eclipse.cdt.debug.core.cdi.model.ICDIThread; import org.eclipse.cdt.debug.core.cdi.model.ICDIThread;
@ -22,6 +22,7 @@ import org.eclipse.cdt.debug.mi.core.MISession;
import org.eclipse.cdt.debug.mi.core.command.CLICommand; import org.eclipse.cdt.debug.mi.core.command.CLICommand;
import org.eclipse.cdt.debug.mi.core.command.CommandFactory; import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
import org.eclipse.cdt.debug.mi.core.command.MIDataEvaluateExpression; import org.eclipse.cdt.debug.mi.core.command.MIDataEvaluateExpression;
import org.eclipse.cdt.debug.mi.core.command.MIDataListRegisterNames;
import org.eclipse.cdt.debug.mi.core.command.MIExecContinue; import org.eclipse.cdt.debug.mi.core.command.MIExecContinue;
import org.eclipse.cdt.debug.mi.core.command.MIExecFinish; import org.eclipse.cdt.debug.mi.core.command.MIExecFinish;
import org.eclipse.cdt.debug.mi.core.command.MIExecInterrupt; import org.eclipse.cdt.debug.mi.core.command.MIExecInterrupt;
@ -35,6 +36,7 @@ import org.eclipse.cdt.debug.mi.core.command.MIThreadListIds;
import org.eclipse.cdt.debug.mi.core.command.MIThreadSelect; import org.eclipse.cdt.debug.mi.core.command.MIThreadSelect;
import org.eclipse.cdt.debug.mi.core.event.MIThreadExitEvent; import org.eclipse.cdt.debug.mi.core.event.MIThreadExitEvent;
import org.eclipse.cdt.debug.mi.core.output.MIDataEvaluateExpressionInfo; import org.eclipse.cdt.debug.mi.core.output.MIDataEvaluateExpressionInfo;
import org.eclipse.cdt.debug.mi.core.output.MIDataListRegisterNamesInfo;
import org.eclipse.cdt.debug.mi.core.output.MIInfo; import org.eclipse.cdt.debug.mi.core.output.MIInfo;
import org.eclipse.cdt.debug.mi.core.output.MIThreadListIdsInfo; import org.eclipse.cdt.debug.mi.core.output.MIThreadListIdsInfo;
import org.eclipse.cdt.debug.mi.core.output.MIThreadSelectInfo; import org.eclipse.cdt.debug.mi.core.output.MIThreadSelectInfo;
@ -441,10 +443,29 @@ public class CTarget implements ICDITarget {
} }
/** /**
* @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#getRegisterGroups() * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#getRegisterObjects()
*/ */
public ICDIRegisterGroup[] getRegisterGroups() throws CDIException { public ICDIRegisterObject[] getRegisterObjects() throws CDIException {
return new ICDIRegisterGroup[0]; MISession mi = session.getMISession();
CommandFactory factory = mi.getCommandFactory();
MIDataListRegisterNames registers =
factory.createMIDataListRegisterNames();
try {
mi.postCommand(registers);
MIDataListRegisterNamesInfo info =
registers.getMIDataListRegisterNamesInfo();
if (info == null) {
throw new CDIException("No answer");
}
String[] names = info.getRegisterNames();
RegisterObject[] regs = new RegisterObject[names.length];
for (int i = 0; i < names.length; i++) {
regs[i] = new RegisterObject(names[i], i);
}
return regs;
} catch (MIException e) {
throw new CDIException(e.toString());
}
} }
/** /**

View file

@ -0,0 +1,43 @@
/*
* (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.ICDIFormat;
import org.eclipse.cdt.debug.mi.core.MIFormat;
/**
*/
public class Format {
private Format() {
}
public static int toMIFormat(int format) {
int fmt = MIFormat.NATURAL;
switch (format) {
case ICDIFormat.NATURAL:
fmt = MIFormat.NATURAL;
break;
case ICDIFormat.DECIMAL:
fmt = MIFormat.DECIMAL;
break;
case ICDIFormat.BINARY:
fmt = MIFormat.BINARY;
break;
case ICDIFormat.OCTAL:
fmt = MIFormat.OCTAL;
break;
case ICDIFormat.HEXADECIMAL:
fmt = MIFormat.HEXADECIMAL;
break;
}
return fmt;
}
}

View file

@ -0,0 +1,28 @@
package org.eclipse.cdt.debug.mi.core.cdi;
import org.eclipse.cdt.debug.core.cdi.ICDIRegisterObject;
/**
*/
public class RegisterObject implements ICDIRegisterObject {
int index;
String name;
public RegisterObject(String n, int i) {
name = n;
index = i;
}
public int getId() {
return index;
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICDIRegisterObject#getName()
*/
public String getName() {
return name;
}
}

View file

@ -7,7 +7,9 @@ package org.eclipse.cdt.debug.mi.core.cdi;
import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDILocation; import org.eclipse.cdt.debug.core.cdi.ICDILocation;
import org.eclipse.cdt.debug.core.cdi.ICDIRegisterObject;
import org.eclipse.cdt.debug.core.cdi.model.ICDIArgument; import org.eclipse.cdt.debug.core.cdi.model.ICDIArgument;
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegister;
import org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame; import org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame;
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable; import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable;
import org.eclipse.cdt.debug.mi.core.MIException; import org.eclipse.cdt.debug.mi.core.MIException;
@ -130,6 +132,30 @@ public class StackFrame extends CObject implements ICDIStackFrame {
return variables; return variables;
} }
/**
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame#getRegisters(ICDIRegisterObject[])
*/
public ICDIRegister[] getRegisters(ICDIRegisterObject[] regs) {
ICDIRegister[] registers = null;
CSession session = getCTarget().getCSession();
VariableManager mgr = (VariableManager)session.getVariableManager();
MISession mi = session.getMISession();
CommandFactory factory = mi.getCommandFactory();
try {
registers = new ICDIRegister[regs.length];
for (int i = 0; i < registers.length; i++) {
registers[i] = mgr.createRegister(this, regs[i].getName());
}
} catch (CDIException e) {
//throw e;
System.err.println(e);
}
if (registers == null) {
registers = new ICDIRegister[0];
}
return registers;
}
/** /**
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame#getLocation() * @see org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame#getLocation()
*/ */

View file

@ -12,6 +12,7 @@ import org.eclipse.cdt.debug.mi.core.MIException;
import org.eclipse.cdt.debug.mi.core.MISession; 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.CommandFactory;
import org.eclipse.cdt.debug.mi.core.command.MIVarAssign; import org.eclipse.cdt.debug.mi.core.command.MIVarAssign;
import org.eclipse.cdt.debug.mi.core.command.MIVarSetFormat;
import org.eclipse.cdt.debug.mi.core.command.MIVarShowAttributes; import org.eclipse.cdt.debug.mi.core.command.MIVarShowAttributes;
import org.eclipse.cdt.debug.mi.core.output.MIInfo; import org.eclipse.cdt.debug.mi.core.output.MIInfo;
import org.eclipse.cdt.debug.mi.core.output.MIVar; import org.eclipse.cdt.debug.mi.core.output.MIVar;
@ -110,6 +111,25 @@ public class Variable extends CObject implements ICDIVariable {
} }
} }
/**
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#setFormat()
*/
public void setFormat(int format) throws CDIException {
int fmt = Format.toMIFormat(format);
MISession mi = getCTarget().getCSession().getMISession();
CommandFactory factory = mi.getCommandFactory();
MIVarSetFormat var = factory.createMIVarSetFormat(miVar.getVarName(), fmt);
try {
mi.postCommand(var);
MIInfo info = var.getMIInfo();
if (info == null) {
throw new CDIException("No answer");
}
} catch (MIException e) {
throw new CDIException(e.toString());
}
}
/** /**
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#equals() * @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#equals()
*/ */

View file

@ -1,3 +1,8 @@
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.mi.core.cdi; package org.eclipse.cdt.debug.mi.core.cdi;
import org.eclipse.cdt.debug.core.cdi.ICDIWatchpointScope; import org.eclipse.cdt.debug.core.cdi.ICDIWatchpointScope;

View file

@ -1,15 +1,14 @@
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.mi.core.cdi; package org.eclipse.cdt.debug.mi.core.cdi;
import org.eclipse.cdt.debug.core.cdi.ICDIWatchpointTrigger; import org.eclipse.cdt.debug.core.cdi.ICDIWatchpointTrigger;
import org.eclipse.cdt.debug.mi.core.event.MIWatchpointEvent; import org.eclipse.cdt.debug.mi.core.event.MIWatchpointEvent;
/** /**
* @author alain
*
* To change this generated comment edit the template variable "typecomment":
* Window>Preferences>Java>Templates.
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
*/ */
public class WatchpointTrigger extends WatchpointScope implements ICDIWatchpointTrigger { public class WatchpointTrigger extends WatchpointScope implements ICDIWatchpointTrigger {

View file

@ -64,6 +64,10 @@ public class CommandFactory {
return new MIDataListChangedRegisters(); return new MIDataListChangedRegisters();
} }
public MIDataListRegisterNames createMIDataListRegisterNames() {
return new MIDataListRegisterNames();
}
public MIDataListRegisterNames createMIDataListRegisterNames(int[] regno) { public MIDataListRegisterNames createMIDataListRegisterNames(int[] regno) {
return new MIDataListRegisterNames(regno); return new MIDataListRegisterNames(regno);
} }

View file

@ -40,6 +40,10 @@ public class MIDataListRegisterNames extends MICommand
} }
} }
public MIDataListRegisterNamesInfo getMIDataListRegisterNamesInfo() throws MIException {
return (MIDataListRegisterNamesInfo)getMIInfo();
}
public MIInfo getMIInfo() throws MIException { public MIInfo getMIInfo() throws MIException {
MIInfo info = null; MIInfo info = null;
MIOutput out = getMIOutput(); MIOutput out = getMIOutput();

View file

@ -19,7 +19,7 @@ public class MIDataListRegisterNamesInfo extends MIInfo {
super(rr); super(rr);
} }
String[] getRegistersNames () { public String[] getRegisterNames () {
if (names == null) { if (names == null) {
parse(); parse();
} }