1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 18:26:01 +02:00

2005-06-27 Alain Magloire

Bug when parsing "int *&" corrected.
	Change in ICDIReferenceValue.
	Use the type in the response of the var-create instead of reissuing -var-info-type

	* cdi/org/eclipse/cdt/debug/mi/core/cdi/CdiResource.properties
	* cdi/org/eclipse/cdt/debug/mi/core/cdi/SignalManager.java
	* cdi/org/eclipse/cdt/debug/mi/core/cdi/ SourceManager.java
	* cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Value.java
	* cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Variable.java
	* cdi;/org/eclipse/cdt/debug/mi/core/cdi/model/CharValue.java
	* cdi;/org/eclipse/cdt/debug/mi/core/cdi/model/IntergralValue.java
	* cdi;/org/eclipse/cdt/debug/mi/core/cdi/model/PointerValue.java
	* cdi;/org/eclipse/cdt/debug/mi/core/cdi/model/ReferenceValue.java
	* mi/org/eclipse/cdt/debug/mi/core/GDBTypeParser.java
	* mi/org/eclipse/cdt/debug/mi/core/MIInferior.java
This commit is contained in:
Alain Magloire 2005-06-28 03:02:59 +00:00
parent 504759ff91
commit dd61bd77b0
12 changed files with 159 additions and 95 deletions

View file

@ -1,3 +1,20 @@
2005-06-27 Alain Magloire
Bug when parsing "int *&" corrected.
Change in ICDIReferenceValue.
Use the type in the response of the var-create instead of reissuing -var-info-type
* cdi/org/eclipse/cdt/debug/mi/core/cdi/CdiResource.properties
* cdi/org/eclipse/cdt/debug/mi/core/cdi/SignalManager.java
* cdi/org/eclipse/cdt/debug/mi/core/cdi/ SourceManager.java
* cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Value.java
* cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Variable.java
* cdi;/org/eclipse/cdt/debug/mi/core/cdi/model/CharValue.java
* cdi;/org/eclipse/cdt/debug/mi/core/cdi/model/IntergralValue.java
* cdi;/org/eclipse/cdt/debug/mi/core/cdi/model/PointerValue.java
* cdi;/org/eclipse/cdt/debug/mi/core/cdi/model/ReferenceValue.java
* mi/org/eclipse/cdt/debug/mi/core/GDBTypeParser.java
* mi/org/eclipse/cdt/debug/mi/core/MIInferior.java
2005-06-27 Alain Magloire 2005-06-27 Alain Magloire
Base on a patch from Chris Wiebe. Base on a patch from Chris Wiebe.
* cdi/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java * cdi/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java

View file

@ -23,7 +23,7 @@ cdi.RuntimeOptions.Unable_to_set_working_dir=Unable to set working directory:
cdi.Session.Unknown_target=Unkown target cdi.Session.Unknown_target=Unkown target
cdi.VariableManager.Unknown_type=Unknown type cdi.VariableManager.Unknown_type=Unknown type
cdi.VariableManager.Wrong_variable_type=Wrong variable type cdi.VariableManager.Wrong_variable_type=Wrong variable type
cdi.VariableManager.Unknown_variable_ogject=Unknown variable object cdi.VariableManager.Unknown_variable_object=Unknown variable object
cdi.model.VariableObject.Target_not_responding=Target is not responding cdi.model.VariableObject.Target_not_responding=Target is not responding
cdi.model.Target.Unknown_thread=Unknown thread cdi.model.Target.Unknown_thread=Unknown thread
cdi.model.Target.Target_not_responding=Target is not responding cdi.model.Target.Target_not_responding=Target is not responding

View file

