Commit eb848eb8 authored by Christian Kandeler's avatar Christian Kandeler

Valgrind: Introduce Frame::filePath().

Change-Id: I40d1b7f739ea905bbcca1a388bada3e077b7c137
Reviewed-by: default avatarhjk <hjk@theqtcompany.com>
parent 36173e25
......@@ -83,9 +83,9 @@ static QString makeFrameName(const Frame &frame, const QString &relativeTo,
bool link = true, const QString &linkAttr = QString())
{
const QString d = frame.directory();
const QString f = frame.file();
const QString f = frame.fileName();
const QString fn = frame.functionName();
const QString fullPath = d + QLatin1Char('/') + f;
const QString fullPath = frame.filePath();
QString path;
if (!d.isEmpty() && !f.isEmpty())
......
......@@ -299,11 +299,11 @@ public:
//find the first frame belonging to the project
if (!m_projectFiles.isEmpty()) {
foreach (const Frame &frame, frames) {
if (frame.directory().isEmpty() || frame.file().isEmpty())
if (frame.directory().isEmpty() || frame.fileName().isEmpty())
continue;
//filepaths can contain "..", clean them:
const QString f = QFileInfo(frame.directory() + QLatin1Char('/') + frame.file()).absoluteFilePath();
const QString f = QFileInfo(frame.filePath()).absoluteFilePath();
if (m_projectFiles.contains(f))
return frame;
}
......
......@@ -238,8 +238,8 @@ QString Error::toXml() const
stream << " <fn>" << frame.functionName() << "</fn>\n";
if (!frame.directory().isEmpty())
stream << " <dir>" << frame.directory() << "</dir>\n";
if (!frame.file().isEmpty())
stream << " <file>" << frame.file() << "</file>\n";
if (!frame.fileName().isEmpty())
stream << " <file>" << frame.fileName() << "</file>\n";
if (frame.line() != -1)
stream << " <line>" << frame.line() << "</line>";
stream << " </frame>\n";
......
......@@ -111,16 +111,13 @@ Frame ErrorListModel::Private::findRelevantFrame(const Error &error) const
QString ErrorListModel::Private::formatAbsoluteFilePath(const Error &error) const
{
const Frame f = findRelevantFrame(error);
if (!f.directory().isEmpty() && !f.file().isEmpty())
return f.directory() + QLatin1Char('/') + f.file();
return QString();
return findRelevantFrame(error).filePath();
}
QString ErrorListModel::Private::formatLocation(const Error &error) const
{
const Frame frame = findRelevantFrame(error);
const QString file = frame.file();
const QString file = frame.fileName();
if (!frame.functionName().isEmpty())
return frame.functionName();
if (!file.isEmpty()) {
......@@ -185,7 +182,7 @@ QVariant ErrorListModel::Private::errorData(int row, int column, int role) const
case AbsoluteFilePathRole:
return formatAbsoluteFilePath(error);
case FileRole:
return findRelevantFrame(error).file();
return findRelevantFrame(error).fileName();
case LineRole: {
const qint64 line = findRelevantFrame(error).line();
return line > 0 ? line : QVariant();
......
......@@ -48,7 +48,7 @@ public:
return ip == other.ip
&& object == other.object
&& functionName == other.functionName
&& file == other.file
&& fileName == other.fileName
&& directory == other.directory
&& line == other.line;
}
......@@ -56,7 +56,7 @@ public:
quint64 ip;
QString object;
QString functionName;
QString file;
QString fileName;
QString directory;
int line;
};
......@@ -126,14 +126,14 @@ void Frame::setFunctionName(const QString &functionName)
d->functionName = functionName;
}
QString Frame::file() const
QString Frame::fileName() const
{
return d->file;
return d->fileName;
}
void Frame::setFile(const QString &file)
void Frame::setFileName(const QString &file)
{
d->file = file;
d->fileName = file;
}
QString Frame::directory() const
......@@ -146,6 +146,14 @@ void Frame::setDirectory(const QString &directory)
d->directory = directory;
}
QString Frame::filePath() const
{
QString f;
if (!directory().isEmpty())
f.append(directory()).append(QLatin1Char('/'));
return f.append(fileName());
}
int Frame::line() const
{
return d->line;
......
......@@ -59,12 +59,14 @@ public:
QString functionName() const;
void setFunctionName(const QString &functionName);
QString file() const;
void setFile(const QString &file);
QString fileName() const;
void setFileName(const QString &fileName);
QString directory() const;
void setDirectory(const QString &directory);
QString filePath() const;
int line() const;
void setLine(int line);
......
......@@ -43,8 +43,8 @@ namespace XmlProtocol {
QString toolTipForFrame(const Frame &frame)
{
QString location;
if (!frame.file().isEmpty()) {
location = frame.directory() + QLatin1Char('/') + frame.file();
if (!frame.fileName().isEmpty()) {
location = frame.filePath();
if (frame.line() > 0)
location += QLatin1Char(':') + QString::number(frame.line());
}
......
......@@ -517,7 +517,7 @@ Frame Parser::Private::parseFrame()
else if (name == QLatin1String("dir"))
frame.setDirectory(blockingReadElementText());
else if (name == QLatin1String("file"))
frame.setFile( blockingReadElementText());
frame.setFileName(blockingReadElementText());
else if (name == QLatin1String("line"))
frame.setLine(parseInt64(blockingReadElementText(), QLatin1String("error/frame/line")));
else if (reader.isStartElement())
......
......@@ -60,7 +60,7 @@ public:
static QString makeName(const Frame &frame)
{
const QString d = frame.directory();
const QString f = frame.file();
const QString f = frame.fileName();
const QString fn = frame.functionName();
if (!fn.isEmpty())
return fn;
......@@ -123,7 +123,7 @@ QVariant StackModel::data(const QModelIndex &index, int role) const
case DirectoryColumn:
return frame.directory();
case FileColumn:
return frame.file();
return frame.fileName();
case LineColumn:
if (frame.line() > 0)
return frame.line();
......@@ -139,7 +139,7 @@ QVariant StackModel::data(const QModelIndex &index, int role) const
case FunctionNameRole:
return frame.functionName();
case FileRole:
return frame.file();
return frame.fileName();
case DirectoryRole:
return frame.directory();
case LineRole:
......
......@@ -70,7 +70,7 @@ QT_END_NAMESPACE
void dumpFrame(const Frame &f)
{
qDebug() << f.instructionPointer() << f.directory() << f.file() << f.functionName()
qDebug() << f.instructionPointer() << f.directory() << f.fileName() << f.functionName()
<< f.line() << f.object();
}
......@@ -168,14 +168,14 @@ void ParserTests::testHelgrindSample1()
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.setFileName(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.setFileName(QLatin1String("qmutex.h"));
frame12.setLine(120);
stack1.setFrames(QVector<Frame>() << frame11 << frame12);
......@@ -186,14 +186,14 @@ void ParserTests::testHelgrindSample1()
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.setFileName(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.setFileName(QLatin1String("qmutex.h"));
frame22.setLine(121);
stack2.setFrames(QVector<Frame>() << frame21 << frame22);
......@@ -204,14 +204,14 @@ void ParserTests::testHelgrindSample1()
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.setFileName(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.setFileName(QLatin1String("qmutex.h"));
frame32.setLine(122);
stack3.setFrames(QVector<Frame>() << frame31 << frame32);
......@@ -260,7 +260,7 @@ void ParserTests::testMemcheckSample1()
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.setFileName(QLatin1String("qframe.cpp"));
f1.setLine(252);
Frame f2;
f2.setInstructionPointer(0x118F2AF7);
......@@ -270,13 +270,13 @@ void ParserTests::testMemcheckSample1()
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.setFileName(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.setFileName(QLatin1String("qapplication.cpp"));
f4.setFunctionName(QLatin1String("QApplicationPrivate::notify_helper(QObject*, QEvent*)"));
f4.setLine(4396);
Stack s1;
......
......@@ -180,7 +180,7 @@ void TestRunner::testLeak1()
QCOMPARE(frame.line(), 5 + HEADER_LENGTH);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(frame.fileName(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDirForApp("leak1"));
}
}
......@@ -214,7 +214,7 @@ void TestRunner::testLeak2()
QCOMPARE(frame.line(), 7 + HEADER_LENGTH);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(frame.fileName(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDirForApp("leak2"));
} else {
QCOMPARE(frame.functionName(), QLatin1String("(below main)"));
......@@ -252,7 +252,7 @@ void TestRunner::testLeak3()
QCOMPARE(frame.line(), 7 + HEADER_LENGTH);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(frame.fileName(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDirForApp("leak3"));
} else {
QCOMPARE(frame.functionName(), QLatin1String("(below main)"));
......@@ -293,7 +293,7 @@ void TestRunner::testLeak4()
QCOMPARE(frame.line(), 6 + HEADER_LENGTH);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(frame.fileName(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDir);
}
{
......@@ -302,7 +302,7 @@ void TestRunner::testLeak4()
QCOMPARE(frame.line(), 14 + HEADER_LENGTH);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(frame.fileName(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDir);
}
}
......@@ -332,7 +332,7 @@ void TestRunner::testLeak4()
QCOMPARE(frame.line(), 14 + HEADER_LENGTH);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(frame.fileName(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDir);
}
}
......@@ -361,7 +361,7 @@ void TestRunner::uninit1()
QCOMPARE(frame.line(), 4 + HEADER_LENGTH);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(frame.fileName(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDir);
}
//BEGIN second stack
......@@ -375,7 +375,7 @@ void TestRunner::uninit1()
QCOMPARE(frame.line(), 2 + HEADER_LENGTH);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(frame.fileName(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDir);
}
}
......@@ -406,7 +406,7 @@ void TestRunner::uninit2()
QCOMPARE(frame.line(), 4 + HEADER_LENGTH);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(frame.fileName(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDir);
}
//BEGIN second stack
......@@ -420,7 +420,7 @@ void TestRunner::uninit2()
QCOMPARE(frame.line(), 2 + HEADER_LENGTH);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(frame.fileName(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDir);
}
}
......@@ -439,7 +439,7 @@ void TestRunner::uninit2()
QCOMPARE(frame.line(), 4 + HEADER_LENGTH);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(frame.fileName(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDir);
}
}
......@@ -470,7 +470,7 @@ void TestRunner::uninit3()
QCOMPARE(frame.line(), 4 + HEADER_LENGTH);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(frame.fileName(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDir);
}
//BEGIN second stack
......@@ -484,7 +484,7 @@ void TestRunner::uninit3()
QCOMPARE(frame.line(), 2 + HEADER_LENGTH);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(frame.fileName(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDir);
}
}
......@@ -503,7 +503,7 @@ void TestRunner::uninit3()
QCOMPARE(frame.line(), 4 + HEADER_LENGTH);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(frame.fileName(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDir);
}
}
......@@ -562,7 +562,7 @@ void TestRunner::syscall()
QCOMPARE(frame.line(), 2 + HEADER_LENGTH);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(frame.fileName(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDir);
}
}
......@@ -595,7 +595,7 @@ void TestRunner::free1()
QCOMPARE(frame.line(), 7 + HEADER_LENGTH);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(frame.fileName(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDir);
}
}
......@@ -615,7 +615,7 @@ void TestRunner::free1()
QCOMPARE(frame.line(), 6 + HEADER_LENGTH);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(frame.fileName(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDir);
}
}
......@@ -649,7 +649,7 @@ void TestRunner::free2()
QCOMPARE(frame.line(), 6 + HEADER_LENGTH);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(frame.fileName(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDir);
}
}
......@@ -673,7 +673,7 @@ void TestRunner::free2()
QCOMPARE(frame.line(), 5 + HEADER_LENGTH);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(frame.fileName(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDir);
}
}
......@@ -733,7 +733,7 @@ void TestRunner::overlap()
QCOMPARE(frame.line(), 6 + HEADER_LENGTH);
QCOMPARE(frame.object(), binary);
QCOMPARE(frame.file(), QLatin1String("main.cpp"));
QCOMPARE(frame.fileName(), QLatin1String("main.cpp"));
QCOMPARE(QDir::cleanPath(frame.directory()), srcDir);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment