Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/debug
diff options
context:
space:
mode:
authorAlain Magloire2003-04-04 04:48:33 +0000
committerAlain Magloire2003-04-04 04:48:33 +0000
commit25006b66d67e2df9dd7b5299738f6682ef34f44b (patch)
treec47457145cf07491dfe68ff5eb79f275884f17ec /debug
parent2aa6a140a743c11f8822713969a38578d635ebc0 (diff)
downloadorg.eclipse.cdt-25006b66d67e2df9dd7b5299738f6682ef34f44b.tar.gz
org.eclipse.cdt-25006b66d67e2df9dd7b5299738f6682ef34f44b.tar.xz
org.eclipse.cdt-25006b66d67e2df9dd7b5299738f6682ef34f44b.zip
Put a limit of the number of stack to examine
when updating the variables if not it may crash gdb for very deep recursive calls.
Diffstat (limited to 'debug')
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/VariableManager.java34
1 files changed, 26 insertions, 8 deletions
diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/VariableManager.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/VariableManager.java
index e0163396611..a3905df2719 100644
--- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/VariableManager.java
+++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/VariableManager.java
@@ -48,6 +48,10 @@ import org.eclipse.cdt.debug.mi.core.output.MIVarUpdateInfo;
*/
public class VariableManager extends SessionObject implements ICDIVariableManager {
+ // We put a restriction on how deep we want to
+ // go when doing update of the variables.
+ // If the number is to high, gdb will just hang.
+ int MAX_STACK_DEPTH = 200;
List variableList;
boolean autoupdate;
MIVarChange[] noChanges = new MIVarChange[0];
@@ -507,6 +511,8 @@ public class VariableManager extends SessionObject implements ICDIVariableManage
* @see org.eclipse.cdt.debug.core.cdi.ICDIVariableManager#createArgument(ICDIArgumentObject)
*/
public void update() throws CDIException {
+ int high = 0;
+ int low = 0;
List eventList = new ArrayList();
Session session = (Session)getSession();
MISession mi = session.getMISession();
@@ -518,13 +524,21 @@ public class VariableManager extends SessionObject implements ICDIVariableManage
if (currentTarget != null) {
ICDIThread currentThread = currentTarget.getCurrentThread();
if (currentThread != null) {
- frames = currentThread.getStackFrames();
currentStack = currentThread.getCurrentStackFrame();
+ high = currentStack.getLevel();
+ if (high > 0) {
+ high--;
+ }
+ low = high - MAX_STACK_DEPTH;
+ if (low < 0) {
+ low = 0;
+ }
+ frames = currentThread.getStackFrames(low, high);
}
}
for (int i = 0; i < vars.length; i++) {
Variable variable = vars[i];
- if (isVariableNeedsUpdate(variable, currentStack, frames )) {
+ if (isVariableNeedsToBeUpdate(variable, currentStack, frames, low)) {
String varName = variable.getMIVar().getVarName();
MIVarChange[] changes = noChanges;
MIVarUpdate update = factory.createMIVarUpdate(varName);
@@ -563,7 +577,7 @@ public class VariableManager extends SessionObject implements ICDIVariableManage
* @param frames
* @return
*/
- boolean isVariableNeedsUpdate(Variable variable, ICDIStackFrame current, ICDIStackFrame[] frames) throws CDIException {
+ boolean isVariableNeedsToBeUpdate(Variable variable, ICDIStackFrame current, ICDIStackFrame[] frames, int low) throws CDIException {
ICDIStackFrame varStack = variable.getStackFrame();
boolean inScope = false;
@@ -579,12 +593,16 @@ public class VariableManager extends SessionObject implements ICDIVariableManage
// The variable is in the current selected frame it should be updated
return true;
} else {
- // Check if the Variable is still in Scope and below say yes
- // if it is no longer in scope so update() call call "-var-delete".
- for (int i = 0; i < frames.length; i++) {
- if (varStack.equals(frames[i])) {
- inScope = true;
+ if (varStack.getLevel() >= low) {
+ // Check if the Variable is still in Scope
+ // if it is no longer in scope so update() call call "-var-delete".
+ for (int i = 0; i < frames.length; i++) {
+ if (varStack.equals(frames[i])) {
+ inScope = true;
+ }
}
+ } else {
+ inScope = true;
}
}
// return true if the variable is no longer in scope we

Back to the top