properly decode messages from gdb

... using fromLocal8Bit instead of fromLatin1.
of course the localized messages pose a "challenge" for the various
workarounds which parse them ...

Task-number: QTCREATORBUG-504
This commit is contained in:
Oswald Buddenhagen
2010-01-04 14:11:07 +01:00
parent 031d6c1690
commit 5fd1e3c454
7 changed files with 17 additions and 14 deletions

View File

@@ -85,7 +85,7 @@ void AttachGdbAdapter::handleAttach(const GdbResponse &response)
emit inferiorPrepared(); emit inferiorPrepared();
m_engine->updateAll(); m_engine->updateAll();
} else { } else {
QString msg = __(response.data.findChild("msg").data()); QString msg = QString::fromLocal8Bit(response.data.findChild("msg").data());
emit inferiorStartFailed(msg); emit inferiorStartFailed(msg);
} }
} }

View File

@@ -108,7 +108,7 @@ void CoreGdbAdapter::handleFileExecAndSymbols(const GdbResponse &response)
showStatusMessage(tr("Symbols found.")); showStatusMessage(tr("Symbols found."));
} else { } else {
QString msg = tr("Loading symbols from \"%1\" failed:\n").arg(m_executable) QString msg = tr("Loading symbols from \"%1\" failed:\n").arg(m_executable)
+ __(response.data.findChild("msg").data()); + QString::fromLocal8Bit(response.data.findChild("msg").data());
showMessageBox(QMessageBox::Warning, tr("Error Loading Symbols"), msg); showMessageBox(QMessageBox::Warning, tr("Error Loading Symbols"), msg);
} }
loadCoreFile(); loadCoreFile();
@@ -160,7 +160,7 @@ void CoreGdbAdapter::handleTargetCore(const GdbResponse &response)
m_engine->updateAll(); m_engine->updateAll();
} else { } else {
QString msg = tr("Attach to core \"%1\" failed:\n").arg(startParameters().coreFile) QString msg = tr("Attach to core \"%1\" failed:\n").arg(startParameters().coreFile)
+ __(response.data.findChild("msg").data()); + QString::fromLocal8Bit(response.data.findChild("msg").data());
emit inferiorStartFailed(msg); emit inferiorStartFailed(msg);
} }
} }

View File

@@ -1518,7 +1518,8 @@ void GdbEngine::handleInferiorShutdown(const GdbResponse &response)
} else { } else {
debugMessage(_("INFERIOR SHUTDOWN FAILED")); debugMessage(_("INFERIOR SHUTDOWN FAILED"));
setState(InferiorShutdownFailed); setState(InferiorShutdownFailed);
QString msg = m_gdbAdapter->msgInferiorStopFailed(_(response.data.findChild("msg").data())); QString msg = m_gdbAdapter->msgInferiorStopFailed(
QString::fromLocal8Bit(response.data.findChild("msg").data()));
showMessageBox(QMessageBox::Critical, tr("Inferior shutdown failed"), msg); showMessageBox(QMessageBox::Critical, tr("Inferior shutdown failed"), msg);
} }
shutdown(); // re-iterate... shutdown(); // re-iterate...
@@ -1531,7 +1532,8 @@ void GdbEngine::handleGdbExit(const GdbResponse &response)
m_commandsDoneCallback = 0; m_commandsDoneCallback = 0;
// don't set state here, this will be handled in handleGdbFinished() // don't set state here, this will be handled in handleGdbFinished()
} else { } else {
QString msg = m_gdbAdapter->msgGdbStopFailed(_(response.data.findChild("msg").data())); QString msg = m_gdbAdapter->msgGdbStopFailed(
QString::fromLocal8Bit(response.data.findChild("msg").data()));
debugMessage(_("GDB WON'T EXIT (%1); KILLING IT").arg(msg)); debugMessage(_("GDB WON'T EXIT (%1); KILLING IT").arg(msg));
m_gdbProc.kill(); m_gdbProc.kill();
} }
@@ -4229,7 +4231,7 @@ void GdbEngine::handleFetchDisassemblerByLine(const GdbResponse &response)
if (msg == "mi_cmd_disassemble: Invalid line number") if (msg == "mi_cmd_disassemble: Invalid line number")
fetchDisassemblerByAddress(ac.agent, true); fetchDisassemblerByAddress(ac.agent, true);
else else
showStatusMessage(tr("Disassembler failed: %1").arg(_(msg)), 5000); showStatusMessage(tr("Disassembler failed: %1").arg(QString::fromLocal8Bit(msg)), 5000);
} }
} }
@@ -4254,7 +4256,7 @@ void GdbEngine::handleFetchDisassemblerByAddress1(const GdbResponse &response)
} else { } else {
// 26^error,msg="Cannot access memory at address 0x801ca308" // 26^error,msg="Cannot access memory at address 0x801ca308"
QByteArray msg = response.data.findChild("msg").data(); QByteArray msg = response.data.findChild("msg").data();
showStatusMessage(tr("Disassembler failed: %1").arg(_(msg)), 5000); showStatusMessage(tr("Disassembler failed: %1").arg(QString::fromLocal8Bit(msg)), 5000);
} }
} }
@@ -4268,7 +4270,7 @@ void GdbEngine::handleFetchDisassemblerByAddress0(const GdbResponse &response)
ac.agent->setContents(parseDisassembler(lines)); ac.agent->setContents(parseDisassembler(lines));
} else { } else {
QByteArray msg = response.data.findChild("msg").data(); QByteArray msg = response.data.findChild("msg").data();
showStatusMessage(tr("Disassembler failed: %1").arg(_(msg)), 5000); showStatusMessage(tr("Disassembler failed: %1").arg(QString::fromLocal8Bit(msg)), 5000);
} }
} }