@ -20,6 +20,7 @@ import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.model.ICDISignal; import org.eclipse.cdt.debug.core.cdi.model.ICDISignal;
import org.eclipse.cdt.debug.mi.core.MIException; 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.RxThread;
import org.eclipse.cdt.debug.mi.core.cdi.model.Signal; import org.eclipse.cdt.debug.mi.core.cdi.model.Signal;
import org.eclipse.cdt.debug.mi.core.cdi.model.Target; import org.eclipse.cdt.debug.mi.core.cdi.model.Target;
import org.eclipse.cdt.debug.mi.core.command.CommandFactory; import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
@ -57,6 +58,8 @@ public class SignalManager extends Manager {
CommandFactory factory = miSession.getCommandFactory(); CommandFactory factory = miSession.getCommandFactory();
CLIInfoSignals sigs = factory.createCLIInfoSignals(); CLIInfoSignals sigs = factory.createCLIInfoSignals();
try { try {
RxThread rxThread = miSession.getRxThread();
rxThread.setEnableConsole(false);
miSession.postCommand(sigs); miSession.postCommand(sigs);
CLIInfoSignalsInfo info = sigs.getMIInfoSignalsInfo(); CLIInfoSignalsInfo info = sigs.getMIInfoSignalsInfo();
if (info == null) { if (info == null) {
@ -65,6 +68,9 @@ public class SignalManager extends Manager {
miSigs = info.getMISignals(); miSigs = info.getMISignals();
} catch (MIException e) { } catch (MIException e) {
throw new MI2CDIException(e); throw new MI2CDIException(e);
} finally {
RxThread rxThread = miSession.getRxThread();
rxThread.setEnableConsole(true);
} }
return miSigs; return miSigs;
} }
@ -74,6 +80,8 @@ public class SignalManager extends Manager {
CommandFactory factory = miSession.getCommandFactory(); CommandFactory factory = miSession.getCommandFactory();
CLIInfoSignals sigs = factory.createCLIInfoSignals(name); CLIInfoSignals sigs = factory.createCLIInfoSignals(name);
try { try {
RxThread rxThread = miSession.getRxThread();
rxThread.setEnableConsole(false);
miSession.postCommand(sigs); miSession.postCommand(sigs);
CLIInfoSignalsInfo info = sigs.getMIInfoSignalsInfo(); CLIInfoSignalsInfo info = sigs.getMIInfoSignalsInfo();
if (info == null) { if (info == null) {
@ -85,6 +93,9 @@ public class SignalManager extends Manager {
} }
} catch (MIException e) { } catch (MIException e) {
throw new MI2CDIException(e); throw new MI2CDIException(e);
} finally {
RxThread rxThread = miSession.getRxThread();
rxThread.setEnableConsole(true);
} }
return sig; return sig;
} }

View file

@ -471,11 +471,13 @@ public class SourceManager extends Manager {
} }
public String getTypeName(Target target, String variable) throws CDIException { public String getTypeName(Target target, String variable) throws CDIException {
MISession miSession = target.getMISession();
try { try {
MISession mi = target.getMISession(); RxThread rxThread = miSession.getRxThread();
CommandFactory factory = mi.getCommandFactory(); rxThread.setEnableConsole(false);
CommandFactory factory = miSession.getCommandFactory();
CLIWhatis whatis = factory.createCLIWhatis(variable); CLIWhatis whatis = factory.createCLIWhatis(variable);
mi.postCommand(whatis); miSession.postCommand(whatis);
CLIWhatisInfo info = whatis.getMIWhatisInfo(); CLIWhatisInfo info = whatis.getMIWhatisInfo();
if (info == null) { if (info == null) {
throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$ throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$
@ -483,6 +485,9 @@ public class SourceManager extends Manager {
return info.getType(); return info.getType();
} catch (MIException e) { } catch (MIException e) {
throw new MI2CDIException(e); throw new MI2CDIException(e);
} finally {
RxThread rxThread = miSession.getRxThread();
rxThread.setEnableConsole(true);
} }
} }

View file

@ -32,6 +32,10 @@ public class Value extends CObject implements ICDIValue {
variable = v; variable = v;
} }
protected Variable getVariable() {
return variable;
}
/** /**
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIValue#getTypeName() * @see org.eclipse.cdt.debug.core.cdi.model.ICDIValue#getTypeName()
*/ */

View file

@ -426,6 +426,8 @@ public abstract class Variable extends VariableDescriptor implements ICDIVariabl
*/ */
public String getTypeName() throws CDIException { public String getTypeName() throws CDIException {
if (fTypename == null) { if (fTypename == null) {
fTypename = fMiVar.getType();
if (fTypename == null || fTypename.length() == 0) {
MISession mi = ((Target) getTarget()).getMISession(); MISession mi = ((Target) getTarget()).getMISession();
CommandFactory factory = mi.getCommandFactory(); CommandFactory factory = mi.getCommandFactory();
MIVarInfoType infoType = factory.createMIVarInfoType(fMiVar.getVarName()); MIVarInfoType infoType = factory.createMIVarInfoType(fMiVar.getVarName());
@ -440,6 +442,7 @@ public abstract class Variable extends VariableDescriptor implements ICDIVariabl
throw new MI2CDIException(e); throw new MI2CDIException(e);
} }
} }
}
return fTypename; return fTypename;
} }
} }

