drkonqi: remove unused parsers methods

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-04-16 06:50:11 +03:00
parent d33efb938b
commit 81838c02f6
7 changed files with 4 additions and 192 deletions

View file

@ -63,19 +63,6 @@ QList<BacktraceLine> BacktraceParser::parsedBacktraceLines() const
return d ? d->m_linesList : QList<BacktraceLine>();
}
QString BacktraceParser::simplifiedBacktrace() const
{
Q_D(const BacktraceParser);
//if there is no cached usefulness, the data calculation function has not run yet.
if (d && d->m_usefulness == InvalidUsefulness) {
const_cast<BacktraceParser*>(this)->calculateRatingData();
}
//if there is no d, the debugger has not run yet, so we have no backtrace.
return d ? d->m_simplifiedBacktrace : QString();
}
BacktraceParser::Usefulness BacktraceParser::backtraceUsefulness() const
{
Q_D(const BacktraceParser);
@ -90,20 +77,6 @@ BacktraceParser::Usefulness BacktraceParser::backtraceUsefulness() const
return d ? d->m_usefulness : Useless;
}
QStringList BacktraceParser::firstValidFunctions() const
{
Q_D(const BacktraceParser);
//if there is no cached usefulness, the data calculation function has not run yet.
if (d && d->m_usefulness == InvalidUsefulness) {
const_cast<BacktraceParser*>(this)->calculateRatingData();
}
//if there is no d, the debugger has not run yet, so we have no functions to return.
return d ? d->m_firstUsefulFunctions : QStringList();
}
QSet<QString> BacktraceParser::librariesWithMissingDebugSymbols() const
{
Q_D(const BacktraceParser);
@ -126,7 +99,7 @@ void BacktraceParser::resetState()
BacktraceParserPrivate *BacktraceParser::constructPrivate() const
{
return new BacktraceParserPrivate;
return new BacktraceParserPrivate();
}
@ -203,82 +176,6 @@ static bool lineShouldBeIgnored(const BacktraceLine & line)
return false;
}
static bool isFunctionUseful(const BacktraceLine & line)
{
//We need the function name
if ( line.rating() == BacktraceLine::MissingEverything
|| line.rating() == BacktraceLine::MissingFunction ) {
return false;
}
//Misc ignores
if ( line.functionName() == "__kernel_vsyscall"
|| line.functionName() == "raise"
|| line.functionName() == "abort"
|| line.functionName() == "__libc_message"
|| line.functionName() == "thr_kill" /* *BSD */) {
return false;
}
//Ignore core Qt functions
//(QObject can be useful in some cases)
if ( line.functionName().startsWith(QLatin1String("QBasicAtomicInt::"))
|| line.functionName().startsWith(QLatin1String("QBasicAtomicPointer::"))
|| line.functionName().startsWith(QLatin1String("QAtomicInt::"))
|| line.functionName().startsWith(QLatin1String("QAtomicPointer::"))
|| line.functionName().startsWith(QLatin1String("QMetaObject::"))
|| line.functionName().startsWith(QLatin1String("QPointer::"))
|| line.functionName().startsWith(QLatin1String("QWeakPointer::"))
|| line.functionName().startsWith(QLatin1String("QSharedPointer::"))
|| line.functionName().startsWith(QLatin1String("QScopedPointer::"))
|| line.functionName().startsWith(QLatin1String("QMetaCallEvent::")) ) {
return false;
}
//Ignore core Qt containers misc functions
if ( line.functionName().endsWith(QLatin1String("detach"))
|| line.functionName().endsWith(QLatin1String("detach_helper"))
|| line.functionName().endsWith(QLatin1String("node_create"))
|| line.functionName().endsWith(QLatin1String("deref"))
|| line.functionName().endsWith(QLatin1String("ref"))
|| line.functionName().endsWith(QLatin1String("node_copy"))
|| line.functionName().endsWith(QLatin1String("d_func")) ) {
return false;
}
//Misc Qt stuff
if ( line.functionName() == "qt_message_output"
|| line.functionName() == "qt_message"
|| line.functionName() == "qFatal"
|| line.functionName().startsWith(QLatin1String("qGetPtrHelper"))
|| line.functionName().startsWith(QLatin1String("qt_meta_")) ) {
return false;
}
return true;
}
static bool isFunctionUsefulForSearch(const BacktraceLine & line)
{
//Ignore Qt containers (and iterators Q*Iterator)
if ( line.functionName().startsWith(QLatin1String("QList"))
|| line.functionName().startsWith(QLatin1String("QLinkedList"))
|| line.functionName().startsWith(QLatin1String("QVector"))
|| line.functionName().startsWith(QLatin1String("QStack"))
|| line.functionName().startsWith(QLatin1String("QQueue"))
|| line.functionName().startsWith(QLatin1String("QSet"))
|| line.functionName().startsWith(QLatin1String("QMap"))
|| line.functionName().startsWith(QLatin1String("QMultiMap"))
|| line.functionName().startsWith(QLatin1String("QMapData"))
|| line.functionName().startsWith(QLatin1String("QHash"))
|| line.functionName().startsWith(QLatin1String("QMultiHash"))
|| line.functionName().startsWith(QLatin1String("QHashData")) ) {
return false;
}
return true;
}
void BacktraceParser::calculateRatingData()
{
Q_D(BacktraceParser);
@ -323,41 +220,6 @@ void BacktraceParser::calculateRatingData()
kDebug() << line.rating() << line.toString();
}
//Generate a simplified backtrace
//- Starts from the first useful function
//- Max of 5 lines
//- Replaces garbage with [...]
//At the same time, grab the first three useful functions for search queries
i.toFront(); //Reuse the list iterator
int functionIndex = 0;
int usefulFunctionsCount = 0;
bool firstUsefulFound = false;
while( i.hasNext() && functionIndex < 5 ) {
const BacktraceLine & line = i.next();
if ( !lineShouldBeIgnored(line) && isFunctionUseful(line) ) { //Line is not garbage to use
if (!firstUsefulFound) {
firstUsefulFound = true;
}
//Save simplified backtrace line
d->m_simplifiedBacktrace += line.toString();
//Fetch three useful functions (only functionName) for search queries
if (usefulFunctionsCount < 3 && isFunctionUsefulForSearch(line) &&
!d->m_firstUsefulFunctions.contains(line.functionName())) {
d->m_firstUsefulFunctions.append(line.functionName());
usefulFunctionsCount++;
}
functionIndex++;
} else if (firstUsefulFound) {
//Add "[...]" if there are invalid functions in the middle
if (!d->m_simplifiedBacktrace.endsWith(QLatin1String("[...]\n"))) {
d->m_simplifiedBacktrace += QLatin1String("[...]\n");
}
}
}
//calculate rating
d->m_usefulness = Useless;
if (rating >= (bestPossibleRating*0.90)) {

View file

@ -49,21 +49,9 @@ public:
*/
virtual QList<BacktraceLine> parsedBacktraceLines() const;
/*! Returns a simplified version of the backtrace. This backtrace:
* \li Starts from the first useful function
* \li Has maximum 5 lines
* \li Replaces garbage with [...]
*/
virtual QString simplifiedBacktrace() const;
/*! Returns a value that indicates how much useful is the backtrace that we got */
virtual Usefulness backtraceUsefulness() const;
/*! Returns a short list of the first good functions that appear in the backtrace
* (in the crashing thread). This is used for quering for duplicate reports.
*/
virtual QStringList firstValidFunctions() const;
/*! Returns a list of libraries/executables that are missing debug symbols. */
virtual QSet<QString> librariesWithMissingDebugSymbols() const;
@ -84,10 +72,9 @@ protected:
/*! Subclasses should override to provide their own BacktraceParserPrivate instance */
virtual BacktraceParserPrivate *constructPrivate() const;
/*! This method should fill the m_usefulness, m_simplifiedBacktrace, m_firstValidFunctions
* and m_librariesWithMissingDebugSymbols members of the BacktraceParserPrivate instance.
* The default implementation uses the lines inserted in m_linesToRate and applies a
* generic algorithm that should work for many debuggers.
/*! This method should fill the m_usefulness and m_librariesWithMissingDebugSymbols members of
* the BacktraceParserPrivate instance. The default implementation uses the lines inserted in
* m_linesToRate and applies a generic algorithm that should work for many debuggers.
*/
virtual void calculateRatingData();

View file

@ -28,8 +28,6 @@ public:
QList<BacktraceLine> m_linesList;
QList<BacktraceLine> m_linesToRate;
QStringList m_firstUsefulFunctions;
QString m_simplifiedBacktrace;
QSet<QString> m_librariesWithMissingDebugSymbols;
BacktraceParser::Usefulness m_usefulness;
};

