summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhjk <qtc-committer@nokia.com>2008-12-10 16:31:50 +0100
committerhjk <qtc-committer@nokia.com>2008-12-10 16:31:50 +0100
commit3b31b5c98ce1ef1cc5158326b77d96d484f81aeb (patch)
tree3f8553fe7cfa782276b8eee865585407c02aaa2a
parentfdfae53abbdf57235fa35b0cc6e23e5f1a2bf18d (diff)
downloadqt-creator-3b31b5c98ce1ef1cc5158326b77d96d484f81aeb.tar.gz
work on std::list dumper; also a bit of refactoring
-rw-r--r--bin/gdbmacros/gdbmacros.cpp155
-rw-r--r--tests/manual/gdbdebugger/simple/app.cpp72
2 files changed, 89 insertions, 138 deletions
diff --git a/bin/gdbmacros/gdbmacros.cpp b/bin/gdbmacros/gdbmacros.cpp
index e074ddd2a5..abca7066ee 100644
--- a/bin/gdbmacros/gdbmacros.cpp
+++ b/bin/gdbmacros/gdbmacros.cpp
@@ -407,12 +407,13 @@ struct QDumper
QDumper &operator<<(unsigned int i);
QDumper &operator<<(const void *p);
QDumper &operator<<(qulonglong c);
- void put(char c);
- void addCommaIfNeeded();
- void putBase64Encoded(const char *buf, int n);
QDumper &operator<<(const char *str);
QDumper &operator<<(const QByteArray &ba);
QDumper &operator<<(const QString &str);
+ void put(char c);
+ void addCommaIfNeeded();
+ void putBase64Encoded(const char *buf, int n);
+ void putEllipsis();
void disarm();
void beginHash(); // start of data hash output
@@ -658,6 +659,14 @@ void QDumper::endHash()
put('}');
}
+void QDumper::putEllipsis()
+{
+ d.beginHash();
+ P(d, "name", "Warning:");
+ P(d, "value", "<incomplete>");
+ P(d, "type", d.innertype);
+ d.endHash();
+}
//
// Some helpers to keep the dumper code short
@@ -816,6 +825,27 @@ static void qDumpInnerValue(QDumper &d, const char *type, const void *addr)
}
+static void qDumpInnerValueOrPointer(QDumper &d,
+ const char *type, const char *strippedtype, const void *addr)
+{
+ if (strippedtype) {
+ if (deref(addr)) {
+ P(d, "addr", deref(addr));
+ P(d, "type", strippedtype);
+ qDumpInnerValueHelper(d, strippedtype, deref(addr));
+ } else {
+ P(d, "addr", addr);
+ P(d, "type", strippedtype);
+ P(d, "value", "<null>");
+ P(d, "numchild", "0");
+ }
+ } else {
+ P(d, "addr", addr);
+ P(d, "type", type);
+ qDumpInnerValueHelper(d, type, addr);
+ }
+}
+
//////////////////////////////////////////////////////////////////////////////
static void qDumpQByteArray(QDumper &d)
@@ -1213,9 +1243,8 @@ static void qDumpQList(QDumper &d)
bool isInternal = innerSize <= int(sizeof(void*))
&& isMovableType(d.innertype);
- P(d, "internal", (int)isInternal);
-
- P(d, "childtype", d.innertype);
+ P(d, "internal", (int)isInternal);
+ P(d, "childtype", d.innertype);
if (n > 1000)
n = 1000;
d << ",children=[";
@@ -1245,11 +1274,8 @@ static void qDumpQList(QDumper &d)
}
d.endHash();
}
- if (n < nn) {
- d.beginHash();
- P(d, "value", "<incomplete>");
- d.endHash();
- }
+ if (n < nn)
+ d.putEllipsis();
d << "]";
}
d.disarm();
@@ -1491,7 +1517,6 @@ static void qDumpQObject(QDumper &d)
d.beginHash();
P(d, "name", "methods");
P(d, "exp", "*(class '"NS"QObject'*)" << d.data);
- P(d, "type", NS"QObjectMethodList");
P(d, "value", "<" << mo->methodCount() << " items>");
P(d, "numchild", mo->methodCount());
d.endHash();
@@ -1877,11 +1902,7 @@ static void qDumpQSet(QDumper &d)
d.endHash();
++i;
if (i > 10000) {
- d.beginHash();
- P(d, "name", "Warning:");
- P(d, "value", "<incomplete>");
- P(d, "type", "");
- d.endHash();
+ d.putEllipsis();
break;
}
}
@@ -1936,13 +1957,8 @@ static void qDumpQStringList(QDumper &d)
P(d, "valueencoded", "1");
d.endHash();
}
- if (n < list.size()) {
- d.beginHash();
- P(d, "name", "Warning:");
- P(d, "value", "<incomplete>");
- P(d, "type", "");
- d.endHash();
- }
+ if (n < list.size())
+ d.putEllipsis();
d << "]";
}
d.disarm();
@@ -2066,37 +2082,21 @@ static void qDumpQVector(QDumper &d)
P(d, "valuedisabled", "true");
P(d, "numchild", n);
if (d.dumpChildren) {
- bool innerTypeIsPointer = isPointerType(d.innertype);
QByteArray strippedInnerType = stripPointerType(d.innertype);
-
+ const char *stripped =
+ isPointerType(d.innertype) ? strippedInnerType.data() : 0;
if (n > 1000)
n = 1000;
d << ",children=[";
for (int i = 0; i != n; ++i) {
d.beginHash();
P(d, "name", "[" << i << "]");
- const void *p = addOffset(v, i * innersize + typeddatasize);
- if (innerTypeIsPointer) {
- if (deref(p)) {
- //P(d, "value","@" << p);
- qDumpInnerValue(d, strippedInnerType.data(), deref(p));
- } else {
- P(d, "type", d.innertype);
- P(d, "value", "<null>");
- P(d, "numchild", "0");
- }
- } else {
- qDumpInnerValue(d, d.innertype, p);
- }
- d.endHash();
- }
- if (n < nn) {
- d.beginHash();
- P(d, "name", "[...]");
- P(d, "value", "<incomplete>");
- P(d, "type", d.innertype);
+ qDumpInnerValueOrPointer(d, d.innertype, stripped,
+ addOffset(v, i * innersize + typeddatasize));
d.endHash();
}
+ if (n < nn)
+ d.putEllipsis();
d << "]";
}
d.disarm();
@@ -2111,23 +2111,17 @@ static void qDumpStdList(QDumper &d)
qCheckAccess(p);
p = deref(p);
qCheckAccess(p);
- p = deref(p);
- qCheckAccess(p);
p = deref(addOffset(d.data, sizeof(void*)));
qCheckAccess(p);
p = deref(addOffset(p, sizeof(void*)));
qCheckAccess(p);
p = deref(addOffset(p, sizeof(void*)));
qCheckAccess(p);
- p = deref(addOffset(p, sizeof(void*)));
- qCheckAccess(p);
int nn = 0;
std::list<int>::const_iterator it = list.begin();
- for (int i = 0; i < 101 && it != list.end(); ++i, ++it) {
+ for (nn < 101 && it != list.end(); ++nn, ++it)
qCheckAccess(it.operator->());
- ++nn;
- }
if (nn > 100)
P(d, "value", "<more than 100 items>");
@@ -2137,36 +2131,19 @@ static void qDumpStdList(QDumper &d)
P(d, "valuedisabled", "true");
if (d.dumpChildren) {
- unsigned innersize = d.extraInt[0];
- bool innerTypeIsPointer = isPointerType(d.innertype);
QByteArray strippedInnerType = stripPointerType(d.innertype);
+ const char *stripped =
+ isPointerType(d.innertype) ? strippedInnerType.data() : 0;
d << ",children=[";
std::list<int>::const_iterator it = list.begin();
for (int i = 0; i < 1000 && it != list.end(); ++i, ++it) {
d.beginHash();
P(d, "name", "[" << i << "]");
- P(d, "type", d.innertype);
- const void *p = it.operator->();
- if (innerTypeIsPointer) {
- if (deref(p)) {
- qDumpInnerValue(d, strippedInnerType.data(), deref(p));
- } else {
- P(d, "type", d.innertype);
- P(d, "value", "<null>");
- P(d, "numchild", "0");
- }
- } else {
- qDumpInnerValue(d, d.innertype, p);
- }
- d.endHash();
- }
- if (it != list.end()) {
- d.beginHash();
- P(d, "name", "[...]");
- P(d, "value", "<incomplete>");
- P(d, "type", d.innertype);
+ qDumpInnerValueOrPointer(d, d.innertype, stripped, it.operator->());
d.endHash();
}
+ if (it != list.end())
+ d.putEllipsis();
d << "]";
}
d.disarm();
@@ -2238,37 +2215,21 @@ static void qDumpStdVector(QDumper &d)
P(d, "numchild", n);
if (d.dumpChildren) {
unsigned innersize = d.extraInt[0];
- bool innerTypeIsPointer = isPointerType(d.innertype);
QByteArray strippedInnerType = stripPointerType(d.innertype);
-
+ const char *stripped =
+ isPointerType(d.innertype) ? strippedInnerType.data() : 0;
if (n > 1000)
n = 1000;
d << ",children=[";
for (int i = 0; i != n; ++i) {
d.beginHash();
P(d, "name", "[" << i << "]");
- const void *p = addOffset(v->start, i * innersize);
- if (innerTypeIsPointer) {
- if (deref(p)) {
- //P(d, "value","@" << p);
- qDumpInnerValue(d, strippedInnerType.data(), deref(p));
- } else {
- P(d, "type", d.innertype);
- P(d, "value", "<null>");
- P(d, "numchild", "0");
- }
- } else {
- qDumpInnerValue(d, d.innertype, p);
- }
- d.endHash();
- }
- if (n < nn) {
- d.beginHash();
- P(d, "name", "[...]");
- P(d, "value", "<incomplete>");
- P(d, "type", d.innertype);
+ qDumpInnerValueOrPointer(d, d.innertype, stripped,
+ addOffset(v->start, i * innersize));
d.endHash();
}
+ if (n < nn)
+ d.putEllipsis();
d << "]";
}
d.disarm();
diff --git a/tests/manual/gdbdebugger/simple/app.cpp b/tests/manual/gdbdebugger/simple/app.cpp
index 4dc0196195..35933ec5a2 100644
--- a/tests/manual/gdbdebugger/simple/app.cpp
+++ b/tests/manual/gdbdebugger/simple/app.cpp
@@ -129,7 +129,7 @@ void testArray()
}
-void testByteArray()
+void testQByteArray()
{
QByteArray ba = "Hello";
ba += '"';
@@ -140,7 +140,7 @@ void testByteArray()
}
-void testHash()
+void testQHash()
{
QHash<int, float> hgg0;
hgg0[11] = 11.0;
@@ -164,7 +164,7 @@ void testHash()
hash.insert(".", QPointer<QObject>(&ob));
}
-void testImage()
+void testQImage()
{
QImage im(QSize(200, 200), QImage::Format_RGB32);
im.fill(QColor(200, 100, 130).rgba());
@@ -192,7 +192,7 @@ void testIO()
}
-void testList()
+void testQList()
{
#if 1
QList<int> li;
@@ -254,7 +254,7 @@ void testList()
v.push_back("dd");
}
-void testMap()
+void testQMap()
{
QMap<uint, QStringList> ggl;
ggl[11] = QStringList() << "11";
@@ -289,7 +289,7 @@ void testMap()
#endif
}
-void testObject(int &argc, char *argv[])
+void testQObject(int &argc, char *argv[])
{
QApplication app(argc, argv);
QAction act("xxx", &app);
@@ -317,7 +317,7 @@ void testObject(int &argc, char *argv[])
app.exec();
}
-void testPixmap()
+void testQPixmap()
{
QImage im(QSize(200, 200), QImage::Format_RGB32);
im.fill(QColor(200, 100, 130).rgba());
@@ -353,7 +353,7 @@ void testPlugin()
}
}
-void testSet()
+void testQSet()
{
QSet<int> hgg0;
hgg0.insert(11);
@@ -506,7 +506,7 @@ void testStdVector()
vec.push_back(false);
}
-void testString()
+void testQString()
{
QString str = "Hello ";
str += " big, ";
@@ -516,19 +516,9 @@ void testString()
str += " World ";
str += " World ";
str += " World ";
- str += " World ";
- str += " World ";
- str += " World ";
- str += " World ";
- str += " World ";
- str += " World ";
- str += " World ";
- str += " World ";
- str += " World ";
- str += " World ";
}
-void testString3()
+void testQString3()
{
QString str = "Hello ";
str += " big, ";
@@ -544,7 +534,7 @@ void testString3()
delete pstring;
}
-void testStringList()
+void testQStringList()
{
QStringList l;
l << "Hello ";
@@ -578,7 +568,7 @@ private:
int m_id;
};
-void testThreads()
+void testQThread()
{
Thread thread1(1);
Thread thread2(2);
@@ -588,7 +578,7 @@ void testThreads()
thread2.wait();
}
-void testVariant1()
+void testQVariant1()
{
QVariant v;
v = 1;
@@ -597,7 +587,7 @@ void testVariant1()
v = 1;
}
-void testVariant2()
+void testQVariant2()
{
QVariant var;
#if 0
@@ -622,7 +612,7 @@ void testVariant2()
var.setValue(my);
}
-void testVariant3()
+void testQVariant3()
{
QList<int> list;
list << 1 << 2 << 3;
@@ -631,7 +621,7 @@ void testVariant3()
list = qVariantValue<QList<int> >(variant);
}
-void testVector()
+void testQVector()
{
QVector<Foo *> plist;
plist.append(new Foo(1));
@@ -652,7 +642,7 @@ void testVector()
vec.append(false);
}
-void testVectorOfList()
+void testQVectorOfQList()
{
QVector<QList<int> > v;
QVector<QList<int> > *pv = &v;
@@ -805,28 +795,28 @@ int main(int argc, char *argv[])
testStdVector();
testPlugin();
- testList();
+ testQList();
testNamespace();
//return 0;
- testByteArray();
- testHash();
- testImage();
- testMap();
- testString();
- testSet();
- testStringList();
+ testQByteArray();
+ testQHash();
+ testQImage();
+ testQMap();
+ testQString();
+ testQSet();
+ testQStringList();
testStruct();
//testThreads();
- testVariant1();
- testVariant2();
- testVariant3();
- testVector();
- testVectorOfList();
+ testQVariant1();
+ testQVariant2();
+ testQVariant3();
+ testQVector();
+ testQVectorOfQList();
*(int *)0 = 0;
- testObject(argc, argv);
+ testQObject(argc, argv);
//QColor color(255,128,10);