forked from qt-creator/qt-creator
debugger: show non-ASCII in QString, too
This commit is contained in:
@@ -1056,7 +1056,8 @@ void DebuggerManager::sessionLoaded()
|
||||
void DebuggerManager::sessionUnloaded()
|
||||
{
|
||||
return;
|
||||
cleanupViews();
|
||||
//FIXME: Breakview crashes on startup as there is
|
||||
//cleanupViews();
|
||||
if (m_engine)
|
||||
m_engine->shutdown();
|
||||
setStatus(DebuggerProcessNotReady);
|
||||
|
||||
@@ -2776,36 +2776,55 @@ void GdbEngine::setToolTipExpression(const QPoint &pos, const QString &exp0)
|
||||
|
||||
static const QString strNotInScope = QLatin1String("<not in scope>");
|
||||
|
||||
static QString quoteUnprintableLatin1(const QByteArray &ba)
|
||||
{
|
||||
QString res;
|
||||
char buf[10];
|
||||
for (int i = 0, n = ba.size(); i != n; ++i) {
|
||||
unsigned char c = ba.at(i);
|
||||
if (isprint(c)) {
|
||||
res += c;
|
||||
} else {
|
||||
qsnprintf(buf, sizeof(buf) - 1, "\\%x", int(c));
|
||||
res += buf;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static void setWatchDataValue(WatchData &data, const GdbMi &mi,
|
||||
int encoding = 0)
|
||||
{
|
||||
if (mi.isValid()) {
|
||||
QByteArray ba;
|
||||
QString str;
|
||||
switch (encoding) {
|
||||
case 0: // unencoded 8 bit data
|
||||
ba = mi.data();
|
||||
str = quoteUnprintableLatin1(ba);
|
||||
break;
|
||||
case 1: // base64 encoded 8 bit data
|
||||
case 1: // base64 encoded 8 bit data, used for QByteArray
|
||||
ba = QByteArray::fromBase64(mi.data());
|
||||
ba = '"' + ba + '"';
|
||||
str = '"' + quoteUnprintableLatin1(ba) + '"';
|
||||
break;
|
||||
case 2: // base64 encoded 16 bit data
|
||||
case 2: // base64 encoded 16 bit data, used for QString
|
||||
ba = QByteArray::fromBase64(mi.data());
|
||||
ba = QString::fromUtf16((ushort *)ba.data(), ba.size() / 2).toUtf8();
|
||||
ba = '"' + ba + '"';
|
||||
str = QString::fromUtf16((ushort *)ba.data(), ba.size() / 2);
|
||||
str = '"' + str + '"';
|
||||
break;
|
||||
case 3: // base64 encoded 32 bit data
|
||||
ba = QByteArray::fromBase64(mi.data());
|
||||
ba = QString::fromUcs4((uint *)ba.data(), ba.size() / 4).toUtf8();
|
||||
ba = '"' + ba + '"';
|
||||
str = QString::fromUcs4((uint *)ba.data(), ba.size() / 4);
|
||||
str = '"' + str + '"';
|
||||
break;
|
||||
case 4: // base64 encoded 8 bit data
|
||||
case 4: // base64 encoded 16 bit data, without quotes (see 2)
|
||||
ba = QByteArray::fromBase64(mi.data());
|
||||
str = QString::fromUtf16((ushort *)ba.data(), ba.size() / 2);
|
||||
break;
|
||||
}
|
||||
data.setValue(ba);
|
||||
data.setValue(str);
|
||||
} else {
|
||||
data.setValueNeeded();
|
||||
data.setValueNeeded();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3411,7 +3430,7 @@ void GdbEngine::handleVarCreate(const GdbResultRecord &record,
|
||||
data.setChildrenNeeded();
|
||||
setWatchDataChildCount(data, record.data.findChild("numchild"));
|
||||
//if (data.isValueNeeded() && data.childCount > 0)
|
||||
// data.setValue(QByteArray());
|
||||
// data.setValue(QString());
|
||||
insertData(data);
|
||||
}
|
||||
} else if (record.resultClass == GdbResultError) {
|
||||
@@ -3607,13 +3626,13 @@ void GdbEngine::handleDumpCustomValue3(const GdbResultRecord &record,
|
||||
QString str;
|
||||
for (int i = 0; i < list.size(); ++i)
|
||||
str.append(list.at(i).toInt());
|
||||
data.setValue('"' + str.toUtf8() + '"');
|
||||
data.setValue('"' + str + '"');
|
||||
data.setChildCount(0);
|
||||
data.setAllUnneeded();
|
||||
insertData(data);
|
||||
} else if (data.type == "QStringList" || data.type.endsWith("::QStringList")) {
|
||||
int l = list.size();
|
||||
data.setValue(QString("<%1 items>").arg(l).toLatin1());
|
||||
data.setValue(tr("<%1 items>").arg(l));
|
||||
data.setChildCount(list.size());
|
||||
data.setAllUnneeded();
|
||||
insertData(data);
|
||||
|
||||
@@ -91,25 +91,9 @@ void WatchData::setError(const QString &msg)
|
||||
valuedisabled = true;
|
||||
}
|
||||
|
||||
static QByteArray quoteUnprintable(const QByteArray &ba)
|
||||
void WatchData::setValue(const QString &value0)
|
||||
{
|
||||
QByteArray res;
|
||||
char buf[10];
|
||||
for (int i = 0, n = ba.size(); i != n; ++i) {
|
||||
unsigned char c = ba.at(i);
|
||||
if (isprint(c)) {
|
||||
res += c;
|
||||
} else {
|
||||
qsnprintf(buf, sizeof(buf) - 1, "\\%x", int(c));
|
||||
res += buf;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
void WatchData::setValue(const QByteArray &value0)
|
||||
{
|
||||
value = quoteUnprintable(value0);
|
||||
value = value0;
|
||||
if (value == "{...}") {
|
||||
value.clear();
|
||||
childCount = 1; // at least one...
|
||||
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
| ChildCountNeeded
|
||||
};
|
||||
|
||||
void setValue(const QByteArray &);
|
||||
void setValue(const QString &);
|
||||
void setType(const QString &);
|
||||
void setValueToolTip(const QString &);
|
||||
void setError(const QString &);
|
||||
|
||||
Reference in New Issue
Block a user