Commit 28d55264 authored by Friedemann Kleint's avatar Friedemann Kleint

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
parent ff58d996
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment