Commit 7a920e46 authored by Erik Verbruggen's avatar Erik Verbruggen
Browse files

Merge branch 'master' of git@scm.dev.nokia.troll.no:creator/mainline

parents 78dbeb4f e36d27d6
......@@ -1276,7 +1276,7 @@ QString CPPEditor::autoComplete(QTextCursor &cursor, const QString &textToInsert
const bool checkBlockEnd = m_allowSkippingOfBlockEnd;
m_allowSkippingOfBlockEnd = false; // consume blockEnd.
if (!contextAllowsAutoParentheses(cursor))
if (!contextAllowsAutoParentheses(cursor, textToInsert))
return QString();
QString text = textToInsert;
......@@ -1374,9 +1374,14 @@ int CPPEditor::paragraphSeparatorAboutToBeInserted(QTextCursor &cursor)
return 0;
}
bool CPPEditor::contextAllowsAutoParentheses(const QTextCursor &cursor) const
bool CPPEditor::contextAllowsAutoParentheses(const QTextCursor &cursor,
const QString &textToInsert) const
{
if (! MatchingText::shouldInsertMatchingText(cursor))
QChar ch;
if (! textToInsert.isEmpty())
ch = textToInsert.at(0);
if (! (MatchingText::shouldInsertMatchingText(cursor) || ch == QLatin1Char('\'') || ch == QLatin1Char('"')))
return false;
CPlusPlus::TokenUnderCursor tokenUnderCursor;
......
......@@ -217,7 +217,8 @@ protected:
bool autoBackspace(QTextCursor &cursor);
int paragraphSeparatorAboutToBeInserted(QTextCursor &cursor);
bool contextAllowsAutoParentheses(const QTextCursor &cursor) const;
bool contextAllowsAutoParentheses(const QTextCursor &cursor,
const QString &textToInsert = QString()) const;
private Q_SLOTS:
void updateFileName();
......
......@@ -58,9 +58,9 @@
#include <QtCore/QDate>
#include <QtCore/QDir>
#include <QtCore/QFileInfo>
#include <QtCore/QTemporaryFile>
#include <QtCore/QTextCodec>
#include <QtCore/QtPlugin>
#include <QtCore/QTemporaryFile>
#include <QtGui/QAction>
#include <QtGui/QMainWindow>
#include <QtGui/QMenu>
......@@ -151,7 +151,6 @@ CVSPlugin *CVSPlugin::m_cvsPluginInstance = 0;
CVSPlugin::CVSPlugin() :
m_versionControl(0),
m_changeTmpFile(0),
m_projectExplorer(0),
m_addAction(0),
m_deleteAction(0),
......@@ -174,18 +173,20 @@ CVSPlugin::CVSPlugin() :
CVSPlugin::~CVSPlugin()
{
cleanChangeTmpFile();
cleanCommitMessageFile();
}
void CVSPlugin::cleanChangeTmpFile()
void CVSPlugin::cleanCommitMessageFile()
{
if (m_changeTmpFile) {
if (m_changeTmpFile->isOpen())
m_changeTmpFile->close();
delete m_changeTmpFile;
m_changeTmpFile = 0;
if (!m_commitMessageFileName.isEmpty()) {
QFile::remove(m_commitMessageFileName);
m_commitMessageFileName.clear();
}
}
bool CVSPlugin::isCommitEditorOpen() const
{
return !m_commitMessageFileName.isEmpty();
}
static const VCSBase::VCSBaseSubmitEditorParameters submitParameters = {
CVS::Constants::CVS_SUBMIT_MIMETYPE,
......@@ -383,7 +384,7 @@ void CVSPlugin::extensionsInitialized()
bool CVSPlugin::editorAboutToClose(Core::IEditor *iEditor)
{
if (!m_changeTmpFile || !iEditor || qstrcmp(Constants::CVSCOMMITEDITOR, iEditor->kind()))
if (!iEditor || !isCommitEditorOpen() || qstrcmp(Constants::CVSCOMMITEDITOR, iEditor->kind()))
return true;
Core::IFile *fileIFace = iEditor->file();
......@@ -394,7 +395,7 @@ bool CVSPlugin::editorAboutToClose(Core::IEditor *iEditor)
// Submit editor closing. Make it write out the commit message
// and retrieve files
const QFileInfo editorFile(fileIFace->fileName());
const QFileInfo changeFile(m_changeTmpFile->fileName());
const QFileInfo changeFile(m_commitMessageFileName);
if (editorFile.absoluteFilePath() != changeFile.absoluteFilePath())
return true; // Oops?!
......@@ -411,7 +412,7 @@ bool CVSPlugin::editorAboutToClose(Core::IEditor *iEditor)
case VCSBase::VCSBaseSubmitEditor::SubmitCanceled:
return false; // Keep editing and change file
case VCSBase::VCSBaseSubmitEditor::SubmitDiscarded:
cleanChangeTmpFile();
cleanCommitMessageFile();
return true; // Cancel all
default:
break;
......@@ -424,10 +425,10 @@ bool CVSPlugin::editorAboutToClose(Core::IEditor *iEditor)
Core::ICore::instance()->fileManager()->blockFileChange(fileIFace);
fileIFace->save();
Core::ICore::instance()->fileManager()->unblockFileChange(fileIFace);
closeEditor= commit(m_changeTmpFile->fileName(), fileList);
closeEditor= commit(m_commitMessageFileName, fileList);
}
if (closeEditor)
cleanChangeTmpFile();
cleanCommitMessageFile();
return closeEditor;
}
......@@ -639,7 +640,7 @@ void CVSPlugin::startCommit(const QString &source)
return;
if (VCSBase::VCSBaseSubmitEditor::raiseSubmitEditor())
return;
if (m_changeTmpFile) {
if (isCommitEditorOpen()) {
VCSBase::VCSBaseOutputWindow::instance()->appendWarning(tr("Another commit is currently being executed."));
return;
}
......@@ -674,22 +675,21 @@ void CVSPlugin::startCommit(const QString &source)
}
// Create a new submit change file containing the submit template
QTemporaryFile *changeTmpFile = new QTemporaryFile(this);
changeTmpFile->setAutoRemove(true);
if (!changeTmpFile->open()) {
VCSBase::VCSBaseOutputWindow::instance()->appendError(tr("Cannot create temporary file: %1").arg(changeTmpFile->errorString()));
delete changeTmpFile;
QTemporaryFile changeTmpFile;
changeTmpFile.setAutoRemove(false);
if (!changeTmpFile.open()) {
VCSBase::VCSBaseOutputWindow::instance()->appendError(tr("Cannot create temporary file: %1").arg(changeTmpFile.errorString()));
return;
}
m_changeTmpFile = changeTmpFile;
// TODO: Retrieve submit template from
const QString submitTemplate;
m_commitMessageFileName = changeTmpFile.fileName();
// Create a submit
m_changeTmpFile->write(submitTemplate.toUtf8());
m_changeTmpFile->flush();
m_changeTmpFile->close();
changeTmpFile.write(submitTemplate.toUtf8());
changeTmpFile.flush();
changeTmpFile.close();
// Create a submit editor and set file list
CVSSubmitEditor *editor = openCVSSubmitEditor(m_changeTmpFile->fileName());
CVSSubmitEditor *editor = openCVSSubmitEditor(m_commitMessageFileName);
editor->setStateList(statusOutput);
}
......
......@@ -39,7 +39,6 @@
QT_BEGIN_NAMESPACE
class QDir;
class QAction;
class QTemporaryFile;
class QTextCodec;
QT_END_NAMESPACE
......@@ -124,6 +123,7 @@ private slots:
void diffFiles(const QStringList &);
private:
bool isCommitEditorOpen() const;
QString currentFileName() const;
Core::IEditor * showOutputInEditor(const QString& title, const QString &output,
int editorType, const QString &source,
......@@ -149,11 +149,11 @@ private:
QStringList currentProjectsTopLevels(QString *name = 0) const;
void startCommit(const QString &file);
bool commit(const QString &messageFile, const QStringList &subVersionFileList);
void cleanChangeTmpFile();
void cleanCommitMessageFile();
CVSSettings m_settings;
Core::IVersionControl *m_versionControl;
QTemporaryFile *m_changeTmpFile;
QString m_commitMessageFileName;
ProjectExplorer::ProjectExplorerPlugin *m_projectExplorer;
......
......@@ -911,7 +911,8 @@ void DebuggerPlugin::extensionsInitialized()
void DebuggerPlugin::attachCmdLinePid()
{
m_manager->showStatusMessage(tr("Attaching to PID %1.").arg(m_cmdLineAttachPid));
const QString crashParameter = m_cmdLineWinCrashEvent ? QString::number(m_cmdLineWinCrashEvent) : QString();
const QString crashParameter =
m_cmdLineWinCrashEvent ? QString::number(m_cmdLineWinCrashEvent) : QString();
attachExternalApplication(m_cmdLineAttachPid, crashParameter);
}
......@@ -1092,10 +1093,16 @@ void DebuggerPlugin::gotoLocation(const StackFrame &frame, bool setMarker)
if (setMarker)
resetLocation();
} else {
TextEditor::BaseTextEditor::openEditorAt(frame.file, frame.line);
if (setMarker) {
resetLocation();
m_locationMark = new LocationMark(frame.file, frame.line);
static QString lastFile;
static int lastLine;
if (frame.line != lastLine || frame.file != lastFile) {
lastLine = frame.line;
lastFile = frame.file;
TextEditor::BaseTextEditor::openEditorAt(frame.file, frame.line);
if (setMarker) {
resetLocation();
m_locationMark = new LocationMark(frame.file, frame.line);
}
}
}
}
......@@ -1165,13 +1172,13 @@ void DebuggerPlugin::showSettingsDialog()
QLatin1String(Debugger::Constants::DEBUGGER_COMMON_SETTINGS_PAGE));
}
static QSharedPointer<RunConfiguration> activeRunConfiguration()
static RunConfigurationPtr activeRunConfiguration()
{
ProjectExplorer::Project *project =
ProjectExplorerPlugin::instance()->currentProject();
if (project)
return project->activeRunConfiguration();
return QSharedPointer<RunConfiguration>();
return RunConfigurationPtr();
}
void DebuggerPlugin::startExternalApplication()
......@@ -1197,7 +1204,7 @@ void DebuggerPlugin::startExternalApplication()
if (dlg.breakAtMain())
m_manager->breakByFunctionMain();
QSharedPointer<RunConfiguration> rc = activeRunConfiguration();
RunConfigurationPtr rc = activeRunConfiguration();
if (rc.isNull())
rc = DebuggerRunner::createDefaultRunConfiguration(sp->executable);
......@@ -1223,7 +1230,7 @@ void DebuggerPlugin::attachExternalApplication(qint64 pid, const QString &crashP
sp->attachPID = pid;
sp->crashParameter = crashParameter;
sp->startMode = crashParameter.isEmpty() ? AttachExternal : AttachCrashedExternal;
QSharedPointer<RunConfiguration> rc = activeRunConfiguration();
RunConfigurationPtr rc = activeRunConfiguration();
if (rc.isNull())
rc = DebuggerRunner::createDefaultRunConfiguration();
if (RunControl *runControl = m_debuggerRunner
......@@ -1248,7 +1255,7 @@ void DebuggerPlugin::attachCore()
sp->executable = dlg.executableFile();
sp->coreFile = dlg.coreFile();
sp->startMode = AttachCore;
QSharedPointer<RunConfiguration> rc = activeRunConfiguration();
RunConfigurationPtr rc = activeRunConfiguration();
if (rc.isNull())
rc = DebuggerRunner::createDefaultRunConfiguration();
if (RunControl *runControl = m_debuggerRunner
......@@ -1283,7 +1290,7 @@ void DebuggerPlugin::startRemoteApplication()
if (dlg.useServerStartScript())
sp->serverStartScript = dlg.serverStartScript();
QSharedPointer<RunConfiguration> rc = activeRunConfiguration();
RunConfigurationPtr rc = activeRunConfiguration();
if (rc.isNull())
rc = DebuggerRunner::createDefaultRunConfiguration();
if (RunControl *runControl = m_debuggerRunner
......@@ -1319,7 +1326,7 @@ void DebuggerPlugin::attachRemoteTcf()
if (dlg.useServerStartScript())
sp->serverStartScript = dlg.serverStartScript();
QSharedPointer<RunConfiguration> rc = activeRunConfiguration();
RunConfigurationPtr rc = activeRunConfiguration();
if (rc.isNull())
rc = DebuggerRunner::createDefaultRunConfiguration();
if (RunControl *runControl = m_debuggerRunner
......
......@@ -33,11 +33,33 @@
#include <QtCore/QObject>
#include <QtCore/QProcess>
#include "gdbengine.h"
namespace Debugger {
namespace Internal {
class GdbEngine;
enum GdbAdapterState
{
AdapterNotRunning,
AdapterStarting,
AdapterStarted,
AdapterStartFailed,
InferiorPreparing,
InferiorPrepared,
InferiorPreparationFailed,
InferiorStarting,
InferiorStarted,
InferiorStartFailed,
InferiorShuttingDown,
InferiorShutDown,
InferiorShutdownFailed,
AdapterShuttingDown,
//AdapterShutDown, // use AdapterNotRunning
AdapterShutdownFailed,
};
// AbstractGdbAdapter is inherited by PlainGdbAdapter used for local
// debugging and TrkGdbAdapter used for on-device debugging.
// In the PlainGdbAdapter case it's just a wrapper around a QProcess running
......@@ -48,36 +70,50 @@ class AbstractGdbAdapter : public QObject
Q_OBJECT
public:
AbstractGdbAdapter(QObject *parent = 0) : QObject(parent) {}
virtual void setEngine(GdbEngine *engine) { m_engine = engine; }
virtual void start(const QString &program, const QStringList &args,
QIODevice::OpenMode mode = QIODevice::ReadWrite) = 0;
virtual void kill() = 0;
virtual void terminate() = 0;
//virtual bool waitForStarted(int msecs = 30000) = 0;
virtual bool waitForFinished(int msecs = 30000) = 0;
virtual QProcess::ProcessState state() const = 0;
virtual QString errorString() const = 0;
AbstractGdbAdapter(GdbEngine *engine, QObject *parent = 0)
: QObject(parent), m_engine(engine), m_state(AdapterNotRunning)
{}
virtual QByteArray readAllStandardError() = 0;
virtual QByteArray readAllStandardOutput() = 0;
virtual qint64 write(const char *data) = 0;
virtual void setWorkingDirectory(const QString &dir) = 0;
virtual void setEnvironment(const QStringList &env) = 0;
virtual bool isAdapter() const = 0;
virtual bool isTrkAdapter() const = 0;
virtual void attach() = 0;
virtual void startAdapter(const DebuggerStartParametersPtr &sp) = 0;
virtual void prepareInferior() = 0;
virtual void startInferior() = 0;
virtual void interruptInferior() = 0;
virtual void shutdown() = 0;
signals:
void adapterStarted();
void adapterStartFailed(const QString &msg);
void adapterShutDown();
void adapterShutdownFailed(const QString &msg);
void adapterCrashed();
void inferiorPrepared();
void inferiorPreparationFailed(const QString &msg);
void inferiorStarted();
void inferiorStartFailed(const QString &msg);
void inferiorShutDown();
void inferiorShutdownFailed(const QString &msg);
void inferiorPidChanged(qint64 pid);
void error(QProcess::ProcessError);
void started();
void readyReadStandardOutput();
void readyReadStandardError();
void finished(int, QProcess::ExitStatus);
public:
virtual GdbAdapterState state() const { return m_state; }
protected:
GdbEngine *m_engine;
virtual void setState(GdbAdapterState state) { m_state = state; }
GdbEngine * const m_engine;
GdbAdapterState m_state;
};
} // namespace Internal
......
......@@ -2,9 +2,11 @@ include(../../../shared/trk/trk.pri)
HEADERS += \
$$PWD/abstractgdbadapter.h \
$$PWD/plaingdbadapter.h \
$$PWD/gdbmi.h \
$$PWD/gdbengine.h \
$$PWD/gdboptionspage.h \
$$PWD/remotegdbadapter.h \
$$PWD/trkgdbadapter.h \
$$PWD/trkoptions.h \
$$PWD/trkoptionswidget.h \
......@@ -14,10 +16,12 @@ SOURCES += \
$$PWD/gdbmi.cpp \
$$PWD/gdbengine.cpp \
$$PWD/gdboptionspage.cpp \
$$PWD/trkgdbadapter.cpp \
$$PWD/plaingdbadapter.cpp \
$$PWD/remotegdbadapter.cpp \
$$PWD/trkoptions.cpp \
$$PWD/trkoptionswidget.cpp \
$$PWD/trkoptionspage.cpp
$$PWD/trkoptionspage.cpp \
$$PWD/trkgdbadapter.cpp
FORMS += $$PWD/gdboptionspage.ui \
$$PWD/trkoptionswidget.ui
......
This diff is collapsed.
......@@ -33,11 +33,8 @@
#include "idebuggerengine.h"
#include "debuggermanager.h" // only for StartParameters
#include "gdbmi.h"
#include "abstractgdbadapter.h"
#include "outputcollector.h"
#include "watchutils.h"
#include <consoleprocess.h>
#include "outputcollector.h"
#include <QtCore/QByteArray>
#include <QtCore/QHash>
......@@ -45,6 +42,7 @@
#include <QtCore/QObject>
#include <QtCore/QProcess>
#include <QtCore/QPoint>
#include <QtCore/QSet>
#include <QtCore/QTextCodec>
#include <QtCore/QTime>
#include <QtCore/QVariant>
......@@ -58,7 +56,7 @@ QT_END_NAMESPACE
namespace Debugger {
namespace Internal {
class AbstractGdbAdapter;
class DebuggerManager;
class IDebuggerManagerAccessForEngines;
class GdbResultRecord;
......@@ -75,52 +73,14 @@ enum DebuggingHelperState
DebuggingHelperUnavailable,
};
class PlainGdbAdapter : public AbstractGdbAdapter
{
public:
PlainGdbAdapter(QObject *parent = 0)
: AbstractGdbAdapter(parent)
{
connect(&m_proc, SIGNAL(error(QProcess::ProcessError)),
this, SIGNAL(error(QProcess::ProcessError)));
connect(&m_proc, SIGNAL(readyReadStandardOutput()),
this, SIGNAL(readyReadStandardOutput()));
connect(&m_proc, SIGNAL(readyReadStandardError()),
this, SIGNAL(readyReadStandardError()));
connect(&m_proc, SIGNAL(started()),
this, SIGNAL(started()));
connect(&m_proc, SIGNAL(finished(int, QProcess::ExitStatus)),
this, SIGNAL(finished(int, QProcess::ExitStatus)));
}
void start(const QString &program, const QStringList &args,
QIODevice::OpenMode mode) { m_proc.start(program, args, mode); }
void kill() { m_proc.kill(); }
void terminate() { m_proc.terminate(); }
bool waitForStarted(int msecs) { return m_proc.waitForStarted(msecs); }
bool waitForFinished(int msecs) { return m_proc.waitForFinished(msecs); }
QProcess::ProcessState state() const { return m_proc.state(); }
QString errorString() const { return m_proc.errorString(); }
QByteArray readAllStandardError() { return m_proc.readAllStandardError(); }
QByteArray readAllStandardOutput() { return m_proc.readAllStandardOutput(); }
qint64 write(const char *data) { return m_proc.write(data); }
void setWorkingDirectory(const QString &dir) { m_proc.setWorkingDirectory(dir); }
void setEnvironment(const QStringList &env) { m_proc.setEnvironment(env); }
bool isAdapter() const { return false; }
void attach();
void interruptInferior();
private:
QProcess m_proc;
};
class GdbEngine : public IDebuggerEngine
{
Q_OBJECT
public:
GdbEngine(DebuggerManager *parent, AbstractGdbAdapter *gdbAdapter);
explicit GdbEngine(DebuggerManager *parent);
~GdbEngine();
void setGdbAdapter(AbstractGdbAdapter *adapter);
signals:
void gdbInputAvailable(int channel, const QString &msg);
......@@ -130,6 +90,7 @@ signals:
private:
friend class PlainGdbAdapter;
friend class TrkGdbAdapter;
friend class RemoteGdbAdapter;
const DebuggerStartParameters &startParameters() const
{ return *m_startParameters; }
......@@ -145,7 +106,6 @@ private:
void shutdown();
void setToolTipExpression(const QPoint &mousePos, TextEditor::ITextEditor *editor, int cursorPos);
void startDebugger(const DebuggerStartParametersPtr &sp);
Q_SLOT void startDebugger2();
void exitDebugger();
void exitDebugger2();
void detachDebugger();
......@@ -194,6 +154,7 @@ private:
int currentFrame() const;
bool supportsThreads() const;
void gotoLocation(const StackFrame &frame, bool setLocationMarker);
void initializeConnections();
void initializeVariables();
......@@ -216,14 +177,20 @@ public: // otherwise the Qt flag macros are unhappy
private:
typedef void (GdbEngine::*GdbCommandCallback)(const GdbResultRecord &record, const QVariant &cookie);
typedef void (GdbEngine::*GdbCommandCallback)
(const GdbResultRecord &record, const QVariant &cookie);
typedef void (AbstractGdbAdapter::*AdapterCallback)
(const GdbResultRecord &record, const QVariant &cookie);
struct GdbCommand
{
GdbCommand() : flags(0), callback(0), callbackName(0) {}
GdbCommand()
: flags(0), callback(0), adapterCallback(0), callbackName(0)
{}
int flags;
GdbCommandCallback callback;
AdapterCallback adapterCallback;
const char *callbackName;
QString command;
QVariant cookie;
......@@ -234,7 +201,7 @@ private:
// queue". resultNeeded == true increments m_pendingResults on
// send and decrements on receipt, effectively preventing
// watch model updates before everything is finished.
void flushCommand(GdbCommand &cmd);
void flushCommand(const GdbCommand &cmd);
void postCommand(const QString &command,
GdbCommandFlags flags,
GdbCommandCallback callback = 0,
......@@ -244,7 +211,16 @@ private:
GdbCommandCallback callback = 0,
const char *callbackName = 0,
const QVariant &cookie = QVariant());
void postCommand(const QString &command,
AdapterCallback callback,
const char *callbackName,
const QVariant &cookie = QVariant());
void postCommand(const QString &command,
GdbCommandFlags flags,
AdapterCallback callback,
const char *callbackName,
const QVariant &cookie = QVariant());
void postCommandHelper(const GdbCommand &cmd);
void setTokenBarrier();
void updateLocals();
......@@ -253,28 +229,35 @@ private slots:
void gdbProcError(QProcess::ProcessError error);
void readGdbStandardOutput();
void readGdbStandardError();
void readUploadStandardOutput();
void readUploadStandardError();
void readDebugeeOutput(const QByteArray &data);
void stubStarted();
void stubError(const QString &msg);
void uploadProcError(QProcess::ProcessError error);
void emitStartFailed();
void handleAdapterStarted();
void handleAdapterStartFailed(const QString &msg);
void handleInferiorPrepared();
void handleInferiorPreparationFailed(const QString &msg);
void handleInferiorStarted();
void handleInferiorStartFailed(const QString &msg);
void handleInferiorShutDown();
void handleInferiorShutdownFailed(const QString &msg);
void handleAdapterShutDown();
void handleAdapterShutdownFailed(const QString &msg);
private:
int terminationIndex(const QByteArray &buffer, int &length);
void handleResponse(const QByteArray &buff);
void handleStart(const GdbResultRecord &response, const QVariant &);
void handleAttach(const GdbResultRecord &, const QVariant &);
void handleStubAttached(const GdbResultRecord &, const QVariant &);
void handleAqcuiredInferior();
void handleAsyncOutput2(const GdbResultRecord &, const QVariant &cookie);
void handleAsyncOutput2(const GdbMi &data);
void handleAsyncOutput(const GdbMi &data);
void handleStop1(const GdbResultRecord &, const QVariant &cookie);
void handleStop2(const GdbResultRecord &, const QVariant &cookie);
void handleStop2(const GdbMi &data);
void handleResultRecord(const GdbResultRecord &response);
void handleFileExecAndSymbols(const GdbResultRecord &response, const QVariant &);