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 "breakwindow.h"
|
2010-10-25 14:00:19 +02:00
|
|
|
#include "breakhandler.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-03-18 09:03:47 +01:00
|
|
|
#include "debuggeractions.h"
|
2010-11-10 11:39:01 +01:00
|
|
|
#include "debuggercore.h"
|
2010-09-21 16:32:43 +02:00
|
|
|
#include "ui_breakpoint.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "ui_breakcondition.h"
|
|
|
|
|
|
2010-09-28 14:07:23 +02:00
|
|
|
#include <utils/pathchooser.h>
|
2009-06-11 13:40:44 +02:00
|
|
|
#include <utils/qtcassert.h>
|
2010-03-18 10:59:06 +01:00
|
|
|
#include <utils/savedaction.h>
|
2009-06-11 13:40:44 +02:00
|
|
|
|
2009-05-05 10:14:35 +02:00
|
|
|
#include <QtCore/QDebug>
|
|
|
|
|
|
|
|
|
|
#include <QtGui/QAction>
|
|
|
|
|
#include <QtGui/QHeaderView>
|
2010-11-10 11:39:01 +01:00
|
|
|
#include <QtGui/QIntValidator>
|
|
|
|
|
#include <QtGui/QItemSelectionModel>
|
2009-05-05 10:14:35 +02:00
|
|
|
#include <QtGui/QKeyEvent>
|
|
|
|
|
#include <QtGui/QMenu>
|
|
|
|
|
#include <QtGui/QResizeEvent>
|
|
|
|
|
#include <QtGui/QToolButton>
|
|
|
|
|
#include <QtGui/QTreeView>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
namespace Debugger {
|
|
|
|
|
namespace Internal {
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-11-04 09:54:23 +01:00
|
|
|
|
2010-09-21 16:32:43 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// BreakpointDialog
|
|
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class BreakpointDialog : public QDialog, public Ui::BreakpointDialog
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2010-10-04 16:00:25 +02:00
|
|
|
explicit BreakpointDialog(QWidget *parent);
|
|
|
|
|
bool showDialog(BreakpointData *data);
|
2010-09-21 16:32:43 +02:00
|
|
|
|
2010-11-16 10:23:20 +01:00
|
|
|
void setParameters(const BreakpointParameters &p);
|
|
|
|
|
BreakpointParameters parameters() const;
|
|
|
|
|
|
2010-09-21 16:32:43 +02:00
|
|
|
public slots:
|
2010-10-04 16:00:25 +02:00
|
|
|
void typeChanged(int index);
|
2010-11-16 10:23:20 +01:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void setType(BreakpointType type);
|
|
|
|
|
BreakpointType type() const;
|
2010-09-21 16:32:43 +02:00
|
|
|
};
|
|
|
|
|
|
2010-10-04 16:00:25 +02:00
|
|
|
BreakpointDialog::BreakpointDialog(QWidget *parent) : QDialog(parent)
|
|
|
|
|
{
|
2010-11-16 10:23:20 +01:00
|
|
|
// match BreakpointType (except unknown type) with additional item
|
2010-10-04 16:00:25 +02:00
|
|
|
setupUi(this);
|
2010-11-16 10:23:20 +01:00
|
|
|
QStringList types;
|
|
|
|
|
types << tr("File and Line Number") << tr("Function Name") << tr("Address")
|
|
|
|
|
<< tr("throw") << tr("catch") << tr("Function \"main()\"")
|
|
|
|
|
<< tr("Address (Watchpoint)");
|
|
|
|
|
QTC_ASSERT(types.size() == Watchpoint, return; )
|
|
|
|
|
comboBoxType->addItems(types);
|
2010-10-04 16:00:25 +02:00
|
|
|
pathChooserFileName->setExpectedKind(Utils::PathChooser::File);
|
|
|
|
|
connect(comboBoxType, SIGNAL(activated(int)), SLOT(typeChanged(int)));
|
2010-10-28 12:18:38 +02:00
|
|
|
lineEditIgnoreCount->setValidator(
|
|
|
|
|
new QIntValidator(0, 2147483647, lineEditIgnoreCount));
|
2010-10-04 16:00:25 +02:00
|
|
|
}
|
|
|
|
|
|
2010-11-16 10:23:20 +01:00
|
|
|
void BreakpointDialog::setType(BreakpointType type)
|
|
|
|
|
{
|
|
|
|
|
const int comboIndex = type - 1; // Skip UnknownType
|
|
|
|
|
if (comboIndex != comboBoxType->currentIndex()) {
|
|
|
|
|
comboBoxType->setCurrentIndex(comboIndex);
|
|
|
|
|
typeChanged(comboIndex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BreakpointType BreakpointDialog::type() const
|
2010-10-04 16:00:25 +02:00
|
|
|
{
|
2010-11-16 10:23:20 +01:00
|
|
|
const int type = comboBoxType->currentIndex() + 1; // Skip unknown type
|
|
|
|
|
return static_cast<BreakpointType>(type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BreakpointDialog::setParameters(const BreakpointParameters &p)
|
|
|
|
|
{
|
|
|
|
|
pathChooserFileName->setPath(p.fileName);
|
|
|
|
|
lineEditLineNumber->setText(QString::number(p.lineNumber));
|
|
|
|
|
lineEditFunction->setText(p.functionName);
|
|
|
|
|
lineEditCondition->setText(QString::fromUtf8(p.condition));
|
|
|
|
|
lineEditIgnoreCount->setText(QString::number(p.ignoreCount));
|
|
|
|
|
checkBoxUseFullPath->setChecked(p.useFullPath);
|
|
|
|
|
lineEditThreadSpec->setText(p.threadSpec);
|
|
|
|
|
const quint64 address = p.address;
|
2010-11-10 16:33:11 +01:00
|
|
|
if (address)
|
|
|
|
|
lineEditAddress->setText(QString::fromAscii("0x%1").arg(address, 0, 16));
|
2010-11-16 10:23:20 +01:00
|
|
|
setType(p.type);
|
|
|
|
|
}
|
2010-10-04 16:00:25 +02:00
|
|
|
|
2010-11-16 10:23:20 +01:00
|
|
|
BreakpointParameters BreakpointDialog::parameters() const
|
|
|
|
|
{
|
|
|
|
|
BreakpointParameters rc(type());
|
|
|
|
|
rc.lineNumber = lineEditLineNumber->text().toInt();
|
|
|
|
|
rc.useFullPath = checkBoxUseFullPath->isChecked();
|
|
|
|
|
rc.address = lineEditAddress->text().toULongLong(0, 0);
|
|
|
|
|
rc.functionName = lineEditFunction->text();
|
|
|
|
|
rc.fileName = pathChooserFileName->path();
|
|
|
|
|
rc.condition = lineEditCondition->text().toUtf8();
|
|
|
|
|
rc.ignoreCount = lineEditIgnoreCount->text().toInt();
|
|
|
|
|
rc.threadSpec = lineEditThreadSpec->text().toUtf8();
|
|
|
|
|
return rc;
|
2010-10-04 16:00:25 +02:00
|
|
|
}
|
|
|
|
|
|
2010-11-16 10:23:20 +01:00
|
|
|
void BreakpointDialog::typeChanged(int)
|
2010-10-04 16:00:25 +02:00
|
|
|
{
|
2010-11-16 10:23:20 +01:00
|
|
|
const BreakpointType t = type();
|
|
|
|
|
const bool isLineVisible = t == BreakpointByFileAndLine;
|
|
|
|
|
const bool isFunctionVisible = t == BreakpointByFunction || t == BreakpointAtMain;
|
|
|
|
|
const bool isAddressVisible = t == BreakpointByAddress || t == Watchpoint;
|
2010-10-04 16:00:25 +02:00
|
|
|
labelFileName->setEnabled(isLineVisible);
|
|
|
|
|
pathChooserFileName->setEnabled(isLineVisible);
|
|
|
|
|
labelLineNumber->setEnabled(isLineVisible);
|
|
|
|
|
lineEditLineNumber->setEnabled(isLineVisible);
|
|
|
|
|
labelUseFullPath->setEnabled(isLineVisible);
|
|
|
|
|
checkBoxUseFullPath->setEnabled(isLineVisible);
|
|
|
|
|
labelFunction->setEnabled(isFunctionVisible);
|
|
|
|
|
lineEditFunction->setEnabled(isFunctionVisible);
|
|
|
|
|
labelAddress->setEnabled(isAddressVisible);
|
|
|
|
|
lineEditAddress->setEnabled(isAddressVisible);
|
2010-11-16 10:23:20 +01:00
|
|
|
if (t == BreakpointAtMain)
|
2010-10-04 16:00:25 +02:00
|
|
|
lineEditFunction->setText(QLatin1String("main"));
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-16 10:23:20 +01:00
|
|
|
bool BreakpointDialog::showDialog(BreakpointData *data)
|
|
|
|
|
{
|
|
|
|
|
setParameters(data->parameters());
|
|
|
|
|
if (exec() != QDialog::Accepted)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
// Check if changed.
|
|
|
|
|
const BreakpointParameters newParameters = parameters();
|
|
|
|
|
if (newParameters == data->parameters())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
bool result = false;
|
|
|
|
|
result |= data->setType(newParameters.type);
|
|
|
|
|
result |= data->setAddress(newParameters.address);
|
|
|
|
|
result |= data->setFunctionName(newParameters.functionName);
|
|
|
|
|
result |= data->setUseFullPath(newParameters.useFullPath);
|
|
|
|
|
result |= data->setFileName(newParameters.fileName);
|
|
|
|
|
result |= data->setLineNumber(newParameters.lineNumber);
|
|
|
|
|
result |= data->setCondition(newParameters.condition);
|
|
|
|
|
result |= data->setIgnoreCount(newParameters.ignoreCount);
|
|
|
|
|
result |= data->setThreadSpec(newParameters.threadSpec);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-12 11:54:01 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// BreakWindow
|
|
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
BreakWindow::BreakWindow(QWidget *parent)
|
|
|
|
|
: QTreeView(parent)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-06-16 11:08:54 +02:00
|
|
|
m_alwaysResizeColumnsToContents = false;
|
|
|
|
|
|
2010-11-10 16:33:11 +01:00
|
|
|
QAction *act = debuggerCore()->action(UseAlternatingRowColors);
|
2010-03-16 16:55:56 +01:00
|
|
|
setFrameStyle(QFrame::NoFrame);
|
2010-04-16 11:39:36 +02:00
|
|
|
setAttribute(Qt::WA_MacShowFocusRect, false);
|
2008-12-02 12:01:29 +01:00
|
|
|
setWindowTitle(tr("Breakpoints"));
|
2010-07-30 22:16:59 +02:00
|
|
|
setWindowIcon(QIcon(QLatin1String(":/debugger/images/debugger_breakpoints.png")));
|
2009-05-05 10:14:35 +02:00
|
|
|
setAlternatingRowColors(act->isChecked());
|
2008-12-02 12:01:29 +01:00
|
|
|
setRootIsDecorated(false);
|
|
|
|
|
setIconSize(QSize(10, 10));
|
2009-06-11 13:40:44 +02:00
|
|
|
setSelectionMode(QAbstractItemView::ExtendedSelection);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
connect(this, SIGNAL(activated(QModelIndex)),
|
2010-11-10 16:33:11 +01:00
|
|
|
SLOT(rowActivated(QModelIndex)));
|
2009-05-05 10:14:35 +02:00
|
|
|
connect(act, SIGNAL(toggled(bool)),
|
2010-11-10 16:33:11 +01:00
|
|
|
SLOT(setAlternatingRowColorsHelper(bool)));
|
|
|
|
|
connect(debuggerCore()->action(UseAddressInBreakpointsView), SIGNAL(toggled(bool)),
|
|
|
|
|
SLOT(showAddressColumn(bool)));
|
2009-10-01 11:22:44 +02:00
|
|
|
}
|
|
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
BreakWindow::~BreakWindow()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-01 11:22:44 +02:00
|
|
|
void BreakWindow::showAddressColumn(bool on)
|
|
|
|
|
{
|
2010-04-29 18:36:18 +02:00
|
|
|
setColumnHidden(7, !on);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-06-11 13:40:44 +02:00
|
|
|
static QModelIndexList normalizeIndexes(const QModelIndexList &list)
|
|
|
|
|
{
|
|
|
|
|
QModelIndexList res;
|
2010-06-16 11:08:54 +02:00
|
|
|
foreach (const QModelIndex &index, list)
|
|
|
|
|
if (index.column() == 0)
|
|
|
|
|
res.append(index);
|
2009-06-11 13:40:44 +02:00
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-17 18:02:08 +01:00
|
|
|
void BreakWindow::keyPressEvent(QKeyEvent *ev)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-06-11 13:40:44 +02:00
|
|
|
if (ev->key() == Qt::Key_Delete) {
|
|
|
|
|
QItemSelectionModel *sm = selectionModel();
|
|
|
|
|
QTC_ASSERT(sm, return);
|
|
|
|
|
QModelIndexList si = sm->selectedIndexes();
|
|
|
|
|
if (si.isEmpty())
|
|
|
|
|
si.append(currentIndex().sibling(currentIndex().row(), 0));
|
|
|
|
|
deleteBreakpoints(normalizeIndexes(si));
|
|
|
|
|
}
|
2008-12-17 18:02:08 +01:00
|
|
|
QTreeView::keyPressEvent(ev);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2008-12-17 18:02:08 +01:00
|
|
|
void BreakWindow::resizeEvent(QResizeEvent *ev)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2008-12-17 18:02:08 +01:00
|
|
|
QTreeView::resizeEvent(ev);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-04-29 18:36:18 +02:00
|
|
|
void BreakWindow::mouseDoubleClickEvent(QMouseEvent *ev)
|
|
|
|
|
{
|
|
|
|
|
QModelIndex indexUnderMouse = indexAt(ev->pos());
|
2010-05-10 10:33:52 +02:00
|
|
|
if (indexUnderMouse.isValid() && indexUnderMouse.column() >= 4)
|
2010-09-21 16:32:43 +02:00
|
|
|
editBreakpoints(QModelIndexList() << indexUnderMouse);
|
2010-05-10 10:33:52 +02:00
|
|
|
QTreeView::mouseDoubleClickEvent(ev);
|
2010-04-29 18:36:18 +02:00
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void BreakWindow::contextMenuEvent(QContextMenuEvent *ev)
|
|
|
|
|
{
|
|
|
|
|
QMenu menu;
|
2009-06-11 13:40:44 +02:00
|
|
|
QItemSelectionModel *sm = selectionModel();
|
|
|
|
|
QTC_ASSERT(sm, return);
|
|
|
|
|
QModelIndexList si = sm->selectedIndexes();
|
|
|
|
|
QModelIndex indexUnderMouse = indexAt(ev->pos());
|
|
|
|
|
if (si.isEmpty() && indexUnderMouse.isValid())
|
|
|
|
|
si.append(indexUnderMouse.sibling(indexUnderMouse.row(), 0));
|
|
|
|
|
si = normalizeIndexes(si);
|
|
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
const int rowCount = model()->rowCount();
|
2010-11-04 09:54:23 +01:00
|
|
|
const unsigned engineCapabilities = BreakOnThrowAndCatchCapability;
|
2010-11-10 16:33:11 +01:00
|
|
|
BreakHandler *handler = breakHandler();
|
2010-11-04 09:54:23 +01:00
|
|
|
// FIXME BP: model()->data(QModelIndex(), EngineCapabilitiesRole).toUInt();
|
2009-07-16 15:22:54 +02:00
|
|
|
|
2010-02-12 10:52:09 +01:00
|
|
|
QAction *deleteAction = new QAction(tr("Delete Breakpoint"), &menu);
|
2009-07-16 15:22:54 +02:00
|
|
|
deleteAction->setEnabled(si.size() > 0);
|
|
|
|
|
|
2010-02-12 10:52:09 +01:00
|
|
|
QAction *deleteAllAction = new QAction(tr("Delete All Breakpoints"), &menu);
|
2010-09-14 17:15:01 +02:00
|
|
|
deleteAllAction->setEnabled(model()->rowCount() > 0);
|
2009-07-16 15:22:54 +02:00
|
|
|
|
2010-02-12 10:52:09 +01:00
|
|
|
// Delete by file: Find indices of breakpoints of the same file.
|
2009-07-16 15:22:54 +02:00
|
|
|
QAction *deleteByFileAction = 0;
|
2010-11-10 16:33:11 +01:00
|
|
|
QList<QModelIndex> breakPointsOfFile;
|
2009-07-16 15:22:54 +02:00
|
|
|
if (indexUnderMouse.isValid()) {
|
2010-02-12 10:52:09 +01:00
|
|
|
const QModelIndex index = indexUnderMouse.sibling(indexUnderMouse.row(), 2);
|
2010-06-16 11:08:54 +02:00
|
|
|
const QString file = model()->data(index).toString();
|
2009-07-16 15:22:54 +02:00
|
|
|
if (!file.isEmpty()) {
|
|
|
|
|
for (int i = 0; i < rowCount; i++)
|
2010-06-16 11:08:54 +02:00
|
|
|
if (model()->data(model()->index(i, 2)).toString() == file)
|
2010-11-10 16:33:11 +01:00
|
|
|
breakPointsOfFile.push_back(model()->index(i, 2));
|
2009-07-16 15:22:54 +02:00
|
|
|
if (breakPointsOfFile.size() > 1) {
|
2010-02-12 10:52:09 +01:00
|
|
|
deleteByFileAction =
|
|
|
|
|
new QAction(tr("Delete Breakpoints of \"%1\"").arg(file), &menu);
|
2009-07-16 15:22:54 +02:00
|
|
|
deleteByFileAction->setEnabled(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!deleteByFileAction) {
|
2010-02-12 10:52:09 +01:00
|
|
|
deleteByFileAction = new QAction(tr("Delete Breakpoints of File"), &menu);
|
2009-07-16 15:22:54 +02:00
|
|
|
deleteByFileAction->setEnabled(false);
|
|
|
|
|
}
|
2009-06-11 13:40:44 +02:00
|
|
|
|
2010-02-12 10:52:09 +01:00
|
|
|
QAction *adjustColumnAction =
|
|
|
|
|
new QAction(tr("Adjust Column Widths to Contents"), &menu);
|
|
|
|
|
|
|
|
|
|
QAction *alwaysAdjustAction =
|
|
|
|
|
new QAction(tr("Always Adjust Column Widths to Contents"), &menu);
|
2009-06-11 13:40:44 +02:00
|
|
|
|
2009-07-16 15:22:54 +02:00
|
|
|
alwaysAdjustAction->setCheckable(true);
|
|
|
|
|
alwaysAdjustAction->setChecked(m_alwaysResizeColumnsToContents);
|
2009-06-11 13:40:44 +02:00
|
|
|
|
2010-04-29 18:36:18 +02:00
|
|
|
QAction *editBreakpointAction =
|
|
|
|
|
new QAction(tr("Edit Breakpoint..."), &menu);
|
|
|
|
|
editBreakpointAction->setEnabled(si.size() > 0);
|
2009-06-11 13:40:44 +02:00
|
|
|
|
2010-11-04 09:54:23 +01:00
|
|
|
int threadId = 0;
|
|
|
|
|
// FIXME BP: m_engine->threadsHandler()->currentThreadId();
|
2010-04-30 14:18:10 +02:00
|
|
|
QString associateTitle = threadId == -1
|
|
|
|
|
? tr("Associate Breakpoint With All Threads")
|
|
|
|
|
: tr("Associate Breakpoint With Thread %1").arg(threadId);
|
|
|
|
|
QAction *associateBreakpointAction = new QAction(associateTitle, &menu);
|
|
|
|
|
associateBreakpointAction->setEnabled(si.size() > 0);
|
|
|
|
|
|
2010-02-12 10:52:09 +01:00
|
|
|
QAction *synchronizeAction =
|
|
|
|
|
new QAction(tr("Synchronize Breakpoints"), &menu);
|
2010-11-10 11:39:01 +01:00
|
|
|
synchronizeAction->setEnabled(debuggerCore()->hasSnapshots());
|
2009-06-11 13:40:44 +02:00
|
|
|
|
2009-06-17 16:00:03 +02:00
|
|
|
QModelIndex idx0 = (si.size() ? si.front() : QModelIndex());
|
2010-11-10 16:33:11 +01:00
|
|
|
const BreakpointId id = handler->findBreakpointByIndex(idx0);
|
|
|
|
|
|
|
|
|
|
bool enabled = si.isEmpty() || handler->isEnabled(id);
|
2010-04-12 15:24:18 +02:00
|
|
|
|
|
|
|
|
const QString str5 = si.size() > 1
|
|
|
|
|
? enabled
|
|
|
|
|
? tr("Disable Selected Breakpoints")
|
|
|
|
|
: tr("Enable Selected Breakpoints")
|
|
|
|
|
: enabled
|
|
|
|
|
? tr("Disable Breakpoint")
|
|
|
|
|
: tr("Enable Breakpoint");
|
2009-07-16 15:22:54 +02:00
|
|
|
QAction *toggleEnabledAction = new QAction(str5, &menu);
|
|
|
|
|
toggleEnabledAction->setEnabled(si.size() > 0);
|
|
|
|
|
|
2010-09-21 16:32:43 +02:00
|
|
|
QAction *addBreakpointAction =
|
2010-09-28 13:14:14 +02:00
|
|
|
new QAction(tr("Add Breakpoint..."), this);
|
2010-02-11 17:29:10 +01:00
|
|
|
QAction *breakAtThrowAction =
|
|
|
|
|
new QAction(tr("Set Breakpoint at \"throw\""), this);
|
|
|
|
|
QAction *breakAtCatchAction =
|
|
|
|
|
new QAction(tr("Set Breakpoint at \"catch\""), this);
|
2009-07-16 15:22:54 +02:00
|
|
|
|
2010-09-28 13:14:14 +02:00
|
|
|
menu.addAction(addBreakpointAction);
|
2009-07-16 15:22:54 +02:00
|
|
|
menu.addAction(deleteAction);
|
2010-04-29 18:36:18 +02:00
|
|
|
menu.addAction(editBreakpointAction);
|
2010-04-30 14:18:10 +02:00
|
|
|
menu.addAction(associateBreakpointAction);
|
2009-07-16 15:22:54 +02:00
|
|
|
menu.addAction(toggleEnabledAction);
|
|
|
|
|
menu.addSeparator();
|
|
|
|
|
menu.addAction(deleteAllAction);
|
2010-11-10 16:33:11 +01:00
|
|
|
//menu.addAction(deleteByFileAction);
|
2009-03-10 17:30:11 +01:00
|
|
|
menu.addSeparator();
|
2009-07-16 15:22:54 +02:00
|
|
|
menu.addAction(synchronizeAction);
|
2010-02-11 17:29:10 +01:00
|
|
|
if (engineCapabilities & BreakOnThrowAndCatchCapability) {
|
2010-09-28 13:14:14 +02:00
|
|
|
menu.addSeparator();
|
2010-02-11 17:29:10 +01:00
|
|
|
menu.addAction(breakAtThrowAction);
|
|
|
|
|
menu.addAction(breakAtCatchAction);
|
|
|
|
|
}
|
2009-06-12 11:54:01 +02:00
|
|
|
menu.addSeparator();
|
2010-11-10 16:33:11 +01:00
|
|
|
menu.addAction(debuggerCore()->action(UseToolTipsInBreakpointsView));
|
|
|
|
|
menu.addAction(debuggerCore()->action(UseAddressInBreakpointsView));
|
2009-08-18 16:46:33 +02:00
|
|
|
menu.addAction(adjustColumnAction);
|
|
|
|
|
menu.addAction(alwaysAdjustAction);
|
|
|
|
|
menu.addSeparator();
|
2010-11-10 16:33:11 +01:00
|
|
|
menu.addAction(debuggerCore()->action(SettingsDialog));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
QAction *act = menu.exec(ev->globalPos());
|
|
|
|
|
|
2009-07-16 15:22:54 +02:00
|
|
|
if (act == deleteAction) {
|
2009-06-11 13:40:44 +02:00
|
|
|
deleteBreakpoints(si);
|
2009-07-16 15:22:54 +02:00
|
|
|
} else if (act == deleteAllAction) {
|
2010-11-10 16:33:11 +01:00
|
|
|
QList<QModelIndex> allRows;
|
2009-07-16 15:22:54 +02:00
|
|
|
for (int i = 0; i < rowCount; i++)
|
2010-11-10 16:33:11 +01:00
|
|
|
allRows.push_back(model()->index(i, 0));
|
2009-07-16 15:22:54 +02:00
|
|
|
deleteBreakpoints(allRows);
|
|
|
|
|
} else if (act == deleteByFileAction)
|
|
|
|
|
deleteBreakpoints(breakPointsOfFile);
|
|
|
|
|
else if (act == adjustColumnAction)
|
2008-12-02 12:01:29 +01:00
|
|
|
resizeColumnsToContents();
|
2009-07-16 15:22:54 +02:00
|
|
|
else if (act == alwaysAdjustAction)
|
2008-12-02 12:01:29 +01:00
|
|
|
setAlwaysResizeColumnsToContents(!m_alwaysResizeColumnsToContents);
|
2010-04-29 18:36:18 +02:00
|
|
|
else if (act == editBreakpointAction)
|
2010-09-21 16:32:43 +02:00
|
|
|
editBreakpoints(si);
|
2010-04-30 14:18:10 +02:00
|
|
|
else if (act == associateBreakpointAction)
|
|
|
|
|
associateBreakpoint(si, threadId);
|
2009-07-16 15:22:54 +02:00
|
|
|
else if (act == synchronizeAction)
|
2010-11-10 16:33:11 +01:00
|
|
|
; //synchronizeBreakpoints();
|
2009-07-16 15:22:54 +02:00
|
|
|
else if (act == toggleEnabledAction)
|
2009-06-11 13:40:44 +02:00
|
|
|
setBreakpointsEnabled(si, !enabled);
|
2010-09-21 16:32:43 +02:00
|
|
|
else if (act == addBreakpointAction)
|
|
|
|
|
addBreakpoint();
|
2010-11-04 09:54:23 +01:00
|
|
|
else if (act == breakAtThrowAction) {
|
2010-11-16 10:23:20 +01:00
|
|
|
handler->appendBreakpoint(BreakpointData(BreakpointAtThrow));
|
2010-11-04 09:54:23 +01:00
|
|
|
} else if (act == breakAtCatchAction) {
|
2010-11-16 10:23:20 +01:00
|
|
|
handler->appendBreakpoint(BreakpointData(BreakpointAtCatch));
|
2010-11-04 09:54:23 +01:00
|
|
|
}
|
2009-06-11 13:40:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BreakWindow::setBreakpointsEnabled(const QModelIndexList &list, bool enabled)
|
|
|
|
|
{
|
2010-11-10 16:33:11 +01:00
|
|
|
BreakHandler *handler = breakHandler();
|
2010-11-15 15:30:39 +01:00
|
|
|
foreach (const BreakpointId id, handler->findBreakpointsByIndex(list))
|
|
|
|
|
handler->setEnabled(id, enabled);
|
2009-06-11 13:40:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BreakWindow::setBreakpointsFullPath(const QModelIndexList &list, bool fullpath)
|
|
|
|
|
{
|
2010-11-10 16:33:11 +01:00
|
|
|
BreakHandler *handler = breakHandler();
|
2010-11-15 15:30:39 +01:00
|
|
|
foreach (const BreakpointId id, handler->findBreakpointsByIndex(list))
|
|
|
|
|
handler->setUseFullPath(id, fullpath);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-11-10 16:33:11 +01:00
|
|
|
void BreakWindow::deleteBreakpoints(const QModelIndexList &list)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-11-10 16:33:11 +01:00
|
|
|
BreakHandler *handler = breakHandler();
|
2010-11-15 15:30:39 +01:00
|
|
|
foreach (const BreakpointId id, handler->findBreakpointsByIndex(list))
|
|
|
|
|
handler->removeBreakpoint(id);
|
2009-07-16 15:22:54 +02:00
|
|
|
}
|
2009-06-11 13:40:44 +02:00
|
|
|
|
2010-11-15 14:12:05 +01:00
|
|
|
void BreakWindow::editBreakpoint(BreakpointId id, QWidget *parent)
|
2010-09-21 16:32:43 +02:00
|
|
|
{
|
2010-10-06 10:32:36 +02:00
|
|
|
BreakpointDialog dialog(parent);
|
2010-11-15 14:12:05 +01:00
|
|
|
dialog.showDialog(breakHandler()->breakpointById(id));
|
2010-09-28 13:14:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BreakWindow::addBreakpoint()
|
|
|
|
|
{
|
2010-11-15 17:25:42 +01:00
|
|
|
BreakpointData data(BreakpointByFileAndLine);
|
2010-11-15 14:12:05 +01:00
|
|
|
BreakpointDialog dialog(this);
|
|
|
|
|
if (dialog.showDialog(&data))
|
2010-11-10 16:33:11 +01:00
|
|
|
breakHandler()->appendBreakpoint(data);
|
2010-09-21 16:32:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BreakWindow::editBreakpoints(const QModelIndexList &list)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-10-06 10:32:36 +02:00
|
|
|
QTC_ASSERT(!list.isEmpty(), return);
|
2010-11-04 09:54:23 +01:00
|
|
|
|
2010-11-10 16:33:11 +01:00
|
|
|
BreakHandler *handler = breakHandler();
|
2010-11-15 15:30:39 +01:00
|
|
|
const BreakpointIds ids = handler->findBreakpointsByIndex(list);
|
|
|
|
|
const BreakpointId id = ids.at(0);
|
2010-11-10 16:33:11 +01:00
|
|
|
|
2010-09-28 13:14:14 +02:00
|
|
|
if (list.size() == 1) {
|
2010-11-10 16:33:11 +01:00
|
|
|
editBreakpoint(id, this);
|
2010-09-28 13:14:14 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This allows to change properties of multiple breakpoints at a time.
|
2008-12-02 12:01:29 +01:00
|
|
|
QDialog dlg(this);
|
|
|
|
|
Ui::BreakCondition ui;
|
|
|
|
|
ui.setupUi(&dlg);
|
2010-09-28 13:14:14 +02:00
|
|
|
dlg.setWindowTitle(tr("Edit Breakpoint Properties"));
|
2010-11-04 09:54:23 +01:00
|
|
|
ui.lineEditIgnoreCount->setValidator(
|
|
|
|
|
new QIntValidator(0, 2147483647, ui.lineEditIgnoreCount));
|
2010-10-06 10:32:36 +02:00
|
|
|
|
2010-11-10 16:33:11 +01:00
|
|
|
const QString oldCondition = QString::fromLatin1(handler->condition(id));
|
|
|
|
|
const QString oldIgnoreCount = QString::number(handler->ignoreCount(id));
|
|
|
|
|
const QString oldThreadSpec = QString::fromLatin1(handler->threadSpec(id));
|
2010-10-06 10:32:36 +02:00
|
|
|
|
|
|
|
|
ui.lineEditCondition->setText(oldCondition);
|
|
|
|
|
ui.lineEditIgnoreCount->setText(oldIgnoreCount);
|
|
|
|
|
ui.lineEditThreadSpec->setText(oldThreadSpec);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
if (dlg.exec() == QDialog::Rejected)
|
|
|
|
|
return;
|
|
|
|
|
|
2010-10-06 10:32:36 +02:00
|
|
|
const QString newCondition = ui.lineEditCondition->text();
|
|
|
|
|
const QString newIgnoreCount = ui.lineEditIgnoreCount->text();
|
|
|
|
|
const QString newThreadSpec = ui.lineEditThreadSpec->text();
|
|
|
|
|
|
|
|
|
|
// Unchanged -> cancel
|
|
|
|
|
if (newCondition == oldCondition && newIgnoreCount == oldIgnoreCount
|
|
|
|
|
&& newThreadSpec == oldThreadSpec)
|
|
|
|
|
return;
|
|
|
|
|
|
2010-11-15 15:30:39 +01:00
|
|
|
foreach (const BreakpointId id, handler->findBreakpointsByIndex(list)) {
|
2010-11-10 16:33:11 +01:00
|
|
|
handler->setCondition(id, newCondition.toLatin1());
|
|
|
|
|
handler->setIgnoreCount(id, newIgnoreCount.toInt());
|
|
|
|
|
handler->setThreadSpec(id, newThreadSpec.toLatin1());
|
2009-06-11 13:40:44 +02:00
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-04-30 14:18:10 +02:00
|
|
|
void BreakWindow::associateBreakpoint(const QModelIndexList &list, int threadId)
|
|
|
|
|
{
|
2010-11-10 16:33:11 +01:00
|
|
|
BreakHandler *handler = breakHandler();
|
|
|
|
|
QByteArray spec = QByteArray::number(threadId);
|
2010-11-15 15:30:39 +01:00
|
|
|
foreach (const BreakpointId id, handler->findBreakpointsByIndex(list))
|
|
|
|
|
handler->setThreadSpec(id, spec);
|
2010-04-30 14:18:10 +02:00
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void BreakWindow::resizeColumnsToContents()
|
|
|
|
|
{
|
2009-10-01 11:22:44 +02:00
|
|
|
for (int i = model()->columnCount(); --i >= 0; )
|
|
|
|
|
resizeColumnToContents(i);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BreakWindow::setAlwaysResizeColumnsToContents(bool on)
|
|
|
|
|
{
|
|
|
|
|
m_alwaysResizeColumnsToContents = on;
|
2010-01-29 21:33:57 +01:00
|
|
|
QHeaderView::ResizeMode mode = on
|
2008-12-02 12:01:29 +01:00
|
|
|
? QHeaderView::ResizeToContents : QHeaderView::Interactive;
|
2009-10-01 11:22:44 +02:00
|
|
|
for (int i = model()->columnCount(); --i >= 0; )
|
|
|
|
|
header()->setResizeMode(i, mode);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
void BreakWindow::rowActivated(const QModelIndex &index)
|
|
|
|
|
{
|
2010-11-10 16:33:11 +01:00
|
|
|
breakHandler()->gotoLocation(breakHandler()->findBreakpointByIndex(index));
|
2010-06-16 11:08:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Debugger
|
2010-09-21 16:32:43 +02:00
|
|
|
|
|
|
|
|
#include "breakwindow.moc"
|