2010-07-13 17:16:31 +02:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
|
|
|
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
|
|
|
**
|
|
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
|
|
|
**
|
|
|
|
|
** Commercial Usage
|
|
|
|
|
**
|
|
|
|
|
** 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.
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
|
|
|
|
** 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.
|
|
|
|
|
**
|
|
|
|
|
** If you are unsure which license is appropriate for your use, please
|
|
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
|
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
2010-10-25 14:00:19 +02:00
|
|
|
#include "breakpoint.h"
|
2010-07-13 17:16:31 +02:00
|
|
|
#include "stackframe.h"
|
|
|
|
|
|
|
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
|
|
|
|
#include <QtCore/QByteArray>
|
|
|
|
|
#include <QtCore/QDebug>
|
|
|
|
|
#include <QtCore/QTextStream>
|
|
|
|
|
#include <QtCore/QFileInfo>
|
2010-09-17 13:28:50 +02:00
|
|
|
#include <QtCore/QDir>
|
2010-07-13 17:16:31 +02:00
|
|
|
|
|
|
|
|
namespace Debugger {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// BreakpointData
|
|
|
|
|
//
|
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2010-09-28 16:42:21 +02:00
|
|
|
const char *BreakpointData::throwFunction = "throw";
|
|
|
|
|
const char *BreakpointData::catchFunction = "catch";
|
|
|
|
|
|
2010-11-15 14:12:05 +01:00
|
|
|
BreakpointData::BreakpointData(BreakpointType type)
|
2010-07-13 17:16:31 +02:00
|
|
|
{
|
2010-11-15 14:12:05 +01:00
|
|
|
m_type = type;
|
2010-11-10 16:33:11 +01:00
|
|
|
m_enabled = true;
|
|
|
|
|
m_ignoreCount = 0;
|
|
|
|
|
m_lineNumber = 0;
|
|
|
|
|
m_address = 0;
|
|
|
|
|
m_useFullPath = false;
|
|
|
|
|
m_markerLineNumber = 0;
|
2010-07-13 17:16:31 +02:00
|
|
|
}
|
|
|
|
|
|
2010-11-10 16:33:11 +01:00
|
|
|
BreakpointResponse::BreakpointResponse()
|
2010-10-05 16:05:47 +02:00
|
|
|
{
|
2010-11-10 16:33:11 +01:00
|
|
|
bpNumber = 0;
|
2010-10-05 16:05:47 +02:00
|
|
|
bpIgnoreCount = 0;
|
|
|
|
|
bpLineNumber = 0;
|
2010-11-10 16:33:11 +01:00
|
|
|
//bpCorrectedLineNumber = 0;
|
2010-10-05 16:05:47 +02:00
|
|
|
bpAddress = 0;
|
|
|
|
|
bpMultiple = false;
|
|
|
|
|
bpEnabled = true;
|
2010-07-13 17:16:31 +02:00
|
|
|
}
|
|
|
|
|
|
2010-11-10 16:33:11 +01:00
|
|
|
#define SETIT(var, value) return (var != value) && (var = value, true)
|
2010-07-13 17:16:31 +02:00
|
|
|
|
2010-11-10 16:33:11 +01:00
|
|
|
bool BreakpointData::setUseFullPath(bool on)
|
|
|
|
|
{ SETIT(m_useFullPath, on); }
|
|
|
|
|
|
|
|
|
|
bool BreakpointData::setMarkerFileName(const QString &file)
|
|
|
|
|
{ SETIT(m_markerFileName, file); }
|
|
|
|
|
|
|
|
|
|
bool BreakpointData::setMarkerLineNumber(int line)
|
|
|
|
|
{ SETIT(m_markerLineNumber, line); }
|
|
|
|
|
|
|
|
|
|
bool BreakpointData::setFileName(const QString &file)
|
|
|
|
|
{ SETIT(m_fileName, file); }
|
|
|
|
|
|
|
|
|
|
bool BreakpointData::setEnabled(bool on)
|
|
|
|
|
{ SETIT(m_enabled, on); }
|
|
|
|
|
|
2010-11-15 14:12:05 +01:00
|
|
|
bool BreakpointData::setIgnoreCount(int count)
|
2010-11-10 16:33:11 +01:00
|
|
|
{ SETIT(m_ignoreCount, count); }
|
|
|
|
|
|
|
|
|
|
bool BreakpointData::setFunctionName(const QString &name)
|
|
|
|
|
{ SETIT(m_functionName, name); }
|
|
|
|
|
|
|
|
|
|
bool BreakpointData::setLineNumber(int line)
|
|
|
|
|
{ SETIT(m_lineNumber, line); }
|
|
|
|
|
|
|
|
|
|
bool BreakpointData::setAddress(quint64 address)
|
|
|
|
|
{ SETIT(m_address, address); }
|
2010-07-13 17:16:31 +02:00
|
|
|
|
2010-11-10 16:33:11 +01:00
|
|
|
bool BreakpointData::setThreadSpec(const QByteArray &spec)
|
|
|
|
|
{ SETIT(m_threadSpec, spec); }
|
|
|
|
|
|
|
|
|
|
bool BreakpointData::setType(BreakpointType type)
|
|
|
|
|
{ SETIT(m_type, type); }
|
|
|
|
|
|
|
|
|
|
bool BreakpointData::setCondition(const QByteArray &cond)
|
|
|
|
|
{ SETIT(m_condition, cond); }
|
|
|
|
|
|
|
|
|
|
#undef SETIT
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void formatAddress(QTextStream &str, quint64 address)
|
2010-09-21 14:26:45 +02:00
|
|
|
{
|
|
|
|
|
if (address) {
|
|
|
|
|
str << "0x";
|
|
|
|
|
str.setIntegerBase(16);
|
|
|
|
|
str << address;
|
|
|
|
|
str.setIntegerBase(10);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-13 17:16:31 +02:00
|
|
|
QString BreakpointData::toToolTip() const
|
|
|
|
|
{
|
2010-11-10 16:33:11 +01:00
|
|
|
QString t;
|
|
|
|
|
switch (m_type) {
|
2010-10-28 12:18:38 +02:00
|
|
|
case BreakpointByFileAndLine:
|
|
|
|
|
t = tr("Breakpoint by File and Line");
|
|
|
|
|
break;
|
|
|
|
|
case BreakpointByFunction:
|
|
|
|
|
t = tr("Breakpoint by Function");
|
|
|
|
|
break;
|
|
|
|
|
case BreakpointByAddress:
|
|
|
|
|
t = tr("Breakpoint by Address");
|
|
|
|
|
break;
|
|
|
|
|
case Watchpoint:
|
|
|
|
|
t = tr("Watchpoint");
|
|
|
|
|
break;
|
2010-11-10 16:33:11 +01:00
|
|
|
case UnknownType:
|
|
|
|
|
t = tr("Unknown Breakpoint Type");
|
2010-10-28 12:18:38 +02:00
|
|
|
}
|
|
|
|
|
|
2010-07-13 17:16:31 +02:00
|
|
|
QString rc;
|
|
|
|
|
QTextStream str(&rc);
|
|
|
|
|
str << "<html><body><table>"
|
2010-11-10 16:33:11 +01:00
|
|
|
//<< "<tr><td>" << tr("Id:")
|
|
|
|
|
//<< "</td><td>" << m_id << "</td></tr>"
|
2010-11-15 14:12:05 +01:00
|
|
|
//<< "<tr><td>" << tr("State:")
|
|
|
|
|
//<< "</td><td>" << m_state << "</td></tr>"
|
|
|
|
|
//<< "<tr><td>" << tr("Engine:")
|
|
|
|
|
//<< "</td><td>" << m_engine << "</td></tr>"
|
2010-10-25 14:00:19 +02:00
|
|
|
<< "<tr><td>" << tr("Marker File:")
|
2010-09-17 13:28:50 +02:00
|
|
|
<< "</td><td>" << QDir::toNativeSeparators(m_markerFileName) << "</td></tr>"
|
2010-10-25 14:00:19 +02:00
|
|
|
<< "<tr><td>" << tr("Marker Line:")
|
2010-07-13 17:16:31 +02:00
|
|
|
<< "</td><td>" << m_markerLineNumber << "</td></tr>"
|
2010-11-10 16:33:11 +01:00
|
|
|
//<< "<tr><td>" << tr("Breakpoint Number:")
|
|
|
|
|
//<< "</td><td>" << bpNumber << "</td></tr>"
|
2010-10-25 14:00:19 +02:00
|
|
|
<< "<tr><td>" << tr("Breakpoint Type:")
|
2010-10-28 12:18:38 +02:00
|
|
|
<< "</td><td>" << t << "</td></tr>"
|
2010-10-25 14:00:19 +02:00
|
|
|
<< "<tr><td>" << tr("State:")
|
2010-11-10 16:33:11 +01:00
|
|
|
//<< "</td><td>" << bpState << "</td></tr>"
|
2010-07-13 17:16:31 +02:00
|
|
|
<< "</table><br><hr><table>"
|
2010-10-25 14:00:19 +02:00
|
|
|
<< "<tr><th>" << tr("Property")
|
|
|
|
|
<< "</th><th>" << tr("Requested")
|
|
|
|
|
<< "</th><th>" << tr("Obtained") << "</th></tr>"
|
|
|
|
|
<< "<tr><td>" << tr("Internal Number:")
|
2010-11-10 16:33:11 +01:00
|
|
|
//<< "</td><td>—</td><td>" << bpNumber << "</td></tr>"
|
2010-10-25 14:00:19 +02:00
|
|
|
<< "<tr><td>" << tr("File Name:")
|
2010-11-10 16:33:11 +01:00
|
|
|
<< "</td><td>" << QDir::toNativeSeparators(m_fileName)
|
|
|
|
|
//<< "</td><td>" << QDir::toNativeSeparators(bpFileName) << "</td></tr>"
|
2010-10-25 14:00:19 +02:00
|
|
|
<< "<tr><td>" << tr("Function Name:")
|
2010-11-10 16:33:11 +01:00
|
|
|
<< "</td><td>" << m_functionName // << "</td><td>" << bpFuncName << "</td></tr>"
|
2010-10-25 14:00:19 +02:00
|
|
|
<< "<tr><td>" << tr("Line Number:") << "</td><td>";
|
2010-11-10 16:33:11 +01:00
|
|
|
if (m_lineNumber)
|
|
|
|
|
str << m_lineNumber;
|
|
|
|
|
//str << "</td><td>";
|
|
|
|
|
//if (bpLineNumber)
|
|
|
|
|
// str << bpLineNumber;
|
2010-09-21 14:26:45 +02:00
|
|
|
str << "</td></tr>"
|
2010-10-25 14:00:19 +02:00
|
|
|
<< "<tr><td>" << tr("Breakpoint Address:")
|
2010-09-21 14:26:45 +02:00
|
|
|
<< "</td><td>";
|
2010-11-10 16:33:11 +01:00
|
|
|
formatAddress(str, m_address);
|
2010-09-21 14:26:45 +02:00
|
|
|
str << "</td><td>";
|
2010-11-10 16:33:11 +01:00
|
|
|
//formatAddress(str, bpAddress);
|
|
|
|
|
//str << "</td></tr>"
|
|
|
|
|
// << "<tr><td>" << tr("Corrected Line Number:")
|
|
|
|
|
// << "</td><td>-</td><td>";
|
|
|
|
|
//if (bpCorrectedLineNumber > 0) {
|
|
|
|
|
// str << bpCorrectedLineNumber;
|
|
|
|
|
// } else {
|
|
|
|
|
// str << '-';
|
|
|
|
|
// }
|
2010-09-21 14:26:45 +02:00
|
|
|
str << "</td></tr>"
|
2010-10-25 14:00:19 +02:00
|
|
|
<< "<tr><td>" << tr("Condition:")
|
2010-11-10 16:33:11 +01:00
|
|
|
// << "</td><td>" << m_condition << "</td><td>" << bpCondition << "</td></tr>"
|
2010-10-25 14:00:19 +02:00
|
|
|
<< "<tr><td>" << tr("Ignore Count:") << "</td><td>";
|
2010-11-10 16:33:11 +01:00
|
|
|
if (m_ignoreCount)
|
|
|
|
|
str << m_ignoreCount;
|
2010-09-21 14:26:45 +02:00
|
|
|
str << "</td><td>";
|
2010-11-10 16:33:11 +01:00
|
|
|
//if (bpIgnoreCount)
|
|
|
|
|
// str << bpIgnoreCount;
|
2010-09-21 14:26:45 +02:00
|
|
|
str << "</td></tr>"
|
2010-10-25 14:00:19 +02:00
|
|
|
<< "<tr><td>" << tr("Thread Specification:")
|
2010-11-10 16:33:11 +01:00
|
|
|
// << "</td><td>" << m_threadSpec << "</td><td>" << bpThreadSpec << "</td></tr>"
|
2010-07-13 17:16:31 +02:00
|
|
|
<< "</table></body></html>";
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-25 14:00:19 +02:00
|
|
|
// Compare file names case insensitively on Windows.
|
|
|
|
|
static inline bool fileNameMatch(const QString &f1, const QString &f2)
|
|
|
|
|
{
|
|
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
|
return f1.compare(f2, Qt::CaseInsensitive) == 0;
|
|
|
|
|
#else
|
|
|
|
|
return f1 == f2;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-10 16:33:11 +01:00
|
|
|
bool BreakpointData::isLocatedAt(const QString &fileName, int lineNumber,
|
2010-09-08 09:54:40 +02:00
|
|
|
bool useMarkerPosition) const
|
2010-07-13 17:16:31 +02:00
|
|
|
{
|
2010-11-10 16:33:11 +01:00
|
|
|
int line = useMarkerPosition ? m_markerLineNumber : m_lineNumber;
|
|
|
|
|
return lineNumber == line && fileNameMatch(fileName, m_markerFileName);
|
2010-07-13 17:16:31 +02:00
|
|
|
}
|
|
|
|
|
|
2010-11-10 16:33:11 +01:00
|
|
|
bool BreakpointData::conditionsMatch(const QString &other) const
|
2010-07-13 17:16:31 +02:00
|
|
|
{
|
|
|
|
|
// Some versions of gdb "beautify" the passed condition.
|
2010-11-10 16:33:11 +01:00
|
|
|
QString s1 = m_condition;
|
2010-07-13 17:16:31 +02:00
|
|
|
s1.remove(QChar(' '));
|
2010-11-10 16:33:11 +01:00
|
|
|
QString s2 = other;
|
2010-07-13 17:16:31 +02:00
|
|
|
s2.remove(QChar(' '));
|
|
|
|
|
return s1 == s2;
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-10 16:33:11 +01:00
|
|
|
QString BreakpointData::toString() const
|
|
|
|
|
{
|
|
|
|
|
QString result;
|
|
|
|
|
QTextStream ts(&result);
|
|
|
|
|
ts << fileName();
|
|
|
|
|
ts << condition();
|
|
|
|
|
ts << ignoreCount();
|
|
|
|
|
ts << lineNumber();
|
|
|
|
|
ts << address();
|
|
|
|
|
ts << functionName();
|
|
|
|
|
ts << useFullPath();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString BreakpointResponse::toString() const
|
|
|
|
|
{
|
|
|
|
|
QString result;
|
|
|
|
|
QTextStream ts(&result);
|
|
|
|
|
ts << bpNumber;
|
|
|
|
|
ts << bpCondition;
|
|
|
|
|
ts << bpIgnoreCount;
|
|
|
|
|
ts << bpFileName;
|
|
|
|
|
ts << bpFullName;
|
|
|
|
|
ts << bpLineNumber;
|
|
|
|
|
ts << bpThreadSpec;
|
|
|
|
|
ts << bpFuncName;
|
|
|
|
|
ts << bpAddress;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-13 17:16:31 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Debugger
|