Ide/Debuggers/Gdb_MI2 : added simplifier for Upp::One

git-svn-id: svn://ultimatepp.org/upp/trunk@6958 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
micio 2014-02-26 12:30:27 +00:00
parent a9057816ce
commit 7da4c8be97
3 changed files with 78 additions and 16 deletions

View file

@ -992,10 +992,11 @@ void Gdb_MI2::SyncLocals()
// simplify batch
for(int iLoc = 0; iLoc < localVars.GetCount(); iLoc++)
{
while(localVars[iLoc].Simplify())
VarItem &v = localVars[iLoc];
while(v.Simplify())
RaiseIfStop();
VarItem &v = localVars[iLoc];
localExpressions.Set(iLoc, v.evaluableExpression);
localValues[iLoc] = v.value;
{
GuiLock __;
@ -1070,7 +1071,10 @@ void Gdb_MI2::SyncLocals(Vector<VarItem> localVars)
{
if(localVars[iLoc].Simplify())
{
locals.Set(iLoc, 1, localVars[iLoc].value);
VarItem &v = localVars[iLoc];
localExpressions.Set(iLoc, v.evaluableExpression);
localValues[iLoc] = v.value;
locals.Set(iLoc, 1, v.value);
SyncAutos();
timeCallback.Set(100, THISBACK1(SyncLocals, localVars));
return;
@ -1078,7 +1082,12 @@ void Gdb_MI2::SyncLocals(Vector<VarItem> localVars)
}
for(int iLoc = 0; iLoc < localVars.GetCount(); iLoc++)
locals.Set(iLoc, 1, localVars[iLoc].value);
{
VarItem &v = localVars[iLoc];
localExpressions.Set(iLoc, v.evaluableExpression);
localValues[iLoc] = v.value;
locals.Set(iLoc, 1, v.value);
}
// when finished, mark changed values
MarkChanged(prev, locals);
@ -1136,11 +1145,12 @@ void Gdb_MI2::SyncThis()
for(int iVar = 0; iVar < children.GetCount(); iVar++)
{
RaiseIfStop();
while(children[iVar].Simplify())
RaiseIfStop();
VarItem &v = children[iVar];
while(v.Simplify())
RaiseIfStop();
thisExpressions.Set(iVar, v.evaluableExpression);
thisValues[iVar] = v.value;
{
GuiLock __;
@ -1203,9 +1213,12 @@ void Gdb_MI2::SyncThis(Vector<VarItem> children)
// simplify batch
for(int iVar = 0; iVar < children.GetCount(); iVar++)
{
if(children[iVar].Simplify())
VarItem &v = children[iVar];
if(v.Simplify())
{
members.Set(iVar, 1, children[iVar].value);
thisExpressions.Set(iVar, v.evaluableExpression);
thisValues[iVar] = v.value;
members.Set(iVar, 1, v.value);
SyncAutos();
timeCallback.Set(100, THISBACK1(SyncThis, children));
return;
@ -1306,11 +1319,12 @@ void Gdb_MI2::SyncWatches()
for(int iWatch = 0; iWatch < watchesVars.GetCount(); iWatch++)
{
RaiseIfStop();
while(watchesVars[iWatch].Simplify())
VarItem &v = watchesVars[iWatch];
while(v.Simplify())
RaiseIfStop();
VarItem &v = watchesVars[iWatch];
watchesExpressions.Set(iWatch, v.evaluableExpression);
watchesValues[iWatch] = v.value;
{
GuiLock __;
@ -1360,14 +1374,22 @@ void Gdb_MI2::SyncWatches(Vector<VarItem> watchesVars)
{
if(watchesVars[iWatch].Simplify())
{
watches.Set(iWatch, 1, watchesVars[iWatch].value);
VarItem &v = watchesVars[iWatch];
watchesExpressions.Set(iWatch, v.evaluableExpression);
watchesValues[iWatch] = v.value;
watches.Set(iWatch, 1, v.value);
timeCallback.Set(100, THISBACK1(SyncWatches, watchesVars));
return;
}
}
for(int iWatch = 0; iWatch < watchesVars.GetCount(); iWatch++)
watches.Set(iWatch, 1, watchesVars[iWatch].value);
{
VarItem &v = watchesVars[iWatch];
watchesExpressions.Set(iWatch, v.evaluableExpression);
watchesValues[iWatch] = v.value;
watches.Set(iWatch, 1, v.value);
}
// when finished, mark changed values
MarkChanged(prev, watches);

View file

@ -33,7 +33,7 @@ static int UppStringSimplify(VarItem &varItem, int step)
} u;
// see Upp::String code for how it works....
MIValue val = varItem.EvaluateExpression(varItem.evaluableExpression + "." + "chr");
MIValue val = varItem.EvaluateExpression("(" + varItem.evaluableExpression + ")." + "chr");
if(!val.IsString())
return 0;
String chrs = val.ToString();
@ -49,7 +49,7 @@ static int UppStringSimplify(VarItem &varItem, int step)
else
{
dword len = u.w[LLEN];
MIValue val = varItem.EvaluateExpression(varItem.evaluableExpression + "." + "ptr[0]@" + FormatInt(len));
MIValue val = varItem.EvaluateExpression("(" + varItem.evaluableExpression + ").ptr[0]@" + FormatInt(len));
if(!val.IsString())
return 0;
s = val.ToString();
@ -433,6 +433,42 @@ static int UppIndexSimplify(VarItem &varItem, int step)
return step + 2;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static int UppOneSimplify(VarItem &varItem, int step)
{
// setup item type
varItem.kind = VarItem::COMPLEX;
// if we're just doing first scan phase, signal that we need further evaluation later
#ifdef EVALDEEP
if(!step)
// next step is 1
return 1;
#else
varItem.value = placeHolder;
return 0;
#endif
// de-reference and forward simplify
MIValue val = varItem.EvaluateExpression(varItem.evaluableExpression + "." + "ptr");
if(val.IsError() || !val.IsString())
{
varItem.value = "Upp::One<> = <can't evaluate contents>";
return 0;
}
String ptr = val.ToString();
if(ptr == "0x0")
{
varItem.value = "Upp::One<> = <EMPTY>";
return 0;
}
// replace variable with de-referenced one
VarItem vItem(&varItem.Debugger(), "*" + varItem.evaluableExpression + "." + "ptr");
varItem = vItem;
return varItem.GetSimplifyStep();
}
// Register the simplifiers
REGISTERSIMPLIFIER("Upp::String" , UppStringSimplify);
REGISTERSIMPLIFIER("Upp::Vector<" , UppVectorSimplify);
@ -440,3 +476,4 @@ REGISTERSIMPLIFIER("Upp::VectorMap<" , UppVectorMapSimplify);
REGISTERSIMPLIFIER("Upp::Array<" , UppArraySimplify);
REGISTERSIMPLIFIER("Upp::ArrayMap<" , UppArrayMapSimplify);
REGISTERSIMPLIFIER("Upp::Index<" , UppIndexSimplify);
REGISTERSIMPLIFIER("Upp::One<" , UppOneSimplify);

View file

@ -51,7 +51,7 @@ class VarItem : Moveable<VarItem>
// number of items for array and maps
int items;
// check if value contains an error
bool IsEmpty(void) const { return empty; }
bool operator!(void) const { return IsEmpty(); }
@ -68,6 +68,9 @@ class VarItem : Moveable<VarItem>
// deep simplify known types
bool Simplify(void);
// get next simplify step
int GetSimplifyStep(void) { return simplifyStep; }
// constructors
VarItem(Gdb_MI2 *dbg);