mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-01 05:15:43 +02:00
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.
This commit is contained in:
parent
2aa6a140a7
commit
25006b66d6
1 changed files with 26 additions and 8 deletions
|
@ -48,6 +48,10 @@ import org.eclipse.cdt.debug.mi.core.output.MIVarUpdateInfo;
|
||||||
*/
|
*/
|
||||||
public class VariableManager extends SessionObject implements ICDIVariableManager {
|
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;
|
List variableList;
|
||||||
boolean autoupdate;
|
boolean autoupdate;
|
||||||
MIVarChange[] noChanges = new MIVarChange[0];
|
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)
|
* @see org.eclipse.cdt.debug.core.cdi.ICDIVariableManager#createArgument(ICDIArgumentObject)
|
||||||
*/
|
*/
|
||||||
public void update() throws CDIException {
|
public void update() throws CDIException {
|
||||||
|
int high = 0;
|
||||||
|
int low = 0;
|
||||||
List eventList = new ArrayList();
|
List eventList = new ArrayList();
|
||||||
Session session = (Session)getSession();
|
Session session = (Session)getSession();
|
||||||
MISession mi = session.getMISession();
|
MISession mi = session.getMISession();
|
||||||
|
@ -518,13 +524,21 @@ public class VariableManager extends SessionObject implements ICDIVariableManage
|
||||||
if (currentTarget != null) {
|
if (currentTarget != null) {
|
||||||
ICDIThread currentThread = currentTarget.getCurrentThread();
|
ICDIThread currentThread = currentTarget.getCurrentThread();
|
||||||
if (currentThread != null) {
|
if (currentThread != null) {
|
||||||
frames = currentThread.getStackFrames();
|
|
||||||
currentStack = currentThread.getCurrentStackFrame();
|
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++) {
|
for (int i = 0; i < vars.length; i++) {
|
||||||
Variable variable = vars[i];
|
Variable variable = vars[i];
|
||||||
if (isVariableNeedsUpdate(variable, currentStack, frames )) {
|
if (isVariableNeedsToBeUpdate(variable, currentStack, frames, low)) {
|
||||||
String varName = variable.getMIVar().getVarName();
|
String varName = variable.getMIVar().getVarName();
|
||||||
MIVarChange[] changes = noChanges;
|
MIVarChange[] changes = noChanges;
|
||||||
MIVarUpdate update = factory.createMIVarUpdate(varName);
|
MIVarUpdate update = factory.createMIVarUpdate(varName);
|
||||||
|
@ -563,7 +577,7 @@ public class VariableManager extends SessionObject implements ICDIVariableManage
|
||||||
* @param frames
|
* @param frames
|
||||||
* @return
|
* @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();
|
ICDIStackFrame varStack = variable.getStackFrame();
|
||||||
boolean inScope = false;
|
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
|
// The variable is in the current selected frame it should be updated
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
// Check if the Variable is still in Scope and below say yes
|
if (varStack.getLevel() >= low) {
|
||||||
// if it is no longer in scope so update() call call "-var-delete".
|
// Check if the Variable is still in Scope
|
||||||
for (int i = 0; i < frames.length; i++) {
|
// if it is no longer in scope so update() call call "-var-delete".
|
||||||
if (varStack.equals(frames[i])) {
|
for (int i = 0; i < frames.length; i++) {
|
||||||
inScope = true;
|
if (varStack.equals(frames[i])) {
|
||||||
|
inScope = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
inScope = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// return true if the variable is no longer in scope we
|
// return true if the variable is no longer in scope we
|
||||||
|
|
Loading…
Add table
Reference in a new issue