From 725d8dbfc6f298934f2b114f994eefea26e10e79 Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 18 Jun 2009 12:37:04 +0200 Subject: [PATCH 1/6] debugger: Prevent updateWatchData from being called multiple times. Each calls to fetchMore() was triggering an updateWatchData, and that can happen several times per user interaction. --- src/plugins/debugger/watchhandler.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index f9ae90d9cfe..21a09cc058e 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -81,16 +81,16 @@ static int generationCounter = 0; class WatchItem : public WatchData { public: - WatchItem() { parent = 0; fetched = 0; } + WatchItem() { parent = 0; fetchedTriggered = 0; } WatchItem(const WatchData &data) : WatchData(data) - { parent = 0; fetched = 0; } + { parent = 0; fetchedTriggered = 0; } void setData(const WatchData &data) { static_cast(*this) = data; } WatchItem *parent; - bool fetched; // children fetch has been triggered + bool fetchedTriggered; // children fetch has been triggered QList children; // fetched children }; @@ -309,7 +309,7 @@ WatchModel::WatchModel(WatchHandler *handler, WatchType type) item->childCount = 1; item->state = 0; item->parent = m_root; - item->fetched = true; + item->fetchedTriggered = true; m_root->children.append(item); } @@ -501,14 +501,15 @@ static QString niceType(QString type) bool WatchModel::canFetchMore(const QModelIndex &index) const { - return index.isValid() && !watchItem(index)->fetched; + return index.isValid() && !watchItem(index)->fetchedTriggered; } void WatchModel::fetchMore(const QModelIndex &index) { QTC_ASSERT(index.isValid(), return); - QTC_ASSERT(!watchItem(index)->fetched, return); + QTC_ASSERT(!watchItem(index)->fetchedTriggered, return); if (WatchItem *item = watchItem(index)) { + item->fetchedTriggered = true; WatchData data = *item; data.setChildrenNeeded(); emit m_handler->watchDataUpdateNeeded(data); From da6614ce6dcf9759779bcb314aa7195f8324db26 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Thu, 18 Jun 2009 12:58:06 +0200 Subject: [PATCH 2/6] Don't check for undefined symbols in ambiguous ast nodes. --- src/plugins/cpptools/cppmodelmanager.cpp | 28 ++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp index e8110c54dae..b00596df85c 100644 --- a/src/plugins/cpptools/cppmodelmanager.cpp +++ b/src/plugins/cpptools/cppmodelmanager.cpp @@ -529,6 +529,34 @@ protected: return true; } + virtual bool visit(BinaryExpressionAST *ast) + { + if (ast->right_expression) { + if (CastExpressionAST *right_cast_expr = ast->right_expression->asCastExpression()) { + if (right_cast_expr->type_id) { + if (TypeIdAST *right_cast_type_id = right_cast_expr->type_id->asTypeId()) { + SpecifierAST *type_specifier = right_cast_type_id->type_specifier; + if (! right_cast_type_id->declarator && type_specifier && ! type_specifier->next && + type_specifier->asNamedTypeSpecifier() && right_cast_expr->expression && + right_cast_expr->expression->asUnaryExpression()) { + // this ast node is ambigious, e.g. + // 1 + (a) + b + // it can be parsed as + // 1 + ((a) + b) + // or + // 1 + (a) (+b) + accept(ast->left_expression); + accept(right_cast_expr->expression); + return false; + } + } + } + } + } + + return true; + } + LookupContext lookupContext(unsigned line, unsigned column) const; private: From a595e8f4035b76012f8537aaf0f92751096e4c82 Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 18 Jun 2009 13:16:09 +0200 Subject: [PATCH 3/6] debugger: limit log window to 100000 lines. --- src/plugins/debugger/debuggeroutputwindow.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/debugger/debuggeroutputwindow.cpp b/src/plugins/debugger/debuggeroutputwindow.cpp index 518551185a7..a953abc502a 100644 --- a/src/plugins/debugger/debuggeroutputwindow.cpp +++ b/src/plugins/debugger/debuggeroutputwindow.cpp @@ -68,6 +68,7 @@ public: DebuggerPane(QWidget *parent) : QPlainTextEdit(parent) { + setMaximumBlockCount(100000); m_clearContentsAction = new QAction(this); m_clearContentsAction->setText(tr("Clear contents")); m_clearContentsAction->setEnabled(true); From d8b589ceffa9a7cc208b05305225a2d5907bcac8 Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 18 Jun 2009 13:22:58 +0200 Subject: [PATCH 4/6] debugger: remove QtGui dependency from debugging helpers It was only used for the watch-QImage-while-it-is-being-drawn-on feature, which does not seem overly useful. --- share/qtcreator/gdbmacros/gdbmacros.cpp | 34 +++++++++++++++---------- share/qtcreator/gdbmacros/gdbmacros.pro | 9 +++++++ src/plugins/debugger/dumper.pro | 8 ++++++ 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/share/qtcreator/gdbmacros/gdbmacros.cpp b/share/qtcreator/gdbmacros/gdbmacros.cpp index eed534ee8d4..4faf6470ac7 100644 --- a/share/qtcreator/gdbmacros/gdbmacros.cpp +++ b/share/qtcreator/gdbmacros/gdbmacros.cpp @@ -52,7 +52,13 @@ int qtGhVersion = QT_VERSION; -#ifdef QT_GUI_LIB +#ifndef USE_QT_GUI +# ifdef QT_GUI_LIB +# define USE_QT_GUI 1 +# endif +#endif + +#if USE_QT_GUI # include # include # include @@ -1296,9 +1302,9 @@ static void qDumpQHashNode(QDumper &d) d.disarm(); } +#if USE_QT_GUI static void qDumpQImage(QDumper &d) { -#ifdef QT_GUI_LIB const QImage &im = *reinterpret_cast(d.data); P(d, "value", "(" << im.width() << "x" << im.height() << ")"); P(d, "type", NS"QImage"); @@ -1312,14 +1318,12 @@ static void qDumpQImage(QDumper &d) d.endHash(); } d.disarm(); -#else - Q_UNUSED(d); -#endif } +#endif +#if USE_QT_GUI static void qDumpQImageData(QDumper &d) { -#ifdef QT_GUI_LIB const QImage &im = *reinterpret_cast(d.data); const QByteArray ba(QByteArray::fromRawData((const char*)im.bits(), im.numBytes())); P(d, "type", NS"QImageData"); @@ -1334,10 +1338,8 @@ static void qDumpQImageData(QDumper &d) P(d, "value", ba); #endif d.disarm(); -#else - Q_UNUSED(d); -#endif } +#endif static void qDumpQList(QDumper &d) { @@ -2020,18 +2022,16 @@ static void qDumpQObjectSlotList(QDumper &d) } +#if USE_QT_GUI static void qDumpQPixmap(QDumper &d) { -#ifdef QT_GUI_LIB const QPixmap &im = *reinterpret_cast(d.data); P(d, "value", "(" << im.width() << "x" << im.height() << ")"); P(d, "type", NS"QPixmap"); P(d, "numchild", "0"); d.disarm(); -#else - Q_UNUSED(d); -#endif } +#endif static void qDumpQSet(QDumper &d) { @@ -2691,10 +2691,12 @@ static void handleProtocolVersion2and3(QDumper & d) qDumpStdList(d); break; case 'I': + #if USE_QT_GUI if (isEqual(type, "QImage")) qDumpQImage(d); else if (isEqual(type, "QImageData")) qDumpQImageData(d); + #endif break; case 'L': if (isEqual(type, "QList")) @@ -2731,8 +2733,10 @@ static void handleProtocolVersion2and3(QDumper & d) qDumpQObjectSlotList(d); break; case 'P': + #if USE_QT_GUI if (isEqual(type, "QPixmap")) qDumpQPixmap(d); + #endif break; case 'S': if (isEqual(type, "QSet")) @@ -2854,7 +2858,9 @@ void *qDumpObjectData440( "\""NS"QVariant\"," "\""NS"QVector\"," "\""NS"QWeakPointer\"," +#if USE_QT_GUI "\""NS"QWidget\"," +#endif #ifdef Q_OS_WIN "\"basic_string\"," "\"list\"," @@ -2884,7 +2890,7 @@ void *qDumpObjectData440( << ""NS"QString=\"" << sizeof(QString) << "\"," << ""NS"QStringList=\"" << sizeof(QStringList) << "\"," << ""NS"QObject=\"" << sizeof(QObject) << "\"," -#ifdef QT_GUI_LIB +#if USE_QT_GUI << ""NS"QWidget=\"" << sizeof(QWidget)<< "\"," #endif #ifdef Q_OS_WIN diff --git a/share/qtcreator/gdbmacros/gdbmacros.pro b/share/qtcreator/gdbmacros/gdbmacros.pro index 5aacbfb84ad..67133e732e8 100644 --- a/share/qtcreator/gdbmacros/gdbmacros.pro +++ b/share/qtcreator/gdbmacros/gdbmacros.pro @@ -1,11 +1,20 @@ TEMPLATE = lib CONFIG += shared +QT = core linux-* { CONFIG -= release CONFIG += debug } SOURCES=gdbmacros.cpp +true { + DEFINES += USE_QT_GUI=0 + QT = core +} else { + DEFINES += USE_QT_GUI=1 + QT = core gui +} + exists($$QMAKE_INCDIR_QT/QtCore/private/qobject_p.h) { DEFINES+=HAS_QOBJECT_P_H } diff --git a/src/plugins/debugger/dumper.pro b/src/plugins/debugger/dumper.pro index 5d373abdd2d..fda9873f851 100644 --- a/src/plugins/debugger/dumper.pro +++ b/src/plugins/debugger/dumper.pro @@ -14,5 +14,13 @@ CONFIG += debug QMAKE_CXXFLAGS *= -O2 } +true { + DEFINES += USE_QT_GUI=0 + QT = core +} else { + DEFINES += USE_QT_GUI=1 + QT = core gui +} + SOURCES += ../../../share/qtcreator/gdbmacros/gdbmacros.cpp From 44aa96fcf5f7f9ff88d8eeaba0d64e3d7e228b6f Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Thu, 18 Jun 2009 14:13:44 +0200 Subject: [PATCH 5/6] Disable the undefined-type check for all the C-cast expressions. --- src/plugins/cpptools/cppmodelmanager.cpp | 35 ++++++++++-------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp index b00596df85c..b1ed719a365 100644 --- a/src/plugins/cpptools/cppmodelmanager.cpp +++ b/src/plugins/cpptools/cppmodelmanager.cpp @@ -529,27 +529,22 @@ protected: return true; } - virtual bool visit(BinaryExpressionAST *ast) + virtual bool visit(CastExpressionAST *ast) { - if (ast->right_expression) { - if (CastExpressionAST *right_cast_expr = ast->right_expression->asCastExpression()) { - if (right_cast_expr->type_id) { - if (TypeIdAST *right_cast_type_id = right_cast_expr->type_id->asTypeId()) { - SpecifierAST *type_specifier = right_cast_type_id->type_specifier; - if (! right_cast_type_id->declarator && type_specifier && ! type_specifier->next && - type_specifier->asNamedTypeSpecifier() && right_cast_expr->expression && - right_cast_expr->expression->asUnaryExpression()) { - // this ast node is ambigious, e.g. - // 1 + (a) + b - // it can be parsed as - // 1 + ((a) + b) - // or - // 1 + (a) (+b) - accept(ast->left_expression); - accept(right_cast_expr->expression); - return false; - } - } + if (ast->lparen_token && ast->type_id && ast->rparen_token && ast->expression) { + if (TypeIdAST *cast_type_id = ast->type_id->asTypeId()) { + SpecifierAST *type_specifier = cast_type_id->type_specifier; + if (! cast_type_id->declarator && type_specifier && ! type_specifier->next && + type_specifier->asNamedTypeSpecifier() && ast->expression && + ast->expression->asUnaryExpression()) { + // this ast node is ambigious, e.g. + // (a) + b + // it can be parsed as + // ((a) + b) + // or + // (a) (+b) + accept(ast->expression); + return false; } } } From 9a8e724f15a8a323299130e90c867f835cbf8ff8 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Thu, 18 Jun 2009 14:21:28 +0200 Subject: [PATCH 6/6] Don't search for undefined symbols in ambiguous typeof expressions. --- src/plugins/cpptools/cppmodelmanager.cpp | 18 ++++++++++++++++++ src/shared/cplusplus/AST.h | 2 ++ src/shared/cplusplus/Parser.cpp | 3 ++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp index b1ed719a365..cf7403953fc 100644 --- a/src/plugins/cpptools/cppmodelmanager.cpp +++ b/src/plugins/cpptools/cppmodelmanager.cpp @@ -552,6 +552,24 @@ protected: return true; } + virtual bool visit(SizeofExpressionAST *ast) + { + if (ast->lparen_token && ast->expression && ast->rparen_token) { + if (TypeIdAST *type_id = ast->expression->asTypeId()) { + SpecifierAST *type_specifier = type_id->type_specifier; + if (! type_id->declarator && type_specifier && ! type_specifier->next && + type_specifier->asNamedTypeSpecifier()) { + // this sizeof expression is ambiguos, e.g. + // sizeof (a) + // `a' can be a typeid or a nested-expression. + return false; + } + } + } + + return true; + } + LookupContext lookupContext(unsigned line, unsigned column) const; private: diff --git a/src/shared/cplusplus/AST.h b/src/shared/cplusplus/AST.h index 5869b1a14d6..bf4da2014a5 100644 --- a/src/shared/cplusplus/AST.h +++ b/src/shared/cplusplus/AST.h @@ -1980,7 +1980,9 @@ class CPLUSPLUS_EXPORT SizeofExpressionAST: public ExpressionAST { public: unsigned sizeof_token; + unsigned lparen_token; ExpressionAST *expression; + unsigned rparen_token; public: virtual SizeofExpressionAST *asSizeofExpression() diff --git a/src/shared/cplusplus/Parser.cpp b/src/shared/cplusplus/Parser.cpp index a2c0d2edda5..d70d8f40d77 100644 --- a/src/shared/cplusplus/Parser.cpp +++ b/src/shared/cplusplus/Parser.cpp @@ -3158,7 +3158,8 @@ bool Parser::parseUnaryExpression(ExpressionAST *&node) if (LA() == T_LPAREN) { unsigned lparen_token = consumeToken(); if (parseTypeId(ast->expression) && LA() == T_RPAREN) { - consumeToken(); + ast->lparen_token = lparen_token; + ast->rparen_token = consumeToken(); node = ast; return true; } else {