Commit d42a7e40 authored by hjk's avatar hjk
Browse files

debugger: small fixes for the gdb macro based QString and QStringList dumpers

parent 6200d188
...@@ -103,14 +103,13 @@ static inline QString _(const QByteArray &ba) ...@@ -103,14 +103,13 @@ static inline QString _(const QByteArray &ba)
return QString::fromLatin1(ba.data(), ba.size()); return QString::fromLatin1(ba.data(), ba.size());
} }
static const QString tooltipIName = _("tooltip");
static int &currentToken() static int &currentToken()
{ {
static int token = 0; static int token = 0;
return token; return token;
} }
static const QString tooltipIName = _("tooltip");
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
// //
...@@ -154,6 +153,10 @@ void GdbEngine::initializeConnections() ...@@ -154,6 +153,10 @@ void GdbEngine::initializeConnections()
connect(&m_uploadProc, SIGNAL(error(QProcess::ProcessError)), connect(&m_uploadProc, SIGNAL(error(QProcess::ProcessError)),
this, SLOT(uploadProcError(QProcess::ProcessError))); this, SLOT(uploadProcError(QProcess::ProcessError)));
connect(&m_uploadProc, SIGNAL(readyReadStandardOutput()),
this, SLOT(readUploadStandardOutput()));
connect(&m_uploadProc, SIGNAL(readyReadStandardError()),
this, SLOT(readUploadStandardError()));
// Output // Output
connect(&m_outputCollector, SIGNAL(byteDelivery(QByteArray)), connect(&m_outputCollector, SIGNAL(byteDelivery(QByteArray)),
...@@ -273,6 +276,18 @@ void GdbEngine::uploadProcError(QProcess::ProcessError error) ...@@ -273,6 +276,18 @@ void GdbEngine::uploadProcError(QProcess::ProcessError error)
QMessageBox::critical(q->mainWindow(), tr("Error"), msg); QMessageBox::critical(q->mainWindow(), tr("Error"), msg);
} }
void GdbEngine::readUploadStandardOutput()
{
QByteArray ba = m_uploadProc.readAllStandardOutput();
gdbOutputAvailable(_("upload-out:"), QString::fromLocal8Bit(ba, ba.length()));
}
void GdbEngine::readUploadStandardError()
{
QByteArray ba = m_uploadProc.readAllStandardError();
gdbOutputAvailable(_("upload-err:"), QString::fromLocal8Bit(ba, ba.length()));
}
#if 0 #if 0
static void dump(const char *first, const char *middle, const QString & to) static void dump(const char *first, const char *middle, const QString & to)
{ {
...@@ -2751,6 +2766,7 @@ void GdbEngine::setToolTipExpression(const QPoint &pos, const QString &exp0) ...@@ -2751,6 +2766,7 @@ void GdbEngine::setToolTipExpression(const QPoint &pos, const QString &exp0)
static const QString strNotInScope = static const QString strNotInScope =
QApplication::translate("Debugger::Internal::GdbEngine", "<not in scope>"); QApplication::translate("Debugger::Internal::GdbEngine", "<not in scope>");
static void setWatchDataValue(WatchData &data, const GdbMi &mi, static void setWatchDataValue(WatchData &data, const GdbMi &mi,
int encoding = 0) int encoding = 0)
{ {
...@@ -2939,8 +2955,8 @@ void GdbEngine::updateSubItem(const WatchData &data0) ...@@ -2939,8 +2955,8 @@ void GdbEngine::updateSubItem(const WatchData &data0)
qDebug() << "FIXME: GdbEngine::updateSubItem:" qDebug() << "FIXME: GdbEngine::updateSubItem:"
<< data.toString() << "should not happen"; << data.toString() << "should not happen";
#else #else
data.setType("<out of scope>"); data.setType(strNotInScope);
data.setValue("<out of scope>"); data.setValue(strNotInScope);
data.setChildCount(0); data.setChildCount(0);
insertData(data); insertData(data);
return; return;
...@@ -3434,14 +3450,15 @@ void GdbEngine::handleDebuggingHelperValue3(const GdbResultRecord &record, ...@@ -3434,14 +3450,15 @@ void GdbEngine::handleDebuggingHelperValue3(const GdbResultRecord &record,
// << " STREAM:" << out; // << " STREAM:" << out;
if (list.isEmpty()) { if (list.isEmpty()) {
//: Value for variable //: Value for variable
data.setValue(tr("<unavailable>")); data.setValue(strNotInScope);
data.setAllUnneeded(); data.setAllUnneeded();
insertData(data); insertData(data);
} else if (data.type == __("QString") } else if (data.type == __("QString")
|| data.type.endsWith(__("::QString"))) { || data.type.endsWith(__("::QString"))) {
QList<QByteArray> list = out.split(' '); QList<QByteArray> list = out.split(' ');
QString str; QString str;
for (int i = 0; i < list.size(); ++i) int l = out.isEmpty() ? 0 : list.size();
for (int i = 0; i < l; ++i)
str.append(list.at(i).toInt()); str.append(list.at(i).toInt());
data.setValue(_c('"') + str + _c('"')); data.setValue(_c('"') + str + _c('"'));
data.setChildCount(0); data.setChildCount(0);
...@@ -3449,35 +3466,42 @@ void GdbEngine::handleDebuggingHelperValue3(const GdbResultRecord &record, ...@@ -3449,35 +3466,42 @@ void GdbEngine::handleDebuggingHelperValue3(const GdbResultRecord &record,
insertData(data); insertData(data);
} else if (data.type == __("QStringList") } else if (data.type == __("QStringList")
|| data.type.endsWith(__("::QStringList"))) { || data.type.endsWith(__("::QStringList"))) {
int l = list.size(); if (out.isEmpty()) {
//: In string list data.setValue(tr("<0 items>"));
data.setValue(tr("<%1 items>").arg(l)); data.setChildCount(0);
data.setChildCount(list.size()); data.setAllUnneeded();
data.setAllUnneeded(); insertData(data);
insertData(data); } else {
for (int i = 0; i < l; ++i) { int l = list.size();
WatchData data1; //: In string list
data1.name = _("[%1]").arg(i); data.setValue(tr("<%1 items>").arg(l));
data1.type = data.type.left(data.type.size() - 4); data.setChildCount(list.size());
data1.iname = data.iname + _(".%1").arg(i); data.setAllUnneeded();
data1.addr = _(list.at(i)); insertData(data);
data1.exp = _("((") + gdbQuoteTypes(data1.type) + _("*)") + data1.addr + _c(')'); for (int i = 0; i < l; ++i) {
data1.setChildCount(0); WatchData data1;
data1.setValueNeeded(); data1.name = _("[%1]").arg(i);
QString cmd = _("qdumpqstring (") + data1.exp + _c(')'); data1.type = data.type.left(data.type.size() - 4);
QVariant var; data1.iname = data.iname + _(".%1").arg(i);
var.setValue(data1); data1.addr = _(list.at(i));
postCommand(cmd, WatchUpdate, CB(handleDebuggingHelperValue3), var); data1.exp = _("((") + gdbQuoteTypes(data1.type) + _("*)") + data1.addr + _c(')');
data1.setChildCount(0);
data1.setValueNeeded();
QString cmd = _("qdumpqstring (") + data1.exp + _c(')');
QVariant var;
var.setValue(data1);
postCommand(cmd, WatchUpdate, CB(handleDebuggingHelperValue3), var);
}
} }
} else { } else {
//: Value for variable //: Value for variable
data.setValue(tr("<unavailable>")); data.setValue(strNotInScope);
data.setAllUnneeded(); data.setAllUnneeded();
insertData(data); insertData(data);
} }
} else if (record.resultClass == GdbResultError) { } else if (record.resultClass == GdbResultError) {
WatchData data = cookie.value<WatchData>(); WatchData data = cookie.value<WatchData>();
data.setValue(tr("<unavailable>")); data.setValue(strNotInScope);
data.setAllUnneeded(); data.setAllUnneeded();
insertData(data); insertData(data);
} }
......
...@@ -189,6 +189,8 @@ private slots: ...@@ -189,6 +189,8 @@ private slots:
void gdbProcError(QProcess::ProcessError error); void gdbProcError(QProcess::ProcessError error);
void readGdbStandardOutput(); void readGdbStandardOutput();
void readGdbStandardError(); void readGdbStandardError();
void readUploadStandardOutput();
void readUploadStandardError();
void readDebugeeOutput(const QByteArray &data); void readDebugeeOutput(const QByteArray &data);
void stubStarted(); void stubStarted();
void stubError(const QString &msg); void stubError(const QString &msg);
......
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