Commit 32aeb579 authored by hjk's avatar hjk

Debugger: Simplify "debug last command"

Let the engine decide what to do. Less magic parsing, less code,
and survives cleaning the log view.

Change-Id: Ic94f27899d7986fb5ce3d24bb2edce8e6faf899c
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent 63c2656d
......@@ -118,7 +118,6 @@ public:
const QVector<Section> &sections) = 0;
virtual void openMemoryEditor() = 0;
virtual void languagesChanged() = 0;
virtual void executeDebuggerCommand(const QString &command, DebuggerLanguages languages) = 0;
virtual Utils::SavedAction *action(int code) const = 0;
virtual bool boolSetting(int code) const = 0;
......
......@@ -189,6 +189,7 @@ public:
virtual void setRegisterValue(int regnr, const QString &value);
virtual void addOptionPages(QList<Core::IOptionsPage*> *) const;
virtual bool hasCapability(unsigned cap) const = 0;
virtual void debugLastCommand() {}
virtual bool isSynchronous() const;
virtual QByteArray qtNamespace() const;
......@@ -205,6 +206,8 @@ public:
virtual void changeBreakpoint(BreakpointModelId id); // FIXME: make pure
virtual bool acceptsDebuggerCommands() const { return true; }
virtual void executeDebuggerCommand(const QString &command, DebuggerLanguages languages);
virtual void assignValueInDebugger(const Internal::WatchData *data,
const QString &expr, const QVariant &value);
virtual void selectThread(Internal::ThreadId threadId) = 0;
......@@ -347,7 +350,6 @@ protected:
virtual void executeRunToLine(const Internal::ContextData &data);
virtual void executeRunToFunction(const QString &functionName);
virtual void executeJumpToLine(const Internal::ContextData &data);
virtual void executeDebuggerCommand(const QString &command, DebuggerLanguages languages);
virtual void frameUp();
virtual void frameDown();
......
......@@ -931,7 +931,6 @@ public slots:
void aboutToUnloadSession();
void aboutToSaveSession();
void executeDebuggerCommand(const QString &command, DebuggerLanguages languages);
void coreShutdown();
#ifdef WITH_TESTS
......@@ -2449,14 +2448,6 @@ void DebuggerPluginPrivate::aboutToSaveSession()
m_breakHandler->saveSessionData();
}
void DebuggerPluginPrivate::executeDebuggerCommand(const QString &command, DebuggerLanguages languages)
{
if (currentEngine()->acceptsDebuggerCommands())
currentEngine()->executeDebuggerCommand(command, languages);
else
showStatusMessage(tr("User commands are not accepted in the current state."));
}
void DebuggerPluginPrivate::showStatusMessage(const QString &msg0, int timeout)
{
showMessage(msg0, LogStatus);
......
......@@ -5484,6 +5484,11 @@ QByteArray GdbEngine::dotEscape(QByteArray str)
return str;
}
void GdbEngine::debugLastCommand()
{
postCommand(m_lastDebuggableCommand, Discardable);
}
//
// Factory
//
......
......@@ -714,6 +714,9 @@ protected:
static QString msgConnectRemoteServerFailed(const QString &why);
static QByteArray dotEscape(QByteArray str);
void debugLastCommand();
QByteArray m_lastDebuggableCommand;
protected:
enum DumperHandling
{
......
......@@ -130,9 +130,15 @@ void GdbEngine::updateLocalsPython(const UpdateParameters &params)
if (!m_resultVarName.isEmpty())
resultVar = "resultvarname:" + m_resultVarName + ' ';
postCommand("bb options:" + options + " vars:" + params.varList + ' '
+ resultVar + expanded + " watchers:" + watchers.toHex() + cutOff,
Discardable, CB(handleStackFramePython), QVariant(params.tryPartial));
QByteArray cmd =
"bb options:" + options + " vars:" + params.varList + ' '
+ resultVar + expanded + " watchers:" + watchers.toHex() + cutOff;
m_lastDebuggableCommand =
"bb options:pe," + options + " vars:" + params.varList + ' '
+ resultVar + expanded + " watchers:" + watchers.toHex() + cutOff;
postCommand(cmd, Discardable, CB(handleStackFramePython), QVariant(params.tryPartial));
}
void GdbEngine::handleStackFramePython(const GdbResponse &response)
......
......@@ -433,27 +433,22 @@ LogWindow::LogWindow(QWidget *parent)
void LogWindow::executeLine()
{
m_ignoreNextInputEcho = true;
debuggerCore()->executeDebuggerCommand(m_inputText->textCursor().block().text(),
CppLanguage);
debuggerCore()->currentEngine()->
executeDebuggerCommand(m_inputText->textCursor().block().text(), CppLanguage);
}
void LogWindow::repeatLastCommand()
{
QTextCursor tc = m_inputText->textCursor();
QRegExp re = QRegExp(QLatin1String("^\\d+(bb options:)(.*)$"));
for (QTextBlock block = tc.block(); block.isValid(); block = block.previous()) {
QString line = block.text();
if (re.exactMatch(line)) {
QString cmd = re.cap(1) + QLatin1String("pe,") + re.cap(2);
debuggerCore()->executeDebuggerCommand(cmd, CppLanguage);
return;
}
}
debuggerCore()->currentEngine()->debugLastCommand();
}
void LogWindow::sendCommand()
{
debuggerCore()->executeDebuggerCommand(m_commandEdit->text(), CppLanguage);
DebuggerEngine *engine = debuggerCore()->currentEngine();
if (engine->acceptsDebuggerCommands())
engine->executeDebuggerCommand(m_commandEdit->text(), CppLanguage);
else
showOutput(LogError, tr("User commands are not accepted in the current state."));
}
void LogWindow::showOutput(int channel, const QString &output)
......
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