Commit df04e575 authored by hjk's avatar hjk

debugger: move more gui bit from engine to plugin

parent a53583d5
......@@ -93,6 +93,7 @@ using namespace TextEditor;
#endif
# define XSDEBUG(s) qDebug() << s
///////////////////////////////////////////////////////////////////////
//
// DebuggerStartParameters
......@@ -211,9 +212,6 @@ public:
~DebuggerEnginePrivate() {}
public slots:
void breakpointSetRemoveMarginActionTriggered();
void breakpointEnableDisableMarginActionTriggered();
void doSetupInferior();
void doRunEngine();
void doShutdownEngine();
......@@ -257,11 +255,6 @@ public slots:
m_runControl->bringApplicationToForeground(m_inferiorPid);
}
private slots:
void slotEditBreakpoint();
void slotRunToLine();
void slotJumpToLine();
public:
DebuggerState state() const { return m_state; }
......@@ -294,73 +287,6 @@ public:
bool m_isSlaveEngine;
};
// Retrieve file name and line and optionally address
// from the data set on the text editor context menu action.
static bool positionFromContextActionData(const QObject *sender,
QString *fileName,
int *lineNumber,
quint64 *address = 0)
{
if (const QAction *action = qobject_cast<const QAction *>(sender)) {
const QVariantList data = action->data().toList();
if (data.size() >= (address ? 3 : 2)) {
*fileName = data.front().toString();
*lineNumber = data.at(1).toInt();
if (address)
*address = data.at(2).toULongLong();
return true;
}
}
return false;
}
void DebuggerEnginePrivate::breakpointSetRemoveMarginActionTriggered()
{
QString fileName;
int lineNumber;
quint64 address;
if (positionFromContextActionData(sender(), &fileName, &lineNumber, &address))
m_engine->breakHandler()->toggleBreakpoint(fileName, lineNumber, address);
}
void DebuggerEnginePrivate::slotRunToLine()
{
// Run to line, file name and line number set as list.
QString fileName;
int lineNumber;
if (positionFromContextActionData(sender(), &fileName, &lineNumber)) {
m_engine->resetLocation();
m_engine->executeRunToLine(fileName, lineNumber);
}
}
void DebuggerEnginePrivate::slotJumpToLine()
{
QString fileName;
int lineNumber;
if (positionFromContextActionData(sender(), &fileName, &lineNumber))
m_engine->executeJumpToLine(fileName, lineNumber);
}
void DebuggerEnginePrivate::breakpointEnableDisableMarginActionTriggered()
{
QString fileName;
int lineNumber;
if (positionFromContextActionData(sender(), &fileName, &lineNumber))
m_engine->breakHandler()->toggleBreakpointEnabled(fileName, lineNumber);
}
void DebuggerEnginePrivate::slotEditBreakpoint()
{
const QAction *act = qobject_cast<QAction *>(sender());
QTC_ASSERT(act, return);
const QVariant data = act->data();
QTC_ASSERT(qVariantCanConvert<BreakpointData *>(data), return);
BreakpointData *breakPointData = qvariant_cast<BreakpointData *>(data);
BreakWindow::editBreakpoint(breakPointData, ICore::instance()->mainWindow());
}
//////////////////////////////////////////////////////////////////////
//
......
......@@ -253,11 +253,6 @@ public:
void breakByFunction(const QString &functionName);
void breakByFunctionMain();
void executeStepX();
void executeStepOutX();
void executeStepNextX();
void executeReturnX();
DebuggerState state() const;
DebuggerState lastGoodState() const;
DebuggerState targetState() const;
......
......@@ -409,11 +409,29 @@ static QToolButton *toolButton(QAction *action)
return button;
}
// Retrieve file name and line and optionally address
// from the data set on the text editor context menu action.
static bool positionFromContextActionData(const QObject *sender,
QString *fileName,
int *lineNumber,
quint64 *address = 0)
{
if (const QAction *action = qobject_cast<const QAction *>(sender)) {
const QVariantList data = action->data().toList();
if (data.size() >= (address ? 3 : 2)) {
*fileName = data.front().toString();
*lineNumber = data.at(1).toInt();
if (address)
*address = data.at(2).toULongLong();
return true;
}
}
return false;
}
namespace Debugger {
namespace Internal {
static const char *Role = "ROLE";
// FIXME: Outdated?
// The createCdbEngine function takes a list of options pages it can add to.
// This allows for having a "enabled" toggle on the page independently
......@@ -854,6 +872,25 @@ public:
DebuggerEngine *currentEngine() const { return m_currentEngine; }
public slots:
void selectThread(int index);
void breakpointSetRemoveMarginActionTriggered()
{
QString fileName;
int lineNumber;
quint64 address;
if (positionFromContextActionData(sender(), &fileName, &lineNumber, &address))
m_breakHandler->toggleBreakpoint(fileName, lineNumber, address);
}
void breakpointEnableDisableMarginActionTriggered()
{
QString fileName;
int lineNumber;
if (positionFromContextActionData(sender(), &fileName, &lineNumber))
m_breakHandler->toggleBreakpointEnabled(fileName, lineNumber);
}
void updateWatchersHeader(int section, int, int newSize)
{
m_watchersWindow->header()->resizeSection(section, newSize);
......@@ -988,8 +1025,17 @@ public slots:
currentEngine()->executeNext();
}
void handleExecStepOut() { resetLocation(); currentEngine()->executeStepOut(); }
void handleExecReturn() { resetLocation(); currentEngine()->executeReturn(); }
void handleExecStepOut()
{
resetLocation();
currentEngine()->executeStepOut();
}
void handleExecReturn()
{
resetLocation();
currentEngine()->executeReturn();
}
void handleExecJumpToLine()
{
......@@ -1011,6 +1057,33 @@ public slots:
currentEngine()->executeRunToFunction(); // FIXME: move code from engine here.
}
void slotEditBreakpoint()
{
const QAction *act = qobject_cast<QAction *>(sender());
QTC_ASSERT(act, return);
const QVariant data = act->data();
QTC_ASSERT(qVariantCanConvert<BreakpointData *>(data), return);
BreakpointData *breakPointData = qvariant_cast<BreakpointData *>(data);
BreakWindow::editBreakpoint(breakPointData, ICore::instance()->mainWindow());
}
void slotRunToLine()
{
// Run to line, file name and line number set as list.
QString fileName;
int lineNumber;
if (positionFromContextActionData(sender(), &fileName, &lineNumber))
handleExecRunToLine();
}
void slotJumpToLine()
{
QString fileName;
int lineNumber;
if (positionFromContextActionData(sender(), &fileName, &lineNumber))
currentEngine()->executeJumpToLine(fileName, lineNumber);
}
void handleAddToWatchWindow()
{
// Requires a selection, but that's the only case we want anyway.
......
......@@ -1310,13 +1310,13 @@ void GdbEngine::handleStopResponse(const GdbMi &data)
if (isLeavableFunction(funcName, fileName)) {
//showMessage(_("LEAVING ") + funcName);
++stepCounter;
executeStepOutX();
executeStepOut();
return;
}
if (isSkippableFunction(funcName, fileName)) {
//showMessage(_("SKIPPING ") + funcName);
++stepCounter;
executeStepX();
executeStep();
return;
}
//if (stepCounter)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment