debugger: update manual tests

Change-Id: I88b980d4bd8c6ad7af34b6cf28cdea196d1e56d2
Reviewed-on: http://codereview.qt.nokia.com/3101
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
hjk
2011-08-17 14:54:31 +02:00
committed by hjk
parent 879766d85c
commit a946538089
2 changed files with 275 additions and 303 deletions

View File

@@ -33,93 +33,98 @@
#ifndef SIMPLE_DEBUGGER_TEST_H #ifndef SIMPLE_DEBUGGER_TEST_H
#define SIMPLE_DEBUGGER_TEST_H #define SIMPLE_DEBUGGER_TEST_H
struct SomeClassWithInlineConstructor namespace breakpoints {
{
SomeClassWithInlineConstructor() struct SomeClassWithInlineConstructor
{ {
a = 21; SomeClassWithInlineConstructor()
} {
int a; a = 21;
}; }
int a;
};
struct SomeBaseClassWithInlineConstructor struct SomeBaseClassWithInlineConstructor
{
SomeBaseClassWithInlineConstructor()
{ {
a = 21; SomeBaseClassWithInlineConstructor()
} {
virtual ~SomeBaseClassWithInlineConstructor(); a = 21;
int a; }
}; virtual ~SomeBaseClassWithInlineConstructor();
int a;
};
struct SomeDerivedClassWithInlineConstructor struct SomeDerivedClassWithInlineConstructor
: SomeBaseClassWithInlineConstructor : SomeBaseClassWithInlineConstructor
{
SomeDerivedClassWithInlineConstructor()
{ {
a = 21; SomeDerivedClassWithInlineConstructor()
} {
virtual ~SomeDerivedClassWithInlineConstructor(); a = 21;
int a; }
}; virtual ~SomeDerivedClassWithInlineConstructor();
int a;
};
template <class T> template <class T>
struct SomeTemplatedClassWithInlineConstructor struct SomeTemplatedClassWithInlineConstructor
{
SomeTemplatedClassWithInlineConstructor()
{ {
a = 21; SomeTemplatedClassWithInlineConstructor()
} {
T a; a = 21;
}; }
T a;
};
template <class T> template <class T>
struct SomeTemplatedBaseClassWithInlineConstructor struct SomeTemplatedBaseClassWithInlineConstructor
{
SomeTemplatedBaseClassWithInlineConstructor()
{ {
a = 21; SomeTemplatedBaseClassWithInlineConstructor()
} {
virtual ~SomeTemplatedBaseClassWithInlineConstructor(); a = 21;
}
virtual ~SomeTemplatedBaseClassWithInlineConstructor();
T a; T a;
}; };
template <class T> template <class T>
struct SomeTemplatedDerivedClassWithInlineConstructor struct SomeTemplatedDerivedClassWithInlineConstructor
: SomeTemplatedBaseClassWithInlineConstructor<T> : SomeTemplatedBaseClassWithInlineConstructor<T>
{
SomeTemplatedDerivedClassWithInlineConstructor()
{ {
a = 21; SomeTemplatedDerivedClassWithInlineConstructor()
{
a = 21;
}
virtual ~SomeTemplatedDerivedClassWithInlineConstructor();
T a;
};
SomeBaseClassWithInlineConstructor::~SomeBaseClassWithInlineConstructor() {}
SomeDerivedClassWithInlineConstructor::~SomeDerivedClassWithInlineConstructor() {}
template <typename T>
SomeTemplatedBaseClassWithInlineConstructor<T>::
~SomeTemplatedBaseClassWithInlineConstructor() {}
template <typename T>
SomeTemplatedDerivedClassWithInlineConstructor<T>::
~SomeTemplatedDerivedClassWithInlineConstructor() {}
void testBreakpoints()
{
SomeClassWithInlineConstructor a;
SomeBaseClassWithInlineConstructor b;
SomeDerivedClassWithInlineConstructor c;
SomeTemplatedClassWithInlineConstructor<int> d;
SomeTemplatedBaseClassWithInlineConstructor<int> e;
SomeTemplatedDerivedClassWithInlineConstructor<int> f;
// <=== Break here.
dummyStatement(&a, &b, &c);
dummyStatement(&d, &e, &f);
} }
virtual ~SomeTemplatedDerivedClassWithInlineConstructor();
T a;
};
} // namespace breakpoints
SomeBaseClassWithInlineConstructor::~SomeBaseClassWithInlineConstructor() {}
SomeDerivedClassWithInlineConstructor::~SomeDerivedClassWithInlineConstructor() {}
template <typename T>
SomeTemplatedBaseClassWithInlineConstructor<T>::
~SomeTemplatedBaseClassWithInlineConstructor() {}
template <typename T>
SomeTemplatedDerivedClassWithInlineConstructor<T>::
~SomeTemplatedDerivedClassWithInlineConstructor() {}
void testInlineBreakpoints()
{
SomeClassWithInlineConstructor a;
SomeBaseClassWithInlineConstructor b;
SomeDerivedClassWithInlineConstructor c;
SomeTemplatedClassWithInlineConstructor<int> d;
SomeTemplatedBaseClassWithInlineConstructor<int> e;
SomeTemplatedDerivedClassWithInlineConstructor<int> f;
int i = a.a + b.a + c.a + d.a + e.a + f.a;
++i;
}
#endif // SIMPLE_DEBUGGER_TEST_H #endif // SIMPLE_DEBUGGER_TEST_H

