forked from qt-creator/qt-creator
Debugger: Use shared TerminalRunner also for CDB
Change-Id: I2dd9b16f5699d0551a2de3e8ebefc865b98ad862 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -49,6 +49,7 @@
|
||||
#include <debugger/sourceutils.h>
|
||||
#include <debugger/shared/cdbsymbolpathlisteditor.h>
|
||||
#include <debugger/shared/hostutils.h>
|
||||
#include <debugger/terminal.h>
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/messagebox.h>
|
||||
@@ -178,12 +179,6 @@ Q_DECLARE_METATYPE(Debugger::Internal::MemoryChangeCookie)
|
||||
namespace Debugger {
|
||||
namespace Internal {
|
||||
|
||||
static inline bool isCreatorConsole(const DebuggerRunParameters &sp)
|
||||
{
|
||||
return !boolSetting(UseCdbConsole) && sp.inferior.runMode == ApplicationLauncher::Console
|
||||
&& (sp.startMode == StartInternal || sp.startMode == StartExternal);
|
||||
}
|
||||
|
||||
// Base data structure for command queue entries with callback
|
||||
class CdbCommand
|
||||
{
|
||||
@@ -372,68 +367,6 @@ int CdbEngine::elapsedLogTime() const
|
||||
return delta;
|
||||
}
|
||||
|
||||
// Start the console stub with the sub process. Continue in consoleStubProcessStarted.
|
||||
bool CdbEngine::startConsole(const DebuggerRunParameters &sp, QString *errorMessage)
|
||||
{
|
||||
if (debug)
|
||||
qDebug("startConsole %s", qPrintable(sp.inferior.executable));
|
||||
m_consoleStub.reset(new ConsoleProcess);
|
||||
m_consoleStub->setMode(ConsoleProcess::Suspend);
|
||||
connect(m_consoleStub.data(), &ConsoleProcess::processError,
|
||||
this, &CdbEngine::consoleStubError);
|
||||
connect(m_consoleStub.data(), &ConsoleProcess::processStarted,
|
||||
this, &CdbEngine::consoleStubProcessStarted);
|
||||
connect(m_consoleStub.data(), &ConsoleProcess::stubStopped,
|
||||
this, &CdbEngine::consoleStubExited);
|
||||
m_consoleStub->setWorkingDirectory(sp.inferior.workingDirectory);
|
||||
if (sp.stubEnvironment.size())
|
||||
m_consoleStub->setEnvironment(sp.stubEnvironment);
|
||||
if (!m_consoleStub->start(sp.inferior.executable, sp.inferior.commandLineArguments)) {
|
||||
*errorMessage = tr("The console process \"%1\" could not be started.").arg(sp.inferior.executable);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void CdbEngine::consoleStubError(const QString &msg)
|
||||
{
|
||||
if (debug)
|
||||
qDebug("consoleStubProcessMessage() in %s %s", qPrintable(stateName(state())), qPrintable(msg));
|
||||
if (state() == EngineSetupRequested) {
|
||||
STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyEngineSetupFailed")
|
||||
notifyEngineSetupFailed();
|
||||
} else {
|
||||
STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyEngineIll")
|
||||
notifyEngineIll();
|
||||
}
|
||||
Core::AsynchronousMessageBox::critical(tr("Debugger Error"), msg);
|
||||
}
|
||||
|
||||
void CdbEngine::consoleStubProcessStarted()
|
||||
{
|
||||
if (debug)
|
||||
qDebug("consoleStubProcessStarted() PID=%lld", m_consoleStub->applicationPID());
|
||||
// Attach to console process.
|
||||
DebuggerRunParameters attachParameters = runParameters();
|
||||
attachParameters.inferior.executable.clear();
|
||||
attachParameters.inferior.commandLineArguments.clear();
|
||||
attachParameters.attachPID = ProcessHandle(m_consoleStub->applicationPID());
|
||||
attachParameters.startMode = AttachExternal;
|
||||
attachParameters.inferior.runMode = ApplicationLauncher::Gui; // Force no terminal.
|
||||
showMessage(QString("Attaching to %1...").arg(attachParameters.attachPID.pid()), LogMisc);
|
||||
QString errorMessage;
|
||||
if (!launchCDB(attachParameters, &errorMessage)) {
|
||||
showMessage(errorMessage, LogError);
|
||||
Core::AsynchronousMessageBox::critical(tr("Failed to Start the Debugger"), errorMessage);
|
||||
STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyEngineSetupFailed")
|
||||
notifyEngineSetupFailed();
|
||||
}
|
||||
}
|
||||
|
||||
void CdbEngine::consoleStubExited()
|
||||
{
|
||||
}
|
||||
|
||||
void CdbEngine::createFullBacktrace()
|
||||
{
|
||||
runCommand({"~*kp", BuiltinCommand, [](const DebuggerResponse &response) {
|
||||
@@ -455,18 +388,33 @@ void CdbEngine::setupEngine()
|
||||
// console, too, but that immediately closes when the debuggee quits.
|
||||
// Use the Creator stub instead.
|
||||
const DebuggerRunParameters &rp = runParameters();
|
||||
const bool launchConsole = isCreatorConsole(rp);
|
||||
m_effectiveStartMode = launchConsole ? AttachExternal : rp.startMode;
|
||||
const bool ok = launchConsole ?
|
||||
startConsole(runParameters(), &errorMessage) :
|
||||
launchCDB(runParameters(), &errorMessage);
|
||||
if (debug)
|
||||
qDebug("<setupEngine ok=%d", ok);
|
||||
if (!ok) {
|
||||
showMessage(errorMessage, LogError);
|
||||
Core::AsynchronousMessageBox::critical(tr("Failed to Start the Debugger"), errorMessage);
|
||||
STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyEngineSetupFailed")
|
||||
notifyEngineSetupFailed();
|
||||
if (terminal()) {
|
||||
m_effectiveStartMode = AttachExternal;
|
||||
DebuggerRunParameters attachParameters = rp;
|
||||
attachParameters.inferior.executable.clear();
|
||||
attachParameters.inferior.commandLineArguments.clear();
|
||||
attachParameters.attachPID = ProcessHandle(terminal()->applicationPid());
|
||||
attachParameters.startMode = AttachExternal;
|
||||
attachParameters.inferior.runMode = ApplicationLauncher::Gui; // Force no terminal.
|
||||
showMessage(QString("Attaching to %1...").arg(attachParameters.attachPID.pid()), LogMisc);
|
||||
QString errorMessage;
|
||||
if (!launchCDB(attachParameters, &errorMessage)) {
|
||||
showMessage(errorMessage, LogError);
|
||||
Core::AsynchronousMessageBox::critical(tr("Failed to Start the Debugger"), errorMessage);
|
||||
STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyEngineSetupFailed")
|
||||
notifyEngineSetupFailed();
|
||||
}
|
||||
} else {
|
||||
m_effectiveStartMode = rp.startMode;
|
||||
const bool ok = launchCDB(runParameters(), &errorMessage);
|
||||
if (debug)
|
||||
qDebug("<setupEngine ok=%d", ok);
|
||||
if (!ok) {
|
||||
showMessage(errorMessage, LogError);
|
||||
Core::AsynchronousMessageBox::critical(tr("Failed to Start the Debugger"), errorMessage);
|
||||
STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyEngineSetupFailed")
|
||||
notifyEngineSetupFailed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -552,7 +500,7 @@ bool CdbEngine::launchCDB(const DebuggerRunParameters &sp, QString *errorMessage
|
||||
if (sp.startMode == AttachCrashedExternal) {
|
||||
arguments << "-e" << sp.crashParameter << "-g";
|
||||
} else {
|
||||
if (isCreatorConsole(runParameters()))
|
||||
if (terminal())
|
||||
arguments << "-pr" << "-pb";
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user