From c00bb1dcfb9aeeb67ec5418db0b885f56b2cb45c Mon Sep 17 00:00:00 2001 From: David Schulz Date: Thu, 30 Mar 2017 09:15:48 +0200 Subject: [PATCH] Debugger: Pass uninitialized variables to the python dumpers Reduces accessing uninitialized memory Change-Id: I025e9070b9b17a806237619b484cb27230e7f494 Reviewed-by: Christian Stenger --- share/qtcreator/debugger/cdbbridge.py | 5 +++-- share/qtcreator/debugger/dumper.py | 2 ++ src/plugins/debugger/cdb/cdbengine.cpp | 7 +++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/share/qtcreator/debugger/cdbbridge.py b/share/qtcreator/debugger/cdbbridge.py index 51089fdfa12..a3ed899e2ad 100644 --- a/share/qtcreator/debugger/cdbbridge.py +++ b/share/qtcreator/debugger/cdbbridge.py @@ -125,7 +125,6 @@ class Dumper(DumperBase): pass val.isBaseClass = val.name == val.type.name val.nativeValue = nativeValue - val.lIsInScope = True val.laddress = nativeValue.address() return val @@ -440,7 +439,9 @@ class Dumper(DumperBase): variables = [] for val in cdbext.listOfLocals(self.partialVariable): - variables.append(self.fromNativeValue(val)) + dumperVal = self.fromNativeValue(val) + dumperVal.lIsInScope = not dumperVal.name in self.uninitialized + variables.append(dumperVal) self.handleLocals(variables) self.handleWatches(args) diff --git a/share/qtcreator/debugger/dumper.py b/share/qtcreator/debugger/dumper.py index 6808dd7d6a4..2d814e76f46 100644 --- a/share/qtcreator/debugger/dumper.py +++ b/share/qtcreator/debugger/dumper.py @@ -317,6 +317,8 @@ class DumperBase: self.nativeMixed = int(args.get('nativemixed', '0')) self.autoDerefPointers = int(args.get('autoderef', '0')) self.partialVariable = args.get('partialvar', '') + self.uninitialized = args.get('uninitialized', []) + self.uninitialized = list(map(lambda x: self.hexdecode(x), self.uninitialized)) self.partialUpdate = int(args.get('partial', '0')) self.fallbackQtVersion = 0x50200 #warn('NAMESPACE: "%s"' % self.qtNamespace()) diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index 3531e882a68..4711b59b909 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -1238,6 +1238,13 @@ void CdbEngine::doUpdateLocals(const UpdateParameters &updateParameters) cmd.arg("stringcutoff", action(MaximalStringLength)->value().toString()); cmd.arg("displaystringlimit", action(DisplayStringLimit)->value().toString()); + if (boolSetting(UseCodeModel)) { + QStringList uninitializedVariables; + getUninitializedVariables(Internal::cppCodeModelSnapshot(), + frame.function, frame.file, frame.line, &uninitializedVariables); + cmd.arg("uninitialized", uninitializedVariables); + } + cmd.callback = [this](const DebuggerResponse &response) { if (response.resultClass == ResultDone) { showMessage(response.data.toString(), LogMisc);