Commit 1f09c6bc authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

Debugger/Windows: Do not attach to process being debugged.


Reviewed-by: default avatarRobert Loehning <robert.loehning@nokia.com>
Task-number: QTCREATORBUG-2086
parent c7e47f53
......@@ -55,6 +55,7 @@
#include <QtGui/QPushButton>
#include <QtGui/QProxyModel>
#include <QtGui/QSortFilterProxyModel>
#include <QtGui/QMessageBox>
using namespace Utils;
......@@ -424,6 +425,20 @@ void AttachExternalDialog::pidChanged(const QString &pid)
okButton()->setEnabled(enabled);
}
void AttachExternalDialog::accept()
{
#ifdef Q_OS_WIN
const qint64 pid = attachPID();
if (pid && isWinProcessBeingDebugged(pid)) {
QMessageBox::warning(this, tr("Process Already Under Debugger Control"),
tr("The process %1 is already under the control of a debugger.\n"
"Qt Creator cannot attach to it.").arg(pid));
return;
}
#endif
QDialog::accept();
}
///////////////////////////////////////////////////////////////////////
//
......
......@@ -92,6 +92,8 @@ public:
qint64 attachPID() const;
QString executable() const;
virtual void accept();
private slots:
void rebuildProcessList();
void procSelected(const QModelIndex &index);
......
......@@ -242,5 +242,16 @@ QString winNormalizeFileName(const QString &f)
return rc.isEmpty() ? f : rc;
}
bool isWinProcessBeingDebugged(unsigned long pid)
{
HANDLE processHandle = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);
if (processHandle == NULL)
return false;
BOOL debugged = FALSE;
CheckRemoteDebuggerPresent(processHandle, &debugged);
CloseHandle(processHandle);
return debugged != FALSE;
}
} // namespace Internal
} // namespace Debugger
......@@ -57,6 +57,8 @@ unsigned long winGetCurrentProcessId();
QString winNormalizeFileName(const QString &f);
bool isWinProcessBeingDebugged(unsigned long pid);
} // namespace Internal
} // namespace Debugger
......
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