forked from qt-creator/qt-creator
Debugger: Use ProcessHandle in notifyInferiorPid()
Change-Id: Idcb6819b64964b6aa0e72d182cc628feba37ba55 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -662,7 +662,7 @@ void CdbEngine::setupInferior()
|
|||||||
runCommand({"pid", ExtensionCommand, [this](const DebuggerResponse &response) {
|
runCommand({"pid", ExtensionCommand, [this](const DebuggerResponse &response) {
|
||||||
// Fails for core dumps.
|
// Fails for core dumps.
|
||||||
if (response.resultClass == ResultDone)
|
if (response.resultClass == ResultDone)
|
||||||
notifyInferiorPid(response.data.data().toULongLong());
|
notifyInferiorPid(response.data.toProcessHandle());
|
||||||
if (response.resultClass == ResultDone || runParameters().startMode == AttachCore) {
|
if (response.resultClass == ResultDone || runParameters().startMode == AttachCore) {
|
||||||
STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorSetupOk")
|
STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorSetupOk")
|
||||||
notifyInferiorSetupOk();
|
notifyInferiorSetupOk();
|
||||||
|
@@ -1428,14 +1428,14 @@ bool DebuggerEngine::debuggerActionsEnabled(DebuggerState state)
|
|||||||
return false;
|
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;
|
return;
|
||||||
d->m_inferiorPid = ProcessHandle(pid);
|
d->m_inferiorPid = pid;
|
||||||
if (d->m_inferiorPid.isValid()) {
|
if (pid.isValid()) {
|
||||||
runControl()->setApplicationProcessHandle(d->m_inferiorPid);
|
runControl()->setApplicationProcessHandle(pid);
|
||||||
showMessage(tr("Taking notice of pid %1").arg(pid));
|
showMessage(tr("Taking notice of pid %1").arg(pid.pid()));
|
||||||
if (d->m_runParameters.startMode == StartInternal
|
if (d->m_runParameters.startMode == StartInternal
|
||||||
|| d->m_runParameters.startMode == StartExternal
|
|| d->m_runParameters.startMode == StartExternal
|
||||||
|| d->m_runParameters.startMode == AttachExternal)
|
|| d->m_runParameters.startMode == AttachExternal)
|
||||||
|
@@ -45,7 +45,11 @@ class QAbstractItemModel;
|
|||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Core { class IOptionsPage; }
|
namespace Core { class IOptionsPage; }
|
||||||
namespace Utils { class MacroExpander; }
|
|
||||||
|
namespace Utils {
|
||||||
|
class MacroExpander;
|
||||||
|
class ProcessHandle;
|
||||||
|
} // Utils
|
||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
|
|
||||||
@@ -300,7 +304,7 @@ public:
|
|||||||
|
|
||||||
static QString stateName(int s);
|
static QString stateName(int s);
|
||||||
|
|
||||||
void notifyInferiorPid(qint64 pid);
|
void notifyInferiorPid(const Utils::ProcessHandle &pid);
|
||||||
qint64 inferiorPid() const;
|
qint64 inferiorPid() const;
|
||||||
bool isReverseDebugging() const;
|
bool isReverseDebugging() const;
|
||||||
void handleCommand(int role, const QVariant &value);
|
void handleCommand(int role, const QVariant &value);
|
||||||
|
@@ -36,6 +36,8 @@
|
|||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#include <utils/processhandle.h>
|
||||||
|
|
||||||
#define QTC_ASSERT_STRINGIFY_HELPER(x) #x
|
#define QTC_ASSERT_STRINGIFY_HELPER(x) #x
|
||||||
#define QTC_ASSERT_STRINGIFY(x) QTC_ASSERT_STRINGIFY_HELPER(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__))
|
#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);
|
return ba.toULongLong(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Utils::ProcessHandle GdbMi::toProcessHandle() const
|
||||||
|
{
|
||||||
|
return Utils::ProcessHandle(m_data.toULongLong());
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// GdbResponse
|
// GdbResponse
|
||||||
|
@@ -34,6 +34,8 @@
|
|||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
|
namespace Utils { class ProcessHandle; }
|
||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -153,6 +155,7 @@ public:
|
|||||||
|
|
||||||
QString toString(bool multiline = false, int indent = 0) const;
|
QString toString(bool multiline = false, int indent = 0) const;
|
||||||
qulonglong toAddress() const;
|
qulonglong toAddress() const;
|
||||||
|
Utils::ProcessHandle toProcessHandle() const;
|
||||||
int toInt() const { return m_data.toInt(); }
|
int toInt() const { return m_data.toInt(); }
|
||||||
qint64 toLongLong() const { return m_data.toLongLong(); }
|
qint64 toLongLong() const { return m_data.toLongLong(); }
|
||||||
void fromString(const QString &str);
|
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"
|
// 7.1.50 has thread-group-started,id="i1",pid="3529"
|
||||||
QString id = result["id"].data();
|
QString id = result["id"].data();
|
||||||
showStatusMessage(tr("Thread group %1 created").arg(id), 1000);
|
showStatusMessage(tr("Thread group %1 created").arg(id), 1000);
|
||||||
int pid = id.toInt();
|
notifyInferiorPid(result["pid"].toProcessHandle());
|
||||||
if (!pid) {
|
|
||||||
id = result["pid"].data();
|
|
||||||
pid = id.toInt();
|
|
||||||
}
|
|
||||||
if (pid)
|
|
||||||
notifyInferiorPid(pid);
|
|
||||||
handleThreadGroupCreated(result);
|
handleThreadGroupCreated(result);
|
||||||
} else if (asyncClass == "thread-created") {
|
} else if (asyncClass == "thread-created") {
|
||||||
//"{id="1",group-id="28902"}"
|
//"{id="1",group-id="28902"}"
|
||||||
|
@@ -116,7 +116,7 @@ void GdbTermEngine::setupInferior()
|
|||||||
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
|
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
|
||||||
const qint64 attachedPID = m_stubProc.applicationPID();
|
const qint64 attachedPID = m_stubProc.applicationPID();
|
||||||
const qint64 attachedMainThreadID = m_stubProc.applicationMainThreadID();
|
const qint64 attachedMainThreadID = m_stubProc.applicationMainThreadID();
|
||||||
notifyInferiorPid(attachedPID);
|
notifyInferiorPid(ProcessHandle(attachedPID));
|
||||||
const QString msg = (attachedMainThreadID != -1)
|
const QString msg = (attachedMainThreadID != -1)
|
||||||
? QString("Going to attach to %1 (%2)").arg(attachedPID).arg(attachedMainThreadID)
|
? QString("Going to attach to %1 (%2)").arg(attachedPID).arg(attachedMainThreadID)
|
||||||
: QString("Going to attach to %1").arg(attachedPID);
|
: QString("Going to attach to %1").arg(attachedPID);
|
||||||
|
@@ -490,7 +490,7 @@ void LldbEngine::handleResponse(const QString &response)
|
|||||||
else if (name == "output")
|
else if (name == "output")
|
||||||
handleOutputNotification(item);
|
handleOutputNotification(item);
|
||||||
else if (name == "pid")
|
else if (name == "pid")
|
||||||
notifyInferiorPid(item.toLongLong());
|
notifyInferiorPid(item.toProcessHandle());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -17,11 +17,13 @@ msvc {
|
|||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$IDE_SOURCE_TREE/src/libs/utils/treemodel.cpp \
|
$$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 += \
|
HEADERS += \
|
||||||
$$IDE_SOURCE_TREE/src/libs/utils/treemodel.h \
|
$$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
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user