From: hjk Date: Fri, 8 Apr 2011 13:38:50 +0000 (+0200) Subject: debugger: cleanup X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=63ebdb36232ce4088454752ed63364f14faae213;p=qt-creator-jp%2Fqt-creator-jp.git debugger: cleanup --- diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 9b11669ddd..bd68d7d2a2 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -329,6 +329,12 @@ void GdbEngine::readDebugeeOutput(const QByteArray &data) showMessage(msg, AppOutput); } +static bool isNameChar(char c) +{ + // could be 'stopped' or 'shlibs-added' + return (c >= 'a' && c <= 'z') || c == '-'; +} + void GdbEngine::handleResponse(const QByteArray &buff) { showMessage(QString::fromLocal8Bit(buff, buff.length()), LogOutput); diff --git a/src/plugins/debugger/watchdata.cpp b/src/plugins/debugger/watchdata.cpp index 705e54b602..81b7e0d49e 100644 --- a/src/plugins/debugger/watchdata.cpp +++ b/src/plugins/debugger/watchdata.cpp @@ -45,13 +45,6 @@ namespace Debugger { namespace Internal { -enum GuessChildrenResult -{ - HasChildren, - HasNoChildren, - HasPossiblyChildren -}; - static QString htmlEscape(const QString &plain) { QString rich; @@ -127,19 +120,6 @@ bool isIntOrFloatType(const QByteArray &type) return isIntType(type) || isFloatType(type); } -GuessChildrenResult guessChildren(const QByteArray &type) -{ - if (isIntOrFloatType(type)) - return HasNoChildren; - if (isCharPointerType(type)) - return HasNoChildren; - if (isPointerType(type)) - return HasChildren; - if (type.endsWith("QString")) - return HasNoChildren; - return HasPossiblyChildren; -} - WatchData::WatchData() : id(0), state(InitialState), @@ -234,6 +214,21 @@ void WatchData::setValueToolTip(const QString &tooltip) valuetooltip = tooltip; } +enum GuessChildrenResult { HasChildren, HasNoChildren, HasPossiblyChildren }; + +static GuessChildrenResult guessChildren(const QByteArray &type) +{ + if (isIntOrFloatType(type)) + return HasNoChildren; + if (isCharPointerType(type)) + return HasNoChildren; + if (isPointerType(type)) + return HasChildren; + if (type.endsWith("QString")) + return HasNoChildren; + return HasPossiblyChildren; +} + void WatchData::setType(const QByteArray &str, bool guessChildrenFromType) { type = str.trimmed(); diff --git a/src/plugins/debugger/watchutils.cpp b/src/plugins/debugger/watchutils.cpp index e3ca6f0248..5c74fa2c5b 100644 --- a/src/plugins/debugger/watchutils.cpp +++ b/src/plugins/debugger/watchutils.cpp @@ -496,18 +496,6 @@ QByteArray gdbQuoteTypes(const QByteArray &type) return result; } -QString extractTypeFromPTypeOutput(const QString &str) -{ - int pos0 = str.indexOf(QLatin1Char('=')); - int pos1 = str.indexOf(QLatin1Char('{')); - int pos2 = str.lastIndexOf(QLatin1Char('}')); - QString res = str; - if (pos0 != -1 && pos1 != -1 && pos2 != -1) - res = str.mid(pos0 + 2, pos1 - 1 - pos0) - + QLatin1String(" ... ") + str.right(str.size() - pos2); - return res.simplified(); -} - bool isSymbianIntType(const QByteArray &type) { return type == "TInt" || type == "TBool"; @@ -730,7 +718,7 @@ void setWatchDataValueEnabled(WatchData &data, const GdbMi &mi) data.valueEnabled = false; } -void setWatchDataValueEditable(WatchData &data, const GdbMi &mi) +static void setWatchDataValueEditable(WatchData &data, const GdbMi &mi) { if (mi.data() == "true") data.valueEditable = true; @@ -738,24 +726,35 @@ void setWatchDataValueEditable(WatchData &data, const GdbMi &mi) data.valueEditable = false; } -void setWatchDataExpression(WatchData &data, const GdbMi &mi) +static void setWatchDataExpression(WatchData &data, const GdbMi &mi) { if (mi.isValid()) data.exp = mi.data(); } +static void setWatchDataAddressHelper(WatchData &data, const QByteArray &addr) +{ + if (addr.startsWith("0x")) { // Item model dumpers pull tricks + data.setHexAddress(addr); + } else { + data.dumperFlags = addr; + } + if (data.exp.isEmpty() && !data.dumperFlags.startsWith('$')) + data.exp = "*(" + gdbQuoteTypes(data.type) + "*)" +data.hexAddress(); +} + void setWatchDataAddress(WatchData &data, const GdbMi &mi) { if (mi.isValid()) setWatchDataAddressHelper(data, mi.data()); } -void setWatchDataOrigAddress(WatchData &data, const GdbMi &mi) +static void setWatchDataOrigAddress(WatchData &data, const GdbMi &mi) { data.origAddress = mi.data().toULongLong(0, 16); } -void setWatchDataSize(WatchData &data, const GdbMi &mi) +static void setWatchDataSize(WatchData &data, const GdbMi &mi) { if (mi.isValid()) { bool ok = false; @@ -765,17 +764,6 @@ void setWatchDataSize(WatchData &data, const GdbMi &mi) } } -void setWatchDataAddressHelper(WatchData &data, const QByteArray &addr) -{ - if (addr.startsWith("0x")) { // Item model dumpers pull tricks - data.setHexAddress(addr); - } else { - data.dumperFlags = addr; - } - if (data.exp.isEmpty() && !data.dumperFlags.startsWith('$')) - data.exp = "*(" + gdbQuoteTypes(data.type) + "*)" +data.hexAddress(); -} - // Find the "type" and "displayedtype" children of root and set up type. void setWatchDataType(WatchData &data, const GdbMi &item) { diff --git a/src/plugins/debugger/watchutils.h b/src/plugins/debugger/watchutils.h index 5b4dd45e9d..4e59fcc5e4 100644 --- a/src/plugins/debugger/watchutils.h +++ b/src/plugins/debugger/watchutils.h @@ -36,11 +36,6 @@ #include #include -#include - -QT_BEGIN_NAMESPACE -class QDebug; -QT_END_NAMESPACE namespace TextEditor { class ITextEditor; @@ -84,12 +79,6 @@ QString currentTime(); bool isSkippableFunction(const QString &funcName, const QString &fileName); bool isLeavableFunction(const QString &funcName, const QString &fileName); -inline bool isNameChar(char c) -{ - // could be 'stopped' or 'shlibs-added' - return (c >= 'a' && c <= 'z') || c == '-'; -} - bool hasLetterOrNumber(const QString &exp); bool hasSideEffects(const QString &exp); bool isKeyWord(const QString &exp); @@ -98,15 +87,11 @@ bool isCharPointerType(const QByteArray &type); bool startsWithDigit(const QString &str); QByteArray stripPointerType(QByteArray type); QByteArray gdbQuoteTypes(const QByteArray &type); -QString extractTypeFromPTypeOutput(const QString &str); bool isFloatType(const QByteArray &type); bool isIntOrFloatType(const QByteArray &type); bool isIntType(const QByteArray &type); bool isSymbianIntType(const QByteArray &type); -enum GuessChildrenResult { HasChildren, HasNoChildren, HasPossiblyChildren }; -GuessChildrenResult guessChildren(const QByteArray &type); - QString quoteUnprintableLatin1(const QByteArray &ba); // Editor tooltip support @@ -124,9 +109,6 @@ bool getUninitializedVariables(const CPlusPlus::Snapshot &snapshot, const QString &function, const QString &file, int line, QStringList *uninitializedVariables); -// remove the default template argument in std:: containers -QString removeDefaultTemplateArguments(QString type); - // // GdbMi interaction @@ -137,10 +119,7 @@ void setWatchDataValueToolTip(WatchData &data, const GdbMi &mi, int encoding); void setWatchDataChildCount(WatchData &data, const GdbMi &mi); void setWatchDataValueEnabled(WatchData &data, const GdbMi &mi); -void setWatchDataValueEditable(WatchData &data, const GdbMi &mi); -void setWatchDataExpression(WatchData &data, const GdbMi &mi); void setWatchDataAddress(WatchData &data, const GdbMi &mi); -void setWatchDataAddressHelper(WatchData &data, const QByteArray &addr); void setWatchDataType(WatchData &data, const GdbMi &mi); void setWatchDataDisplayedType(WatchData &data, const GdbMi &mi);