View file

@ -30,8 +30,7 @@ public class CharValue extends IntegralValue implements ICDICharValue {
* @see org.eclipse.cdt.debug.core.cdi.model.ICDICharValue#getValue() * @see org.eclipse.cdt.debug.core.cdi.model.ICDICharValue#getValue()
*/ */
public char getValue() throws CDIException { public char getValue() throws CDIException {
// TODO Auto-generated method stub return (char)intValue();
return 0;
} }
} }

View file

@ -36,11 +36,24 @@ public abstract class IntegralValue extends Value implements ICDIIntegralValue {
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIIntegralValue#biIntegerValue() * @see org.eclipse.cdt.debug.core.cdi.model.ICDIIntegralValue#biIntegerValue()
*/ */
public BigInteger bigIntegerValue() throws CDIException { public BigInteger bigIntegerValue() throws CDIException {
String valueString = getValueString(); return bigIntegerValue(getValueString());
}
public static BigInteger bigIntegerValue(String valueString) {
// Coming from a reference
if (valueString.startsWith("@")) { //$NON-NLS-1$
valueString = valueString.substring(1);
int colon = valueString.indexOf(':');
if (colon != -1) {
valueString = valueString.substring(colon + 1);
}
} else {
int space = valueString.indexOf(' '); int space = valueString.indexOf(' ');
if (space != -1) { if (space != -1) {
valueString = valueString.substring(0, space).trim(); valueString = valueString.substring(0, space).trim();
} }
}
try { try {
return MIFormat.getBigInteger(valueString); return MIFormat.getBigInteger(valueString);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
@ -52,68 +65,28 @@ public abstract class IntegralValue extends Value implements ICDIIntegralValue {
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIIntegralValue#longValue() * @see org.eclipse.cdt.debug.core.cdi.model.ICDIIntegralValue#longValue()
*/ */
public long longValue() throws CDIException { public long longValue() throws CDIException {
long value = 0; return bigIntegerValue().longValue();
String valueString = getValueString();
int space = valueString.indexOf(' ');
if (space != -1) {
valueString = valueString.substring(0, space).trim();
}
try {
value = MIFormat.getBigInteger(valueString).longValue();
} catch (NumberFormatException e) {
}
return value;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIIntegralValue#longValue() * @see org.eclipse.cdt.debug.core.cdi.model.ICDIIntegralValue#longValue()
*/ */
public int intValue() throws CDIException { public int intValue() throws CDIException {
int value = 0; return bigIntegerValue().intValue();
String valueString = getValueString();
int space = valueString.indexOf(' ');
if (space != -1) {
valueString = valueString.substring(0, space).trim();
}
try {
value = MIFormat.getBigInteger(valueString).intValue();
} catch (NumberFormatException e) {
}
return value;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIIntegralValue#shortValue() * @see org.eclipse.cdt.debug.core.cdi.model.ICDIIntegralValue#shortValue()
*/ */
public short shortValue() throws CDIException { public short shortValue() throws CDIException {
short value = 0; return bigIntegerValue().shortValue();
String valueString = getValueString();
int space = valueString.indexOf(' ');
if (space != -1) {
valueString = valueString.substring(0, space).trim();
}
try {
value = MIFormat.getBigInteger(valueString).shortValue();
} catch (NumberFormatException e) {
}
return value;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIIntegralValue#byteValue() * @see org.eclipse.cdt.debug.core.cdi.model.ICDIIntegralValue#byteValue()
*/ */
public int byteValue() throws CDIException { public int byteValue() throws CDIException {
byte value = 0; return bigIntegerValue().byteValue();
String valueString = getValueString();
int space = valueString.indexOf(' ');
if (space != -1) {
valueString = valueString.substring(0, space).trim();
}
try {
value = MIFormat.getBigInteger(valueString).byteValue();
} catch (NumberFormatException e) {
}
return value;
} }
} }

View file

@ -15,7 +15,6 @@ import java.math.BigInteger;
import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIPointerValue; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIPointerValue;
import org.eclipse.cdt.debug.mi.core.MIFormat;
import org.eclipse.cdt.debug.mi.core.cdi.model.Variable; import org.eclipse.cdt.debug.mi.core.cdi.model.Variable;
/** /**
@ -33,15 +32,6 @@ public class PointerValue extends DerivedValue implements ICDIPointerValue {
* @see org.eclipse.cdt.debug.core.cdi.model.type.ICDIPointerValue#pointerValue() * @see org.eclipse.cdt.debug.core.cdi.model.type.ICDIPointerValue#pointerValue()
*/ */
public BigInteger pointerValue() throws CDIException { public BigInteger pointerValue() throws CDIException {
String valueString = getValueString().trim(); return IntegralValue.bigIntegerValue(getValueString());
int space = valueString.indexOf(' ');
if (space != -1) {
valueString = valueString.substring(0, space).trim();
}
try {
return MIFormat.getBigInteger(valueString);
} catch(Exception e) {
return null;
}
} }
} }

View file

@ -11,11 +11,26 @@
package org.eclipse.cdt.debug.mi.core.cdi.model.type; package org.eclipse.cdt.debug.mi.core.cdi.model.type;
import java.math.BigInteger;
import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.model.ICDIValue;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIArrayType;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIBoolType;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDICharType;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIDoubleType;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIEnumType;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIFloatType;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIFunctionType;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIIntType;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDILongLongType;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDILongType;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIPointerType;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIReferenceType;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIReferenceValue; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIReferenceValue;
import org.eclipse.cdt.debug.mi.core.MIFormat; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIShortType;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIStructType;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIType;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIWCharType;
import org.eclipse.cdt.debug.mi.core.cdi.model.Value;
import org.eclipse.cdt.debug.mi.core.cdi.model.Variable; import org.eclipse.cdt.debug.mi.core.cdi.model.Variable;
/** /**
@ -35,21 +50,43 @@ public class ReferenceValue extends DerivedValue implements ICDIReferenceValue {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.model.type.ICDIReferenceValue#referenceValue() * @see org.eclipse.cdt.debug.core.cdi.model.type.ICDIReferenceValue#referenceValue()
*/ */
public BigInteger referenceValue() throws CDIException { public ICDIValue referenceValue() throws CDIException {
String valueString = getValueString().trim(); Value value = null;
if (valueString.startsWith("@")) { //$NON-NLS-1$ ICDIReferenceType rt = (ICDIReferenceType)getType();
valueString = valueString.substring(1); ICDIType t = rt.getComponentType();
if (t instanceof ICDIBoolType) {
value = new BoolValue(getVariable());
} else if (t instanceof ICDICharType) {
value = new CharValue(getVariable());
} else if (t instanceof ICDIWCharType) {
value = new WCharValue(getVariable());
} else if (t instanceof ICDIShortType) {
value = new ShortValue(getVariable());
} else if (t instanceof ICDIIntType) {
value = new IntValue(getVariable());
} else if (t instanceof ICDILongType) {
value = new LongValue(getVariable());
} else if (t instanceof ICDILongLongType) {
value = new LongLongValue(getVariable());
} else if (t instanceof ICDIEnumType) {
value = new EnumValue(getVariable());
} else if (t instanceof ICDIFloatType) {
value = new FloatValue(getVariable());
} else if (t instanceof ICDIDoubleType) {
value = new DoubleValue(getVariable());
} else if (t instanceof ICDIFunctionType) {
value = new FunctionValue(getVariable());
} else if (t instanceof ICDIPointerType) {
value = new PointerValue(getVariable());
// } else if (t instanceof ICDIReferenceType) {
// value = new ReferenceValue(getVariable());
} else if (t instanceof ICDIArrayType) {
value = new ArrayValue(getVariable());
} else if (t instanceof ICDIStructType) {
value = new StructValue(getVariable());
} else {
value = new Value(getVariable());
} }
int space = valueString.indexOf(":"); //$NON-NLS-1$ return value;
if (space != -1) {
valueString = valueString.substring(0, space).trim();
}
try {
return MIFormat.getBigInteger(valueString);
} catch(Exception e){
return null;
}
} }
} }

View file

@ -412,6 +412,8 @@ public class GDBTypeParser {
} }
} }
insertingChild(GDBType.ARRAY, len); insertingChild(GDBType.ARRAY, len);
} else if (tokenType == '&') {
insertingChild(GDBType.REFERENCE);
} else { } else {
// oops bad declaration ? // oops bad declaration ?
return; return;
@ -437,6 +439,24 @@ public class GDBTypeParser {
GDBTypeParser parser = new GDBTypeParser(); GDBTypeParser parser = new GDBTypeParser();
System.out.println("int *&"); //$NON-NLS-1$
parser.parse("int *&"); //$NON-NLS-1$
System.out.println(GDBTypeParser.unParse(parser.getGDBType()));
System.out.println(parser.getGDBType().verbose());
System.out.println();
System.out.println("int (&rg)(int)"); //$NON-NLS-1$
parser.parse("int (&rg)(int)"); //$NON-NLS-1$
System.out.println(GDBTypeParser.unParse(parser.getGDBType()));
System.out.println(parser.getGDBType().verbose());
System.out.println();
System.out.println("int (&ra)[3]"); //$NON-NLS-1$
parser.parse("int (&rg)[3]"); //$NON-NLS-1$
System.out.println(GDBTypeParser.unParse(parser.getGDBType()));
System.out.println(parser.getGDBType().verbose());
System.out.println();
System.out.println("struct link { int i; int j; struct link * next;} *"); //$NON-NLS-1$ System.out.println("struct link { int i; int j; struct link * next;} *"); //$NON-NLS-1$
parser.parse("struct link { int i; int j; struct link * next} *"); //$NON-NLS-1$ parser.parse("struct link { int i; int j; struct link * next} *"); //$NON-NLS-1$
System.out.println(GDBTypeParser.unParse(parser.getGDBType())); System.out.println(GDBTypeParser.unParse(parser.getGDBType()));

View file

@ -332,11 +332,16 @@ public class MIInferior extends Process {
CommandFactory factory = session.getCommandFactory(); CommandFactory factory = session.getCommandFactory();
CLIInfoProgram prog = factory.createCLIInfoProgram(); CLIInfoProgram prog = factory.createCLIInfoProgram();
try { try {
RxThread rxThread = session.getRxThread();
rxThread.setEnableConsole(false);
session.postCommand(prog); session.postCommand(prog);
CLIInfoProgramInfo info = prog.getMIInfoProgramInfo(); CLIInfoProgramInfo info = prog.getMIInfoProgramInfo();
pid = info.getPID(); pid = info.getPID();
} catch (MIException e) { } catch (MIException e) {
// no rethrown. // no rethrown.
} finally {
RxThread rxThread = session.getRxThread();
rxThread.setEnableConsole(true);
} }
} }
// We fail permantely. // We fail permantely.