forked from qt-creator/qt-creator
debugger: move m_inferiorPid from DebuggerManager to DebuggerRunControl
This commit is contained in:
@@ -1259,11 +1259,11 @@ void CdbDebugEngine::slotConsoleStubStarted()
|
||||
const qint64 appPid = m_d->m_consoleStubProc.applicationPID();
|
||||
if (debugCDB)
|
||||
qDebug() << Q_FUNC_INFO << appPid;
|
||||
// Attach to console process
|
||||
// Attach to console process.
|
||||
QString errorMessage;
|
||||
if (startAttachDebugger(appPid, AttachExternal, &errorMessage)) {
|
||||
m_d->startWatchTimer();
|
||||
manager()->notifyInferiorPidChanged(appPid);
|
||||
runControl()->notifyInferiorPid(appPid);
|
||||
} else {
|
||||
QMessageBox::critical(DebuggerUISwitcher::instance()->mainWindow(), tr("Debugger Error"), errorMessage);
|
||||
}
|
||||
|
@@ -268,7 +268,6 @@ struct DebuggerManagerPrivate
|
||||
|
||||
// FIXME: Remove engine-specific state
|
||||
DebuggerRunControl *m_runControl;
|
||||
qint64 m_inferiorPid;
|
||||
|
||||
/// Views
|
||||
DebuggerMainWindow *m_mainWindow;
|
||||
@@ -324,7 +323,6 @@ DebuggerManagerPrivate::DebuggerManagerPrivate(DebuggerManager *manager) :
|
||||
m_stopIcon(QLatin1String(":/debugger/images/debugger_stop_small.png")),
|
||||
m_interruptIcon(QLatin1String(":/debugger/images/debugger_interrupt_small.png")),
|
||||
m_locationMarkIcon(QLatin1String(":/debugger/images/location_16.png")),
|
||||
m_inferiorPid(0),
|
||||
m_disassemblerViewAgent(manager),
|
||||
m_engine(0)
|
||||
{
|
||||
@@ -809,16 +807,6 @@ void DebuggerManager::notifyInferiorExited()
|
||||
showStatusMessage(tr("Exited"), 5000);
|
||||
}
|
||||
|
||||
void DebuggerManager::notifyInferiorPidChanged(qint64 pid)
|
||||
{
|
||||
STATE_DEBUG(d->m_inferiorPid << pid);
|
||||
|
||||
if (d->m_inferiorPid != pid) {
|
||||
d->m_inferiorPid = pid;
|
||||
emit inferiorPidChanged(pid);
|
||||
}
|
||||
}
|
||||
|
||||
void DebuggerManager::aboutToShutdown()
|
||||
{
|
||||
STATE_DEBUG(d->m_engine);
|
||||
@@ -985,7 +973,6 @@ void DebuggerManager::startNewDebugger(DebuggerRunControl *runControl)
|
||||
return;
|
||||
d->m_runControl = runControl;
|
||||
const DebuggerStartParameters *sp = &runControl->sp();
|
||||
d->m_inferiorPid = sp->attachPID > 0 ? sp->attachPID : 0;
|
||||
const QString toolChainName = ProjectExplorer::ToolChain::toolChainName(
|
||||
ProjectExplorer::ToolChain::ToolChainType(sp->toolChainType));
|
||||
|
||||
@@ -1095,11 +1082,6 @@ void DebuggerManager::abortDebugger()
|
||||
d->m_codeModelSnapshot = CPlusPlus::Snapshot();
|
||||
}
|
||||
|
||||
qint64 DebuggerManager::inferiorPid() const
|
||||
{
|
||||
return d->m_inferiorPid;
|
||||
}
|
||||
|
||||
void DebuggerManager::assignValueInDebugger()
|
||||
{
|
||||
if (QAction *action = qobject_cast<QAction *>(sender())) {
|
||||
|
@@ -152,7 +152,6 @@ public:
|
||||
Internal::IDebuggerEngine *currentEngine() const;
|
||||
|
||||
DebuggerRunControl *runControl() const;
|
||||
qint64 inferiorPid() const;
|
||||
|
||||
QMessageBox *showMessageBox(int icon, const QString &title, const QString &text,
|
||||
int buttons = 0);
|
||||
@@ -273,7 +272,6 @@ private:
|
||||
void notifyInferiorStopped();
|
||||
void notifyInferiorRunning();
|
||||
void notifyInferiorExited();
|
||||
void notifyInferiorPidChanged(qint64);
|
||||
|
||||
void cleanupViews();
|
||||
|
||||
@@ -296,7 +294,6 @@ private:
|
||||
|
||||
signals:
|
||||
void debuggingFinished();
|
||||
void inferiorPidChanged(qint64 pid);
|
||||
void stateChanged(int newstatus);
|
||||
void statusMessageRequested(const QString &msg, int timeout); // -1 for 'forever'
|
||||
void applicationOutputAvailable(const QString &output, bool onStdErr);
|
||||
|
@@ -56,6 +56,7 @@
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QFileInfo>
|
||||
#include <QtCore/QTimer>
|
||||
|
||||
#include <QtGui/QAbstractItemView>
|
||||
#include <QtGui/QTextDocument>
|
||||
@@ -166,6 +167,7 @@ public:
|
||||
DebuggerManager *m_manager;
|
||||
Internal::IDebuggerEngine *m_engine;
|
||||
bool m_running;
|
||||
qint64 m_inferiorPid;
|
||||
|
||||
ModulesHandler *m_modulesHandler;
|
||||
RegisterHandler *m_registerHandler;
|
||||
@@ -188,6 +190,7 @@ DebuggerRunControl::Private::Private(DebuggerRunControl *parent,
|
||||
m_engine(0)
|
||||
{
|
||||
m_running = false;
|
||||
m_inferiorPid = m_startParameters.attachPID > 0 ? m_startParameters.attachPID : 0;
|
||||
m_modulesHandler = new ModulesHandler(q);
|
||||
m_registerHandler = new RegisterHandler();
|
||||
m_snapshotHandler = new SnapshotHandler(q);
|
||||
@@ -219,9 +222,6 @@ DebuggerRunControl::DebuggerRunControl(DebuggerManager *manager,
|
||||
Qt::QueuedConnection);
|
||||
connect(d->m_manager, SIGNAL(messageAvailable(QString, bool)),
|
||||
this, SLOT(slotMessageAvailable(QString, bool)));
|
||||
connect(d->m_manager, SIGNAL(inferiorPidChanged(qint64)),
|
||||
this, SLOT(bringApplicationToForeground(qint64)),
|
||||
Qt::QueuedConnection);
|
||||
connect(this, SIGNAL(stopRequested()),
|
||||
d->m_manager, SLOT(exitDebugger()));
|
||||
|
||||
@@ -383,6 +383,24 @@ void DebuggerRunControl::startDebugger(IDebuggerEngine *engine)
|
||||
d->m_engine->startDebugger();
|
||||
}
|
||||
|
||||
void DebuggerRunControl::notifyInferiorPid(qint64 pid)
|
||||
{
|
||||
//STATE_DEBUG(d->m_inferiorPid << pid);
|
||||
if (d->m_inferiorPid == pid)
|
||||
return;
|
||||
d->m_inferiorPid = pid;
|
||||
QTimer::singleShot(0, this, SLOT(raiseApplication()));
|
||||
}
|
||||
|
||||
qint64 DebuggerRunControl::inferiorPid() const
|
||||
{
|
||||
return d->m_inferiorPid;
|
||||
}
|
||||
|
||||
void DebuggerRunControl::raiseApplication()
|
||||
{
|
||||
bringApplicationToForeground(d->m_inferiorPid);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
@@ -150,6 +150,9 @@ public:
|
||||
|
||||
void cleanup();
|
||||
void startDebugger(Internal::IDebuggerEngine *engine);
|
||||
void notifyInferiorPid(qint64 pid);
|
||||
qint64 inferiorPid() const;
|
||||
|
||||
Internal::IDebuggerEngine *engine();
|
||||
|
||||
signals:
|
||||
@@ -160,6 +163,7 @@ public slots:
|
||||
|
||||
private slots:
|
||||
void slotMessageAvailable(const QString &data, bool isError);
|
||||
void raiseApplication();
|
||||
|
||||
private:
|
||||
void init();
|
||||
|
@@ -444,13 +444,12 @@ void GdbEngine::handleResponse(const QByteArray &buff)
|
||||
// Archer had only "{id="28902"}" at some point of 6.8.x.
|
||||
// *-started seems to be standard in 7.1, but in early
|
||||
// 7.0.x, there was a *-created instead.
|
||||
int progress = m_progress->progressValue();
|
||||
const int progress = m_progress->progressValue();
|
||||
m_progress->setProgressValue(qMin(70, progress + 1));
|
||||
QByteArray id = result.findChild("id").data();
|
||||
showStatusMessage(tr("Thread group %1 created").arg(_(id)), 1000);
|
||||
int pid = id.toInt();
|
||||
if (pid != inferiorPid())
|
||||
handleInferiorPidChanged(pid);
|
||||
const int pid = id.toInt();
|
||||
runControl()->notifyInferiorPid(pid);
|
||||
} else if (asyncClass == "thread-created") {
|
||||
//"{id="1",group-id="28902"}"
|
||||
QByteArray id = result.findChild("id").data();
|
||||
@@ -503,7 +502,7 @@ void GdbEngine::handleResponse(const QByteArray &buff)
|
||||
m_pendingConsoleStreamOutput += data;
|
||||
|
||||
// Parse pid from noise.
|
||||
if (!inferiorPid()) {
|
||||
if (!runControl()->inferiorPid()) {
|
||||
// Linux/Mac gdb: [New [Tt]hread 0x545 (LWP 4554)]
|
||||
static QRegExp re1(_("New .hread 0x[0-9a-f]+ \\(LWP ([0-9]*)\\)"));
|
||||
// MinGW 6.8: [New thread 2437.0x435345]
|
||||
@@ -693,11 +692,11 @@ void GdbEngine::maybeHandleInferiorPidChanged(const QString &pid0)
|
||||
showMessage(_("Cannot parse PID from %1").arg(pid0));
|
||||
return;
|
||||
}
|
||||
if (pid == inferiorPid())
|
||||
if (pid == runControl()->inferiorPid())
|
||||
return;
|
||||
showMessage(_("FOUND PID %1").arg(pid));
|
||||
|
||||
handleInferiorPidChanged(pid);
|
||||
runControl()->notifyInferiorPid(pid);
|
||||
}
|
||||
|
||||
void GdbEngine::postCommand(const QByteArray &command, AdapterCallback callback,
|
||||
@@ -1276,7 +1275,7 @@ void GdbEngine::handleStopResponse(const GdbMi &data)
|
||||
// Gdb <= 6.8 reports a frame but no reason, 6.8.50+ reports everything.
|
||||
// The case of the user really setting a breakpoint at _start is simply
|
||||
// unsupported.
|
||||
if (!inferiorPid()) // For programs without -pthread under gdb <= 6.8.
|
||||
if (!runControl()->inferiorPid()) // For programs without -pthread under gdb <= 6.8.
|
||||
postCommand("info proc", CB(handleInfoProc));
|
||||
continueInferiorInternal();
|
||||
return;
|
||||
|
@@ -321,8 +321,6 @@ private: ////////// Inferior Management //////////
|
||||
void handleExecuteNext(const GdbResponse &response);
|
||||
void handleExecuteReturn(const GdbResponse &response);
|
||||
|
||||
qint64 inferiorPid() const { return m_manager->inferiorPid(); }
|
||||
void handleInferiorPidChanged(qint64 pid) { manager()->notifyInferiorPidChanged(pid); }
|
||||
void maybeHandleInferiorPidChanged(const QString &pid);
|
||||
void handleInfoProc(const GdbResponse &response);
|
||||
|
||||
|
@@ -123,7 +123,7 @@ void LocalPlainGdbAdapter::checkForReleaseBuild()
|
||||
|
||||
void LocalPlainGdbAdapter::interruptInferior()
|
||||
{
|
||||
const qint64 attachedPID = m_engine->inferiorPid();
|
||||
const qint64 attachedPID = runControl()->inferiorPid();
|
||||
if (attachedPID <= 0) {
|
||||
showMessage(_("TRYING TO INTERRUPT INFERIOR BEFORE PID WAS OBTAINED"));
|
||||
return;
|
||||
|
@@ -120,7 +120,7 @@ void TermGdbAdapter::startInferior()
|
||||
{
|
||||
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
|
||||
const qint64 attachedPID = m_stubProc.applicationPID();
|
||||
m_engine->handleInferiorPidChanged(attachedPID);
|
||||
runControl()->notifyInferiorPid(attachedPID);
|
||||
m_engine->postCommand("attach " + QByteArray::number(attachedPID),
|
||||
CB(handleStubAttached));
|
||||
}
|
||||
@@ -159,7 +159,7 @@ void TermGdbAdapter::handleEntryPoint(const GdbResponse &response)
|
||||
|
||||
void TermGdbAdapter::interruptInferior()
|
||||
{
|
||||
const qint64 attachedPID = m_engine->inferiorPid();
|
||||
const qint64 attachedPID = runControl()->inferiorPid();
|
||||
QTC_ASSERT(attachedPID > 0, return);
|
||||
if (!interruptProcess(attachedPID))
|
||||
showMessage(_("CANNOT INTERRUPT %1").arg(attachedPID));
|
||||
|
Reference in New Issue
Block a user