forked from qt-creator/qt-creator
debugger: enable breakpoint setting from a disassembler view
This commit is contained in:
@@ -756,36 +756,6 @@ void BreakHandler::appendBreakpoint(const BreakpointParameters &data)
|
|||||||
scheduleSynchronization();
|
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()
|
void BreakHandler::saveSessionData()
|
||||||
{
|
{
|
||||||
saveBreakpoints();
|
saveBreakpoints();
|
||||||
|
|||||||
@@ -88,7 +88,6 @@ public:
|
|||||||
static QIcon pendingBreakPointIcon();
|
static QIcon pendingBreakPointIcon();
|
||||||
static QIcon emptyIcon();
|
static QIcon emptyIcon();
|
||||||
|
|
||||||
void toggleBreakpoint(const QString &fileName, int lineNumber, quint64 address = 0);
|
|
||||||
BreakpointId findBreakpointByFileAndLine(const QString &fileName,
|
BreakpointId findBreakpointByFileAndLine(const QString &fileName,
|
||||||
int lineNumber, bool useMarkerPosition = true);
|
int lineNumber, bool useMarkerPosition = true);
|
||||||
BreakpointId findBreakpointByAddress(quint64 address) const;
|
BreakpointId findBreakpointByAddress(quint64 address) const;
|
||||||
|
|||||||
@@ -40,11 +40,11 @@
|
|||||||
#include <coreplugin/mimedatabase.h>
|
#include <coreplugin/mimedatabase.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
#include <texteditor/basetexteditor.h>
|
|
||||||
#include <texteditor/plaintexteditor.h>
|
|
||||||
#include <texteditor/basetextmark.h>
|
|
||||||
#include <texteditor/texteditorconstants.h>
|
|
||||||
#include <texteditor/basetextdocument.h>
|
#include <texteditor/basetextdocument.h>
|
||||||
|
#include <texteditor/basetexteditor.h>
|
||||||
|
#include <texteditor/basetextmark.h>
|
||||||
|
#include <texteditor/plaintexteditor.h>
|
||||||
|
#include <texteditor/texteditorconstants.h>
|
||||||
|
|
||||||
#include <utils/qtcassert.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_BY_DEBUGGER, true);
|
||||||
d->editor->setProperty(Debugger::Constants::OPENED_WITH_DISASSEMBLY, true);
|
d->editor->setProperty(Debugger::Constants::OPENED_WITH_DISASSEMBLY, true);
|
||||||
d->configureMimeType();
|
d->configureMimeType();
|
||||||
|
|
||||||
|
BaseTextEditor *baseTextEdit =
|
||||||
|
qobject_cast<BaseTextEditor *>(d->editor->widget());
|
||||||
|
if (baseTextEdit)
|
||||||
|
baseTextEdit->setRequestMarkEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
editorManager->activateEditor(d->editor);
|
editorManager->activateEditor(d->editor);
|
||||||
|
|||||||
@@ -431,8 +431,8 @@ static QToolButton *toolButton(QAction *action)
|
|||||||
|
|
||||||
// Retrieve file name and line and optionally address
|
// Retrieve file name and line and optionally address
|
||||||
// from the data set on the text editor context menu action.
|
// from the data set on the text editor context menu action.
|
||||||
static bool positionFromContextActionData(const QObject *sender,
|
static bool positionFromActionData(const QObject *sender,
|
||||||
QString *fileName, int *lineNumber, quint64 *address = 0)
|
QString *fileName, int *lineNumber, quint64 *address)
|
||||||
{
|
{
|
||||||
const QAction *action = qobject_cast<const QAction *>(sender);
|
const QAction *action = qobject_cast<const QAction *>(sender);
|
||||||
QTC_ASSERT(action, return false);
|
QTC_ASSERT(action, return false);
|
||||||
@@ -440,8 +440,7 @@ static bool positionFromContextActionData(const QObject *sender,
|
|||||||
QTC_ASSERT(data.size() == 3, return false);
|
QTC_ASSERT(data.size() == 3, return false);
|
||||||
*fileName = data.front().toString();
|
*fileName = data.front().toString();
|
||||||
*lineNumber = data.at(1).toInt();
|
*lineNumber = data.at(1).toInt();
|
||||||
if (address)
|
*address = data.at(2).toULongLong();
|
||||||
*address = data.at(2).toULongLong();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -910,8 +909,12 @@ public slots:
|
|||||||
QString fileName;
|
QString fileName;
|
||||||
int lineNumber;
|
int lineNumber;
|
||||||
quint64 address;
|
quint64 address;
|
||||||
if (positionFromContextActionData(sender(), &fileName, &lineNumber, &address))
|
if (positionFromActionData(sender(), &fileName, &lineNumber, &address)) {
|
||||||
m_breakHandler->toggleBreakpoint(fileName, lineNumber, address);
|
if (address)
|
||||||
|
toggleBreakpointByAddress(address);
|
||||||
|
else
|
||||||
|
toggleBreakpointByFileAndLine(fileName, lineNumber);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void breakpointRemoveMarginActionTriggered()
|
void breakpointRemoveMarginActionTriggered()
|
||||||
@@ -992,7 +995,8 @@ public slots:
|
|||||||
void activatePreviousMode();
|
void activatePreviousMode();
|
||||||
void activateDebugMode();
|
void activateDebugMode();
|
||||||
void toggleBreakpoint();
|
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 onModeChanged(Core::IMode *mode);
|
||||||
void showSettingsDialog();
|
void showSettingsDialog();
|
||||||
|
|
||||||
@@ -1193,7 +1197,8 @@ public slots:
|
|||||||
// Run to line, file name and line number set as list.
|
// Run to line, file name and line number set as list.
|
||||||
QString fileName;
|
QString fileName;
|
||||||
int lineNumber;
|
int lineNumber;
|
||||||
if (positionFromContextActionData(sender(), &fileName, &lineNumber))
|
quint64 address;
|
||||||
|
if (positionFromActionData(sender(), &fileName, &lineNumber, &address))
|
||||||
handleExecRunToLine();
|
handleExecRunToLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1201,7 +1206,8 @@ public slots:
|
|||||||
{
|
{
|
||||||
QString fileName;
|
QString fileName;
|
||||||
int lineNumber;
|
int lineNumber;
|
||||||
if (positionFromContextActionData(sender(), &fileName, &lineNumber))
|
quint64 address;
|
||||||
|
if (positionFromActionData(sender(), &fileName, &lineNumber, &address))
|
||||||
currentEngine()->executeJumpToLine(fileName, lineNumber);
|
currentEngine()->executeJumpToLine(fileName, lineNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2466,20 +2472,62 @@ void DebuggerPluginPrivate::toggleBreakpoint()
|
|||||||
{
|
{
|
||||||
ITextEditor *textEditor = currentTextEditor();
|
ITextEditor *textEditor = currentTextEditor();
|
||||||
QTC_ASSERT(textEditor, return);
|
QTC_ASSERT(textEditor, return);
|
||||||
int lineNumber = textEditor->currentLine();
|
const int lineNumber = textEditor->currentLine();
|
||||||
if (lineNumber >= 0)
|
if (textEditor->property("DisassemblerView").toBool()) {
|
||||||
toggleBreakpoint(textEditor->file()->fileName(), lineNumber);
|
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::toggleBreakpoint(const QString &fileName, int lineNumber)
|
void DebuggerPluginPrivate::toggleBreakpointByFileAndLine(const QString &fileName,
|
||||||
|
int lineNumber)
|
||||||
{
|
{
|
||||||
m_breakHandler->toggleBreakpoint(fileName, 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::toggleBreakpointByAddress(quint64 address)
|
||||||
|
{
|
||||||
|
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)
|
void DebuggerPluginPrivate::requestMark(ITextEditor *editor, int lineNumber)
|
||||||
{
|
{
|
||||||
if (isDebuggable(editor) && editor->file())
|
if (editor->property("DisassemblerView").toBool()) {
|
||||||
toggleBreakpoint(editor->file()->fileName(), lineNumber);
|
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,
|
void DebuggerPluginPrivate::showToolTip(ITextEditor *editor,
|
||||||
|
|||||||
Reference in New Issue
Block a user