Commit b66a6741 authored by hjk's avatar hjk

debugger: enable breakpoint setting from a disassembler view

parent 0de7f23d
......@@ -756,36 +756,6 @@ void BreakHandler::appendBreakpoint(const BreakpointParameters &data)
scheduleSynchronization();
}
void BreakHandler::toggleBreakpoint(const QString &fileName, int lineNumber,
quint64 address /* = 0 */)
{
BreakpointId id(-1);
if (address) {
id = findBreakpointByAddress(address);
} else {
id = findBreakpointByFileAndLine(fileName, lineNumber, true);
if (id == BreakpointId(-1))
id = findBreakpointByFileAndLine(fileName, lineNumber, false);
}
if (id != BreakpointId(-1)) {
removeBreakpoint(id);
} else {
BreakpointParameters data;
if (address) {
data.type = BreakpointByAddress;
data.address = address;
} else {
data.type = BreakpointByFileAndLine;
data.fileName = fileName;
data.lineNumber = lineNumber;
}
appendBreakpoint(data);
}
debuggerCore()->synchronizeBreakpoints();
}
void BreakHandler::saveSessionData()
{
saveBreakpoints();
......
......@@ -88,7 +88,6 @@ public:
static QIcon pendingBreakPointIcon();
static QIcon emptyIcon();
void toggleBreakpoint(const QString &fileName, int lineNumber, quint64 address = 0);
BreakpointId findBreakpointByFileAndLine(const QString &fileName,
int lineNumber, bool useMarkerPosition = true);
BreakpointId findBreakpointByAddress(quint64 address) const;
......
......@@ -40,11 +40,11 @@
#include <coreplugin/mimedatabase.h>
#include <coreplugin/icore.h>
#include <texteditor/basetextdocument.h>
#include <texteditor/basetexteditor.h>
#include <texteditor/plaintexteditor.h>
#include <texteditor/basetextmark.h>
#include <texteditor/plaintexteditor.h>
#include <texteditor/texteditorconstants.h>
#include <texteditor/basetextdocument.h>
#include <utils/qtcassert.h>
......@@ -357,6 +357,11 @@ void DisassemblerViewAgent::setContents(const DisassemblerLines &contents)
d->editor->setProperty(Debugger::Constants::OPENED_BY_DEBUGGER, true);
d->editor->setProperty(Debugger::Constants::OPENED_WITH_DISASSEMBLY, true);
d->configureMimeType();
BaseTextEditor *baseTextEdit =
qobject_cast<BaseTextEditor *>(d->editor->widget());
if (baseTextEdit)
baseTextEdit->setRequestMarkEnabled(true);
}
editorManager->activateEditor(d->editor);
......
......@@ -431,8 +431,8 @@ static QToolButton *toolButton(QAction *action)
// 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)
static bool positionFromActionData(const QObject *sender,
QString *fileName, int *lineNumber, quint64 *address)
{
const QAction *action = qobject_cast<const QAction *>(sender);
QTC_ASSERT(action, return false);
......@@ -440,8 +440,7 @@ static bool positionFromContextActionData(const QObject *sender,
QTC_ASSERT(data.size() == 3, return false);
*fileName = data.front().toString();
*lineNumber = data.at(1).toInt();
if (address)
*address = data.at(2).toULongLong();
*address = data.at(2).toULongLong();
return true;
}
......@@ -910,8 +909,12 @@ public slots:
QString fileName;
int lineNumber;
quint64 address;
if (positionFromContextActionData(sender(), &fileName, &lineNumber, &address))
m_breakHandler->toggleBreakpoint(fileName, lineNumber, address);
if (positionFromActionData(sender(), &fileName, &lineNumber, &address)) {
if (address)
toggleBreakpointByAddress(address);
else
toggleBreakpointByFileAndLine(fileName, lineNumber);
}
}
void breakpointRemoveMarginActionTriggered()
......@@ -992,7 +995,8 @@ public slots:
void activatePreviousMode();
void activateDebugMode();
void toggleBreakpoint();
void toggleBreakpoint(const QString &fileName, int lineNumber);
void toggleBreakpointByFileAndLine(const QString &fileName, int lineNumber);
void toggleBreakpointByAddress(quint64 address);
void onModeChanged(Core::IMode *mode);
void showSettingsDialog();
......@@ -1193,7 +1197,8 @@ public slots:
// Run to line, file name and line number set as list.
QString fileName;
int lineNumber;
if (positionFromContextActionData(sender(), &fileName, &lineNumber))
quint64 address;
if (positionFromActionData(sender(), &fileName, &lineNumber, &address))
handleExecRunToLine();
}
......@@ -1201,7 +1206,8 @@ public slots:
{
QString fileName;
int lineNumber;
if (positionFromContextActionData(sender(), &fileName, &lineNumber))
quint64 address;
if (positionFromActionData(sender(), &fileName, &lineNumber, &address))
currentEngine()->executeJumpToLine(fileName, lineNumber);
}
......@@ -2466,20 +2472,62 @@ void DebuggerPluginPrivate::toggleBreakpoint()
{
ITextEditor *textEditor = currentTextEditor();
QTC_ASSERT(textEditor, return);
int lineNumber = textEditor->currentLine();
if (lineNumber >= 0)
toggleBreakpoint(textEditor->file()->fileName(), lineNumber);
const int lineNumber = textEditor->currentLine();
if (textEditor->property("DisassemblerView").toBool()) {
QString line = textEditor->contents()
.section('\n', lineNumber - 1, lineNumber - 1);
quint64 address = DisassemblerViewAgent::addressFromDisassemblyLine(line);
toggleBreakpointByAddress(address);
} else if (lineNumber >= 0) {
toggleBreakpointByFileAndLine(textEditor->file()->fileName(), lineNumber);
}
}
void DebuggerPluginPrivate::toggleBreakpointByFileAndLine(const QString &fileName,
int lineNumber)
{
BreakHandler *handler = m_breakHandler;
BreakpointId id =
handler->findBreakpointByFileAndLine(fileName, lineNumber, true);
if (id == BreakpointId(-1))
id = handler->findBreakpointByFileAndLine(fileName, lineNumber, false);
if (id != BreakpointId(-1)) {
handler->removeBreakpoint(id);
} else {
BreakpointParameters data(BreakpointByFileAndLine);
data.fileName = fileName;
data.lineNumber = lineNumber;
handler->appendBreakpoint(data);
}
synchronizeBreakpoints();
}
void DebuggerPluginPrivate::toggleBreakpoint(const QString &fileName, int lineNumber)
void DebuggerPluginPrivate::toggleBreakpointByAddress(quint64 address)
{
m_breakHandler->toggleBreakpoint(fileName, lineNumber);
BreakHandler *handler = m_breakHandler;
BreakpointId id = handler->findBreakpointByAddress(address);
if (id != BreakpointId(-1)) {
handler->removeBreakpoint(id);
} else {
BreakpointParameters data(BreakpointByAddress);
data.address = address;
handler->appendBreakpoint(data);
}
synchronizeBreakpoints();
}
void DebuggerPluginPrivate::requestMark(ITextEditor *editor, int lineNumber)
{
if (isDebuggable(editor) && editor->file())
toggleBreakpoint(editor->file()->fileName(), lineNumber);
if (editor->property("DisassemblerView").toBool()) {
QString line = editor->contents()
.section('\n', lineNumber - 1, lineNumber - 1);
quint64 address = DisassemblerViewAgent::addressFromDisassemblyLine(line);
toggleBreakpointByAddress(address);
} else if (editor->file()) {
toggleBreakpointByFileAndLine(editor->file()->fileName(), lineNumber);
}
}
void DebuggerPluginPrivate::showToolTip(ITextEditor *editor,
......
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