forked from qt-creator/qt-creator
Debugger: Move external terminal into separate RunWorker
Change-Id: Ifb9701f840195ba90db48a0f6fa07b28e0409648 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -25,11 +25,16 @@
|
||||
|
||||
#include "terminal.h"
|
||||
|
||||
#include "debuggerruncontrol.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QIODevice>
|
||||
#include <QSocketNotifier>
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
|
||||
#ifdef Q_OS_UNIX
|
||||
# define DEBUGGER_USE_TERMINAL
|
||||
@@ -45,6 +50,10 @@
|
||||
# include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
using namespace Core;
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
namespace Debugger {
|
||||
namespace Internal {
|
||||
|
||||
@@ -159,6 +168,67 @@ void Terminal::onSlaveReaderActivated(int fd)
|
||||
#endif
|
||||
}
|
||||
|
||||
TerminalRunner::TerminalRunner(DebuggerRunTool *debugger)
|
||||
: RunWorker(debugger->runControl())
|
||||
{
|
||||
setDisplayName("TerminalRunner");
|
||||
|
||||
const DebuggerRunParameters &rp = debugger->runParameters();
|
||||
m_stubRunnable = rp.inferior;
|
||||
m_stubRunnable.environment = rp.stubEnvironment;
|
||||
m_stubRunnable.workingDirectory = rp.inferior.workingDirectory;
|
||||
|
||||
connect(&m_stubProc, &ConsoleProcess::processError,
|
||||
this, &TerminalRunner::stubError);
|
||||
connect(&m_stubProc, &ConsoleProcess::processStarted,
|
||||
this, &TerminalRunner::stubStarted);
|
||||
connect(&m_stubProc, &ConsoleProcess::stubStopped,
|
||||
this, &TerminalRunner::stubExited);
|
||||
}
|
||||
|
||||
void TerminalRunner::start()
|
||||
{
|
||||
m_stubProc.setEnvironment(m_stubRunnable.environment);
|
||||
m_stubProc.setWorkingDirectory(m_stubRunnable.workingDirectory);
|
||||
|
||||
if (HostOsInfo::isWindowsHost()) {
|
||||
// Windows up to xp needs a workaround for attaching to freshly started processes. see proc_stub_win
|
||||
if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA)
|
||||
m_stubProc.setMode(ConsoleProcess::Suspend);
|
||||
else
|
||||
m_stubProc.setMode(ConsoleProcess::Debug);
|
||||
} else {
|
||||
m_stubProc.setMode(ConsoleProcess::Debug);
|
||||
m_stubProc.setSettings(Core::ICore::settings());
|
||||
}
|
||||
|
||||
// Error message for user is delivered via a signal.
|
||||
m_stubProc.start(m_stubRunnable.executable, m_stubRunnable.commandLineArguments);
|
||||
}
|
||||
|
||||
void TerminalRunner::stop()
|
||||
{
|
||||
m_stubProc.stop();
|
||||
reportStopped();
|
||||
}
|
||||
|
||||
void TerminalRunner::stubStarted()
|
||||
{
|
||||
m_applicationPid = m_stubProc.applicationPID();
|
||||
m_applicationMainThreadId = m_stubProc.applicationMainThreadID();
|
||||
reportStarted();
|
||||
}
|
||||
|
||||
void TerminalRunner::stubError(const QString &msg)
|
||||
{
|
||||
reportFailure(msg);
|
||||
}
|
||||
|
||||
void TerminalRunner::stubExited()
|
||||
{
|
||||
reportStopped();
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Debugger
|
||||
|
||||
|
||||
Reference in New Issue
Block a user