forked from qt-creator/qt-creator
Debugger: split fixCppExpression into some common and some cdb part
Task-number: QTCREATORBUG-8446 Change-Id: I79abc7f75779db15bd8700c085b9cd57411bb2e1 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
This commit is contained in:
@@ -170,7 +170,8 @@ enum DebuggerCapabilities
|
||||
OperateByInstructionCapability = 0x400000,
|
||||
RunToLineCapability = 0x800000,
|
||||
MemoryAddressCapability = 0x1000000,
|
||||
ShowModuleSectionsCapability = 0x200000
|
||||
ShowModuleSectionsCapability = 0x200000,
|
||||
WatchComplexExpressionsCapability = 0x400000 // Used to filter out challenges for cdb.
|
||||
};
|
||||
|
||||
enum LogChannel
|
||||
|
||||
@@ -1166,7 +1166,10 @@ public slots:
|
||||
int line, column;
|
||||
exp = cppExpressionAt(textEditor, tc.position(), &line, &column);
|
||||
}
|
||||
exp = fixCppExpression(exp);
|
||||
if (currentEngine()->hasCapability(WatchComplexExpressionsCapability))
|
||||
exp = removeObviousSideEffects(exp);
|
||||
else
|
||||
exp = fixCppExpression(exp);
|
||||
if (exp.isEmpty())
|
||||
return;
|
||||
currentEngine()->watchHandler()->watchVariable(exp);
|
||||
|
||||
@@ -2132,6 +2132,7 @@ bool GdbEngine::hasCapability(unsigned cap) const
|
||||
| CatchCapability
|
||||
| OperateByInstructionCapability
|
||||
| RunToLineCapability
|
||||
| WatchComplexExpressionsCapability
|
||||
| MemoryAddressCapability))
|
||||
return true;
|
||||
|
||||
|
||||
@@ -820,7 +820,7 @@ QString cppExpressionAt(TextEditor::ITextEditor *editor, int pos,
|
||||
// free debugger expression.
|
||||
QString fixCppExpression(const QString &expIn)
|
||||
{
|
||||
QString exp = expIn;
|
||||
QString exp = expIn.trimmed();;
|
||||
// Extract the first identifier, everything else is considered
|
||||
// too dangerous.
|
||||
int pos1 = 0, pos2 = exp.size();
|
||||
@@ -838,7 +838,12 @@ QString fixCppExpression(const QString &expIn)
|
||||
}
|
||||
}
|
||||
exp = exp.mid(pos1, pos2 - pos1);
|
||||
return removeObviousSideEffects(exp);
|
||||
}
|
||||
|
||||
QString removeObviousSideEffects(const QString &expIn)
|
||||
{
|
||||
QString exp = expIn.trimmed();
|
||||
if (exp.isEmpty() || exp.startsWith(QLatin1Char('#')) || !hasLetterOrNumber(exp) || isKeyWord(exp))
|
||||
return QString();
|
||||
|
||||
|
||||
@@ -120,6 +120,7 @@ QString quoteUnprintableLatin1(const QByteArray &ba);
|
||||
bool isCppEditor(Core::IEditor *editor);
|
||||
QString cppExpressionAt(TextEditor::ITextEditor *editor, int pos,
|
||||
int *line, int *column, QString *function = 0);
|
||||
QString removeObviousSideEffects(const QString &exp);
|
||||
QString fixCppExpression(const QString &exp);
|
||||
QString cppFunctionAt(const QString &fileName, int line);
|
||||
// Decode string data as returned by the dumper helpers.
|
||||
|
||||
Reference in New Issue
Block a user