Debugger: Fix interrupting code.

- Windows: Always use DebugBreakProcess if Qt Creator is compiled
  64bit. Else always use win64interrupt.exe if Qt Creator
  is a WOW64 application.
- Remove redundant code (procinterrupt/hostutils, gdb adapters).
- Give interruptProcess an errorMessage parameter such that it can
  be used by all C++ engines and a proper error is displayed.
- Improve error messages.
- Build win64interrupt if target architecture is 64 bit (clean tools
  profile, add a profile), borrowing the check from
  qtcreatorcdbext.pro.

Change-Id: I2a6caf98e46051c49c84e1f3aac4c8d2aba66e8b
Reviewed-by: David Schulz <david.schulz@nokia.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
This commit is contained in:
Friedemann Kleint
2012-02-02 09:30:22 +01:00
parent 1d3dc30153
commit 38510a482d
14 changed files with 185 additions and 125 deletions

View File

@@ -34,6 +34,7 @@
#include "gdbengine.h"
#include "debuggerstartparameters.h"
#include "abstractgdbprocess.h"
#include "procinterrupt.h"
#include <utils/qtcassert.h>
#include <utils/qtcprocess.h>
@@ -158,5 +159,21 @@ void AbstractGdbAdapter::handleRemoteSetupFailed(const QString &reason)
Q_UNUSED(reason);
}
void AbstractGdbAdapter::interruptLocalInferior(qint64 pid)
{
QTC_ASSERT(state() == InferiorStopRequested, qDebug() << state(); return);
if (pid <= 0) {
showMessage(QLatin1String("TRYING TO INTERRUPT INFERIOR BEFORE PID WAS OBTAINED"), LogError);
return;
}
QString errorMessage;
if (interruptProcess(pid, GdbEngineType, &errorMessage)) {
showMessage(QLatin1String("Interrupted ") + QString::number(pid));
} else {
showMessage(errorMessage, LogError);
m_engine->notifyInferiorStopFailed();
}
}
} // namespace Internal
} // namespace Debugger

View File

@@ -96,6 +96,7 @@ public:
virtual void handleRemoteSetupDone(int gdbServerPort, int qmlPort);
virtual void handleRemoteSetupFailed(const QString &reason);
protected:
DebuggerState state() const;
GdbEngine *engine() const { return m_engine; }
@@ -103,6 +104,7 @@ protected:
DebuggerStartParameters &startParameters();
void showMessage(const QString &msg, int channel = LogDebug, int timeout = 1);
bool prepareCommand();
void interruptLocalInferior(qint64 pid);
GdbEngine * const m_engine;
};

View File

@@ -113,13 +113,7 @@ void AttachGdbAdapter::handleAttach(const GdbResponse &response)
void AttachGdbAdapter::interruptInferior()
{
QTC_ASSERT(state() == InferiorStopRequested, qDebug() << state(); return);
const qint64 pid = startParameters().attachPID;
QTC_ASSERT(pid > 0, return);
if (!interruptProcess(pid)) {
showMessage(_("CANNOT INTERRUPT %1").arg(pid));
m_engine->notifyInferiorStopFailed();
}
interruptLocalInferior(startParameters().attachPID);
}
void AttachGdbAdapter::shutdownInferior()

View File

@@ -174,18 +174,7 @@ void LocalPlainGdbAdapter::checkForReleaseBuild()
void LocalPlainGdbAdapter::interruptInferior()
{
const qint64 attachedPID = m_engine->inferiorPid();
if (attachedPID <= 0) {
showMessage(_("TRYING TO INTERRUPT INFERIOR BEFORE PID WAS OBTAINED"));
return;
}
if (interruptProcess(attachedPID)) {
showMessage(_("INTERRUPTED %1").arg(attachedPID));
} else {
showMessage(_("CANNOT INTERRUPT %1").arg(attachedPID));
m_engine->notifyInferiorStopFailed();
}
interruptLocalInferior(m_engine->inferiorPid());
}
QByteArray LocalPlainGdbAdapter::execFilePath() const

View File

@@ -192,10 +192,7 @@ void TermGdbAdapter::runEngine()
void TermGdbAdapter::interruptInferior()
{
const qint64 attachedPID = m_engine->inferiorPid();
QTC_ASSERT(attachedPID > 0, return);
if (!interruptProcess(attachedPID))
showMessage(_("CANNOT INTERRUPT %1").arg(attachedPID));
interruptLocalInferior(m_engine->inferiorPid());
}
void TermGdbAdapter::stubError(const QString &msg)