forked from qt-creator/qt-creator
debugger: basic support for address-based breakpoints
This commit is contained in:
@@ -378,9 +378,16 @@ int BreakHandler::findBreakpoint(const BreakpointData &needle) const
|
|||||||
|
|
||||||
int BreakHandler::findBreakpoint(const QString &fileName, int lineNumber) const
|
int BreakHandler::findBreakpoint(const QString &fileName, int lineNumber) const
|
||||||
{
|
{
|
||||||
|
if (lineNumber <= 0) {
|
||||||
|
QByteArray address = fileName.toLatin1();
|
||||||
|
for (int index = 0; index != size(); ++index)
|
||||||
|
if (at(index)->bpAddress == address)
|
||||||
|
return index;
|
||||||
|
} else {
|
||||||
for (int index = 0; index != size(); ++index)
|
for (int index = 0; index != size(); ++index)
|
||||||
if (at(index)->isLocatedAt(fileName, lineNumber))
|
if (at(index)->isLocatedAt(fileName, lineNumber))
|
||||||
return index;
|
return index;
|
||||||
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -710,11 +717,22 @@ void BreakHandler::setBreakpoint(const QString &fileName, int lineNumber)
|
|||||||
QFileInfo fi(fileName);
|
QFileInfo fi(fileName);
|
||||||
|
|
||||||
BreakpointData *data = new BreakpointData(this);
|
BreakpointData *data = new BreakpointData(this);
|
||||||
|
if (lineNumber > 0) {
|
||||||
data->fileName = fileName;
|
data->fileName = fileName;
|
||||||
data->lineNumber = QByteArray::number(lineNumber);
|
data->lineNumber = QByteArray::number(lineNumber);
|
||||||
data->pending = true;
|
data->pending = true;
|
||||||
data->setMarkerFileName(fileName);
|
data->setMarkerFileName(fileName);
|
||||||
data->setMarkerLineNumber(lineNumber);
|
data->setMarkerLineNumber(lineNumber);
|
||||||
|
} else {
|
||||||
|
data->funcName = fileName;
|
||||||
|
data->lineNumber = 0;
|
||||||
|
data->pending = true;
|
||||||
|
// FIXME: Figure out in which disassembler view the Marker sits.
|
||||||
|
// Might be better to let the user code create the BreakpointData
|
||||||
|
// structure and insert it here.
|
||||||
|
data->setMarkerFileName(QString());
|
||||||
|
data->setMarkerLineNumber(0);
|
||||||
|
}
|
||||||
append(data);
|
append(data);
|
||||||
emit layoutChanged();
|
emit layoutChanged();
|
||||||
saveBreakpoints();
|
saveBreakpoints();
|
||||||
|
|||||||
@@ -140,6 +140,7 @@ public:
|
|||||||
void removeAt(int index); // This also deletes the marker.
|
void removeAt(int index); // This also deletes the marker.
|
||||||
void clear(); // This also deletes all the marker.
|
void clear(); // This also deletes all the marker.
|
||||||
int indexOf(BreakpointData *data) { return m_bp.indexOf(data); }
|
int indexOf(BreakpointData *data) { return m_bp.indexOf(data); }
|
||||||
|
// If lineNumber < 0, interpret fileName as address.
|
||||||
int findBreakpoint(const QString &fileName, int lineNumber) const;
|
int findBreakpoint(const QString &fileName, int lineNumber) const;
|
||||||
int findBreakpoint(const BreakpointData &data) const; // Returns index.
|
int findBreakpoint(const BreakpointData &data) const; // Returns index.
|
||||||
BreakpointData *findBreakpoint(int bpNumber) const;
|
BreakpointData *findBreakpoint(int bpNumber) const;
|
||||||
|
|||||||
@@ -287,6 +287,7 @@ void DisassemblerViewAgent::setContents(const QString &contents)
|
|||||||
Core::Constants::K_DEFAULT_TEXT_EDITOR_ID,
|
Core::Constants::K_DEFAULT_TEXT_EDITOR_ID,
|
||||||
&titlePattern));
|
&titlePattern));
|
||||||
d->editor->setProperty("OpenedByDebugger", true);
|
d->editor->setProperty("OpenedByDebugger", true);
|
||||||
|
d->editor->setProperty("DisassemblerView", true);
|
||||||
QTC_ASSERT(d->editor, return);
|
QTC_ASSERT(d->editor, return);
|
||||||
if ((plainTextEdit = qobject_cast<QPlainTextEdit *>(d->editor->widget())))
|
if ((plainTextEdit = qobject_cast<QPlainTextEdit *>(d->editor->widget())))
|
||||||
(void) new DisassemblerHighlighter(plainTextEdit);
|
(void) new DisassemblerHighlighter(plainTextEdit);
|
||||||
|
|||||||
@@ -1128,8 +1128,19 @@ void DebuggerPlugin::requestContextMenu(TextEditor::ITextEditor *editor,
|
|||||||
{
|
{
|
||||||
if (!isDebuggable(editor))
|
if (!isDebuggable(editor))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
QString fileName, position;
|
||||||
|
if (editor->property("DisassemblerView").toBool()) {
|
||||||
QString fileName = editor->file()->fileName();
|
QString fileName = editor->file()->fileName();
|
||||||
QString position = fileName + QString(":%1").arg(lineNumber);
|
QString line = editor->contents()
|
||||||
|
.section('\n', lineNumber - 1, lineNumber - 1);
|
||||||
|
fileName = line.left(line.indexOf(QLatin1Char(' ')));
|
||||||
|
lineNumber = -1;
|
||||||
|
position = _("*") + fileName;
|
||||||
|
} else {
|
||||||
|
fileName = editor->file()->fileName();
|
||||||
|
position = fileName + QString(":%1").arg(lineNumber);
|
||||||
|
}
|
||||||
BreakpointData *data = m_manager->findBreakpoint(fileName, lineNumber);
|
BreakpointData *data = m_manager->findBreakpoint(fileName, lineNumber);
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
|
|||||||
@@ -2150,6 +2150,9 @@ QByteArray GdbEngine::breakpointLocation(int index)
|
|||||||
const BreakpointData *data = manager()->breakHandler()->at(index);
|
const BreakpointData *data = manager()->breakHandler()->at(index);
|
||||||
if (!data->funcName.isEmpty())
|
if (!data->funcName.isEmpty())
|
||||||
return data->funcName.toLatin1();
|
return data->funcName.toLatin1();
|
||||||
|
// In this case, data->funcName is something like '*0xdeadbeef'
|
||||||
|
if (data->lineNumber.toInt() == 0)
|
||||||
|
return data->funcName.toLatin1();
|
||||||
QString loc = data->useFullPath ? data->fileName : breakLocation(data->fileName);
|
QString loc = data->useFullPath ? data->fileName : breakLocation(data->fileName);
|
||||||
// The argument is simply a C-quoted version of the argument to the
|
// The argument is simply a C-quoted version of the argument to the
|
||||||
// non-MI "break" command, including the "original" quoting it wants.
|
// non-MI "break" command, including the "original" quoting it wants.
|
||||||
|
|||||||
Reference in New Issue
Block a user