forked from qt-creator/qt-creator
debugger: refactoring
Intergrate per-engine state tracking with the global running/stopped state.
This commit is contained in:
@@ -286,19 +286,18 @@ CdbComInterfaces::CdbComInterfaces() :
|
||||
|
||||
// --- CdbDebugEnginePrivate
|
||||
|
||||
CdbDebugEnginePrivate::CdbDebugEnginePrivate(DebuggerManager *parent,
|
||||
CdbDebugEnginePrivate::CdbDebugEnginePrivate(DebuggerManager *manager,
|
||||
const QSharedPointer<CdbOptions> &options,
|
||||
CdbDebugEngine* engine) :
|
||||
m_options(options),
|
||||
m_hDebuggeeProcess(0),
|
||||
m_hDebuggeeThread(0),
|
||||
m_breakEventMode(BreakEventHandle),
|
||||
m_dumper(new CdbDumperHelper(parent, &m_cif)),
|
||||
m_dumper(new CdbDumperHelper(manager, &m_cif)),
|
||||
m_watchTimer(-1),
|
||||
m_debugEventCallBack(engine),
|
||||
m_engine(engine),
|
||||
m_debuggerManager(parent),
|
||||
m_debuggerManagerAccess(parent->engineInterface()),
|
||||
m_debuggerManagerAccess(manager->engineInterface()),
|
||||
m_currentStackTrace(0),
|
||||
m_firstActivatedFrame(true),
|
||||
m_mode(AttachCore)
|
||||
@@ -369,11 +368,11 @@ bool CdbDebugEnginePrivate::init(QString *errorMessage)
|
||||
return true;
|
||||
}
|
||||
|
||||
IDebuggerEngine *CdbDebugEngine::create(DebuggerManager *parent,
|
||||
IDebuggerEngine *CdbDebugEngine::create(DebuggerManager *manager,
|
||||
const QSharedPointer<CdbOptions> &options,
|
||||
QString *errorMessage)
|
||||
{
|
||||
CdbDebugEngine *rc = new CdbDebugEngine(parent, options);
|
||||
CdbDebugEngine *rc = new CdbDebugEngine(manager, options);
|
||||
if (rc->m_d->init(errorMessage)) {
|
||||
rc->syncDebuggerPaths();
|
||||
return rc;
|
||||
@@ -446,7 +445,7 @@ void CdbDebugEnginePrivate::cleanStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
CdbDebugEngine::CdbDebugEngine(DebuggerManager *parent, const QSharedPointer<CdbOptions> &options) :
|
||||
CdbDebugEngine::CdbDebugEngine(DebuggerManager *manager, const QSharedPointer<CdbOptions> &options) :
|
||||
IDebuggerEngine(parent),
|
||||
m_d(new CdbDebugEnginePrivate(parent, options, this))
|
||||
{
|
||||
@@ -455,13 +454,13 @@ CdbDebugEngine::CdbDebugEngine(DebuggerManager *parent, const QSharedPointer<Cdb
|
||||
connect(&m_d->m_consoleStubProc, SIGNAL(processStarted()), this, SLOT(slotConsoleStubStarted()));
|
||||
connect(&m_d->m_consoleStubProc, SIGNAL(wrapperStopped()), this, SLOT(slotConsoleStubTerminated()));
|
||||
connect(&m_d->m_debugOutputCallBack, SIGNAL(debuggerOutput(int,QString)),
|
||||
m_d->m_debuggerManager, SLOT(showDebuggerOutput(int,QString)));
|
||||
manager(), SLOT(showDebuggerOutput(int,QString)));
|
||||
connect(&m_d->m_debugOutputCallBack, SIGNAL(debuggerInputPrompt(int,QString)),
|
||||
m_d->m_debuggerManager, SLOT(showDebuggerInput(int,QString)));
|
||||
manager(), SLOT(showDebuggerInput(int,QString)));
|
||||
connect(&m_d->m_debugOutputCallBack, SIGNAL(debuggeeOutput(QString)),
|
||||
m_d->m_debuggerManager, SLOT(showApplicationOutput(QString)));
|
||||
manager(), SLOT(showApplicationOutput(QString)));
|
||||
connect(&m_d->m_debugOutputCallBack, SIGNAL(debuggeeInputPrompt(QString)),
|
||||
m_d->m_debuggerManager, SLOT(showApplicationOutput(QString)));
|
||||
manager(), SLOT(showApplicationOutput(QString)));
|
||||
}
|
||||
|
||||
CdbDebugEngine::~CdbDebugEngine()
|
||||
@@ -588,7 +587,7 @@ void CdbDebugEngine::startDebugger(const QSharedPointer<DebuggerStartParameters>
|
||||
}
|
||||
}
|
||||
m_d->m_dumper->reset(dumperLibName, dumperEnabled);
|
||||
m_d->m_debuggerManager->showStatusMessage("Starting Debugger", -1);
|
||||
showStatusMessage("Starting Debugger", -1);
|
||||
QString errorMessage;
|
||||
bool rc = false;
|
||||
bool needWatchTimer = false;
|
||||
@@ -621,7 +620,7 @@ void CdbDebugEngine::startDebugger(const QSharedPointer<DebuggerStartParameters>
|
||||
break;
|
||||
}
|
||||
if (rc) {
|
||||
m_d->m_debuggerManager->showStatusMessage(tr("Debugger running"), -1);
|
||||
showStatusMessage(tr("Debugger running"), -1);
|
||||
if (needWatchTimer)
|
||||
startWatchTimer();
|
||||
} else {
|
||||
@@ -653,13 +652,13 @@ bool CdbDebugEngine::startAttachDebugger(qint64 pid, DebuggerStartMode sm, QStri
|
||||
|
||||
bool CdbDebugEngine::startDebuggerWithExecutable(DebuggerStartMode sm, QString *errorMessage)
|
||||
{
|
||||
m_d->m_debuggerManager->showStatusMessage("Starting Debugger", -1);
|
||||
showStatusMessage("Starting Debugger", -1);
|
||||
|
||||
DEBUG_CREATE_PROCESS_OPTIONS dbgopts;
|
||||
memset(&dbgopts, 0, sizeof(dbgopts));
|
||||
dbgopts.CreateFlags = DEBUG_PROCESS | DEBUG_ONLY_THIS_PROCESS;
|
||||
|
||||
const QSharedPointer<DebuggerStartParameters> sp = m_d->m_debuggerManager->startParameters();
|
||||
const QSharedPointer<DebuggerStartParameters> sp = manager()->startParameters();
|
||||
const QString filename(sp->executable);
|
||||
// Set image path
|
||||
const QFileInfo fi(filename);
|
||||
@@ -728,7 +727,7 @@ void CdbDebugEnginePrivate::processCreatedAttached(ULONG64 processHandle, ULONG6
|
||||
// Attaching to crashed: This handshake (signalling an event) is required for
|
||||
// the exception to be delivered to the debugger
|
||||
if (m_mode == AttachCrashedExternal) {
|
||||
const QString crashParameter = m_debuggerManager->startParameters()->crashParameter;
|
||||
const QString crashParameter = manager()->startParameters()->crashParameter;
|
||||
if (!crashParameter.isEmpty()) {
|
||||
ULONG64 evtNr = crashParameter.toULongLong();
|
||||
const HRESULT hr = m_cif.debugControl->SetNotifyEventHandle(evtNr);
|
||||
@@ -748,7 +747,7 @@ void CdbDebugEngine::processTerminated(unsigned long exitCode)
|
||||
m_d->clearForRun();
|
||||
m_d->setDebuggeeHandles(0, 0);
|
||||
m_d->m_debuggerManagerAccess->notifyInferiorExited();
|
||||
m_d->m_debuggerManager->exitDebugger();
|
||||
manager()->exitDebugger();
|
||||
}
|
||||
|
||||
// End debugging using
|
||||
@@ -1025,8 +1024,9 @@ bool CdbDebugEnginePrivate::continueInferior(QString *errorMessage)
|
||||
clearForRun();
|
||||
setCodeLevel();
|
||||
m_engine->killWatchTimer();
|
||||
m_debuggerManager->resetLocation();
|
||||
m_debuggerManagerAccess->notifyInferiorRunningRequested();
|
||||
manager()->resetLocation();
|
||||
setState(InferiorRunningRequested);
|
||||
showStatusMessage(tr("Running requested..."), 5000);
|
||||
|
||||
if (!continueInferiorProcess(errorMessage))
|
||||
return false;
|
||||
@@ -1186,7 +1186,7 @@ void CdbDebugEngine::activateFrame(int frameIndex)
|
||||
if (debugCDB)
|
||||
qDebug() << Q_FUNC_INFO << frameIndex;
|
||||
|
||||
if (m_d->m_debuggerManager->status() != DebuggerInferiorStopped) {
|
||||
if (state() != InferiorStopped) {
|
||||
qWarning("WARNING %s: invoked while debuggee is running\n", Q_FUNC_INFO);
|
||||
return;
|
||||
}
|
||||
@@ -1215,7 +1215,7 @@ void CdbDebugEngine::activateFrame(int frameIndex)
|
||||
break;
|
||||
}
|
||||
|
||||
m_d->m_debuggerManager->gotoLocation(frame, true);
|
||||
manager()->gotoLocation(frame, true);
|
||||
|
||||
if (oldIndex != frameIndex || m_d->m_firstActivatedFrame) {
|
||||
watchHandler->beginCycle();
|
||||
@@ -1235,7 +1235,7 @@ void CdbDebugEngine::selectThread(int index)
|
||||
qDebug() << Q_FUNC_INFO << index;
|
||||
|
||||
//reset location arrow
|
||||
m_d->m_debuggerManager->resetLocation();
|
||||
manager()->resetLocation();
|
||||
|
||||
ThreadsHandler *threadsHandler = m_d->m_debuggerManagerAccess->threadsHandler();
|
||||
threadsHandler->setCurrentThread(index);
|
||||
@@ -1417,7 +1417,7 @@ void CdbDebugEngine::timerEvent(QTimerEvent* te)
|
||||
const HRESULT hr = m_d->m_cif.debugControl->WaitForEvent(0, 1);
|
||||
if (debugCDB)
|
||||
if (debugCDB > 1 || hr != S_FALSE)
|
||||
qDebug() << Q_FUNC_INFO << "WaitForEvent" << m_d->m_debuggerManager->status() << msgDebugEngineComResult(hr);
|
||||
qDebug() << Q_FUNC_INFO << "WaitForEvent" << state() << msgDebugEngineComResult(hr);
|
||||
|
||||
switch (hr) {
|
||||
case S_OK:
|
||||
@@ -1446,13 +1446,13 @@ void CdbDebugEngine::slotConsoleStubStarted()
|
||||
m_d->m_debuggerManagerAccess->notifyInferiorPidChanged(appPid);
|
||||
m_d->m_debuggerManagerAccess->notifyInferiorRunning();
|
||||
} else {
|
||||
QMessageBox::critical(m_d->m_debuggerManager->mainWindow(), tr("Debugger Error"), errorMessage);
|
||||
QMessageBox::critical(manager()->mainWindow(), tr("Debugger Error"), errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
void CdbDebugEngine::slotConsoleStubError(const QString &msg)
|
||||
{
|
||||
QMessageBox::critical(m_d->m_debuggerManager->mainWindow(), tr("Debugger Error"), msg);
|
||||
QMessageBox::critical(manager()->mainWindow(), tr("Debugger Error"), msg);
|
||||
}
|
||||
|
||||
void CdbDebugEngine::slotConsoleStubTerminated()
|
||||
|
||||
@@ -100,6 +100,10 @@ public:
|
||||
virtual void reloadSourceFiles();
|
||||
virtual void reloadFullStack() {}
|
||||
|
||||
DebuggerState state() const;
|
||||
void setState(DebuggerState state);
|
||||
void showStatusMessage(const QString &msg, int timeout = -1);
|
||||
|
||||
public slots:
|
||||
void syncDebuggerPaths();
|
||||
|
||||
|
||||
@@ -45,7 +45,6 @@ namespace Debugger {
|
||||
namespace Internal {
|
||||
|
||||
class DebuggerManager;
|
||||
class IDebuggerManagerAccessForEngines;
|
||||
class WatchHandler;
|
||||
class CdbStackFrameContext;
|
||||
class CdbStackTraceContext;
|
||||
@@ -161,9 +160,8 @@ struct CdbDebugEnginePrivate
|
||||
QSharedPointer<CdbDumperHelper> m_dumper;
|
||||
QString m_baseImagePath;
|
||||
|
||||
CdbDebugEngine* m_engine;
|
||||
DebuggerManager *m_debuggerManager;
|
||||
IDebuggerManagerAccessForEngines *m_debuggerManagerAccess;
|
||||
CdbDebugEngine *m_engine;
|
||||
DebuggerManager *manager() const { return m_engine->manager(); }
|
||||
CdbStackTraceContext *m_currentStackTrace;
|
||||
EditorToolTipCache m_editorToolTipCache;
|
||||
|
||||
|
||||
@@ -372,10 +372,9 @@ STDMETHODIMP CdbDebugEventCallback::SystemError(
|
||||
}
|
||||
|
||||
// -----------ExceptionLoggerEventCallback
|
||||
CdbExceptionLoggerEventCallback::CdbExceptionLoggerEventCallback(int logChannel,
|
||||
IDebuggerManagerAccessForEngines *access) :
|
||||
CdbExceptionLoggerEventCallback::CdbExceptionLoggerEventCallback(int logChannel, DebuggerManager *manager) :
|
||||
m_logChannel(logChannel),
|
||||
m_access(access)
|
||||
m_manager(manager)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -399,7 +398,7 @@ STDMETHODIMP CdbExceptionLoggerEventCallback::Exception(
|
||||
}
|
||||
if (debugCDB)
|
||||
qDebug() << Q_FUNC_INFO << '\n' << m_exceptionMessages.back();
|
||||
m_access->showDebuggerOutput(m_logChannel, m_exceptionMessages.back());
|
||||
m_manager->showDebuggerOutput(m_logChannel, m_exceptionMessages.back());
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,6 @@ namespace Debugger {
|
||||
namespace Internal {
|
||||
|
||||
class CdbDebugEngine;
|
||||
class IDebuggerManagerAccessForEngines;
|
||||
|
||||
// Base class for event callbacks that takes care
|
||||
// Active X magic. Provides base implementations with
|
||||
@@ -241,8 +240,7 @@ private:
|
||||
class CdbExceptionLoggerEventCallback : public CdbDebugEventCallbackBase
|
||||
{
|
||||
public:
|
||||
explicit CdbExceptionLoggerEventCallback(int logChannel,
|
||||
IDebuggerManagerAccessForEngines *access);
|
||||
CdbExceptionLoggerEventCallback(int logChannel, DebuggerManager *access);
|
||||
|
||||
STDMETHOD(GetInterestMask)(
|
||||
THIS_
|
||||
@@ -261,7 +259,7 @@ public:
|
||||
|
||||
private:
|
||||
const int m_logChannel;
|
||||
IDebuggerManagerAccessForEngines *m_access;
|
||||
DebuggerManager *m_manager;
|
||||
QList<ULONG> m_exceptionCodes;
|
||||
QStringList m_exceptionMessages;
|
||||
};
|
||||
|
||||
@@ -140,7 +140,7 @@ static bool createDebuggeeAscIIString(CdbComInterfaces *cif,
|
||||
// the QtCored4.pdb file to be present as we need "qstrdup"
|
||||
// as dummy symbol. This is ok ATM since dumpers only
|
||||
// make sense for Qt apps.
|
||||
static bool debuggeeLoadLibrary(IDebuggerManagerAccessForEngines *access,
|
||||
static bool debuggeeLoadLibrary(DebuggerManager *manager,
|
||||
CdbComInterfaces *cif,
|
||||
const QString &moduleName,
|
||||
QString *errorMessage)
|
||||
@@ -148,7 +148,7 @@ static bool debuggeeLoadLibrary(IDebuggerManagerAccessForEngines *access,
|
||||
if (loadDebug > 1)
|
||||
qDebug() << Q_FUNC_INFO << moduleName;
|
||||
// Try to ignore the breakpoints
|
||||
CdbExceptionLoggerEventCallback exLogger(LogWarning, access);
|
||||
CdbExceptionLoggerEventCallback exLogger(LogWarning, manager);
|
||||
EventCallbackRedirector eventRedir(cif->debugClient, &exLogger);
|
||||
// Make a call to LoadLibraryA. First, reserve memory in debugger
|
||||
// and copy name over.
|
||||
@@ -221,7 +221,6 @@ CdbDumperHelper::CdbDumperHelper(DebuggerManager *manager,
|
||||
m_tryInjectLoad(true),
|
||||
m_state(NotLoaded),
|
||||
m_manager(manager),
|
||||
m_access(manager),
|
||||
m_cif(cif),
|
||||
m_inBufferAddress(0),
|
||||
m_inBufferSize(0),
|
||||
@@ -240,7 +239,7 @@ void CdbDumperHelper::disable()
|
||||
{
|
||||
if (loadDebug)
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
m_access->showDebuggerOutput(LogMisc, QCoreApplication::translate("Debugger::Internal::CdbDumperHelper", "Disabling dumpers due to debuggee crash..."));
|
||||
m_manager->showDebuggerOutput(LogMisc, QCoreApplication::translate("Debugger::Internal::CdbDumperHelper", "Disabling dumpers due to debuggee crash..."));
|
||||
m_state = Disabled;
|
||||
}
|
||||
|
||||
@@ -287,7 +286,7 @@ void CdbDumperHelper::moduleLoadHook(const QString &module, HANDLE debuggeeHandl
|
||||
} else {
|
||||
m_state = InjectLoadFailed;
|
||||
// Ok, try call loading...
|
||||
m_access->showDebuggerOutput(LogMisc, msgLoadFailed(m_library, true, errorMessage));
|
||||
m_manager->showDebuggerOutput(LogMisc, msgLoadFailed(m_library, true, errorMessage));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -295,7 +294,7 @@ void CdbDumperHelper::moduleLoadHook(const QString &module, HANDLE debuggeeHandl
|
||||
// check if gdbmacros.dll loaded
|
||||
if (module.contains(QLatin1String(dumperModuleNameC), Qt::CaseInsensitive)) {
|
||||
m_state = Loaded;
|
||||
m_access->showDebuggerOutput(LogMisc, msgLoadSucceeded(m_library, true));
|
||||
m_manager->showDebuggerOutput(LogMisc, msgLoadSucceeded(m_library, true));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -317,7 +316,7 @@ CdbDumperHelper::CallLoadResult CdbDumperHelper::initCallLoad(QString *errorMess
|
||||
if (modules.filter(QLatin1String(qtCoreModuleNameC), Qt::CaseInsensitive).isEmpty())
|
||||
return CallLoadNoQtApp;
|
||||
// Try to load
|
||||
if (!debuggeeLoadLibrary(m_access, m_cif, m_library, errorMessage))
|
||||
if (!debuggeeLoadLibrary(m_manager, m_cif, m_library, errorMessage))
|
||||
return CallLoadError;
|
||||
return CallLoadOk;
|
||||
}
|
||||
@@ -342,17 +341,17 @@ bool CdbDumperHelper::ensureInitialized(QString *errorMessage)
|
||||
switch (initCallLoad(errorMessage)) {
|
||||
case CallLoadOk:
|
||||
case CallLoadAlreadyLoaded:
|
||||
m_access->showDebuggerOutput(LogMisc, msgLoadSucceeded(m_library, false));
|
||||
m_manager->showDebuggerOutput(LogMisc, msgLoadSucceeded(m_library, false));
|
||||
m_state = Loaded;
|
||||
break;
|
||||
case CallLoadError:
|
||||
*errorMessage = msgLoadFailed(m_library, false, *errorMessage);
|
||||
m_access->showDebuggerOutput(LogError, *errorMessage);
|
||||
m_access->showQtDumperLibraryWarning(*errorMessage);
|
||||
m_manager->showDebuggerOutput(LogError, *errorMessage);
|
||||
m_manager->showQtDumperLibraryWarning(*errorMessage);
|
||||
m_state = Disabled; // No message here, no point in retrying
|
||||
return false;
|
||||
case CallLoadNoQtApp:
|
||||
m_access->showDebuggerOutput(LogMisc, QCoreApplication::translate("Debugger::Internal::CdbDumperHelper", "The debuggee does not appear to be Qt application."));
|
||||
m_manager->showDebuggerOutput(LogMisc, QCoreApplication::translate("Debugger::Internal::CdbDumperHelper", "The debuggee does not appear to be Qt application."));
|
||||
m_state = Disabled; // No message here
|
||||
return true;
|
||||
}
|
||||
@@ -364,14 +363,14 @@ bool CdbDumperHelper::ensureInitialized(QString *errorMessage)
|
||||
m_manager->showStatusMessage(QCoreApplication::translate("Debugger::Internal::CdbDumperHelper", "Initializing dumpers..."), 10000);
|
||||
const bool ok = initResolveSymbols(errorMessage) && initKnownTypes(errorMessage);
|
||||
if (ok) {
|
||||
m_access->showDebuggerOutput(LogMisc, QCoreApplication::translate("Debugger::Internal::CdbDumperHelper", "Custom dumper library initialized."));
|
||||
m_access->showDebuggerOutput(LogMisc, m_helper.toString());
|
||||
m_manager->showDebuggerOutput(LogMisc, QCoreApplication::translate("Debugger::Internal::CdbDumperHelper", "Custom dumper library initialized."));
|
||||
m_manager->showDebuggerOutput(LogMisc, m_helper.toString());
|
||||
m_state = Initialized;
|
||||
} else {
|
||||
m_state = Disabled; // No message here
|
||||
*errorMessage = QCoreApplication::translate("Debugger::Internal::CdbDumperHelper", "The custom dumper library could not be initialized: %1").arg(*errorMessage);
|
||||
m_access->showDebuggerOutput(LogMisc, *errorMessage);
|
||||
m_access->showQtDumperLibraryWarning(*errorMessage);
|
||||
m_manager->showDebuggerOutput(LogMisc, *errorMessage);
|
||||
m_manager->showQtDumperLibraryWarning(*errorMessage);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
@@ -479,7 +478,7 @@ bool CdbDumperHelper::callDumper(const QString &callCmd, const QByteArray &inBuf
|
||||
bool ignoreAccessViolation, QString *errorMessage)
|
||||
{
|
||||
*outDataPtr = 0;
|
||||
CdbExceptionLoggerEventCallback exLogger(LogWarning, m_access);
|
||||
CdbExceptionLoggerEventCallback exLogger(LogWarning, m_manager);
|
||||
EventCallbackRedirector eventRedir(m_cif->debugClient, &exLogger);
|
||||
// write input buffer
|
||||
if (!inBuffer.isEmpty()) {
|
||||
@@ -574,7 +573,7 @@ CdbDumperHelper::DumpResult CdbDumperHelper::dumpType(const WatchData &wd, bool
|
||||
// Ensure types are parsed and known.
|
||||
if (!ensureInitialized(errorMessage)) {
|
||||
*errorMessage = msgDumpFailed(wd, errorMessage);
|
||||
m_access->showDebuggerOutput(LogError, *errorMessage);
|
||||
m_manager->showDebuggerOutput(LogError, *errorMessage);
|
||||
return DumpError;
|
||||
}
|
||||
|
||||
@@ -591,7 +590,7 @@ CdbDumperHelper::DumpResult CdbDumperHelper::dumpType(const WatchData &wd, bool
|
||||
const QString message = QCoreApplication::translate("Debugger::Internal::CdbDumperHelper",
|
||||
"Querying dumpers for '%1'/'%2' (%3)").
|
||||
arg(wd.name, wd.exp, wd.type);
|
||||
m_access->showDebuggerOutput(LogMisc, message);
|
||||
m_manager->showDebuggerOutput(LogMisc, message);
|
||||
|
||||
const DumpExecuteResult der = executeDump(wd, td, dumpChildren, result, errorMessage);
|
||||
if (der == DumpExecuteOk)
|
||||
@@ -604,7 +603,7 @@ CdbDumperHelper::DumpResult CdbDumperHelper::dumpType(const WatchData &wd, bool
|
||||
m_failedTypes.push_back(wd.type);
|
||||
// log error
|
||||
*errorMessage = msgDumpFailed(wd, errorMessage);
|
||||
m_access->showDebuggerOutput(LogWarning, *errorMessage);
|
||||
m_manager->showDebuggerOutput(LogWarning, *errorMessage);
|
||||
return DumpError;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,6 @@ namespace Debugger {
|
||||
namespace Internal {
|
||||
|
||||
struct CdbComInterfaces;
|
||||
class IDebuggerManagerAccessForEngines;
|
||||
class DebuggerManager;
|
||||
|
||||
/* For code clarity, all the stuff related to custom dumpers goes here.
|
||||
@@ -121,7 +120,6 @@ private:
|
||||
const bool m_tryInjectLoad;
|
||||
State m_state;
|
||||
DebuggerManager *m_manager;
|
||||
IDebuggerManagerAccessForEngines *m_access;
|
||||
CdbComInterfaces *m_cif;
|
||||
|
||||
QString m_library;
|
||||
|
||||
@@ -59,6 +59,66 @@ namespace Internal {
|
||||
enum { debug = 0 };
|
||||
}
|
||||
} // namespace Constants
|
||||
|
||||
namespace Internal {
|
||||
|
||||
enum DebuggerState
|
||||
{
|
||||
DebuggerNotReady, // Debugger not started
|
||||
|
||||
EngineStarting, // Engine starts
|
||||
|
||||
AdapterStarting,
|
||||
AdapterStarted,
|
||||
AdapterStartFailed,
|
||||
InferiorPreparing,
|
||||
InferiorPrepared,
|
||||
InferiorPreparationFailed,
|
||||
InferiorStarting,
|
||||
// InferiorStarted, // That's either InferiorRunningRequested or InferiorStopped
|
||||
InferiorStartFailed,
|
||||
|
||||
InferiorRunningRequested, // Debuggee requested to run
|
||||
InferiorRunning, // Debuggee running
|
||||
|
||||
InferiorStopping, // Debuggee running, stop requested
|
||||
InferiorStopped, // Debuggee stopped
|
||||
InferiorStopFailed, // Debuggee stopped
|
||||
|
||||
InferiorShuttingDown,
|
||||
InferiorShutDown,
|
||||
InferiorShutdownFailed,
|
||||
|
||||
AdapterShuttingDown,
|
||||
//AdapterShutDown, // use DebuggerNotReady
|
||||
AdapterShutdownFailed,
|
||||
};
|
||||
|
||||
enum DebuggerStartMode
|
||||
{
|
||||
NoStartMode,
|
||||
StartInternal, // Start current start project's binary
|
||||
StartExternal, // Start binary found in file system
|
||||
AttachExternal, // Attach to running process by process id
|
||||
AttachCrashedExternal, // Attach to crashed process by process id
|
||||
AttachTcf, // Attach to a running Target Communication Framework agent
|
||||
AttachCore, // Attach to a core file
|
||||
StartRemote // Start and attach to a remote process
|
||||
};
|
||||
|
||||
enum LogChannel
|
||||
{
|
||||
LogInput, // Used for user input
|
||||
LogOutput,
|
||||
LogWarning,
|
||||
LogError,
|
||||
LogStatus, // Used for status changed messages
|
||||
LogTime, // Used for time stamp messages
|
||||
LogDebug,
|
||||
LogMisc
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Debugger
|
||||
|
||||
#endif // DEBUGGERCONSTANTS_H
|
||||
|
||||
@@ -92,6 +92,48 @@
|
||||
# define STATE_DEBUG(s)
|
||||
#endif
|
||||
|
||||
// Note: the Debugger process itself is referred to as 'Debugger',
|
||||
// whereas the debugged process is referred to as 'Inferior'.
|
||||
//
|
||||
// 0 == DebuggerNotReady
|
||||
// |
|
||||
// EngineStarting
|
||||
// |
|
||||
// AdapterStarting --> AdapterStartFailed --> 0
|
||||
// |
|
||||
// AdapterStarted
|
||||
// |
|
||||
// InferiorStarting --> InferiorStartFailed --> 0
|
||||
// | |
|
||||
// | |
|
||||
// InferiorStopped |
|
||||
// | |
|
||||
// | <--------
|
||||
// | .------------------------------------.
|
||||
// | v |
|
||||
// InferiorRunningRequested |
|
||||
// | |
|
||||
// InferiorRunning --> 1 (normal exit) |
|
||||
// | |
|
||||
// InferiorStopping |
|
||||
// | |
|
||||
// InferiorStopped --> 1 |
|
||||
// | |
|
||||
// `---------------------------------------'
|
||||
//
|
||||
// 1 == InferiorShuttingDown -> InferiorShutdownFailed
|
||||
// |
|
||||
// InferiorShutDown
|
||||
// |
|
||||
// AdapterShuttingDown -> AdapterShutdownFailed --> 0
|
||||
// |
|
||||
// 0
|
||||
//
|
||||
// Allowed actions:
|
||||
// [R] : Run
|
||||
// [C] : Continue
|
||||
// [N] : Step, Next
|
||||
|
||||
namespace Debugger {
|
||||
namespace Internal {
|
||||
|
||||
@@ -134,21 +176,31 @@ static const QString tooltipIName = "tooltip";
|
||||
|
||||
static const char *stateName(int s)
|
||||
{
|
||||
#define SN(x) case x: return #x;
|
||||
switch (s) {
|
||||
case DebuggerProcessNotReady:
|
||||
return "DebuggerProcessNotReady";
|
||||
case DebuggerProcessStartingUp:
|
||||
return "DebuggerProcessStartingUp";
|
||||
case DebuggerInferiorRunningRequested:
|
||||
return "DebuggerInferiorRunningRequested";
|
||||
case DebuggerInferiorRunning:
|
||||
return "DebuggerInferiorRunning";
|
||||
case DebuggerInferiorStopRequested:
|
||||
return "DebuggerInferiorStopRequested";
|
||||
case DebuggerInferiorStopped:
|
||||
return "DebuggerInferiorStopped";
|
||||
SN(DebuggerNotReady)
|
||||
SN(EngineStarting)
|
||||
SN(AdapterStarting)
|
||||
SN(AdapterStarted)
|
||||
SN(AdapterStartFailed)
|
||||
SN(InferiorPreparing)
|
||||
SN(InferiorPrepared)
|
||||
SN(InferiorPreparationFailed)
|
||||
SN(InferiorStarting)
|
||||
SN(InferiorStartFailed)
|
||||
SN(InferiorRunningRequested)
|
||||
SN(InferiorRunning)
|
||||
SN(InferiorStopping)
|
||||
SN(InferiorStopped)
|
||||
SN(InferiorStopFailed)
|
||||
SN(InferiorShuttingDown)
|
||||
SN(InferiorShutDown)
|
||||
SN(InferiorShutdownFailed)
|
||||
SN(AdapterShuttingDown)
|
||||
SN(AdapterShutdownFailed)
|
||||
}
|
||||
return "<unknown>";
|
||||
#undef SN
|
||||
}
|
||||
|
||||
|
||||
@@ -214,7 +266,7 @@ DebuggerManager::~DebuggerManager()
|
||||
|
||||
void DebuggerManager::init()
|
||||
{
|
||||
m_status = -1;
|
||||
m_state = DebuggerState(-1);
|
||||
m_busy = false;
|
||||
|
||||
m_modulesHandler = 0;
|
||||
@@ -443,7 +495,7 @@ void DebuggerManager::init()
|
||||
localsAndWatchers->setStretchFactor(2, 1);
|
||||
m_watchDock = m_mainWindow->addDockForWidget(localsAndWatchers);
|
||||
|
||||
setStatus(DebuggerProcessNotReady);
|
||||
setState(DebuggerNotReady);
|
||||
}
|
||||
|
||||
QList<Core::IOptionsPage*> DebuggerManager::initializeEngines(unsigned enabledTypeFlags)
|
||||
@@ -477,11 +529,6 @@ IDebuggerEngine *DebuggerManager::engine()
|
||||
return m_engine;
|
||||
}
|
||||
|
||||
IDebuggerManagerAccessForEngines *DebuggerManager::engineInterface()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
void DebuggerManager::createNewDock(QWidget *widget)
|
||||
{
|
||||
QDockWidget *dockWidget = new QDockWidget(widget->windowTitle(), m_mainWindow);
|
||||
@@ -546,34 +593,22 @@ void DebuggerManager::showStatusMessage(const QString &msg, int timeout)
|
||||
}
|
||||
}
|
||||
|
||||
void DebuggerManager::notifyInferiorStopRequested()
|
||||
{
|
||||
setStatus(DebuggerInferiorStopRequested);
|
||||
showStatusMessage(tr("Stop requested..."), 5000);
|
||||
}
|
||||
|
||||
void DebuggerManager::notifyInferiorStopped()
|
||||
{
|
||||
resetLocation();
|
||||
setStatus(DebuggerInferiorStopped);
|
||||
setState(InferiorStopped);
|
||||
showStatusMessage(tr("Stopped."), 5000);
|
||||
}
|
||||
|
||||
void DebuggerManager::notifyInferiorRunningRequested()
|
||||
{
|
||||
setStatus(DebuggerInferiorRunningRequested);
|
||||
showStatusMessage(tr("Running requested..."), 5000);
|
||||
}
|
||||
|
||||
void DebuggerManager::notifyInferiorRunning()
|
||||
{
|
||||
setStatus(DebuggerInferiorRunning);
|
||||
setState(InferiorRunning);
|
||||
showStatusMessage(tr("Running..."), 5000);
|
||||
}
|
||||
|
||||
void DebuggerManager::notifyInferiorExited()
|
||||
{
|
||||
setStatus(DebuggerProcessNotReady);
|
||||
setState(DebuggerNotReady);
|
||||
showStatusMessage(tr("Exited."), 5000);
|
||||
}
|
||||
|
||||
@@ -649,9 +684,9 @@ void DebuggerManager::toggleBreakpoint(const QString &fileName, int lineNumber)
|
||||
{
|
||||
STATE_DEBUG(fileName << lineNumber);
|
||||
QTC_ASSERT(m_breakHandler, return);
|
||||
if (status() != DebuggerInferiorRunning
|
||||
&& status() != DebuggerInferiorStopped
|
||||
&& status() != DebuggerProcessNotReady) {
|
||||
if (state() != InferiorRunning
|
||||
&& state() != InferiorStopped
|
||||
&& state() != DebuggerNotReady) {
|
||||
showStatusMessage(tr("Changing breakpoint state requires either a "
|
||||
"fully running or fully stopped application."));
|
||||
return;
|
||||
@@ -670,9 +705,9 @@ void DebuggerManager::toggleBreakpointEnabled(const QString &fileName, int lineN
|
||||
{
|
||||
STATE_DEBUG(fileName << lineNumber);
|
||||
QTC_ASSERT(m_breakHandler, return);
|
||||
if (status() != DebuggerInferiorRunning
|
||||
&& status() != DebuggerInferiorStopped
|
||||
&& status() != DebuggerProcessNotReady) {
|
||||
if (state() != InferiorRunning
|
||||
&& state() != InferiorStopped
|
||||
&& state() != DebuggerNotReady) {
|
||||
showStatusMessage(tr("Changing breakpoint state requires either a "
|
||||
"fully running or fully stopped application."));
|
||||
return;
|
||||
@@ -862,7 +897,7 @@ void DebuggerManager::startNewDebugger(const DebuggerStartParametersPtr &sp)
|
||||
|
||||
STATE_DEBUG(m_startParameters->executable << m_engine);
|
||||
setBusyCursor(false);
|
||||
setStatus(DebuggerProcessStartingUp);
|
||||
setState(EngineStarting);
|
||||
connect(m_engine, SIGNAL(startFailed()), this, SLOT(startFailed()));
|
||||
m_engine->startDebugger(m_startParameters);
|
||||
}
|
||||
@@ -870,7 +905,7 @@ void DebuggerManager::startNewDebugger(const DebuggerStartParametersPtr &sp)
|
||||
void DebuggerManager::startFailed()
|
||||
{
|
||||
disconnect(m_engine, SIGNAL(startFailed()), this, SLOT(startFailed()));
|
||||
setStatus(DebuggerProcessNotReady);
|
||||
setState(DebuggerNotReady);
|
||||
emit debuggingFinished();
|
||||
}
|
||||
|
||||
@@ -892,7 +927,7 @@ void DebuggerManager::exitDebugger()
|
||||
if (m_engine)
|
||||
m_engine->exitDebugger();
|
||||
cleanupViews();
|
||||
setStatus(DebuggerProcessNotReady);
|
||||
setState(DebuggerNotReady);
|
||||
setBusyCursor(false);
|
||||
emit debuggingFinished();
|
||||
}
|
||||
@@ -900,7 +935,7 @@ void DebuggerManager::exitDebugger()
|
||||
void DebuggerManager::notifyEngineFinished()
|
||||
{
|
||||
cleanupViews();
|
||||
setStatus(DebuggerProcessNotReady);
|
||||
setState(DebuggerNotReady);
|
||||
setBusyCursor(false);
|
||||
emit debuggingFinished();
|
||||
}
|
||||
@@ -1011,7 +1046,7 @@ void DebuggerManager::executeDebuggerCommand(const QString &command)
|
||||
void DebuggerManager::sessionLoaded()
|
||||
{
|
||||
cleanupViews();
|
||||
setStatus(DebuggerProcessNotReady);
|
||||
setState(DebuggerNotReady);
|
||||
setBusyCursor(false);
|
||||
loadSessionData();
|
||||
}
|
||||
@@ -1021,7 +1056,7 @@ void DebuggerManager::aboutToUnloadSession()
|
||||
cleanupViews();
|
||||
if (m_engine)
|
||||
m_engine->shutdown();
|
||||
setStatus(DebuggerProcessNotReady);
|
||||
setState(DebuggerNotReady);
|
||||
setBusyCursor(false);
|
||||
}
|
||||
|
||||
@@ -1094,79 +1129,6 @@ void DebuggerManager::breakByFunction(const QString &functionName)
|
||||
attemptBreakpointSynchronization();
|
||||
}
|
||||
|
||||
static bool isAllowedTransition(int from, int to)
|
||||
{
|
||||
return (from == -1)
|
||||
|| (from == DebuggerProcessNotReady && to == DebuggerProcessStartingUp)
|
||||
|| (from == DebuggerProcessStartingUp && to == DebuggerInferiorStopped)
|
||||
|| (from == DebuggerInferiorStopped && to == DebuggerInferiorRunningRequested)
|
||||
|| (from == DebuggerInferiorRunningRequested && to == DebuggerInferiorRunning)
|
||||
|| (from == DebuggerInferiorRunning && to == DebuggerInferiorStopRequested)
|
||||
|| (from == DebuggerInferiorRunning && to == DebuggerInferiorStopped)
|
||||
|| (from == DebuggerInferiorStopRequested && to == DebuggerInferiorStopped)
|
||||
|| (to == DebuggerProcessNotReady);
|
||||
}
|
||||
|
||||
void DebuggerManager::setStatus(int status)
|
||||
{
|
||||
STATE_DEBUG("STATUS CHANGE: FROM " << stateName(m_status)
|
||||
<< " TO " << stateName(status));
|
||||
|
||||
if (status == m_status)
|
||||
return;
|
||||
|
||||
if (!isAllowedTransition(m_status, status)) {
|
||||
const QString msg = QString::fromLatin1("%1: UNEXPECTED TRANSITION: %2 -> %3")
|
||||
.arg(_(Q_FUNC_INFO), _(stateName(m_status)), _(stateName(status)));
|
||||
qWarning("%s", qPrintable(msg));
|
||||
}
|
||||
|
||||
m_status = status;
|
||||
|
||||
const bool started = status == DebuggerInferiorRunning
|
||||
|| status == DebuggerInferiorRunningRequested
|
||||
|| status == DebuggerInferiorStopRequested
|
||||
|| status == DebuggerInferiorStopped;
|
||||
|
||||
const bool running = status == DebuggerInferiorRunning;
|
||||
|
||||
const bool ready = status == DebuggerInferiorStopped
|
||||
&& m_startParameters->startMode != AttachCore;
|
||||
|
||||
STATE_DEBUG("STARTED: " << started << " RUNNING: " << running
|
||||
<< " READY: " << ready);
|
||||
|
||||
if (ready)
|
||||
QApplication::alert(mainWindow(), 3000);
|
||||
|
||||
m_watchAction->setEnabled(ready);
|
||||
m_breakAction->setEnabled(true);
|
||||
|
||||
bool interruptIsExit = !running;
|
||||
if (interruptIsExit) {
|
||||
m_stopAction->setIcon(QIcon(":/debugger/images/debugger_stop_small.png"));
|
||||
m_stopAction->setText(tr("Stop Debugger"));
|
||||
} else {
|
||||
m_stopAction->setIcon(QIcon(":/debugger/images/debugger_interrupt_small.png"));
|
||||
m_stopAction->setText(tr("Interrupt"));
|
||||
}
|
||||
|
||||
m_stopAction->setEnabled(started);
|
||||
m_resetAction->setEnabled(true);
|
||||
|
||||
m_stepAction->setEnabled(ready);
|
||||
m_stepOutAction->setEnabled(ready);
|
||||
m_runToLineAction->setEnabled(ready);
|
||||
m_runToFunctionAction->setEnabled(ready);
|
||||
m_jumpToLineAction->setEnabled(ready);
|
||||
m_nextAction->setEnabled(ready);
|
||||
//showStatusMessage(QString("started: %1, running: %2")
|
||||
// .arg(started).arg(running));
|
||||
emit statusChanged(m_status);
|
||||
const bool notbusy = ready || status == DebuggerProcessNotReady;
|
||||
setBusyCursor(!notbusy);
|
||||
}
|
||||
|
||||
void DebuggerManager::setBusyCursor(bool busy)
|
||||
{
|
||||
//STATE_DEBUG("BUSY FROM: " << m_busy << " TO: " << m_busy);
|
||||
@@ -1207,14 +1169,13 @@ void DebuggerManager::detachDebugger()
|
||||
|
||||
void DebuggerManager::interruptDebuggingRequest()
|
||||
{
|
||||
STATE_DEBUG(status());
|
||||
STATE_DEBUG(state());
|
||||
if (!m_engine)
|
||||
return;
|
||||
bool interruptIsExit = (status() != DebuggerInferiorRunning);
|
||||
if (interruptIsExit)
|
||||
bool interruptIsExit = (state() != InferiorRunning);
|
||||
if (interruptIsExit) {
|
||||
exitDebugger();
|
||||
else {
|
||||
setStatus(DebuggerInferiorStopRequested);
|
||||
} else {
|
||||
m_engine->interruptInferior();
|
||||
}
|
||||
}
|
||||
@@ -1483,6 +1444,158 @@ void DebuggerManager::showMessageBox(int icon,
|
||||
mb->show();
|
||||
}
|
||||
|
||||
DebuggerState DebuggerManager::state() const
|
||||
{
|
||||
return m_state;
|
||||
}
|
||||
|
||||
static bool isAllowedTransition(int from, int to)
|
||||
{
|
||||
switch (from) {
|
||||
case -1:
|
||||
return to == DebuggerNotReady;
|
||||
|
||||
case DebuggerNotReady:
|
||||
return to == EngineStarting || to == DebuggerNotReady;
|
||||
|
||||
case EngineStarting:
|
||||
return to == AdapterStarting || to == DebuggerNotReady;
|
||||
|
||||
case AdapterStarting:
|
||||
return to == AdapterStarted || to == AdapterStartFailed;
|
||||
case AdapterStarted:
|
||||
return to == InferiorPreparing;
|
||||
case AdapterStartFailed:
|
||||
return to == DebuggerNotReady;
|
||||
|
||||
case InferiorPreparing:
|
||||
return to == InferiorPrepared || to == InferiorPreparationFailed;
|
||||
case InferiorPrepared:
|
||||
return to == InferiorStarting;
|
||||
case InferiorPreparationFailed:
|
||||
return to == DebuggerNotReady;
|
||||
|
||||
case InferiorStarting:
|
||||
return to == InferiorRunningRequested || to == InferiorStopped
|
||||
|| to == InferiorStartFailed;
|
||||
case InferiorStartFailed:
|
||||
return to == DebuggerNotReady;
|
||||
|
||||
case InferiorRunningRequested:
|
||||
return to == InferiorRunning;
|
||||
case InferiorRunning:
|
||||
return to == InferiorStopping || to == InferiorShuttingDown;
|
||||
|
||||
case InferiorStopping:
|
||||
return to == InferiorStopped || to == InferiorStopFailed;
|
||||
case InferiorStopped:
|
||||
return to == InferiorRunningRequested || to == InferiorShuttingDown;
|
||||
case InferiorStopFailed:
|
||||
return to == DebuggerNotReady;
|
||||
|
||||
case InferiorShuttingDown:
|
||||
return to == InferiorShutDown || to == InferiorShutdownFailed;
|
||||
case InferiorShutDown:
|
||||
return to == AdapterShuttingDown;
|
||||
|
||||
case AdapterShuttingDown:
|
||||
return to == DebuggerNotReady;
|
||||
|
||||
default:
|
||||
qDebug() << "UNKNOWN STATE: " << from;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void DebuggerManager::setState(DebuggerState state)
|
||||
{
|
||||
//STATE_DEBUG("STATUS CHANGE: FROM " << stateName(m_state)
|
||||
// << " TO " << stateName(state));
|
||||
|
||||
QString msg = _("State changed from %1(%2) to %3(%4).")
|
||||
.arg(stateName(m_state)).arg(m_state).arg(stateName(state)).arg(state);
|
||||
qDebug() << msg;
|
||||
if (!isAllowedTransition(m_state, state))
|
||||
qDebug() << "UNEXPECTED STATE TRANSITION: " << msg;
|
||||
|
||||
showDebuggerOutput(LogDebug, msg);
|
||||
|
||||
resetLocation();
|
||||
if (state == m_state)
|
||||
return;
|
||||
|
||||
m_state = state;
|
||||
|
||||
if (m_state == InferiorStopped)
|
||||
resetLocation();
|
||||
|
||||
const bool started = state == InferiorRunning
|
||||
|| state == InferiorRunningRequested
|
||||
|| state == InferiorStopping
|
||||
|| state == InferiorStopped;
|
||||
|
||||
const bool running = state == InferiorRunning;
|
||||
|
||||
const bool ready = state == InferiorStopped
|
||||
&& m_startParameters->startMode != AttachCore;
|
||||
|
||||
if (ready)
|
||||
QApplication::alert(mainWindow(), 3000);
|
||||
|
||||
m_watchAction->setEnabled(ready);
|
||||
m_breakAction->setEnabled(true);
|
||||
|
||||
bool interruptIsExit = !running;
|
||||
if (interruptIsExit) {
|
||||
m_stopAction->setIcon(QIcon(":/debugger/images/debugger_stop_small.png"));
|
||||
m_stopAction->setText(tr("Stop Debugger"));
|
||||
} else {
|
||||
m_stopAction->setIcon(QIcon(":/debugger/images/debugger_interrupt_small.png"));
|
||||
m_stopAction->setText(tr("Interrupt"));
|
||||
}
|
||||
|
||||
m_stopAction->setEnabled(started);
|
||||
m_resetAction->setEnabled(true);
|
||||
|
||||
m_stepAction->setEnabled(ready);
|
||||
m_stepOutAction->setEnabled(ready);
|
||||
m_runToLineAction->setEnabled(ready);
|
||||
m_runToFunctionAction->setEnabled(ready);
|
||||
m_jumpToLineAction->setEnabled(ready);
|
||||
m_nextAction->setEnabled(ready);
|
||||
//showStatusMessage(QString("started: %1, running: %2")
|
||||
// .arg(started).arg(running));
|
||||
emit stateChanged(m_state);
|
||||
const bool notbusy = ready || state == DebuggerNotReady;
|
||||
setBusyCursor(!notbusy);
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug d, DebuggerState state)
|
||||
{
|
||||
return d << stateName(state) << '(' << int(state) << ')';
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// AbstractDebuggerEngine
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
void IDebuggerEngine::showStatusMessage(const QString &msg, int timeout)
|
||||
{
|
||||
m_manager->showStatusMessage(msg, timeout);
|
||||
}
|
||||
|
||||
DebuggerState IDebuggerEngine::state() const
|
||||
{
|
||||
return m_manager->state();
|
||||
}
|
||||
|
||||
void IDebuggerEngine::setState(DebuggerState state)
|
||||
{
|
||||
m_manager->setState(state);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Testing
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
#ifndef DEBUGGER_DEBUGGERMANAGER_H
|
||||
#define DEBUGGER_DEBUGGERMANAGER_H
|
||||
|
||||
#include "debuggerconstants.h"
|
||||
|
||||
#include <utils/fancymainwindow.h>
|
||||
|
||||
#include <QtCore/QByteArray>
|
||||
@@ -84,64 +86,6 @@ class ThreadsHandler;
|
||||
class WatchData;
|
||||
class WatchHandler;
|
||||
|
||||
// Note: the Debugger process itself is referred to as 'Debugger',
|
||||
// whereas the debugged process is referred to as 'Inferior' or 'Debuggee'.
|
||||
|
||||
// DebuggerProcessNotReady
|
||||
// |
|
||||
// DebuggerProcessStartingUp
|
||||
// | <-------------------------------------.
|
||||
// DebuggerInferiorRunningRequested |
|
||||
// | |
|
||||
// DebuggerInferiorRunning |
|
||||
// | |
|
||||
// DebuggerInferiorStopRequested |
|
||||
// | |
|
||||
// DebuggerInferiorStopped |
|
||||
// | |
|
||||
// `---------------------------------------'
|
||||
//
|
||||
// Allowed actions:
|
||||
// [R] : Run
|
||||
// [C] : Continue
|
||||
// [N] : Step, Next
|
||||
|
||||
|
||||
enum DebuggerStatus
|
||||
{
|
||||
DebuggerProcessNotReady, // Debugger not started
|
||||
DebuggerProcessStartingUp, // Debugger starting up
|
||||
|
||||
DebuggerInferiorRunningRequested, // Debuggee requested to run
|
||||
DebuggerInferiorRunning, // Debuggee running
|
||||
DebuggerInferiorStopRequested, // Debuggee running, stop requested
|
||||
DebuggerInferiorStopped, // Debuggee stopped
|
||||
};
|
||||
|
||||
enum DebuggerStartMode
|
||||
{
|
||||
NoStartMode,
|
||||
StartInternal, // Start current start project's binary
|
||||
StartExternal, // Start binary found in file system
|
||||
AttachExternal, // Attach to running process by process id
|
||||
AttachCrashedExternal, // Attach to crashed process by process id
|
||||
AttachTcf, // Attach to a running Target Communication Framework agent
|
||||
AttachCore, // Attach to a core file
|
||||
StartRemote // Start and attach to a remote process
|
||||
};
|
||||
|
||||
enum LogChannel
|
||||
{
|
||||
LogInput, // Used for user input
|
||||
LogOutput,
|
||||
LogWarning,
|
||||
LogError,
|
||||
LogStatus, // Used for status changed messages
|
||||
LogTime, // Used for time stamp messages
|
||||
LogDebug,
|
||||
LogMisc
|
||||
};
|
||||
|
||||
class DebuggerStartParameters
|
||||
{
|
||||
public:
|
||||
@@ -190,26 +134,19 @@ enum DebuggerEngineTypeFlags
|
||||
| TcfEngineType
|
||||
};
|
||||
|
||||
// The construct below is not nice but enforces a bit of order. The
|
||||
// DebuggerManager interfaces a lots of thing: The DebuggerPlugin,
|
||||
// the DebuggerEngines, the RunMode, the handlers and views.
|
||||
// Instead of making the whole interface public, we split in into
|
||||
// smaller parts and grant friend access only to the classes that
|
||||
// need it.
|
||||
|
||||
QDebug operator<<(QDebug d, DebuggerState state);
|
||||
|
||||
//
|
||||
// IDebuggerManagerAccessForEngines
|
||||
// DebuggerManager
|
||||
//
|
||||
|
||||
class IDebuggerManagerAccessForEngines
|
||||
class DebuggerManager : public QObject
|
||||
{
|
||||
public:
|
||||
virtual ~IDebuggerManagerAccessForEngines() {}
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
// This is the part of the interface that's exclusively seen by the
|
||||
// debugger engines
|
||||
public:
|
||||
DebuggerManager();
|
||||
~DebuggerManager();
|
||||
|
||||
friend class CdbDebugEngine;
|
||||
friend class CdbDebugEventCallback;
|
||||
@@ -220,58 +157,8 @@ private:
|
||||
friend class TcfEngine;
|
||||
friend struct CdbDebugEnginePrivate;
|
||||
|
||||
// called from the engines after successful startup
|
||||
virtual void notifyInferiorStopRequested() = 0;
|
||||
virtual void notifyInferiorStopped() = 0;
|
||||
virtual void notifyInferiorRunningRequested() = 0;
|
||||
virtual void notifyInferiorRunning() = 0;
|
||||
virtual void notifyInferiorExited() = 0;
|
||||
virtual void notifyInferiorPidChanged(qint64) = 0;
|
||||
virtual void notifyEngineFinished() {} // FIXME: make pure
|
||||
|
||||
virtual ModulesHandler *modulesHandler() = 0;
|
||||
virtual BreakHandler *breakHandler() = 0;
|
||||
virtual RegisterHandler *registerHandler() = 0;
|
||||
virtual StackHandler *stackHandler() = 0;
|
||||
virtual ThreadsHandler *threadsHandler() = 0;
|
||||
virtual WatchHandler *watchHandler() = 0;
|
||||
virtual SourceFilesWindow *sourceFileWindow() = 0;
|
||||
|
||||
virtual void showApplicationOutput(const QString &data) = 0;
|
||||
virtual void showDebuggerOutput(int channel, const QString &msg) = 0;
|
||||
virtual void showDebuggerInput(int channel, const QString &msg) = 0;
|
||||
|
||||
virtual void reloadModules() = 0;
|
||||
virtual void reloadSourceFiles() = 0;
|
||||
virtual void reloadRegisters() = 0;
|
||||
|
||||
virtual bool qtDumperLibraryEnabled() const = 0;
|
||||
virtual QString qtDumperLibraryName() const = 0;
|
||||
virtual QStringList qtDumperLibraryLocations() const = 0;
|
||||
virtual void showQtDumperLibraryWarning(const QString &details = QString()) = 0;
|
||||
virtual bool isReverseDebugging() const = 0;
|
||||
|
||||
virtual qint64 inferiorPid() const = 0;
|
||||
|
||||
virtual DebuggerStartParametersPtr startParameters() const = 0;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// DebuggerManager
|
||||
//
|
||||
|
||||
class DebuggerManager : public QObject, public IDebuggerManagerAccessForEngines
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DebuggerManager();
|
||||
QList<Core::IOptionsPage*> initializeEngines(unsigned enabledTypeFlags);
|
||||
|
||||
~DebuggerManager();
|
||||
|
||||
IDebuggerManagerAccessForEngines *engineInterface();
|
||||
Core::Utils::FancyMainWindow *mainWindow() const { return m_mainWindow; }
|
||||
QLabel *statusLabel() const { return m_statusLabel; }
|
||||
IDebuggerEngine *currentEngine() const { return m_engine; }
|
||||
@@ -349,7 +236,6 @@ private slots:
|
||||
|
||||
void reloadRegisters();
|
||||
void registerDockToggled(bool on);
|
||||
void setStatus(int status);
|
||||
void clearStatusMessage();
|
||||
void attemptBreakpointSynchronization();
|
||||
void reloadFullStack();
|
||||
@@ -357,9 +243,6 @@ private slots:
|
||||
void startFailed();
|
||||
|
||||
private:
|
||||
//
|
||||
// Implementation of IDebuggerManagerAccessForEngines
|
||||
//
|
||||
ModulesHandler *modulesHandler() { return m_modulesHandler; }
|
||||
BreakHandler *breakHandler() { return m_breakHandler; }
|
||||
RegisterHandler *registerHandler() { return m_registerHandler; }
|
||||
@@ -370,8 +253,6 @@ private:
|
||||
QWidget *threadsWindow() const { return m_threadsWindow; }
|
||||
|
||||
void notifyInferiorStopped();
|
||||
void notifyInferiorRunningRequested();
|
||||
void notifyInferiorStopRequested();
|
||||
void notifyInferiorRunning();
|
||||
void notifyInferiorExited();
|
||||
void notifyInferiorPidChanged(qint64);
|
||||
@@ -379,6 +260,10 @@ private:
|
||||
|
||||
void cleanupViews();
|
||||
|
||||
DebuggerState state() const;
|
||||
void setState(DebuggerState state);
|
||||
DebuggerState m_state;
|
||||
|
||||
//
|
||||
// internal implementation
|
||||
//
|
||||
@@ -402,7 +287,7 @@ public:
|
||||
signals:
|
||||
void debuggingFinished();
|
||||
void inferiorPidChanged(qint64 pid);
|
||||
void statusChanged(int newstatus);
|
||||
void stateChanged(int newstatus);
|
||||
void debugModeRequested();
|
||||
void previousModeRequested();
|
||||
void statusMessageRequested(const QString &msg, int timeout); // -1 for 'forever'
|
||||
@@ -425,7 +310,8 @@ private:
|
||||
void toggleBreakpoint(const QString &fileName, int lineNumber);
|
||||
void toggleBreakpointEnabled(const QString &fileName, int lineNumber);
|
||||
BreakpointData *findBreakpoint(const QString &fileName, int lineNumber);
|
||||
void setToolTipExpression(const QPoint &mousePos, TextEditor::ITextEditor *editor, int cursorPos);
|
||||
void setToolTipExpression(const QPoint &mousePos,
|
||||
TextEditor::ITextEditor *editor, int cursorPos);
|
||||
|
||||
// FIXME: Remove engine-specific state
|
||||
DebuggerStartParametersPtr m_startParameters;
|
||||
@@ -454,6 +340,7 @@ private:
|
||||
|
||||
/// Actions
|
||||
friend class DebuggerPlugin;
|
||||
friend class IDebuggerEngine;
|
||||
QAction *m_continueAction;
|
||||
QAction *m_stopAction;
|
||||
QAction *m_resetAction; // FIXME: Should not be needed in a stable release
|
||||
|
||||
@@ -887,8 +887,8 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
|
||||
this, SLOT(resetLocation()));
|
||||
connect(m_manager, SIGNAL(gotoLocationRequested(StackFrame,bool)),
|
||||
this, SLOT(gotoLocation(StackFrame,bool)));
|
||||
connect(m_manager, SIGNAL(statusChanged(int)),
|
||||
this, SLOT(changeStatus(int)));
|
||||
connect(m_manager, SIGNAL(stateChanged(int)),
|
||||
this, SLOT(handleStateChanged(int)));
|
||||
connect(m_manager, SIGNAL(previousModeRequested()),
|
||||
this, SLOT(activatePreviousMode()));
|
||||
connect(m_manager, SIGNAL(debugModeRequested()),
|
||||
@@ -1040,7 +1040,7 @@ void DebuggerPlugin::showToolTip(TextEditor::ITextEditor *editor,
|
||||
const QPoint &point, int pos)
|
||||
{
|
||||
if (!theDebuggerBoolSetting(UseToolTipsInMainEditor)
|
||||
|| m_manager->status() == DebuggerProcessNotReady)
|
||||
|| m_manager->state() == DebuggerNotReady)
|
||||
return;
|
||||
|
||||
m_manager->setToolTipExpression(point, editor, pos);
|
||||
@@ -1111,9 +1111,9 @@ void DebuggerPlugin::gotoLocation(const StackFrame &frame, bool setMarker)
|
||||
}
|
||||
}
|
||||
|
||||
void DebuggerPlugin::changeStatus(int status)
|
||||
void DebuggerPlugin::handleStateChanged(int state)
|
||||
{
|
||||
const bool startIsContinue = (status == DebuggerInferiorStopped);
|
||||
const bool startIsContinue = (state == InferiorStopped);
|
||||
ICore *core = ICore::instance();
|
||||
if (startIsContinue) {
|
||||
core->addAdditionalContext(m_gdbRunningContext);
|
||||
@@ -1123,15 +1123,15 @@ void DebuggerPlugin::changeStatus(int status)
|
||||
core->updateContext();
|
||||
}
|
||||
|
||||
const bool started = status == DebuggerInferiorRunning
|
||||
|| status == DebuggerInferiorRunningRequested
|
||||
|| status == DebuggerInferiorStopRequested
|
||||
|| status == DebuggerInferiorStopped;
|
||||
const bool started = state == InferiorRunning
|
||||
|| state == InferiorRunningRequested
|
||||
|| state == InferiorStopping
|
||||
|| state == InferiorStopped;
|
||||
|
||||
const bool starting = status == DebuggerProcessStartingUp;
|
||||
//const bool running = status == DebuggerInferiorRunning;
|
||||
const bool starting = state == EngineStarting;
|
||||
//const bool running = state == InferiorRunning;
|
||||
|
||||
const bool ready = status == DebuggerInferiorStopped
|
||||
const bool ready = state == InferiorStopped
|
||||
&& m_manager->startParameters()->startMode != AttachCore;
|
||||
|
||||
m_startExternalAction->setEnabled(!started && !starting);
|
||||
|
||||
@@ -85,7 +85,7 @@ private slots:
|
||||
void queryCurrentTextEditor(QString *fileName, int *line, QObject **object);
|
||||
void editorOpened(Core::IEditor *);
|
||||
void editorAboutToClose(Core::IEditor *);
|
||||
void changeStatus(int status);
|
||||
void handleStateChanged(int state);
|
||||
void requestMark(TextEditor::ITextEditor *editor, int lineNumber);
|
||||
void showToolTip(TextEditor::ITextEditor *editor, const QPoint &pnt, int pos);
|
||||
void querySessionValue(const QString &name, QVariant *value);
|
||||
|
||||
@@ -88,9 +88,10 @@ signals:
|
||||
void readyReadStandardError();
|
||||
|
||||
protected:
|
||||
GdbAdapterState state() const
|
||||
DebuggerState state() const
|
||||
{ return m_engine->state(); }
|
||||
void setState(GdbAdapterState state);
|
||||
void setState(DebuggerState state)
|
||||
{ m_engine->setState(state); }
|
||||
const DebuggerStartParameters &startParameters() const
|
||||
{ return m_engine->startParameters(); }
|
||||
void debugMessage(const QString &msg) const
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Internal {
|
||||
AttachGdbAdapter::AttachGdbAdapter(GdbEngine *engine, QObject *parent)
|
||||
: AbstractGdbAdapter(engine, parent)
|
||||
{
|
||||
QTC_ASSERT(state() == AdapterNotRunning, qDebug() << state());
|
||||
QTC_ASSERT(state() == DebuggerNotReady, qDebug() << state());
|
||||
connect(&m_gdbProc, SIGNAL(error(QProcess::ProcessError)),
|
||||
this, SIGNAL(error(QProcess::ProcessError)));
|
||||
connect(&m_gdbProc, SIGNAL(readyReadStandardOutput()),
|
||||
@@ -69,7 +69,7 @@ AttachGdbAdapter::AttachGdbAdapter(GdbEngine *engine, QObject *parent)
|
||||
|
||||
void AttachGdbAdapter::startAdapter()
|
||||
{
|
||||
QTC_ASSERT(state() == AdapterNotRunning, qDebug() << state());
|
||||
QTC_ASSERT(state() == EngineStarting, qDebug() << state());
|
||||
setState(AdapterStarting);
|
||||
debugMessage(_("TRYING TO START ADAPTER"));
|
||||
|
||||
@@ -125,16 +125,22 @@ void AttachGdbAdapter::handleAttach(const GdbResponse &response)
|
||||
|
||||
void AttachGdbAdapter::startInferior()
|
||||
{
|
||||
QTC_ASSERT(state() == InferiorPrepared, qDebug() << state());
|
||||
setState(InferiorStarting);
|
||||
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
|
||||
#if 0
|
||||
// continue on attach
|
||||
setState(InferiorRunningRequested);
|
||||
m_engine->postCommand(_("-exec-continue"), CB(handleContinue));
|
||||
#else
|
||||
setState(InferiorStopped);
|
||||
emit inferiorStarted();
|
||||
#endif
|
||||
}
|
||||
|
||||
void AttachGdbAdapter::handleContinue(const GdbResponse &response)
|
||||
{
|
||||
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
|
||||
if (response.resultClass == GdbResultRunning) {
|
||||
setState(InferiorStarted);
|
||||
setState(InferiorRunning);
|
||||
emit inferiorStarted();
|
||||
} else {
|
||||
QTC_ASSERT(response.resultClass == GdbResultError, /**/);
|
||||
@@ -154,18 +160,21 @@ void AttachGdbAdapter::interruptInferior()
|
||||
|
||||
void AttachGdbAdapter::shutdown()
|
||||
{
|
||||
if (state() == InferiorStarted) {
|
||||
switch (state()) {
|
||||
|
||||
case InferiorStopped:
|
||||
setState(InferiorShuttingDown);
|
||||
m_engine->postCommand(_("detach"), CB(handleDetach));
|
||||
return;
|
||||
}
|
||||
|
||||
if (state() == InferiorShutDown) {
|
||||
case InferiorShutDown:
|
||||
setState(AdapterShuttingDown);
|
||||
m_engine->postCommand(_("-gdb-exit"), CB(handleExit));
|
||||
return;
|
||||
|
||||
default:
|
||||
QTC_ASSERT(false, qDebug() << state());
|
||||
}
|
||||
QTC_ASSERT(state() == AdapterNotRunning, qDebug() << state());
|
||||
}
|
||||
|
||||
void AttachGdbAdapter::handleDetach(const GdbResponse &response)
|
||||
@@ -196,7 +205,7 @@ void AttachGdbAdapter::handleExit(const GdbResponse &response)
|
||||
void AttachGdbAdapter::handleGdbFinished(int, QProcess::ExitStatus)
|
||||
{
|
||||
debugMessage(_("GDB PROESS FINISHED"));
|
||||
setState(AdapterNotRunning);
|
||||
setState(DebuggerNotReady);
|
||||
emit adapterShutDown();
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Internal {
|
||||
CoreGdbAdapter::CoreGdbAdapter(GdbEngine *engine, QObject *parent)
|
||||
: AbstractGdbAdapter(engine, parent)
|
||||
{
|
||||
QTC_ASSERT(state() == AdapterNotRunning, qDebug() << state());
|
||||
QTC_ASSERT(state() == DebuggerNotReady, qDebug() << state());
|
||||
connect(&m_gdbProc, SIGNAL(error(QProcess::ProcessError)),
|
||||
this, SIGNAL(error(QProcess::ProcessError)));
|
||||
connect(&m_gdbProc, SIGNAL(readyReadStandardOutput()),
|
||||
@@ -69,7 +69,7 @@ CoreGdbAdapter::CoreGdbAdapter(GdbEngine *engine, QObject *parent)
|
||||
|
||||
void CoreGdbAdapter::startAdapter()
|
||||
{
|
||||
QTC_ASSERT(state() == AdapterNotRunning, qDebug() << state());
|
||||
QTC_ASSERT(state() == EngineStarting, qDebug() << state());
|
||||
setState(AdapterStarting);
|
||||
debugMessage(_("TRYING TO START ADAPTER"));
|
||||
|
||||
@@ -129,8 +129,7 @@ void CoreGdbAdapter::handleFileExecAndSymbols(const GdbResponse &response)
|
||||
|
||||
void CoreGdbAdapter::startInferior()
|
||||
{
|
||||
QTC_ASSERT(state() == InferiorPrepared, qDebug() << state());
|
||||
setState(InferiorStarting);
|
||||
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
|
||||
QFileInfo fi(startParameters().executable);
|
||||
QString fileName = _c('"') + fi.absoluteFilePath() + _c('"');
|
||||
QFileInfo fi2(startParameters().coreFile);
|
||||
@@ -143,7 +142,7 @@ void CoreGdbAdapter::handleTargetCore(const GdbResponse &response)
|
||||
{
|
||||
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
|
||||
if (response.resultClass == GdbResultDone) {
|
||||
setState(InferiorStarted);
|
||||
setState(InferiorStopped);
|
||||
emit inferiorStarted();
|
||||
m_engine->updateAll();
|
||||
} else {
|
||||
@@ -162,12 +161,12 @@ void CoreGdbAdapter::interruptInferior()
|
||||
|
||||
void CoreGdbAdapter::shutdown()
|
||||
{
|
||||
if (state() == InferiorStarted || state() == InferiorShutDown) {
|
||||
if (state() == InferiorStopped || state() == InferiorShutDown) {
|
||||
setState(AdapterShuttingDown);
|
||||
m_engine->postCommand(_("-gdb-exit"), CB(handleExit));
|
||||
return;
|
||||
}
|
||||
QTC_ASSERT(state() == AdapterNotRunning, qDebug() << state());
|
||||
QTC_ASSERT(state() == DebuggerNotReady, qDebug() << state());
|
||||
}
|
||||
|
||||
void CoreGdbAdapter::handleExit(const GdbResponse &response)
|
||||
@@ -184,7 +183,7 @@ void CoreGdbAdapter::handleExit(const GdbResponse &response)
|
||||
void CoreGdbAdapter::handleGdbFinished(int, QProcess::ExitStatus)
|
||||
{
|
||||
debugMessage(_("GDB PROESS FINISHED"));
|
||||
setState(AdapterNotRunning);
|
||||
setState(DebuggerNotReady);
|
||||
emit adapterShutDown();
|
||||
}
|
||||
|
||||
|
||||
@@ -106,13 +106,16 @@ namespace Internal {
|
||||
#define STRINGIFY(x) STRINGIFY_INTERNAL(x)
|
||||
#define CB(callback) &GdbEngine::callback, STRINGIFY(callback)
|
||||
|
||||
static bool stateAcceptsGdbCommands(GdbAdapterState state)
|
||||
static bool stateAcceptsGdbCommands(DebuggerState state)
|
||||
{
|
||||
return state == AdapterStarted
|
||||
|| state == InferiorPreparing
|
||||
|| state == InferiorPrepared
|
||||
|| state == InferiorStarting
|
||||
|| state == InferiorStarted
|
||||
|| state == InferiorRunningRequested
|
||||
|| state == InferiorRunning
|
||||
|| state == InferiorStopping
|
||||
|| state == InferiorStopped
|
||||
|| state == InferiorShuttingDown
|
||||
|| state == InferiorShutDown
|
||||
|| state == AdapterShuttingDown;
|
||||
@@ -166,17 +169,15 @@ static QByteArray parsePlainConsoleStream(const GdbResponse &response)
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
GdbEngine::GdbEngine(DebuggerManager *parent) :
|
||||
GdbEngine::GdbEngine(DebuggerManager *manager) :
|
||||
IDebuggerEngine(manager),
|
||||
#ifdef Q_OS_WIN // Do injection loading with MinGW (call loading does not work with 64bit)
|
||||
m_dumperInjectionLoad(true),
|
||||
m_dumperInjectionLoad(true)
|
||||
#else
|
||||
m_dumperInjectionLoad(false),
|
||||
m_dumperInjectionLoad(false)
|
||||
#endif
|
||||
m_manager(parent),
|
||||
qq(parent->engineInterface())
|
||||
{
|
||||
m_gdbAdapter = 0;
|
||||
m_state = AdapterNotRunning;
|
||||
QSharedPointer<TrkOptions> options(new TrkOptions);
|
||||
options->fromSettings(Core::ICore::instance()->settings());
|
||||
m_plainAdapter = new PlainGdbAdapter(this);
|
||||
@@ -551,7 +552,7 @@ void GdbEngine::handleResponse(const QByteArray &buff)
|
||||
// On Windows, the contents seem to depend on the debugger
|
||||
// version and/or OS version used.
|
||||
if (data.startsWith("warning:"))
|
||||
qq->showApplicationOutput(_(data.mid(9))); // cut "warning: "
|
||||
manager()->showApplicationOutput(_(data.mid(9))); // cut "warning: "
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -657,15 +658,17 @@ void GdbEngine::readGdbStandardOutput()
|
||||
|
||||
void GdbEngine::interruptInferior()
|
||||
{
|
||||
// debugMessage(_("GDBENGINE INTERRUPT INFERIOR: %1").arg(m_gdbAdapter->state()));
|
||||
qq->notifyInferiorStopRequested();
|
||||
QTC_ASSERT(state() == InferiorRunning, qDebug() << state());
|
||||
|
||||
if (state() == AdapterNotRunning) {
|
||||
if (state() == DebuggerNotReady) {
|
||||
debugMessage(_("TRYING TO INTERRUPT INFERIOR WITHOUT RUNNING GDB"));
|
||||
shutdown();
|
||||
return;
|
||||
}
|
||||
|
||||
setState(InferiorStopping);
|
||||
showStatusMessage(tr("Stop requested..."), 5000);
|
||||
|
||||
debugMessage(_("TRYING TO INTERUPT INFERIOR"));
|
||||
m_gdbAdapter->interruptInferior();
|
||||
}
|
||||
@@ -681,7 +684,7 @@ void GdbEngine::maybeHandleInferiorPidChanged(const QString &pid0)
|
||||
return;
|
||||
debugMessage(_("FOUND PID %1").arg(pid));
|
||||
|
||||
qq->notifyInferiorPidChanged(pid);
|
||||
manager()->notifyInferiorPidChanged(pid);
|
||||
if (m_dumperInjectionLoad)
|
||||
tryLoadDebuggingHelpers();
|
||||
}
|
||||
@@ -727,6 +730,8 @@ void GdbEngine::postCommand(const QString &command, GdbCommandFlags flags,
|
||||
void GdbEngine::postCommandHelper(const GdbCommand &cmd)
|
||||
{
|
||||
if (!stateAcceptsGdbCommands(state())) {
|
||||
qDebug() << _("NO GDB PROCESS RUNNING, CMD IGNORED: ") << cmd.command
|
||||
<< state();
|
||||
PENDING_DEBUG(_("NO GDB PROCESS RUNNING, CMD IGNORED: ") + cmd.command);
|
||||
debugMessage(_("NO GDB PROCESS RUNNING, CMD IGNORED: ") + cmd.command);
|
||||
return;
|
||||
@@ -743,15 +748,20 @@ void GdbEngine::postCommandHelper(const GdbCommand &cmd)
|
||||
<< m_gdbAdapter->state());
|
||||
}
|
||||
|
||||
if ((cmd.flags & NeedsStop) && status() != DebuggerInferiorStopped
|
||||
&& status() != DebuggerProcessStartingUp) {
|
||||
// queue the commands that we cannot send at once
|
||||
QTC_ASSERT(status() == DebuggerInferiorRunning,
|
||||
qDebug() << "STATUS:" << status());
|
||||
showStatusMessage(tr("Stopping temporarily."));
|
||||
debugMessage(_("QUEUING COMMAND ") + cmd.command);
|
||||
m_commandsToRunOnTemporaryBreak.append(cmd);
|
||||
interruptInferior();
|
||||
if (cmd.flags & NeedsStop) {
|
||||
if (state() == InferiorStopped
|
||||
|| state() == EngineStarting
|
||||
|| state() == InferiorPrepared) {
|
||||
// Can be safely sent now.
|
||||
flushCommand(cmd);
|
||||
} else {
|
||||
// Queue the commands that we cannot send at once.
|
||||
showStatusMessage(tr("Stopping temporarily."), 1000);
|
||||
qDebug() << _("QUEUING COMMAND ") + cmd.command;
|
||||
debugMessage(_("QUEUING COMMAND ") + cmd.command);
|
||||
m_commandsToRunOnTemporaryBreak.append(cmd);
|
||||
interruptInferior();
|
||||
}
|
||||
} else if (!cmd.command.isEmpty()) {
|
||||
flushCommand(cmd);
|
||||
}
|
||||
@@ -760,7 +770,7 @@ void GdbEngine::postCommandHelper(const GdbCommand &cmd)
|
||||
void GdbEngine::flushCommand(const GdbCommand &cmd0)
|
||||
{
|
||||
GdbCommand cmd = cmd0;
|
||||
if (state() == AdapterNotRunning) {
|
||||
if (state() == DebuggerNotReady) {
|
||||
emit gdbInputAvailable(LogInput, cmd.command);
|
||||
debugMessage(_("GDB PROCESS NOT RUNNING, PLAIN CMD IGNORED: ") + cmd.command);
|
||||
return;
|
||||
@@ -863,7 +873,7 @@ void GdbEngine::handleResultRecord(const GdbResponse &response)
|
||||
|
||||
void GdbEngine::executeDebuggerCommand(const QString &command)
|
||||
{
|
||||
if (state() == AdapterNotRunning) {
|
||||
if (state() == DebuggerNotReady) {
|
||||
debugMessage(_("GDB PROCESS NOT RUNNING, PLAIN CMD IGNORED: ") + command);
|
||||
return;
|
||||
}
|
||||
@@ -874,16 +884,15 @@ void GdbEngine::executeDebuggerCommand(const QString &command)
|
||||
// called from CoreAdapter and AttachAdapter
|
||||
void GdbEngine::updateAll()
|
||||
{
|
||||
qq->notifyInferiorStopped();
|
||||
showStatusMessage(tr("Core file loaded."));
|
||||
m_manager->resetLocation();
|
||||
QTC_ASSERT(state() == InferiorStopped, /**/);
|
||||
manager()->resetLocation();
|
||||
tryLoadDebuggingHelpers();
|
||||
qq->stackHandler()->setCurrentIndex(0);
|
||||
manager()->stackHandler()->setCurrentIndex(0);
|
||||
updateLocals();
|
||||
reloadStack();
|
||||
if (supportsThreads())
|
||||
postCommand(_("-thread-list-ids"), WatchUpdate, CB(handleStackListThreads), 0);
|
||||
qq->reloadRegisters();
|
||||
manager()->reloadRegisters();
|
||||
}
|
||||
|
||||
void GdbEngine::handleQuerySources(const GdbResponse &response)
|
||||
@@ -908,7 +917,7 @@ void GdbEngine::handleQuerySources(const GdbResponse &response)
|
||||
}
|
||||
}
|
||||
if (m_shortToFullName != oldShortToFull)
|
||||
qq->sourceFileWindow()->setSourceFiles(m_shortToFullName);
|
||||
manager()->sourceFileWindow()->setSourceFiles(m_shortToFullName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -973,7 +982,7 @@ void GdbEngine::handleExecJumpToLine(const GdbResponse &response)
|
||||
// ~"run1 (argc=1, argv=0x7fffb213a478) at test1.cpp:242"
|
||||
// ~"242\t x *= 2;"
|
||||
//109^done"
|
||||
qq->notifyInferiorStopped();
|
||||
setState(InferiorStopped);
|
||||
showStatusMessage(tr("Jumped. Stopped."));
|
||||
QByteArray output = response.data.findChild("logstreamoutput").data();
|
||||
if (output.isEmpty())
|
||||
@@ -998,8 +1007,8 @@ void GdbEngine::handleExecRunToFunction(const GdbResponse &response)
|
||||
// 14*stopped,thread-id="1",frame={addr="0x0000000000403ce4",
|
||||
// func="foo",args=[{name="str",value="@0x7fff0f450460"}],
|
||||
// file="main.cpp",fullname="/tmp/g/main.cpp",line="37"}
|
||||
qq->notifyInferiorStopped();
|
||||
showStatusMessage(tr("Run to Function finished. Stopped."));
|
||||
setState(InferiorStopped);
|
||||
showStatusMessage(tr("Function reached. Stopped."));
|
||||
GdbMi frame = response.data.findChild("frame");
|
||||
StackFrame f;
|
||||
f.file = QString::fromLocal8Bit(frame.findChild("fullname").data());
|
||||
@@ -1079,11 +1088,7 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data)
|
||||
const QByteArray reason = data.findChild("reason").data();
|
||||
|
||||
if (isExitedReason(reason)) {
|
||||
// Give adapter a chance to take notice of regular exits.
|
||||
QTC_ASSERT(state() == InferiorStarted, /**/);
|
||||
setState(InferiorShuttingDown);
|
||||
setState(InferiorShutDown);
|
||||
|
||||
QTC_ASSERT(state() == InferiorRunning, /**/);
|
||||
QString msg;
|
||||
if (reason == "exited") {
|
||||
msg = tr("Program exited with exit code %1.")
|
||||
@@ -1095,14 +1100,16 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data)
|
||||
msg = tr("Program exited normally.");
|
||||
}
|
||||
showStatusMessage(msg);
|
||||
setState(InferiorShuttingDown);
|
||||
setState(InferiorShutDown);
|
||||
shutdown();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_commandsToRunOnTemporaryBreak.isEmpty()) {
|
||||
QTC_ASSERT(status() == DebuggerInferiorStopRequested,
|
||||
qDebug() << "STATUS:" << status())
|
||||
qq->notifyInferiorStopped();
|
||||
QTC_ASSERT(state() == InferiorStopping, qDebug() << state())
|
||||
setState(InferiorStopped);
|
||||
showStatusMessage(tr("Stopped."), 5000);
|
||||
// FIXME: racy
|
||||
while (!m_commandsToRunOnTemporaryBreak.isEmpty()) {
|
||||
GdbCommand cmd = m_commandsToRunOnTemporaryBreak.takeFirst();
|
||||
@@ -1110,8 +1117,9 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data)
|
||||
.arg(cmd.command).arg(_(cmd.callbackName)));
|
||||
flushCommand(cmd);
|
||||
}
|
||||
showStatusMessage(tr("Processing queued commands."));
|
||||
// FIXME: m_continuationAfterDone = true;
|
||||
showStatusMessage(tr("Processing queued commands."), 1000);
|
||||
QTC_ASSERT(m_continuationAfterDone == 0, /**/);
|
||||
m_continuationAfterDone = &GdbEngine::continueInferior;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1199,8 +1207,7 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data)
|
||||
// MAC yields sometimes:
|
||||
// >3661*stopped,time={wallclock="0.00658",user="0.00142",
|
||||
// system="0.00136",start="1218810678.805432",end="1218810678.812011"}
|
||||
m_manager->resetLocation();
|
||||
qq->notifyInferiorStopped();
|
||||
setState(InferiorStopped);
|
||||
showStatusMessage(tr("Run to Function finished. Stopped."));
|
||||
GdbMi frame = data.findChild("frame");
|
||||
StackFrame f;
|
||||
@@ -1303,7 +1310,8 @@ void GdbEngine::handleStop2(const GdbResponse &response)
|
||||
|
||||
void GdbEngine::handleStop2(const GdbMi &data)
|
||||
{
|
||||
qq->notifyInferiorStopped();
|
||||
setState(InferiorStopped);
|
||||
showStatusMessage(tr("Stopped."), 5000);
|
||||
|
||||
// Sometimes we get some interesting extra information. Grab it.
|
||||
GdbMi frame = data.findChild("frame");
|
||||
@@ -1330,7 +1338,7 @@ void GdbEngine::handleStop2(const GdbMi &data)
|
||||
//
|
||||
// Stack
|
||||
//
|
||||
qq->stackHandler()->setCurrentIndex(0);
|
||||
manager()->stackHandler()->setCurrentIndex(0);
|
||||
updateLocals(); // Quick shot
|
||||
|
||||
reloadStack();
|
||||
@@ -1344,7 +1352,7 @@ void GdbEngine::handleStop2(const GdbMi &data)
|
||||
//
|
||||
// Registers
|
||||
//
|
||||
qq->reloadRegisters();
|
||||
manager()->reloadRegisters();
|
||||
}
|
||||
|
||||
void GdbEngine::handleShowVersion(const GdbResponse &response)
|
||||
@@ -1394,7 +1402,7 @@ void GdbEngine::handleFileExecAndSymbols(const GdbResponse &response)
|
||||
} else if (response.resultClass == GdbResultError) {
|
||||
QString msg = __(response.data.findChild("msg").data());
|
||||
showMessageBox(QMessageBox::Critical, tr("Starting executable failed"), msg);
|
||||
QTC_ASSERT(status() == DebuggerInferiorRunning, /**/);
|
||||
QTC_ASSERT(state() == InferiorRunning, /**/);
|
||||
//interruptInferior();
|
||||
shutdown();
|
||||
}
|
||||
@@ -1402,20 +1410,23 @@ void GdbEngine::handleFileExecAndSymbols(const GdbResponse &response)
|
||||
|
||||
void GdbEngine::handleExecContinue(const GdbResponse &response)
|
||||
{
|
||||
QTC_ASSERT(state() == InferiorRunningRequested, /**/);
|
||||
if (response.resultClass == GdbResultRunning) {
|
||||
qq->notifyInferiorRunning();
|
||||
setState(InferiorRunning);
|
||||
showStatusMessage(tr("Running..."), 5000);
|
||||
} else {
|
||||
QTC_ASSERT(response.resultClass == GdbResultError, /**/);
|
||||
const QByteArray &msg = response.data.findChild("msg").data();
|
||||
if (msg == "Cannot find bounds of current function") {
|
||||
qq->notifyInferiorStopped();
|
||||
setState(InferiorStopped);
|
||||
showStatusMessage(tr("Stopped."), 5000);
|
||||
//showStatusMessage(tr("No debug information available. "
|
||||
// "Leaving function..."));
|
||||
//stepOutExec();
|
||||
} else {
|
||||
showMessageBox(QMessageBox::Critical, tr("Error"),
|
||||
tr("Starting executable failed:\n") + QString::fromLocal8Bit(msg));
|
||||
QTC_ASSERT(status() == DebuggerInferiorRunning, /**/);
|
||||
QTC_ASSERT(state() == InferiorRunning, /**/);
|
||||
shutdown();
|
||||
}
|
||||
}
|
||||
@@ -1481,11 +1492,12 @@ void GdbEngine::exitDebugger() // called from the manager
|
||||
|
||||
int GdbEngine::currentFrame() const
|
||||
{
|
||||
return qq->stackHandler()->currentIndex();
|
||||
return manager()->stackHandler()->currentIndex();
|
||||
}
|
||||
|
||||
void GdbEngine::startDebugger(const DebuggerStartParametersPtr &sp)
|
||||
{
|
||||
QTC_ASSERT(state() == EngineStarting, qDebug() << state());
|
||||
// This should be set by the constructor or in exitDebugger()
|
||||
// via initializeVariables()
|
||||
//QTC_ASSERT(m_debuggingHelperState == DebuggingHelperUninitialized,
|
||||
@@ -1556,52 +1568,21 @@ void GdbEngine::startDebugger(const DebuggerStartParametersPtr &sp)
|
||||
|
||||
void GdbEngine::continueInferior()
|
||||
{
|
||||
QTC_ASSERT(state() == InferiorStopped, qDebug() << state());
|
||||
m_manager->resetLocation();
|
||||
setTokenBarrier();
|
||||
qq->notifyInferiorRunningRequested();
|
||||
setState(InferiorRunningRequested);
|
||||
showStatusMessage(tr("Running requested..."), 5000);
|
||||
postCommand(_("-exec-continue"), CB(handleExecContinue));
|
||||
}
|
||||
|
||||
#if 0
|
||||
void GdbEngine::handleSetTargetAsync(const GdbResponse &response)
|
||||
{
|
||||
if (response.resultClass == GdbResultDone) {
|
||||
qq->notifyInferiorRunningRequested();
|
||||
postCommand(_("target remote %1")
|
||||
.arg(m_manager->startParameters()->remoteChannel),
|
||||
CB(handleTargetRemote));
|
||||
} else if (response.resultClass == GdbResultError) {
|
||||
// a typical response on "old" gdb is:
|
||||
// &"set target-async on\n"
|
||||
//&"No symbol table is loaded. Use the \"file\" command.\n"
|
||||
//^error,msg="No symbol table is loaded. Use the \"file\" command."
|
||||
postCommand(_("detach"));
|
||||
postCommand(_("-gdb-exit"), CB(handleExit));
|
||||
}
|
||||
}
|
||||
|
||||
void GdbEngine::handleTargetRemote(const GdbResponse &response)
|
||||
{
|
||||
if (response.resultClass == GdbResultDone) {
|
||||
//postCommand(_("-exec-continue"), CB(handleExecContinue));
|
||||
handleAqcuiredInferior();
|
||||
// FIXME m_continuationAfterDone = true;
|
||||
} else if (response.resultClass == GdbResultError) {
|
||||
// 16^error,msg="hd:5555: Connection timed out."
|
||||
QString msg = __(response.data.findChild("msg").data());
|
||||
QString msg1 = tr("Connecting to remote server failed:");
|
||||
showStatusMessage(msg1 + _c(' ') + msg);
|
||||
showMessageBox(QMessageBox::Critical, tr("Error"), msg1 + _c('\n') + msg);
|
||||
postCommand(_("-gdb-exit"), CB(handleExit));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void GdbEngine::stepExec()
|
||||
{
|
||||
QTC_ASSERT(state() == InferiorStopped, qDebug() << state());
|
||||
setTokenBarrier();
|
||||
qq->notifyInferiorRunningRequested();
|
||||
if (qq->isReverseDebugging())
|
||||
setState(InferiorRunningRequested);
|
||||
showStatusMessage(tr("Step requested..."), 5000);
|
||||
if (manager()->isReverseDebugging())
|
||||
postCommand(_("-reverse-step"), CB(handleExecContinue));
|
||||
else
|
||||
postCommand(_("-exec-step"), CB(handleExecContinue));
|
||||
@@ -1609,9 +1590,11 @@ void GdbEngine::stepExec()
|
||||
|
||||
void GdbEngine::stepIExec()
|
||||
{
|
||||
QTC_ASSERT(state() == InferiorStopped, qDebug() << state());
|
||||
setTokenBarrier();
|
||||
qq->notifyInferiorRunningRequested();
|
||||
if (qq->isReverseDebugging())
|
||||
setState(InferiorRunningRequested);
|
||||
showStatusMessage(tr("Step by instruction requested..."), 5000);
|
||||
if (manager()->isReverseDebugging())
|
||||
postCommand(_("-reverse-stepi"), CB(handleExecContinue));
|
||||
else
|
||||
postCommand(_("-exec-step-instruction"), CB(handleExecContinue));
|
||||
@@ -1619,16 +1602,20 @@ void GdbEngine::stepIExec()
|
||||
|
||||
void GdbEngine::stepOutExec()
|
||||
{
|
||||
QTC_ASSERT(state() == InferiorStopped, qDebug() << state());
|
||||
setTokenBarrier();
|
||||
qq->notifyInferiorRunningRequested();
|
||||
setState(InferiorRunningRequested);
|
||||
showStatusMessage(tr("Finish function requested..."), 5000);
|
||||
postCommand(_("-exec-finish"), CB(handleExecContinue));
|
||||
}
|
||||
|
||||
void GdbEngine::nextExec()
|
||||
{
|
||||
QTC_ASSERT(state() == InferiorStopped, qDebug() << state());
|
||||
setTokenBarrier();
|
||||
qq->notifyInferiorRunningRequested();
|
||||
if (qq->isReverseDebugging())
|
||||
setState(InferiorRunningRequested);
|
||||
showStatusMessage(tr("Step next requested..."), 5000);
|
||||
if (manager()->isReverseDebugging())
|
||||
postCommand(_("-reverse-next"), CB(handleExecContinue));
|
||||
else {
|
||||
#if 1
|
||||
@@ -1643,9 +1630,11 @@ void GdbEngine::nextExec()
|
||||
|
||||
void GdbEngine::nextIExec()
|
||||
{
|
||||
QTC_ASSERT(state() == InferiorStopped, qDebug() << state());
|
||||
setTokenBarrier();
|
||||
qq->notifyInferiorRunningRequested();
|
||||
if (qq->isReverseDebugging())
|
||||
setState(InferiorRunningRequested);
|
||||
showStatusMessage(tr("Step next instruction requested..."), 5000);
|
||||
if (manager()->isReverseDebugging())
|
||||
postCommand(_("-reverse-nexti"), CB(handleExecContinue));
|
||||
else
|
||||
postCommand(_("-exec-next-instruction"), CB(handleExecContinue));
|
||||
@@ -1653,16 +1642,20 @@ void GdbEngine::nextIExec()
|
||||
|
||||
void GdbEngine::runToLineExec(const QString &fileName, int lineNumber)
|
||||
{
|
||||
QTC_ASSERT(state() == InferiorStopped, qDebug() << state());
|
||||
setTokenBarrier();
|
||||
qq->notifyInferiorRunningRequested();
|
||||
setState(InferiorRunningRequested);
|
||||
showStatusMessage(tr("Run to line %1 requested...").arg(lineNumber), 5000);
|
||||
postCommand(_("-exec-until %1:%2").arg(fileName).arg(lineNumber));
|
||||
}
|
||||
|
||||
void GdbEngine::runToFunctionExec(const QString &functionName)
|
||||
{
|
||||
QTC_ASSERT(state() == InferiorStopped, qDebug() << state());
|
||||
setTokenBarrier();
|
||||
postCommand(_("-break-insert -t ") + functionName);
|
||||
qq->notifyInferiorRunningRequested();
|
||||
setState(InferiorRunningRequested);
|
||||
showStatusMessage(tr("Run to function %1 requested...").arg(functionName), 5000);
|
||||
// that should be "^running". We need to handle the resulting
|
||||
// "Stopped"
|
||||
postCommand(_("-exec-continue"), CB(handleExecContinue));
|
||||
@@ -1671,6 +1664,7 @@ void GdbEngine::runToFunctionExec(const QString &functionName)
|
||||
|
||||
void GdbEngine::jumpToLineExec(const QString &fileName, int lineNumber)
|
||||
{
|
||||
QTC_ASSERT(state() == InferiorStopped, qDebug() << state());
|
||||
StackFrame frame;
|
||||
frame.file = fileName;
|
||||
frame.line = lineNumber;
|
||||
@@ -1810,7 +1804,7 @@ void GdbEngine::breakpointDataFromOutput(BreakpointData *data, const GdbMi &bkpt
|
||||
|
||||
void GdbEngine::sendInsertBreakpoint(int index)
|
||||
{
|
||||
const BreakpointData *data = qq->breakHandler()->at(index);
|
||||
const BreakpointData *data = manager()->breakHandler()->at(index);
|
||||
QString where;
|
||||
if (data->funcName.isEmpty()) {
|
||||
if (data->useFullPath) {
|
||||
@@ -1845,7 +1839,7 @@ void GdbEngine::sendInsertBreakpoint(int index)
|
||||
// cmd += _("-c ") + data->condition + ' ';
|
||||
#endif
|
||||
cmd += where;
|
||||
emit gdbOutputAvailable(LogStatus, _("Current state: %1").arg(status()));
|
||||
emit gdbOutputAvailable(LogStatus, _("Current state: %1").arg(state()));
|
||||
postCommand(cmd, NeedsStop, CB(handleBreakInsert), index);
|
||||
}
|
||||
|
||||
@@ -1893,7 +1887,7 @@ void GdbEngine::handleBreakList(const GdbMi &table)
|
||||
//qDebug() << "LEFT" << bkpts.size() << "BREAKPOINTS";
|
||||
}
|
||||
|
||||
BreakHandler *handler = qq->breakHandler();
|
||||
BreakHandler *handler = manager()->breakHandler();
|
||||
for (int index = 0; index != bkpts.size(); ++index) {
|
||||
BreakpointData temp(handler);
|
||||
breakpointDataFromOutput(&temp, bkpts.at(index));
|
||||
@@ -1921,7 +1915,7 @@ void GdbEngine::handleBreakIgnore(const GdbResponse &response)
|
||||
// 29^done
|
||||
//
|
||||
// gdb 6.3 does not produce any console output
|
||||
BreakHandler *handler = qq->breakHandler();
|
||||
BreakHandler *handler = manager()->breakHandler();
|
||||
if (response.resultClass == GdbResultDone && index < handler->size()) {
|
||||
QString msg = _(response.data.findChild("consolestreamoutput").data());
|
||||
BreakpointData *data = handler->at(index);
|
||||
@@ -1939,7 +1933,7 @@ void GdbEngine::handleBreakIgnore(const GdbResponse &response)
|
||||
void GdbEngine::handleBreakCondition(const GdbResponse &response)
|
||||
{
|
||||
int index = response.cookie.toInt();
|
||||
BreakHandler *handler = qq->breakHandler();
|
||||
BreakHandler *handler = manager()->breakHandler();
|
||||
if (response.resultClass == GdbResultDone) {
|
||||
// we just assume it was successful. otherwise we had to parse
|
||||
// the output stream data
|
||||
@@ -1962,7 +1956,7 @@ void GdbEngine::handleBreakCondition(const GdbResponse &response)
|
||||
void GdbEngine::handleBreakInsert(const GdbResponse &response)
|
||||
{
|
||||
int index = response.cookie.toInt();
|
||||
BreakHandler *handler = qq->breakHandler();
|
||||
BreakHandler *handler = manager()->breakHandler();
|
||||
if (response.resultClass == GdbResultDone) {
|
||||
//qDebug() << "HANDLE BREAK INSERT" << index;
|
||||
//#if defined(Q_OS_MAC)
|
||||
@@ -2047,7 +2041,7 @@ void GdbEngine::extractDataFromInfoBreak(const QString &output, BreakpointData *
|
||||
void GdbEngine::handleBreakInfo(const GdbResponse &response)
|
||||
{
|
||||
int bpNumber = response.cookie.toInt();
|
||||
BreakHandler *handler = qq->breakHandler();
|
||||
BreakHandler *handler = manager()->breakHandler();
|
||||
if (response.resultClass == GdbResultDone) {
|
||||
// Old-style output for multiple breakpoints, presumably in a
|
||||
// constructor
|
||||
@@ -2064,7 +2058,7 @@ void GdbEngine::handleBreakInfo(const GdbResponse &response)
|
||||
void GdbEngine::handleBreakInsert1(const GdbResponse &response)
|
||||
{
|
||||
int index = response.cookie.toInt();
|
||||
BreakHandler *handler = qq->breakHandler();
|
||||
BreakHandler *handler = manager()->breakHandler();
|
||||
if (response.resultClass == GdbResultDone) {
|
||||
// Pending breakpoints in dylibs on Mac only?
|
||||
BreakpointData *data = handler->at(index);
|
||||
@@ -2081,7 +2075,7 @@ void GdbEngine::handleBreakInsert1(const GdbResponse &response)
|
||||
|
||||
void GdbEngine::attemptBreakpointSynchronization()
|
||||
{
|
||||
BreakHandler *handler = qq->breakHandler();
|
||||
BreakHandler *handler = manager()->breakHandler();
|
||||
|
||||
foreach (BreakpointData *data, handler->takeDisabledBreakpoints()) {
|
||||
QString bpNumber = data->bpNumber;
|
||||
@@ -2240,7 +2234,7 @@ void GdbEngine::handleModulesList(const GdbResponse &response)
|
||||
}
|
||||
}
|
||||
}
|
||||
qq->modulesHandler()->setModules(modules);
|
||||
manager()->modulesHandler()->setModules(modules);
|
||||
}
|
||||
|
||||
|
||||
@@ -2329,10 +2323,10 @@ void GdbEngine::handleStackListFrames(const GdbResponse &response)
|
||||
bool canExpand = !isFull
|
||||
&& (n >= theDebuggerAction(MaximalStackDepth)->value().toInt());
|
||||
theDebuggerAction(ExpandStack)->setEnabled(canExpand);
|
||||
qq->stackHandler()->setFrames(stackFrames, canExpand);
|
||||
manager()->stackHandler()->setFrames(stackFrames, canExpand);
|
||||
|
||||
if (topFrame != -1 || theDebuggerBoolSetting(StepByInstruction)) {
|
||||
const StackFrame &frame = qq->stackHandler()->currentFrame();
|
||||
const StackFrame &frame = manager()->stackHandler()->currentFrame();
|
||||
gotoLocation(frame, true);
|
||||
}
|
||||
} else {
|
||||
@@ -2348,7 +2342,7 @@ void GdbEngine::selectThread(int index)
|
||||
//reset location arrow
|
||||
m_manager->resetLocation();
|
||||
|
||||
ThreadsHandler *threadsHandler = qq->threadsHandler();
|
||||
ThreadsHandler *threadsHandler = manager()->threadsHandler();
|
||||
threadsHandler->setCurrentThread(index);
|
||||
|
||||
QList<ThreadData> threads = threadsHandler->threads();
|
||||
@@ -2360,10 +2354,10 @@ void GdbEngine::selectThread(int index)
|
||||
|
||||
void GdbEngine::activateFrame(int frameIndex)
|
||||
{
|
||||
if (status() != DebuggerInferiorStopped)
|
||||
if (state() != InferiorStopped)
|
||||
return;
|
||||
|
||||
StackHandler *stackHandler = qq->stackHandler();
|
||||
StackHandler *stackHandler = manager()->stackHandler();
|
||||
int oldIndex = stackHandler->currentIndex();
|
||||
//qDebug() << "ACTIVATE FRAME:" << frameIndex << oldIndex
|
||||
// << stackHandler->currentIndex();
|
||||
@@ -2410,7 +2404,7 @@ void GdbEngine::handleStackListThreads(const GdbResponse &response)
|
||||
currentIndex = index;
|
||||
}
|
||||
}
|
||||
ThreadsHandler *threadsHandler = qq->threadsHandler();
|
||||
ThreadsHandler *threadsHandler = manager()->threadsHandler();
|
||||
threadsHandler->setThreads(threads);
|
||||
threadsHandler->setCurrentThread(currentIndex);
|
||||
}
|
||||
@@ -2438,7 +2432,7 @@ void GdbEngine::reloadRegisters()
|
||||
|
||||
void GdbEngine::setRegisterValue(int nr, const QString &value)
|
||||
{
|
||||
Register reg = qq->registerHandler()->registers().at(nr);
|
||||
Register reg = manager()->registerHandler()->registers().at(nr);
|
||||
//qDebug() << "NOT IMPLEMENTED: CHANGE REGISTER " << nr << reg.name << ":"
|
||||
// << value;
|
||||
postCommand(_("-var-delete \"R@\""));
|
||||
@@ -2459,7 +2453,7 @@ void GdbEngine::handleRegisterListNames(const GdbResponse &response)
|
||||
foreach (const GdbMi &item, response.data.findChild("register-names").children())
|
||||
registers.append(Register(_(item.data())));
|
||||
|
||||
qq->registerHandler()->setRegisters(registers);
|
||||
manager()->registerHandler()->setRegisters(registers);
|
||||
}
|
||||
|
||||
void GdbEngine::handleRegisterListValues(const GdbResponse &response)
|
||||
@@ -2467,7 +2461,7 @@ void GdbEngine::handleRegisterListValues(const GdbResponse &response)
|
||||
if (response.resultClass != GdbResultDone)
|
||||
return;
|
||||
|
||||
QList<Register> registers = qq->registerHandler()->registers();
|
||||
QList<Register> registers = manager()->registerHandler()->registers();
|
||||
|
||||
// 24^done,register-values=[{number="0",value="0xf423f"},...]
|
||||
foreach (const GdbMi &item, response.data.findChild("register-values").children()) {
|
||||
@@ -2480,7 +2474,7 @@ void GdbEngine::handleRegisterListValues(const GdbResponse &response)
|
||||
reg.value = value;
|
||||
}
|
||||
}
|
||||
qq->registerHandler()->setRegisters(registers);
|
||||
manager()->registerHandler()->setRegisters(registers);
|
||||
}
|
||||
|
||||
|
||||
@@ -2520,7 +2514,7 @@ static QString tooltipINameForExpression(const QString &exp)
|
||||
|
||||
bool GdbEngine::showToolTip()
|
||||
{
|
||||
WatchHandler *handler = qq->watchHandler();
|
||||
WatchHandler *handler = manager()->watchHandler();
|
||||
WatchModel *model = handler->model(TooltipsWatch);
|
||||
QString iname = tooltipINameForExpression(m_toolTipExpression);
|
||||
model->setActiveData(iname);
|
||||
@@ -2537,7 +2531,7 @@ bool GdbEngine::showToolTip()
|
||||
void GdbEngine::setToolTipExpression(const QPoint &mousePos,
|
||||
TextEditor::ITextEditor *editor, int cursorPos)
|
||||
{
|
||||
if (status() != DebuggerInferiorStopped || !isCppEditor(editor)) {
|
||||
if (state() != InferiorStopped || !isCppEditor(editor)) {
|
||||
//qDebug() << "SUPPRESSING DEBUGGER TOOLTIP, INFERIOR NOT STOPPED/Non Cpp editor";
|
||||
return;
|
||||
}
|
||||
@@ -2612,8 +2606,8 @@ void GdbEngine::setToolTipExpression(const QPoint &mousePos,
|
||||
toolTip.exp = exp;
|
||||
toolTip.name = exp;
|
||||
toolTip.iname = tooltipINameForExpression(exp);
|
||||
qq->watchHandler()->removeData(toolTip.iname);
|
||||
qq->watchHandler()->insertData(toolTip);
|
||||
manager()->watchHandler()->removeData(toolTip.iname);
|
||||
manager()->watchHandler()->insertData(toolTip);
|
||||
}
|
||||
|
||||
|
||||
@@ -2715,7 +2709,7 @@ bool GdbEngine::hasDebuggingHelperForType(const QString &type) const
|
||||
}
|
||||
|
||||
if (theDebuggerBoolSetting(DebugDebuggingHelpers)
|
||||
&& qq->stackHandler()->isDebuggingDebuggingHelpers())
|
||||
&& manager()->stackHandler()->isDebuggingDebuggingHelpers())
|
||||
return false;
|
||||
|
||||
if (m_debuggingHelperState != DebuggingHelperAvailable)
|
||||
@@ -2887,7 +2881,7 @@ void GdbEngine::updateSubItem(const WatchData &data0)
|
||||
#if DEBUG_SUBITEM
|
||||
qDebug() << "UPDATE SUBITEM: CUSTOMVALUE";
|
||||
#endif
|
||||
runDebuggingHelper(data, qq->watchHandler()->isExpandedIName(data.iname));
|
||||
runDebuggingHelper(data, manager()->watchHandler()->isExpandedIName(data.iname));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2952,7 +2946,7 @@ void GdbEngine::updateSubItem(const WatchData &data0)
|
||||
#if DEBUG_SUBITEM
|
||||
qDebug() << "UPDATE SUBITEM: CUSTOMVALUE WITH CHILDREN";
|
||||
#endif
|
||||
runDebuggingHelper(data, qq->watchHandler()->isExpandedIName(data.iname));
|
||||
runDebuggingHelper(data, manager()->watchHandler()->isExpandedIName(data.iname));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3015,7 +3009,7 @@ void GdbEngine::rebuildModel()
|
||||
PENDING_DEBUG("REBUILDING MODEL" << count);
|
||||
emit gdbInputAvailable(LogStatus, _("<Rebuild Watchmodel %1>").arg(count));
|
||||
showStatusMessage(tr("Finished retrieving data."), 400);
|
||||
qq->watchHandler()->endCycle();
|
||||
manager()->watchHandler()->endCycle();
|
||||
showToolTip();
|
||||
}
|
||||
|
||||
@@ -3045,7 +3039,7 @@ void GdbEngine::handleQueryDebuggingHelper(const GdbResponse &response)
|
||||
// currently causes errors.
|
||||
const double dumperVersion = getDumperVersion(contents);
|
||||
if (dumperVersion < dumperVersionRequired) {
|
||||
qq->showQtDumperLibraryWarning(
|
||||
manager()->showQtDumperLibraryWarning(
|
||||
QtDumperHelper::msgDumperOutdated(dumperVersionRequired, dumperVersion));
|
||||
m_debuggingHelperState = DebuggingHelperUnavailable;
|
||||
return;
|
||||
@@ -3137,13 +3131,13 @@ void GdbEngine::handleVarCreate(const GdbResponse &response)
|
||||
// we do not trust gdb if we have a custom dumper
|
||||
if (response.data.findChild("children").isValid())
|
||||
data.setChildrenUnneeded();
|
||||
else if (qq->watchHandler()->isExpandedIName(data.iname))
|
||||
else if (manager()->watchHandler()->isExpandedIName(data.iname))
|
||||
data.setChildrenNeeded();
|
||||
insertData(data);
|
||||
} else {
|
||||
if (response.data.findChild("children").isValid())
|
||||
data.setChildrenUnneeded();
|
||||
else if (qq->watchHandler()->isExpandedIName(data.iname))
|
||||
else if (manager()->watchHandler()->isExpandedIName(data.iname))
|
||||
data.setChildrenNeeded();
|
||||
setWatchDataChildCount(data, response.data.findChild("numchild"));
|
||||
//if (data.isValueNeeded() && data.childCount > 0)
|
||||
@@ -3238,7 +3232,7 @@ void GdbEngine::handleDebuggingHelperValue2(const GdbResponse &response)
|
||||
handleChildren(data, contents, &list);
|
||||
//for (int i = 0; i != list.size(); ++i)
|
||||
// qDebug() << "READ: " << list.at(i).toString();
|
||||
qq->watchHandler()->insertBulkData(list);
|
||||
manager()->watchHandler()->insertBulkData(list);
|
||||
}
|
||||
|
||||
void GdbEngine::handleChildren(const WatchData &data0, const GdbMi &item,
|
||||
@@ -3246,18 +3240,18 @@ void GdbEngine::handleChildren(const WatchData &data0, const GdbMi &item,
|
||||
{
|
||||
//qDebug() << "HANDLE CHILDREN: " << data0.toString() << item.toString();
|
||||
WatchData data = data0;
|
||||
if (!qq->watchHandler()->isExpandedIName(data.iname))
|
||||
if (!manager()->watchHandler()->isExpandedIName(data.iname))
|
||||
data.setChildrenUnneeded();
|
||||
|
||||
GdbMi children = item.findChild("children");
|
||||
if (children.isValid() || !qq->watchHandler()->isExpandedIName(data.iname))
|
||||
if (children.isValid() || !manager()->watchHandler()->isExpandedIName(data.iname))
|
||||
data.setChildrenUnneeded();
|
||||
|
||||
if (qq->watchHandler()->isDisplayedIName(data.iname)) {
|
||||
if (manager()->watchHandler()->isDisplayedIName(data.iname)) {
|
||||
GdbMi editvalue = item.findChild("editvalue");
|
||||
if (editvalue.isValid()) {
|
||||
setWatchDataEditValue(data, editvalue);
|
||||
qq->watchHandler()->showEditValue(data);
|
||||
manager()->watchHandler()->showEditValue(data);
|
||||
}
|
||||
}
|
||||
setWatchDataType(data, item.findChild("type"));
|
||||
@@ -3391,7 +3385,7 @@ void GdbEngine::updateLocals()
|
||||
PENDING_DEBUG("\nRESET PENDING");
|
||||
//m_toolTipCache.clear();
|
||||
m_toolTipExpression.clear();
|
||||
qq->watchHandler()->beginCycle();
|
||||
manager()->watchHandler()->beginCycle();
|
||||
|
||||
QString level = QString::number(currentFrame());
|
||||
// '2' is 'list with type and value'
|
||||
@@ -3445,7 +3439,7 @@ void GdbEngine::handleStackListLocals(const GdbResponse &response)
|
||||
locals += m_currentFunctionArgs;
|
||||
|
||||
setLocals(locals);
|
||||
qq->watchHandler()->updateWatchers();
|
||||
manager()->watchHandler()->updateWatchers();
|
||||
}
|
||||
|
||||
void GdbEngine::setLocals(const QList<GdbMi> &locals)
|
||||
@@ -3507,7 +3501,7 @@ void GdbEngine::setLocals(const QList<GdbMi> &locals)
|
||||
// if (!value.isEmpty() && value != "{...}")
|
||||
// data.setValue(decodeData(value, 0));
|
||||
//}
|
||||
if (!qq->watchHandler()->isExpandedIName(data.iname))
|
||||
if (!manager()->watchHandler()->isExpandedIName(data.iname))
|
||||
data.setChildrenUnneeded();
|
||||
if (isPointerType(data.type) || data.name == __("this"))
|
||||
data.setHasChildren(true);
|
||||
@@ -3518,7 +3512,7 @@ void GdbEngine::setLocals(const QList<GdbMi> &locals)
|
||||
list.append(data);
|
||||
}
|
||||
}
|
||||
qq->watchHandler()->insertBulkData(list);
|
||||
manager()->watchHandler()->insertBulkData(list);
|
||||
}
|
||||
|
||||
void GdbEngine::insertData(const WatchData &data0)
|
||||
@@ -3529,7 +3523,7 @@ void GdbEngine::insertData(const WatchData &data0)
|
||||
qDebug() << "BOGUS VALUE:" << data.toString();
|
||||
return;
|
||||
}
|
||||
qq->watchHandler()->insertData(data);
|
||||
manager()->watchHandler()->insertData(data);
|
||||
}
|
||||
|
||||
void GdbEngine::handleVarListChildrenHelper(const GdbMi &item,
|
||||
@@ -3586,7 +3580,7 @@ void GdbEngine::handleVarListChildrenHelper(const GdbMi &item,
|
||||
setWatchDataAddress(data, item.findChild("addr"));
|
||||
setWatchDataSAddress(data, item.findChild("saddr"));
|
||||
setWatchDataChildCount(data, item.findChild("numchild"));
|
||||
if (!qq->watchHandler()->isExpandedIName(data.iname))
|
||||
if (!manager()->watchHandler()->isExpandedIName(data.iname))
|
||||
data.setChildrenUnneeded();
|
||||
|
||||
data.name = _(exp);
|
||||
@@ -3708,10 +3702,10 @@ void GdbEngine::tryLoadDebuggingHelpers()
|
||||
|
||||
PENDING_DEBUG("TRY LOAD CUSTOM DUMPERS");
|
||||
m_debuggingHelperState = DebuggingHelperUnavailable;
|
||||
if (!qq->qtDumperLibraryEnabled())
|
||||
if (!manager()->qtDumperLibraryEnabled())
|
||||
return;
|
||||
const QString lib = qq->qtDumperLibraryName();
|
||||
const QStringList &locations = qq->qtDumperLibraryLocations();
|
||||
const QString lib = manager()->qtDumperLibraryName();
|
||||
const QStringList &locations = manager()->qtDumperLibraryLocations();
|
||||
//qDebug() << "DUMPERLIB:" << lib;
|
||||
// @TODO: same in CDB engine...
|
||||
const QFileInfo fi(lib);
|
||||
@@ -3719,7 +3713,7 @@ void GdbEngine::tryLoadDebuggingHelpers()
|
||||
const QString loc = locations.join(QLatin1String(", "));
|
||||
const QString msg = tr("The dumper library was not found at %1.").arg(loc);
|
||||
debugMessage(msg);
|
||||
qq->showQtDumperLibraryWarning(msg);
|
||||
manager()->showQtDumperLibraryWarning(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3734,7 +3728,7 @@ void GdbEngine::tryLoadDebuggingHelpers()
|
||||
} else {
|
||||
debugMessage(tr("Dumper loading (%1) failed: %2").arg(lib, errorMessage));
|
||||
debugMessage(errorMessage);
|
||||
qq->showQtDumperLibraryWarning(errorMessage);
|
||||
manager()->showQtDumperLibraryWarning(errorMessage);
|
||||
m_debuggingHelperState = DebuggingHelperUnavailable;
|
||||
return;
|
||||
}
|
||||
@@ -4025,7 +4019,6 @@ void GdbEngine::handleAdapterStartFailed(const QString &msg)
|
||||
void GdbEngine::handleAdapterStarted()
|
||||
{
|
||||
debugMessage(_("ADAPTER SUCCESSFULLY STARTED, PREPARING INFERIOR"));
|
||||
qq->notifyInferiorStopped();
|
||||
m_gdbAdapter->prepareInferior();
|
||||
}
|
||||
|
||||
@@ -4039,9 +4032,9 @@ void GdbEngine::handleInferiorPreparationFailed(const QString &msg)
|
||||
|
||||
void GdbEngine::handleInferiorPrepared()
|
||||
{
|
||||
QTC_ASSERT(state() == InferiorPrepared, qDebug() << state());
|
||||
debugMessage(_("INFERIOR PREPARED"));
|
||||
// FIXME: Check that inferior is in "stopped" state
|
||||
qq->notifyInferiorStopped();
|
||||
showStatusMessage(tr("Inferior prepared for startup."));
|
||||
|
||||
postCommand(_("show version"), CB(handleShowVersion));
|
||||
@@ -4121,45 +4114,18 @@ void GdbEngine::handleInferiorPrepared()
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if (startMode() == AttachExternal || startMode() == AttachCrashedExternal) {
|
||||
postCommand(_("attach %1").arg(m_startParameters->attachPID), CB(handleAttach));
|
||||
// Task 254674 does not want to remove them
|
||||
//qq->breakHandler()->removeAllBreakpoints();
|
||||
} else if (startMode() == StartRemote) {
|
||||
postCommand(_("set architecture %1").arg(m_startParameters->remoteArchitecture));
|
||||
qq->breakHandler()->setAllPending();
|
||||
//QFileInfo fi(m_startParameters->executable);
|
||||
//QString fileName = fi.absoluteFileName();
|
||||
QString fileName = m_startParameters->executable;
|
||||
postCommand(_("-file-exec-and-symbols \"%1\"").arg(fileName), CB(handleFileExecAndSymbols));
|
||||
// works only for > 6.8
|
||||
postCommand(_("set target-async on"), CB(handleSetTargetAsync));
|
||||
} else if (m_startParameters->useTerminal) {
|
||||
qq->breakHandler()->setAllPending();
|
||||
} else if (startMode() == StartInternal || startMode() == StartExternal) {
|
||||
qq->breakHandler()->setAllPending();
|
||||
m_gdbAdapter->attach();
|
||||
if (m_gdbAdapter->isTrkAdapter()) {
|
||||
m_continuationAfterDone = true;
|
||||
qq->notifyInferiorStopped();
|
||||
attemptBreakpointSynchronization();
|
||||
qq->notifyInferiorRunningRequested();
|
||||
} [...]
|
||||
}
|
||||
*/
|
||||
|
||||
// initial attempt to set breakpoints
|
||||
// Initial attempt to set breakpoints
|
||||
QTC_ASSERT(m_continuationAfterDone == 0, /**/);
|
||||
showStatusMessage(tr("Start initial breakpoint setting."));
|
||||
m_continuationAfterDone = &GdbEngine::handleInitialBreakpointsSet;
|
||||
showStatusMessage(tr("Setting breakpoints..."));
|
||||
m_continuationAfterDone = &GdbEngine::startInferior;
|
||||
attemptBreakpointSynchronization();
|
||||
}
|
||||
|
||||
void GdbEngine::handleInitialBreakpointsSet()
|
||||
void GdbEngine::startInferior()
|
||||
{
|
||||
showStatusMessage(tr("Initial breakpoint setting finished."), 1000);
|
||||
qq->notifyInferiorRunningRequested();
|
||||
QTC_ASSERT(state() == InferiorPrepared, qDebug() << state());
|
||||
showStatusMessage(tr("Starting inferior..."));
|
||||
setState(InferiorStarting);
|
||||
m_gdbAdapter->startInferior();
|
||||
}
|
||||
|
||||
@@ -4172,8 +4138,13 @@ void GdbEngine::handleInferiorStartFailed(const QString &msg)
|
||||
|
||||
void GdbEngine::handleInferiorStarted()
|
||||
{
|
||||
QTC_ASSERT(state() == InferiorRunningRequested
|
||||
|| state() == InferiorStopped, qDebug() << state());
|
||||
debugMessage(_("INFERIOR STARTED"));
|
||||
qq->notifyInferiorRunning();
|
||||
if (state() == InferiorStopped)
|
||||
showStatusMessage(tr("Inferior stopped."));
|
||||
else
|
||||
showStatusMessage(tr("Inferior started."));
|
||||
}
|
||||
|
||||
void GdbEngine::handleInferiorShutDown()
|
||||
@@ -4198,14 +4169,14 @@ void GdbEngine::handleAdapterCrashed()
|
||||
void GdbEngine::handleAdapterShutDown()
|
||||
{
|
||||
debugMessage(_("ADAPTER SUCCESSFULLY SHUT DOWN"));
|
||||
qq->notifyEngineFinished();
|
||||
manager()->notifyEngineFinished();
|
||||
}
|
||||
|
||||
void GdbEngine::handleAdapterShutdownFailed(const QString &msg)
|
||||
{
|
||||
debugMessage(_("ADAPTER SHUTDOWN FAILED"));
|
||||
showMessageBox(QMessageBox::Critical, tr("Inferior shutdown failed"), msg);
|
||||
qq->notifyEngineFinished();
|
||||
manager()->notifyEngineFinished();
|
||||
}
|
||||
|
||||
void GdbEngine::addOptionPages(QList<Core::IOptionsPage*> *opts) const
|
||||
@@ -4220,57 +4191,14 @@ void GdbEngine::showMessageBox(int icon, const QString &title, const QString &te
|
||||
m_manager->showMessageBox(icon, title, text);
|
||||
}
|
||||
|
||||
static bool isAllowedTransition(int from, int to)
|
||||
{
|
||||
return (from == -1)
|
||||
|| (from == AdapterNotRunning && to == AdapterNotRunning)
|
||||
|| (from == AdapterNotRunning && to == AdapterStarting)
|
||||
|| (from == AdapterStarting && to == AdapterStarted)
|
||||
|| (from == AdapterStarting && to == AdapterStartFailed)
|
||||
|| (from == AdapterStarted && to == InferiorPreparing)
|
||||
|| (from == InferiorPreparing && to == InferiorPrepared)
|
||||
|| (from == InferiorPreparing && to == InferiorPreparationFailed)
|
||||
|| (from == InferiorPrepared && to == InferiorStarting)
|
||||
|| (from == InferiorStarting && to == InferiorStarted)
|
||||
|| (from == InferiorStarting && to == InferiorStartFailed)
|
||||
|| (from == InferiorStarted && to == InferiorShuttingDown)
|
||||
|| (from == InferiorShuttingDown && to == InferiorShutDown)
|
||||
|| (from == InferiorShuttingDown && to == InferiorShutdownFailed)
|
||||
|| (from == InferiorShutDown && to == AdapterShuttingDown)
|
||||
|| (from == AdapterShuttingDown && to == AdapterNotRunning)
|
||||
;
|
||||
}
|
||||
|
||||
GdbAdapterState GdbEngine::state() const
|
||||
{
|
||||
return m_state;
|
||||
}
|
||||
|
||||
void GdbEngine::setState(GdbAdapterState state)
|
||||
{
|
||||
QString msg = _("Adapter state from %1 to state %2.").arg(m_state).arg(state);
|
||||
if (!isAllowedTransition(m_state, state))
|
||||
qDebug() << "UNEXPECTED ADAPTER TRANSITION: " << msg;
|
||||
debugMessage(msg);
|
||||
m_state = state;
|
||||
}
|
||||
|
||||
//
|
||||
// AbstractGdbAdapter
|
||||
//
|
||||
|
||||
void AbstractGdbAdapter::setState(GdbAdapterState state)
|
||||
{
|
||||
m_engine->setState(state);
|
||||
}
|
||||
|
||||
//
|
||||
// Factory
|
||||
//
|
||||
|
||||
IDebuggerEngine *createGdbEngine(DebuggerManager *parent)
|
||||
IDebuggerEngine *createGdbEngine(DebuggerManager *manager)
|
||||
{
|
||||
return new GdbEngine(parent);
|
||||
return new GdbEngine(manager);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -79,32 +79,12 @@ enum DebuggingHelperState
|
||||
DebuggingHelperUnavailable,
|
||||
};
|
||||
|
||||
enum GdbAdapterState
|
||||
{
|
||||
AdapterNotRunning,
|
||||
AdapterStarting,
|
||||
AdapterStarted,
|
||||
AdapterStartFailed,
|
||||
InferiorPreparing,
|
||||
InferiorPrepared,
|
||||
InferiorPreparationFailed,
|
||||
InferiorStarting,
|
||||
InferiorStarted,
|
||||
InferiorStartFailed,
|
||||
InferiorShuttingDown,
|
||||
InferiorShutDown,
|
||||
InferiorShutdownFailed,
|
||||
AdapterShuttingDown,
|
||||
//AdapterShutDown, // use AdapterNotRunning
|
||||
AdapterShutdownFailed,
|
||||
};
|
||||
|
||||
class GdbEngine : public IDebuggerEngine
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GdbEngine(DebuggerManager *parent);
|
||||
explicit GdbEngine(DebuggerManager *manager);
|
||||
~GdbEngine();
|
||||
|
||||
signals:
|
||||
@@ -292,10 +272,6 @@ private:
|
||||
bool showToolTip();
|
||||
|
||||
// Convenience
|
||||
DebuggerManager *manager() { return m_manager; }
|
||||
void showStatusMessage(const QString &msg, int timeout = -1)
|
||||
{ m_manager->showStatusMessage(msg, timeout); }
|
||||
int status() const { return m_manager->status(); }
|
||||
QMainWindow *mainWindow() const { return m_manager->mainWindow(); }
|
||||
DebuggerStartMode startMode() const;
|
||||
qint64 inferiorPid() const { return m_manager->inferiorPid(); }
|
||||
@@ -438,14 +414,12 @@ private:
|
||||
typedef void (GdbEngine::*Continuation)();
|
||||
// function called after all previous responses have been received
|
||||
Continuation m_continuationAfterDone;
|
||||
void handleInitialBreakpointsSet();
|
||||
void startInferior();
|
||||
|
||||
bool m_modulesListOutdated;
|
||||
|
||||
QList<GdbCommand> m_commandsToRunOnTemporaryBreak;
|
||||
|
||||
DebuggerManager * const m_manager;
|
||||
IDebuggerManagerAccessForEngines * const qq;
|
||||
DebuggerStartParametersPtr m_startParameters;
|
||||
// make sure to re-initialize new members in initializeVariables();
|
||||
|
||||
@@ -457,11 +431,7 @@ private:
|
||||
RemoteGdbAdapter *m_remoteAdapter; // owned
|
||||
TrkGdbAdapter *m_trkAdapter; // owned
|
||||
|
||||
// State
|
||||
friend class AbstractGdbAdapter;
|
||||
GdbAdapterState m_state;
|
||||
void setState(GdbAdapterState state);
|
||||
GdbAdapterState state() const;
|
||||
|
||||
public:
|
||||
void showMessageBox(int icon, const QString &title, const QString &text);
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace Internal {
|
||||
PlainGdbAdapter::PlainGdbAdapter(GdbEngine *engine, QObject *parent)
|
||||
: AbstractGdbAdapter(engine, parent)
|
||||
{
|
||||
QTC_ASSERT(state() == AdapterNotRunning, qDebug() << state());
|
||||
QTC_ASSERT(state() == DebuggerNotReady, qDebug() << state());
|
||||
connect(&m_gdbProc, SIGNAL(error(QProcess::ProcessError)),
|
||||
this, SIGNAL(error(QProcess::ProcessError)));
|
||||
connect(&m_gdbProc, SIGNAL(readyReadStandardOutput()),
|
||||
@@ -85,7 +85,7 @@ PlainGdbAdapter::PlainGdbAdapter(GdbEngine *engine, QObject *parent)
|
||||
|
||||
void PlainGdbAdapter::startAdapter()
|
||||
{
|
||||
QTC_ASSERT(state() == AdapterNotRunning, qDebug() << state());
|
||||
QTC_ASSERT(state() == EngineStarting, qDebug() << state());
|
||||
setState(AdapterStarting);
|
||||
debugMessage(_("TRYING TO START ADAPTER"));
|
||||
|
||||
@@ -159,7 +159,7 @@ void PlainGdbAdapter::handleFileExecAndSymbols(const GdbResponse &response)
|
||||
|
||||
void PlainGdbAdapter::handleInfoTarget(const GdbResponse &response)
|
||||
{
|
||||
QTC_ASSERT(state() == AdapterNotRunning, qDebug() << state());
|
||||
QTC_ASSERT(state() == DebuggerNotReady, qDebug() << state());
|
||||
#if defined(Q_OS_MAC)
|
||||
Q_UNUSED(response)
|
||||
#else
|
||||
@@ -187,6 +187,7 @@ void PlainGdbAdapter::handleInfoTarget(const GdbResponse &response)
|
||||
//debugMessage(_("STREAM: ") + msg + " " + needle.cap(1));
|
||||
m_engine->postCommand(_("tbreak *") + needle.cap(1));
|
||||
// FIXME: m_waitingForFirstBreakpointToBeHit = true;
|
||||
setState(InferiorRunningRequested);
|
||||
m_engine->postCommand(_("-exec-run"), CB(handleExecRun));
|
||||
} else {
|
||||
debugMessage(_("PARSING START ADDRESS FAILED: ") + msg);
|
||||
@@ -201,14 +202,14 @@ void PlainGdbAdapter::handleInfoTarget(const GdbResponse &response)
|
||||
|
||||
void PlainGdbAdapter::handleExecRun(const GdbResponse &response)
|
||||
{
|
||||
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
|
||||
QTC_ASSERT(state() == InferiorRunningRequested, qDebug() << state());
|
||||
if (response.resultClass == GdbResultRunning) {
|
||||
setState(InferiorStarted);
|
||||
emit inferiorStarted();
|
||||
setState(InferiorRunning);
|
||||
} else {
|
||||
QTC_ASSERT(response.resultClass == GdbResultError, /**/);
|
||||
const QByteArray &msg = response.data.findChild("msg").data();
|
||||
//QTC_ASSERT(status() == DebuggerInferiorRunning, /**/);
|
||||
//QTC_ASSERT(status() == InferiorRunning, /**/);
|
||||
//interruptInferior();
|
||||
setState(InferiorStartFailed);
|
||||
emit inferiorStartFailed(msg);
|
||||
@@ -217,8 +218,8 @@ void PlainGdbAdapter::handleExecRun(const GdbResponse &response)
|
||||
|
||||
void PlainGdbAdapter::startInferior()
|
||||
{
|
||||
QTC_ASSERT(state() == InferiorPrepared, qDebug() << state());
|
||||
setState(InferiorStarting);
|
||||
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
|
||||
setState(InferiorRunningRequested);
|
||||
m_engine->postCommand(_("-exec-run"), CB(handleExecRun));
|
||||
}
|
||||
|
||||
@@ -237,26 +238,28 @@ void PlainGdbAdapter::interruptInferior()
|
||||
|
||||
void PlainGdbAdapter::shutdown()
|
||||
{
|
||||
if (state() == InferiorStarted) {
|
||||
switch (state()) {
|
||||
|
||||
case InferiorRunningRequested:
|
||||
case InferiorRunning:
|
||||
case InferiorStopping:
|
||||
case InferiorStopped:
|
||||
setState(InferiorShuttingDown);
|
||||
m_engine->postCommand(_("kill"), CB(handleKill));
|
||||
return;
|
||||
}
|
||||
|
||||
if (state() == InferiorShutDown) {
|
||||
case InferiorShutDown:
|
||||
setState(AdapterShuttingDown);
|
||||
m_engine->postCommand(_("-gdb-exit"), CB(handleExit));
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
if (state() == InferiorShutdownFailed) {
|
||||
case InferiorShutdownFailed:
|
||||
m_gdbProc.terminate();
|
||||
// 20s can easily happen when loading webkit debug information
|
||||
m_gdbProc.waitForFinished(20000);
|
||||
setState(AdapterShuttingDown);
|
||||
debugMessage(_("FORCING TERMINATION: %1")
|
||||
.arg(state()));
|
||||
debugMessage(_("FORCING TERMINATION: %1").arg(state()));
|
||||
if (state() != QProcess::NotRunning) {
|
||||
debugMessage(_("PROBLEM STOPPING DEBUGGER: STATE %1")
|
||||
.arg(state()));
|
||||
@@ -264,10 +267,10 @@ void PlainGdbAdapter::shutdown()
|
||||
}
|
||||
m_engine->postCommand(_("-gdb-exit"), CB(handleExit));
|
||||
return;
|
||||
}
|
||||
|
||||
*/
|
||||
QTC_ASSERT(state() == AdapterNotRunning, qDebug() << state());
|
||||
default:
|
||||
QTC_ASSERT(false, qDebug() << state());
|
||||
}
|
||||
}
|
||||
|
||||
void PlainGdbAdapter::handleKill(const GdbResponse &response)
|
||||
@@ -298,7 +301,7 @@ void PlainGdbAdapter::handleExit(const GdbResponse &response)
|
||||
void PlainGdbAdapter::handleGdbFinished(int, QProcess::ExitStatus)
|
||||
{
|
||||
debugMessage(_("GDB PROESS FINISHED"));
|
||||
setState(AdapterNotRunning);
|
||||
setState(DebuggerNotReady);
|
||||
emit adapterShutDown();
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace Internal {
|
||||
RemoteGdbAdapter::RemoteGdbAdapter(GdbEngine *engine, QObject *parent)
|
||||
: AbstractGdbAdapter(engine, parent)
|
||||
{
|
||||
QTC_ASSERT(state() == AdapterNotRunning, qDebug() << state());
|
||||
QTC_ASSERT(state() == DebuggerNotReady, qDebug() << state());
|
||||
connect(&m_gdbProc, SIGNAL(error(QProcess::ProcessError)),
|
||||
this, SIGNAL(error(QProcess::ProcessError)));
|
||||
connect(&m_gdbProc, SIGNAL(readyReadStandardOutput()),
|
||||
@@ -77,7 +77,7 @@ RemoteGdbAdapter::RemoteGdbAdapter(GdbEngine *engine, QObject *parent)
|
||||
|
||||
void RemoteGdbAdapter::startAdapter()
|
||||
{
|
||||
QTC_ASSERT(state() == AdapterNotRunning, qDebug() << state());
|
||||
QTC_ASSERT(state() == EngineStarting, qDebug() << state());
|
||||
setState(AdapterStarting);
|
||||
debugMessage(_("TRYING TO START ADAPTER"));
|
||||
|
||||
@@ -234,20 +234,16 @@ void RemoteGdbAdapter::handleTargetRemote(const GdbResponse &record)
|
||||
|
||||
void RemoteGdbAdapter::startInferior()
|
||||
{
|
||||
QTC_ASSERT(state() == InferiorPrepared, qDebug() << state());
|
||||
setState(InferiorStarting);
|
||||
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
|
||||
m_engine->postCommand(_("attach"), CB(handleFirstContinue));
|
||||
// FIXME: Is there a way to properly recognize a successful start?
|
||||
setState(InferiorStarted);
|
||||
emit inferiorStarted();
|
||||
}
|
||||
|
||||
void RemoteGdbAdapter::handleFirstContinue(const GdbResponse &record)
|
||||
{
|
||||
//QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
|
||||
QTC_ASSERT(state() == InferiorStarted, qDebug() << state());
|
||||
QTC_ASSERT(state() == InferiorRunningRequested, qDebug() << state());
|
||||
if (record.resultClass == GdbResultDone) {
|
||||
// inferiorStarted already emitted above, see FIXME
|
||||
setState(InferiorStopped);
|
||||
emit inferiorStarted();
|
||||
} else if (record.resultClass == GdbResultError) {
|
||||
//QString msg = __(record.data.findChild("msg").data());
|
||||
QString msg1 = tr("Connecting to remote server failed:\n");
|
||||
@@ -264,10 +260,8 @@ void RemoteGdbAdapter::shutdown()
|
||||
{
|
||||
switch (state()) {
|
||||
|
||||
case AdapterNotRunning:
|
||||
return;
|
||||
|
||||
case InferiorStarted:
|
||||
case InferiorRunning:
|
||||
case InferiorStopped:
|
||||
setState(InferiorShuttingDown);
|
||||
m_engine->postCommand(_("kill"), CB(handleKill));
|
||||
return;
|
||||
@@ -313,7 +307,7 @@ void RemoteGdbAdapter::handleExit(const GdbResponse &response)
|
||||
void RemoteGdbAdapter::handleGdbFinished(int, QProcess::ExitStatus)
|
||||
{
|
||||
debugMessage(_("GDB PROESS FINISHED"));
|
||||
setState(AdapterNotRunning);
|
||||
setState(DebuggerNotReady);
|
||||
emit adapterShutDown();
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ TrkGdbAdapter::TrkGdbAdapter(GdbEngine *engine, const TrkOptionsPtr &options) :
|
||||
m_bufferedMemoryRead(true),
|
||||
m_waitCount(0)
|
||||
{
|
||||
setState(AdapterNotRunning);
|
||||
setState(DebuggerNotReady);
|
||||
#ifdef Q_OS_WIN
|
||||
const DWORD portOffset = GetCurrentProcessId() % 100;
|
||||
#else
|
||||
@@ -246,7 +246,7 @@ void TrkGdbAdapter::startInferiorEarly()
|
||||
QString msg = QString::fromLatin1("Failed to connect to %1 after "
|
||||
"%2 attempts").arg(device).arg(m_waitCount);
|
||||
logMessage(msg);
|
||||
setState(AdapterNotRunning);
|
||||
setState(DebuggerNotReady);
|
||||
emit adapterStartFailed(msg);
|
||||
}
|
||||
return;
|
||||
@@ -1327,7 +1327,7 @@ void TrkGdbAdapter::handleGdbFinished(int exitCode, QProcess::ExitStatus exitSta
|
||||
{
|
||||
logMessage(QString("GDB: ProcessFinished %1 %2")
|
||||
.arg(exitCode).arg(exitStatus));
|
||||
setState(AdapterNotRunning);
|
||||
setState(DebuggerNotReady);
|
||||
emit adapterShutDown();
|
||||
}
|
||||
|
||||
@@ -1346,7 +1346,7 @@ void TrkGdbAdapter::handleGdbStateChanged(QProcess::ProcessState newState)
|
||||
|
||||
void TrkGdbAdapter::startAdapter()
|
||||
{
|
||||
QTC_ASSERT(state() == AdapterNotRunning, qDebug() << state());
|
||||
QTC_ASSERT(state() == EngineStarting, qDebug() << state());
|
||||
setState(AdapterStarting);
|
||||
debugMessage(_("TRYING TO START ADAPTER"));
|
||||
logMessage(QLatin1String("### Starting TrkGdbAdapter"));
|
||||
@@ -1406,18 +1406,16 @@ void TrkGdbAdapter::handleTargetRemote(const GdbResponse &record)
|
||||
|
||||
void TrkGdbAdapter::startInferior()
|
||||
{
|
||||
QTC_ASSERT(state() == InferiorPrepared, qDebug() << state());
|
||||
setState(InferiorStarting);
|
||||
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
|
||||
setState(InferiorRunningRequested);
|
||||
m_engine->postCommand(_("-exec-continue"), CB(handleFirstContinue));
|
||||
// FIXME: Is there a way to properly recognize a successful start?
|
||||
setState(InferiorStarted);
|
||||
emit inferiorStarted();
|
||||
}
|
||||
|
||||
void TrkGdbAdapter::handleFirstContinue(const GdbResponse &record)
|
||||
{
|
||||
//QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
|
||||
QTC_ASSERT(state() == InferiorStarted, qDebug() << state());
|
||||
QTC_ASSERT(state() == InferiorRunningRequested, qDebug() << state());
|
||||
if (record.resultClass == GdbResultDone) {
|
||||
// inferiorStarted already emitted above, see FIXME
|
||||
} else if (record.resultClass == GdbResultError) {
|
||||
@@ -1457,7 +1455,7 @@ void TrkGdbAdapter::startGdb()
|
||||
QString msg = QString("Unable to start the gdb server at %1: %2.")
|
||||
.arg(m_gdbServerName).arg(m_gdbServer.errorString());
|
||||
logMessage(msg);
|
||||
setState(AdapterNotRunning);
|
||||
setState(DebuggerNotReady);
|
||||
emit adapterStartFailed(msg);
|
||||
return;
|
||||
}
|
||||
@@ -1590,22 +1588,26 @@ void TrkGdbAdapter::setEnvironment(const QStringList &env)
|
||||
|
||||
void TrkGdbAdapter::shutdown()
|
||||
{
|
||||
qDebug() << "ADAPTER SHUTDOWN " << state();
|
||||
if (state() == InferiorStarted) {
|
||||
switch (state()) {
|
||||
|
||||
case InferiorStopped:
|
||||
case InferiorStopping:
|
||||
case InferiorRunningRequested:
|
||||
case InferiorRunning:
|
||||
setState(InferiorShuttingDown);
|
||||
qDebug() << "kill";
|
||||
m_engine->postCommand(_("kill"), CB(handleKill));
|
||||
return;
|
||||
}
|
||||
|
||||
if (state() == InferiorShutDown) {
|
||||
case InferiorShutDown:
|
||||
setState(AdapterShuttingDown);
|
||||
qDebug() << "gdb-exit";
|
||||
m_engine->postCommand(_("-gdb-exit"), CB(handleExit));
|
||||
return;
|
||||
}
|
||||
|
||||
QTC_ASSERT(state() == AdapterNotRunning, qDebug() << state());
|
||||
default:
|
||||
QTC_ASSERT(false, qDebug() << state());
|
||||
}
|
||||
}
|
||||
|
||||
void TrkGdbAdapter::handleKill(const GdbResponse &response)
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
#ifndef DEBUGGER_IDEBUGGERENGINE_H
|
||||
#define DEBUGGER_IDEBUGGERENGINE_H
|
||||
|
||||
#include "debuggerconstants.h"
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QSharedPointer>
|
||||
@@ -51,6 +53,7 @@ namespace Debugger {
|
||||
namespace Internal {
|
||||
|
||||
class DebuggerStartParameters;
|
||||
class DebuggerManager;
|
||||
class DisassemblerViewAgent;
|
||||
class MemoryViewAgent;
|
||||
struct StackFrame;
|
||||
@@ -63,7 +66,9 @@ class IDebuggerEngine : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
IDebuggerEngine(QObject *parent = 0) : QObject(parent) {}
|
||||
IDebuggerEngine(DebuggerManager *manager, QObject *parent = 0)
|
||||
: QObject(parent), m_manager(manager)
|
||||
{}
|
||||
|
||||
virtual void shutdown() = 0;
|
||||
virtual void setToolTipExpression(const QPoint &mousePos, TextEditor::ITextEditor *editor, int cursorPos) = 0;
|
||||
@@ -111,6 +116,13 @@ public:
|
||||
|
||||
virtual void addOptionPages(QList<Core::IOptionsPage*> *) const {}
|
||||
|
||||
protected:
|
||||
void showStatusMessage(const QString &msg, int timeout = -1);
|
||||
DebuggerState state() const;
|
||||
void setState(DebuggerState state);
|
||||
DebuggerManager *manager() const { return m_manager; }
|
||||
DebuggerManager *m_manager;
|
||||
|
||||
signals:
|
||||
void startSuccessful();
|
||||
void startFailed();
|
||||
|
||||
@@ -184,10 +184,9 @@ void ScriptAgent::scriptUnload(qint64 scriptId)
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
ScriptEngine::ScriptEngine(DebuggerManager *parent)
|
||||
ScriptEngine::ScriptEngine(DebuggerManager *manager)
|
||||
: IDebuggerEngine(manager)
|
||||
{
|
||||
q = parent;
|
||||
qq = parent->engineInterface();
|
||||
// created in startDebugger()
|
||||
m_scriptEngine = 0;
|
||||
m_scriptAgent = 0;
|
||||
@@ -214,7 +213,7 @@ void ScriptEngine::exitDebugger()
|
||||
m_stopped = false;
|
||||
m_stopOnNextLine = false;
|
||||
m_scriptEngine->abortEvaluation();
|
||||
qq->notifyInferiorExited();
|
||||
manager()->notifyInferiorExited();
|
||||
}
|
||||
|
||||
void ScriptEngine::startDebugger(const DebuggerStartParametersPtr &sp)
|
||||
@@ -241,7 +240,8 @@ void ScriptEngine::startDebugger(const DebuggerStartParametersPtr &sp)
|
||||
m_scriptContents = stream.readAll();
|
||||
scriptFile.close();
|
||||
attemptBreakpointSynchronization();
|
||||
qq->notifyInferiorRunningRequested();
|
||||
setState(InferiorRunningRequested);
|
||||
showStatusMessage(tr("Running requested..."), 5000);
|
||||
QTimer::singleShot(0, this, SLOT(runInferior()));
|
||||
emit startSuccessful();
|
||||
}
|
||||
@@ -381,7 +381,7 @@ void ScriptEngine::selectThread(int index)
|
||||
|
||||
void ScriptEngine::attemptBreakpointSynchronization()
|
||||
{
|
||||
BreakHandler *handler = qq->breakHandler();
|
||||
BreakHandler *handler = manager()->breakHandler();
|
||||
bool updateNeeded = false;
|
||||
for (int index = 0; index != handler->size(); ++index) {
|
||||
BreakpointData *data = handler->at(index);
|
||||
@@ -432,18 +432,20 @@ static WatchData m_toolTip;
|
||||
static QPoint m_toolTipPos;
|
||||
static QHash<QString, WatchData> m_toolTipCache;
|
||||
|
||||
void ScriptEngine::setToolTipExpression(const QPoint &mousePos, TextEditor::ITextEditor *editor, int cursorPos)
|
||||
void ScriptEngine::setToolTipExpression(const QPoint &mousePos,
|
||||
TextEditor::ITextEditor *editor, int cursorPos)
|
||||
{
|
||||
Q_UNUSED(mousePos)
|
||||
Q_UNUSED(editor)
|
||||
Q_UNUSED(cursorPos)
|
||||
|
||||
if (q->status() != DebuggerInferiorStopped) {
|
||||
if (state() != InferiorStopped) {
|
||||
//SDEBUG("SUPPRESSING DEBUGGER TOOLTIP, INFERIOR NOT STOPPED");
|
||||
return;
|
||||
}
|
||||
// Check mime type and get expression (borrowing some C++ - functions)
|
||||
const QString javaScriptMimeType = QLatin1String(QtScriptEditor::Constants::C_QTSCRIPTEDITOR_MIMETYPE);
|
||||
const QString javaScriptMimeType =
|
||||
QLatin1String(QtScriptEditor::Constants::C_QTSCRIPTEDITOR_MIMETYPE);
|
||||
if (!editor->file() || editor->file()->mimeType() != javaScriptMimeType)
|
||||
return;
|
||||
|
||||
@@ -493,7 +495,7 @@ void ScriptEngine::setToolTipExpression(const QPoint &mousePos, TextEditor::ITex
|
||||
}
|
||||
|
||||
#if 0
|
||||
//if (m_manager->status() != DebuggerInferiorStopped)
|
||||
//if (m_manager->status() != InferiorStopped)
|
||||
// return;
|
||||
|
||||
// FIXME: 'exp' can contain illegal characters
|
||||
@@ -534,7 +536,7 @@ void ScriptEngine::maybeBreakNow(bool byFunction)
|
||||
if (byFunction)
|
||||
lineNumber = info.functionStartLineNumber();
|
||||
|
||||
BreakHandler *handler = qq->breakHandler();
|
||||
BreakHandler *handler = manager()->breakHandler();
|
||||
|
||||
if (m_stopOnNextLine) {
|
||||
m_stopOnNextLine = false;
|
||||
@@ -567,18 +569,20 @@ void ScriptEngine::maybeBreakNow(bool byFunction)
|
||||
data->updateMarker();
|
||||
}
|
||||
|
||||
qq->notifyInferiorStopped();
|
||||
setState(InferiorStopped);
|
||||
showStatusMessage(tr("Stopped."), 5000);
|
||||
|
||||
StackFrame frame;
|
||||
frame.file = fileName;
|
||||
frame.line = lineNumber;
|
||||
q->gotoLocation(frame, true);
|
||||
manager()->gotoLocation(frame, true);
|
||||
updateLocals();
|
||||
}
|
||||
|
||||
void ScriptEngine::updateLocals()
|
||||
{
|
||||
QScriptContext *context = m_scriptEngine->currentContext();
|
||||
qq->watchHandler()->beginCycle();
|
||||
manager()->watchHandler()->beginCycle();
|
||||
//SDEBUG("UPDATE LOCALS");
|
||||
|
||||
//
|
||||
@@ -601,7 +605,7 @@ void ScriptEngine::updateLocals()
|
||||
//frame.address = ...;
|
||||
stackFrames.append(frame);
|
||||
}
|
||||
qq->stackHandler()->setFrames(stackFrames);
|
||||
manager()->stackHandler()->setFrames(stackFrames);
|
||||
|
||||
//
|
||||
// Build locals
|
||||
@@ -610,13 +614,13 @@ void ScriptEngine::updateLocals()
|
||||
data.iname = "local";
|
||||
data.name = "local";
|
||||
data.scriptValue = context->activationObject();
|
||||
qq->watchHandler()->beginCycle();
|
||||
manager()->watchHandler()->beginCycle();
|
||||
updateSubItem(data);
|
||||
qq->watchHandler()->endCycle();
|
||||
manager()->watchHandler()->endCycle();
|
||||
|
||||
// FIXME: Use an extra thread. This here is evil
|
||||
m_stopped = true;
|
||||
q->showStatusMessage(tr("Stopped."), 5000);
|
||||
showStatusMessage(tr("Stopped."), 5000);
|
||||
while (m_stopped) {
|
||||
//SDEBUG("LOOPING");
|
||||
QApplication::processEvents();
|
||||
@@ -627,7 +631,7 @@ void ScriptEngine::updateLocals()
|
||||
void ScriptEngine::updateWatchData(const WatchData &data)
|
||||
{
|
||||
updateSubItem(data);
|
||||
//qq->watchHandler()->rebuildModel();
|
||||
//manager()->watchHandler()->rebuildModel();
|
||||
}
|
||||
|
||||
void ScriptEngine::updateSubItem(const WatchData &data0)
|
||||
@@ -689,7 +693,7 @@ void ScriptEngine::updateSubItem(const WatchData &data0)
|
||||
data.setValue("<unknown>");
|
||||
data.setHasChildren(false);
|
||||
}
|
||||
qq->watchHandler()->insertData(data);
|
||||
manager()->watchHandler()->insertData(data);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -703,17 +707,17 @@ void ScriptEngine::updateSubItem(const WatchData &data0)
|
||||
data1.exp = it.name();
|
||||
data1.name = it.name();
|
||||
data1.scriptValue = it.value();
|
||||
if (qq->watchHandler()->isExpandedIName(data1.iname))
|
||||
if (manager()->watchHandler()->isExpandedIName(data1.iname))
|
||||
data1.setChildrenNeeded();
|
||||
else
|
||||
data1.setChildrenUnneeded();
|
||||
qq->watchHandler()->insertData(data1);
|
||||
manager()->watchHandler()->insertData(data1);
|
||||
++numChild;
|
||||
}
|
||||
//SDEBUG(" ... CHILDREN: " << numChild);
|
||||
data.setHasChildren(numChild > 0);
|
||||
data.setChildrenUnneeded();
|
||||
qq->watchHandler()->insertData(data);
|
||||
manager()->watchHandler()->insertData(data);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -726,16 +730,16 @@ void ScriptEngine::updateSubItem(const WatchData &data0)
|
||||
}
|
||||
data.setHasChildren(numChild > 0);
|
||||
//SDEBUG(" ... CHILDCOUNT: " << numChild);
|
||||
qq->watchHandler()->insertData(data);
|
||||
manager()->watchHandler()->insertData(data);
|
||||
return;
|
||||
}
|
||||
|
||||
QTC_ASSERT(false, return);
|
||||
}
|
||||
|
||||
IDebuggerEngine *createScriptEngine(DebuggerManager *parent)
|
||||
IDebuggerEngine *createScriptEngine(DebuggerManager *manager)
|
||||
{
|
||||
return new ScriptEngine(parent);
|
||||
return new ScriptEngine(manager);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -52,8 +52,6 @@ QT_END_NAMESPACE
|
||||
namespace Debugger {
|
||||
namespace Internal {
|
||||
|
||||
class DebuggerManager;
|
||||
class IDebuggerManagerAccessForEngines;
|
||||
class ScriptAgent;
|
||||
class WatchData;
|
||||
|
||||
@@ -62,7 +60,7 @@ class ScriptEngine : public IDebuggerEngine
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ScriptEngine(DebuggerManager *parent);
|
||||
ScriptEngine(DebuggerManager *manager);
|
||||
~ScriptEngine();
|
||||
|
||||
private:
|
||||
@@ -74,7 +72,8 @@ private:
|
||||
void nextIExec();
|
||||
|
||||
void shutdown();
|
||||
void setToolTipExpression(const QPoint &mousePos, TextEditor::ITextEditor *editor, int cursorPos);
|
||||
void setToolTipExpression(const QPoint &mousePos,
|
||||
TextEditor::ITextEditor *editor, int cursorPos);
|
||||
void startDebugger(const DebuggerStartParametersPtr &sp);
|
||||
|
||||
void exitDebugger();
|
||||
@@ -111,8 +110,6 @@ private:
|
||||
|
||||
private:
|
||||
friend class ScriptAgent;
|
||||
DebuggerManager *q;
|
||||
IDebuggerManagerAccessForEngines *qq;
|
||||
|
||||
QScriptEngine *m_scriptEngine;
|
||||
QString m_scriptContents;
|
||||
|
||||
@@ -107,11 +107,9 @@ QString TcfEngine::TcfCommand::toString() const
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
TcfEngine::TcfEngine(DebuggerManager *parent)
|
||||
TcfEngine::TcfEngine(DebuggerManager *manager)
|
||||
: IDebuggerEngine(manager)
|
||||
{
|
||||
q = parent;
|
||||
qq = parent->engineInterface();
|
||||
|
||||
m_congestion = 0;
|
||||
m_inAir = 0;
|
||||
|
||||
@@ -136,13 +134,13 @@ TcfEngine::TcfEngine(DebuggerManager *parent)
|
||||
// thism SLOT(socketStateChanged(QAbstractSocket::SocketState)));
|
||||
|
||||
connect(this, SIGNAL(tcfOutputAvailable(int,QString)),
|
||||
q, SLOT(showDebuggerOutput(int,QString)),
|
||||
m_manager, SLOT(showDebuggerOutput(int,QString)),
|
||||
Qt::QueuedConnection);
|
||||
connect(this, SIGNAL(tcfInputAvailable(int,QString)),
|
||||
q, SLOT(showDebuggerInput(int,QString)),
|
||||
m_manager, SLOT(showDebuggerInput(int,QString)),
|
||||
Qt::QueuedConnection);
|
||||
connect(this, SIGNAL(applicationOutputAvailable(QString)),
|
||||
q, SLOT(showApplicationOutput(QString)),
|
||||
m_manager, SLOT(showApplicationOutput(QString)),
|
||||
Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
@@ -169,7 +167,7 @@ void TcfEngine::socketReadyRead()
|
||||
|
||||
void TcfEngine::socketConnected()
|
||||
{
|
||||
q->showStatusMessage("Socket connected.");
|
||||
showStatusMessage("Socket connected.");
|
||||
m_socket->waitForConnected(2000);
|
||||
//sendCommand("Locator", "redirect", "ID");
|
||||
}
|
||||
@@ -183,8 +181,8 @@ void TcfEngine::socketError(QAbstractSocket::SocketError)
|
||||
{
|
||||
QString msg = tr("%1.").arg(m_socket->errorString());
|
||||
//QMessageBox::critical(q->mainWindow(), tr("Error"), msg);
|
||||
q->showStatusMessage(msg);
|
||||
qq->notifyInferiorExited();
|
||||
showStatusMessage(msg);
|
||||
manager()->notifyInferiorExited();
|
||||
}
|
||||
|
||||
void TcfEngine::executeDebuggerCommand(const QString &command)
|
||||
@@ -213,12 +211,13 @@ void TcfEngine::shutdown()
|
||||
void TcfEngine::exitDebugger()
|
||||
{
|
||||
SDEBUG("TcfEngine::exitDebugger()");
|
||||
qq->notifyInferiorExited();
|
||||
manager()->notifyInferiorExited();
|
||||
}
|
||||
|
||||
void TcfEngine::startDebugger(const DebuggerStartParametersPtr &sp)
|
||||
{
|
||||
qq->notifyInferiorRunningRequested();
|
||||
setState(InferiorRunningRequested);
|
||||
showStatusMessage(tr("Running requested..."), 5000);
|
||||
const int pos = sp->remoteChannel.indexOf(QLatin1Char(':'));
|
||||
const QString host = sp->remoteChannel.left(pos);
|
||||
const quint16 port = sp->remoteChannel.mid(pos + 1).toInt();
|
||||
@@ -558,7 +557,7 @@ void TcfEngine::updateLocals()
|
||||
void TcfEngine::updateWatchData(const WatchData &)
|
||||
{
|
||||
//qq->watchHandler()->rebuildModel();
|
||||
q->showStatusMessage(tr("Stopped."), 5000);
|
||||
showStatusMessage(tr("Stopped."), 5000);
|
||||
}
|
||||
|
||||
void TcfEngine::updateSubItem(const WatchData &data0)
|
||||
@@ -567,9 +566,9 @@ void TcfEngine::updateSubItem(const WatchData &data0)
|
||||
QTC_ASSERT(false, return);
|
||||
}
|
||||
|
||||
IDebuggerEngine *createTcfEngine(DebuggerManager *parent)
|
||||
IDebuggerEngine *createTcfEngine(DebuggerManager *manager)
|
||||
{
|
||||
return new TcfEngine(parent);
|
||||
return new TcfEngine(manager);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -54,8 +54,6 @@ QT_END_NAMESPACE
|
||||
namespace Debugger {
|
||||
namespace Internal {
|
||||
|
||||
class DebuggerManager;
|
||||
class IDebuggerManagerAccessForEngines;
|
||||
class ScriptAgent;
|
||||
class WatchData;
|
||||
|
||||
@@ -163,8 +161,6 @@ private:
|
||||
void acknowledgeResult();
|
||||
int m_inAir;
|
||||
|
||||
DebuggerManager *q;
|
||||
IDebuggerManagerAccessForEngines *qq;
|
||||
QTcpSocket *m_socket;
|
||||
QByteArray m_inbuffer;
|
||||
QList<QByteArray> m_services;
|
||||
|
||||
Reference in New Issue
Block a user