2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2010-03-05 11:25:49 +01:00
|
|
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-06-17 00:01:27 +10:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Commercial Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Nokia.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** If you are unsure which license is appropriate for your use, please
|
2009-08-14 09:30:56 +02:00
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-02 15:08:31 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "breakhandler.h"
|
|
|
|
|
|
2009-09-23 16:11:25 +02:00
|
|
|
#include "debuggeractions.h"
|
2009-08-14 13:04:05 +02:00
|
|
|
#include "debuggermanager.h"
|
|
|
|
|
#include "stackframe.h"
|
|
|
|
|
|
2010-02-04 13:18:44 +01:00
|
|
|
#include <texteditor/basetextmark.h>
|
2010-03-26 08:52:49 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2008-12-09 16:18:28 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <QtCore/QDebug>
|
2009-05-12 14:28:27 +02:00
|
|
|
#include <QtCore/QTextStream>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <QtCore/QFileInfo>
|
|
|
|
|
|
|
|
|
|
using namespace Debugger;
|
|
|
|
|
using namespace Debugger::Internal;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// BreakpointMarker
|
|
|
|
|
//
|
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2009-12-15 10:21:02 +01:00
|
|
|
// Compare file names case insensitively on Windows.
|
|
|
|
|
static inline bool fileNameMatch(const QString &f1, const QString &f2)
|
|
|
|
|
{
|
|
|
|
|
return f1.compare(f2,
|
|
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
|
Qt::CaseInsensitive
|
|
|
|
|
#else
|
|
|
|
|
Qt::CaseSensitive
|
|
|
|
|
#endif
|
|
|
|
|
) == 0;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
namespace Debugger {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
// The red blob on the left side in the cpp editor.
|
|
|
|
|
class BreakpointMarker : public TextEditor::BaseTextMark
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
BreakpointMarker(BreakpointData *data, const QString &fileName, int lineNumber)
|
2009-04-28 15:08:52 +02:00
|
|
|
: BaseTextMark(fileName, lineNumber)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-04-28 15:08:52 +02:00
|
|
|
m_data = data;
|
|
|
|
|
m_pending = true;
|
|
|
|
|
m_enabled = true;
|
2008-12-02 12:01:29 +01:00
|
|
|
//qDebug() << "CREATE MARKER " << fileName << lineNumber;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
~BreakpointMarker()
|
|
|
|
|
{
|
|
|
|
|
//qDebug() << "REMOVE MARKER ";
|
|
|
|
|
m_data = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QIcon icon() const
|
2009-04-28 15:08:52 +02:00
|
|
|
{
|
2010-02-10 10:47:34 +01:00
|
|
|
const BreakHandler *handler = DebuggerManager::instance()->breakHandler();
|
|
|
|
|
if (!m_enabled)
|
|
|
|
|
return handler->disabledBreakpointIcon();
|
|
|
|
|
return m_pending ? handler->pendingBreakPointIcon() : handler->breakpointIcon();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-04-28 15:08:52 +02:00
|
|
|
void setPending(bool pending, bool enabled)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-04-28 15:08:52 +02:00
|
|
|
if (pending == m_pending && enabled == m_enabled)
|
2008-12-02 12:01:29 +01:00
|
|
|
return;
|
|
|
|
|
m_pending = pending;
|
2009-04-28 15:08:52 +02:00
|
|
|
m_enabled = enabled;
|
2008-12-02 12:01:29 +01:00
|
|
|
updateMarker();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void updateBlock(const QTextBlock &)
|
|
|
|
|
{
|
|
|
|
|
//qDebug() << "BREAKPOINT MARKER UPDATE BLOCK";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void removedFromEditor()
|
|
|
|
|
{
|
|
|
|
|
if (!m_data)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
BreakHandler *handler = m_data->handler();
|
|
|
|
|
handler->removeBreakpoint(handler->indexOf(m_data));
|
|
|
|
|
handler->saveBreakpoints();
|
|
|
|
|
handler->updateMarkers();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void updateLineNumber(int lineNumber)
|
|
|
|
|
{
|
|
|
|
|
if (!m_data)
|
|
|
|
|
return;
|
|
|
|
|
//if (m_data->markerLineNumber == lineNumber)
|
|
|
|
|
// return;
|
2010-03-26 10:29:19 +01:00
|
|
|
if (m_data->markerLineNumber() != lineNumber) {
|
|
|
|
|
m_data->setMarkerLineNumber(lineNumber);
|
|
|
|
|
// FIXME: Should we tell gdb about the change?
|
2008-12-02 12:01:29 +01:00
|
|
|
// Ignore it for now, as we would require re-compilation
|
|
|
|
|
// and debugger re-start anyway.
|
|
|
|
|
if (0 && !m_data->bpLineNumber.isEmpty()) {
|
|
|
|
|
if (!m_data->bpNumber.trimmed().isEmpty()) {
|
|
|
|
|
m_data->pending = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-03-26 10:29:19 +01:00
|
|
|
// Ignore updates to the "real" line number while the debugger is
|
|
|
|
|
// running, as this can be triggered by moving the breakpoint to
|
|
|
|
|
// the next line that generated code.
|
|
|
|
|
// FIXME: Do we need yet another data member?
|
|
|
|
|
if (m_data->bpNumber.trimmed().isEmpty()) {
|
|
|
|
|
m_data->lineNumber = QByteArray::number(lineNumber);
|
|
|
|
|
m_data->handler()->updateMarkers();
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
BreakpointData *m_data;
|
|
|
|
|
bool m_pending;
|
2009-04-28 15:08:52 +02:00
|
|
|
bool m_enabled;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Debugger
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// BreakpointData
|
|
|
|
|
//
|
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
BreakpointData::BreakpointData(BreakHandler *handler)
|
|
|
|
|
{
|
|
|
|
|
//qDebug() << "CREATE BREAKPOINTDATA" << this;
|
|
|
|
|
m_handler = handler;
|
2009-04-28 15:08:52 +02:00
|
|
|
enabled = true;
|
2008-12-02 12:01:29 +01:00
|
|
|
pending = true;
|
|
|
|
|
marker = 0;
|
2010-03-26 10:29:19 +01:00
|
|
|
m_markerLineNumber = 0;
|
2008-12-02 12:01:29 +01:00
|
|
|
bpMultiple = false;
|
2009-05-11 13:21:59 +02:00
|
|
|
//#if defined(Q_OS_MAC)
|
|
|
|
|
// // full names do not work on Mac/MI
|
2010-01-29 21:33:57 +01:00
|
|
|
useFullPath = false;
|
2009-05-11 13:21:59 +02:00
|
|
|
//#else
|
|
|
|
|
// //where = m_manager->shortName(data->fileName);
|
2010-01-29 21:33:57 +01:00
|
|
|
// useFullPath = true;
|
2009-05-11 13:21:59 +02:00
|
|
|
//#endif
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BreakpointData::~BreakpointData()
|
|
|
|
|
{
|
|
|
|
|
removeMarker();
|
|
|
|
|
//qDebug() << "DESTROY BREAKPOINTDATA" << this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BreakpointData::removeMarker()
|
|
|
|
|
{
|
|
|
|
|
BreakpointMarker *m = marker;
|
|
|
|
|
marker = 0;
|
|
|
|
|
delete m;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BreakpointData::updateMarker()
|
|
|
|
|
{
|
2010-03-26 10:29:19 +01:00
|
|
|
if (marker && (m_markerFileName != marker->fileName()
|
|
|
|
|
|| m_markerLineNumber != marker->lineNumber()))
|
2008-12-02 12:01:29 +01:00
|
|
|
removeMarker();
|
|
|
|
|
|
2010-03-26 10:29:19 +01:00
|
|
|
if (!marker && !m_markerFileName.isEmpty() && m_markerLineNumber > 0)
|
|
|
|
|
marker = new BreakpointMarker(this, m_markerFileName, m_markerLineNumber);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
if (marker)
|
2009-04-28 15:08:52 +02:00
|
|
|
marker->setPending(pending, enabled);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-26 10:29:19 +01:00
|
|
|
void BreakpointData::setMarkerFileName(const QString &fileName)
|
|
|
|
|
{
|
|
|
|
|
m_markerFileName = fileName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BreakpointData::setMarkerLineNumber(int lineNumber)
|
|
|
|
|
{
|
|
|
|
|
m_markerLineNumber = lineNumber;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
QString BreakpointData::toToolTip() const
|
|
|
|
|
{
|
2009-05-12 14:28:27 +02:00
|
|
|
QString rc;
|
|
|
|
|
QTextStream str(&rc);
|
2010-03-26 08:52:49 +01:00
|
|
|
str << "<html><body><table>"
|
|
|
|
|
<< "<tr><td>" << BreakHandler::tr("Marker File:")
|
2010-03-26 10:29:19 +01:00
|
|
|
<< "</td><td>" << m_markerFileName << "</td></tr>"
|
2010-03-26 08:52:49 +01:00
|
|
|
<< "<tr><td>" << BreakHandler::tr("Marker Line:")
|
2010-03-26 10:29:19 +01:00
|
|
|
<< "</td><td>" << m_markerLineNumber << "</td></tr>"
|
2010-03-26 08:52:49 +01:00
|
|
|
<< "<tr><td>" << BreakHandler::tr("Breakpoint Number:")
|
|
|
|
|
<< "</td><td>" << bpNumber << "</td></tr>"
|
|
|
|
|
<< "<tr><td>" << BreakHandler::tr("Breakpoint Address:")
|
|
|
|
|
<< "</td><td>" << bpAddress << "</td></tr>"
|
|
|
|
|
<< "</table><br><hr><table>"
|
|
|
|
|
<< "<tr><th>" << BreakHandler::tr("Property")
|
2009-05-12 14:28:27 +02:00
|
|
|
<< "</th><th>" << BreakHandler::tr("Requested")
|
2010-03-26 08:52:49 +01:00
|
|
|
<< "</th><th>" << BreakHandler::tr("Obtained") << "</th></tr>"
|
|
|
|
|
<< "<tr><td>" << BreakHandler::tr("Internal Number:")
|
|
|
|
|
<< "</td><td>—</td><td>" << bpNumber << "</td></tr>"
|
|
|
|
|
<< "<tr><td>" << BreakHandler::tr("File Name:")
|
|
|
|
|
<< "</td><td>" << fileName << "</td><td>" << bpFileName << "</td></tr>"
|
|
|
|
|
<< "<tr><td>" << BreakHandler::tr("Function Name:")
|
|
|
|
|
<< "</td><td>" << funcName << "</td><td>" << bpFuncName << "</td></tr>"
|
|
|
|
|
<< "<tr><td>" << BreakHandler::tr("Line Number:")
|
|
|
|
|
<< "</td><td>" << lineNumber << "</td><td>" << bpLineNumber << "</td></tr>"
|
|
|
|
|
<< "<tr><td>" << BreakHandler::tr("Corrected Line Number:")
|
2010-03-26 10:29:19 +01:00
|
|
|
<< "</td><td>-</td><td>" << bpCorrectedLineNumber << "</td></tr>"
|
2010-03-26 08:52:49 +01:00
|
|
|
<< "<tr><td>" << BreakHandler::tr("Condition:")
|
|
|
|
|
<< "</td><td>" << condition << "</td><td>" << bpCondition << "</td></tr>"
|
|
|
|
|
<< "<tr><td>" << BreakHandler::tr("Ignore Count:")
|
|
|
|
|
<< "</td><td>" << ignoreCount << "</td><td>" << bpIgnoreCount << "</td></tr>"
|
|
|
|
|
<< "</table></body></html>";
|
2009-05-12 14:28:27 +02:00
|
|
|
return rc;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-01-19 18:10:50 +01:00
|
|
|
QString BreakpointData::toString() const
|
|
|
|
|
{
|
|
|
|
|
QString rc;
|
|
|
|
|
QTextStream str(&rc);
|
2010-03-26 10:29:19 +01:00
|
|
|
str << BreakHandler::tr("Marker File:") << m_markerFileName << ' '
|
|
|
|
|
<< BreakHandler::tr("Marker Line:") << m_markerLineNumber << ' '
|
2010-03-26 08:52:49 +01:00
|
|
|
<< BreakHandler::tr("Breakpoint Number:") << bpNumber << ' '
|
|
|
|
|
<< BreakHandler::tr("Breakpoint Address:") << bpAddress << '\n'
|
|
|
|
|
<< BreakHandler::tr("File Name:")
|
|
|
|
|
<< fileName << " -- " << bpFileName << '\n'
|
|
|
|
|
<< BreakHandler::tr("Function Name:")
|
|
|
|
|
<< funcName << " -- " << bpFuncName << '\n'
|
|
|
|
|
<< BreakHandler::tr("Line Number:")
|
|
|
|
|
<< lineNumber << " -- " << bpLineNumber << '\n'
|
|
|
|
|
<< BreakHandler::tr("Condition:")
|
|
|
|
|
<< condition << " -- " << bpCondition << '\n'
|
|
|
|
|
<< BreakHandler::tr("Ignore Count:")
|
2010-01-19 18:10:50 +01:00
|
|
|
<< ignoreCount << " -- " << bpIgnoreCount << '\n';
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
bool BreakpointData::isLocatedAt(const QString &fileName_, int lineNumber_) const
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
if (lineNumber != QString::number(lineNumber_))
|
|
|
|
|
return false;
|
|
|
|
|
if (fileName == fileName_)
|
|
|
|
|
return true;
|
|
|
|
|
if (fileName_.endsWith(fileName))
|
|
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
*/
|
2010-03-26 10:29:19 +01:00
|
|
|
return lineNumber_ == m_markerLineNumber
|
|
|
|
|
&& fileNameMatch(fileName_, m_markerFileName);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BreakpointData::conditionsMatch() const
|
|
|
|
|
{
|
2010-03-26 08:52:49 +01:00
|
|
|
// Some versions of gdb "beautify" the passed condition.
|
2008-12-02 12:01:29 +01:00
|
|
|
QString s1 = condition;
|
|
|
|
|
s1.remove(QChar(' '));
|
|
|
|
|
QString s2 = bpCondition;
|
|
|
|
|
s2.remove(QChar(' '));
|
|
|
|
|
return s1 == s2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// BreakHandler
|
|
|
|
|
//
|
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2010-02-10 10:47:34 +01:00
|
|
|
BreakHandler::BreakHandler(DebuggerManager *manager, QObject *parent) :
|
|
|
|
|
QAbstractTableModel(parent),
|
2010-03-05 14:30:08 +01:00
|
|
|
m_breakpointIcon(QLatin1String(":/debugger/images/breakpoint_16.png")),
|
|
|
|
|
m_disabledBreakpointIcon(QLatin1String(":/debugger/images/breakpoint_disabled_16.png")),
|
|
|
|
|
m_pendingBreakPointIcon(QLatin1String(":/debugger/images/breakpoint_pending_16.png")),
|
2010-02-10 10:47:34 +01:00
|
|
|
m_manager(manager)
|
|
|
|
|
{
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2008-12-04 11:37:43 +01:00
|
|
|
BreakHandler::~BreakHandler()
|
|
|
|
|
{
|
|
|
|
|
clear();
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
int BreakHandler::columnCount(const QModelIndex &parent) const
|
|
|
|
|
{
|
2009-10-01 11:22:44 +02:00
|
|
|
return parent.isValid() ? 0 : 7;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int BreakHandler::rowCount(const QModelIndex &parent) const
|
|
|
|
|
{
|
|
|
|
|
return parent.isValid() ? 0 : size();
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-08 16:37:41 +02:00
|
|
|
bool BreakHandler::hasPendingBreakpoints() const
|
|
|
|
|
{
|
|
|
|
|
for (int i = size() - 1; i >= 0; i--)
|
|
|
|
|
if (at(i)->pending)
|
|
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-26 08:52:49 +01:00
|
|
|
BreakpointData *BreakHandler::at(int index) const
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(index < size(), return 0);
|
|
|
|
|
return m_bp.at(index);
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void BreakHandler::removeAt(int index)
|
|
|
|
|
{
|
|
|
|
|
BreakpointData *data = at(index);
|
|
|
|
|
m_bp.removeAt(index);
|
|
|
|
|
delete data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BreakHandler::clear()
|
|
|
|
|
{
|
2009-06-30 15:50:56 +02:00
|
|
|
qDeleteAll(m_bp);
|
|
|
|
|
m_bp.clear();
|
|
|
|
|
m_enabled.clear();
|
|
|
|
|
m_disabled.clear();
|
|
|
|
|
m_removed.clear();
|
|
|
|
|
m_inserted.clear();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-26 10:29:19 +01:00
|
|
|
int BreakHandler::findBreakpoint(const BreakpointData &needle) const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-02-11 17:29:10 +01:00
|
|
|
// Search a breakpoint we might refer to.
|
2008-12-02 12:01:29 +01:00
|
|
|
for (int index = 0; index != size(); ++index) {
|
|
|
|
|
const BreakpointData *data = at(index);
|
2010-02-11 17:29:10 +01:00
|
|
|
// Clear hit.
|
2008-12-02 12:01:29 +01:00
|
|
|
if (data->bpNumber == needle.bpNumber)
|
|
|
|
|
return index;
|
2010-02-11 17:29:10 +01:00
|
|
|
// At least at a position we were looking for.
|
2008-12-02 12:01:29 +01:00
|
|
|
// FIXME: breaks multiple breakpoints at the same location
|
2009-12-15 10:21:02 +01:00
|
|
|
if (fileNameMatch(data->fileName, needle.bpFileName)
|
2008-12-02 12:01:29 +01:00
|
|
|
&& data->lineNumber == needle.bpLineNumber)
|
|
|
|
|
return index;
|
|
|
|
|
}
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-26 10:29:19 +01:00
|
|
|
int BreakHandler::findBreakpoint(const QString &fileName, int lineNumber) const
|
2009-04-28 15:08:52 +02:00
|
|
|
{
|
2010-04-09 14:55:09 +02:00
|
|
|
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)
|
|
|
|
|
if (at(index)->isLocatedAt(fileName, lineNumber))
|
|
|
|
|
return index;
|
|
|
|
|
}
|
2009-04-28 15:08:52 +02:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-26 10:29:19 +01:00
|
|
|
BreakpointData *BreakHandler::findBreakpoint(int bpNumber) const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-06-10 10:29:31 +02:00
|
|
|
if (!size())
|
2010-03-26 10:29:19 +01:00
|
|
|
return 0;
|
2009-06-10 10:29:31 +02:00
|
|
|
QString numStr = QString::number(bpNumber);
|
2008-12-02 12:01:29 +01:00
|
|
|
for (int index = 0; index != size(); ++index)
|
2009-06-10 10:29:31 +02:00
|
|
|
if (at(index)->bpNumber == numStr)
|
2010-03-26 10:29:19 +01:00
|
|
|
return at(index);
|
|
|
|
|
return 0;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BreakHandler::saveBreakpoints()
|
|
|
|
|
{
|
|
|
|
|
QList<QVariant> list;
|
|
|
|
|
for (int index = 0; index != size(); ++index) {
|
|
|
|
|
const BreakpointData *data = at(index);
|
|
|
|
|
QMap<QString, QVariant> map;
|
|
|
|
|
if (!data->fileName.isEmpty())
|
2009-06-30 15:50:56 +02:00
|
|
|
map.insert(QLatin1String("filename"), data->fileName);
|
2008-12-02 12:01:29 +01:00
|
|
|
if (!data->lineNumber.isEmpty())
|
2009-06-30 15:50:56 +02:00
|
|
|
map.insert(QLatin1String("linenumber"), data->lineNumber);
|
2008-12-02 12:01:29 +01:00
|
|
|
if (!data->funcName.isEmpty())
|
2009-06-30 15:50:56 +02:00
|
|
|
map.insert(QLatin1String("funcname"), data->funcName);
|
2008-12-02 12:01:29 +01:00
|
|
|
if (!data->condition.isEmpty())
|
2009-06-30 15:50:56 +02:00
|
|
|
map.insert(QLatin1String("condition"), data->condition);
|
2008-12-02 12:01:29 +01:00
|
|
|
if (!data->ignoreCount.isEmpty())
|
2009-06-30 15:50:56 +02:00
|
|
|
map.insert(QLatin1String("ignorecount"), data->ignoreCount);
|
2009-04-28 15:08:52 +02:00
|
|
|
if (!data->enabled)
|
2009-06-30 15:50:56 +02:00
|
|
|
map.insert(QLatin1String("disabled"), QLatin1String("1"));
|
2009-05-11 13:21:59 +02:00
|
|
|
if (data->useFullPath)
|
2009-06-30 15:50:56 +02:00
|
|
|
map.insert(QLatin1String("usefullpath"), QLatin1String("1"));
|
2008-12-02 12:01:29 +01:00
|
|
|
list.append(map);
|
|
|
|
|
}
|
2009-08-14 13:04:05 +02:00
|
|
|
m_manager->setSessionValue("Breakpoints", list);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BreakHandler::loadBreakpoints()
|
|
|
|
|
{
|
2009-08-14 13:04:05 +02:00
|
|
|
QVariant value = m_manager->sessionValue("Breakpoints");
|
2008-12-02 12:01:29 +01:00
|
|
|
QList<QVariant> list = value.toList();
|
|
|
|
|
clear();
|
|
|
|
|
foreach (const QVariant &var, list) {
|
|
|
|
|
const QMap<QString, QVariant> map = var.toMap();
|
|
|
|
|
BreakpointData *data = new BreakpointData(this);
|
2009-06-30 15:50:56 +02:00
|
|
|
QVariant v = map.value(QLatin1String("filename"));
|
|
|
|
|
if (v.isValid())
|
|
|
|
|
data->fileName = v.toString();
|
|
|
|
|
v = map.value(QLatin1String("linenumber"));
|
|
|
|
|
if (v.isValid())
|
2010-01-05 16:51:55 +01:00
|
|
|
data->lineNumber = v.toString().toLatin1();
|
2009-06-30 15:50:56 +02:00
|
|
|
v = map.value(QLatin1String("condition"));
|
|
|
|
|
if (v.isValid())
|
2010-01-05 16:51:55 +01:00
|
|
|
data->condition = v.toString().toLatin1();
|
2009-06-30 15:50:56 +02:00
|
|
|
v = map.value(QLatin1String("ignorecount"));
|
|
|
|
|
if (v.isValid())
|
2010-01-05 16:51:55 +01:00
|
|
|
data->ignoreCount = v.toString().toLatin1();
|
2009-06-30 15:50:56 +02:00
|
|
|
v = map.value(QLatin1String("funcname"));
|
|
|
|
|
if (v.isValid())
|
|
|
|
|
data->funcName = v.toString();
|
|
|
|
|
v = map.value(QLatin1String("disabled"));
|
|
|
|
|
if (v.isValid())
|
|
|
|
|
data->enabled = !v.toInt();
|
|
|
|
|
v = map.value(QLatin1String("usefullpath"));
|
|
|
|
|
if (v.isValid())
|
|
|
|
|
data->useFullPath = bool(v.toInt());
|
2010-03-26 10:29:19 +01:00
|
|
|
data->setMarkerFileName(data->fileName);
|
|
|
|
|
data->setMarkerLineNumber(data->lineNumber.toInt());
|
2008-12-02 12:01:29 +01:00
|
|
|
append(data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BreakHandler::resetBreakpoints()
|
|
|
|
|
{
|
|
|
|
|
for (int index = size(); --index >= 0;) {
|
|
|
|
|
BreakpointData *data = at(index);
|
|
|
|
|
data->pending = true;
|
2009-06-17 17:19:32 +02:00
|
|
|
data->bpMultiple = false;
|
|
|
|
|
data->bpEnabled = true;
|
2008-12-02 12:01:29 +01:00
|
|
|
data->bpNumber.clear();
|
|
|
|
|
data->bpFuncName.clear();
|
|
|
|
|
data->bpFileName.clear();
|
|
|
|
|
data->bpLineNumber.clear();
|
2010-03-26 10:29:19 +01:00
|
|
|
data->bpCorrectedLineNumber.clear();
|
2008-12-02 12:01:29 +01:00
|
|
|
data->bpCondition.clear();
|
|
|
|
|
data->bpIgnoreCount.clear();
|
2009-06-17 17:19:32 +02:00
|
|
|
data->bpAddress.clear();
|
2010-03-26 08:52:49 +01:00
|
|
|
// Keep marker data if it was primary.
|
2010-03-26 10:29:19 +01:00
|
|
|
if (data->markerFileName() != data->fileName)
|
|
|
|
|
data->setMarkerFileName(QString());
|
|
|
|
|
if (data->markerLineNumber() != data->lineNumber.toInt())
|
|
|
|
|
data->setMarkerLineNumber(0);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2009-06-17 17:19:32 +02:00
|
|
|
m_enabled.clear();
|
|
|
|
|
m_disabled.clear();
|
|
|
|
|
m_removed.clear();
|
|
|
|
|
m_inserted.clear();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BreakHandler::updateMarkers()
|
|
|
|
|
{
|
|
|
|
|
for (int index = 0; index != size(); ++index)
|
|
|
|
|
at(index)->updateMarker();
|
|
|
|
|
emit layoutChanged();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariant BreakHandler::headerData(int section,
|
|
|
|
|
Qt::Orientation orientation, int role) const
|
|
|
|
|
{
|
|
|
|
|
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
|
|
|
|
|
static QString headers[] = {
|
|
|
|
|
tr("Number"), tr("Function"), tr("File"), tr("Line"),
|
2009-10-01 11:22:44 +02:00
|
|
|
tr("Condition"), tr("Ignore"), tr("Address")
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
return headers[section];
|
|
|
|
|
}
|
|
|
|
|
return QVariant();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariant BreakHandler::data(const QModelIndex &mi, int role) const
|
|
|
|
|
{
|
|
|
|
|
static const QString empty = QString(QLatin1Char('-'));
|
|
|
|
|
|
2008-12-09 12:08:56 +01:00
|
|
|
QTC_ASSERT(mi.isValid(), return QVariant());
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
if (mi.row() >= size())
|
|
|
|
|
return QVariant();
|
|
|
|
|
|
|
|
|
|
const BreakpointData *data = at(mi.row());
|
|
|
|
|
switch (mi.column()) {
|
|
|
|
|
case 0:
|
|
|
|
|
if (role == Qt::DisplayRole) {
|
2010-02-10 10:47:34 +01:00
|
|
|
const QString str = data->bpNumber;
|
2008-12-02 12:01:29 +01:00
|
|
|
return str.isEmpty() ? empty : str;
|
|
|
|
|
}
|
2009-04-28 15:08:52 +02:00
|
|
|
if (role == Qt::UserRole)
|
|
|
|
|
return data->enabled;
|
2010-02-10 10:47:34 +01:00
|
|
|
if (role == Qt::DecorationRole) {
|
|
|
|
|
if (!data->enabled)
|
|
|
|
|
return m_disabledBreakpointIcon;
|
|
|
|
|
return data->pending ? m_pendingBreakPointIcon : m_breakpointIcon;
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
if (role == Qt::DisplayRole) {
|
2010-02-10 10:47:34 +01:00
|
|
|
const QString str = data->pending ? data->funcName : data->bpFuncName;
|
2008-12-02 12:01:29 +01:00
|
|
|
return str.isEmpty() ? empty : str;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
if (role == Qt::DisplayRole) {
|
|
|
|
|
QString str = data->pending ? data->fileName : data->bpFileName;
|
|
|
|
|
str = QFileInfo(str).fileName();
|
2010-02-10 11:45:40 +01:00
|
|
|
// FIXME: better?
|
|
|
|
|
//if (data->bpMultiple && str.isEmpty() && !data->markerFileName.isEmpty())
|
|
|
|
|
// str = data->markerFileName;
|
2009-05-11 13:21:59 +02:00
|
|
|
str = str.isEmpty() ? empty : str;
|
|
|
|
|
if (data->useFullPath)
|
2010-01-29 21:33:57 +01:00
|
|
|
str = "/.../" + str;
|
2009-05-11 13:21:59 +02:00
|
|
|
return str;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2009-05-11 13:21:59 +02:00
|
|
|
if (role == Qt::UserRole)
|
|
|
|
|
return data->useFullPath;
|
2008-12-02 12:01:29 +01:00
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
if (role == Qt::DisplayRole) {
|
2010-02-10 11:45:40 +01:00
|
|
|
// FIXME: better?
|
|
|
|
|
//if (data->bpMultiple && str.isEmpty() && !data->markerFileName.isEmpty())
|
|
|
|
|
// str = data->markerLineNumber;
|
2010-02-10 10:47:34 +01:00
|
|
|
const QString str = data->pending ? data->lineNumber : data->bpLineNumber;
|
2008-12-02 12:01:29 +01:00
|
|
|
return str.isEmpty() ? empty : str;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
if (role == Qt::DisplayRole)
|
|
|
|
|
return data->pending ? data->condition : data->bpCondition;
|
|
|
|
|
if (role == Qt::ToolTipRole)
|
|
|
|
|
return tr("Breakpoint will only be hit if this condition is met.");
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
|
|
|
|
if (role == Qt::DisplayRole)
|
|
|
|
|
return data->pending ? data->ignoreCount : data->bpIgnoreCount;
|
|
|
|
|
if (role == Qt::ToolTipRole)
|
|
|
|
|
return tr("Breakpoint will only be hit after being ignored so many times.");
|
2009-10-01 11:22:44 +02:00
|
|
|
case 6:
|
|
|
|
|
if (role == Qt::DisplayRole)
|
|
|
|
|
return data->bpAddress;
|
2008-12-02 12:01:29 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (role == Qt::ToolTipRole)
|
2009-10-01 11:22:44 +02:00
|
|
|
return theDebuggerBoolSetting(UseToolTipsInBreakpointsView)
|
2009-09-23 16:11:25 +02:00
|
|
|
? data->toToolTip() : QVariant();
|
2008-12-02 12:01:29 +01:00
|
|
|
return QVariant();
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-28 15:08:52 +02:00
|
|
|
Qt::ItemFlags BreakHandler::flags(const QModelIndex &mi) const
|
|
|
|
|
{
|
|
|
|
|
switch (mi.column()) {
|
|
|
|
|
//case 0:
|
|
|
|
|
// return Qt::ItemIsUserCheckable | Qt::ItemIsEnabled;
|
|
|
|
|
default:
|
2009-10-01 11:22:44 +02:00
|
|
|
return QAbstractTableModel::flags(mi);
|
2009-04-28 15:08:52 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
bool BreakHandler::setData(const QModelIndex &mi, const QVariant &value, int role)
|
|
|
|
|
{
|
|
|
|
|
if (role != Qt::EditRole)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
BreakpointData *data = at(mi.row());
|
|
|
|
|
switch (mi.column()) {
|
2009-04-28 15:08:52 +02:00
|
|
|
case 0: {
|
|
|
|
|
if (data->enabled != value.toBool()) {
|
|
|
|
|
toggleBreakpointEnabled(data);
|
|
|
|
|
dataChanged(mi, mi);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2009-05-11 13:21:59 +02:00
|
|
|
case 2: {
|
|
|
|
|
if (data->useFullPath != value.toBool()) {
|
|
|
|
|
data->useFullPath = value.toBool();
|
|
|
|
|
dataChanged(mi, mi);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
case 4: {
|
|
|
|
|
QString val = value.toString();
|
|
|
|
|
if (val != data->condition) {
|
2010-01-05 16:51:55 +01:00
|
|
|
data->condition = val.toLatin1();
|
2008-12-02 12:01:29 +01:00
|
|
|
dataChanged(mi, mi);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
case 5: {
|
|
|
|
|
QString val = value.toString();
|
|
|
|
|
if (val != data->ignoreCount) {
|
2010-01-05 16:51:55 +01:00
|
|
|
data->ignoreCount = val.toLatin1();
|
2008-12-02 12:01:29 +01:00
|
|
|
dataChanged(mi, mi);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2010-01-29 21:33:57 +01:00
|
|
|
default: {
|
2008-12-02 12:01:29 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-12 14:28:27 +02:00
|
|
|
void BreakHandler::append(BreakpointData *data)
|
|
|
|
|
{
|
|
|
|
|
m_bp.append(data);
|
|
|
|
|
m_inserted.append(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<BreakpointData *> BreakHandler::insertedBreakpoints() const
|
|
|
|
|
{
|
|
|
|
|
return m_inserted;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BreakHandler::takeInsertedBreakPoint(BreakpointData *d)
|
|
|
|
|
{
|
|
|
|
|
m_inserted.removeAll(d);
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
QList<BreakpointData *> BreakHandler::takeRemovedBreakpoints()
|
|
|
|
|
{
|
|
|
|
|
QList<BreakpointData *> result = m_removed;
|
|
|
|
|
m_removed.clear();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-28 15:08:52 +02:00
|
|
|
QList<BreakpointData *> BreakHandler::takeEnabledBreakpoints()
|
|
|
|
|
{
|
|
|
|
|
QList<BreakpointData *> result = m_enabled;
|
|
|
|
|
m_enabled.clear();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<BreakpointData *> BreakHandler::takeDisabledBreakpoints()
|
|
|
|
|
{
|
|
|
|
|
QList<BreakpointData *> result = m_disabled;
|
|
|
|
|
m_disabled.clear();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void BreakHandler::removeBreakpointHelper(int index)
|
|
|
|
|
{
|
|
|
|
|
BreakpointData *data = m_bp.at(index);
|
|
|
|
|
m_bp.removeAt(index);
|
|
|
|
|
data->removeMarker();
|
|
|
|
|
m_removed.append(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BreakHandler::removeBreakpoint(int index)
|
|
|
|
|
{
|
|
|
|
|
if (index < 0 || index >= size())
|
|
|
|
|
return;
|
2009-06-11 13:40:44 +02:00
|
|
|
removeBreakpointHelper(index);
|
2008-12-02 12:01:29 +01:00
|
|
|
emit layoutChanged();
|
|
|
|
|
saveBreakpoints();
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-28 15:08:52 +02:00
|
|
|
void BreakHandler::toggleBreakpointEnabled(BreakpointData *data)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(data, return);
|
|
|
|
|
data->enabled = !data->enabled;
|
|
|
|
|
if (data->enabled) {
|
|
|
|
|
m_enabled.append(data);
|
|
|
|
|
m_disabled.removeAll(data);
|
|
|
|
|
} else {
|
|
|
|
|
m_enabled.removeAll(data);
|
|
|
|
|
m_disabled.append(data);
|
|
|
|
|
}
|
|
|
|
|
saveBreakpoints();
|
|
|
|
|
updateMarkers();
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-04-09 15:19:10 +02:00
|
|
|
void BreakHandler::appendBreakpoint(BreakpointData *data)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
append(data);
|
|
|
|
|
emit layoutChanged();
|
|
|
|
|
saveBreakpoints();
|
|
|
|
|
updateMarkers();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BreakHandler::removeAllBreakpoints()
|
|
|
|
|
{
|
|
|
|
|
for (int index = size(); --index >= 0;)
|
|
|
|
|
removeBreakpointHelper(index);
|
|
|
|
|
emit layoutChanged();
|
|
|
|
|
saveBreakpoints();
|
|
|
|
|
updateMarkers();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BreakHandler::setAllPending()
|
|
|
|
|
{
|
|
|
|
|
loadBreakpoints();
|
|
|
|
|
for (int index = size(); --index >= 0;)
|
|
|
|
|
at(index)->pending = true;
|
|
|
|
|
saveBreakpoints();
|
|
|
|
|
updateMarkers();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BreakHandler::saveSessionData()
|
|
|
|
|
{
|
|
|
|
|
saveBreakpoints();
|
|
|
|
|
updateMarkers();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BreakHandler::loadSessionData()
|
|
|
|
|
{
|
|
|
|
|
//resetBreakpoints();
|
|
|
|
|
loadBreakpoints();
|
|
|
|
|
updateMarkers();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BreakHandler::breakByFunction(const QString &functionName)
|
|
|
|
|
{
|
2010-03-26 08:52:49 +01:00
|
|
|
// One breakpoint per function is enough for now. This does not handle
|
|
|
|
|
// combinations of multiple conditions and ignore counts, though.
|
2008-12-02 12:01:29 +01:00
|
|
|
for (int index = size(); --index >= 0;) {
|
|
|
|
|
const BreakpointData *data = at(index);
|
2008-12-09 12:08:56 +01:00
|
|
|
QTC_ASSERT(data, break);
|
2008-12-02 12:01:29 +01:00
|
|
|
if (data->funcName == functionName && data->condition.isEmpty()
|
|
|
|
|
&& data->ignoreCount.isEmpty())
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
BreakpointData *data = new BreakpointData(this);
|
|
|
|
|
data->funcName = functionName;
|
|
|
|
|
append(data);
|
|
|
|
|
saveBreakpoints();
|
|
|
|
|
updateMarkers();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#include "breakhandler.moc"
|