diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index 8669ec5132c..997073d560c 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -662,7 +662,7 @@ void CdbEngine::setupInferior() runCommand({"pid", ExtensionCommand, [this](const DebuggerResponse &response) { // Fails for core dumps. if (response.resultClass == ResultDone) - notifyInferiorPid(response.data.data().toULongLong()); + notifyInferiorPid(response.data.toProcessHandle()); if (response.resultClass == ResultDone || runParameters().startMode == AttachCore) { STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorSetupOk") notifyInferiorSetupOk(); diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index 5df6b0096ac..bf15de1bcf2 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -1428,14 +1428,14 @@ bool DebuggerEngine::debuggerActionsEnabled(DebuggerState state) return false; } -void DebuggerEngine::notifyInferiorPid(qint64 pid) +void DebuggerEngine::notifyInferiorPid(const ProcessHandle &pid) { - if (d->m_inferiorPid.pid() == pid) + if (d->m_inferiorPid == pid) return; - d->m_inferiorPid = ProcessHandle(pid); - if (d->m_inferiorPid.isValid()) { - runControl()->setApplicationProcessHandle(d->m_inferiorPid); - showMessage(tr("Taking notice of pid %1").arg(pid)); + d->m_inferiorPid = pid; + if (pid.isValid()) { + runControl()->setApplicationProcessHandle(pid); + showMessage(tr("Taking notice of pid %1").arg(pid.pid())); if (d->m_runParameters.startMode == StartInternal || d->m_runParameters.startMode == StartExternal || d->m_runParameters.startMode == AttachExternal) diff --git a/src/plugins/debugger/debuggerengine.h b/src/plugins/debugger/debuggerengine.h index c9c9d532626..88789f05935 100644 --- a/src/plugins/debugger/debuggerengine.h +++ b/src/plugins/debugger/debuggerengine.h @@ -45,7 +45,11 @@ class QAbstractItemModel; QT_END_NAMESPACE namespace Core { class IOptionsPage; } -namespace Utils { class MacroExpander; } + +namespace Utils { +class MacroExpander; +class ProcessHandle; +} // Utils namespace Debugger { @@ -300,7 +304,7 @@ public: static QString stateName(int s); - void notifyInferiorPid(qint64 pid); + void notifyInferiorPid(const Utils::ProcessHandle &pid); qint64 inferiorPid() const; bool isReverseDebugging() const; void handleCommand(int role, const QVariant &value); diff --git a/src/plugins/debugger/debuggerprotocol.cpp b/src/plugins/debugger/debuggerprotocol.cpp index 2ce53c443c1..ba289945898 100644 --- a/src/plugins/debugger/debuggerprotocol.cpp +++ b/src/plugins/debugger/debuggerprotocol.cpp @@ -36,6 +36,8 @@ #include +#include + #define QTC_ASSERT_STRINGIFY_HELPER(x) #x #define QTC_ASSERT_STRINGIFY(x) QTC_ASSERT_STRINGIFY_HELPER(x) #define QTC_ASSERT_STRING(cond) qDebug("SOFT ASSERT: \"" cond"\" in file " __FILE__ ", line " QTC_ASSERT_STRINGIFY(__LINE__)) @@ -385,6 +387,11 @@ qulonglong GdbMi::toAddress() const return ba.toULongLong(0, 0); } +Utils::ProcessHandle GdbMi::toProcessHandle() const +{ + return Utils::ProcessHandle(m_data.toULongLong()); +} + ////////////////////////////////////////////////////////////////////////////////// // // GdbResponse diff --git a/src/plugins/debugger/debuggerprotocol.h b/src/plugins/debugger/debuggerprotocol.h index c23c5060b7b..07df3eecd6a 100644 --- a/src/plugins/debugger/debuggerprotocol.h +++ b/src/plugins/debugger/debuggerprotocol.h @@ -34,6 +34,8 @@ #include +namespace Utils { class ProcessHandle; } + namespace Debugger { namespace Internal { @@ -153,6 +155,7 @@ public: QString toString(bool multiline = false, int indent = 0) const; qulonglong toAddress() const; + Utils::ProcessHandle toProcessHandle() const; int toInt() const { return m_data.toInt(); } qint64 toLongLong() const { return m_data.toLongLong(); } void fromString(const QString &str); diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 152af4cc51c..bf1af8a15cb 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -637,13 +637,7 @@ void GdbEngine::handleAsyncOutput(const QString &asyncClass, const GdbMi &result // 7.1.50 has thread-group-started,id="i1",pid="3529" QString id = result["id"].data(); showStatusMessage(tr("Thread group %1 created").arg(id), 1000); - int pid = id.toInt(); - if (!pid) { - id = result["pid"].data(); - pid = id.toInt(); - } - if (pid) - notifyInferiorPid(pid); + notifyInferiorPid(result["pid"].toProcessHandle()); handleThreadGroupCreated(result); } else if (asyncClass == "thread-created") { //"{id="1",group-id="28902"}" diff --git a/src/plugins/debugger/gdb/termgdbadapter.cpp b/src/plugins/debugger/gdb/termgdbadapter.cpp index 9048b9dee6b..359f26f831d 100644 --- a/src/plugins/debugger/gdb/termgdbadapter.cpp +++ b/src/plugins/debugger/gdb/termgdbadapter.cpp @@ -116,7 +116,7 @@ void GdbTermEngine::setupInferior() QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state()); const qint64 attachedPID = m_stubProc.applicationPID(); const qint64 attachedMainThreadID = m_stubProc.applicationMainThreadID(); - notifyInferiorPid(attachedPID); + notifyInferiorPid(ProcessHandle(attachedPID)); const QString msg = (attachedMainThreadID != -1) ? QString("Going to attach to %1 (%2)").arg(attachedPID).arg(attachedMainThreadID) : QString("Going to attach to %1").arg(attachedPID); diff --git a/src/plugins/debugger/lldb/lldbengine.cpp b/src/plugins/debugger/lldb/lldbengine.cpp index 07695256208..c94a31d5a92 100644 --- a/src/plugins/debugger/lldb/lldbengine.cpp +++ b/src/plugins/debugger/lldb/lldbengine.cpp @@ -490,7 +490,7 @@ void LldbEngine::handleResponse(const QString &response) else if (name == "output") handleOutputNotification(item); else if (name == "pid") - notifyInferiorPid(item.toLongLong()); + notifyInferiorPid(item.toProcessHandle()); } } diff --git a/tests/auto/debugger/dumpers.pro b/tests/auto/debugger/dumpers.pro index 310906a4eb9..0eec400a89c 100644 --- a/tests/auto/debugger/dumpers.pro +++ b/tests/auto/debugger/dumpers.pro @@ -17,11 +17,13 @@ msvc { SOURCES += \ $$IDE_SOURCE_TREE/src/libs/utils/treemodel.cpp \ - $$IDE_SOURCE_TREE/src/libs/utils/qtcassert.cpp + $$IDE_SOURCE_TREE/src/libs/utils/qtcassert.cpp \ + $$IDE_SOURCE_TREE/src/libs/utils/processhandle.cpp HEADERS += \ $$IDE_SOURCE_TREE/src/libs/utils/treemodel.h \ - $$IDE_SOURCE_TREE/src/libs/utils/qtcassert.h + $$IDE_SOURCE_TREE/src/libs/utils/qtcassert.h \ + $$IDE_SOURCE_TREE/src/libs/utils/processhandle.h }