forked from qt-creator/qt-creator
Debugger: Restrict LocationMark dragging
... to engines that actually support JumpToLine and make it work in disassembler views. Change-Id: I10368ea719587caa7c4f33665eff57c2bf300d84 Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
@@ -46,6 +46,7 @@
|
|||||||
#include "gdb/gdbengine.h" // REMOVE
|
#include "gdb/gdbengine.h" // REMOVE
|
||||||
#include "registerhandler.h"
|
#include "registerhandler.h"
|
||||||
#include "sourcefileshandler.h"
|
#include "sourcefileshandler.h"
|
||||||
|
#include "sourceutils.h"
|
||||||
#include "stackhandler.h"
|
#include "stackhandler.h"
|
||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
#include "threadshandler.h"
|
#include "threadshandler.h"
|
||||||
@@ -134,29 +135,26 @@ Location::Location(const StackFrame &frame, bool marker)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class LocationMark : public TextMark
|
LocationMark::LocationMark(DebuggerEngine *engine, const QString &file, int line)
|
||||||
{
|
|
||||||
public:
|
|
||||||
LocationMark(DebuggerEngine *engine, const QString &file, int line)
|
|
||||||
: TextMark(file, line, Constants::TEXT_MARK_CATEGORY_LOCATION), m_engine(engine)
|
: TextMark(file, line, Constants::TEXT_MARK_CATEGORY_LOCATION), m_engine(engine)
|
||||||
{}
|
{
|
||||||
|
setIcon(Internal::locationMarkIcon());
|
||||||
|
setPriority(TextMark::HighPriority);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
bool LocationMark::isDraggable() const
|
||||||
bool isDraggable() const { return true; }
|
{
|
||||||
|
return m_engine->hasCapability(JumpToLineCapability);
|
||||||
|
}
|
||||||
|
|
||||||
void dragToLine(int line)
|
void LocationMark::dragToLine(int line)
|
||||||
{
|
{
|
||||||
if (m_engine) {
|
if (m_engine) {
|
||||||
ContextData data;
|
if (BaseTextEditor *textEditor = BaseTextEditor::currentTextEditor())
|
||||||
data.fileName = fileName();
|
m_engine->executeJumpToLine(getLocationContext(textEditor->textDocument(), line));
|
||||||
data.lineNumber = line;
|
|
||||||
m_engine->executeJumpToLine(data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointer<DebuggerEngine> m_engine;
|
|
||||||
};
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// DebuggerEnginePrivate
|
// DebuggerEnginePrivate
|
||||||
@@ -632,11 +630,8 @@ void DebuggerEngine::gotoLocation(const Location &loc)
|
|||||||
if (newEditor)
|
if (newEditor)
|
||||||
editor->document()->setProperty(Constants::OPENED_BY_DEBUGGER, true);
|
editor->document()->setProperty(Constants::OPENED_BY_DEBUGGER, true);
|
||||||
|
|
||||||
if (loc.needsMarker()) {
|
if (loc.needsMarker())
|
||||||
d->m_locationMark.reset(new LocationMark(this, file, line));
|
d->m_locationMark.reset(new LocationMark(this, file, line));
|
||||||
d->m_locationMark->setIcon(Internal::locationMarkIcon());
|
|
||||||
d->m_locationMark->setPriority(TextMark::HighPriority);
|
|
||||||
}
|
|
||||||
|
|
||||||
//qDebug() << "MEMORY: " << d->m_memoryAgent.hasVisibleEditor();
|
//qDebug() << "MEMORY: " << d->m_memoryAgent.hasVisibleEditor();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
#include "debuggerstartparameters.h"
|
#include "debuggerstartparameters.h"
|
||||||
|
|
||||||
#include <projectexplorer/devicesupport/idevice.h>
|
#include <projectexplorer/devicesupport/idevice.h>
|
||||||
|
#include <texteditor/textmark.h>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
@@ -446,6 +447,18 @@ private:
|
|||||||
DebuggerEnginePrivate *d;
|
DebuggerEnginePrivate *d;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class LocationMark : public TextEditor::TextMark
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LocationMark(DebuggerEngine *engine, const QString &file, int line);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool isDraggable() const;
|
||||||
|
void dragToLine(int line);
|
||||||
|
|
||||||
|
QPointer<DebuggerEngine> m_engine;
|
||||||
|
};
|
||||||
|
|
||||||
DebuggerEngine *createEngine(DebuggerEngineType et, const DebuggerRunParameters &rp, QStringList *errors);
|
DebuggerEngine *createEngine(DebuggerEngineType et, const DebuggerRunParameters &rp, QStringList *errors);
|
||||||
|
|
||||||
DebuggerRunControl *createAndScheduleRun(const DebuggerRunParameters &rp, const ProjectExplorer::Kit *kit);
|
DebuggerRunControl *createAndScheduleRun(const DebuggerRunParameters &rp, const ProjectExplorer::Kit *kit);
|
||||||
|
|||||||
@@ -552,25 +552,6 @@ static Kit *findUniversalCdbKit()
|
|||||||
return KitManager::find(cdbMatcher());
|
return KitManager::find(cdbMatcher());
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool currentTextEditorPosition(ContextData *data)
|
|
||||||
{
|
|
||||||
BaseTextEditor *textEditor = BaseTextEditor::currentTextEditor();
|
|
||||||
if (!textEditor)
|
|
||||||
return false;
|
|
||||||
const TextDocument *document = textEditor->textDocument();
|
|
||||||
QTC_ASSERT(document, return false);
|
|
||||||
data->fileName = document->filePath().toString();
|
|
||||||
if (document->property(Constants::OPENED_WITH_DISASSEMBLY).toBool()) {
|
|
||||||
int lineNumber = textEditor->currentLine();
|
|
||||||
QString line = textEditor->textDocument()->plainText()
|
|
||||||
.section(QLatin1Char('\n'), lineNumber - 1, lineNumber - 1);
|
|
||||||
data->address = DisassemblerLine::addressFromDisassemblyLine(line);
|
|
||||||
} else {
|
|
||||||
data->lineNumber = textEditor->currentLine();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// DebuggerPluginPrivate
|
// DebuggerPluginPrivate
|
||||||
@@ -848,17 +829,17 @@ public slots:
|
|||||||
void handleExecJumpToLine()
|
void handleExecJumpToLine()
|
||||||
{
|
{
|
||||||
currentEngine()->resetLocation();
|
currentEngine()->resetLocation();
|
||||||
ContextData data;
|
if (BaseTextEditor *textEditor = BaseTextEditor::currentTextEditor())
|
||||||
if (currentTextEditorPosition(&data))
|
currentEngine()->executeJumpToLine(getLocationContext(textEditor->textDocument(),
|
||||||
currentEngine()->executeJumpToLine(data);
|
textEditor->currentLine()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleExecRunToLine()
|
void handleExecRunToLine()
|
||||||
{
|
{
|
||||||
currentEngine()->resetLocation();
|
currentEngine()->resetLocation();
|
||||||
ContextData data;
|
if (BaseTextEditor *textEditor = BaseTextEditor::currentTextEditor())
|
||||||
if (currentTextEditorPosition(&data))
|
currentEngine()->executeRunToLine(getLocationContext(textEditor->textDocument(),
|
||||||
currentEngine()->executeRunToLine(data);
|
textEditor->currentLine()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleExecRunToSelectedFunction()
|
void handleExecRunToSelectedFunction()
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ typedef QPair<FrameKey, DisassemblerLines> CacheEntry;
|
|||||||
class DisassemblerAgentPrivate
|
class DisassemblerAgentPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DisassemblerAgentPrivate();
|
DisassemblerAgentPrivate(DebuggerEngine *engine);
|
||||||
~DisassemblerAgentPrivate();
|
~DisassemblerAgentPrivate();
|
||||||
void configureMimeType();
|
void configureMimeType();
|
||||||
DisassemblerLines contentsAtCurrentLocation() const;
|
DisassemblerLines contentsAtCurrentLocation() const;
|
||||||
@@ -107,22 +107,20 @@ public:
|
|||||||
QPointer<TextDocument> document;
|
QPointer<TextDocument> document;
|
||||||
Location location;
|
Location location;
|
||||||
QPointer<DebuggerEngine> engine;
|
QPointer<DebuggerEngine> engine;
|
||||||
TextMark locationMark;
|
LocationMark locationMark;
|
||||||
QList<TextMark *> breakpointMarks;
|
QList<TextMark *> breakpointMarks;
|
||||||
QList<CacheEntry> cache;
|
QList<CacheEntry> cache;
|
||||||
QString mimeType;
|
QString mimeType;
|
||||||
bool resetLocationScheduled;
|
bool resetLocationScheduled;
|
||||||
};
|
};
|
||||||
|
|
||||||
DisassemblerAgentPrivate::DisassemblerAgentPrivate()
|
DisassemblerAgentPrivate::DisassemblerAgentPrivate(DebuggerEngine *engine)
|
||||||
: document(0),
|
: document(0),
|
||||||
locationMark(QString(), 0, Constants::TEXT_MARK_CATEGORY_LOCATION),
|
engine(engine),
|
||||||
|
locationMark(engine, QString(), 0),
|
||||||
mimeType(_("text/x-qtcreator-generic-asm")),
|
mimeType(_("text/x-qtcreator-generic-asm")),
|
||||||
resetLocationScheduled(false)
|
resetLocationScheduled(false)
|
||||||
{
|
{}
|
||||||
locationMark.setIcon(Internal::locationMarkIcon());
|
|
||||||
locationMark.setPriority(TextMark::HighPriority);
|
|
||||||
}
|
|
||||||
|
|
||||||
DisassemblerAgentPrivate::~DisassemblerAgentPrivate()
|
DisassemblerAgentPrivate::~DisassemblerAgentPrivate()
|
||||||
{
|
{
|
||||||
@@ -157,10 +155,8 @@ DisassemblerLines DisassemblerAgentPrivate::contentsAtCurrentLocation() const
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
DisassemblerAgent::DisassemblerAgent(DebuggerEngine *engine)
|
DisassemblerAgent::DisassemblerAgent(DebuggerEngine *engine)
|
||||||
: QObject(0), d(new DisassemblerAgentPrivate)
|
: d(new DisassemblerAgentPrivate(engine))
|
||||||
{
|
{}
|
||||||
d->engine = engine;
|
|
||||||
}
|
|
||||||
|
|
||||||
DisassemblerAgent::~DisassemblerAgent()
|
DisassemblerAgent::~DisassemblerAgent()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,6 +30,9 @@
|
|||||||
|
|
||||||
#include "sourceutils.h"
|
#include "sourceutils.h"
|
||||||
|
|
||||||
|
#include "debuggerinternalconstants.h"
|
||||||
|
#include "debuggerengine.h"
|
||||||
|
#include "disassemblerlines.h"
|
||||||
#include "watchdata.h"
|
#include "watchdata.h"
|
||||||
#include "watchutils.h"
|
#include "watchutils.h"
|
||||||
|
|
||||||
@@ -333,5 +336,19 @@ QString fixCppExpression(const QString &expIn)
|
|||||||
return removeObviousSideEffects(exp);
|
return removeObviousSideEffects(exp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ContextData getLocationContext(TextDocument *document, int lineNumber)
|
||||||
|
{
|
||||||
|
ContextData data;
|
||||||
|
QTC_ASSERT(document, return data);
|
||||||
|
data.fileName = document->filePath().toString();
|
||||||
|
if (document->property(Constants::OPENED_WITH_DISASSEMBLY).toBool()) {
|
||||||
|
QString line = document->plainText().section(QLatin1Char('\n'), lineNumber - 1, lineNumber - 1);
|
||||||
|
data.address = DisassemblerLine::addressFromDisassemblyLine(line);
|
||||||
|
} else {
|
||||||
|
data.lineNumber = lineNumber;
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Debugger
|
} // namespace Debugger
|
||||||
|
|||||||
@@ -33,12 +33,18 @@
|
|||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
namespace TextEditor { class TextEditorWidget; }
|
namespace TextEditor {
|
||||||
|
class TextDocument;
|
||||||
|
class TextEditorWidget;
|
||||||
|
}
|
||||||
|
|
||||||
namespace CPlusPlus { class Snapshot; }
|
namespace CPlusPlus { class Snapshot; }
|
||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
class ContextData;
|
||||||
|
|
||||||
// Editor tooltip support
|
// Editor tooltip support
|
||||||
QString cppExpressionAt(TextEditor::TextEditorWidget *editorWidget, int pos,
|
QString cppExpressionAt(TextEditor::TextEditorWidget *editorWidget, int pos,
|
||||||
int *line, int *column, QString *function = 0,
|
int *line, int *column, QString *function = 0,
|
||||||
@@ -53,6 +59,8 @@ bool getUninitializedVariables(const CPlusPlus::Snapshot &snapshot,
|
|||||||
const QString &function, const QString &file, int line,
|
const QString &function, const QString &file, int line,
|
||||||
QStringList *uninitializedVariables);
|
QStringList *uninitializedVariables);
|
||||||
|
|
||||||
|
ContextData getLocationContext(TextEditor::TextDocument *document, int lineNumber);
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Debugger
|
} // namespace Debugger
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user