View file

@ -80,27 +80,6 @@ void BacktraceParserTest::btParserUsefulnessTest()
QCOMPARE(btUsefulness, result);
}
void BacktraceParserTest::btParserFunctionsTest_data()
{
fetchData("firstValidFunctions");
}
void BacktraceParserTest::btParserFunctionsTest()
{
QFETCH(QString, filename);
QFETCH(QString, result);
QFETCH(QString, debugger);
//parse
QSharedPointer<BacktraceParser> parser(BacktraceParser::newParser(debugger));
parser->connectToGenerator(m_generator);
m_generator->sendData(filename);
//compare
QString functions = parser->firstValidFunctions().join("|");
QCOMPARE(functions, result);
}
void BacktraceParserTest::btParserBenchmark_data()
{
QTest::addColumn<QString>("filename");

View file

@ -32,8 +32,6 @@ public:
private slots:
void btParserUsefulnessTest_data();
void btParserUsefulnessTest();
void btParserFunctionsTest_data();
void btParserFunctionsTest();
void btParserBenchmark_data();
void btParserBenchmark();

View file

@ -13,16 +13,6 @@ test_bug192412_b=Useless
test_bug168000=MayBeUseful
test_bug200993=ReallyUseful
[firstValidFunctions]
test_usefulfunctions=SqlQueryMaker::handleTracks|SqlQueryMaker::handleResult|SqlWorkerThread::run
test_usefulfunctions2=Digikam::Album::removeExtraData|~TreeAlbumItem|~TreeAlbumCheckListItem
;should qt_assert appear here??
test_usefulfunctions3=qt_assert|ExceptionGuard|QMenuPrivate::activateCausedStack
test_usefulfunctions4=KarbonPart::addShape|KoShapeDeleteCommand::undo|QUndoCommand::undo
test_usefulfunctions5=qt_assert|KMetaDataWidget::Private::slotLoadingFinished|KMetaDataWidget::qt_metacall
test_trailing_const=QString::operator==|qStringComparisonHelper|QString::operator!=
test_anon_namespace=formatICalInvitationHelper|KCal::IncidenceFormatter::formatICalInvitationNoHtml|(anonymous namespace)::Formatter::format
[debugger]
test_a=gdb
test_b=gdb

View file

@ -56,8 +56,6 @@ int main(int argc, char **argv)
QMetaEnum metaUsefulness = BacktraceParser::staticMetaObject.enumerator(
BacktraceParser::staticMetaObject.indexOfEnumerator("Usefulness"));
QTextStream(stdout) << "Usefulness: " << metaUsefulness.valueToKey(parser->backtraceUsefulness()) << endl;
QTextStream(stdout) << "First valid functions: " << parser->firstValidFunctions().join(" ") << endl;
QTextStream(stdout) << "Simplified backtrace:\n" << parser->simplifiedBacktrace() << endl;
QStringList l = static_cast<QStringList>(parser->librariesWithMissingDebugSymbols().toList());
QTextStream(stdout) << "Missing dbgsym libs: " << l.join(" ") << endl;