2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-03-04 12:15:18 +01:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
|
** Contact: http://www.qt.io/licensing
|
2011-03-04 12:15:18 +01:00
|
|
|
** Author: Frank Osterfeld, KDAB (frank.osterfeld@kdab.com)
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-03-04 12:15:18 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2011-03-04 12:15:18 +01:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2011-03-04 12:15:18 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2011-03-04 12:15:18 +01:00
|
|
|
|
|
|
|
|
#include "error.h"
|
|
|
|
|
#include "frame.h"
|
|
|
|
|
#include "stack.h"
|
|
|
|
|
#include "suppression.h"
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QSharedData>
|
|
|
|
|
#include <QString>
|
|
|
|
|
#include <QTextStream>
|
|
|
|
|
#include <QVector>
|
2011-03-04 12:15:18 +01:00
|
|
|
|
2014-06-16 21:34:13 +04:00
|
|
|
#include <algorithm>
|
2011-03-04 12:15:18 +01:00
|
|
|
|
2011-05-18 17:05:49 +02:00
|
|
|
namespace Valgrind {
|
|
|
|
|
namespace XmlProtocol {
|
2011-03-04 12:15:18 +01:00
|
|
|
|
2011-05-18 17:05:49 +02:00
|
|
|
class Error::Private : public QSharedData
|
|
|
|
|
{
|
2011-03-04 12:15:18 +01:00
|
|
|
public:
|
|
|
|
|
explicit Private() :
|
|
|
|
|
unique(0),
|
|
|
|
|
tid(0),
|
|
|
|
|
kind(0),
|
|
|
|
|
leakedBytes(0),
|
|
|
|
|
leakedBlocks(0),
|
|
|
|
|
hThreadId(-1)
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
qint64 unique;
|
|
|
|
|
qint64 tid;
|
|
|
|
|
QString what;
|
|
|
|
|
int kind;
|
|
|
|
|
QVector<Stack> stacks;
|
|
|
|
|
Suppression suppression;
|
|
|
|
|
quint64 leakedBytes;
|
|
|
|
|
qint64 leakedBlocks;
|
|
|
|
|
qint64 hThreadId;
|
|
|
|
|
|
|
|
|
|
bool operator==(const Private &other) const
|
|
|
|
|
{
|
|
|
|
|
return unique == other.unique
|
|
|
|
|
&& tid == other.tid
|
|
|
|
|
&& what == other.what
|
|
|
|
|
&& kind == other.kind
|
|
|
|
|
&& stacks == other.stacks
|
|
|
|
|
&& suppression == other.suppression
|
|
|
|
|
&& leakedBytes == other.leakedBytes
|
|
|
|
|
&& leakedBlocks == other.leakedBlocks
|
|
|
|
|
&& hThreadId == other.hThreadId;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Error::Error() :
|
|
|
|
|
d(new Private)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Error::~Error()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Error::Error(const Error &other) :
|
|
|
|
|
d( other.d )
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Error::swap(Error &other)
|
|
|
|
|
{
|
2014-06-16 21:34:13 +04:00
|
|
|
std::swap(d, other.d);
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Error &Error::operator=(const Error &other)
|
|
|
|
|
{
|
|
|
|
|
Error tmp(other);
|
|
|
|
|
swap(tmp);
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Error::operator ==(const Error &other) const
|
|
|
|
|
{
|
|
|
|
|
return *d == *other.d;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Error::operator !=(const Error &other) const
|
|
|
|
|
{
|
|
|
|
|
return !(*d == *other.d);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Suppression Error::suppression() const
|
|
|
|
|
{
|
|
|
|
|
return d->suppression;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Error::setSuppression(const Suppression &supp)
|
|
|
|
|
{
|
|
|
|
|
d->suppression = supp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
qint64 Error::unique() const
|
|
|
|
|
{
|
|
|
|
|
return d->unique;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Error::setUnique(qint64 unique)
|
|
|
|
|
{
|
|
|
|
|
d->unique = unique;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
qint64 Error::tid() const
|
|
|
|
|
{
|
|
|
|
|
return d->tid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Error::setTid(qint64 tid)
|
|
|
|
|
{
|
|
|
|
|
d->tid = tid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
quint64 Error::leakedBytes() const
|
|
|
|
|
{
|
|
|
|
|
return d->leakedBytes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Error::setLeakedBytes(quint64 l)
|
|
|
|
|
{
|
|
|
|
|
d->leakedBytes = l;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
qint64 Error::leakedBlocks() const
|
|
|
|
|
{
|
|
|
|
|
return d->leakedBlocks;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Error::setLeakedBlocks(qint64 b)
|
|
|
|
|
{
|
|
|
|
|
d->leakedBlocks = b;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString Error::what() const
|
|
|
|
|
{
|
|
|
|
|
return d->what;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Error::setWhat(const QString &what)
|
|
|
|
|
{
|
|
|
|
|
d->what = what;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int Error::kind() const
|
|
|
|
|
{
|
|
|
|
|
return d->kind;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Error::setKind(int k)
|
|
|
|
|
{
|
|
|
|
|
d->kind = k;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVector<Stack> Error::stacks() const
|
|
|
|
|
{
|
|
|
|
|
return d->stacks;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Error::setStacks(const QVector<Stack> &stacks)
|
|
|
|
|
{
|
|
|
|
|
d->stacks = stacks;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Error::setHelgrindThreadId(qint64 id)
|
|
|
|
|
{
|
|
|
|
|
d->hThreadId = id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
qint64 Error::helgrindThreadId() const
|
|
|
|
|
{
|
|
|
|
|
return d->hThreadId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString Error::toXml() const
|
|
|
|
|
{
|
|
|
|
|
QString xml;
|
|
|
|
|
QTextStream stream(&xml);
|
|
|
|
|
stream << "<error>\n";
|
|
|
|
|
stream << " <unique>" << d->unique << "</unique>\n";
|
|
|
|
|
stream << " <tid>" << d->tid << "</tid>\n";
|
|
|
|
|
stream << " <kind>" << d->kind << "</kind>\n";
|
|
|
|
|
if (d->leakedBlocks > 0 && d->leakedBytes > 0) {
|
|
|
|
|
stream << " <xwhat>\n"
|
|
|
|
|
<< " <text>" << d->what << "</text>\n"
|
|
|
|
|
<< " <leakedbytes>" << d->leakedBytes << "</leakedbytes>\n"
|
|
|
|
|
<< " <leakedblocks>" << d->leakedBlocks << "</leakedblocks>\n"
|
|
|
|
|
<< " </xwhat>\n";
|
|
|
|
|
} else {
|
|
|
|
|
stream << " <what>" << d->what << "</what>\n";
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-11 16:26:34 +02:00
|
|
|
foreach (const Stack &stack, d->stacks) {
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (!stack.auxWhat().isEmpty())
|
2011-03-04 12:15:18 +01:00
|
|
|
stream << " <auxwhat>" << stack.auxWhat() << "</auxwhat>\n";
|
|
|
|
|
stream << " <stack>\n";
|
|
|
|
|
|
2011-05-11 16:26:34 +02:00
|
|
|
foreach (const Frame &frame, stack.frames()) {
|
2011-03-04 12:15:18 +01:00
|
|
|
stream << " <frame>\n";
|
|
|
|
|
stream << " <ip>0x" << QString::number(frame.instructionPointer(), 16) << "</ip>\n";
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (!frame.object().isEmpty())
|
2011-03-04 12:15:18 +01:00
|
|
|
stream << " <obj>" << frame.object() << "</obj>\n";
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (!frame.functionName().isEmpty())
|
2011-03-04 12:15:18 +01:00
|
|
|
stream << " <fn>" << frame.functionName() << "</fn>\n";
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (!frame.directory().isEmpty())
|
2011-03-04 12:15:18 +01:00
|
|
|
stream << " <dir>" << frame.directory() << "</dir>\n";
|
2015-06-26 14:12:33 +02:00
|
|
|
if (!frame.fileName().isEmpty())
|
|
|
|
|
stream << " <file>" << frame.fileName() << "</file>\n";
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (frame.line() != -1)
|
2011-03-04 12:15:18 +01:00
|
|
|
stream << " <line>" << frame.line() << "</line>";
|
|
|
|
|
stream << " </frame>\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stream << " </stack>\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stream << "</error>\n";
|
|
|
|
|
|
|
|
|
|
return xml;
|
|
|
|
|
}
|
2011-05-18 17:05:49 +02:00
|
|
|
|
|
|
|
|
} // namespace XmlProtocol
|
|
|
|
|
} // namespace Valgrind
|