diff --git a/src/plugins/debugger/cdb/cdbstacktracecontext.cpp b/src/plugins/debugger/cdb/cdbstacktracecontext.cpp index 7a1448d708fe93ad68f32effd7d92e466b11a4cb..90329dfe04fbfbc34bf5b41d0fbe5b672353851b 100644 --- a/src/plugins/debugger/cdb/cdbstacktracecontext.cpp +++ b/src/plugins/debugger/cdb/cdbstacktracecontext.cpp @@ -88,6 +88,7 @@ bool CdbStackTraceContext::init(unsigned long frameCount, QString * /*errorMessa if (debugCDB) qDebug() << Q_FUNC_INFO << frameCount; + const QChar exclamationMark = QLatin1Char('!'); m_frameContexts.resize(frameCount); qFill(m_frameContexts, static_cast<CdbStackFrameContext*>(0)); @@ -102,7 +103,11 @@ bool CdbStackTraceContext::init(unsigned long frameCount, QString * /*errorMessa frame.address = QString::fromLatin1("0x%1").arg(instructionOffset, 0, 16); m_cif->debugSymbols->GetNameByOffsetWide(instructionOffset, wszBuf, MAX_PATH, 0, 0); + // Determine function and module, if available frame.function = QString::fromUtf16(reinterpret_cast<const ushort *>(wszBuf)); + const int moduleSepPos = frame.function.indexOf(exclamationMark); + if (moduleSepPos != -1) + frame.from = frame.function.mid(0, moduleSepPos); ULONG ulLine; ULONG64 ul64Displacement; diff --git a/src/plugins/debugger/watchutils.cpp b/src/plugins/debugger/watchutils.cpp index e7d52147aa9705ed0d668cc48b8b426f81a9cdd3..55e03207bdb65d8a1bda5e6134e6760f06205164 100644 --- a/src/plugins/debugger/watchutils.cpp +++ b/src/plugins/debugger/watchutils.cpp @@ -365,16 +365,24 @@ int getUninitializedVariablesI(const CPlusPlus::Snapshot &snapshot, const CPlusPlus::Symbol *symbolAtLine = doc->findSymbolAt(line, 0); if (!symbolAtLine) return 4; - // First figure out the function to do a safety name check. + // First figure out the function to do a safety name check + // and the innermost scope at cursor position const CPlusPlus::Function *function = 0; - const bool hitFunction = symbolAtLine->isFunction(); - if (hitFunction) { + const CPlusPlus::Scope *innerMostScope = 0; + if (symbolAtLine->isFunction()) { function = symbolAtLine->asFunction(); + if (function->memberCount() == 1) // Skip over function block + if (CPlusPlus::Block *block = function->memberAt(0)->asBlock()) + innerMostScope = block->members(); } else { - if (CPlusPlus::Scope *functionScope = symbolAtLine->enclosingFunctionScope()) + if (const CPlusPlus::Scope *functionScope = symbolAtLine->enclosingFunctionScope()) { function = functionScope->owner()->asFunction(); + innerMostScope = symbolAtLine->isBlock() ? + symbolAtLine->asBlock()->members() : + symbolAtLine->enclosingBlockScope(); + } } - if (!function) + if (!function || !innerMostScope) return 7; // Compare function names with a bit off fuzz, // skipping modules from a CDB symbol "lib!foo" or namespaces @@ -388,13 +396,7 @@ int getUninitializedVariablesI(const CPlusPlus::Snapshot &snapshot, if (previousChar != ':' && previousChar != '!' ) return 11; } - // Starting from the innermost block scope, collect - // declarations. - const CPlusPlus::Scope *innerMostScope = hitFunction ? - symbolAtLine->asFunction()->members() : - symbolAtLine->enclosingBlockScope(); - if (!innerMostScope) - return 15; + // Starting from the innermost block scope, collect declarations. SeenHash seenHash; blockRecursion(overview, innerMostScope, line, uninitializedVariables, &seenHash); return 0;