View File

@@ -34,6 +34,8 @@
//template <typename T> class B; B foo() {} //template <typename T> class B; B foo() {}
void dummyStatement(const void * = 0, const void * = 0, const void * = 0) {}
#include "../simple/deep/deep/simple_gdbtest_app.h" #include "../simple/deep/deep/simple_gdbtest_app.h"
#include <QtCore/QDebug> #include <QtCore/QDebug>
@@ -125,13 +127,6 @@
#include <stddef.h> #include <stddef.h>
#endif #endif
void dummyStatement(const void *x = 0, const void *y = 0, const void *z = 0)
{
Q_UNUSED(x);
Q_UNUSED(y);
Q_UNUSED(z);
}
namespace multibp { namespace multibp {
template <typename T> class Vector template <typename T> class Vector
@@ -370,17 +365,6 @@ class D : public X, public Y
int diamond; int diamond;
}; };
#ifndef Q_CC_RVCT
struct TestAnonymous
{
union {
struct { int i; int b; };
struct { float f; };
double d;
};
};
#endif
void testPeekAndPoke3() void testPeekAndPoke3()
{ {
// Anonymous structs // Anonymous structs
@@ -430,45 +414,58 @@ void testPeekAndPoke3()
} }
#ifndef Q_CC_RVCT namespace anon {
namespace { // anon
struct Something #ifndef Q_CC_RVCT
{ struct TestAnonymous
Something() { a = b = 1; }
void foo()
{ {
a = 42; union {
b = 43; struct { int i; int b; };
struct { float f; };
double d;
};
};
namespace {
struct Something
{
Something() { a = b = 1; }
void foo()
{
a = 42;
b = 43;
}
int a, b;
};
}
#endif
void testAnonymous()
{
#ifndef Q_CC_RVCT
TestAnonymous a;
a.i = 1;
a.i = 2;
a.i = 3;
Something s;
// <== Break here.
// Step.
s.foo();
dummyStatement(&a, &s);
#endif
} }
int a, b; } // namespace anon
};
} // anon
#endif
void testAnonymous()
{
#ifndef Q_CC_RVCT
TestAnonymous a;
a.i = 1;
a.i = 2;
a.i = 3;
Q_UNUSED(a);
Something s;
s.foo();
Q_UNUSED(s);
#endif
}
typedef void (*func_t)(); typedef void (*func_t)();
func_t testFunctionPointer() func_t testFunctionPointer()
{ {
func_t f1 = testAnonymous; func_t f1 = anon::testAnonymous;
func_t f2 = testPeekAndPoke3; func_t f2 = testPeekAndPoke3;
func_t f3 = testPeekAndPoke3; func_t f3 = testPeekAndPoke3;
Q_UNUSED(f1); Q_UNUSED(f1);
@@ -478,6 +475,7 @@ func_t testFunctionPointer()
} }
namespace qbytearray { namespace qbytearray {
void testQByteArray1() void testQByteArray1()
@@ -1653,15 +1651,19 @@ namespace stdvector {
v.push_back(2); v.push_back(2);
v.push_back(3); v.push_back(3);
v.push_back(4); v.push_back(4);
// <=== Break here.
dummyStatement(&v); dummyStatement(&v);
} }
void testStdVector3() void testStdVector3()
{ {
Foo f;
std::vector<Foo *> v; std::vector<Foo *> v;
v.push_back(new Foo(1)); v.push_back(new Foo(1));
v.push_back(0); v.push_back(0);
v.push_back(new Foo(2)); v.push_back(new Foo(2));
// <=== Break here.
// Expand v.[0].x
dummyStatement(&v); dummyStatement(&v);
} }
@@ -1672,6 +1674,8 @@ namespace stdvector {
flist.push_back(2); flist.push_back(2);
flist.push_back(3); flist.push_back(3);
flist.push_back(4); flist.push_back(4);
// <=== Break here.
// Expand v.[0].x
dummyStatement(&flist); dummyStatement(&flist);
} }
@@ -1683,6 +1687,7 @@ namespace stdvector {
vec.push_back(false); vec.push_back(false);
vec.push_back(true); vec.push_back(true);
vec.push_back(false); vec.push_back(false);
// <=== Break here.
dummyStatement(&vec); dummyStatement(&vec);
} }
@@ -1695,6 +1700,7 @@ namespace stdvector {
list.push_back(45); list.push_back(45);
vector.push_back(new std::list<int>(list)); vector.push_back(new std::list<int>(list));
vector.push_back(0); vector.push_back(0);
// <=== Break here.
dummyStatement(&vector, &list); dummyStatement(&vector, &list);
} }
@@ -1764,17 +1770,6 @@ void testQUrl()
(void) url; (void) url;
} }
void testLongEvaluation()
{
QDateTime time = QDateTime::currentDateTime();
QVector<QDateTime> bigv;
for (int i = 0; i < 10000; ++i)
bigv.append(time);
int s = bigv.size();
++s;
}
#ifdef FOP #ifdef FOP
int xxxx() int xxxx()
@@ -1847,18 +1842,6 @@ namespace qstringlist {
} // namespace qstringlist } // namespace qstringlist
Foo testStruct()
{
Foo f(2);
f.doit();
f.doit();
f.doit();
Foo f1 = f;
f1.doit();
return f1;
}
namespace formats { namespace formats {
void testString() void testString()
@@ -2420,27 +2403,6 @@ void testMemoryView()
a[i] = i; a[i] = i;
} }
void testUninitialized()
{
QString s;
QStringList sl;
QMap<int, int> mii;
QMap<QString, QString> mss;
QHash<int, int> hii;
QHash<QString, QString> hss;
QList<int> li;
QVector<int> vi;
QStack<int> si;
std::string ss;
std::map<int, int> smii;
std::map<std::string, std::string> smss;
std::list<int> sli;
std::list<std::string> ssl;
std::vector<int> svi;
std::stack<int> ssi;
}
void testEndlessRecursion() void testEndlessRecursion()
{ {
testEndlessRecursion(); testEndlessRecursion();
@@ -2626,6 +2588,16 @@ namespace basic {
++t2; ++t2;
} }
void testStruct()
{
Foo f(2);
f.doit();
f.doit();
f.doit();
// <=== Break here.
dummyStatement(&f);
}
void testUninitialized() void testUninitialized()
{ {
// This tests the display of uninitialized data. // This tests the display of uninitialized data.
@@ -2766,6 +2738,17 @@ namespace basic {
dummyStatement(&c, &d); dummyStatement(&c, &d);
} }
void testLongEvaluation()
{
QDateTime time = QDateTime::currentDateTime();
QVector<QDateTime> bigv;
for (int i = 0; i < 10000; ++i)
bigv.append(time);
// <== Break here.
// Expand bigv.
dummyStatement(&bigv);
}
void testBasic() void testBasic()
{ {
testArray1(); testArray1();
@@ -2779,6 +2762,7 @@ namespace basic {
testAlphabeticSorting(); testAlphabeticSorting();
testTypedef(); testTypedef();
testPtrTypedef(); testPtrTypedef();
testStruct();
testUninitialized(); testUninitialized();
testTypeFormats(); testTypeFormats();
testStringWithNewline(); testStringWithNewline();
@@ -2786,32 +2770,12 @@ namespace basic {
testColoredMemoryView(); testColoredMemoryView();
testReference1(); testReference1();
testReference2(); testReference2();
testLongEvaluation();
} }
} // namespace basic } // namespace basic
void testStuff()
{
using namespace std;
typedef map<string, list<string> > map_t;
map_t m;
m["one"].push_back("a");
m["one"].push_back("b");
m["one"].push_back("c");
m["two"].push_back("1");
m["two"].push_back("2");
m["two"].push_back("3");
map_t::const_iterator i = m.begin();
vector<int> vec;
vec.push_back(1);
vec.push_back(2);
pair<vector<int>, vector<int> > a(pair<vector<int>,vector<int> >(vec, vec));
i++;
}
void testStuff2() void testStuff2()
{ {
QList<QList<int> > list1; QList<QList<int> > list1;
@@ -2992,93 +2956,98 @@ void testFork()
ba.append('x'); ba.append('x');
} }
struct structdata
{
int ints[8];
char chars[32];
double doubles[5];
};
enum type_t { MPI_LB, MPI_INT, MPI_CHAR, MPI_DOUBLE, MPI_UB }; namespace mpi {
struct tree_entry struct structdata
{ {
tree_entry() {} int ints[8];
tree_entry(int l, int o, type_t t) char chars[32];
: blocklength(l), offset(o), type(t) double doubles[5];
{}
int blocklength;
int offset;
type_t type;
};
struct tree
{
enum kind_t { STRUCT };
void *base;
kind_t kind;
int count;
tree_entry entries[20];
};
void testMPI()
{
structdata buffer = {
//{MPI_LB},
{0, 1024, 2048, 3072, 4096, 5120, 6144 },
{"message to 1 of 2: hello"},
{0, 3.14, 6.2831853071795862, 9.4247779607693793, 13},
//{MPI_UB}
}; };
tree x; enum type_t { MPI_LB, MPI_INT, MPI_CHAR, MPI_DOUBLE, MPI_UB };
x.base = &buffer;
x.kind = tree::STRUCT; struct tree_entry
x.count = 5; {
x.entries[0] = tree_entry(1, -4, MPI_LB); tree_entry() {}
x.entries[1] = tree_entry(5, 0, MPI_INT); tree_entry(int l, int o, type_t t)
x.entries[2] = tree_entry(7, 47, MPI_CHAR); : blocklength(l), offset(o), type(t)
x.entries[3] = tree_entry(2, 76, MPI_DOUBLE); {}
x.entries[4] = tree_entry(1, 100, MPI_UB);
int blocklength;
int offset;
type_t type;
};
struct tree
{
enum kind_t { STRUCT };
void *base;
kind_t kind;
int count;
tree_entry entries[20];
};
void testMPI()
{
structdata buffer = {
//{MPI_LB},
{0, 1024, 2048, 3072, 4096, 5120, 6144 },
{"message to 1 of 2: hello"},
{0, 3.14, 6.2831853071795862, 9.4247779607693793, 13},
//{MPI_UB}
};
tree x;
x.base = &buffer;
x.kind = tree::STRUCT;
x.count = 5;
x.entries[0] = tree_entry(1, -4, MPI_LB);
x.entries[1] = tree_entry(5, 0, MPI_INT);
x.entries[2] = tree_entry(7, 47, MPI_CHAR);
x.entries[3] = tree_entry(2, 76, MPI_DOUBLE);
x.entries[4] = tree_entry(1, 100, MPI_UB);
int i = x.count; int i = x.count;
i = buffer.ints[0]; i = buffer.ints[0];
i = buffer.ints[1]; i = buffer.ints[1];
i = buffer.ints[2]; i = buffer.ints[2];
i = buffer.ints[3]; i = buffer.ints[3];
/* /*
gdb) print datatype gdb) print datatype
> $3 = { > $3 = {
> kind = STRUCT, > kind = STRUCT,
> count = 5, > count = 5,
> entries = {{ > entries = {{
> blocklength = 1, > blocklength = 1,
> offset = -4, > offset = -4,
> type = MPI_LB > type = MPI_LB
> }, { > }, {
> blocklength = 5, > blocklength = 5,
> offset = 0, > offset = 0,
> type = MPI_INT > type = MPI_INT
> }, { > }, {
> blocklength = 7, > blocklength = 7,
> offset = 47, > offset = 47,
> type = MPI_CHAR > type = MPI_CHAR
> }, { > }, {
> blocklength = 2, > blocklength = 2,
> offset = 76, > offset = 76,
> type = MPI_DOUBLE > type = MPI_DOUBLE
> }, { > }, {
> blocklength = 1, > blocklength = 1,
> offset = 100, > offset = 100,
> type = MPI_UB > type = MPI_UB
> }} > }}
> } > }
*/ */
} }
} // namespace mpi
//namespace kr { //namespace kr {
@@ -3255,7 +3224,7 @@ namespace bug4904 {
double dvalue; double dvalue;
}; };
int test4904() void test4904()
{ {
QMap<int, CustomStruct> map; QMap<int, CustomStruct> map;
CustomStruct cs1; CustomStruct cs1;
@@ -3266,11 +3235,11 @@ namespace bug4904 {
map.insert(cs1.id, cs1); map.insert(cs1.id, cs1);
map.insert(cs2.id, cs2); map.insert(cs2.id, cs2);
QMap<int, CustomStruct>::iterator it = map.begin(); QMap<int, CustomStruct>::iterator it = map.begin();
int n = map.size(); // <=== Break here. // <=== Break here.
// - expand map/[0]/value // - expand map/[0]/value
// - verify map[0].key == -1 // - verify map[0].key == -1
// - verify map[0].value.id == -1 // - verify map[0].value.id == -1
return n; dummyStatement(&it);
} }
} // namespace bug4904 } // namespace bug4904
@@ -3282,16 +3251,17 @@ namespace bug5046 {
struct Foo { int a, b, c; }; struct Foo { int a, b, c; };
int test5046() void test5046()
{ {
Foo f; Foo f;
f.a = 1; f.a = 1;
f.b = 2; f.b = 2;
f.c = 3; f.c = 3;
f.a = 4; // <= Break here. f.a = 4;
// <= Break here.
// - pop up main editor tooltip over 'f' // - pop up main editor tooltip over 'f'
// - verify that the entry is expandable, and expansion works // - verify that the entry is expandable, and expansion works
return f.a; dummyStatement(&f);
} }
} // namespace bug5046 } // namespace bug5046
@@ -3370,14 +3340,13 @@ namespace qc42170 {
struct Point : Object struct Point : Object
{ {
Point(double x_, double y_, int id_) : Object(id_), x(x_), y(y_) {} Point(double x_, double y_) : Object(1), x(x_), y(y_) {}
double x, y; double x, y;
}; };
struct Circle : Point struct Circle : Point
{ {
Circle(double x_, double y_, double r_, int id_) Circle(double x_, double y_, double r_) : Point(x_, y_), r(r_) { id = 2; }
: Point(x_, y_, id_), r(r_) {}
double r; double r;
}; };
@@ -3391,11 +3360,10 @@ namespace qc42170 {
void test42170() void test42170()
{ {
Circle *circle = new Circle(1.5, -2.5, 3.0, 15); Circle *circle = new Circle(1.5, -2.5, 3.0);
Object *obj = circle; Object *obj = circle;
helper(circle); helper(circle);
helper(obj); helper(obj);
dummyStatement(obj);
} }
} // namespace qc42170 } // namespace qc42170
@@ -3501,6 +3469,26 @@ namespace varargs {
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
std::string s;
s = "hallo";
s += "hallo";
QVector<int> qv;
qv.push_back(2);
std::vector<int> v;
v.push_back(2);
QStringList list;
list << "aaa" << "bbb" << "cc";
QList<const char *> list2;
list2 << "foo";
list2 << "bar";
list2 << 0;
list2 << "baz";
list2 << 0;
qhostaddress::testQHostAddress(); qhostaddress::testQHostAddress();
varargs::testVaList(); varargs::testVaList();
cp42895::test42895(); cp42895::test42895();
@@ -3518,14 +3506,10 @@ int main(int argc, char *argv[])
//bug4497::test4497(); //bug4497::test4497();
eigen::testEigen(); eigen::testEigen();
kr::testKR(); kr::testKR();
std::string s;
s = "hallo";
s += "hallo";
qxml::testQXmlAttributes(); qxml::testQXmlAttributes();
qregexp::testQRegExp(); qregexp::testQRegExp();
testInlineBreakpoints(); breakpoints::testBreakpoints();
testLongEvaluation(); mpi::testMPI();
testMPI();
qobjectdata::testQObjectData(); qobjectdata::testQObjectData();
//testQSettings(); //testQSettings();
//testWCout0(); //testWCout0();
@@ -3535,10 +3519,9 @@ int main(int argc, char *argv[])
qrect::testGeometry(); qrect::testGeometry();
qregion::testQRegion(); qregion::testQRegion();
basic::testBasic(); basic::testBasic();
testStuff();
testPeekAndPoke3(); testPeekAndPoke3();
testFunctionPointer(); testFunctionPointer();
testAnonymous(); anon::testAnonymous();
//testEndlessLoop(); //testEndlessLoop();
//testEndlessRecursion(); //testEndlessRecursion();
testQStack(); testQStack();
@@ -3551,22 +3534,6 @@ int main(int argc, char *argv[])
testQHash1(); testQHash1();
testSignalSlot(argc, argv); testSignalSlot(argc, argv);
QVector<int> qv;
qv.push_back(2);
std::vector<int> v;
v.push_back(2);
QStringList list;
list << "aaa" << "bbb" << "cc";
QList<const char *> list2;
list2 << "foo";
list2 << "bar";
list2 << 0;
list2 << "baz";
list2 << 0;
testQStandardItemModel(); testQStandardItemModel();
testFunction(); testFunction();
testQImage(); testQImage();
@@ -3602,7 +3569,7 @@ int main(int argc, char *argv[])
testQSharedPointer(); testQSharedPointer();
qstringlist::testQStringList(); qstringlist::testQStringList();
testQScriptValue(argc, argv); testQScriptValue(argc, argv);
testStruct(); basic::testStruct();
//qthread::testQThread(); //qthread::testQThread();
qvariant::testQVariant(); qvariant::testQVariant();
qvector::testQVector(); qvector::testQVector();