Commit dd180bb4 authored by Harald Sitter's avatar Harald Sitter 🌹
Browse files

further constrict line parsing of .so files

Summary:
As seen in https://bugs.kde.org/show_bug.cgi?id=417435 the previous fix
for .so detection actually falls flat on the face for most things
other than glib2. The original test here was flawed as libglib-2.0.so.0
has the complete suffix '0.so.0' which matched the original parsing
condition. most libraries however are libfoo.so.0 and for that the suffix
would be 'so.0' which did not match the original condition.

extend the condition to properly cover files without so-version, files with
awkward suffix (such as glib) and files with normal names and normal
versioning.
also extend test case accordingly

CCBUG: 418538

Test Plan: test passes. all lines from 417435 score less than `Good`

Reviewers: cfeck, ngraham

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D28026
parent e4c22f0b
......@@ -77,7 +77,11 @@ void BacktraceLineGdb::parse()
// sometimes the stack can resolve to a library even when it uses the 'at' key word.
// This specifically seems to happen when a frame has no function name.
const QString path = regExp.cap(9);
file = file && !QFileInfo(path).completeSuffix().contains(QLatin1String(".so"));
const auto completeSuffix = QFileInfo(path).completeSuffix();
file = file
&& completeSuffix != QLatin1String("so") /* libf.so (so) */
&& !completeSuffix.startsWith(QLatin1String("so.")) /* libf.so.1 (so.1) */
&& !completeSuffix.contains(QLatin1String(".so") /* libf-1.0.so.1 (0.so.1)*/);
if (file) {
d->m_file = regExp.cap(9);
} else { //'from' means we have a library
......
......@@ -65,13 +65,43 @@ private Q_SLOTS:
// couldn't deal with the function name being missing entirely.
// As a result this line used to rate as 'Good' -.-
// https://bugs.kde.org/show_bug.cgi?id=416923
BacktraceLineGdb line("#13 0x00007fe6059971b1 in () at /usr/lib/libglib-2.0.so.0\n");
QCOMPARE(line.type(), BacktraceLine::StackFrame);
QCOMPARE(line.frameNumber(), 13);
QCOMPARE(line.functionName(), "");
QCOMPARE(line.fileName(), "");
QCOMPARE(line.libraryName(), "/usr/lib/libglib-2.0.so.0");
QCOMPARE(line.rating(), BacktraceLine::MissingSourceFile);
// https://bugs.kde.org/show_bug.cgi?id=418538
{ // glib
BacktraceLineGdb line("#13 0x00007fe6059971b1 in () at /usr/lib/libglib-2.0.so.0\n");
QCOMPARE(line.type(), BacktraceLine::StackFrame);
QCOMPARE(line.frameNumber(), 13);
QCOMPARE(line.functionName(), "");
QCOMPARE(line.fileName(), "");
QCOMPARE(line.libraryName(), "/usr/lib/libglib-2.0.so.0");
QCOMPARE(line.rating(), BacktraceLine::MissingSourceFile);
}
{ // library without -2.0 (trips up suffix detection)
BacktraceLineGdb line("#13 0x00007fe6059971b1 in () at /usr/lib/libpackagekit-qt.so.12\n");
QCOMPARE(line.type(), BacktraceLine::StackFrame);
QCOMPARE(line.frameNumber(), 13);
QCOMPARE(line.functionName(), "");
QCOMPARE(line.fileName(), "");
QCOMPARE(line.libraryName(), "/usr/lib/libpackagekit-qt.so.12");
QCOMPARE(line.rating(), BacktraceLine::MissingSourceFile);
}
{ // library without any soversion
BacktraceLineGdb line("#13 0x00007fe6059971b1 in () at /usr/lib/libpackagekit-qt.so\n");
QCOMPARE(line.type(), BacktraceLine::StackFrame);
QCOMPARE(line.frameNumber(), 13);
QCOMPARE(line.functionName(), "");
QCOMPARE(line.fileName(), "");
QCOMPARE(line.libraryName(), "/usr/lib/libpackagekit-qt.so");
QCOMPARE(line.rating(), BacktraceLine::MissingSourceFile);
}
{ // library without any soversion but name suffix
BacktraceLineGdb line("#13 0x00007fe6059971b1 in () at /usr/lib/libpackagekit-1.0.so\n");
QCOMPARE(line.type(), BacktraceLine::StackFrame);
QCOMPARE(line.frameNumber(), 13);
QCOMPARE(line.functionName(), "");
QCOMPARE(line.fileName(), "");
QCOMPARE(line.libraryName(), "/usr/lib/libpackagekit-1.0.so");
QCOMPARE(line.rating(), BacktraceLine::MissingSourceFile);
}
}
void testOnlyFunctionNofile()
......
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