forked from qt-creator/qt-creator
Debugger: Use Utils::ProcessHandle for DebuggerEngine::m_inferiorPid
That's the intended "typesafe" use. Change-Id: Ib288fe87a47bd9484bda83e05406f0d22989b3c2 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -428,10 +428,10 @@ void CdbEngine::consoleStubProcessStarted()
|
||||
DebuggerRunParameters attachParameters = runParameters();
|
||||
attachParameters.inferior.executable.clear();
|
||||
attachParameters.inferior.commandLineArguments.clear();
|
||||
attachParameters.attachPID = m_consoleStub->applicationPID();
|
||||
attachParameters.attachPID = ProcessHandle(m_consoleStub->applicationPID());
|
||||
attachParameters.startMode = AttachExternal;
|
||||
attachParameters.useTerminal = false;
|
||||
showMessage(QString("Attaching to %1...").arg(attachParameters.attachPID), LogMisc);
|
||||
showMessage(QString("Attaching to %1...").arg(attachParameters.attachPID.pid()), LogMisc);
|
||||
QString errorMessage;
|
||||
if (!launchCDB(attachParameters, &errorMessage)) {
|
||||
showMessage(errorMessage, LogError);
|
||||
@@ -570,7 +570,7 @@ bool CdbEngine::launchCDB(const DebuggerRunParameters &sp, QString *errorMessage
|
||||
break;
|
||||
case AttachExternal:
|
||||
case AttachCrashedExternal:
|
||||
arguments << "-p" << QString::number(sp.attachPID);
|
||||
arguments << "-p" << QString::number(sp.attachPID.pid());
|
||||
if (sp.startMode == AttachCrashedExternal) {
|
||||
arguments << "-e" << sp.crashParameter << "-g";
|
||||
} else {
|
||||
|
@@ -108,7 +108,7 @@ QDebug operator<<(QDebug str, const DebuggerRunParameters &sp)
|
||||
<< " inferior environment=<" << sp.inferior.environment.size() << " variables>"
|
||||
<< " debugger environment=<" << sp.debugger.environment.size() << " variables>"
|
||||
<< " workingDir=" << sp.inferior.workingDirectory
|
||||
<< " attachPID=" << sp.attachPID
|
||||
<< " attachPID=" << sp.attachPID.pid()
|
||||
<< " useTerminal=" << sp.useTerminal
|
||||
<< " remoteChannel=" << sp.remoteChannel
|
||||
<< " serverStartScript=" << sp.serverStartScript
|
||||
@@ -311,7 +311,7 @@ public:
|
||||
void raiseApplication()
|
||||
{
|
||||
QTC_ASSERT(runControl(), return);
|
||||
runControl()->bringApplicationToForeground(m_inferiorPid);
|
||||
runControl()->bringApplicationToForeground(m_inferiorPid.pid());
|
||||
}
|
||||
|
||||
void scheduleResetLocation()
|
||||
@@ -363,7 +363,7 @@ public:
|
||||
RemoteSetupState m_remoteSetupState = RemoteSetupNone;
|
||||
|
||||
Terminal m_terminal;
|
||||
qint64 m_inferiorPid = 0;
|
||||
ProcessHandle m_inferiorPid;
|
||||
|
||||
ModulesHandler m_modulesHandler;
|
||||
RegisterHandler m_registerHandler;
|
||||
@@ -593,10 +593,10 @@ void DebuggerEngine::startDebugger(DebuggerRunControl *runControl)
|
||||
|
||||
d->m_runControl = runControl;
|
||||
|
||||
d->m_inferiorPid = d->m_runParameters.attachPID > 0
|
||||
? d->m_runParameters.attachPID : 0;
|
||||
if (d->m_inferiorPid)
|
||||
d->m_runControl->setApplicationProcessHandle(ProcessHandle(d->m_inferiorPid));
|
||||
d->m_inferiorPid = d->m_runParameters.attachPID.isValid()
|
||||
? d->m_runParameters.attachPID : ProcessHandle();
|
||||
if (d->m_inferiorPid.isValid())
|
||||
d->m_runControl->setApplicationProcessHandle(d->m_inferiorPid);
|
||||
|
||||
if (isNativeMixedActive())
|
||||
d->m_runParameters.inferior.environment.set("QV4_FORCE_INTERPRETER", "1");
|
||||
@@ -945,7 +945,7 @@ void DebuggerEngine::notifyEngineRemoteSetupFinished(const RemoteSetupResult &re
|
||||
}
|
||||
} else if (result.inferiorPid != InvalidPid && runParameters().startMode == AttachExternal) {
|
||||
// e.g. iOS Simulator
|
||||
runParameters().attachPID = result.inferiorPid;
|
||||
runParameters().attachPID = ProcessHandle(result.inferiorPid);
|
||||
}
|
||||
|
||||
if (result.qmlServerPort.isValid()) {
|
||||
@@ -1430,11 +1430,11 @@ bool DebuggerEngine::debuggerActionsEnabled(DebuggerState state)
|
||||
|
||||
void DebuggerEngine::notifyInferiorPid(qint64 pid)
|
||||
{
|
||||
if (d->m_inferiorPid == pid)
|
||||
if (d->m_inferiorPid.pid() == pid)
|
||||
return;
|
||||
d->m_inferiorPid = pid;
|
||||
if (pid) {
|
||||
runControl()->setApplicationProcessHandle(ProcessHandle(pid));
|
||||
d->m_inferiorPid = ProcessHandle(pid);
|
||||
if (d->m_inferiorPid.isValid()) {
|
||||
runControl()->setApplicationProcessHandle(d->m_inferiorPid);
|
||||
showMessage(tr("Taking notice of pid %1").arg(pid));
|
||||
if (d->m_runParameters.startMode == StartInternal
|
||||
|| d->m_runParameters.startMode == StartExternal
|
||||
@@ -1445,7 +1445,7 @@ void DebuggerEngine::notifyInferiorPid(qint64 pid)
|
||||
|
||||
qint64 DebuggerEngine::inferiorPid() const
|
||||
{
|
||||
return d->m_inferiorPid;
|
||||
return d->m_inferiorPid.pid();
|
||||
}
|
||||
|
||||
bool DebuggerEngine::isReverseDebugging() const
|
||||
|
@@ -1166,9 +1166,9 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it,
|
||||
if (pid) {
|
||||
rp.startMode = AttachExternal;
|
||||
rp.closeMode = DetachAtClose;
|
||||
rp.attachPID = pid;
|
||||
rp.displayName = tr("Process %1").arg(rp.attachPID);
|
||||
rp.startMessage = tr("Attaching to local process %1.").arg(rp.attachPID);
|
||||
rp.attachPID = ProcessHandle(pid);
|
||||
rp.displayName = tr("Process %1").arg(rp.attachPID.pid());
|
||||
rp.startMessage = tr("Attaching to local process %1.").arg(rp.attachPID.pid());
|
||||
} else {
|
||||
rp.startMode = StartExternal;
|
||||
QStringList args = it->split(QLatin1Char(','));
|
||||
@@ -1230,10 +1230,10 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it,
|
||||
DebuggerRunParameters rp;
|
||||
rp.startMode = AttachCrashedExternal;
|
||||
rp.crashParameter = it->section(QLatin1Char(':'), 0, 0);
|
||||
rp.attachPID = it->section(QLatin1Char(':'), 1, 1).toULongLong();
|
||||
rp.displayName = tr("Crashed process %1").arg(rp.attachPID);
|
||||
rp.startMessage = tr("Attaching to crashed process %1").arg(rp.attachPID);
|
||||
if (!rp.attachPID) {
|
||||
rp.attachPID = ProcessHandle(it->section(QLatin1Char(':'), 1, 1).toULongLong());
|
||||
rp.displayName = tr("Crashed process %1").arg(rp.attachPID.pid());
|
||||
rp.startMessage = tr("Attaching to crashed process %1").arg(rp.attachPID.pid());
|
||||
if (!rp.attachPID.isValid()) {
|
||||
*errorMessage = DebuggerPlugin::tr("The parameter \"%1\" of option \"%2\" "
|
||||
"does not match the pattern <handle>:<pid>.").arg(*it, option);
|
||||
return false;
|
||||
@@ -2108,7 +2108,7 @@ DebuggerRunControl *DebuggerPluginPrivate::attachToRunningProcess(Kit *kit,
|
||||
}
|
||||
|
||||
DebuggerRunParameters rp;
|
||||
rp.attachPID = process.pid;
|
||||
rp.attachPID = ProcessHandle(process.pid);
|
||||
rp.displayName = tr("Process %1").arg(process.pid);
|
||||
rp.inferior.executable = process.exe;
|
||||
rp.startMode = AttachExternal;
|
||||
@@ -2120,8 +2120,8 @@ DebuggerRunControl *DebuggerPluginPrivate::attachToRunningProcess(Kit *kit,
|
||||
void DebuggerPlugin::attachExternalApplication(RunControl *rc)
|
||||
{
|
||||
DebuggerRunParameters rp;
|
||||
rp.attachPID = rc->applicationProcessHandle().pid();
|
||||
rp.displayName = tr("Process %1").arg(rp.attachPID);
|
||||
rp.attachPID = rc->applicationProcessHandle();
|
||||
rp.displayName = tr("Process %1").arg(rp.attachPID.pid());
|
||||
rp.startMode = AttachExternal;
|
||||
rp.closeMode = DetachAtClose;
|
||||
rp.toolChainAbi = rc->abi();
|
||||
@@ -2924,8 +2924,8 @@ static QString formatStartParameters(DebuggerRunParameters &sp)
|
||||
str << "Debugger: " << QDir::toNativeSeparators(cmd) << '\n';
|
||||
if (!sp.coreFile.isEmpty())
|
||||
str << "Core: " << QDir::toNativeSeparators(sp.coreFile) << '\n';
|
||||
if (sp.attachPID > 0)
|
||||
str << "PID: " << sp.attachPID << ' ' << sp.crashParameter << '\n';
|
||||
if (sp.attachPID.isValid())
|
||||
str << "PID: " << sp.attachPID.pid() << ' ' << sp.crashParameter << '\n';
|
||||
if (!sp.projectSourceDirectory.isEmpty()) {
|
||||
str << "Project: " << QDir::toNativeSeparators(sp.projectSourceDirectory);
|
||||
str << "Addtional Search Directories:"
|
||||
|
@@ -380,9 +380,9 @@ static DebuggerRunControl *doCreate(DebuggerRunParameters rp, RunConfiguration *
|
||||
}
|
||||
|
||||
// We might get an executable from a local PID.
|
||||
if (rp.inferior.executable.isEmpty() && rp.attachPID != InvalidPid) {
|
||||
if (rp.inferior.executable.isEmpty() && rp.attachPID.isValid()) {
|
||||
foreach (const DeviceProcessItem &p, DeviceProcessList::localProcesses())
|
||||
if (p.pid == rp.attachPID)
|
||||
if (p.pid == rp.attachPID.pid())
|
||||
rp.inferior.executable = p.exe;
|
||||
}
|
||||
|
||||
|
@@ -31,6 +31,7 @@
|
||||
#include <ssh/sshconnection.h>
|
||||
#include <utils/environment.h>
|
||||
#include <utils/port.h>
|
||||
#include <utils/processhandle.h>
|
||||
#include <projectexplorer/abi.h>
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
#include <projectexplorer/runnables.h>
|
||||
@@ -73,7 +74,7 @@ public:
|
||||
ProjectExplorer::StandardRunnable inferior;
|
||||
QString displayName; // Used in the Snapshots view.
|
||||
Utils::Environment stubEnvironment;
|
||||
qint64 attachPID = InvalidPid;
|
||||
Utils::ProcessHandle attachPID;
|
||||
QStringList solibSearchPath;
|
||||
bool useTerminal = false;
|
||||
|
||||
|
@@ -59,7 +59,7 @@ void GdbAttachEngine::setupInferior()
|
||||
void GdbAttachEngine::runEngine()
|
||||
{
|
||||
QTC_ASSERT(state() == EngineRunRequested, qDebug() << state());
|
||||
const qint64 pid = runParameters().attachPID;
|
||||
const qint64 pid = runParameters().attachPID.pid();
|
||||
showStatusMessage(tr("Attaching to process %1.").arg(pid));
|
||||
runCommand({"attach " + QString::number(pid),
|
||||
[this](const DebuggerResponse &r) { handleAttach(r); }});
|
||||
@@ -110,10 +110,9 @@ void GdbAttachEngine::handleAttach(const DebuggerResponse &response)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GdbAttachEngine::interruptInferior2()
|
||||
{
|
||||
interruptLocalInferior(runParameters().attachPID);
|
||||
interruptLocalInferior(runParameters().attachPID.pid());
|
||||
}
|
||||
|
||||
void GdbAttachEngine::shutdownEngine()
|
||||
|
@@ -294,9 +294,9 @@ void GdbRemoteServerEngine::handleTargetExtendedRemote(const DebuggerResponse &r
|
||||
QString commands = expand(stringSetting(GdbPostAttachCommands));
|
||||
if (!commands.isEmpty())
|
||||
runCommand({commands, NativeCommand});
|
||||
if (runParameters().attachPID > 0) { // attach to pid if valid
|
||||
if (runParameters().attachPID.isValid()) { // attach to pid if valid
|
||||
// gdb server will stop the remote application itself.
|
||||
runCommand({"attach " + QString::number(runParameters().attachPID),
|
||||
runCommand({"attach " + QString::number(runParameters().attachPID.pid()),
|
||||
CB(handleTargetExtendedAttach)});
|
||||
} else if (!runParameters().inferior.executable.isEmpty()) {
|
||||
runCommand({"-gdb-set remote exec-file " + runParameters().inferior.executable,
|
||||
@@ -347,10 +347,9 @@ void GdbRemoteServerEngine::handleTargetQnx(const DebuggerResponse &response)
|
||||
showMessage(msgAttachedToStoppedInferior(), StatusBar);
|
||||
|
||||
const DebuggerRunParameters &rp = isMasterEngine() ? runParameters() : masterEngine()->runParameters();
|
||||
const qint64 pid = rp.attachPID;
|
||||
const QString remoteExecutable = rp.inferior.executable;
|
||||
if (pid > -1)
|
||||
runCommand({"attach " + QString::number(pid), CB(handleAttach)});
|
||||
if (rp.attachPID.isValid())
|
||||
runCommand({"attach " + QString::number(rp.attachPID.pid()), CB(handleAttach)});
|
||||
else if (!remoteExecutable.isEmpty())
|
||||
runCommand({"set nto-executable " + remoteExecutable, CB(handleSetNtoExecutable)});
|
||||
else
|
||||
@@ -465,7 +464,7 @@ void GdbRemoteServerEngine::notifyEngineRemoteServerRunning
|
||||
(const QString &serverChannel, int inferiorPid)
|
||||
{
|
||||
// Currently only used by Android support.
|
||||
runParameters().attachPID = inferiorPid;
|
||||
runParameters().attachPID = Utils::ProcessHandle(inferiorPid);
|
||||
runParameters().remoteChannel = serverChannel;
|
||||
runParameters().useExtendedRemote = true;
|
||||
showMessage("NOTE: REMOTE SERVER RUNNING IN MULTIMODE");
|
||||
|
@@ -366,9 +366,9 @@ void LldbEngine::setupInferior()
|
||||
cmd2.arg("startmode", rp.startMode);
|
||||
// it is better not to check the start mode on the python sid (as we would have to duplicate the
|
||||
// enum values), and thus we assume that if the rp.attachPID is valid we really have to attach
|
||||
QTC_CHECK(rp.attachPID <= 0 || (rp.startMode == AttachCrashedExternal
|
||||
QTC_CHECK(!rp.attachPID.isValid() || (rp.startMode == AttachCrashedExternal
|
||||
|| rp.startMode == AttachExternal));
|
||||
cmd2.arg("attachpid", rp.attachPID);
|
||||
cmd2.arg("attachpid", rp.attachPID.pid());
|
||||
cmd2.arg("sysroot", rp.deviceSymbolsRoot.isEmpty() ? rp.sysRoot : rp.deviceSymbolsRoot);
|
||||
cmd2.arg("remotechannel", ((rp.startMode == AttachToRemoteProcess
|
||||
|| rp.startMode == AttachToRemoteServer)
|
||||
|
@@ -119,7 +119,7 @@ void QnxAttachDebugSupport::launchPDebug()
|
||||
void QnxAttachDebugSupport::attachToProcess()
|
||||
{
|
||||
Debugger::DebuggerStartParameters sp;
|
||||
sp.attachPID = m_process.pid;
|
||||
sp.attachPID = Utils::ProcessHandle(m_process.pid);
|
||||
sp.startMode = Debugger::AttachToRemoteServer;
|
||||
sp.closeMode = Debugger::DetachAtClose;
|
||||
sp.connParams.port = m_pdebugPort.number();
|
||||
|
@@ -138,7 +138,7 @@ RunControl *WinRtDebugSupport::createDebugRunControl(WinRtRunConfiguration *runC
|
||||
QList<QByteArray> arg = output.split(':');
|
||||
if (arg.first() == "PID") {
|
||||
bool ok =false;
|
||||
params.attachPID = arg.last().toInt(&ok);
|
||||
params.attachPID = Utils::ProcessHandle(arg.last().toInt(&ok));
|
||||
if (!ok) {
|
||||
*errorMessage = tr("Cannot extract the PID from the WinRT debugging helper. "
|
||||
"(output: %1)").arg(QString::fromLocal8Bit(output));
|
||||
|
Reference in New Issue
Block a user