diff --git a/share/qtcreator/gdbmacros/gdbmacros.cpp b/share/qtcreator/gdbmacros/gdbmacros.cpp index c7a68bc7d35cd1b96865996d17f3f5edd859fdb4..ecaee41ec3ac5bb0d663c64429c16ca2f9058bb7 100644 --- a/share/qtcreator/gdbmacros/gdbmacros.cpp +++ b/share/qtcreator/gdbmacros/gdbmacros.cpp @@ -57,16 +57,6 @@ #include <QtCore/QTextStream> #include <QtCore/QVector> -#ifndef Q_OS_WIN -# include <stdint.h> -#endif - -#if (QT_POINTER_SIZE==4) // How to printf/scanf a pointer (uintptr_t) -# define POINTER_PRINTFORMAT "0x%x" -#else -# define POINTER_PRINTFORMAT "0x%lx" -#endif - #ifndef QT_BOOTSTRAPPED #include <QtCore/QModelIndex> @@ -641,7 +631,9 @@ QDumper &QDumper::put(int i) QDumper &QDumper::put(const void *p) { if (p) { - pos += sprintf(outBuffer + pos, POINTER_PRINTFORMAT, reinterpret_cast<uintptr_t>(p)); + // Pointer is 'long long' on WIN_64, only + static const char *printFormat = sizeof(quintptr) == sizeof(long) ? "0x%lx" : "0x%llx"; + pos += sprintf(outBuffer + pos, printFormat, reinterpret_cast<uintptr_t>(p)); } else { pos += sprintf(outBuffer + pos, "<null>"); } @@ -1073,8 +1065,10 @@ static void qDumpQAbstractItem(QDumper &d) { ModelIndex *mm = reinterpret_cast<ModelIndex *>(&mi); mm->r = mm->c = 0; - mm->p = mm->m = 0; - sscanf(d.templateParameters[0], "%d,%d,"POINTER_PRINTFORMAT","POINTER_PRINTFORMAT, &mm->r, &mm->c, + mm->p = mm->m = 0; + static const char *printFormat = sizeof(quintptr) == sizeof(long) ? + "%d,%d,0x%lx,0x%lx" : "%d,%d,0x%llx,0x%llx"; + sscanf(d.templateParameters[0], printFormat, &mm->r, &mm->c, reinterpret_cast<uintptr_t*>(&mm->p), reinterpret_cast<uintptr_t*>(&mm->m)); } const QAbstractItemModel *m = mi.model(); @@ -2152,10 +2146,14 @@ static void qDumpQVariantHelper(const QVariant *v, QString *value, break; #endif default: { + static const char *qTypeFormat = sizeof(quintptr) == sizeof(long) ? + "'"NS"%s "NS"qVariantValue<"NS"%s >'(*('"NS"QVariant'*)0x%lx)" : + "'"NS"%s "NS"qVariantValue<"NS"%s >'(*('"NS"QVariant'*)0x%llx)"; + static const char *nonQTypeFormat = sizeof(quintptr) == sizeof(long) ? + "'%s "NS"qVariantValue<%s >'(*('"NS"QVariant'*)0x%lx)" : + "'%s "NS"qVariantValue<%s >'(*('"NS"QVariant'*)0x%llx)"; char buf[1000]; - const char *format = (v->typeName()[0] == 'Q') - ? "'"NS"%s "NS"qVariantValue<"NS"%s >'(*('"NS"QVariant'*)"POINTER_PRINTFORMAT")" - : "'%s "NS"qVariantValue<%s >'(*('"NS"QVariant'*)"POINTER_PRINTFORMAT")"; + const char *format = (v->typeName()[0] == 'Q') ? qTypeFormat : nonQTypeFormat; qsnprintf(buf, sizeof(buf) - 1, format, v->typeName(), v->typeName(), v); *exp = QLatin1String(buf); *numchild = 1; diff --git a/tests/auto/debugger/tst_dumpers.cpp b/tests/auto/debugger/tst_dumpers.cpp index eff6f97dbd211e7a171fb569d78a206035404141..129e487a8439cd8e5d48c54890a5600711e4bd8a 100644 --- a/tests/auto/debugger/tst_dumpers.cpp +++ b/tests/auto/debugger/tst_dumpers.cpp @@ -10,11 +10,10 @@ #include <QtTest/QtTest> //#include <QtTest/qtest_gui.h> -#if (QT_POINTER_SIZE==4) -# define POINTER_PRINTFORMAT "0x%x" -#else -# define POINTER_PRINTFORMAT "0x%lx" -#endif +static const char *pointerPrintFormat() +{ + return sizeof(quintptr) == sizeof(long) ? "0x%lx" : "0x%llx"; +} #undef NS #ifdef QT_NAMESPACE @@ -393,7 +392,7 @@ static void testDumper(QByteArray expected0, const void *data, QByteArray outert extraInt0, extraInt1, extraInt2, extraInt3); QString expected(expected0); char buf[100]; - sprintf(buf, POINTER_PRINTFORMAT, (uintptr_t)data); + sprintf(buf, pointerPrintFormat(), (uintptr_t)data); if ((!expected.startsWith('t') && !expected.startsWith('f')) || expected.startsWith("type")) expected = "tiname='$I',addr='$A'," + expected; @@ -423,7 +422,7 @@ static void testDumper(QByteArray expected0, const void *data, QByteArray outert QByteArray str(const void *p) { char buf[100]; - sprintf(buf, POINTER_PRINTFORMAT, (uintptr_t)p); + sprintf(buf, pointerPrintFormat(), (uintptr_t)p); return buf; } @@ -1975,7 +1974,7 @@ void tst_Debugger::dumpQObjectSignalList() "numchild='0',addr='$A',type='"NS"QObjectSignal'}," "{name='21',value='columnsMoved(QModelIndex,int,int,QModelIndex,int)'," "numchild='0',addr='$A',type='"NS"QObjectSignal'}]"; - + testDumper(expected << "0" << "0" << "0" << "0" << "0" << "0", &m, NS"QObjectSignalList", true);