Commit 9bb67101 authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

Trk[TCF]: Proper exit handling

parent 1ff095ee
......@@ -598,8 +598,11 @@ void TcfTrkGdbAdapter::handleGdbServerCommand(const QByteArray &cmd)
else if (cmd == "k" || cmd.startsWith("vKill")) {
// Kill inferior process
logMessage(msgGdbPacket(QLatin1String("kill")));
m_trkDevice->sendProcessTerminateCommand(TcfTrkCallback(),
m_tcfProcessId);
// Requires id of main thread to terminate.
// Note that calling 'Settings|set|removeExecutable' crashes TCF TRK,
// so, it is apparently not required.
m_trkDevice->sendRunControlTerminateCommand(TcfTrkCallback(),
mainThreadContextId());
}
else if (cmd.startsWith('m')) {
......@@ -1066,12 +1069,6 @@ void TcfTrkGdbAdapter::cleanup()
if (!m_trkIODevice.isNull()) {
QAbstractSocket *socket = qobject_cast<QAbstractSocket *>(m_trkIODevice.data());
const bool isOpen = socket ? socket->state() == QAbstractSocket::ConnectedState : m_trkIODevice->isOpen();
if (isOpen) { // Not sure if that is required: Remove Trk's context?
if (!m_remoteExecutable.isEmpty() && m_uid) {
m_trkDevice->sendSettingsRemoveExecutableCommand(m_remoteExecutable, m_uid);
m_uid = 0;
}
}
if (isOpen) {
if (socket) {
socket->disconnect();
......
......@@ -689,6 +689,16 @@ void TcfTrkDevice::sendProcessTerminateCommand(const TcfTrkCallback &callBack,
sendTcfTrkMessage(MessageWithReply, ProcessesService, "terminate", data, callBack, cookie);
}
void TcfTrkDevice::sendRunControlTerminateCommand(const TcfTrkCallback &callBack,
const QByteArray &id,
const QVariant &cookie)
{
QByteArray data;
JsonInputStream str(data);
str << id;
sendTcfTrkMessage(MessageWithReply, RunControlService, "terminate", data, callBack, cookie);
}
// Non-standard: Remove executable from settings
void TcfTrkDevice::sendSettingsRemoveExecutableCommand(const QString &binaryIn,
unsigned uid,
......
......@@ -158,6 +158,11 @@ public:
const QStringList &additionalLibraries = QStringList(),
const QVariant &cookie = QVariant());
// Preferred over Processes:Terminate by TCF TRK.
void sendRunControlTerminateCommand(const TcfTrkCallback &callBack,
const QByteArray &id,
const QVariant &cookie = QVariant());
void sendProcessTerminateCommand(const TcfTrkCallback &callBack,
const QByteArray &id,
const QVariant &cookie = QVariant());
......
Supports Markdown
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