forked from qt-creator/qt-creator
Debugger[CDB]: Fix handling of shadowed variables.
Fix name formatting and algorithm to find uninitialized variables to use reverse order in case locals of the same name occur in a scope. Reviewed-by: hjk Task-number: QTCREATORBUG-4475
This commit is contained in:
@@ -1432,19 +1432,21 @@ void CdbEngine::updateLocals(bool forNewStackFrame)
|
||||
}
|
||||
}
|
||||
addLocalsOptions(str);
|
||||
// Uninitialized variables if desired
|
||||
// Uninitialized variables if desired. Quote as safeguard against shadowed
|
||||
// variables in case of errors in uninitializedVariables().
|
||||
if (debuggerCore()->boolSetting(UseCodeModel)) {
|
||||
QStringList uninitializedVariables;
|
||||
getUninitializedVariables(debuggerCore()->cppCodeModelSnapshot(),
|
||||
frame.function, frame.file, frame.line, &uninitializedVariables);
|
||||
if (!uninitializedVariables.isEmpty()) {
|
||||
str << blankSeparator << "-u ";
|
||||
str << blankSeparator << "-u \"";
|
||||
int i = 0;
|
||||
foreach(const QString &u, uninitializedVariables) {
|
||||
if (i++)
|
||||
str << ',';
|
||||
str << localsPrefixC << u;
|
||||
}
|
||||
str << '"';
|
||||
}
|
||||
}
|
||||
// Perform watches synchronization
|
||||
|
@@ -397,7 +397,7 @@ QString WatchData::shadowedName(const QString &name, int seen)
|
||||
{
|
||||
if (seen <= 0)
|
||||
return name;
|
||||
return shadowedNameFormat().arg(name, seen);
|
||||
return shadowedNameFormat().arg(name).arg(seen);
|
||||
}
|
||||
|
||||
quint64 WatchData::coreAddress() const
|
||||
|
@@ -338,8 +338,9 @@ static void blockRecursion(const CPlusPlus::Overview &overview,
|
||||
SeenHash *seenHash,
|
||||
int level = 0)
|
||||
{
|
||||
const int size = scope->memberCount();
|
||||
for (int s = 0; s < size; s++){
|
||||
// Go backwards in case someone has identical variables in the same scope.
|
||||
// Fixme: loop variables or similar are currently seen in the outer scope
|
||||
for (int s = scope->memberCount() - 1; s >= 0; --s){
|
||||
const CPlusPlus::Symbol *symbol = scope->memberAt(s);
|
||||
if (symbol->isDeclaration()) {
|
||||
// Find out about shadowed symbols by bookkeeping
|
||||
|
Reference in New Issue
Block a user