Commit 59f45976 authored by hjk's avatar hjk
Browse files

debugger: use single instead of double quotes for dumper output.

This makes both source and log files more readable and also prevents
gdb from applying extra quoting of its own.
parent df92275f
......@@ -36,24 +36,42 @@
// this relies on contents copied from qobject_p.h
#define PRIVATE_OBJECT_ALLOWED 1
#include <QDateTime>
#include <QDebug>
#include <QDir>
#include <QFile>
#include <QFileInfo>
#include <QHash>
#include <QLinkedList>
#include <QLocale>
#include <QMap>
#include <QMetaObject>
#include <QMetaProperty>
#include <QModelIndex>
#include <QObject>
#include <QPointer>
#include <QString>
#include <QTextCodec>
#include <QVector>
#include <QtCore/QDateTime>
#include <QtCore/QDebug>
#include <QtCore/QDir>
#include <QtCore/QFile>
#include <QtCore/QFileInfo>
#include <QtCore/QHash>
#include <QtCore/QLinkedList>
#include <QtCore/QLocale>
#include <QtCore/QMap>
#include <QtCore/QMetaObject>
#include <QtCore/QMetaProperty>
#include <QtCore/QModelIndex>
#include <QtCore/QObject>
#include <QtCore/QPointer>
#include <QtCore/QString>
#include <QtCore/QTextCodec>
#include <QtCore/QVector>
int qtGhVersion = QT_VERSION;
#ifdef QT_GUI_LIB
# include <QtGui/QPixmap>
# include <QtGui/QImage>
#endif
#include <list>
#include <map>
#include <string>
#include <vector>
#include <ctype.h>
#include <stdio.h>
#ifdef Q_OS_WIN
# include <windows.h>
#endif
/*!
\class QDumper
......@@ -91,7 +109,7 @@
'P(d, name, value)' roughly expands to:
d << (name) << "=\"" << value << "\"";
d << (name) << "='" << value << "'";
Useful (i.e. understood by the IDE) names include:
......@@ -117,25 +135,6 @@
*/
int qtGhVersion = QT_VERSION;
#ifdef QT_GUI_LIB
# include <QPixmap>
# include <QImage>
#endif
#include <list>
#include <map>
#include <string>
#include <vector>
#include <ctype.h>
#include <stdio.h>
#ifdef Q_OS_WIN
# include <windows.h>
#endif
#undef NS
#ifdef QT_NAMESPACE
# define STRINGIFY0(s) #s
......@@ -552,7 +551,7 @@ void QDumper::addCommaIfNeeded()
if (pos == 0)
return;
char c = qDumpOutBuffer[pos - 1];
if (c == '}' || c == '"' || c == ']')
if (c == '}' || c == '\'' || c == ']')
put(',');
}
......@@ -631,7 +630,7 @@ void QDumper::endHash()
void QDumper::putEllipsis()
{
addCommaIfNeeded();
*this << "{name=\"<incomplete>\",value=\"\",type=\"" << innertype << "\"}";
*this << "{name='<incomplete>',value='',type='" << innertype << "'}";
}
//
......@@ -643,7 +642,7 @@ void QDumper::putEllipsis()
#define P(dumper,name,value) \
do { \
dumper.addCommaIfNeeded(); \
dumper << (name) << "=\"" << value << "\""; \
dumper << (name) << "='" << value << "'"; \
} while (0)
// simple string property
......@@ -741,7 +740,7 @@ static void qDumpInnerValueHelper(QDumper &d, const char *type, const void *addr
return;
case 'B':
if (isEqual(type, "QByteArray")) {
d << key << "encoded=\"1\",";
d << key << "encoded='1',";
P(d, key, *(QByteArray*)addr);
}
return;
......@@ -770,7 +769,7 @@ static void qDumpInnerValueHelper(QDumper &d, const char *type, const void *addr
return;
case 'S':
if (isEqual(type, "QString")) {
d << key << "encoded=\"1\",";
d << key << "encoded='1',";
P(d, key, *(QString*)addr);
}
return;
......@@ -837,7 +836,7 @@ static void qDumpQByteArray(QDumper &d)
char buf[20];
for (int i = 0; i != ba.size(); ++i) {
unsigned char c = ba.at(i);
unsigned char u = isprint(c) && c != '"' ? c : '?';
unsigned char u = (isprint(c) && c != '\'' && c != '"') ? c : '?';
sprintf(buf, "%02x (%u '%c')", c, c, u);
d.beginHash();
P(d, "name", "[" << i << "]");
......@@ -2009,7 +2008,7 @@ static void qDumpQVariantHelper(const void *data, QString *value,
*numchild = 0;
break;
case QVariant::String:
*value = QLatin1Char('"') + v.toString() + QLatin1Char('"');
*value = QLatin1Char('\'') + v.toString() + QLatin1Char('\'');
*numchild = 0;
break;
case QVariant::StringList:
......@@ -2241,9 +2240,9 @@ static void qDumpStdString(QDumper &d)
qCheckAccess(str.c_str() + str.size() - 1);
}
d << ",value=\"";
d << ",value='";
d.putBase64Encoded(str.c_str(), str.size());
d << "\"";
d << "'";
P(d, "valueencoded", "1");
P(d, "type", "std::string");
P(d, "numchild", "0");
......@@ -2260,9 +2259,9 @@ static void qDumpStdWString(QDumper &d)
qCheckAccess(str.c_str() + str.size() - 1);
}
d << "value=\"";
d << "value='";
d.putBase64Encoded((const char *)str.c_str(), str.size() * sizeof(wchar_t));
d << "\"";
d << "'";
P(d, "valueencoded", (sizeof(wchar_t) == 2 ? "2" : "3"));
P(d, "type", "std::wstring");
P(d, "numchild", "0");
......@@ -2483,54 +2482,54 @@ void qDumpObjectData440(
// They are mentioned here nevertheless. For types that not listed
// here, dumpers won't be used.
d << "dumpers=["
"\""NS"QByteArray\","
"\""NS"QDateTime\","
"\""NS"QDir\","
"\""NS"QFile\","
"\""NS"QFileInfo\","
"\""NS"QHash\","
"\""NS"QHashNode\","
"\""NS"QImage\","
"\""NS"QLinkedList\","
"\""NS"QList\","
"\""NS"QLocale\","
"\""NS"QMap\","
"\""NS"QMapNode\","
"\""NS"QModelIndex\","
"'"NS"QByteArray',"
"'"NS"QDateTime',"
"'"NS"QDir',"
"'"NS"QFile',"
"'"NS"QFileInfo',"
"'"NS"QHash',"
"'"NS"QHashNode',"
"'"NS"QImage',"
"'"NS"QLinkedList',"
"'"NS"QList',"
"'"NS"QLocale',"
"'"NS"QMap',"
"'"NS"QMapNode',"
"'"NS"QModelIndex',"
#if QT_VERSION >= 0x040500
"\""NS"QMultiMap\","
"'"NS"QMultiMap',"
#endif
"\""NS"QObject\","
"\""NS"QObjectMethodList\"," // hack to get nested properties display
"\""NS"QObjectPropertyList\","
"'"NS"QObject',"
"'"NS"QObjectMethodList'," // hack to get nested properties display
"'"NS"QObjectPropertyList',"
#if PRIVATE_OBJECT_ALLOWED
"\""NS"QObjectSignal\","
"\""NS"QObjectSignalList\","
"\""NS"QObjectSlot\","
"\""NS"QObjectSlotList\","
"'"NS"QObjectSignal',"
"'"NS"QObjectSignalList',"
"'"NS"QObjectSlot',"
"'"NS"QObjectSlotList',"
#endif // PRIVATE_OBJECT_ALLOWED
// << "\""NS"QRegion\","
"\""NS"QSet\","
"\""NS"QString\","
"\""NS"QStringList\","
"\""NS"QTextCodec\","
"\""NS"QVariant\","
"\""NS"QVector\","
"\""NS"QWidget\","
"\"string\","
"\"wstring\","
"\"std::basic_string\","
"\"std::list\","
"\"std::map\","
"\"std::string\","
"\"std::vector\","
"\"std::wstring\","
// << "'"NS"QRegion',"
"'"NS"QSet',"
"'"NS"QString',"
"'"NS"QStringList',"
"'"NS"QTextCodec',"
"'"NS"QVariant',"
"'"NS"QVector',"
"'"NS"QWidget',"
"'string',"
"'wstring',"
"'std::basic_string',"
"'std::list',"
"'std::map',"
"'std::string',"
"'std::vector',"
"'std::wstring',"
"]";
d << ",qtversion=["
"\"" << ((QT_VERSION >> 16) & 255) << "\","
"\"" << ((QT_VERSION >> 8) & 255) << "\","
"\"" << ((QT_VERSION) & 255) << "\"]";
d << ",namespace=\""NS"\"";
"'" << ((QT_VERSION >> 16) & 255) << "',"
"'" << ((QT_VERSION >> 8) & 255) << "',"
"'" << ((QT_VERSION) & 255) << "']";
d << ",namespace='"NS"'";
d.disarm();
}
......
......@@ -467,20 +467,6 @@ void GdbEngine::handleResponse()
break;
}
case '#': {
//qDebug() << "CUSTOM OUTPUT, TOKEN" << token;
QString str;
for (; from != to && *from >= '0' && *from <= '9'; ++from)
str += QLatin1Char(*from);
++from; // skip the ' '
int len = str.toInt();
QByteArray ba(from, len);
from += len;
m_inbuffer = QByteArray(from, to - from);
m_customOutputForToken[token] += QString(ba);
break;
}
case '^': {
GdbResultRecord record;
......@@ -3320,9 +3306,9 @@ void GdbEngine::handleQueryDataDumper2(const GdbResultRecord &record)
GdbMi output = record.data.findChild("consolestreamoutput");
QByteArray out = output.data();
out = out.mid(out.indexOf('"') + 2); // + 1 is success marker
out = out.replace('\\', "");
out = out.left(out.lastIndexOf('"'));
out = "result={" + out + "}";
out = out.replace('\'', '"');
out = "dummy={" + out + "}";
//qDebug() << "OUTPUT: " << out;
GdbMi contents;
......@@ -3507,14 +3493,12 @@ void GdbEngine::handleDumpCustomValue2(const GdbResultRecord &record,
//qDebug() << "CUSTOM VALUE RESULT: " << record.toString();
//qDebug() << "FOR DATA: " << data.toString() << record.resultClass;
if (record.resultClass == GdbResultDone) {
//GdbMi output = record.data.findChild("customvaluecontents");
GdbMi output = record.data.findChild("consolestreamoutput");
QByteArray out = output.data();
out = out.mid(out.indexOf('"') + 2); // +1 is the 'success marker'
out = out.replace('\\', "");
out = out.mid(out.indexOf('"') + 2); // + 1 is the 'success marker'
out = out.left(out.lastIndexOf('"'));
out = "result={" + out + "}";
out = out.replace('\'', '"');
out = "dummy={" + out + "}";
//qDebug() << "OUTPUT: " << out;
GdbMi contents;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment