Commit 329db5f4 authored by hjk's avatar hjk

Debugger: Use ProcessHandle in notifyInferiorPid()

Change-Id: Idcb6819b64964b6aa0e72d182cc628feba37ba55
Reviewed-by: David Schulz's avatarDavid Schulz <david.schulz@qt.io>
parent c168ba9f
......@@ -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();
......
......@@ -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)
......
......@@ -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);
......
......@@ -36,6 +36,8 @@
#include <ctype.h>
#include <utils/processhandle.h>
#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
......
......@@ -34,6 +34,8 @@
#include <functional>
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);
......
......@@ -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"}"
......
......@@ -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);
......
......@@ -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());
}
}
......
......@@ -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
}
......
Markdown is supported
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