forked from qt-creator/qt-creator
Debugger: Consolidate CdbEngine::startEngine()
Change-Id: I92c74b96c891bb46b7ceb9c45ffea268a223b325 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -374,6 +374,13 @@ void CdbEngine::createFullBacktrace()
|
|||||||
}});
|
}});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CdbEngine::handleSetupFailure(const QString &errorMessage)
|
||||||
|
{
|
||||||
|
showMessage(errorMessage, LogError);
|
||||||
|
Core::AsynchronousMessageBox::critical(tr("Failed to Start the Debugger"), errorMessage);
|
||||||
|
notifyEngineSetupFailed();
|
||||||
|
}
|
||||||
|
|
||||||
void CdbEngine::setupEngine()
|
void CdbEngine::setupEngine()
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
@@ -382,46 +389,24 @@ void CdbEngine::setupEngine()
|
|||||||
init();
|
init();
|
||||||
if (!m_logTime.elapsed())
|
if (!m_logTime.elapsed())
|
||||||
m_logTime.start();
|
m_logTime.start();
|
||||||
QString errorMessage;
|
|
||||||
// Console: Launch the stub with the suspended application and attach to it
|
// Console: Launch the stub with the suspended application and attach to it
|
||||||
// CDB in theory has a command line option '-2' that launches a
|
// CDB in theory has a command line option '-2' that launches a
|
||||||
// console, too, but that immediately closes when the debuggee quits.
|
// console, too, but that immediately closes when the debuggee quits.
|
||||||
// Use the Creator stub instead.
|
// Use the Creator stub instead.
|
||||||
const DebuggerRunParameters &rp = runParameters();
|
DebuggerRunParameters sp = runParameters();
|
||||||
if (terminal()) {
|
if (terminal()) {
|
||||||
m_effectiveStartMode = AttachExternal;
|
m_effectiveStartMode = AttachExternal;
|
||||||
DebuggerRunParameters attachParameters = rp;
|
sp.inferior.executable.clear();
|
||||||
attachParameters.inferior.executable.clear();
|
sp.inferior.commandLineArguments.clear();
|
||||||
attachParameters.inferior.commandLineArguments.clear();
|
sp.attachPID = ProcessHandle(terminal()->applicationPid());
|
||||||
attachParameters.attachPID = ProcessHandle(terminal()->applicationPid());
|
sp.startMode = AttachExternal;
|
||||||
attachParameters.startMode = AttachExternal;
|
sp.inferior.runMode = ApplicationLauncher::Gui; // Force no terminal.
|
||||||
attachParameters.inferior.runMode = ApplicationLauncher::Gui; // Force no terminal.
|
showMessage(QString("Attaching to %1...").arg(sp.attachPID.pid()), LogMisc);
|
||||||
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 {
|
} else {
|
||||||
m_effectiveStartMode = rp.startMode;
|
m_effectiveStartMode = sp.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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
bool CdbEngine::launchCDB(const DebuggerRunParameters &sp, QString *errorMessage)
|
|
||||||
{
|
|
||||||
if (debug)
|
|
||||||
qDebug("launchCDB startMode=%d", sp.startMode);
|
|
||||||
const QChar blank(' ');
|
const QChar blank(' ');
|
||||||
// Start engine which will run until initial breakpoint:
|
// Start engine which will run until initial breakpoint:
|
||||||
// Determine binary (force MSVC), extension lib name and path to use
|
// Determine binary (force MSVC), extension lib name and path to use
|
||||||
@@ -429,8 +414,8 @@ bool CdbEngine::launchCDB(const DebuggerRunParameters &sp, QString *errorMessage
|
|||||||
//(does not work with absolute path names)
|
//(does not work with absolute path names)
|
||||||
const QString executable = sp.debugger.executable;
|
const QString executable = sp.debugger.executable;
|
||||||
if (executable.isEmpty()) {
|
if (executable.isEmpty()) {
|
||||||
*errorMessage = tr("There is no CDB executable specified.");
|
handleSetupFailure(tr("There is no CDB executable specified."));
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cdbIs64Bit = Utils::is64BitWindowsBinary(executable);
|
bool cdbIs64Bit = Utils::is64BitWindowsBinary(executable);
|
||||||
@@ -438,7 +423,7 @@ bool CdbEngine::launchCDB(const DebuggerRunParameters &sp, QString *errorMessage
|
|||||||
m_wow64State = noWow64Stack;
|
m_wow64State = noWow64Stack;
|
||||||
const QFileInfo extensionFi(CdbEngine::extensionLibraryName(cdbIs64Bit));
|
const QFileInfo extensionFi(CdbEngine::extensionLibraryName(cdbIs64Bit));
|
||||||
if (!extensionFi.isFile()) {
|
if (!extensionFi.isFile()) {
|
||||||
*errorMessage = tr("Internal error: The extension %1 cannot be found.\n"
|
handleSetupFailure(tr("Internal error: The extension %1 cannot be found.\n"
|
||||||
"If you have updated Qt Creator via Maintenance Tool, you may "
|
"If you have updated Qt Creator via Maintenance Tool, you may "
|
||||||
"need to rerun the Tool and select \"Add or remove components\" "
|
"need to rerun the Tool and select \"Add or remove components\" "
|
||||||
"and then select the\n"
|
"and then select the\n"
|
||||||
@@ -447,8 +432,8 @@ bool CdbEngine::launchCDB(const DebuggerRunParameters &sp, QString *errorMessage
|
|||||||
"with another bitness than your Qt Creator build,\n"
|
"with another bitness than your Qt Creator build,\n"
|
||||||
"you will need to build a separate CDB extension with the "
|
"you will need to build a separate CDB extension with the "
|
||||||
"same bitness as the CDB you want to use.").
|
"same bitness as the CDB you want to use.").
|
||||||
arg(QDir::toNativeSeparators(extensionFi.absoluteFilePath()));
|
arg(QDir::toNativeSeparators(extensionFi.absoluteFilePath())));
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
const QString extensionFileName = extensionFi.fileName();
|
const QString extensionFileName = extensionFi.fileName();
|
||||||
// Prepare arguments
|
// Prepare arguments
|
||||||
@@ -508,8 +493,8 @@ bool CdbEngine::launchCDB(const DebuggerRunParameters &sp, QString *errorMessage
|
|||||||
arguments << "-z" << sp.coreFile;
|
arguments << "-z" << sp.coreFile;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
*errorMessage = QString("Internal error: Unsupported start mode %1.").arg(sp.startMode);
|
handleSetupFailure(QString("Internal error: Unsupported start mode %1.").arg(sp.startMode));
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
if (!sp.inferior.commandLineArguments.isEmpty()) { // Complete native argument string.
|
if (!sp.inferior.commandLineArguments.isEmpty()) { // Complete native argument string.
|
||||||
if (!nativeArguments.isEmpty())
|
if (!nativeArguments.isEmpty())
|
||||||
@@ -547,9 +532,9 @@ bool CdbEngine::launchCDB(const DebuggerRunParameters &sp, QString *errorMessage
|
|||||||
#endif
|
#endif
|
||||||
m_process.start(executable, arguments);
|
m_process.start(executable, arguments);
|
||||||
if (!m_process.waitForStarted()) {
|
if (!m_process.waitForStarted()) {
|
||||||
*errorMessage = QString("Internal error: Cannot start process %1: %2").
|
handleSetupFailure(QString("Internal error: Cannot start process %1: %2").
|
||||||
arg(QDir::toNativeSeparators(executable), m_process.errorString());
|
arg(QDir::toNativeSeparators(executable), m_process.errorString()));
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const qint64 pid = m_process.processId();
|
const qint64 pid = m_process.processId();
|
||||||
@@ -559,10 +544,8 @@ bool CdbEngine::launchCDB(const DebuggerRunParameters &sp, QString *errorMessage
|
|||||||
if (isRemote) { // We do not get an 'idle' in a remote session, but are accessible
|
if (isRemote) { // We do not get an 'idle' in a remote session, but are accessible
|
||||||
m_accessible = true;
|
m_accessible = true;
|
||||||
runCommand({".load " + extensionFileName, NoFlags});
|
runCommand({".load " + extensionFileName, NoFlags});
|
||||||
STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyEngineSetupOk")
|
|
||||||
notifyEngineSetupOk();
|
notifyEngineSetupOk();
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CdbEngine::setupInferior()
|
void CdbEngine::setupInferior()
|
||||||
|
|||||||
@@ -30,22 +30,14 @@
|
|||||||
|
|
||||||
#include <projectexplorer/devicesupport/idevice.h>
|
#include <projectexplorer/devicesupport/idevice.h>
|
||||||
|
|
||||||
#include <QSharedPointer>
|
|
||||||
#include <QProcess>
|
|
||||||
#include <QMap>
|
|
||||||
#include <QVariant>
|
|
||||||
#include <QTime>
|
#include <QTime>
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class DisassemblerAgent;
|
|
||||||
class CdbCommand;
|
class CdbCommand;
|
||||||
struct MemoryViewCookie;
|
struct MemoryViewCookie;
|
||||||
class StringInputStream;
|
class StringInputStream;
|
||||||
class GdbMi;
|
|
||||||
|
|
||||||
class CdbEngine : public DebuggerEngine
|
class CdbEngine : public DebuggerEngine
|
||||||
{
|
{
|
||||||
@@ -156,7 +148,6 @@ private:
|
|||||||
ScriptCommand
|
ScriptCommand
|
||||||
};
|
};
|
||||||
|
|
||||||
bool startConsole(const DebuggerRunParameters &sp, QString *errorMessage);
|
|
||||||
void init();
|
void init();
|
||||||
unsigned examineStopReason(const GdbMi &stopReason, QString *message,
|
unsigned examineStopReason(const GdbMi &stopReason, QString *message,
|
||||||
QString *exceptionBoxMessage,
|
QString *exceptionBoxMessage,
|
||||||
@@ -165,7 +156,6 @@ private:
|
|||||||
bool commandsPending() const;
|
bool commandsPending() const;
|
||||||
void handleExtensionMessage(char t, int token, const QString &what, const QString &message);
|
void handleExtensionMessage(char t, int token, const QString &what, const QString &message);
|
||||||
bool doSetupEngine(QString *errorMessage);
|
bool doSetupEngine(QString *errorMessage);
|
||||||
bool launchCDB(const DebuggerRunParameters &sp, QString *errorMessage);
|
|
||||||
void handleSessionAccessible(unsigned long cdbExState);
|
void handleSessionAccessible(unsigned long cdbExState);
|
||||||
void handleSessionInaccessible(unsigned long cdbExState);
|
void handleSessionInaccessible(unsigned long cdbExState);
|
||||||
void handleSessionIdle(const QString &message);
|
void handleSessionIdle(const QString &message);
|
||||||
@@ -216,6 +206,7 @@ private:
|
|||||||
void mergeStartParametersSourcePathMap();
|
void mergeStartParametersSourcePathMap();
|
||||||
|
|
||||||
const QString m_tokenPrefix;
|
const QString m_tokenPrefix;
|
||||||
|
void handleSetupFailure(const QString &errorMessage);
|
||||||
|
|
||||||
QProcess m_process;
|
QProcess m_process;
|
||||||
DebuggerStartMode m_effectiveStartMode = NoStartMode;
|
DebuggerStartMode m_effectiveStartMode = NoStartMode;
|
||||||
|
|||||||
Reference in New Issue
Block a user