1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 09:25:31 +02:00

Bug 323630 - Expanding registers in the register view triggers an infinite recursion loop in Eclipse/CDI

This commit is contained in:
Anton Leherbauer 2010-09-08 07:04:58 +00:00
parent 6b44ff1ead
commit 4f83e760c3
6 changed files with 65 additions and 26 deletions

View file

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.cdt.debug.mi.core; singleton:=true
Bundle-Version: 7.0.0.qualifier
Bundle-Version: 7.1.0.qualifier
Bundle-Activator: org.eclipse.cdt.debug.mi.core.MIPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2008 QNX Software Systems and others.
* Copyright (c) 2000, 2010 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -449,10 +449,12 @@ public class RegisterManager extends Manager {
private Register findRegister(RegisterDescriptor rd) throws CDIException {
Target target = (Target)rd.getTarget();
String name = rd.getName();
String fullName = rd.getFullName();
int position = rd.getPosition();
Register[] regs = getRegisters(target);
for (int i = 0; i < regs.length; i++) {
if (regs[i].getName().equals(name)
&& regs[i].getFullName().equals(fullName)
&& regs[i].getCastingArrayStart() == rd.getCastingArrayStart()
&& regs[i].getCastingArrayEnd() == rd.getCastingArrayEnd()
&& VariableDescriptor.equalsCasting(regs[i], rd)) {

View file

@ -154,7 +154,12 @@ public abstract class Variable extends VariableDescriptor implements ICDIVariabl
return fMIVar;
}
private String getHexAddress() throws CDIException {
/**
* @return The address of this variable as hex string if available, otherwise an empty string.
* @noreference This method is not intended to be referenced by clients outside CDT.
* @since 7.1
*/
public String getHexAddress() throws CDIException {
if (hexAddress != null) {
return hexAddress;
}
@ -162,8 +167,13 @@ public abstract class Variable extends VariableDescriptor implements ICDIVariabl
String qualName = "&(" + getQualifiedName() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
VariableDescriptor desc = createDescriptor((Target)getTarget(), (Thread)getThread(), (StackFrame)getStackFrame(), getName(), qualName, getPosition(), getStackDepth());
Variable v = vm.createVariable( desc );
v.setFormat(ICDIFormat.HEXADECIMAL);
hexAddress = v.getValue().getValueString();
// make sure to avoid infinite recursion. see bug 323630
if (v != this) {
v.setFormat(ICDIFormat.HEXADECIMAL);
hexAddress = v.getValue().getValueString();
} else {
hexAddress = ""; //$NON-NLS-1$
}
return hexAddress;
}
@ -361,7 +371,7 @@ public abstract class Variable extends VariableDescriptor implements ICDIVariabl
} else if (t instanceof ICDIReferenceType) {
value = new ReferenceValue(this);
} else if (t instanceof ICDIArrayType) {
value = new ArrayValue(this, getHexAddress());
value = new ArrayValue(this);
} else if (t instanceof ICDIStructType) {
value = new StructValue(this);
} else {
@ -510,7 +520,8 @@ public abstract class Variable extends VariableDescriptor implements ICDIVariabl
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariableDescriptor#getTypeName()
*/
public String getTypeName() throws CDIException {
@Override
public String getTypeName() throws CDIException {
if (fTypename == null) {
fTypename = getMIVar().getType();
if (fTypename == null || fTypename.length() == 0) {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2009 QNX Software Systems and others.
* Copyright (c) 2000, 2010 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -34,6 +34,16 @@ public class ArrayValue extends DerivedValue implements ICDIArrayValue, ICDIPoin
private String hexAddress;
/**
* Construct the array value object given a variable
*
* @param v
* @since 7.1
*/
public ArrayValue(Variable v) {
super(v);
}
/**
* Construct the array value object given a variable and the
* hexadecimal address of the variable.
@ -41,21 +51,35 @@ public class ArrayValue extends DerivedValue implements ICDIArrayValue, ICDIPoin
* @param v
* @param hexAddress
*/
public ArrayValue(Variable v, String hexAddress) {
super(v);
if (hexAddress == null || hexAddress.trim().length()==0) {
return;
} else if (hexAddress.startsWith("0x") || hexAddress.startsWith("0X")) { //$NON-NLS-1$ //$NON-NLS-2$
this.hexAddress = hexAddress.substring(2);
} else {
this.hexAddress = hexAddress;
}
public ArrayValue(Variable v, String address) {
this(v);
hexAddress = address;
}
/**
* Compute array address as string.
*/
private String getAddressString() throws CDIException {
if (hexAddress != null)
return hexAddress;
String address = getVariable().getHexAddress();
if (address == null) {
address = ""; //$NON-NLS-1$
}
if (address.startsWith("0x") || address.startsWith("0X")) { //$NON-NLS-1$ //$NON-NLS-2$
hexAddress = address.substring(2);
} else {
hexAddress = address;
}
return hexAddress;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIValue#getVariables()
*/
public ICDIVariable[] getVariables() throws CDIException {
@Override
public ICDIVariable[] getVariables() throws CDIException {
/* GDB is appallingly slow on array fetches. As as slow as 128 entries
* per second on NT gdbs with slow processors. We need to set a timeout
@ -102,12 +126,14 @@ public class ArrayValue extends DerivedValue implements ICDIArrayValue, ICDIPoin
* @see org.eclipse.cdt.debug.core.cdi.model.type.ICDIPointerValue#pointerValue()
*/
public BigInteger pointerValue() throws CDIException {
if (hexAddress == null)
return null;
try {
return new BigInteger(hexAddress, 16);
} catch (NumberFormatException e) {
return null;
String address = getAddressString();
if (address.length() > 0 ){
try {
return new BigInteger(address, 16);
} catch (NumberFormatException e) {
return null;
}
}
return null;
}
}

View file

@ -2,7 +2,7 @@
<feature
id="org.eclipse.cdt.gnu.debug"
label="%featureName"
version="6.1.0.qualifier"
version="7.1.0.qualifier"
provider-name="%providerName">
<description>

View file

@ -39,7 +39,7 @@
<feature id="org.eclipse.cdt.gnu.build" url="features/org.eclipse.cdt.gnu.build_7.0.0.@timeStamp@.jar" version="7.0.0.@timeStamp@">
<category name="CDT Optional Features"/>
</feature>
<feature id="org.eclipse.cdt.gnu.debug" url="features/org.eclipse.cdt.gnu.debug_6.1.0.@timeStamp@.jar" version="6.1.0.@timeStamp@">
<feature id="org.eclipse.cdt.gnu.debug" url="features/org.eclipse.cdt.gnu.debug_7.1.0.@timeStamp@.jar" version="7.1.0.@timeStamp@">
<category name="CDT Optional Features"/>
</feature>
<feature id="org.eclipse.cdt.platform" url="features/org.eclipse.cdt.platform_7.1.0.@timeStamp@.jar" version="7.1.0.@timeStamp@">