tests: move valgrind into auto tests

* re-added some test data files
* added QSKIP for not existing data files

Change-Id: Ie0ae3f563e0d94534b620320176b7ec56e36d313
Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
Christian Stenger
2013-02-22 17:07:43 +01:00
committed by hjk
parent f1b358562c
commit e6c0c292b9
59 changed files with 1390 additions and 19 deletions
+2 -1
View File
@@ -14,7 +14,8 @@ SUBDIRS += \
qtcprocess \
utils \
utils_stringutils \
filesearch
filesearch \
valgrind
#contains (QT_CONFIG, declarative) {
#SUBDIRS += qml
+15
View File
@@ -0,0 +1,15 @@
# HOWTO COMPILE
# go to your build folder of Qt Creator
cd /path/to/qtc-build
# create and enter build directory for valgrind tests
mkdir valgrind-test
cd valgrind-test
# make library paths known to ldconfig
export LD_LIBRARY_PATH=/path/to/qtc-build/lib/qtcreator:/path/to/qtc-build/lib/qtcreator/plugins/QtProject
# run qmake, make
qmake CONFIG+=debug IDE_BUILD_TREE=$(readlink -f ..) ../../path/to/qtc/tests/auto/valgrind
make
@@ -0,0 +1,4 @@
TEMPLATE = subdirs
SUBDIRS += callgrindparsertests.pro
# modeltest.pro not compiling due to missing widget handler.
@@ -0,0 +1,472 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** 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
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "callgrindparsertests.h"
#include <valgrind/callgrind/callgrindparser.h>
#include <valgrind/callgrind/callgrindfunctioncall.h>
#include <valgrind/callgrind/callgrindfunction.h>
#include <valgrind/callgrind/callgrindfunctioncycle.h>
#include <valgrind/callgrind/callgrindcostitem.h>
#include <valgrind/callgrind/callgrindparsedata.h>
#include <QDebug>
#include <QFile>
#include <QString>
#include <QTest>
using namespace Valgrind;
using namespace Valgrind::Callgrind;
namespace {
static QString dataFile(const char *file)
{
return QLatin1String(PARSERTESTS_DATA_DIR) + QLatin1String("/") + QLatin1String(file);
}
void testCostItem(const CostItem *item, quint64 expectedPosition, quint64 expectedCost)
{
QCOMPARE(item->cost(0), expectedCost);
QCOMPARE(item->position(0), expectedPosition);
}
void testSimpleCostItem(const CostItem *item, quint64 expectedPosition, quint64 expectedCost)
{
QVERIFY(item->differingFileId() == -1);
QVERIFY(!item->call());
QCOMPARE(item->differingFileId(), qint64(-1));
testCostItem(item, expectedPosition, expectedCost);
}
void testFunctionCall(const FunctionCall *call, const Function *caller, const Function *callee,
quint64 expectedCost, quint64 expectedCalls, quint64 expectedDestination)
{
QCOMPARE(call->callee(), callee);
QCOMPARE(call->caller(), caller);
QCOMPARE(call->cost(0), expectedCost);
QCOMPARE(call->calls(), expectedCalls);
QCOMPARE(call->destination(0), expectedDestination);
}
void testCallCostItem(const CostItem *item, const Function *caller, const Function *callee,
quint64 expectedCalls, quint64 expectedDestination, quint64 expectedPosition,
quint64 expectedCost)
{
QCOMPARE(item->differingFileId(), qint64(-1));
testCostItem(item, expectedPosition, expectedCost);
QVERIFY(item->call());
testFunctionCall(item->call(), caller, callee, expectedCost, expectedCalls, expectedDestination);
}
void testDifferringFileCostItem(const CostItem *item, const QString &differingFile, quint64 expectedPosition, quint64 expectedCost)
{
QVERIFY(!item->call());
QCOMPARE(item->differingFile(), differingFile);
testCostItem(item, expectedPosition, expectedCost);
}
}
void CallgrindParserTests::initTestCase()
{
}
void CallgrindParserTests::cleanup()
{
}
ParseData* parseDataFile(const QString &dataFile)
{
QFile file(dataFile);
Q_ASSERT(file.exists());
file.open(QIODevice::ReadOnly);
Parser p;
p.parse(&file);
return p.takeData();
}
void CallgrindParserTests::testHeaderData()
{
QScopedPointer<const ParseData> data(parseDataFile(dataFile("simpleFunction.out")));
QCOMPARE(data->command(), QLatin1String("ls"));
QCOMPARE(data->creator(), QLatin1String("callgrind-3.6.0.SVN-Debian"));
QCOMPARE(data->pid(), quint64(2992));
QCOMPARE(data->version(), 1);
QCOMPARE(data->part(), 1u);
QCOMPARE(data->descriptions(), QStringList() << "I1 cache:" << "D1 cache:" << "L2 cache:"
<< "Timerange: Basic block 0 - 300089"
<< "Trigger: Program termination");
QCOMPARE(data->positions(), QStringList() << "line");
QCOMPARE(data->lineNumberPositionIndex(), 0);
QCOMPARE(data->events(), QStringList() << "Ir");
QCOMPARE(data->totalCost(0), quint64(1434186));
}
void CallgrindParserTests::testSimpleFunction()
{
QScopedPointer<const ParseData> data(parseDataFile(dataFile("simpleFunction.out")));
QCOMPARE(data->functions().size(), 4);
{
const Function *func = data->functions().at(0);
QCOMPARE(func->file(), QLatin1String("/my/file.cpp"));
QCOMPARE(func->object(), QLatin1String("/my/object"));
QCOMPARE(func->name(), QLatin1String("myFunction"));
QVERIFY(func->outgoingCalls().isEmpty());
QCOMPARE(func->called(), quint64(0));
QVERIFY(func->incomingCalls().isEmpty());
QCOMPARE(func->costItems().size(), 7);
testSimpleCostItem(func->costItems().at(0), 1, 1);
testSimpleCostItem(func->costItems().at(1), 3, 1);
testSimpleCostItem(func->costItems().at(2), 3, 3);
testSimpleCostItem(func->costItems().at(3), 1, 1);
testSimpleCostItem(func->costItems().at(4), 5, 4);
testDifferringFileCostItem(func->costItems().at(5), QLatin1String("/my/file3.h"), 1, 5);
testSimpleCostItem(func->costItems().at(6), 7, 5);
QCOMPARE(func->selfCost(0), quint64(20));
QCOMPARE(func->inclusiveCost(0), quint64(20));
}
{
const Function *func = data->functions().at(1);
QCOMPARE(func->file(), QLatin1String("/my/file.cpp"));
QCOMPARE(func->object(), QLatin1String("/my/object"));
QCOMPARE(func->name(), QLatin1String("myFunction2"));
QVERIFY(func->incomingCalls().isEmpty());
QCOMPARE(func->called(), quint64(0));
QVERIFY(func->outgoingCalls().isEmpty());
QCOMPARE(func->costItems().size(), 1);
QCOMPARE(func->selfCost(0), quint64(1));
QCOMPARE(func->inclusiveCost(0), func->selfCost(0));
}
{
const Function *func = data->functions().at(2);
QCOMPARE(func->file(), QLatin1String("/my/file2.cpp"));
QCOMPARE(func->object(), QLatin1String("/my/object"));
QCOMPARE(func->name(), QLatin1String("myFunction4"));
QVERIFY(func->incomingCalls().isEmpty());
QCOMPARE(func->called(), quint64(0));
QVERIFY(func->outgoingCalls().isEmpty());
QCOMPARE(func->costItems().size(), 1);
QCOMPARE(func->selfCost(0), quint64(1));
QCOMPARE(func->inclusiveCost(0), func->selfCost(0));
}
{
const Function *func = data->functions().at(3);
QCOMPARE(func->file(), QLatin1String("/my/file.cpp"));
QCOMPARE(func->object(), QLatin1String("/my/object2"));
QCOMPARE(func->name(), QLatin1String("myFunction3"));
QVERIFY(func->incomingCalls().isEmpty());
QCOMPARE(func->called(), quint64(0));
QVERIFY(func->outgoingCalls().isEmpty());
QCOMPARE(func->costItems().size(), 1);
QCOMPARE(func->selfCost(0), quint64(1));
}
}
void CallgrindParserTests::testCallee()
{
QScopedPointer<const ParseData> data(parseDataFile(dataFile("calleeFunctions.out")));
QCOMPARE(data->functions().size(), 3);
// basic function data testing
const Function *main = data->functions().at(0);
QCOMPARE(main->file(), QLatin1String("file1.c"));
QCOMPARE(main->object(), QLatin1String(""));
QCOMPARE(main->name(), QLatin1String("main"));
QVERIFY(main->incomingCalls().isEmpty());
QCOMPARE(main->called(), quint64(0));
QCOMPARE(main->outgoingCalls().size(), 2);
QCOMPARE(main->costItems().size(), 5);
testSimpleCostItem(main->costItems().at(0), 16, 20);
testSimpleCostItem(main->costItems().at(3), 17, 10);
QCOMPARE(main->selfCost(0), quint64(30));
QCOMPARE(main->inclusiveCost(0), quint64(1230));
const Function *func1 = data->functions().at(1);
QCOMPARE(func1->file(), QLatin1String("file1.c"));
QCOMPARE(func1->object(), QLatin1String(""));
QCOMPARE(func1->name(), QLatin1String("func1"));
QCOMPARE(func1->incomingCalls().size(), 1);
QCOMPARE(func1->called(), quint64(1));
QCOMPARE(func1->outgoingCalls().size(), 1);
QCOMPARE(func1->costItems().size(), 2);
testSimpleCostItem(func1->costItems().at(0), 51, 100);
QCOMPARE(func1->selfCost(0), quint64(100));
QCOMPARE(func1->inclusiveCost(0), quint64(400));
const Function *func2 = data->functions().at(2);
QCOMPARE(func2->file(), QLatin1String("file2.c"));
QCOMPARE(func2->object(), QLatin1String(""));
QCOMPARE(func2->name(), QLatin1String("func2"));
QCOMPARE(func2->incomingCalls().size(), 2);
QCOMPARE(func2->called(), quint64(8));
QVERIFY(func2->outgoingCalls().isEmpty());
QCOMPARE(func2->costItems().size(), 1);
testSimpleCostItem(func2->costItems().at(0), 20, 700);
QCOMPARE(func2->selfCost(0), quint64(700));
QCOMPARE(func2->inclusiveCost(0), quint64(700));
// now test callees
testCallCostItem(main->costItems().at(1), main, func1, 1, 50, 16, 400);
testCallCostItem(main->costItems().at(2), main, func2, 3, 20, 16, 400);
testCallCostItem(func1->costItems().at(1), func1, func2, 2, 20, 51, 300);
// order is undefined
if (func2->incomingCalls().first()->caller() == func1) {
testFunctionCall(func2->incomingCalls().first(), func1, func2, 300, 2, 20);
testFunctionCall(func2->incomingCalls().last(), main, func2, 800, 6, 20);
} else {
testFunctionCall(func2->incomingCalls().last(), func1, func2, 300, 2, 20);
testFunctionCall(func2->incomingCalls().first(), main, func2, 800, 6, 20);
}
// order is undefined
if (main->outgoingCalls().first()->callee() == func2) {
testFunctionCall(main->outgoingCalls().first(), main, func2, 800, 6, 20);
testFunctionCall(main->outgoingCalls().last(), main, func1, 400, 1, 50);
} else {
testFunctionCall(main->outgoingCalls().last(), main, func2, 800, 6, 20);
testFunctionCall(main->outgoingCalls().first(), main, func1, 400, 1, 50);
}
testFunctionCall(func1->outgoingCalls().first(), func1, func2, 300, 2, 20);
testFunctionCall(func1->incomingCalls().first(), main, func1, 400, 1, 50);
}
void CallgrindParserTests::testInlinedCalls()
{
QScopedPointer<const ParseData> data(parseDataFile(dataFile("inlinedFunctions.out")));
QCOMPARE(data->functions().size(), 3);
const Function *main = data->functions().first();
QCOMPARE(main->name(), QLatin1String("main"));
QCOMPARE(main->file(), QLatin1String("file1.c"));
QCOMPARE(main->selfCost(0), quint64(4));
QCOMPARE(main->inclusiveCost(0), quint64(804));
const Function *inlined = data->functions().at(1);
QCOMPARE(inlined->name(), QLatin1String("Something::Inlined()"));
QCOMPARE(inlined->file(), QLatin1String("file.h"));
const Function *func1 = data->functions().last();
QCOMPARE(func1->name(), QLatin1String("func1"));
QCOMPARE(func1->file(), QLatin1String("file3.h"));
QCOMPARE(main->outgoingCalls().size(), 2);
QCOMPARE(main->costItems().at(2)->call()->callee(), inlined);
QCOMPARE(main->costItems().at(3)->call()->callee(), func1);
testSimpleCostItem(main->costItems().last(), 1, 2);
}
void CallgrindParserTests::testMultiCost()
{
QScopedPointer<const ParseData> data(parseDataFile(dataFile("multiCost.out")));
QCOMPARE(data->functions().size(), 2);
QCOMPARE(data->positions(), QStringList() << "line");
QCOMPARE(data->events(), QStringList() << "Ir" << "Time");
QCOMPARE(data->totalCost(0), quint64(4));
QCOMPARE(data->totalCost(1), quint64(400));
const Function *main = data->functions().at(0);
QCOMPARE(main->costItems().first()->costs(), QVector<quint64>() << 1 << 100);
QCOMPARE(main->costItems().first()->positions(), QVector<quint64>() << 1);
QVERIFY(main->costItems().last()->call());
QCOMPARE(main->costItems().last()->call()->destinations(), QVector<quint64>() << 1);
}
void CallgrindParserTests::testMultiPos()
{
QScopedPointer<const ParseData> data(parseDataFile(dataFile("multiPos.out")));
QCOMPARE(data->functions().size(), 2);
QCOMPARE(data->positions(), QStringList() << "line" << "memAddr");
QCOMPARE(data->events(), QStringList() << "Ir");
QCOMPARE(data->totalCost(0), quint64(4));
const Function *main = data->functions().at(0);
QCOMPARE(main->costItems().first()->costs(), QVector<quint64>() << 1);
QCOMPARE(main->costItems().first()->positions(), QVector<quint64>() << 1 << 0x01);
QVERIFY(main->costItems().last()->call());
QCOMPARE(main->costItems().last()->call()->destinations(), QVector<quint64>() << 1 << 0x04);
}
void CallgrindParserTests::testMultiPosAndCost()
{
QScopedPointer<const ParseData> data(parseDataFile(dataFile("multiCostAndPos.out")));
QCOMPARE(data->functions().size(), 2);
QCOMPARE(data->positions(), QStringList() << "line" << "memAddr");
QCOMPARE(data->events(), QStringList() << "Ir" << "Time");
QCOMPARE(data->totalCost(0), quint64(4));
QCOMPARE(data->totalCost(1), quint64(400));
const Function *main = data->functions().at(0);
QCOMPARE(main->costItems().first()->costs(), QVector<quint64>() << 1 << 100);
QCOMPARE(main->costItems().first()->positions(), QVector<quint64>() << 1 << 0x01);
QVERIFY(main->costItems().last()->call());
QCOMPARE(main->costItems().last()->call()->destinations(), QVector<quint64>() << 1 << 0x04);
}
const Function *findFunction(const QString &needle, const QVector<const Function *> &haystack)
{
foreach (const Function *function, haystack) {
if (function->name() == needle) {
return function;
}
}
return 0;
}
void CallgrindParserTests::testCycle()
{
QScopedPointer<const ParseData> data(parseDataFile(dataFile("cycle.out")));
QCOMPARE(data->functions().size(), 4);
const Function *main = data->functions().at(0);
QCOMPARE(main->name(), QLatin1String("main"));
QCOMPARE(main->inclusiveCost(0), quint64(80));
QCOMPARE(main->selfCost(0), quint64(30));
const Function *a = data->functions().at(1);
QCOMPARE(a->name(), QLatin1String("A()"));
QCOMPARE(a->inclusiveCost(0), quint64(50));
QCOMPARE(a->selfCost(0), quint64(10));
const Function *c = data->functions().at(2);
QCOMPARE(c->name(), QLatin1String("C(bool)"));
QCOMPARE(c->inclusiveCost(0), quint64(30));
QCOMPARE(c->selfCost(0), quint64(20));
const Function *b = data->functions().at(3);
QCOMPARE(b->name(), QLatin1String("B(bool)"));
QCOMPARE(b->inclusiveCost(0), quint64(30));
QCOMPARE(b->selfCost(0), quint64(20));
QCOMPARE(data->functions(true).size(), 3);
QCOMPARE(findFunction(QLatin1String("main"), data->functions(true)), main);
QCOMPARE(findFunction(QLatin1String("A()"), data->functions(true)), a);
const FunctionCycle *cycle = dynamic_cast<const FunctionCycle*>(findFunction(QLatin1String("cycle 1"), data->functions(true)));
QVERIFY(cycle);
QCOMPARE(cycle->called(), quint64(2));
QCOMPARE(cycle->inclusiveCost(0), quint64(40));
QCOMPARE(cycle->selfCost(0), quint64(40));
}
void CallgrindParserTests::testRecursiveCycle()
{
QScopedPointer<const ParseData> data(parseDataFile(dataFile("recursiveCycle.out")));
QCOMPARE(data->functions().size(), 5);
const Function *main = findFunction(QLatin1String("main"), data->functions());
QVERIFY(main);
QCOMPARE(main->inclusiveCost(0), quint64(70701765 + 3 + 4));
QCOMPARE(data->totalCost(0), main->inclusiveCost(0));
QCOMPARE(main->selfCost(0), quint64(3 + 4));
const Function *a1 = findFunction(QLatin1String("A(int)"), data->functions());
QVERIFY(a1);
QCOMPARE(a1->inclusiveCost(0), quint64(700017 + 70001746 + 2));
QCOMPARE(a1->selfCost(0), quint64(700017 + 2));
const Function *a2 = findFunction(QLatin1String("A(int)'2"), data->functions());
QVERIFY(a2);
QCOMPARE(a2->inclusiveCost(0), quint64(35000846 + 1715042679 + 100));
QCOMPARE(a2->selfCost(0), quint64(35000846 + 100));
const Function *b1 = findFunction(QLatin1String("B(int)"), data->functions());
QVERIFY(b1);
QCOMPARE(b1->inclusiveCost(0), quint64(700014 + 69301730 + 2));
QCOMPARE(b1->selfCost(0), quint64(700014 + 2));
const Function *b2 = findFunction(QLatin1String("B(int)'2"), data->functions());
QVERIFY(b2);
QCOMPARE(b2->inclusiveCost(0), quint64(34300686 + 1680741895 + 98));
QCOMPARE(b2->selfCost(0), quint64(34300686 + 98));
{ // cycle detection
QCOMPARE(data->functions(true).size(), 4);
QCOMPARE(findFunction(QLatin1String("main"), data->functions(true)), main);
QCOMPARE(findFunction(QLatin1String("A(int)"), data->functions(true)), a1);
QCOMPARE(findFunction(QLatin1String("B(int)"), data->functions(true)), b1);
const FunctionCycle *cycle = dynamic_cast<const FunctionCycle*>(findFunction(QLatin1String("cycle 1"), data->functions(true)));
QVERIFY(cycle);
QCOMPARE(cycle->called(), quint64(1));
const quint64 restCost = data->totalCost(0) - main->selfCost(0) - a1->selfCost(0) - b1->selfCost(0);
QCOMPARE(cycle->inclusiveCost(0), restCost);
QCOMPARE(cycle->selfCost(0), restCost);
}
}
void CallgrindParserTests::testRecursion()
{
QScopedPointer<const ParseData> data(parseDataFile(dataFile("recursion.out")));
QCOMPARE(data->functions().size(), 3);
QCOMPARE(data->totalCost(0), quint64(35700972));
const Function *main = findFunction(QLatin1String("main"), data->functions());
QVERIFY(main);
QCOMPARE(main->inclusiveCost(0), quint64(4 + 35700965 + 3));
QCOMPARE(main->selfCost(0), quint64(4 + 3));
const Function *a1 = findFunction(QLatin1String("A(int)"), data->functions());
QVERIFY(a1);
QCOMPARE(a1->inclusiveCost(0), quint64(700010 + 35000946 + 2));
QCOMPARE(a1->selfCost(0), quint64(700010 + 2));
const Function *a2 = findFunction(QLatin1String("A(int)'2"), data->functions());
QVERIFY(a2);
// inclusive cost must be the same as call-cost from a1
QCOMPARE(a2->inclusiveCost(0), quint64(35000946));
QCOMPARE(a2->selfCost(0), quint64(35000846));
}
QTEST_APPLESS_MAIN(CallgrindParserTests)
@@ -0,0 +1,62 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** 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
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef CALLGRINDPARSERTESTS_H
#define CALLGRINDPARSERTESTS_H
#include <QObject>
#include <QPair>
#include <QStringList>
#include <QVector>
#include <QDebug>
class CallgrindParserTests : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void cleanup();
void testHeaderData();
void testSimpleFunction();
void testCallee();
void testInlinedCalls();
void testMultiCost();
void testMultiPos();
void testMultiPosAndCost();
void testCycle();
void testRecursiveCycle();
void testRecursion();
};
#endif // CALLGRINDPARSERTESTS_H
@@ -0,0 +1,12 @@
include(../../qttest.pri)
include($$IDE_SOURCE_TREE/src/plugins/valgrind/valgrind_test.pri)
include($$IDE_SOURCE_TREE/src/libs/utils/utils.pri)
include($$IDE_SOURCE_TREE/src/libs/ssh/ssh.pri)
TARGET = tst_callgrindparsertests
DEFINES += "PARSERTESTS_DATA_DIR=\\\"$$_PRO_FILE_PWD_/data\\\""
#enable extra debugging code
DEFINES += "CALLGRINDPARSERTESTS"
SOURCES += callgrindparsertests.cpp
HEADERS += callgrindparsertests.h
@@ -0,0 +1,44 @@
version: 1
creator: callgrind-3.6.0.SVN-Debian
pid: 2992
cmd: ls
part: 1
desc: I1 cache:
desc: D1 cache:
desc: L2 cache:
desc: Timerange: Basic block 0 - 300089
desc: Trigger: Program termination
positions: line
events: Ir
summary: 820
fl=(1) file1.c
fn=(1) main
16 20
cfn=(2) func1
calls=1 50
16 400
cfi=(2) file2.c
cfn=(3) func2
calls=3 20
16 400
17 10
cfi=(2)
cfn=(3)
calls=3 20
16 400
fn=(2)
51 100
cfl=(2)
cfn=(3)
calls=2 20
51 300
fl=(2)
fn=(3)
20 700
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,355 @@
## THIS IS AN ANNOTATED VERSION AND NOT SUPPOSED TO BE PARSED
## for more information on the file format see:
## http://kcachegrind.sourceforge.net/html/CallgrindFormat.html
## and
## http://valgrind.org/docs/manual/cg-manual.html#cg-manual.impl-details.file-format
#################
# information about the app that was run
##
version: 1
creator: callgrind-3.6.0.SVN-Debian
pid: 2992
cmd: ls
part: 1
#################
# desc: type: value [Cachegrind]
# This specifies various information for this dump.
# For some types, the semantic is defined, but any description type is allowed.
# Unknown types are ignored.
#
# From cachegrind man:
#
# The contents of the "desc:" lines are printed out at the top of the summary.
# This is a generic way of providing simulation specific information,
# e.g. for giving the cache configuration for cache simulation.
#
# Basically seems to be some information on what caches where found, how long the app ran and
# why the callgrind file was created (app closed, died, callgrind_control --dump, ...)
##
desc: I1 cache:
desc: D1 cache:
desc: L2 cache:
desc: Timerange: Basic block 0 - 300089
desc: Trigger: Program termination
#################
# the positions that get reported, whitespace separated list
##
positions: line
#################
# events that where counted, whitespace separated list
#
# Ir == Instructions
##
events: Ir
#################
# list of total count of events, in this case total cost of Ir events
# Can be used for a progress bar
##
summary: 1434186
#################
# ob: the object the function lives in
# fl: the file where the function lives in
# fn: the function
#
# the (NUM) stuff before that is used for string compression, each string gets only printed once,
# afterwards only (3) or similar will be written
#
# the numbers below are the data columns, starting with the position(s) and then the event(s)
# in our case it's just a pair of pos, event
#
# "If a cost line specifies less event counts than given in the "events" line,
# the rest is assumed to be zero."
#
# "Note that regular cost lines always give self (also called exclusive)
# cost of code at a given position."
#
# generally all this should be shown accumulated for the function.
# if the file exists we might want to show a line-by-line analysis though.
# furthermore note that positions size gets compressed by just wirting the absolute number once
# than using relative values.
##
ob=(3) /lib/i686/cmov/libpthread-2.11.2.so
fl=(131) /build/buildd-eglibc_2.11.2-6-i386-6jE6oF/eglibc-2.11.2/nptl/../nptl/sysdeps/unix/sysv/linux/i386/i686/../i486/pthread_rwlock_unlock.S
fn=(782) pthread_rwlock_unlock
33 3
+2 3
+5 3
+3 3
+1 3
+1 3
+6 3
+2 3
+1 3
+4 3
+2 3
+1 3
+1 3
+1 3
+3 3
+1 3
+39 3
+6 3
+2 3
+1 3
+1 3
+1 3
#################
# here we don't have an object and the fn has no symbol, same as above otherwise
##
fl=(44) /build/buildd-eglibc_2.11.2-6-i386-6jE6oF/eglibc-2.11.2/nptl/../nptl/sysdeps/unix/sysv/linux/i386/i686/../i486/sem_post.S
fn=(196) 0x00004340
170 11
+1 11
#################
# here we don't have an object, same as above otherwise
#
# also noteworthy is the c{ob,fi,fn} stuff, it shows the object, file, and function of a call
# if they are not given for a calls=... line, they are assumed to be the same as the parent function.
# The calls format is this:
#
# calls=(Call Count) (Destination position)
# (Source position) (Inclusive cost of call)
#
# Another interesting point: The * for the position means: +-0, i.e. same position as before
##
fl=(43) /build/buildd-eglibc_2.11.2-6-i386-6jE6oF/eglibc-2.11.2/nptl/nptl-init.c
fn=(194) __pthread_initialize_minimal
273 4
+14 1
+2 1
-16 1
+16 1
-16 1
+16 1
-2 1
-14 1
cfi=(44)
cfn=(196)
calls=1 170
* 2
* 1
+16 3
cob=(1) /lib/ld-2.11.2.so
cfi=(1) ???
cfn=(198) _dl_sysinfo_int80
calls=1 0
* 2
* 4
+1 3
+1 1
+4 5
+7 1
+6 1
-6 2
+2 1
+4 3
cob=(1)
cfi=(1)
cfn=(198)
calls=1 0
* 2
* 1
+11 2
-2 1
+2 4
cob=(1)
cfi=(1)
cfn=(198)
calls=1 0
* 2
* 1
+1 1
-2 1
+2 1
+1 1
+7 3
+12 2
-8 1
+8 7
cob=(1)
cfi=(1)
cfn=(198)
calls=1 0
* 2
* 1
+1 1
-3 1
+3 1
+1 2
+1 2
+7 3
+4 1
fi=(156) /build/buildd-eglibc_2.11.2-6-i386-6jE6oF/eglibc-2.11.2/nptl/../nptl/sysdeps/pthread/list.h
49 2
fe=(43)
354 1
fi=(156)
49 1
+1 1
+2 1
-1 1
fe=(43)
358 2
+8 2
-2 2
+2 37
+16 1
-14 2
-3 1
+3 3
cfi=(45) /build/buildd-eglibc_2.11.2-6-i386-6jE6oF/eglibc-2.11.2/nptl/../sysdeps/unix/sysv/linux/i386/sigaction.c
cfn=(200) __libc_sigaction
calls=1 59
* 93
+3 1
+3 1
+8 1
-11 1
+1 1
+2 3
cfi=(45)
cfn=(200)
calls=1 59
* 93
+8 1
fi=(157) /build/buildd-eglibc_2.11.2-6-i386-6jE6oF/eglibc-2.11.2/nptl/../sysdeps/unix/sysv/linux/bits/sigset.h
119 2
fe=(43)
382 4
cob=(1)
cfi=(1)
cfn=(198)
calls=1 0
* 2
* 1
+5 3
cob=(1)
cfi=(36) /build/buildd-eglibc_2.11.2-6-i386-6jE6oF/eglibc-2.11.2/elf/dl-tls.c
cfn=(214) _dl_get_tls_static_info
calls=1 -64
* 14
cob=(1)
cfi=(46) /build/buildd-eglibc_2.11.2-6-i386-6jE6oF/eglibc-2.11.2/elf/../sysdeps/i386/dl-trampoline.S
cfn=(208) _dl_runtime_resolve
calls=1 29
* 1958
+3 4
+2 1
+2 2
+6 1
-6 4
+6 3
cob=(4) /lib/i686/cmov/libc-2.11.2.so
cfi=(48) /build/buildd-eglibc_2.11.2-6-i386-6jE6oF/eglibc-2.11.2/resource/../sysdeps/unix/sysv/linux/i386/getrlimit.c
cfn=(220) getrlimit@@GLIBC_2.2
calls=1 41
* 20
cob=(1)
cfi=(46)
cfn=(208)
calls=1 29
* 1634
-1 2
+1 1
-1 2
+5 2
+7 2
cob=(4)
cfi=(50) /build/buildd-eglibc_2.11.2-6-i386-6jE6oF/eglibc-2.11.2/posix/../sysdeps/unix/sysv/linux/x86_64/sysconf.c
cfn=(228) sysconf
calls=1 33
* 50
cob=(1)
cfi=(46)
cfn=(208)
calls=1 29
* 1458
+1 1
+1 1
-1 1
+1 2
+4 4
+1 1
+4 1
cob=(4)
cfi=(55) /build/buildd-eglibc_2.11.2-6-i386-6jE6oF/eglibc-2.11.2/elf/dl-tsd.c
cfn=(242) __libc_dl_error_tsd
calls=1 51
* 10
cob=(1)
cfi=(46)
cfn=(208)
calls=1 29
* 1630
* 3
cob=(1)
cfi=(2) /build/buildd-eglibc_2.11.2-6-i386-6jE6oF/eglibc-2.11.2/elf/rtld.c
cfn=(84) _dl_initial_error_catch_tsd
calls=1 796
* 9
* 2
+1 1
+6 1
+1 1
-7 1
+4 2
+4 1
-3 2
+3 1
+3 2
+11 1
fi=(58) /build/buildd-eglibc_2.11.2-6-i386-6jE6oF/eglibc-2.11.2/nptl/../nptl/sysdeps/unix/sysv/linux/i386/smp.h
40 1
fe=(43)
434 1
+3 2
+2 2
+6 3
cob=(4)
cfi=(56) /build/buildd-eglibc_2.11.2-6-i386-6jE6oF/eglibc-2.11.2/nptl/../nptl/sysdeps/unix/sysv/linux/libc_pthread_init.c
cfn=(248) __libc_pthread_init
calls=1 43
* 458
cob=(1)
cfi=(46)
cfn=(208)
calls=1 29
* 1630
fi=(58)
40 2
cob=(4)
cfi=(59) /build/buildd-eglibc_2.11.2-6-i386-6jE6oF/eglibc-2.11.2/posix/../sysdeps/unix/syscall-template.S
cfn=(258) uname
calls=1 +42
* 10
cob=(1)
cfi=(46)
cfn=(208)
calls=1 -11
* 1377
* 3
+15 4
cob=(4)
cfi=(62) /build/buildd-eglibc_2.11.2-6-i386-6jE6oF/eglibc-2.11.2/string/../string/strstr.c
cfn=(268) __GI_strstr
calls=1 -2
* 366
cob=(1)
cfi=(46)
cfn=(208)
calls=1 -26
* 1474
fe=(43)
449 4
+1 6
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,45 @@
version: 1
creator: callgrind-3.6.0.SVN-Debian
pid: 3303
cmd: ./a.out
part: 1
desc: I1 cache:
desc: D1 cache:
desc: L2 cache:
desc: Timerange: Basic block 0 - 718438
desc: Trigger: Program termination
positions: line
events: Ir
summary: 80
fn=(470) main
0 15
cfn=(472) A()
calls=1 0
0 50
0 15
fn=(472)
0 10
cfn=(474) B(bool)
calls=1 0
0 20
cfn=(476) C(bool)
calls=1 0
0 20
fn=(476)
0 20
cfn=(474)
calls=1 0
0 10
fn=(474)
0 20
cfn=(476)
calls=1 0
0 10
@@ -0,0 +1,40 @@
version: 1
creator: callgrind-3.6.0.SVN-Debian
pid: 2992
cmd: ls
part: 1
desc: I1 cache:
desc: D1 cache:
desc: L2 cache:
desc: Timerange: Basic block 0 - 300089
desc: Trigger: Program termination
positions: line
events: Ir
summary: 820
fl=(1) file1.c
fn=(1) main
1 1
fi=(2) file.h
2 1
cfn=(2) Something::Inlined()
calls=1 50
1 400
cfl=(3) file3.h
cfn=(3) func1
calls=1 50
1 400
fe=(1)
1 2
fl=(2)
fn=(2)
20 400
fl=(3)
fn=(3)
20 400
@@ -0,0 +1,32 @@
version: 1
creator: callgrind-3.6.0.SVN-Debian
pid: 2992
cmd: ls
part: 1
desc: I1 cache:
desc: D1 cache:
desc: L2 cache:
desc: Timerange: Basic block 0 - 300089
desc: Trigger: Program termination
positions: line
events: Ir Time
summary: 4 400
ob=(1) /my/object
fl=(1) /my/file.cpp
fn=(1) main
1 1 100
fi=(3) /my/file.h
2 1 100
fe=(1)
3 1 100
cfn=(2) func1
calls=1 1
4 1 100
fn=(2)
1 1 100
@@ -0,0 +1,32 @@
version: 1
creator: callgrind-3.6.0.SVN-Debian
pid: 2992
cmd: ls
part: 1
desc: I1 cache:
desc: D1 cache:
desc: L2 cache:
desc: Timerange: Basic block 0 - 300089
desc: Trigger: Program termination
positions: line memAddr
events: Ir Time
summary: 4 400
ob=(1) /my/object
fl=(1) /my/file.cpp
fn=(1) main
1 0x01 1 100
fi=(3) /my/file.h
2 0x02 1 100
fe=(1)
3 0x03 1 100
cfn=(2) func1
calls=1 1 0x04
4 0x05 1 100
fn=(2)
1 0x04 1 100
@@ -0,0 +1,33 @@
version: 1
creator: callgrind-3.6.0.SVN-Debian
pid: 2992
cmd: ls
part: 1
desc: I1 cache:
desc: D1 cache:
desc: L2 cache:
desc: Timerange: Basic block 0 - 300089
desc: Trigger: Program termination
positions: line memAddr
events: Ir
summary: 4
ob=(1) /my/object
fl=(1) /my/file.cpp
fn=(1) main
1 0x01 1
fi=(3) /my/file.h
2 0x02 1
fe=(1)
3 0x3 1
cfn=(2) func1
calls=1 1 0x04
4 0x05 1
fn=(2)
1 0x04 1
@@ -0,0 +1,38 @@
version: 1
creator: callgrind-3.6.0.SVN-Debian
pid: 19824
cmd: ./a.out
part: 1
desc: I1 cache:
desc: D1 cache:
desc: L2 cache:
desc: Timerange: Basic block 0 - 10318874
desc: Trigger: Program termination
positions: line
events: Ir
summary: 35700972
fn=(470) main
0 4
cfn=(472) A(int)
calls=1 0
0 35700965
0 3
fn=(472)
0 700010
cfn=(473) A(int)'2
calls=1 0
0 35000946
0 2
fn=(473)
0 35000846
cfn=(473)
calls=49 0
0 857523079
@@ -0,0 +1,52 @@
version: 1
creator: callgrind-3.6.0.SVN-Debian
pid: 19824
cmd: ./a.out
part: 1
desc: I1 cache:
desc: D1 cache:
desc: L2 cache:
desc: Timerange: Basic block 0 - 10318874
desc: Trigger: Program termination
positions: line
events: Ir
summary: 70701772
fn=(470) main
0 4
cfn=(472) A(int)
calls=1 0
0 70701765
0 3
fn=(472)
0 700017
cfn=(474) B(int)
calls=1 0
0 70001746
0 2
fn=(473) A(int)'2
0 35000846
cfn=(475) B(int)'2
calls=49 0
0 1715042679
0 100
fn=(474)
0 700014
cfn=(473)
calls=1 0
0 69301730
0 2
fn=(475)
0 34300686
cfn=(473)
calls=49 0
0 1680741895
0 98
@@ -0,0 +1,43 @@
version: 1
creator: callgrind-3.6.0.SVN-Debian
pid: 2992
cmd: ls
part: 1
desc: I1 cache:
desc: D1 cache:
desc: L2 cache:
desc: Timerange: Basic block 0 - 300089
desc: Trigger: Program termination
positions: line
events: Ir
summary: 1434186
ob=(1) /my/object
fl=(1) /my/file.cpp
fn=(1) myFunction
1 1
+2 1
* 3
-2 1
5 4
fi=(3) /my/file3.h
1 5
fe=(1)
7 5
fn=(2) myFunction2
1 1
fl=(2) /my/file2.cpp
fn=(4) myFunction4
1 1
ob=(2) /my/object2
fl=(1)
fn=(3) myFunction3
1 1
+237
View File
@@ -0,0 +1,237 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** 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
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "modeltest.h"
#include <QStringList>
#include <QFile>
#include <QTextStream>
#include <QDebug>
#include <QApplication>
#include <QTableView>
#include <QDesktopWidget>
#include <QVBoxLayout>
#include <QMenu>
#include <QSortFilterProxyModel>
#include <QStandardItemModel>
#include <QPushButton>
#include <QSpinBox>
#include <QComboBox>
#include <QMainWindow>
#include <QDockWidget>
#include <QToolButton>
#include <callgrindcostview.h>
#include <callgrindcostdelegate.h>
#include <callgrindvisualisation.h>
#include <valgrind/callgrind/callgrindparsedata.h>
#include <valgrind/callgrind/callgrindparser.h>
#include <valgrind/callgrind/callgrinddatamodel.h>
#include <valgrind/callgrind/callgrindfunction.h>
#include <valgrind/callgrind/callgrindcallmodel.h>
#include <valgrind/callgrind/callgrindcostitem.h>
#include <valgrind/callgrind/callgrindfunctioncall.h>
#include <valgrind/callgrind/callgrindproxymodel.h>
using namespace Valgrind::Callgrind;
using namespace Callgrind::Internal;
QTextStream qerr(stderr);
void usage() {
qerr << "modeltest CALLGRINDFILE ..." << endl;
}
ModelTestWidget::ModelTestWidget(CallgrindWidgetHandler *handler)
: m_format(0)
, m_event(0)
, m_handler(handler)
{
QVBoxLayout *l = new QVBoxLayout;
setLayout(l);
QHBoxLayout *h = new QHBoxLayout;
l->addLayout(h);
l->addWidget(handler->flatView());
m_handler->populateActions(h);
m_format = new QComboBox;
m_format->addItem("absolute", CostDelegate::FormatAbsolute);
m_format->addItem("relative", CostDelegate::FormatRelative);
m_format->addItem("rel. to parent", CostDelegate::FormatRelativeToParent);
connect(m_format, SIGNAL(activated(int)),
this, SLOT(formatChanged(int)));
h->addWidget(m_format);
QDoubleSpinBox *minimumCost = new QDoubleSpinBox;
minimumCost->setToolTip("Minimum cost");
minimumCost->setRange(0, 1);
minimumCost->setDecimals(4);
minimumCost->setSingleStep(0.01);
connect(minimumCost, SIGNAL(valueChanged(double)),
m_handler->proxyModel(), SLOT(setMinimumInclusiveCostRatio(double)));
minimumCost->setValue(0.0001);
h->addWidget(minimumCost);
m_handler->flatView()->setContextMenuPolicy(Qt::CustomContextMenu);
connect(m_handler->flatView(), SIGNAL(customContextMenuRequested(QPoint)),
this, SLOT(showViewContextMenu(QPoint)));
resize(qMin(qApp->desktop()->width(), 1024), 600);
}
ModelTestWidget::~ModelTestWidget()
{
}
void ModelTestWidget::formatChanged(int index)
{
CostDelegate::CostFormat format = static_cast<CostDelegate::CostFormat>(m_format->itemData(index).toInt());
m_handler->setCostFormat(format);
}
void ModelTestWidget::showViewContextMenu(const QPoint &pos)
{
const QModelIndex idx = m_handler->flatView()->indexAt(pos);
if (!idx.isValid())
return;
QMenu menu;
QAction *showCostItems = menu.addAction("show cost items");
const ParseData* data = m_handler->dataModel()->parseData();
QAction *ret = menu.exec(m_handler->flatView()->mapToGlobal(pos));
if (ret == showCostItems) {
///TODO: put this into a reusable class?
const Function *func = idx.data(DataModel::FunctionRole).value<const Function *>();
Q_ASSERT(func);
QTableView *view = new QTableView();
view->setAttribute(Qt::WA_DeleteOnClose, true);
const int rows = func->costItems().size();
const int columns = data->events().size() + data->positions().size() + 2;
QStandardItemModel *model = new QStandardItemModel(rows, columns, view);
int headerColumn = 0;
foreach (const QString &event, data->events()) {
model->setHeaderData(headerColumn++, Qt::Horizontal, event);
}
const int lastEventColumn = headerColumn;
foreach (const QString &pos, data->positions()) {
model->setHeaderData(headerColumn++, Qt::Horizontal, pos);
}
const int lastPosColumn = headerColumn;
model->setHeaderData(headerColumn++, Qt::Horizontal, "Call");
model->setHeaderData(headerColumn++, Qt::Horizontal, "Differring File");
Q_ASSERT(headerColumn == columns);
QVector<quint64> totalCosts;
totalCosts.fill(0, data->events().size());
for (int row = 0; row < rows; ++row) {
const CostItem *item = func->costItems().at(row);
for (int column = 0; column < columns; ++column) {
QVariant value;
if (column < lastEventColumn) {
value = item->cost(column);
totalCosts[column] += item->cost(column);
} else if (column < lastPosColumn) {
value = item->position(column - lastEventColumn);
} else if (column == lastPosColumn) {
if (item->call())
value = item->call()->callee()->name();
} else {
value = item->differingFile();
}
model->setData(model->index(row, column), value);
}
}
QStringList totalCostsStrings;
for (int i = 0; i < totalCosts.size(); ++i) {
totalCostsStrings << QString("%1: %2").arg(totalCosts.at(i)).arg(data->events().at(i));
}
view->setWindowTitle(totalCostsStrings.join(QLatin1String(", ")));
view->setModel(model);
view->show();
}
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
if (app.arguments().count() < 2) {
usage();
return 1;
}
///TODO: multi-part callgrind files
QFile file(app.arguments().at(1));
if (!file.open(QIODevice::ReadOnly)) {
qerr << "could not open callgrind file for reading:" << file.fileName() << file.errorString();
return 3;
}
Parser p;
p.parse(&file);
ParseData *data = p.takeData();
if (!data) {
qerr << "invalid callgrind file:" << file.fileName() << endl;
return 2;
}
QMainWindow window;
CallgrindWidgetHandler *handler = new CallgrindWidgetHandler(&window);
ModelTestWidget *widget = new ModelTestWidget(handler);
widget->setWindowTitle(file.fileName());
window.setCentralWidget(widget);
QDockWidget *callerDock = new QDockWidget("callers", &window);
callerDock->setWidget(handler->callersView());
window.addDockWidget(Qt::RightDockWidgetArea, callerDock);
QDockWidget *calleeDock = new QDockWidget("callees", &window);
calleeDock->setWidget(handler->calleesView());
window.addDockWidget(Qt::RightDockWidgetArea, calleeDock);
QDockWidget *widgetDock = new QDockWidget("vizualisation", &window);
widgetDock->setWidget(handler->visualisation());
window.addDockWidget(Qt::BottomDockWidgetArea, widgetDock);
handler->setParseData(data);
window.show();
return app.exec();
}
+72
View File
@@ -0,0 +1,72 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** 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
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef MODELTEST_H
#define MODELTEST_H
#include <QWidget>
QT_BEGIN_NAMESPACE
class QComboBox;
QT_END_NAMESPACE
namespace Valgrind {
namespace Callgrind {
class ParseData;
class Function;
class CallModel;
}
}
namespace Callgrind {
namespace Internal {
class CallgrindWidgetHandler;
}
}
class ModelTestWidget : public QWidget
{
Q_OBJECT
public:
explicit ModelTestWidget(Callgrind::Internal::CallgrindWidgetHandler *handler);
virtual ~ModelTestWidget();
public slots:
void showViewContextMenu(const QPoint &pos);
void formatChanged(int);
public:
QComboBox *m_format;
QComboBox *m_event;
Callgrind::Internal::CallgrindWidgetHandler *m_handler;
};
#endif // MODELTEST_H
@@ -0,0 +1,36 @@
include(../../../qtcreator.pri)
include(../../auto/qttestrpath.pri)
include($$IDE_SOURCE_TREE/src/plugins/valgrind/valgrind_test.pri)
include($$IDE_SOURCE_TREE/src/libs/languageutils/languageutils.pri)
TEMPLATE = app
TARGET = modeltest
macx:CONFIG -= app_bundle
SRCDIR = $$IDE_SOURCE_TREE/src
SOURCES += \
modeltest.cpp \
$$SRCDIR/plugins/valgrind/callgrindcostdelegate.cpp \
$$SRCDIR/plugins/valgrind/callgrindhelper.cpp \
$$SRCDIR/plugins/valgrind/callgrindcostview.cpp \
$$SRCDIR/plugins/valgrind/callgrindnamedelegate.cpp \
$$SRCDIR/plugins/valgrind/callgrindwidgethandler.cpp \
$$SRCDIR/plugins/valgrind/callgrindvisualisation.cpp \
HEADERS += \
modeltest.h \
$$SRCDIR/plugins/valgrind/callgrindcostdelegate.h \
$$SRCDIR/plugins/valgrind/callgrindcostview.h \
$$SRCDIR/plugins/valgrind/callgrindhelper.h \
$$SRCDIR/plugins/valgrind/callgrindnamedelegate.h \
$$SRCDIR/plugins/valgrind/callgrindwidgethandler.h \
$$SRCDIR/plugins/valgrind/callgrindvisualisation.h \
LIBS += -L$$IDE_PLUGIN_PATH/QtProject
INCLUDEPATH *= $$IDE_BUILD_TREE/src/plugins/coreplugin # for ide_version.h
DEFINES += "DISABLE_CALLGRIND_WORKAROUNDS"
@@ -0,0 +1,370 @@
<?xml version="1.0"?>
<valgrindoutput>
<protocolversion>4</protocolversion>
<protocoltool>memcheck</protocoltool>
<preamble>
<line>Memcheck, a memory error detector</line>
<line>Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.</line>
<line>Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for copyright info</line>
<line>Command: kate</line>
</preamble>
<pid>22733</pid>
<ppid>17584</ppid>
<tool>memcheck</tool>
<args>
<vargv>
<exe>/usr/bin/valgrind.bin</exe>
<arg>--suppressions=/usr/lib/valgrind/debian-libc6-dbg.supp</arg>
<arg>--xml=yes</arg>
<arg>--xml-file=test.xml</arg>
<arg>--track-origins=yes</arg>
</vargv>
<argv>
<exe>kate</exe>
</argv>
</args>
<status>
<state>RUNNING</state>
<time>00:00:00:00.241 </time>
</status>
<error>
<unique>0x9</unique>
<tid>1</tid>
<kind>InvalidRead</kind>
<what>Invalid read of size 4</what>
<stack>
<frame>
<ip>0x6E47964</ip>
<obj>/usr/lib/libQtGui.so.4.7.0</obj>
<fn>QFrame::frameStyle() const</fn>
<dir>/build/buildd/qt4-x11-4.7.0/src/gui/widgets</dir>
<file>qframe.cpp</file>
<line>252</line>
</frame>
<frame>
<ip>0x118F2AF7</ip>
<obj>/usr/lib/kde4/plugins/styles/oxygen.so</obj>
</frame>
<frame>
<ip>0x6A81671</ip>
<obj>/usr/lib/libQtGui.so.4.7.0</obj>
<fn>QWidget::event(QEvent*)</fn>
<dir>/build/buildd/qt4-x11-4.7.0/src/gui/kernel</dir>
<file>qwidget.cpp</file>
<line>8273</line>
</frame>
<frame>
<ip>0x6A2B6EB</ip>
<obj>/usr/lib/libQtGui.so.4.7.0</obj>
<fn>QApplicationPrivate::notify_helper(QObject*, QEvent*)</fn>
<dir>/build/buildd/qt4-x11-4.7.0/src/gui/kernel</dir>
<file>qapplication.cpp</file>
<line>4396</line>
</frame>
<!--
<frame>
<ip>0x6A311DC</ip>
<obj>/usr/lib/libQtGui.so.4.7.0</obj>
<fn>QApplication::notify(QObject*, QEvent*)</fn>
<dir>/build/buildd/qt4-x11-4.7.0/src/gui/kernel</dir>
<file>qapplication.cpp</file>
<line>4277</line>
</frame>
<frame>
<ip>0x6443535</ip>
<obj>/usr/lib/libkdeui.so.5.5.0</obj>
<fn>KApplication::notify(QObject*, QEvent*)</fn>
</frame>
<frame>
<ip>0x83690AB</ip>
<obj>/usr/lib/libQtCore.so.4.7.0</obj>
<fn>QCoreApplication::notifyInternal(QObject*, QEvent*)</fn>
<dir>/build/buildd/qt4-x11-4.7.0/src/corelib/kernel</dir>
<file>qcoreapplication.cpp</file>
<line>732</line>
</frame>
<frame>
<ip>0x6A77600</ip>
<obj>/usr/lib/libQtGui.so.4.7.0</obj>
<fn>QWidget::ensurePolished() const</fn>
<dir>/build/buildd/qt4-x11-4.7.0/src/gui/../../include/QtCore/../../src/corelib/kernel</dir>
<file>qcoreapplication.h</file>
<line>215</line>
</frame>
<frame>
<ip>0x6A869B2</ip>
<obj>/usr/lib/libQtGui.so.4.7.0</obj>
<fn>QWidget::setVisible(bool)</fn>
<dir>/build/buildd/qt4-x11-4.7.0/src/gui/kernel</dir>
<file>qwidget.cpp</file>
<line>7539</line>
</frame>
<frame>
<ip>0x18B1ED35</ip>
<obj>/home/milian/projects/compiled/kde4/lib/libkatepartinterfaces.so.4.5.0</obj>
<fn>QWidget::show()</fn>
<dir>/usr/include/qt4/QtGui</dir>
<file>qwidget.h</file>
<line>487</line>
</frame>
<frame>
<ip>0x18C23615</ip>
<obj>/home/milian/projects/compiled/kde4/lib/libkatepartinterfaces.so.4.5.0</obj>
<fn>KateViewInternal::KateViewInternal(KateView*)</fn>
<dir>/home/milian/projects/kde4/kate/part/view</dir>
<file>kateviewinternal.cpp</file>
<line>144</line>
</frame>
<frame>
<ip>0x18C0DA68</ip>
<obj>/home/milian/projects/compiled/kde4/lib/libkatepartinterfaces.so.4.5.0</obj>
<fn>KateView::KateView(KateDocument*, QWidget*)</fn>
<dir>/home/milian/projects/kde4/kate/part/view</dir>
<file>kateview.cpp</file>
<line>136</line>
</frame>
-->
</stack>
<auxwhat>Address 0x11527cb8 is not stack'd, malloc'd or (recently) free'd</auxwhat>
</error>
<status>
<state>FINISHED</state>
<time>00:00:01:49.732 </time>
</status>
<error>
<unique>0x13</unique>
<tid>1</tid>
<kind>Leak_PossiblyLost</kind>
<xwhat>
<text>2 bytes in 1 blocks are possibly lost in loss record 2 of 2,003</text>
<leakedbytes>2</leakedbytes>
<leakedblocks>1</leakedblocks>
</xwhat>
<stack>
<frame>
<ip>0x4C284A8</ip>
<obj>/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so</obj>
<fn>malloc</fn>
<dir>/build/buildd/valgrind-3.6.0~svn20100212/coregrind/m_replacemalloc</dir>
<file>vg_replace_malloc.c</file>
<line>236</line>
</frame>
<frame>
<ip>0xD4D7754</ip>
<obj>/lib/libglib-2.0.so.0.2400.1</obj>
<fn>g_malloc</fn>
</frame>
<frame>
<ip>0xD4EF11D</ip>
<obj>/lib/libglib-2.0.so.0.2400.1</obj>
<fn>g_strdup</fn>
</frame>
<frame>
<ip>0xD503DC4</ip>
<obj>/lib/libglib-2.0.so.0.2400.1</obj>
<fn>g_get_language_names</fn>
</frame>
<frame>
<ip>0xD4F89A9</ip>
<obj>/lib/libglib-2.0.so.0.2400.1</obj>
<fn>g_thread_init_glib</fn>
</frame>
<frame>
<ip>0x8396569</ip>
<obj>/usr/lib/libQtCore.so.4.7.0</obj>
<fn>QEventDispatcherGlibPrivate::QEventDispatcherGlibPrivate(_GMainContext*)</fn>
<dir>/build/buildd/qt4-x11-4.7.0/src/corelib/kernel</dir>
<file>qeventdispatcher_glib.cpp</file>
<line>299</line>
</frame>
<frame>
<ip>0x6ADDBEE</ip>
<obj>/usr/lib/libQtGui.so.4.7.0</obj>
<fn>QGuiEventDispatcherGlibPrivate::QGuiEventDispatcherGlibPrivate()</fn>
<dir>/build/buildd/qt4-x11-4.7.0/src/gui/kernel</dir>
<file>qguieventdispatcher_glib.cpp</file>
<line>171</line>
</frame>
<frame>
<ip>0x6ADDCDD</ip>
<obj>/usr/lib/libQtGui.so.4.7.0</obj>
<fn>QGuiEventDispatcherGlib::QGuiEventDispatcherGlib(QObject*)</fn>
<dir>/build/buildd/qt4-x11-4.7.0/src/gui/kernel</dir>
<file>qguieventdispatcher_glib.cpp</file>
<line>186</line>
</frame>
<frame>
<ip>0x6AA5152</ip>
<obj>/usr/lib/libQtGui.so.4.7.0</obj>
<fn>QApplicationPrivate::createEventDispatcher()</fn>
<dir>/build/buildd/qt4-x11-4.7.0/src/gui/kernel</dir>
<file>qapplication_x11.cpp</file>
<line>605</line>
</frame>
<frame>
<ip>0x836D069</ip>
<obj>/usr/lib/libQtCore.so.4.7.0</obj>
<fn>QCoreApplication::init()</fn>
<dir>/build/buildd/qt4-x11-4.7.0/src/corelib/kernel</dir>
<file>qcoreapplication.cpp</file>
<line>552</line>
</frame>
<frame>
<ip>0x836D134</ip>
<obj>/usr/lib/libQtCore.so.4.7.0</obj>
<fn>QCoreApplication::QCoreApplication(QCoreApplicationPrivate&amp;)</fn>
<dir>/build/buildd/qt4-x11-4.7.0/src/corelib/kernel</dir>
<file>qcoreapplication.cpp</file>
<line>477</line>
</frame>
<frame>
<ip>0x6A3815A</ip>
<obj>/usr/lib/libQtGui.so.4.7.0</obj>
<fn>QApplication::QApplication(int&amp;, char**, bool, int)</fn>
<dir>/build/buildd/qt4-x11-4.7.0/src/gui/kernel</dir>
<file>qapplication.cpp</file>
<line>745</line>
</frame>
</stack>
</error>
<error>
<unique>0x7e4</unique>
<tid>1</tid>
<kind>Leak_DefinitelyLost</kind>
<xwhat>
<text>544,542 (56 direct, 544,486 indirect) bytes in 1 blocks are definitely lost in loss record 2,003 of 2,003</text>
<leakedbytes>544542</leakedbytes>
<leakedblocks>1</leakedblocks>
</xwhat>
<stack>
<frame>
<ip>0x4C284A8</ip>
<obj>/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so</obj>
<fn>malloc</fn>
<dir>/build/buildd/valgrind-3.6.0~svn20100212/coregrind/m_replacemalloc</dir>
<file>vg_replace_malloc.c</file>
<line>236</line>
</frame>
<frame>
<ip>0x82A1A6C</ip>
<obj>/usr/lib/libQtCore.so.4.7.0</obj>
<fn>QMapData::node_create(QMapData::Node**, int, int)</fn>
<dir>/build/buildd/qt4-x11-4.7.0/src/corelib/tools</dir>
<file>qmap.cpp</file>
<line>140</line>
</frame>
<frame>
<ip>0x8336F68</ip>
<obj>/usr/lib/libQtCore.so.4.7.0</obj>
<fn>QMap&lt;QSettingsKey, QVariant&gt;::detach_helper()</fn>
<dir>/build/buildd/qt4-x11-4.7.0/src/corelib/../../include/QtCore/../../src/corelib/tools</dir>
<file>qmap.h</file>
<line>449</line>
</frame>
<frame>
<ip>0x832C564</ip>
<obj>/usr/lib/libQtCore.so.4.7.0</obj>
<fn>QConfFile::mergedKeyMap() const</fn>
<dir>/build/buildd/qt4-x11-4.7.0/src/corelib/../../include/QtCore/../../src/corelib/tools</dir>
<file>qmap.h</file>
<line>202</line>
</frame>
<frame>
<ip>0x833305A</ip>
<obj>/usr/lib/libQtCore.so.4.7.0</obj>
<fn>QConfFileSettingsPrivate::syncConfFile(int)</fn>
<dir>/build/buildd/qt4-x11-4.7.0/src/corelib/io</dir>
<file>qsettings.cpp</file>
<line>1569</line>
</frame>
<frame>
<ip>0x8333D5B</ip>
<obj>/usr/lib/libQtCore.so.4.7.0</obj>
<fn>QConfFileSettingsPrivate::sync()</fn>
<dir>/build/buildd/qt4-x11-4.7.0/src/corelib/io</dir>
<file>qsettings.cpp</file>
<line>1386</line>
</frame>
<frame>
<ip>0x83260D9</ip>
<obj>/usr/lib/libQtCore.so.4.7.0</obj>
<fn>QSettingsPrivate::update()</fn>
<dir>/build/buildd/qt4-x11-4.7.0/src/corelib/io</dir>
<file>qsettings.cpp</file>
<line>415</line>
</frame>
<frame>
<ip>0x83267C7</ip>
<obj>/usr/lib/libQtCore.so.4.7.0</obj>
<fn>QSettings::event(QEvent*)</fn>
<dir>/build/buildd/qt4-x11-4.7.0/src/corelib/io</dir>
<file>qsettings.cpp</file>
<line>3326</line>
</frame>
<frame>
<ip>0x6A2B6EB</ip>
<obj>/usr/lib/libQtGui.so.4.7.0</obj>
<fn>QApplicationPrivate::notify_helper(QObject*, QEvent*)</fn>
<dir>/build/buildd/qt4-x11-4.7.0/src/gui/kernel</dir>
<file>qapplication.cpp</file>
<line>4396</line>
</frame>
<frame>
<ip>0x6A311DC</ip>
<obj>/usr/lib/libQtGui.so.4.7.0</obj>
<fn>QApplication::notify(QObject*, QEvent*)</fn>
<dir>/build/buildd/qt4-x11-4.7.0/src/gui/kernel</dir>
<file>qapplication.cpp</file>
<line>4277</line>
</frame>
<frame>
<ip>0x6443535</ip>
<obj>/usr/lib/libkdeui.so.5.5.0</obj>
<fn>KApplication::notify(QObject*, QEvent*)</fn>
</frame>
<frame>
<ip>0x83690AB</ip>
<obj>/usr/lib/libQtCore.so.4.7.0</obj>
<fn>QCoreApplication::notifyInternal(QObject*, QEvent*)</fn>
<dir>/build/buildd/qt4-x11-4.7.0/src/corelib/kernel</dir>
<file>qcoreapplication.cpp</file>
<line>732</line>
</frame>
</stack>
</error>
<errorcounts>
<pair>
<count>2</count>
<unique>0x9</unique>
</pair>
</errorcounts>
<suppcounts>
<pair>
<count>12</count>
<name>X on SUSE11 writev uninit padding</name>
</pair>
<pair>
<count>2</count>
<name>dl-hack3-cond-1</name>
</pair>
<pair>
<count>2</count>
<name>glibc-2.5.x-on-SUSE-10.2-(PPC)-2a</name>
</pair>
</suppcounts>
</valgrindoutput>
@@ -0,0 +1,984 @@
<?xml version="1.0"?>
<valgrindoutput>
<protocolversion>4</protocolversion>
<protocoltool>memcheck</protocoltool>
<preamble>
<line>Memcheck, a memory error detector</line>
<line>Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.</line>
<line>Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info</line>
<line>Command: /home/chris/untitled/untitled</line>
</preamble>
<pid>20854</pid>
<ppid>20386</ppid>
<tool>memcheck</tool>
<args>
<vargv>
<exe>/usr/bin/valgrind.bin</exe>
<arg>--suppressions=/usr/lib/valgrind/debian-libc6-dbg.supp</arg>
<arg>--xml=yes</arg>
<arg>--xml-file=/tmp/bla</arg>
</vargv>
<argv>
<exe>/home/chris/untitled/untitled</exe>
</argv>
</args>
<status>
<state>RUNNING</state>
<time>00:00:00:00.161 </time>
</status>
<status>
<state>FINISHED</state>
<time>00:00:00:12.379 </time>
</status>
<error>
<unique>0x107</unique>
<tid>1</tid>
<kind>Leak_PossiblyLost</kind>
<xwhat>
<text>120 bytes in 1 blocks are possibly lost in loss record 184 of 270</text>
<leakedbytes>120</leakedbytes>
<leakedblocks>1</leakedblocks>
</xwhat>
<stack>
<frame>
<ip>0x402517B</ip>
<obj>/usr/lib/valgrind/vgpreload_memcheck-x86-linux.so</obj>
<fn>memalign</fn>
<dir>/build/buildd/valgrind-3.6.1/coregrind/m_replacemalloc</dir>
<file>vg_replace_malloc.c</file>
<line>581</line>
</frame>
<frame>
<ip>0x40251D8</ip>
<obj>/usr/lib/valgrind/vgpreload_memcheck-x86-linux.so</obj>
<fn>posix_memalign</fn>
<dir>/build/buildd/valgrind-3.6.1/coregrind/m_replacemalloc</dir>
<file>vg_replace_malloc.c</file>
<line>709</line>
</frame>
<frame>
<ip>0x42BE546</ip>
<obj>/lib/i386-linux-gnu/libglib-2.0.so.0.2800.6</obj>
</frame>
<frame>
<ip>0x42BFA2F</ip>
<obj>/lib/i386-linux-gnu/libglib-2.0.so.0.2800.6</obj>
<fn>g_slice_alloc</fn>
</frame>
<frame>
<ip>0x42C06DD</ip>
<obj>/lib/i386-linux-gnu/libglib-2.0.so.0.2800.6</obj>
<fn>g_slist_prepend</fn>
</frame>
<frame>
<ip>0x42C368E</ip>
<obj>/lib/i386-linux-gnu/libglib-2.0.so.0.2800.6</obj>
<fn>g_strsplit</fn>
</frame>
<frame>
<ip>0x42D9393</ip>
<obj>/lib/i386-linux-gnu/libglib-2.0.so.0.2800.6</obj>
<fn>g_get_language_names</fn>
</frame>
<frame>
<ip>0x42D98E6</ip>
<obj>/lib/i386-linux-gnu/libglib-2.0.so.0.2800.6</obj>
</frame>
<frame>
<ip>0x42CB919</ip>
<obj>/lib/i386-linux-gnu/libglib-2.0.so.0.2800.6</obj>
<fn>g_thread_init_glib</fn>
</frame>
<frame>
<ip>0x4254506</ip>
<obj>/usr/lib/i386-linux-gnu/libgthread-2.0.so.0.2800.6</obj>
<fn>g_thread_init</fn>
</frame>
<frame>
<ip>0x8D4D458</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QEventDispatcherGlibPrivate::QEventDispatcherGlibPrivate(_GMainContext*)</fn>
</frame>
<frame>
<ip>0x85C7CA5</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QGuiEventDispatcherGlibPrivate::QGuiEventDispatcherGlibPrivate()</fn>
</frame>
</stack>
</error>
<error>
<unique>0x109</unique>
<tid>1</tid>
<kind>Leak_DefinitelyLost</kind>
<xwhat>
<text>122 (56 direct, 66 indirect) bytes in 1 blocks are definitely lost in loss record 186 of 270</text>
<leakedbytes>122</leakedbytes>
<leakedblocks>1</leakedblocks>
</xwhat>
<stack>
<frame>
<ip>0x402641D</ip>
<obj>/usr/lib/valgrind/vgpreload_memcheck-x86-linux.so</obj>
<fn>operator new(unsigned int)</fn>
<dir>/build/buildd/valgrind-3.6.1/coregrind/m_replacemalloc</dir>
<file>vg_replace_malloc.c</file>
<line>255</line>
</frame>
<frame>
<ip>0x8D0FC45</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QLibraryPrivate::findOrCreate(QString const&amp;, QString const&amp;)</fn>
</frame>
<frame>
<ip>0x8D10347</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QLibrary::setFileNameAndVersion(QString const&amp;, int)</fn>
</frame>
<frame>
<ip>0x8D10404</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QLibrary::QLibrary(QString const&amp;, int, QObject*)</fn>
</frame>
<frame>
<ip>0x859BD96</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>qt_load_library_runtime(char const*, int, int, char const*)</fn>
</frame>
<frame>
<ip>0x859C93C</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>qt_init(QApplicationPrivate*, int, _XDisplay*, unsigned long, unsigned long)</fn>
</frame>
<frame>
<ip>0x853EEDC</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QApplicationPrivate::construct(_XDisplay*, unsigned long, unsigned long)</fn>
</frame>
<frame>
<ip>0x853F766</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QApplication::QApplication(int&amp;, char**, int)</fn>
</frame>
<frame>
<ip>0x805209E</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>createApplication(int&amp;, char**)</fn>
<dir>/home/chris/untitled/qmlapplicationviewer</dir>
<file>qmlapplicationviewer.cpp</file>
<line>175</line>
</frame>
<frame>
<ip>0x805185F</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>main</fn>
<dir>/home/chris/untitled</dir>
<file>main.cpp</file>
<line>6</line>
</frame>
</stack>
</error>
<error>
<unique>0x10a</unique>
<tid>1</tid>
<kind>Leak_DefinitelyLost</kind>
<xwhat>
<text>124 bytes in 1 blocks are definitely lost in loss record 187 of 270</text>
<leakedbytes>124</leakedbytes>
<leakedblocks>1</leakedblocks>
</xwhat>
<stack>
<frame>
<ip>0x4026864</ip>
<obj>/usr/lib/valgrind/vgpreload_memcheck-x86-linux.so</obj>
<fn>malloc</fn>
<dir>/build/buildd/valgrind-3.6.1/coregrind/m_replacemalloc</dir>
<file>vg_replace_malloc.c</file>
<line>236</line>
</frame>
<frame>
<ip>0x4635902</ip>
<obj>/usr/lib/i386-linux-gnu/libxcb.so.1.1.0</obj>
<fn>get_peer_sock_name</fn>
<dir>/build/buildd/libxcb-1.7/obj-i686-linux-gnu/src/../../src</dir>
<file>xcb_auth.c</file>
<line>259</line>
</frame>
<frame>
<ip>0x4635A04</ip>
<obj>/usr/lib/i386-linux-gnu/libxcb.so.1.1.0</obj>
<fn>_xcb_get_auth_info</fn>
<dir>/build/buildd/libxcb-1.7/obj-i686-linux-gnu/src/../../src</dir>
<file>xcb_auth.c</file>
<line>302</line>
</frame>
<frame>
<ip>0x46353D1</ip>
<obj>/usr/lib/i386-linux-gnu/libxcb.so.1.1.0</obj>
<fn>xcb_connect_to_display_with_auth_info</fn>
<dir>/build/buildd/libxcb-1.7/obj-i686-linux-gnu/src/../../src</dir>
<file>xcb_util.c</file>
<line>424</line>
</frame>
<frame>
<ip>0x46355DB</ip>
<obj>/usr/lib/i386-linux-gnu/libxcb.so.1.1.0</obj>
<fn>xcb_connect</fn>
<dir>/build/buildd/libxcb-1.7/obj-i686-linux-gnu/src/../../src</dir>
<file>xcb_util.c</file>
<line>395</line>
</frame>
<frame>
<ip>0x4169A22</ip>
<obj>/usr/lib/i386-linux-gnu/libX11.so.6.3.0</obj>
<fn>_XConnectXCB</fn>
</frame>
<frame>
<ip>0x41598F3</ip>
<obj>/usr/lib/i386-linux-gnu/libX11.so.6.3.0</obj>
<fn>XOpenDisplay</fn>
</frame>
<frame>
<ip>0x859E45F</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>qt_init(QApplicationPrivate*, int, _XDisplay*, unsigned long, unsigned long)</fn>
</frame>
<frame>
<ip>0x853EEDC</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QApplicationPrivate::construct(_XDisplay*, unsigned long, unsigned long)</fn>
</frame>
<frame>
<ip>0x853F766</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QApplication::QApplication(int&amp;, char**, int)</fn>
</frame>
<frame>
<ip>0x805209E</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>createApplication(int&amp;, char**)</fn>
<dir>/home/chris/untitled/qmlapplicationviewer</dir>
<file>qmlapplicationviewer.cpp</file>
<line>175</line>
</frame>
<frame>
<ip>0x805185F</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>main</fn>
<dir>/home/chris/untitled</dir>
<file>main.cpp</file>
<line>6</line>
</frame>
</stack>
</error>
<error>
<unique>0x10f</unique>
<tid>1</tid>
<kind>Leak_DefinitelyLost</kind>
<xwhat>
<text>138 (56 direct, 82 indirect) bytes in 1 blocks are definitely lost in loss record 192 of 270</text>
<leakedbytes>138</leakedbytes>
<leakedblocks>1</leakedblocks>
</xwhat>
<stack>
<frame>
<ip>0x402641D</ip>
<obj>/usr/lib/valgrind/vgpreload_memcheck-x86-linux.so</obj>
<fn>operator new(unsigned int)</fn>
<dir>/build/buildd/valgrind-3.6.1/coregrind/m_replacemalloc</dir>
<file>vg_replace_malloc.c</file>
<line>255</line>
</frame>
<frame>
<ip>0x8D0FC45</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QLibraryPrivate::findOrCreate(QString const&amp;, QString const&amp;)</fn>
</frame>
<frame>
<ip>0x8D10347</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QLibrary::setFileNameAndVersion(QString const&amp;, int)</fn>
</frame>
<frame>
<ip>0x8D10404</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QLibrary::QLibrary(QString const&amp;, int, QObject*)</fn>
</frame>
<frame>
<ip>0x859BD96</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>qt_load_library_runtime(char const*, int, int, char const*)</fn>
</frame>
<frame>
<ip>0x859DE94</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>qt_init(QApplicationPrivate*, int, _XDisplay*, unsigned long, unsigned long)</fn>
</frame>
<frame>
<ip>0x853EEDC</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QApplicationPrivate::construct(_XDisplay*, unsigned long, unsigned long)</fn>
</frame>
<frame>
<ip>0x853F766</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QApplication::QApplication(int&amp;, char**, int)</fn>
</frame>
<frame>
<ip>0x805209E</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>createApplication(int&amp;, char**)</fn>
<dir>/home/chris/untitled/qmlapplicationviewer</dir>
<file>qmlapplicationviewer.cpp</file>
<line>175</line>
</frame>
<frame>
<ip>0x805185F</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>main</fn>
<dir>/home/chris/untitled</dir>
<file>main.cpp</file>
<line>6</line>
</frame>
</stack>
</error>
<error>
<unique>0x114</unique>
<tid>1</tid>
<kind>Leak_DefinitelyLost</kind>
<xwhat>
<text>158 (56 direct, 102 indirect) bytes in 1 blocks are definitely lost in loss record 197 of 270</text>
<leakedbytes>158</leakedbytes>
<leakedblocks>1</leakedblocks>
</xwhat>
<stack>
<frame>
<ip>0x402641D</ip>
<obj>/usr/lib/valgrind/vgpreload_memcheck-x86-linux.so</obj>
<fn>operator new(unsigned int)</fn>
<dir>/build/buildd/valgrind-3.6.1/coregrind/m_replacemalloc</dir>
<file>vg_replace_malloc.c</file>
<line>255</line>
</frame>
<frame>
<ip>0x8D0FC45</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QLibraryPrivate::findOrCreate(QString const&amp;, QString const&amp;)</fn>
</frame>
<frame>
<ip>0x8D1023F</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QLibrary::setFileNameAndVersion(QString const&amp;, QString const&amp;)</fn>
</frame>
<frame>
<ip>0x8D102A4</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QLibrary::QLibrary(QString const&amp;, QString const&amp;, QObject*)</fn>
</frame>
<frame>
<ip>0x8C8FCCD</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>qt_initIcu(QString const&amp;)</fn>
</frame>
<frame>
<ip>0x8C4B0CF</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QLocalePrivate::updateSystemPrivate()</fn>
</frame>
<frame>
<ip>0x8C4B3C6</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>systemPrivate()</fn>
</frame>
<frame>
<ip>0x8C4B40C</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>defaultPrivate()</fn>
</frame>
<frame>
<ip>0x8C4B55F</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QLocale::QLocale()</fn>
</frame>
<frame>
<ip>0x8CCF6F3</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QResourceFileEngine::QResourceFileEngine(QString const&amp;)</fn>
</frame>
<frame>
<ip>0x8CF87DC</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>_q_resolveEntryAndCreateLegacyEngine_recursive(QFileSystemEntry&amp;, QFileSystemMetaData&amp;, QAbstractFileEngine*&amp;, bool)</fn>
</frame>
<frame>
<ip>0x8CF8947</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QFileSystemEngine::resolveEntryAndCreateLegacyEngine(QFileSystemEntry&amp;, QFileSystemMetaData&amp;)</fn>
</frame>
</stack>
</error>
<error>
<unique>0x116</unique>
<tid>1</tid>
<kind>Leak_PossiblyLost</kind>
<xwhat>
<text>160 bytes in 1 blocks are possibly lost in loss record 199 of 270</text>
<leakedbytes>160</leakedbytes>
<leakedblocks>1</leakedblocks>
</xwhat>
<stack>
<frame>
<ip>0x4025315</ip>
<obj>/usr/lib/valgrind/vgpreload_memcheck-x86-linux.so</obj>
<fn>calloc</fn>
<dir>/build/buildd/valgrind-3.6.1/coregrind/m_replacemalloc</dir>
<file>vg_replace_malloc.c</file>
<line>467</line>
</frame>
<frame>
<ip>0x4010CD7</ip>
<obj>/lib/i386-linux-gnu/ld-2.13.so</obj>
<fn>allocate_dtv</fn>
<dir>/build/buildd/eglibc-2.13/elf</dir>
<file>dl-tls.c</file>
<line>300</line>
</frame>
<frame>
<ip>0x401146B</ip>
<obj>/lib/i386-linux-gnu/ld-2.13.so</obj>
<fn>_dl_allocate_tls</fn>
<dir>/build/buildd/eglibc-2.13/elf</dir>
<file>dl-tls.c</file>
<line>464</line>
</frame>
<frame>
<ip>0x433E5C6</ip>
<obj>/lib/i386-linux-gnu/libpthread-2.13.so</obj>
<fn>pthread_create@@GLIBC_2.1</fn>
<dir>/build/buildd/eglibc-2.13/nptl</dir>
<file>allocatestack.c</file>
<line>570</line>
</frame>
<frame>
<ip>0x83A6BED</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QTWTF::TCMalloc_PageHeap::initializeScavenger()</fn>
</frame>
<frame>
<ip>0x83A92E9</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QTWTF::TCMalloc_ThreadCache::InitModule()</fn>
</frame>
<frame>
<ip>0x83AA188</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QTWTF::fastMalloc(unsigned int)</fn>
</frame>
<frame>
<ip>0x83AEE4B</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QTWTF::initializeThreading()</fn>
</frame>
<frame>
<ip>0x8338CBF</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QTJSC::initializeThreading()</fn>
</frame>
<frame>
<ip>0x82897BE</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QScriptEnginePrivate::QScriptEnginePrivate()</fn>
</frame>
<frame>
<ip>0x828AAB2</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QScriptEngine::QScriptEngine()</fn>
</frame>
<frame>
<ip>0x8063261</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QDeclarativeScriptEngine::QDeclarativeScriptEngine(QDeclarativeEnginePrivate*)</fn>
</frame>
</stack>
</error>
<error>
<unique>0x117</unique>
<tid>1</tid>
<kind>Leak_DefinitelyLost</kind>
<xwhat>
<text>160 (40 direct, 120 indirect) bytes in 1 blocks are definitely lost in loss record 200 of 270</text>
<leakedbytes>160</leakedbytes>
<leakedblocks>1</leakedblocks>
</xwhat>
<stack>
<frame>
<ip>0x4026864</ip>
<obj>/usr/lib/valgrind/vgpreload_memcheck-x86-linux.so</obj>
<fn>malloc</fn>
<dir>/build/buildd/valgrind-3.6.1/coregrind/m_replacemalloc</dir>
<file>vg_replace_malloc.c</file>
<line>236</line>
</frame>
<frame>
<ip>0x4565FAB</ip>
<obj>/lib/i386-linux-gnu/libc-2.13.so</obj>
<fn>nss_parse_service_list</fn>
<dir>/build/buildd/eglibc-2.13/nss</dir>
<file>nsswitch.c</file>
<line>626</line>
</frame>
<frame>
<ip>0x4566584</ip>
<obj>/lib/i386-linux-gnu/libc-2.13.so</obj>
<fn>__nss_database_lookup</fn>
<dir>/build/buildd/eglibc-2.13/nss</dir>
<file>nsswitch.c</file>
<line>167</line>
</frame>
<frame>
<ip>0x6BAAE9B</ip>
</frame>
<frame>
<ip>0x6BAC9F4</ip>
</frame>
<frame>
<ip>0x451C7EA</ip>
<obj>/lib/i386-linux-gnu/libc-2.13.so</obj>
<fn>getpwuid_r@@GLIBC_2.1.2</fn>
<dir>/build/buildd/eglibc-2.13/pwd/../nss</dir>
<file>getXXbyYY_r.c</file>
<line>256</line>
</frame>
<frame>
<ip>0x85A34E4</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>sm_performSaveYourself(QSessionManagerPrivate*)</fn>
</frame>
<frame>
<ip>0x85A3F56</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>sm_saveYourselfCallback(_SmcConn*, void*, int, int, int, int)</fn>
</frame>
<frame>
<ip>0x4047727</ip>
<obj>/usr/lib/i386-linux-gnu/libSM.so.6.0.1</obj>
<fn>_SmcProcessMessage</fn>
</frame>
<frame>
<ip>0x405D1B5</ip>
<obj>/usr/lib/i386-linux-gnu/libICE.so.6.3.0</obj>
<fn>IceProcessMessages</fn>
</frame>
<frame>
<ip>0x858FE67</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QSmSocketReceiver::socketActivated(int)</fn>
</frame>
<frame>
<ip>0x8D3A9C1</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QMetaObject::activate(QObject*, QMetaObject const*, int, void**)</fn>
</frame>
</stack>
</error>
<error>
<unique>0x118</unique>
<tid>1</tid>
<kind>Leak_DefinitelyLost</kind>
<xwhat>
<text>166 (56 direct, 110 indirect) bytes in 1 blocks are definitely lost in loss record 201 of 270</text>
<leakedbytes>166</leakedbytes>
<leakedblocks>1</leakedblocks>
</xwhat>
<stack>
<frame>
<ip>0x402641D</ip>
<obj>/usr/lib/valgrind/vgpreload_memcheck-x86-linux.so</obj>
<fn>operator new(unsigned int)</fn>
<dir>/build/buildd/valgrind-3.6.1/coregrind/m_replacemalloc</dir>
<file>vg_replace_malloc.c</file>
<line>255</line>
</frame>
<frame>
<ip>0x8D0FC45</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QLibraryPrivate::findOrCreate(QString const&amp;, QString const&amp;)</fn>
</frame>
<frame>
<ip>0x8D1023F</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QLibrary::setFileNameAndVersion(QString const&amp;, QString const&amp;)</fn>
</frame>
<frame>
<ip>0x8D102A4</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QLibrary::QLibrary(QString const&amp;, QString const&amp;, QObject*)</fn>
</frame>
<frame>
<ip>0x8C8FA56</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>qt_initIcu(QString const&amp;)</fn>
</frame>
<frame>
<ip>0x8C4B0CF</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QLocalePrivate::updateSystemPrivate()</fn>
</frame>
<frame>
<ip>0x8C4B3C6</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>systemPrivate()</fn>
</frame>
<frame>
<ip>0x8C4B40C</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>defaultPrivate()</fn>
</frame>
<frame>
<ip>0x8C4B55F</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QLocale::QLocale()</fn>
</frame>
<frame>
<ip>0x8CCF6F3</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QResourceFileEngine::QResourceFileEngine(QString const&amp;)</fn>
</frame>
<frame>
<ip>0x8CF87DC</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>_q_resolveEntryAndCreateLegacyEngine_recursive(QFileSystemEntry&amp;, QFileSystemMetaData&amp;, QAbstractFileEngine*&amp;, bool)</fn>
</frame>
<frame>
<ip>0x8CF8947</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QFileSystemEngine::resolveEntryAndCreateLegacyEngine(QFileSystemEntry&amp;, QFileSystemMetaData&amp;)</fn>
</frame>
</stack>
</error>
<error>
<unique>0x11d</unique>
<tid>1</tid>
<kind>Leak_DefinitelyLost</kind>
<xwhat>
<text>216 bytes in 1 blocks are definitely lost in loss record 206 of 270</text>
<leakedbytes>216</leakedbytes>
<leakedblocks>1</leakedblocks>
</xwhat>
<stack>
<frame>
<ip>0x4026864</ip>
<obj>/usr/lib/valgrind/vgpreload_memcheck-x86-linux.so</obj>
<fn>malloc</fn>
<dir>/build/buildd/valgrind-3.6.1/coregrind/m_replacemalloc</dir>
<file>vg_replace_malloc.c</file>
<line>236</line>
</frame>
<frame>
<ip>0x4193FB2</ip>
<obj>/usr/lib/i386-linux-gnu/libX11.so.6.3.0</obj>
<fn>_XimOpenIM</fn>
</frame>
<frame>
<ip>0x4193BCF</ip>
<obj>/usr/lib/i386-linux-gnu/libX11.so.6.3.0</obj>
<fn>_XimRegisterIMInstantiateCallback</fn>
</frame>
<frame>
<ip>0x41789A7</ip>
<obj>/usr/lib/i386-linux-gnu/libX11.so.6.3.0</obj>
<fn>XRegisterIMInstantiateCallback</fn>
</frame>
<frame>
<ip>0x89FB291</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QXIMInputContext::QXIMInputContext()</fn>
</frame>
<frame>
<ip>0x89F9450</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QInputContextFactory::create(QString const&amp;, QObject*)</fn>
</frame>
<frame>
<ip>0x85361C7</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QApplication::inputContext() const</fn>
</frame>
<frame>
<ip>0x85662A7</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QWidgetPrivate::inputContext() const</fn>
</frame>
<frame>
<ip>0x8571D7C</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QWidget::setAttribute(Qt::WidgetAttribute, bool)</fn>
</frame>
<frame>
<ip>0x8A54527</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QGraphicsViewPrivate::updateInputMethodSensitivity()</fn>
</frame>
<frame>
<ip>0x8A55E1A</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QGraphicsView::setScene(QGraphicsScene*)</fn>
</frame>
<frame>
<ip>0x805273E</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QDeclarativeViewPrivate::init()</fn>
</frame>
</stack>
</error>
<error>
<unique>0x126</unique>
<tid>1</tid>
<kind>Leak_PossiblyLost</kind>
<xwhat>
<text>360 bytes in 3 blocks are possibly lost in loss record 215 of 270</text>
<leakedbytes>360</leakedbytes>
<leakedblocks>3</leakedblocks>
</xwhat>
<stack>
<frame>
<ip>0x402517B</ip>
<obj>/usr/lib/valgrind/vgpreload_memcheck-x86-linux.so</obj>
<fn>memalign</fn>
<dir>/build/buildd/valgrind-3.6.1/coregrind/m_replacemalloc</dir>
<file>vg_replace_malloc.c</file>
<line>581</line>
</frame>
<frame>
<ip>0x40251D8</ip>
<obj>/usr/lib/valgrind/vgpreload_memcheck-x86-linux.so</obj>
<fn>posix_memalign</fn>
<dir>/build/buildd/valgrind-3.6.1/coregrind/m_replacemalloc</dir>
<file>vg_replace_malloc.c</file>
<line>709</line>
</frame>
<frame>
<ip>0x42BE546</ip>
<obj>/lib/i386-linux-gnu/libglib-2.0.so.0.2800.6</obj>
</frame>
<frame>
<ip>0x42BFA4C</ip>
<obj>/lib/i386-linux-gnu/libglib-2.0.so.0.2800.6</obj>
<fn>g_slice_alloc</fn>
</frame>
<frame>
<ip>0x42C06DD</ip>
<obj>/lib/i386-linux-gnu/libglib-2.0.so.0.2800.6</obj>
<fn>g_slist_prepend</fn>
</frame>
<frame>
<ip>0x42C368E</ip>
<obj>/lib/i386-linux-gnu/libglib-2.0.so.0.2800.6</obj>
<fn>g_strsplit</fn>
</frame>
<frame>
<ip>0x42D9393</ip>
<obj>/lib/i386-linux-gnu/libglib-2.0.so.0.2800.6</obj>
<fn>g_get_language_names</fn>
</frame>
<frame>
<ip>0x42D98E6</ip>
<obj>/lib/i386-linux-gnu/libglib-2.0.so.0.2800.6</obj>
</frame>
<frame>
<ip>0x42CB919</ip>
<obj>/lib/i386-linux-gnu/libglib-2.0.so.0.2800.6</obj>
<fn>g_thread_init_glib</fn>
</frame>
<frame>
<ip>0x4254506</ip>
<obj>/usr/lib/i386-linux-gnu/libgthread-2.0.so.0.2800.6</obj>
<fn>g_thread_init</fn>
</frame>
<frame>
<ip>0x8D4D458</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QEventDispatcherGlibPrivate::QEventDispatcherGlibPrivate(_GMainContext*)</fn>
</frame>
<frame>
<ip>0x85C7CA5</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QGuiEventDispatcherGlibPrivate::QGuiEventDispatcherGlibPrivate()</fn>
</frame>
</stack>
</error>
<error>
<unique>0x128</unique>
<tid>1</tid>
<kind>Leak_DefinitelyLost</kind>
<xwhat>
<text>396 (256 direct, 140 indirect) bytes in 2 blocks are definitely lost in loss record 217 of 270</text>
<leakedbytes>396</leakedbytes>
<leakedblocks>2</leakedblocks>
</xwhat>
<stack>
<frame>
<ip>0x4026864</ip>
<obj>/usr/lib/valgrind/vgpreload_memcheck-x86-linux.so</obj>
<fn>malloc</fn>
<dir>/build/buildd/valgrind-3.6.1/coregrind/m_replacemalloc</dir>
<file>vg_replace_malloc.c</file>
<line>236</line>
</frame>
<frame>
<ip>0x4086087</ip>
<obj>/usr/lib/i386-linux-gnu/libfontconfig.so.1.4.4</obj>
</frame>
<frame>
<ip>0x4086F7C</ip>
<obj>/usr/lib/i386-linux-gnu/libfontconfig.so.1.4.4</obj>
</frame>
<frame>
<ip>0x4087073</ip>
<obj>/usr/lib/i386-linux-gnu/libfontconfig.so.1.4.4</obj>
</frame>
<frame>
<ip>0x408C6EB</ip>
<obj>/usr/lib/i386-linux-gnu/libfontconfig.so.1.4.4</obj>
</frame>
<frame>
<ip>0x4607790</ip>
<obj>/lib/i386-linux-gnu/libexpat.so.1.5.2</obj>
</frame>
<frame>
<ip>0x4608670</ip>
<obj>/lib/i386-linux-gnu/libexpat.so.1.5.2</obj>
</frame>
<frame>
<ip>0x4608F92</ip>
<obj>/lib/i386-linux-gnu/libexpat.so.1.5.2</obj>
</frame>
<frame>
<ip>0x460A7D9</ip>
<obj>/lib/i386-linux-gnu/libexpat.so.1.5.2</obj>
</frame>
<frame>
<ip>0x460C5F2</ip>
<obj>/lib/i386-linux-gnu/libexpat.so.1.5.2</obj>
<fn>XML_ParseBuffer</fn>
</frame>
<frame>
<ip>0x408B2B2</ip>
<obj>/usr/lib/i386-linux-gnu/libfontconfig.so.1.4.4</obj>
<fn>FcConfigParseAndLoad</fn>
</frame>
<frame>
<ip>0x408B60B</ip>
<obj>/usr/lib/i386-linux-gnu/libfontconfig.so.1.4.4</obj>
<fn>FcConfigParseAndLoad</fn>
</frame>
</stack>
</error>
<error>
<unique>0x144</unique>
<tid>1</tid>
<kind>Leak_PossiblyLost</kind>
<xwhat>
<text>1,240 bytes in 5 blocks are possibly lost in loss record 245 of 270</text>
<leakedbytes>1240</leakedbytes>
<leakedblocks>5</leakedblocks>
</xwhat>
<stack>
<frame>
<ip>0x402517B</ip>
<obj>/usr/lib/valgrind/vgpreload_memcheck-x86-linux.so</obj>
<fn>memalign</fn>
<dir>/build/buildd/valgrind-3.6.1/coregrind/m_replacemalloc</dir>
<file>vg_replace_malloc.c</file>
<line>581</line>
</frame>
<frame>
<ip>0x40251D8</ip>
<obj>/usr/lib/valgrind/vgpreload_memcheck-x86-linux.so</obj>
<fn>posix_memalign</fn>
<dir>/build/buildd/valgrind-3.6.1/coregrind/m_replacemalloc</dir>
<file>vg_replace_malloc.c</file>
<line>709</line>
</frame>
<frame>
<ip>0x42BE546</ip>
<obj>/lib/i386-linux-gnu/libglib-2.0.so.0.2800.6</obj>
</frame>
<frame>
<ip>0x42BFA4C</ip>
<obj>/lib/i386-linux-gnu/libglib-2.0.so.0.2800.6</obj>
<fn>g_slice_alloc</fn>
</frame>
<frame>
<ip>0x42729D8</ip>
<obj>/lib/i386-linux-gnu/libglib-2.0.so.0.2800.6</obj>
<fn>g_array_sized_new</fn>
</frame>
<frame>
<ip>0x4272AB2</ip>
<obj>/lib/i386-linux-gnu/libglib-2.0.so.0.2800.6</obj>
<fn>g_array_new</fn>
</frame>
<frame>
<ip>0x42CB7FE</ip>
<obj>/lib/i386-linux-gnu/libglib-2.0.so.0.2800.6</obj>
<fn>g_static_private_set</fn>
</frame>
<frame>
<ip>0x4282D0E</ip>
<obj>/lib/i386-linux-gnu/libglib-2.0.so.0.2800.6</obj>
<fn>g_get_filename_charsets</fn>
</frame>
<frame>
<ip>0x4282D9C</ip>
<obj>/lib/i386-linux-gnu/libglib-2.0.so.0.2800.6</obj>
</frame>
<frame>
<ip>0x42CB909</ip>
<obj>/lib/i386-linux-gnu/libglib-2.0.so.0.2800.6</obj>
<fn>g_thread_init_glib</fn>
</frame>
<frame>
<ip>0x4254506</ip>
<obj>/usr/lib/i386-linux-gnu/libgthread-2.0.so.0.2800.6</obj>
<fn>g_thread_init</fn>
</frame>
<frame>
<ip>0x8D4D458</ip>
<obj>/home/chris/untitled/untitled</obj>
<fn>QEventDispatcherGlibPrivate::QEventDispatcherGlibPrivate(_GMainContext*)</fn>
</frame>
</stack>
</error>
<errorcounts>
</errorcounts>
<suppcounts>
<pair>
<count>80</count>
<name>U1004-ARM-_dl_relocate_object</name>
</pair>
</suppcounts>
</valgrindoutput>
@@ -0,0 +1,3 @@
TEMPLATE = subdirs
CONFIG += ordered
SUBDIRS += parsertests.pro modeldemo.pro testapps testrunner.pro
@@ -0,0 +1,94 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
** Author: Frank Osterfeld, KDAB (frank.osterfeld@kdab.com)
**
** This file is part of Qt Creator.
**
** 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
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include <valgrind/xmlprotocol/frame.h>
#include <valgrind/xmlprotocol/parser.h>
#include <valgrind/xmlprotocol/stack.h>
#include <valgrind/xmlprotocol/status.h>
#include <valgrind/xmlprotocol/threadedparser.h>
#include "modeldemo.h"
#include <QApplication>
#include <QTreeView>
using namespace Valgrind;
using namespace Valgrind::XmlProtocol;
static QString fakeValgrindExecutable()
{
return QLatin1String(VALGRIND_FAKE_PATH);
}
static QString dataFile(const QLatin1String &file)
{
return QLatin1String(PARSERTESTS_DATA_DIR) + QLatin1String("/") + file;
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
qRegisterMetaType<Valgrind::XmlProtocol::Error>();
ThreadedParser parser;
Valgrind::Memcheck::MemcheckRunner runner;
runner.setValgrindExecutable(fakeValgrindExecutable());
runner.setValgrindArguments(QStringList() << QLatin1String("-i") << dataFile(QLatin1String("memcheck-output-sample1.xml")) );
runner.setParser(&parser);
ModelDemo demo(&runner);
runner.connect(&runner, SIGNAL(finished()), &demo, SLOT(finished()));
ErrorListModel model;
parser.connect(&parser, SIGNAL(error(Valgrind::XmlProtocol::Error)),
&model, SLOT(addError(Valgrind::XmlProtocol::Error)),
Qt::QueuedConnection);
QTreeView errorview;
errorview.setSelectionMode(QAbstractItemView::SingleSelection);
errorview.setSelectionBehavior(QAbstractItemView::SelectRows);
errorview.setModel(&model);
errorview.show();
StackModel stackModel;
demo.stackModel = &stackModel;
QTreeView stackView;
stackView.setModel(&stackModel);
stackView.show();
errorview.connect(errorview.selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
&demo, SLOT(selectionChanged(QItemSelection,QItemSelection)));
runner.start();
return app.exec();
}
+75
View File
@@ -0,0 +1,75 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
** Author: Frank Osterfeld, KDAB (frank.osterfeld@kdab.com)
**
** This file is part of Qt Creator.
**
** 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
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef MODELDEMO_H
#define MODELDEMO_H
#include <QObject>
#include <QDebug>
#include <QItemSelection>
#include <QModelIndex>
#include <valgrind/xmlprotocol/error.h>
#include <valgrind/xmlprotocol/errorlistmodel.h>
#include <valgrind/xmlprotocol/stackmodel.h>
#include <valgrind/memcheck/memcheckrunner.h>
class ModelDemo : public QObject
{
Q_OBJECT
public:
explicit ModelDemo(Valgrind::Memcheck::MemcheckRunner *r, QObject *parent = 0)
: QObject(parent)
, runner(r)
{
}
Valgrind::XmlProtocol::StackModel* stackModel;
public Q_SLOTS:
void finished() {
qDebug() << runner->errorString();
}
void selectionChanged(const QItemSelection &sel, const QItemSelection &) {
if (sel.indexes().isEmpty())
return;
const QModelIndex idx = sel.indexes().first();
const Valgrind::XmlProtocol::Error err = idx.data(Valgrind::XmlProtocol::ErrorListModel::ErrorRole).value<Valgrind::XmlProtocol::Error>();
qDebug() << idx.row() << err.what();
stackModel->setError(err);
}
private:
Valgrind::Memcheck::MemcheckRunner *runner;
};
#endif // MODELDEMO_H
@@ -0,0 +1,20 @@
include(../../../../qtcreator.pri)
include(../../qttestrpath.pri)
include($$IDE_SOURCE_TREE/src/libs/3rdparty/botan/botan.pri)
include($$IDE_SOURCE_TREE/src/libs/utils/utils.pri)
include($$IDE_SOURCE_TREE/src/libs/ssh/ssh.pri)
include($$IDE_SOURCE_TREE/src/plugins/valgrind/valgrind_test.pri)
TEMPLATE = app
TARGET = modeldemo
macx:CONFIG -= app_bundle
QT += gui network
DEFINES += "PARSERTESTS_DATA_DIR=\\\"$$PWD/data\\\""
DEFINES += "VALGRIND_FAKE_PATH=\\\"$$IDE_BUILD_TREE/src/tools/valgrindfake/valgrind-fake\\\""
SOURCES += modeldemo.cpp
HEADERS += modeldemo.h
@@ -0,0 +1,522 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
** Author: Frank Osterfeld, KDAB (frank.osterfeld@kdab.com)
**
** This file is part of Qt Creator.
**
** 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
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include <valgrind/xmlprotocol/frame.h>
#include <valgrind/xmlprotocol/parser.h>
#include <valgrind/xmlprotocol/stack.h>
#include <valgrind/xmlprotocol/suppression.h>
#include "parsertests.h"
#include <QCoreApplication>
#include <QDebug>
#include <QFile>
#include <QFileInfo>
#include <QString>
#include <QTest>
#include <QTcpServer>
#include <QTcpSocket>
#include <QSignalSpy>
#include <iostream>
#include <QProcess>
#if QT_VERSION >= 0x050000
#define MSKIP_SINGLE(x) QSKIP(x)
#else
#define MSKIP_SINGLE(x) QSKIP(x, SkipSingle)
#endif
using namespace Valgrind;
using namespace Valgrind::XmlProtocol;
QT_BEGIN_NAMESPACE
namespace QTest {
template<>
inline bool qCompare(int const &t1, Valgrind::XmlProtocol::MemcheckErrorKind const &t2,
char const *actual, char const *expected, char const *file, int line)
{
return qCompare(t1, int(t2), actual, expected, file, line);
}
} // namespace QTest
QT_END_NAMESPACE
void dumpFrame(const Frame &f)
{
qDebug() << f.instructionPointer() << f.directory() << f.file() << f.functionName()
<< f.line() << f.object();
}
void dumpError(const Error &e)
{
qDebug() << e.kind() << e.leakedBlocks() << e.leakedBytes() << e.what() << e.tid() << e.unique();
qDebug() << "stacks:" << e.stacks().size();
Q_FOREACH(const Stack& s, e.stacks()) {
qDebug() << s.auxWhat() << s.directory() << s.file() << s.line() << s.helgrindThreadId();
qDebug() << "frames:";
Q_FOREACH(const Frame& f, s.frames()) {
dumpFrame(f);
}
}
}
static QString fakeValgrindExecutable()
{
QString ret(VALGRIND_FAKE_PATH);
QFileInfo fileInfo(ret);
Q_ASSERT(fileInfo.isExecutable());
Q_ASSERT(!fileInfo.isDir());
return ret;
}
static QString dataFile(const QLatin1String &file)
{
return QLatin1String(PARSERTESTS_DATA_DIR) + QLatin1String("/") + file;
}
void ParserTests::initTestCase()
{
m_server = new QTcpServer(this);
QVERIFY(m_server->listen());
m_socket = 0;
m_process = 0;
}
void ParserTests::initTest(const QLatin1String &testfile, const QStringList &otherArgs)
{
QVERIFY(!m_server->hasPendingConnections());
m_process = new QProcess(m_server);
m_process->setProcessChannelMode(QProcess::ForwardedChannels);
m_process->start(
fakeValgrindExecutable(),
QStringList()
<< QString::fromLatin1("--xml-socket=127.0.0.1:%1").arg(m_server->serverPort())
<< QLatin1String("-i")
<< dataFile(testfile)
<< otherArgs
);
QVERIFY(m_process->waitForStarted(5000));
QCOMPARE(m_process->state(), QProcess::Running);
QVERIFY2(m_process->error() == QProcess::UnknownError, qPrintable(m_process->errorString()));
QVERIFY(m_server->waitForNewConnection(5000));
m_socket = m_server->nextPendingConnection();
QVERIFY(m_socket);
}
void ParserTests::cleanup()
{
if (m_socket) {
delete m_socket;
m_socket = 0;
}
if (m_process) {
delete m_process;
m_process = 0;
}
}
void ParserTests::testHelgrindSample1()
{
MSKIP_SINGLE("testfile does not exist");
initTest(QLatin1String("helgrind-output-sample1.xml"));
QList<Error> expectedErrors;
{
Error error1;
error1.setUnique(0x0);
error1.setTid(1);
error1.setKind(LockOrder);
error1.setWhat(QLatin1String("Thread #1: lock order \"0xA39C270 before 0xA3AC010\" violated"));
error1.setHelgrindThreadId(1);
Stack stack1;
Frame frame11;
frame11.setInstructionPointer(0x4C2B806);
frame11.setObject(QLatin1String("/usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so"));
frame11.setFunctionName(QLatin1String("QMutex::lock()"));
frame11.setDirectory(QLatin1String("/build/buildd/valgrind-3.6.0~svn20100212/helgrind"));
frame11.setFile(QLatin1String("hg_intercepts.c"));
frame11.setLine(1988);
Frame frame12;
frame12.setInstructionPointer(0x72E57EE);
frame12.setObject(QLatin1String("/home/frank/local/qt4-4.6.3-shared-debug/lib/libQtCore.so.4.6.3"));
frame12.setFunctionName(QLatin1String("QMutexLocker::relock()"));
frame12.setDirectory(QLatin1String("/home/frank/source/tarballs/qt-4.6.3-build/src/corelib/../../include/QtCore/../../src/corelib/thread"));
frame12.setFile(QLatin1String("qmutex.h"));
frame12.setLine(120);
stack1.setFrames(QVector<Frame>() << frame11 << frame12);
Stack stack2;
stack2.setAuxWhat(QLatin1String("Required order was established by acquisition of lock at 0xA39C270"));
Frame frame21;
frame21.setInstructionPointer(0x4C2B806);
frame21.setObject(QLatin1String("/usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so"));
frame21.setFunctionName(QLatin1String("QMutex::lock()"));
frame21.setDirectory(QLatin1String("/build/buildd/valgrind-3.6.0~svn20100212/helgrind"));
frame21.setFile(QLatin1String("hg_intercepts.c"));
frame21.setLine(1989);
Frame frame22;
frame22.setInstructionPointer(0x72E57EE);
frame22.setObject(QLatin1String("/home/frank/local/qt4-4.6.3-shared-debug/lib/libQtCore.so.4.6.3"));
frame22.setFunctionName(QLatin1String("QMutexLocker::relock()"));
frame22.setDirectory(QLatin1String("/home/frank/source/tarballs/qt-4.6.3-build/src/corelib/../../include/QtCore/../../src/corelib/thread"));
frame22.setFile(QLatin1String("qmutex.h"));
frame22.setLine(121);
stack2.setFrames(QVector<Frame>() << frame21 << frame22);
Stack stack3;
stack3.setAuxWhat(QLatin1String("followed by a later acquisition of lock at 0xA3AC010"));
Frame frame31;
frame31.setInstructionPointer(0x4C2B806);
frame31.setObject(QLatin1String("/usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so"));
frame31.setFunctionName(QLatin1String("QMutex::lock()"));
frame31.setDirectory(QLatin1String("/build/buildd/valgrind-3.6.0~svn20100212/helgrind"));
frame31.setFile(QLatin1String("hg_intercepts.c"));
frame31.setLine(1990);
Frame frame32;
frame32.setInstructionPointer(0x72E57EE);
frame32.setObject(QLatin1String("/home/frank/local/qt4-4.6.3-shared-debug/lib/libQtCore.so.4.6.3"));
frame32.setFunctionName(QLatin1String("QMutexLocker::relock()"));
frame32.setDirectory(QLatin1String("/home/frank/source/tarballs/qt-4.6.3-build/src/corelib/../../include/QtCore/../../src/corelib/thread"));
frame32.setFile(QLatin1String("qmutex.h"));
frame32.setLine(122);
stack3.setFrames(QVector<Frame>() << frame31 << frame32);
error1.setStacks(QVector<Stack>() << stack1 << stack2 << stack3);
expectedErrors.append(error1);
}
Valgrind::XmlProtocol::Parser parser;
Recorder rec(&parser);
parser.parse(m_socket);
m_process->waitForFinished();
QCOMPARE(m_process->exitStatus(), QProcess::NormalExit);
QCOMPARE(m_process->state(), QProcess::NotRunning);
QVERIFY2(parser.errorString().isEmpty(), qPrintable(parser.errorString()));
const QList<Error> actualErrors = rec.errors;
if (actualErrors.first() != expectedErrors.first()) {
dumpError(actualErrors.first());
dumpError(expectedErrors.first());
}
QCOMPARE(actualErrors.first(), expectedErrors.first());
QCOMPARE(actualErrors.size(), 1);
// QCOMPARE(rec.errorcounts, expectedErrorCounts);
// QCOMPARE(rec.suppcounts, expectedSuppCounts);
}
void ParserTests::testMemcheckSample1()
{
initTest(QLatin1String("memcheck-output-sample1.xml"));
QList<Error> expectedErrors;
{
Error error;
error.setKind(InvalidRead);
error.setWhat(QLatin1String("Invalid read of size 4"));
error.setUnique(0x9);
error.setTid(1);
Frame f1;
f1.setInstructionPointer(0x6E47964);
f1.setObject(QLatin1String("/usr/lib/libQtGui.so.4.7.0"));
f1.setFunctionName(QLatin1String("QFrame::frameStyle() const"));
f1.setDirectory(QLatin1String("/build/buildd/qt4-x11-4.7.0/src/gui/widgets"));
f1.setFile(QLatin1String("qframe.cpp"));
f1.setLine(252);
Frame f2;
f2.setInstructionPointer(0x118F2AF7);
f2.setObject(QLatin1String("/usr/lib/kde4/plugins/styles/oxygen.so"));
Frame f3;
f3.setInstructionPointer(0x6A81671);
f3.setObject(QLatin1String("/usr/lib/libQtGui.so.4.7.0"));
f3.setFunctionName(QLatin1String("QWidget::event(QEvent*)"));
f3.setDirectory(QLatin1String("/build/buildd/qt4-x11-4.7.0/src/gui/kernel"));
f3.setFile(QLatin1String("qwidget.cpp"));
f3.setLine(8273);
Frame f4;
f4.setInstructionPointer(0x6A2B6EB);
f4.setObject(QLatin1String("/usr/lib/libQtGui.so.4.7.0"));
f4.setDirectory(QLatin1String("/build/buildd/qt4-x11-4.7.0/src/gui/kernel"));
f4.setFile(QLatin1String("qapplication.cpp"));
f4.setFunctionName(QLatin1String("QApplicationPrivate::notify_helper(QObject*, QEvent*)"));
f4.setLine(4396);
Stack s1;
s1.setAuxWhat(QLatin1String("Address 0x11527cb8 is not stack'd, malloc'd or (recently) free'd"));
s1.setFrames(QVector<Frame>() << f1 << f2 << f3 << f4);
error.setStacks( QVector<Stack>() << s1 );
expectedErrors << error;
}
QVector<QPair<qint64,qint64> > expectedErrorCounts;
expectedErrorCounts.push_back(QPair<qint64,qint64>(9, 2));
QVector<QPair<QString,qint64> > expectedSuppCounts;
expectedSuppCounts.push_back(qMakePair(QString::fromLatin1("X on SUSE11 writev uninit padding"), static_cast<qint64>(12)));
expectedSuppCounts.push_back(qMakePair(QString::fromLatin1("dl-hack3-cond-1"), static_cast<qint64>(2)));
expectedSuppCounts.push_back(qMakePair(QString::fromLatin1("glibc-2.5.x-on-SUSE-10.2-(PPC)-2a"), static_cast<qint64>(2)));
Valgrind::XmlProtocol::Parser parser;
Recorder rec(&parser);
parser.parse(m_socket);
m_process->waitForFinished();
QCOMPARE(m_process->exitStatus(), QProcess::NormalExit);
QCOMPARE(m_process->state(), QProcess::NotRunning);
QVERIFY2(parser.errorString().isEmpty(), qPrintable(parser.errorString()));
const QList<Error> actualErrors = rec.errors;
if (actualErrors.first() != expectedErrors.first()) {
dumpError(actualErrors.first());
dumpError(expectedErrors.first());
}
QCOMPARE(actualErrors.first(), expectedErrors.first());
QCOMPARE(actualErrors.size(), 3);
QCOMPARE(rec.errorcounts, expectedErrorCounts);
QCOMPARE(rec.suppcounts, expectedSuppCounts);
}
void ParserTests::testMemcheckSample2()
{
MSKIP_SINGLE("testfile does not exist");
initTest(QLatin1String("memcheck-output-sample2.xml"));
Valgrind::XmlProtocol::Parser parser;
Recorder rec(&parser);
parser.parse(m_socket);
m_process->waitForFinished();
QCOMPARE(m_process->exitStatus(), QProcess::NormalExit);
QCOMPARE(m_process->state(), QProcess::NotRunning);
QVERIFY2(parser.errorString().isEmpty(), qPrintable(parser.errorString()));
//tests: multiple stacks with auxwhat == stack count - 1.
//the first auxwhat should be assigned to the _second_ stack.
const QList<Error> errors = rec.errors;
QCOMPARE(errors.size(), 1);
const QVector<Stack> stacks = errors.first().stacks();
QCOMPARE(stacks.size(), 2);
QCOMPARE(stacks.first().auxWhat(), QString());
QCOMPARE(stacks.last().auxWhat(), QLatin1String("Address 0x11b66c50 is 0 bytes inside a block of size 16 free'd"));
}
void ParserTests::testMemcheckSample3()
{
MSKIP_SINGLE("testfile does not exist");
initTest(QLatin1String("memcheck-output-sample3.xml"));
Valgrind::XmlProtocol::Parser parser;
Recorder rec(&parser);
parser.parse(m_socket);
m_process->waitForFinished();
QCOMPARE(m_process->exitStatus(), QProcess::NormalExit);
QCOMPARE(m_process->state(), QProcess::NotRunning);
QVERIFY2(parser.errorString().isEmpty(), qPrintable(parser.errorString()));
const QList<Error> errors = rec.errors;
QCOMPARE(errors.size(), 6);
{
const Error error = errors.at(0);
const QVector<Stack> stacks = error.stacks();
QCOMPARE(error.unique(), 0x1ll);
QCOMPARE(error.what(), QLatin1String("Conditional jump or move depends on uninitialised value(s)"));
QCOMPARE(error.kind(), UninitCondition);
QCOMPARE(stacks.size(), 1);
QCOMPARE(stacks.first().frames().size(), 12);
QVERIFY(!error.suppression().isNull());
QCOMPARE(error.suppression().frames().count(), stacks.first().frames().size());
QCOMPARE(error.suppression().kind(), QLatin1String("Memcheck:Cond"));
QVERIFY(!error.suppression().rawText().trimmed().isEmpty());
// rawtext contains <...> while <name></name> does not
QCOMPARE(error.suppression().name(), QLatin1String("insert_a_suppression_name_here"));
Suppression sup = error.suppression();
sup.setName(QLatin1String("<insert_a_suppression_name_here>"));
QCOMPARE(sup.toString().trimmed(), sup.rawText().trimmed());
QCOMPARE(error.suppression().frames().first().object(),
QLatin1String("/usr/lib/kde4/plugins/styles/qtcurve.so"));
QVERIFY(error.suppression().frames().first().function().isEmpty());
QCOMPARE(error.suppression().frames().last().function(), QLatin1String("main"));
QVERIFY(error.suppression().frames().last().object().isEmpty());
}
QCOMPARE(rec.suppcounts.count(), 3);
QCOMPARE(rec.suppcounts.at(0).second, qint64(1));
QCOMPARE(rec.suppcounts.at(1).second, qint64(2));
QCOMPARE(rec.suppcounts.at(2).second, qint64(3));
}
void ParserTests::testMemcheckCharm()
{
MSKIP_SINGLE("testfile does not exist");
// a somewhat larger file, to make sure buffering and partial I/O works ok
initTest(QLatin1String("memcheck-output-untitled.xml"));
Valgrind::XmlProtocol::Parser parser;
Recorder rec(&parser);
parser.parse(m_socket);
m_process->waitForFinished();
QCOMPARE(m_process->exitStatus(), QProcess::NormalExit);
QCOMPARE(m_process->state(), QProcess::NotRunning);
const QList<Error> errors = rec.errors;
QCOMPARE(errors.size(), 102);
QVERIFY2(parser.errorString().isEmpty(), qPrintable(parser.errorString()));
}
void ParserTests::testValgrindCrash()
{
initTest(QLatin1String("memcheck-output-sample1.xml"), QStringList() << "--crash");
Valgrind::XmlProtocol::Parser parser;
parser.parse(m_socket);
m_process->waitForFinished();
QCOMPARE(m_process->state(), QProcess::NotRunning);
QCOMPARE(m_process->exitStatus(), QProcess::CrashExit);
QVERIFY(!parser.errorString().isEmpty());
QCOMPARE(m_socket->error(), QAbstractSocket::RemoteHostClosedError);
QCOMPARE(parser.errorString(), m_socket->errorString());
}
void ParserTests::testValgrindGarbage()
{
initTest(QLatin1String("memcheck-output-sample1.xml"), QStringList() << "--garbage");
Valgrind::XmlProtocol::Parser parser;
parser.parse(m_socket);
m_process->waitForFinished();
QCOMPARE(m_process->state(), QProcess::NotRunning);
QCOMPARE(m_process->exitStatus(), QProcess::NormalExit);
QVERIFY(!parser.errorString().isEmpty());
qDebug() << parser.errorString();
}
void ParserTests::testParserStop()
{
ThreadedParser parser;
Valgrind::Memcheck::MemcheckRunner runner;
runner.setValgrindExecutable(fakeValgrindExecutable());
runner.setParser(&parser);
runner.setValgrindArguments(QStringList() << QLatin1String("-i")
<< dataFile(QLatin1String("memcheck-output-sample1.xml"))
<< "--wait" << "5");
runner.setProcessChannelMode(QProcess::ForwardedChannels);
runner.start();
QTest::qWait(500);
runner.stop();
}
void ParserTests::testRealValgrind()
{
QString executable = QProcessEnvironment::systemEnvironment().value("VALGRIND_TEST_BIN", fakeValgrindExecutable());
qDebug() << "running exe:" << executable << " HINT: set VALGRIND_TEST_BIN to change this";
ThreadedParser parser;
Valgrind::Memcheck::MemcheckRunner runner;
runner.setValgrindExecutable(QLatin1String("valgrind"));
runner.setDebuggeeExecutable(executable);
runner.setParser(&parser);
RunnerDumper dumper(&runner, &parser);
runner.start();
runner.waitForFinished();
}
void ParserTests::testValgrindStartError_data()
{
QTest::addColumn<QString>("valgrindExe");
QTest::addColumn<QStringList>("valgrindArgs");
QTest::addColumn<QString>("debuggee");
QTest::addColumn<QString>("debuggeeArgs");
QTest::newRow("invalid_client") << QString::fromLatin1("valgrind") << QStringList()
<< QString::fromLatin1("please-dont-let-this-app-exist") << QString();
QTest::newRow("invalid_valgrind") << QString::fromLatin1("valgrind-that-does-not-exist") << QStringList()
<< fakeValgrindExecutable() << QString();
QTest::newRow("invalid_valgrind_args") << QString::fromLatin1("valgrind")
<< (QStringList() << QString::fromLatin1("--foobar-fail"))
<< fakeValgrindExecutable() << QString();
}
void ParserTests::testValgrindStartError()
{
QFETCH(QString, valgrindExe);
QFETCH(QStringList, valgrindArgs);
QFETCH(QString, debuggee);
QFETCH(QString, debuggeeArgs);
ThreadedParser parser;
Valgrind::Memcheck::MemcheckRunner runner;
runner.setParser(&parser);
runner.setValgrindExecutable(valgrindExe);
runner.setValgrindArguments(valgrindArgs);
runner.setDebuggeeExecutable(debuggee);
runner.setDebuggeeArguments(debuggeeArgs);
RunnerDumper dumper(&runner, &parser);
runner.start();
runner.waitForFinished();
QVERIFY(dumper.m_errorReceived);
// just finish without deadlock and we are fine
}
QTEST_MAIN(ParserTests)
+185
View File
@@ -0,0 +1,185 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
** Author: Frank Osterfeld, KDAB (frank.osterfeld@kdab.com)
**
** This file is part of Qt Creator.
**
** 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
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef PARSERTESTS_H
#define PARSERTESTS_H
#include <QObject>
#include <QPair>
#include <QStringList>
#include <QVector>
#include <QDebug>
#include <valgrind/xmlprotocol/error.h>
#include <valgrind/xmlprotocol/status.h>
#include <valgrind/xmlprotocol/threadedparser.h>
#include <valgrind/xmlprotocol/parser.h>
#include <valgrind/memcheck/memcheckrunner.h>
QT_BEGIN_NAMESPACE
class QTcpServer;
class QTcpSocket;
class QProcess;
QT_END_NAMESPACE
void dumpError(const Valgrind::XmlProtocol::Error &e);
class Recorder : public QObject
{
Q_OBJECT
public:
explicit Recorder(Valgrind::XmlProtocol::Parser *parser, QObject *parent = 0)
: QObject(parent)
{
connect(parser, SIGNAL(error(Valgrind::XmlProtocol::Error)),
this, SLOT(error(Valgrind::XmlProtocol::Error)));
connect(parser, SIGNAL(errorCount(qint64, qint64)),
this, SLOT(errorCount(qint64, qint64)));
connect(parser, SIGNAL(suppressionCount(QString, qint64)),
this, SLOT(suppressionCount(QString, qint64)));
}
QList<Valgrind::XmlProtocol::Error> errors;
QVector<QPair<qint64,qint64> > errorcounts;
QVector<QPair<QString,qint64> > suppcounts;
public Q_SLOTS:
void error(const Valgrind::XmlProtocol::Error &err)
{
errors.append(err);
}
void errorCount(qint64 unique, qint64 count)
{
errorcounts.push_back(qMakePair(unique, count));
}
void suppressionCount(const QString &name, qint64 count)
{
suppcounts.push_back(qMakePair(name, count));
}
};
class RunnerDumper : public QObject
{
Q_OBJECT
public:
explicit RunnerDumper(Valgrind::Memcheck::MemcheckRunner *runner, Valgrind::XmlProtocol::ThreadedParser *parser)
: QObject()
, m_errorReceived(false)
{
connect(parser, SIGNAL(error(Valgrind::XmlProtocol::Error)),
this, SLOT(error(Valgrind::XmlProtocol::Error)));
connect(parser, SIGNAL(internalError(QString)),
this, SLOT(internalError(QString)));
connect(parser, SIGNAL(status(Valgrind::XmlProtocol::Status)),
this, SLOT(status(Valgrind::XmlProtocol::Status)));
connect(runner, SIGNAL(standardErrorReceived(QByteArray)),
this, SLOT(standardErrorReceived(QByteArray)));
connect(runner, SIGNAL(standardOutputReceived(QByteArray)),
this, SLOT(standardOutputReceived(QByteArray)));
connect(runner, SIGNAL(logMessageReceived(QByteArray)),
this, SLOT(logMessageReceived(QByteArray)));
connect(runner, SIGNAL(processErrorReceived(QString, QProcess::ProcessError)),
this, SLOT(processErrorReceived(QString)));
}
public slots:
void error(const Valgrind::XmlProtocol::Error &e)
{
qDebug() << "error received";
dumpError(e);
}
void internalError(const QString& error)
{
qDebug() << "internal error received:" << error;
}
void standardErrorReceived(const QByteArray &err)
{
Q_UNUSED(err);
// qDebug() << "STDERR received:" << err; // this can be a lot of text
}
void standardOutputReceived(const QByteArray &out)
{
qDebug() << "STDOUT received:" << out;
}
void status(const Valgrind::XmlProtocol::Status &status)
{
qDebug() << "status received:" << status.state() << status.time();
}
void logMessageReceived(const QByteArray &log)
{
qDebug() << "log message received:" << log;
}
void processErrorReceived(const QString &s)
{
Q_UNUSED(s);
// qDebug() << "error received:" << s; // this can be a lot of text
m_errorReceived = true;
}
public:
bool m_errorReceived;
};
class ParserTests : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void cleanup();
void testMemcheckSample1();
void testMemcheckSample2();
void testMemcheckSample3();
void testMemcheckCharm();
void testHelgrindSample1();
void testValgrindCrash();
void testValgrindGarbage();
void testParserStop();
void testRealValgrind();
void testValgrindStartError_data();
void testValgrindStartError();
private:
void initTest(const QLatin1String &testfile, const QStringList &otherArgs = QStringList());
QTcpServer *m_server;
QProcess *m_process;
QTcpSocket *m_socket;
};
#endif // PARSERTESTS_H
@@ -0,0 +1,15 @@
include(../../qttest.pri)
include($$IDE_SOURCE_TREE/src/libs/3rdparty/botan/botan.pri)
include($$IDE_SOURCE_TREE/src/libs/ssh/ssh.pri)
include($$IDE_SOURCE_TREE/src/libs/utils/utils.pri)
include($$IDE_SOURCE_TREE/src/plugins/valgrind/valgrind_test.pri)
TARGET = tst_parsertests
QT += network
DEFINES += "PARSERTESTS_DATA_DIR=\\\"$$_PRO_FILE_PWD_/data\\\""
DEFINES += "VALGRIND_FAKE_PATH=\\\"$$IDE_BUILD_TREE/src/tools/valgrindfake/valgrind-fake\\\""
SOURCES += parsertests.cpp
HEADERS += parsertests.h
@@ -0,0 +1,8 @@
TEMPLATE = app
TARGET = free1
QT -= core gui
macx:CONFIG -= app_bundle
SOURCES += main.cpp
@@ -0,0 +1,38 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** 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
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include <cstdlib>
int main()
{
int *p = new int;
delete p;
delete p;
return 0;
}
@@ -0,0 +1,8 @@
TEMPLATE = app
TARGET = free2
QT -= core gui
macx:CONFIG -= app_bundle
SOURCES += main.cpp
@@ -0,0 +1,37 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** 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
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include <cstdlib>
int main()
{
int *p = new int;
free(p);
return 0;
}
@@ -0,0 +1,8 @@
TEMPLATE = app
TARGET = invalidjump
QT -= core gui
macx:CONFIG -= app_bundle
SOURCES += main.cpp
@@ -0,0 +1,37 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** 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
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
void foo() { }
int main()
{
void (*fooPtr)() = 0;
fooPtr();
return 0;
}
@@ -0,0 +1,8 @@
TEMPLATE = app
TARGET = leak1
QT += core
macx:CONFIG -= app_bundle
SOURCES += main.cpp
@@ -0,0 +1,36 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** 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
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include <qglobal.h>
int main()
{
new qint64;
return 0;
}
@@ -0,0 +1,8 @@
TEMPLATE = app
TARGET = leak2
QT += core
macx:CONFIG -= app_bundle
SOURCES += main.cpp
@@ -0,0 +1,42 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** 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
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include <string.h>
char *lower;
int main()
{
lower = strdup("asdf");
while (*lower)
lower++;
return 0;
}
@@ -0,0 +1,8 @@
TEMPLATE = app
TARGET = leak3
QT += core
macx:CONFIG -= app_bundle
SOURCES += main.cpp
@@ -0,0 +1,39 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** 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
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include <string.h>
char *lower;
int main()
{
lower = strdup("asdf");
return 0;
}
@@ -0,0 +1,8 @@
TEMPLATE = app
TARGET = leak4
QT += core
macx:CONFIG -= app_bundle
SOURCES += main.cpp
@@ -0,0 +1,46 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** 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
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include <qglobal.h>
struct Foo
{
Foo()
: num(new qint64)
{}
qint64 *num;
};
int main()
{
new Foo;
return 0;
}
@@ -0,0 +1,38 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** 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
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include <string.h>
int main()
{
int *i = new int[10];
memcpy(i, &i[1], 20);
delete[] i;
return 0;
}
@@ -0,0 +1,8 @@
TEMPLATE = app
TARGET = overlap
QT -= core gui
macx:CONFIG -= app_bundle
SOURCES += main.cpp
@@ -0,0 +1,36 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** 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
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#pragma GCC diagnostic ignored "-Wuninitialized"
int main()
{
int i;
return i;
}
@@ -0,0 +1,8 @@
TEMPLATE = app
TARGET = syscall
QT += core
macx:CONFIG -= app_bundle
SOURCES += main.cpp
@@ -0,0 +1,4 @@
TEMPLATE = subdirs
SUBDIRS += leak1 leak2 leak3 leak4 uninit1 uninit2 syscall free1 uninit3 free2 invalidjump \
overlap
@@ -0,0 +1,40 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** 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
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#pragma GCC diagnostic ignored "-Wuninitialized"
int main()
{
bool b;
if (b) {
return 1;
}
return 0;
}
@@ -0,0 +1,8 @@
TEMPLATE = app
TARGET = uninit1
QT -= core gui
macx:CONFIG -= app_bundle
SOURCES += main.cpp
@@ -0,0 +1,38 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** 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
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#pragma GCC diagnostic ignored "-Wuninitialized"
int main()
{
int *i;
*i = 5;
return 0;
}
@@ -0,0 +1,8 @@
TEMPLATE = app
TARGET = uninit2
QT -= core gui
macx:CONFIG -= app_bundle
SOURCES += main.cpp
@@ -0,0 +1,36 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** 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
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#pragma GCC diagnostic ignored "-Wuninitialized"
int main()
{
int *i;
return *i;
}
@@ -0,0 +1,8 @@
TEMPLATE = app
TARGET = uninit3
QT -= core gui
macx:CONFIG -= app_bundle
SOURCES += main.cpp
+698
View File
@@ -0,0 +1,698 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
** Author: Milian Wolff, KDAB (milian.wolff@kdab.com)
**
** This file is part of Qt Creator.
**
** 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
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "testrunner.h"
#include <valgrind/xmlprotocol/frame.h>
#include <valgrind/xmlprotocol/stack.h>
#include <valgrind/xmlprotocol/suppression.h>
#include <valgrind/xmlprotocol/threadedparser.h>
#include <valgrind/xmlprotocol/parser.h>
#include <valgrind/memcheck/memcheckrunner.h>
#include <QDebug>
#include <QTest>
#include <QDir>
#include <QSignalSpy>
const QString appSrcDir(TESTRUNNER_SRC_DIR);
const QString appBinDir(TESTRUNNER_APP_DIR);
QString srcDirForApp(const QString &app)
{
return appSrcDir + QDir::separator() + app;
}
QTEST_MAIN(Valgrind::TestRunner)
using namespace Valgrind;
using namespace Valgrind::XmlProtocol;
using namespace Valgrind::Memcheck;
//BEGIN Test Helpers and boilerplate code
TestRunner::TestRunner(QObject *parent)
: QObject(parent),
m_parser(0),
m_runner(0)
{
qRegisterMetaType<Error>();
}
QString TestRunner::runTestBinary(const QString &binary, const QStringList &vArgs)
{
const QString binPath = appBinDir + QDir::separator() + binary;
Q_ASSERT(QFileInfo(binPath).isExecutable());
m_runner->setValgrindArguments(QStringList() << "--num-callers=50" << "--track-origins=yes" << vArgs);
m_runner->setDebuggeeExecutable(binPath);
m_runner->start();
m_runner->waitForFinished();
return binPath;
}
void TestRunner::logMessageReceived(const QByteArray &message)
{
qDebug() << "log message received:" << message;
m_logMessages << message;
}
void TestRunner::internalError(const QString &error)
{
if (!m_expectCrash)
QFAIL(qPrintable(error));
else
qDebug() << "expected crash:" << error;
}
void TestRunner::error(const Error &error)
{
m_errors << error;
}
void TestRunner::cleanup()
{
Q_ASSERT(m_runner);
delete m_runner;
m_runner = 0;
Q_ASSERT(m_parser);
delete m_parser;
m_parser = 0;
m_logMessages.clear();
m_errors.clear();
m_expectCrash = false;
}
void TestRunner::init()
{
Q_ASSERT(m_logMessages.isEmpty());
Q_ASSERT(!m_runner);
m_runner = new MemcheckRunner;
m_runner->setValgrindExecutable(QLatin1String("valgrind"));
m_runner->setProcessChannelMode(QProcess::ForwardedChannels);
connect(m_runner, SIGNAL(logMessageReceived(QByteArray)),
this, SLOT(logMessageReceived(QByteArray)));
connect(m_runner, SIGNAL(processErrorReceived(QString,QProcess::ProcessError)),
this, SLOT(internalError(QString)));
Q_ASSERT(!m_parser);
m_parser = new ThreadedParser;
connect(m_parser, SIGNAL(internalError(QString)),
this, SLOT(internalError(QString)));
connect(m_parser, SIGNAL(error(Valgrind::XmlProtocol::Error)),
this, SLOT(error(Valgrind::XmlProtocol::Error)));
m_runner->setParser(m_parser);
}
//BEGIN: Actual test cases
void TestRunner::testLeak1()
{
const QString binary = runTestBinary(QLatin1String("leak1/leak1"));
QVERIFY(m_logMessages.isEmpty());
QCOMPARE(m_errors.count(), 1);
const Error error = m_errors.first();
QCOMPARE(error.kind(), int(Leak_DefinitelyLost));
QCOMPARE(error.leakedBlocks(), qint64(1));
QCOMPARE(error.leakedBytes(), quint64(8));
QCOMPARE(error.stacks().count(), 1);
const Stack stack = error.stacks().first();
QCOMPARE(stack.line(), qint64(-1));
QCOMPARE(stack.frames().count(), 2);
{
const Frame frame = stack.frames().at(0);
QCOMPARE(frame.functionName(), QLatin1String("operator new(unsigned long)"));
}
{
const Frame frame = stack.frames().at(1);
QCOMPARE(frame.functionName(), QLatin1String("main"));
QCOMPARE(frame.line(), 5);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDirForApp("leak1"));
}
}
void TestRunner::testLeak2()
{
const QString binary = runTestBinary(QLatin1String("leak2/leak2"));
QVERIFY(m_logMessages.isEmpty());
QCOMPARE(m_errors.count(), 1);
const Error error = m_errors.first();
QCOMPARE(error.kind(), int(Leak_PossiblyLost));
QCOMPARE(error.leakedBlocks(), qint64(1));
QCOMPARE(error.leakedBytes(), quint64(5));
QCOMPARE(error.stacks().count(), 1);
const Stack stack = error.stacks().first();
QCOMPARE(stack.line(), qint64(-1));
QCOMPARE(stack.frames().count(), 3);
{
const Frame frame = stack.frames().at(0);
QCOMPARE(frame.functionName(), QLatin1String("malloc"));
}
{
const Frame frame = stack.frames().at(1);
QCOMPARE(frame.functionName(), QLatin1String("strdup"));
}
{
const Frame frame = stack.frames().at(2);
QCOMPARE(frame.functionName(), QLatin1String("main"));
QCOMPARE(frame.line(), 7);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDirForApp("leak2"));
}
}
void TestRunner::testLeak3()
{
const QString binary = runTestBinary(QLatin1String("leak3/leak3"), QStringList() << "--show-reachable=yes");
QVERIFY(m_logMessages.isEmpty());
QCOMPARE(m_errors.count(), 1);
const Error error = m_errors.first();
QCOMPARE(error.kind(), int(Leak_StillReachable));
QCOMPARE(error.leakedBlocks(), qint64(1));
QCOMPARE(error.leakedBytes(), quint64(5));
QCOMPARE(error.stacks().count(), 1);
const Stack stack = error.stacks().first();
QCOMPARE(stack.line(), qint64(-1));
QCOMPARE(stack.frames().count(), 3);
{
const Frame frame = stack.frames().at(0);
QCOMPARE(frame.functionName(), QLatin1String("malloc"));
}
{
const Frame frame = stack.frames().at(1);
QCOMPARE(frame.functionName(), QLatin1String("strdup"));
}
{
const Frame frame = stack.frames().at(2);
QCOMPARE(frame.functionName(), QLatin1String("main"));
QCOMPARE(frame.line(), 7);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDirForApp("leak3"));
}
}
void TestRunner::testLeak4()
{
const QString app("leak4");
const QString binary = runTestBinary(app + QDir::separator() + app,
QStringList() << "--show-reachable=yes");
const QString srcDir = srcDirForApp("leak4");
QVERIFY(m_logMessages.isEmpty());
QCOMPARE(m_errors.count(), 2);
//BEGIN first error
{
const Error error = m_errors.first();
QCOMPARE(error.kind(), int(Leak_IndirectlyLost));
QCOMPARE(error.leakedBlocks(), qint64(1));
QCOMPARE(error.leakedBytes(), quint64(8));
QCOMPARE(error.stacks().count(), 1);
const Stack stack = error.stacks().first();
QCOMPARE(stack.line(), qint64(-1));
QCOMPARE(stack.frames().count(), 3);
{
const Frame frame = stack.frames().at(0);
QCOMPARE(frame.functionName(), QLatin1String("operator new(unsigned long)"));
}
{
const Frame frame = stack.frames().at(2);
QCOMPARE(frame.functionName(), QLatin1String("main"));
QCOMPARE(frame.line(), 14);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDir);
}
{
const Frame frame = stack.frames().at(1);
QCOMPARE(frame.functionName(), QLatin1String("Foo::Foo()"));
QCOMPARE(frame.line(), 6);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDir);
}
{
const Frame frame = stack.frames().at(2);
QCOMPARE(frame.functionName(), QLatin1String("main"));
QCOMPARE(frame.line(), 14);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDir);
}
}
//BEGIN second error
{
const Error error = m_errors.last();
QCOMPARE(error.kind(), int(Leak_DefinitelyLost));
QCOMPARE(error.leakedBlocks(), qint64(1));
QCOMPARE(error.leakedBytes(), quint64(16));
QCOMPARE(error.stacks().count(), 1);
const Stack stack = error.stacks().first();
QCOMPARE(stack.line(), qint64(-1));
QCOMPARE(stack.frames().count(), 2);
{
const Frame frame = stack.frames().at(0);
QCOMPARE(frame.functionName(), QLatin1String("operator new(unsigned long)"));
}
{
const Frame frame = stack.frames().at(1);
QCOMPARE(frame.functionName(), QLatin1String("main"));
QCOMPARE(frame.line(), 14);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDir);
}
}
}
void TestRunner::uninit1()
{
const QString app("uninit1");
const QString binary = runTestBinary(app + QDir::separator() + app);
const QString srcDir = srcDirForApp(app);
QVERIFY(m_logMessages.isEmpty());
QCOMPARE(m_errors.count(), 1);
const Error error = m_errors.first();
QCOMPARE(error.kind(), int(UninitCondition));
QCOMPARE(error.stacks().count(), 2);
//BEGIN first stack
{
const Stack stack = error.stacks().first();
QCOMPARE(stack.line(), qint64(-1));
QCOMPARE(stack.frames().count(), 1);
const Frame frame = stack.frames().first();
QCOMPARE(frame.functionName(), QLatin1String("main"));
QCOMPARE(frame.line(), 4);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDir);
}
//BEGIN second stack
{
const Stack stack = error.stacks().last();
QCOMPARE(stack.line(), qint64(-1));
QCOMPARE(stack.frames().count(), 1);
const Frame frame = stack.frames().first();
QCOMPARE(frame.functionName(), QLatin1String("main"));
QCOMPARE(frame.line(), 2);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDir);
}
}
void TestRunner::uninit2()
{
const QString app("uninit2");
m_expectCrash = true;
const QString binary = runTestBinary(app + QDir::separator() + app);
const QString srcDir = srcDirForApp(app);
QVERIFY(m_logMessages.isEmpty());
QCOMPARE(m_errors.count(), 2);
//BEGIN first error
{
const Error error = m_errors.first();
QCOMPARE(error.kind(), int(UninitValue));
QCOMPARE(error.stacks().count(), 2);
//BEGIN first stack
{
const Stack stack = error.stacks().first();
QCOMPARE(stack.line(), qint64(-1));
QCOMPARE(stack.frames().count(), 1);
const Frame frame = stack.frames().first();
QCOMPARE(frame.functionName(), QLatin1String("main"));
QCOMPARE(frame.line(), 4);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDir);
}
//BEGIN second stack
{
const Stack stack = error.stacks().last();
QCOMPARE(stack.line(), qint64(-1));
QCOMPARE(stack.frames().count(), 1);
const Frame frame = stack.frames().first();
QCOMPARE(frame.functionName(), QLatin1String("main"));
QCOMPARE(frame.line(), 2);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDir);
}
}
//BEGIN second error
{
const Error error = m_errors.last();
QCOMPARE(error.kind(), int(InvalidWrite));
QCOMPARE(error.stacks().count(), 1);
const Stack stack = error.stacks().first();
QCOMPARE(stack.line(), qint64(-1));
QCOMPARE(stack.frames().count(), 1);
const Frame frame = stack.frames().first();
QCOMPARE(frame.functionName(), QLatin1String("main"));
QCOMPARE(frame.line(), 4);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDir);
}
}
void TestRunner::uninit3()
{
const QString app("uninit3");
m_expectCrash = true;
const QString binary = runTestBinary(app + QDir::separator() + app);
const QString srcDir = srcDirForApp(app);
QVERIFY(m_logMessages.isEmpty());
QCOMPARE(m_errors.count(), 2);
//BEGIN first error
{
const Error error = m_errors.first();
QCOMPARE(error.kind(), int(UninitValue));
QCOMPARE(error.stacks().count(), 2);
//BEGIN first stack
{
const Stack stack = error.stacks().first();
QCOMPARE(stack.line(), qint64(-1));
QCOMPARE(stack.frames().count(), 1);
const Frame frame = stack.frames().first();
QCOMPARE(frame.functionName(), QLatin1String("main"));
QCOMPARE(frame.line(), 4);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDir);
}
//BEGIN second stack
{
const Stack stack = error.stacks().last();
QCOMPARE(stack.line(), qint64(-1));
QCOMPARE(stack.frames().count(), 1);
const Frame frame = stack.frames().first();
QCOMPARE(frame.functionName(), QLatin1String("main"));
QCOMPARE(frame.line(), 2);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDir);
}
}
//BEGIN second error
{
const Error error = m_errors.last();
QCOMPARE(error.kind(), int(InvalidRead));
QCOMPARE(error.stacks().count(), 1);
const Stack stack = error.stacks().first();
QCOMPARE(stack.line(), qint64(-1));
QCOMPARE(stack.frames().count(), 1);
const Frame frame = stack.frames().first();
QCOMPARE(frame.functionName(), QLatin1String("main"));
QCOMPARE(frame.line(), 4);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDir);
}
}
void TestRunner::syscall()
{
const QString app("syscall");
const QString binary = runTestBinary(app + QDir::separator() + app);
const QString srcDir = srcDirForApp(app);
QVERIFY(m_logMessages.isEmpty());
QCOMPARE(m_errors.count(), 1);
const Error error = m_errors.first();
QCOMPARE(error.kind(), int(SyscallParam));
QCOMPARE(error.stacks().count(), 2);
//BEGIN first stack
{
const Stack stack = error.stacks().first();
QCOMPARE(stack.line(), qint64(-1));
QCOMPARE(stack.frames().count(), 3);
{
///TODO: is this platform specific?
const Frame frame = stack.frames().at(0);
QCOMPARE(frame.functionName(), QLatin1String("_Exit"));
}
{
const Frame frame = stack.frames().at(1);
QCOMPARE(frame.functionName(), QLatin1String("exit"));
}
{
const Frame frame = stack.frames().at(2);
QCOMPARE(frame.functionName(), QLatin1String("(below main)"));
}
}
//BEGIN second stack
{
const Stack stack = error.stacks().last();
QCOMPARE(stack.line(), qint64(-1));
QCOMPARE(stack.frames().count(), 1);
const Frame frame = stack.frames().first();
QCOMPARE(frame.functionName(), QLatin1String("main"));
QCOMPARE(frame.line(), 2);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDir);
}
}
void TestRunner::free1()
{
const QString app("free1");
const QString binary = runTestBinary(app + QDir::separator() + app);
const QString srcDir = srcDirForApp(app);
QVERIFY(m_logMessages.isEmpty());
QCOMPARE(m_errors.count(), 1);
const Error error = m_errors.first();
QCOMPARE(error.kind(), int(InvalidFree));
QCOMPARE(error.stacks().count(), 2);
//BEGIN first stack
{
const Stack stack = error.stacks().first();
QCOMPARE(stack.line(), qint64(-1));
QCOMPARE(stack.frames().count(), 2);
{
const Frame frame = stack.frames().first();
QCOMPARE(frame.functionName(), QLatin1String("operator delete(void*)"));
}
{
const Frame frame = stack.frames().last();
QCOMPARE(frame.functionName(), QLatin1String("main"));
QCOMPARE(frame.line(), 7);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDir);
}
}
//BEGIN second stack
{
const Stack stack = error.stacks().last();
QCOMPARE(stack.line(), qint64(-1));
QCOMPARE(stack.frames().count(), 2);
{
const Frame frame = stack.frames().first();
QCOMPARE(frame.functionName(), QLatin1String("operator delete(void*)"));
}
{
const Frame frame = stack.frames().last();
QCOMPARE(frame.functionName(), QLatin1String("main"));
QCOMPARE(frame.line(), 6);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDir);
}
}
}
void TestRunner::free2()
{
const QString app("free2");
const QString binary = runTestBinary(app + QDir::separator() + app);
const QString srcDir = srcDirForApp(app);
QVERIFY(m_logMessages.isEmpty());
QCOMPARE(m_errors.count(), 1);
const Error error = m_errors.first();
QCOMPARE(error.kind(), int(MismatchedFree));
QCOMPARE(error.stacks().count(), 2);
//BEGIN first stack
{
const Stack stack = error.stacks().first();
QCOMPARE(stack.line(), qint64(-1));
QCOMPARE(stack.frames().count(), 2);
{
const Frame frame = stack.frames().first();
QCOMPARE(frame.functionName(), QLatin1String("free"));
}
{
const Frame frame = stack.frames().last();
QCOMPARE(frame.functionName(), QLatin1String("main"));
QCOMPARE(frame.line(), 6);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDir);
}
}
//BEGIN second stack
{
const Stack stack = error.stacks().last();
QCOMPARE(stack.line(), qint64(-1));
QCOMPARE(stack.frames().count(), 2);
{
const Frame frame = stack.frames().first();
QCOMPARE(frame.functionName(), QLatin1String("operator new(unsigned long)"));
}
{
const Frame frame = stack.frames().last();
QCOMPARE(frame.functionName(), QLatin1String("main"));
QCOMPARE(frame.line(), 5);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDir);
}
}
}
void TestRunner::invalidjump()
{
const QString app("invalidjump");
m_expectCrash = true;
const QString binary = runTestBinary(app + QDir::separator() + app);
const QString srcDir = srcDirForApp(app);
QVERIFY(m_logMessages.isEmpty());
QCOMPARE(m_errors.count(), 1);
const Error error = m_errors.first();
QCOMPARE(error.kind(), int(InvalidJump));
QCOMPARE(error.stacks().count(), 1);
const Stack stack = error.stacks().first();
QCOMPARE(stack.line(), qint64(-1));
QCOMPARE(stack.frames().count(), 2);
QVERIFY(!stack.auxWhat().isEmpty());
{
const Frame frame = stack.frames().at(0);
QCOMPARE(frame.instructionPointer(), quint64(0));
}
{
const Frame frame = stack.frames().at(1);
QCOMPARE(frame.functionName(), QLatin1String("(below main)"));
}
}
void TestRunner::overlap()
{
const QString app("overlap");
m_expectCrash = true;
const QString binary = runTestBinary(app + QDir::separator() + app);
const QString srcDir = srcDirForApp(app);
QVERIFY(m_logMessages.isEmpty());
QCOMPARE(m_errors.count(), 1);
const Error error = m_errors.first();
QCOMPARE(error.kind(), int(Overlap));
QCOMPARE(error.stacks().count(), 1);
const Stack stack = error.stacks().first();
QCOMPARE(stack.line(), qint64(-1));
QCOMPARE(stack.frames().count(), 2);
{
const Frame frame = stack.frames().at(0);
QCOMPARE(frame.functionName(), QLatin1String("memcpy"));
}
{
const Frame frame = stack.frames().last();
QCOMPARE(frame.functionName(), QLatin1String("main"));
QCOMPARE(frame.line(), 6);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDir);
}
}
+93
View File
@@ -0,0 +1,93 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
** Author: Milian Wolff, KDAB (milian.wolff@kdab.com)
**
** This file is part of Qt Creator.
**
** 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
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef TESTRUNNER_H
#define TESTRUNNER_H
#include <QObject>
#include <QStringList>
#include <valgrind/xmlprotocol/error.h>
namespace Valgrind {
namespace XmlProtocol {
class ThreadedParser;
}
namespace Memcheck {
class MemcheckRunner;
}
class TestRunner : public QObject
{
Q_OBJECT
public:
explicit TestRunner(QObject *parent = 0);
private Q_SLOTS:
void init();
void cleanup();
void testLeak1();
void testLeak2();
void testLeak3();
void testLeak4();
void uninit1();
void uninit2();
void uninit3();
void free1();
void free2();
void invalidjump();
void syscall();
void overlap();
private Q_SLOTS:
void logMessageReceived(const QByteArray &message);
void internalError(const QString &error);
void error(const Valgrind::XmlProtocol::Error &error);
private:
QString runTestBinary(const QString &binary, const QStringList &vArgs = QStringList());
XmlProtocol::ThreadedParser *m_parser;
Memcheck::MemcheckRunner *m_runner;
QList<QByteArray> m_logMessages;
QList<XmlProtocol::Error> m_errors;
bool m_expectCrash;
};
} // namespace Valgrind
#endif // TESTRUNNER_H
@@ -0,0 +1,12 @@
include(../../qttest.pri)
include($$IDE_SOURCE_TREE/src/libs/utils/utils.pri)
include($$IDE_SOURCE_TREE/src/libs/ssh/ssh.pri)
include($$IDE_SOURCE_TREE/src/plugins/valgrind/valgrind_test.pri)
TARGET = tst_testrunner
DEFINES += "TESTRUNNER_SRC_DIR=\\\"$$_PRO_FILE_PWD_/testapps\\\""
DEFINES += "TESTRUNNER_APP_DIR=\\\"$(PWD)/testapps\\\""
SOURCES += testrunner.cpp
HEADERS += testrunner.h
+3
View File
@@ -0,0 +1,3 @@
TEMPLATE = subdirs
SUBDIRS += memcheck callgrind