Bug 354695 - Error parser doesn't parse assertions
Summary: Error parser doesn't parse assertions
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: Output Views (other bugs)
Version First Reported In: unspecified
Platform: Ubuntu Linux
: NOR wishlist
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
: 292745 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-11-01 15:58 UTC by Talin
Modified: 2016-01-06 18:26 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In: 5.0.0
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Talin 2015-11-01 15:58:01 UTC
The program I'm developing prints error messages on the console, with source file and line information, which Kdevelop is able to parse and turn into links. However, this is not true for errors resulting from calls to the standard C library macro "assert". These errors are of the form:

<program name>: <source file>:<line>: <message>

It seems like it should be fairly straightforward to extend the error parser to handle these kinds of errors.

Reproducible: Always

Steps to Reproduce:
Create a program that calls assert(false);

Actual Results:  
Assert error message is printed on the console but is not turned into an error link.

Expected Results:  
Assert message should be turned into an error link.
Comment 1 Milian Wolff 2015-11-14 16:40:41 UTC
The problem with this is that the cassert output contains short file names. What heuristic should we apply to find the correct file?

May need special code similar to what we have for cmake right now. Here's an initial patch to get this process started, but the test will fail as it cannot find the file. The test itself is probably wrong as it should test for some proper path, not just "test.cpp".

diff --git a/outputview/outputfilteringstrategies.cpp b/outputview/outputfilteringstrategies.cpp
index e44a121..41ebf88 100644
--- a/outputview/outputfilteringstrategies.cpp
+++ b/outputview/outputfilteringstrategies.cpp
@@ -379,7 +379,7 @@ FilteredItem NativeAppErrorFilterStrategy::actionInLine(const QString& line)
 
 FilteredItem NativeAppErrorFilterStrategy::errorInLine(const QString& line)
 {
-    static const ErrorFormat QT_APPLICATION_ERROR_FILTERS[] = {
+    static const ErrorFormat NATIVE_APPLICATION_ERROR_FILTERS[] = {
         // QObject::connect related errors, also see err_method_notfound() in qobject.cpp
         // QObject::connect: No such slot Foo::bar() in /foo/bar.cpp:313
         ErrorFormat(QStringLiteral("^QObject::connect: (?:No such|Parentheses expected,) (?:slot|signal) [^ ]* in (.*):([0-9]+)$"), 1, 2, -1),
@@ -396,7 +396,9 @@ FilteredItem NativeAppErrorFilterStrategy::errorInLine(const QString& line)
         // Do *not* catch:
         //    ...
         //    Loc: [Unknown file(0)]
-        ErrorFormat(QStringLiteral("^   Loc: \\[(.*)\\(([1-9][0-9]*)\\)\\]$"), 1, 2, -1)
+        ErrorFormat(QStringLiteral("^   Loc: \\[(.*)\\(([1-9][0-9]*)\\)\\]$"), 1, 2, -1),
+        // a.out: test.cpp:5: int main(): Assertion `false' failed.
+        ErrorFormat(QStringLiteral("^.+: (.+):([1-9][0-9]*): .*: Assertion `.*' failed\\.$"), 1, 2, -1),
     };
 
     return match(QT_APPLICATION_ERROR_FILTERS, line);
diff --git a/outputview/tests/test_filteringstrategy.cpp b/outputview/tests/test_filteringstrategy.cpp
index 3ce8d4c..c707e45 100644
--- a/outputview/tests/test_filteringstrategy.cpp
+++ b/outputview/tests/test_filteringstrategy.cpp
@@ -263,6 +263,10 @@ void TestFilteringStrategy::testNativeAppErrorFilterStrategy_data()
         << "QObject::connect: Parentheses expected, signal Foo::bar() in /foo/bar.cpp:313"
         << "/foo/bar.cpp"
         << 312 << 0 << FilteredItem::ErrorItem;
+    QTest::newRow("cassert")
+        << "a.out: test.cpp:5: int main(): Assertion `false' failed."
+        << "test.cpp"
+        << 5 << 0 << FilteredItem::ErrorItem;
     QTest::newRow("qt-assert")
         << "ASSERT: \"errors().isEmpty()\" in file /tmp/foo/bar.cpp, line 49"
         << "/tmp/foo/bar.cpp"
Comment 2 Milian Wolff 2016-01-05 09:20:29 UTC
*** Bug 292745 has been marked as a duplicate of this bug. ***
Comment 3 Kevin Funk 2016-01-06 18:26:11 UTC
Git commit 128cb1abc33b88e771741ba02a5f8f6ded31a5af by Kevin Funk.
Committed on 06/01/2016 at 18:23.
Pushed by kfunk into branch '5.0'.

[GCI] Parse runtime output of assert() message, make it clickable

Note: We can only handle absolute paths, I honestly think supporting
relative paths is out of scope. Too many (likely fragile) heuristics needed in
order to support this reliably.

Reviewers: #kdevelop

Subscribers: #kdevelop

Projects: #kdevelop

Differential Revision: https://phabricator.kde.org/D751
FIXED-IN: 5.0.0

M  +5    -3    outputview/outputfilteringstrategies.cpp
M  +4    -0    outputview/tests/test_filteringstrategy.cpp

http://commits.kde.org/kdevplatform/128cb1abc33b88e771741ba02a5f8f6ded31a5af