View File

@@ -121,7 +121,7 @@ void PlainGdbAdapter::handleFileExecAndSymbols(const GdbResponse &response)
emit inferiorPrepared(); emit inferiorPrepared();
} else { } else {
QString msg = tr("Starting executable failed:\n") + QString msg = tr("Starting executable failed:\n") +
__(response.data.findChild("msg").data()); QString::fromLocal8Bit(response.data.findChild("msg").data());
emit inferiorStartFailed(msg); emit inferiorStartFailed(msg);
} }
} }
@@ -163,7 +163,7 @@ void PlainGdbAdapter::handleExecRun(const GdbResponse &response)
showStatusMessage(msgInferiorStarted()); showStatusMessage(msgInferiorStarted());
} else { } else {
QTC_ASSERT(state() == InferiorRunningRequested, qDebug() << state()); QTC_ASSERT(state() == InferiorRunningRequested, qDebug() << state());
const QByteArray &msg = response.data.findChild("msg").data(); const QString &msg = QString::fromLocal8Bit(response.data.findChild("msg").data());
//QTC_ASSERT(status() == InferiorRunning, /**/); //QTC_ASSERT(status() == InferiorRunning, /**/);
//interruptInferior(); //interruptInferior();
emit inferiorStartFailed(msg); emit inferiorStartFailed(msg);

View File

@@ -203,7 +203,7 @@ void RemoteGdbAdapter::handleFileExecAndSymbols(const GdbResponse &response)
CB(handleTargetRemote)); CB(handleTargetRemote));
} else { } else {
QString msg = tr("Starting remote executable failed:\n"); QString msg = tr("Starting remote executable failed:\n");
msg += __(response.data.findChild("msg").data()); msg += QString::fromLocal8Bit(response.data.findChild("msg").data());
emit inferiorStartFailed(msg); emit inferiorStartFailed(msg);
} }
} }
@@ -219,7 +219,8 @@ void RemoteGdbAdapter::handleTargetRemote(const GdbResponse &record)
emit inferiorPrepared(); emit inferiorPrepared();
} else { } else {
// 16^error,msg="hd:5555: Connection timed out." // 16^error,msg="hd:5555: Connection timed out."
QString msg = msgConnectRemoteServerFailed(__(record.data.findChild("msg").data())); QString msg = msgConnectRemoteServerFailed(
QString::fromLocal8Bit(record.data.findChild("msg").data()));
emit inferiorStartFailed(msg); emit inferiorStartFailed(msg);
} }
} }

View File

@@ -143,7 +143,7 @@ void TermGdbAdapter::handleStubAttached(const GdbResponse &response)
m_engine->postCommand(_("-stack-list-frames 0 0"), CB(handleEntryPoint)); m_engine->postCommand(_("-stack-list-frames 0 0"), CB(handleEntryPoint));
#endif #endif
} else if (response.resultClass == GdbResultError) { } else if (response.resultClass == GdbResultError) {
QString msg = _(response.data.findChild("msg").data()); QString msg = QString::fromLocal8Bit(response.data.findChild("msg").data());
emit inferiorStartFailed(msg); emit inferiorStartFailed(msg);
} }
} }

View File

@@ -1628,7 +1628,7 @@ void TrkGdbAdapter::handleTargetRemote(const GdbResponse &record)
emit inferiorPrepared(); emit inferiorPrepared();
} else { } else {
QString msg = tr("Connecting to TRK server adapter failed:\n") QString msg = tr("Connecting to TRK server adapter failed:\n")
+ _(record.data.findChild("msg").data()); + QString::fromLocal8Bit(record.data.findChild("msg").data());
emit inferiorStartFailed(msg); emit inferiorStartFailed(msg);
} }
} }