forked from qt-creator/qt-creator
Debugger: Remove #ifdef Q_OS_WIN from hostutils.
- Provide stubs for Non-Windows - Reduce #ifdefs, check Abi if possible. - Remove unused winGetCurrentProcessId(). Task-number: QTCREATORBUG-8141 Change-Id: I80558ca4e52e87c7371597ea07c091af08097b34 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -2079,7 +2079,6 @@ unsigned CdbEngine::examineStopReason(const GdbMi &stopReason,
|
|||||||
WinException exception;
|
WinException exception;
|
||||||
exception.fromGdbMI(stopReason);
|
exception.fromGdbMI(stopReason);
|
||||||
QString description = exception.toString();
|
QString description = exception.toString();
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
// It is possible to hit on a startup trap or WOW86 exception while stepping (if something
|
// It is possible to hit on a startup trap or WOW86 exception while stepping (if something
|
||||||
// pulls DLLs. Avoid showing a 'stopped' Message box.
|
// pulls DLLs. Avoid showing a 'stopped' Message box.
|
||||||
if (exception.exceptionCode == winExceptionStartupCompleteTrap
|
if (exception.exceptionCode == winExceptionStartupCompleteTrap
|
||||||
@@ -2099,7 +2098,6 @@ unsigned CdbEngine::examineStopReason(const GdbMi &stopReason,
|
|||||||
*message = msgInterrupted();
|
*message = msgInterrupted();
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
*exceptionBoxMessage = msgStoppedByException(description, QString::number(threadId));
|
*exceptionBoxMessage = msgStoppedByException(description, QString::number(threadId));
|
||||||
*message = description;
|
*message = description;
|
||||||
rc |= StopShowExceptionMessageBox|StopReportStatusMessage|StopNotifyStop;
|
rc |= StopShowExceptionMessageBox|StopReportStatusMessage|StopNotifyStop;
|
||||||
|
|||||||
@@ -413,10 +413,8 @@ QString WinException::toString(bool includeLocation) const
|
|||||||
{
|
{
|
||||||
QString rc;
|
QString rc;
|
||||||
QTextStream str(&rc);
|
QTextStream str(&rc);
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
formatWindowsException(exceptionCode, exceptionAddress,
|
formatWindowsException(exceptionCode, exceptionAddress,
|
||||||
exceptionFlags, info1, info2, str);
|
exceptionFlags, info1, info2, str);
|
||||||
#endif
|
|
||||||
if (includeLocation) {
|
if (includeLocation) {
|
||||||
if (lineNumber) {
|
if (lineNumber) {
|
||||||
str << " at " << QLatin1String(file) << ':' << lineNumber;
|
str << " at " << QLatin1String(file) << ':' << lineNumber;
|
||||||
|
|||||||
@@ -1692,14 +1692,15 @@ void DebuggerPluginPrivate::attachToProcess(bool startServerOnly)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
bool isWindows = false;
|
||||||
if (isWinProcessBeingDebugged(process.pid)) {
|
if (const ProjectExplorer::ToolChain *tc = ToolChainKitInformation::toolChain(kit))
|
||||||
|
isWindows = tc->targetAbi().os() == ProjectExplorer::Abi::WindowsOS;
|
||||||
|
if (isWindows && isWinProcessBeingDebugged(process.pid)) {
|
||||||
QMessageBox::warning(ICore::mainWindow(), tr("Process Already Under Debugger Control"),
|
QMessageBox::warning(ICore::mainWindow(), tr("Process Already Under Debugger Control"),
|
||||||
tr("The process %1 is already under the control of a debugger.\n"
|
tr("The process %1 is already under the control of a debugger.\n"
|
||||||
"Qt Creator cannot attach to it.").arg(process.pid));
|
"Qt Creator cannot attach to it.").arg(process.pid));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
|
if (device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
|
||||||
DebuggerStartParameters sp;
|
DebuggerStartParameters sp;
|
||||||
|
|||||||
@@ -356,12 +356,7 @@ static inline QString msgWinException(const QByteArray &data)
|
|||||||
QString rc;
|
QString rc;
|
||||||
QTextStream str(&rc);
|
QTextStream str(&rc);
|
||||||
str << GdbEngine::tr("An exception was triggered: ");
|
str << GdbEngine::tr("An exception was triggered: ");
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
formatWindowsException(exCode, address, 0, 0, 0, str);
|
formatWindowsException(exCode, address, 0, 0, 0, str);
|
||||||
#else
|
|
||||||
Q_UNUSED(exCode)
|
|
||||||
Q_UNUSED(address)
|
|
||||||
#endif
|
|
||||||
str << '.';
|
str << '.';
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -145,25 +145,29 @@ void GdbTermEngine::setupInferior()
|
|||||||
void GdbTermEngine::handleStubAttached(const GdbResponse &response)
|
void GdbTermEngine::handleStubAttached(const GdbResponse &response)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
|
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
QString errorMessage;
|
|
||||||
#endif // Q_OS_WIN
|
|
||||||
switch (response.resultClass) {
|
switch (response.resultClass) {
|
||||||
case GdbResultDone:
|
case GdbResultDone:
|
||||||
case GdbResultRunning:
|
case GdbResultRunning:
|
||||||
#ifdef Q_OS_WIN
|
if (startParameters().toolChainAbi.os() != ProjectExplorer::Abi::WindowsOS) {
|
||||||
// Resume thread that was suspended by console stub process (see stub code).
|
showMessage(_("INFERIOR ATTACHED"));
|
||||||
if (winResumeThread(m_stubProc.applicationMainThreadID(), &errorMessage)) {
|
|
||||||
showMessage(QString::fromLatin1("Inferior attached, thread %1 resumed").
|
|
||||||
arg(m_stubProc.applicationMainThreadID()), LogMisc);
|
|
||||||
} else {
|
} else {
|
||||||
showMessage(QString::fromLatin1("Inferior attached, unable to resume thread %1: %2").
|
QString errorMessage;
|
||||||
arg(m_stubProc.applicationMainThreadID()).arg(errorMessage),
|
// Resume thread that was suspended by console stub process (see stub code).
|
||||||
LogWarning);
|
#ifdef Q_OS_WIN
|
||||||
}
|
const qint64 mainThreadId = m_stubProc.applicationMainThreadID();
|
||||||
#else
|
#else
|
||||||
showMessage(_("INFERIOR ATTACHED"));
|
const qint64 mainThreadId = -1;
|
||||||
#endif // Q_OS_WIN
|
#endif
|
||||||
|
if (winResumeThread(mainThreadId, &errorMessage)) {
|
||||||
|
showMessage(QString::fromLatin1("Inferior attached, thread %1 resumed").
|
||||||
|
arg(mainThreadId), LogMisc);
|
||||||
|
} else {
|
||||||
|
showMessage(QString::fromLatin1("Inferior attached, unable to resume thread %1: %2").
|
||||||
|
arg(mainThreadId).arg(errorMessage),
|
||||||
|
LogWarning);
|
||||||
|
}
|
||||||
|
}
|
||||||
handleInferiorPrepared();
|
handleInferiorPrepared();
|
||||||
break;
|
break;
|
||||||
case GdbResultError:
|
case GdbResultError:
|
||||||
|
|||||||
@@ -82,11 +82,6 @@ bool winResumeThread(unsigned long dwThreadId, QString *errorMessage)
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long winGetCurrentProcessId()
|
|
||||||
{
|
|
||||||
return GetCurrentProcessId();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isWinProcessBeingDebugged(unsigned long pid)
|
bool isWinProcessBeingDebugged(unsigned long pid)
|
||||||
{
|
{
|
||||||
HANDLE processHandle = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);
|
HANDLE processHandle = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);
|
||||||
@@ -228,7 +223,16 @@ bool isFatalWinException(long code)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // Q_OS_WIN
|
#else // Q_OS_WIN
|
||||||
|
|
||||||
|
bool winResumeThread(unsigned long, QString *) { return false; }
|
||||||
|
bool isWinProcessBeingDebugged(unsigned long) { return false; }
|
||||||
|
void formatWindowsException(unsigned long , quint64, unsigned long,
|
||||||
|
quint64, quint64, QTextStream &) { }
|
||||||
|
bool isFatalWinException(long) { return false; }
|
||||||
|
bool isDebuggerWinException(unsigned long) { return false; }
|
||||||
|
|
||||||
|
#endif // !Q_OS_WIN
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Debugger
|
} // namespace Debugger
|
||||||
|
|||||||
@@ -40,13 +40,9 @@ QT_END_NAMESPACE
|
|||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
|
|
||||||
// Resume a suspended thread by id.
|
// Resume a suspended thread by id.
|
||||||
bool winResumeThread(unsigned long dwThreadId, QString *errorMessage);
|
bool winResumeThread(unsigned long dwThreadId, QString *errorMessage);
|
||||||
|
|
||||||
unsigned long winGetCurrentProcessId();
|
|
||||||
|
|
||||||
bool isWinProcessBeingDebugged(unsigned long pid);
|
bool isWinProcessBeingDebugged(unsigned long pid);
|
||||||
|
|
||||||
// Special exception codes.
|
// Special exception codes.
|
||||||
@@ -75,8 +71,6 @@ bool isFatalWinException(long code);
|
|||||||
// Check for EXCEPTION_BREAKPOINT, EXCEPTION_SINGLE_STEP
|
// Check for EXCEPTION_BREAKPOINT, EXCEPTION_SINGLE_STEP
|
||||||
bool isDebuggerWinException(unsigned long code);
|
bool isDebuggerWinException(unsigned long code);
|
||||||
|
|
||||||
#endif // defined(Q_OS_WIN)
|
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Debugger
|
} // namespace Debugger
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user