diff options
author | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2012-11-02 15:33:06 +0100 |
---|---|---|
committer | hjk <qthjk@ovi.com> | 2012-11-02 15:40:41 +0100 |
commit | 2e40c54ea3422f7a3e8441cf81c0b07e4491f287 (patch) | |
tree | a8deca8324bbe78fed23e866644d3470aea281ce | |
parent | 31e2ddd08535e792337075de86465d0360cbcf2a (diff) | |
download | qt-creator-2e40c54ea3422f7a3e8441cf81c0b07e4491f287.tar.gz |
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>
-rw-r--r-- | src/plugins/debugger/cdb/cdbengine.cpp | 2 | ||||
-rw-r--r-- | src/plugins/debugger/cdb/cdbparsehelpers.cpp | 2 | ||||
-rw-r--r-- | src/plugins/debugger/debuggerplugin.cpp | 7 | ||||
-rw-r--r-- | src/plugins/debugger/gdb/gdbengine.cpp | 5 | ||||
-rw-r--r-- | src/plugins/debugger/gdb/termgdbadapter.cpp | 32 | ||||
-rw-r--r-- | src/plugins/debugger/shared/hostutils.cpp | 16 | ||||
-rw-r--r-- | src/plugins/debugger/shared/hostutils.h | 6 |
7 files changed, 32 insertions, 38 deletions
diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index 37b81aab8c..bdc0e13168 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -2079,7 +2079,6 @@ unsigned CdbEngine::examineStopReason(const GdbMi &stopReason, WinException exception; exception.fromGdbMI(stopReason); QString description = exception.toString(); -#ifdef Q_OS_WIN // It is possible to hit on a startup trap or WOW86 exception while stepping (if something // pulls DLLs. Avoid showing a 'stopped' Message box. if (exception.exceptionCode == winExceptionStartupCompleteTrap @@ -2099,7 +2098,6 @@ unsigned CdbEngine::examineStopReason(const GdbMi &stopReason, *message = msgInterrupted(); return rc; } -#endif *exceptionBoxMessage = msgStoppedByException(description, QString::number(threadId)); *message = description; rc |= StopShowExceptionMessageBox|StopReportStatusMessage|StopNotifyStop; diff --git a/src/plugins/debugger/cdb/cdbparsehelpers.cpp b/src/plugins/debugger/cdb/cdbparsehelpers.cpp index ce54909b8d..cbda20639a 100644 --- a/src/plugins/debugger/cdb/cdbparsehelpers.cpp +++ b/src/plugins/debugger/cdb/cdbparsehelpers.cpp @@ -413,10 +413,8 @@ QString WinException::toString(bool includeLocation) const { QString rc; QTextStream str(&rc); -#ifdef Q_OS_WIN formatWindowsException(exceptionCode, exceptionAddress, exceptionFlags, info1, info2, str); -#endif if (includeLocation) { if (lineNumber) { str << " at " << QLatin1String(file) << ':' << lineNumber; diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index ff4fedfa95..2e2d878ea1 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -1692,14 +1692,15 @@ void DebuggerPluginPrivate::attachToProcess(bool startServerOnly) return; } - #ifdef Q_OS_WIN - if (isWinProcessBeingDebugged(process.pid)) { + bool isWindows = false; + 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"), tr("The process %1 is already under the control of a debugger.\n" "Qt Creator cannot attach to it.").arg(process.pid)); return; } - #endif if (device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) { DebuggerStartParameters sp; diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 84bcf4e985..e01c595e3f 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -356,12 +356,7 @@ static inline QString msgWinException(const QByteArray &data) QString rc; QTextStream str(&rc); str << GdbEngine::tr("An exception was triggered: "); -#ifdef Q_OS_WIN formatWindowsException(exCode, address, 0, 0, 0, str); -#else - Q_UNUSED(exCode) - Q_UNUSED(address) -#endif str << '.'; return rc; } diff --git a/src/plugins/debugger/gdb/termgdbadapter.cpp b/src/plugins/debugger/gdb/termgdbadapter.cpp index a8eb65abfb..4d71e42ab8 100644 --- a/src/plugins/debugger/gdb/termgdbadapter.cpp +++ b/src/plugins/debugger/gdb/termgdbadapter.cpp @@ -145,25 +145,29 @@ void GdbTermEngine::setupInferior() void GdbTermEngine::handleStubAttached(const GdbResponse &response) { QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state()); -#ifdef Q_OS_WIN - QString errorMessage; -#endif // Q_OS_WIN + switch (response.resultClass) { case GdbResultDone: case GdbResultRunning: -#ifdef Q_OS_WIN - // Resume thread that was suspended by console stub process (see stub code). - if (winResumeThread(m_stubProc.applicationMainThreadID(), &errorMessage)) { - showMessage(QString::fromLatin1("Inferior attached, thread %1 resumed"). - arg(m_stubProc.applicationMainThreadID()), LogMisc); + if (startParameters().toolChainAbi.os() != ProjectExplorer::Abi::WindowsOS) { + showMessage(_("INFERIOR ATTACHED")); } else { - showMessage(QString::fromLatin1("Inferior attached, unable to resume thread %1: %2"). - arg(m_stubProc.applicationMainThreadID()).arg(errorMessage), - LogWarning); - } + QString errorMessage; + // Resume thread that was suspended by console stub process (see stub code). +#ifdef Q_OS_WIN + const qint64 mainThreadId = m_stubProc.applicationMainThreadID(); #else - showMessage(_("INFERIOR ATTACHED")); -#endif // Q_OS_WIN + const qint64 mainThreadId = -1; +#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(); break; case GdbResultError: diff --git a/src/plugins/debugger/shared/hostutils.cpp b/src/plugins/debugger/shared/hostutils.cpp index e645a716e2..aa38d72611 100644 --- a/src/plugins/debugger/shared/hostutils.cpp +++ b/src/plugins/debugger/shared/hostutils.cpp @@ -82,11 +82,6 @@ bool winResumeThread(unsigned long dwThreadId, QString *errorMessage) return ok; } -unsigned long winGetCurrentProcessId() -{ - return GetCurrentProcessId(); -} - bool isWinProcessBeingDebugged(unsigned long pid) { HANDLE processHandle = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid); @@ -228,7 +223,16 @@ bool isFatalWinException(long code) 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 Debugger diff --git a/src/plugins/debugger/shared/hostutils.h b/src/plugins/debugger/shared/hostutils.h index 1b052c92a4..511b4ea720 100644 --- a/src/plugins/debugger/shared/hostutils.h +++ b/src/plugins/debugger/shared/hostutils.h @@ -40,13 +40,9 @@ QT_END_NAMESPACE namespace Debugger { namespace Internal { -#ifdef Q_OS_WIN - // Resume a suspended thread by id. bool winResumeThread(unsigned long dwThreadId, QString *errorMessage); -unsigned long winGetCurrentProcessId(); - bool isWinProcessBeingDebugged(unsigned long pid); // Special exception codes. @@ -75,8 +71,6 @@ bool isFatalWinException(long code); // Check for EXCEPTION_BREAKPOINT, EXCEPTION_SINGLE_STEP bool isDebuggerWinException(unsigned long code); -#endif // defined(Q_OS_WIN) - } // namespace Internal } // namespace Debugger |