using namespace Debugger;
using namespace Debugger::Internal;
+
+/////////////////////////////////////////////////////////////////////////
+//
+// Helper stuff
+//
+/////////////////////////////////////////////////////////////////////////
+
typedef QList<QByteArray> QByteArrayList;
#if 0
void writeToGdb(const QByteArray &ba);
private slots:
+ void dumpQList_int();
void dumpQString();
void dumpQStringList();
void dumpQImage();
void dumpQImageData();
void dumpQLinkedList();
- void dumpQList_int();
void dumpQList_char();
void dumpQList_QString();
void dumpQList_QString3();
}
#endif
-void tst_Gdb::dumpQList_int()
-{
- QList<int> ilist;
- testDumper("value='<0 items>',valuedisabled='true',numchild='0',"
- "internal='1',children=[]",
- &ilist, NS"QList", true, "int");
- ilist.append(1);
- ilist.append(2);
- testDumper("value='<2 items>',valuedisabled='true',numchild='2',"
- "internal='1',childtype='int',childnumchild='0',children=["
- "{addr='" + str(&ilist.at(0)) + "',value='1'},"
- "{addr='" + str(&ilist.at(1)) + "',value='2'}]",
- &ilist, NS"QList", true, "int");
-}
-
-void tst_Gdb::dumpQList_char()
-{
- QList<char> clist;
- testDumper("value='<0 items>',valuedisabled='true',numchild='0',"
- "internal='1',children=[]",
- &clist, NS"QList", true, "char");
- clist.append('a');
- clist.append('b');
- testDumper("value='<2 items>',valuedisabled='true',numchild='2',"
- "internal='1',childtype='char',childnumchild='0',children=["
- "{addr='" + str(&clist.at(0)) + "',value=''a', ascii=97'},"
- "{addr='" + str(&clist.at(1)) + "',value=''b', ascii=98'}]",
- &clist, NS"QList", true, "char");
-}
-
-void tst_Gdb::dumpQList_QString()
-{
- QList<QString> slist;
- testDumper("value='<0 items>',valuedisabled='true',numchild='0',"
- "internal='1',children=[]",
- &slist, NS"QList", true, NS"QString");
- slist.append("a");
- slist.append("b");
- testDumper("value='<2 items>',valuedisabled='true',numchild='2',"
- "internal='1',childtype='"NS"QString',childnumchild='0',children=["
- "{addr='" + str(&slist.at(0)) + "',value='YQA=',valueencoded='2'},"
- "{addr='" + str(&slist.at(1)) + "',value='YgA=',valueencoded='2'}]",
- &slist, NS"QList", true, NS"QString");
-}
-
void tst_Gdb::dumpQList_Int3()
{
QList<Int3> i3list;
}
#endif // #if 0
-#define VERIFY_OFFSETOF(member) \
-do { \
- QObjectPrivate *qob = 0; \
- ObjectPrivate *ob = 0; \
- QVERIFY(size_t(&qob->member) == size_t(&ob->member)); \
-} while (0)
+/////////////////////////////////////////////////////////////////////////
+//
+// Gdb Thread
+//
+/////////////////////////////////////////////////////////////////////////
Thread::Thread(tst_Gdb *test)
{
start();
}
-void Thread::handleGdbError(QProcess::ProcessError)
+void Thread::handleGdbError(QProcess::ProcessError error)
{
- qDebug() << "GDB ERROR: ";
+ qDebug() << "GDB ERROR: " << error;
+ //this->exit();
}
-void Thread::handleGdbFinished(int, QProcess::ExitStatus)
+void Thread::handleGdbFinished(int code, QProcess::ExitStatus st)
{
- qDebug() << "GDB FINISHED: ";
+ qDebug() << "GDB FINISHED: " << code << st;
+ //m_waitCondition.wakeAll();
+ //this->exit();
+ throw 42;
}
void Thread::readStandardOutput()
{
QByteArray ba = m_proc->readAllStandardOutput();
- //DEBUGX("THREAD GDB OUT: " << ba);
+ DEBUG("THREAD GDB OUT: " << ba);
// =library-loaded...
if (ba.startsWith("="))
return;
if (ba.startsWith("~\"XXX: ")) {
QByteArray ba1 = ba.mid(7, ba.size() - 11);
- qWarning() << "MESSAGE: " << ba.mid(7, ba.size() - 11);
+ qWarning() << "MESSAGE: " << ba.mid(7, ba.size() - 12);
}
- if (!ba.startsWith("~\"locals="))
+ if (!ba.contains("locals={iname="))
return;
//m_output += ba;
ba = ba.mid(2, ba.size() - 4);
exec();
}
+
+/////////////////////////////////////////////////////////////////////////
+//
+// Test Class Framework Implementation
+//
+/////////////////////////////////////////////////////////////////////////
+
tst_Gdb::tst_Gdb()
: m_thread(this)
{
// FIXME: Wait until gdb proc is running.
- QTest::qWait(300);
+ QTest::qWait(600);
QFile file("tst_gdb.cpp");
Q_ASSERT(file.open(QIODevice::ReadOnly));
const QByteArray &expected0, const QByteArray &expanded)
{
//qDebug() << "\nABOUT TO RUN TEST: " << function << m_thread.m_proc;
- writeToGdb("bb " + expanded);
+ writeToGdb("bb 1 " + expanded);
m_mutex.lock();
m_waitCondition.wait(&m_mutex);
QByteArray ba = m_thread.m_output;
//qDebug() << "OUTPUT: " << ba << "\n\n";
//qDebug() << "OUTPUT: " << locals.toString() << "\n\n";
- QByteArray actual____ = received;
+ QByteArray actual____ = received.trimmed();
QByteArray expected = "locals={iname='local',name='Locals',value=' ',type=' ',"
"children=[" + expected0 + "]}";
int line = m_thread.m_line;
ok = false;
qWarning() << "!= size: " << l1.size() << l2.size();
}
+ qWarning() << "RECEIVED: " << received;
}
QCOMPARE(ok, true);
qWarning() << "LINE: " << line << "ACT/EXP" << m_function + '@' + label;
//m_thread.m_proc->waitForFinished();
}
+
+/////////////////////////////////////////////////////////////////////////
+//
+// Dumper Tests
+//
+/////////////////////////////////////////////////////////////////////////
+
+void dumpQList_int()
+{
+ /* A */ QList<int> ilist;
+ /* B */ ilist.append(1);
+ /* C */ ilist.append(2);
+ /* D */ (void) 0;
+}
+
+void tst_Gdb::dumpQList_int()
+{
+ prepare("dumpQList_int");
+ run("A","{iname='local.ilist',addr='-',name='ilist',"
+ "type='"NS"QList<int>',value='<not in scope>',numchild='0'}");
+ next();
+ run("B","{iname='local.ilist',addr='-',name='ilist',"
+ "type='"NS"QList<int>',value='<0 items>',numchild='0'}");
+ next();
+ run("C","{iname='local.ilist',addr='-',name='ilist',"
+ "type='"NS"QList<int>',value='<1 items>',numchild='1'}");
+ //run("C","{iname='local.ilist',addr='-',name='ilist',"
+ // "type='"NS"QList<int>',value='<1 items>',numchild='1',"
+ // "childtype='int',childnumchild='0',children=["
+ // "{value='1'}]}", "local.ilist");
+/*
+ next();
+ run("D","{iname='local.ilist',addr='-',name='ilist',"
+ "type='"NS"QList<int>',value='<2 items>',numchild='2',"
+ "childtype='int',childnumchild='0'}");
+ run("D","{iname='local.ilist',addr='-',name='ilist',"
+ "type='"NS"QList<int>',value='<2 items>',numchild='2',"
+ "childtype='int',childnumchild='0',children=["
+ "{addr='-',value='1'},{addr='-',value='2'}]}", "local.ilist");
+*/
+}
+
+/*
+void tst_Gdb::dumpQList_char()
+{
+ QList<char> clist;
+ testDumper("value='<0 items>',valuedisabled='true',numchild='0',"
+ "internal='1',children=[]",
+ &clist, NS"QList", true, "char");
+ clist.append('a');
+ clist.append('b');
+ testDumper("value='<2 items>',valuedisabled='true',numchild='2',"
+ "internal='1',childtype='char',childnumchild='0',children=["
+ "{addr='" + str(&clist.at(0)) + "',value=''a', ascii=97'},"
+ "{addr='" + str(&clist.at(1)) + "',value=''b', ascii=98'}]",
+ &clist, NS"QList", true, "char");
+}
+
+void tst_Gdb::dumpQList_QString()
+{
+ QList<QString> slist;
+ testDumper("value='<0 items>',valuedisabled='true',numchild='0',"
+ "internal='1',children=[]",
+ &slist, NS"QList", true, NS"QString");
+ slist.append("a");
+ slist.append("b");
+ testDumper("value='<2 items>',valuedisabled='true',numchild='2',"
+ "internal='1',childtype='"NS"QString',childnumchild='0',children=["
+ "{addr='" + str(&slist.at(0)) + "',value='YQA=',valueencoded='2'},"
+ "{addr='" + str(&slist.at(1)) + "',value='YgA=',valueencoded='2'}]",
+ &slist, NS"QList", true, NS"QString");
+}
+*/
+
void dumpQStringTest()
{
/* A */ QString s;
/* B */ s = "hallo";
/* C */ s += "x";
- /* D */ }
+ /* D */ (void) 0;
+}
void tst_Gdb::dumpQString()
{
prepare("dumpQStringTest");
- run("A", "{iname='local.s',addr='-',name='s',type='"NS"QString',"
- "value='<not in scope>',numchild='0'}");
+ run("A","{iname='local.s',addr='-',name='s',type='"NS"QString',"
+ "value='<not in scope>',numchild='0'}");
next();
- run("B", "{iname='local.s',addr='-',name='s',type='"NS"QString',"
- "valueencoded='7',value='',numchild='0'}");
+ run("B","{iname='local.s',addr='-',name='s',type='"NS"QString',"
+ "valueencoded='7',value='',numchild='0'}");
next();
- run("C", "{iname='local.s',addr='-',name='s',type='"NS"QString',"
- "valueencoded='7',value='680061006c006c006f00',numchild='0'}");
+ run("C","{iname='local.s',addr='-',name='s',type='"NS"QString',"
+ "valueencoded='7',value='680061006c006c006f00',numchild='0'}");
next();
- run("D", "{iname='local.s',addr='-',name='s',type='"NS"QString',"
- "valueencoded='7',value='680061006c006c006f007800',numchild='0'}");
+ run("D","{iname='local.s',addr='-',name='s',type='"NS"QString',"
+ "valueencoded='7',value='680061006c006c006f007800',numchild='0'}");
}
void dumpQStringListTest()
/* A */ QStringList s;
/* B */ s.append("hello");
/* C */ s.append("world");
+ /* D */ (void) 0;
}
void tst_Gdb::dumpQStringList()
{
prepare("dumpQStringListTest");
- run("A", "{iname='local.s',addr='-',name='s',type='"NS"QStringList',"
- "value='<not in scope>',numchild='0'}");
+ run("A","{iname='local.s',addr='-',name='s',type='"NS"QStringList',"
+ "value='<not in scope>',numchild='0'}");
+ next();
+ run("B","{iname='local.s',addr='-',name='s',type='"NS"QStringList',"
+ "value='<0 items>',numchild='0'}");
+ run("B","{iname='local.s',addr='-',name='s',type='"NS"QStringList',"
+ "value='<0 items>',numchild='0',children=[]}", "local.s");
next();
- //run("B", "{iname='local.s',addr='-',name='s',type='"NS"QStringList',"
- // "value='<0 items>',numchild='0'}");
- run("B", "{iname='local.s',addr='-',name='s',type='"NS"QStringList',"
- "value='<0 items>',numchild='0'}", "local.s");
+ run("C","{iname='local.s',addr='-',name='s',type='"NS"QStringList',"
+ "value='<1 items>',numchild='1'}");
+ run("C","{iname='local.s',addr='-',name='s',type='"NS"QStringList',"
+ "value='<1 items>',numchild='1',childtype='"NS"QString',"
+ "childnumchild='0',children=[{valueencoded='7',"
+ "value='680065006c006c006f00'}]}",
+ "local.s");
+return;
next();
- run("C", "{iname='local.s',addr='-',name='s',type='"NS"QStringList',"
- "value='<1 items>',numchild='1'}");
+ run("D","{iname='local.s',addr='-',name='s',type='"NS"QStringList',"
+ "value='<2 items>',numchild='2'}");
+ run("D","{iname='local.s',addr='-',name='s',type='"NS"QStringList',"
+ "value='<2 items>',numchild='2',childtype='"NS"QString',"
+ "childnumchild='0',children=["
+ "{valueencoded='7',value='680065006c006c006f00'},"
+ "{valueencoded='7',value='77006f0072006c006400'}]}",
+ "local.s");
}
-int runit(int &argc, char *argv[])
-{
- // Plain call. Start the testing.
- QCoreApplication app(argc, argv);
- tst_Gdb test;
- return QTest::qExec(&test, argc, argv);
-}
+
+/////////////////////////////////////////////////////////////////////////
+//
+// Main
+//
+/////////////////////////////////////////////////////////////////////////
int main(int argc, char *argv[])
{
return 0;
}
- return runit(argc, argv);
+ try {
+ // Plain call. Start the testing.
+ QCoreApplication app(argc, argv);
+ tst_Gdb *test = new tst_Gdb;
+ return QTest::qExec(test, argc, argv);
+ } catch (...) {
+ qDebug() << "TEST ABORTED ";
+ }
}
#include "tst_gdb.moc"