-
Notifications
You must be signed in to change notification settings - Fork 385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[report-converter] Sparse parser #3160
Conversation
b4ad7cd
to
6372ea6
Compare
sparse creates multi-line error messages, but this report-converter here does not parse those correctly. Please rework that. |
@bulwahn @csordasmarton So should we include that multi-line messages with the message of the original file? Because those lines to have a path,line and column number? |
Well, sparse has a very special syntax for its output... it would be best to just repair the sparse output to be more like clang-analyzer or clang-tidy, but for the time being, you need understand which lines belong to previous warning line and when a new warning line starts. You can have a look at Argert's implementation (he got that right). |
6372ea6
to
9118724
Compare
@csordasmarton @bulwahn I think I have made the required changes to recognize the multi-line comments Kindly have a look and let me know if any modifications are required. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some tiny little comments. The biggest one is to update the test case with a multiline warning. Otherwise LGTM!
tools/report-converter/codechecker_report_converter/sparse/output_parser.py
Outdated
Show resolved
Hide resolved
tools/report-converter/tests/unit/sparse_output_test_files/sample.out
Outdated
Show resolved
Hide resolved
9118724
to
45abc16
Compare
@csordasmarton Apologies for changing the approved code of the Parser. I noticed a bug while re-writing the test cases and hence decided to fix it. Kindly have a look at the modified code |
tools/report-converter/tests/unit/sparse_output_test_files/files/sample.h
Outdated
Show resolved
Hide resolved
tools/report-converter/tests/unit/sparse_output_test_files/files/sample.h
Outdated
Show resolved
Hide resolved
It is "its converter", not "it's converter" in the commit message header of the third commit. |
Review is done; I will start testing... |
45abc16
to
2b150c3
Compare
@csordasmarton Kindly have a look 😄 |
tools/report-converter/tests/unit/sparse_output_test_files/files/sample.c
Outdated
Show resolved
Hide resolved
tools/report-converter/codechecker_report_converter/sparse/output_parser.py
Outdated
Show resolved
Hide resolved
tools/report-converter/codechecker_report_converter/sparse/output_parser.py
Outdated
Show resolved
Hide resolved
tools/report-converter/codechecker_report_converter/sparse/output_parser.py
Outdated
Show resolved
Hide resolved
tools/report-converter/codechecker_report_converter/sparse/output_parser.py
Outdated
Show resolved
Hide resolved
tools/report-converter/codechecker_report_converter/sparse/output_parser.py
Outdated
Show resolved
Hide resolved
2b150c3
to
7c79b0d
Compare
@csordasmarton removing this and the above-mentioned regex was actually creating a separate Kindly have a look 😄 |
tools/report-converter/tests/unit/sparse_output_test_files/Makefile
Outdated
Show resolved
Hide resolved
tools/report-converter/codechecker_report_converter/sparse/output_parser.py
Outdated
Show resolved
Hide resolved
tools/report-converter/tests/unit/sparse_output_test_files/sample.out
Outdated
Show resolved
Hide resolved
r'(?P<message>[\S \t]+)\s*' | ||
) | ||
|
||
def parse_message(self, it, line): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to convert what the sample.out with the report-converter tool and then store the results to a running server. Now there is only one report with a lot of bug steps:
I don't think this is what you want.
In my previous comment (#3160 (comment)) my recommendation was the following:
- Every line which looks like this will be a new report (Message):
./files/sample.h:3:40: warning: incorrect type in argument 2 (different address spaces)
(thewarning
keyword identifies that we have a new report). - Every line which looks like this will be an event / bug step item of the previous Message object:
./files/sample.h:3:40: expected struct task_struct *p1
. (So it doesn't contain the warning keyword like in the previous case). - Every line can be skipped which looks like this
files/sample.c: note: in included file:
.
So in case of the following output:
files/sample.c:4:1: warning: symbol 'machine_id' was not declared. Should it be static?
files/sample.h:3:40: warning: incorrect type in argument 2 (different address spaces)
files/sample.c: note: in included file:
files/sample.h:3:40: warning: incorrect type in argument 1 (different address spaces)
files/sample.h:3:40: expected struct task_struct *p1
files/sample.h:3:40: got struct spinlock [noderef] __rcu *
I want to see 3 reports:
- files/sample.c:4:1: warning: symbol 'machine_id' was not declared. Should it be static?
- files/sample.h:3:40: warning: incorrect type in argument 2 (different address spaces)
- files/sample.h:3:40: warning: incorrect type in argument 1 (different address spaces)
files/sample.h:3:40: expected struct task_struct *p1
files/sample.h:3:40: got struct spinlock [noderef] __rcu *
In the third case the report will have multiple bug steps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to convert what the sample.out with the report-converter tool and then store the results to a running server. Now there is only one report with a lot of bug steps:
I don't think this is what you want.
Well Actually I thought that is what we wanted, a single report for all the files and hence changed the code to include it in the single report. 😢
In my previous comment (#3160 (comment)) my recommendation was the following:
- Every line which looks like this will be a new report (Message):
./files/sample.h:3:40: warning: incorrect type in argument 2 (different address spaces)
(thewarning
keyword identifies that we have a new report).
This logic won't always stand true as some lines also start with error
. Do you recommend modifying the regex as well now?
- Every line which looks like this will be an event / bug step item of the previous Message object:
./files/sample.h:3:40: expected struct task_struct *p1
. (So it doesn't contain the warning keyword like in the previous case).- Every line can be skipped which looks like this
files/sample.c: note: in included file:
.So in case of the following output:
files/sample.c:4:1: warning: symbol 'machine_id' was not declared. Should it be static? files/sample.h:3:40: warning: incorrect type in argument 2 (different address spaces) files/sample.c: note: in included file: files/sample.h:3:40: warning: incorrect type in argument 1 (different address spaces) files/sample.h:3:40: expected struct task_struct *p1 files/sample.h:3:40: got struct spinlock [noderef] __rcu *
I want to see 3 reports:
- files/sample.c:4:1: warning: symbol 'machine_id' was not declared. Should it be static?
- files/sample.h:3:40: warning: incorrect type in argument 2 (different address spaces)
- files/sample.h:3:40: warning: incorrect type in argument 1 (different address spaces)
files/sample.h:3:40: expected struct task_struct *p1
files/sample.h:3:40: got struct spinlock [noderef] __rcu *In the third case the report will have multiple bug steps.
Alright so in the tests, we will also have two sample.c.expected.plist
and sample.h.expected.plist
, this is after the assumption that second line in the sample.out
file is removed. Correct me if I am wrong
7c79b0d
to
3a5865e
Compare
@csordasmarton I think the current code solves the issues discussed above by us. Kindly have a look and let me know what you think |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have just 2 tiny comments, otherwise its LGTM!
tools/report-converter/codechecker_report_converter/sparse/output_parser.py
Outdated
Show resolved
Hide resolved
./files/sample.h:3:40: warning: incorrect type in argument 1 (different address spaces) | ||
./files/sample.h:3:40: expected struct task_struct *p1 | ||
./files/sample.h:3:40: got struct spinlock [noderef] __rcu * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my previous review comments I asked what is the reason that one line starts with ./
and the others are not (#3160 (comment)).
Now with the regexes we will identify every line which stars with ./
as notes and the others as reports. Are you sure that every note line will start with ./
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes as far as I have checked, all the note lines start with ./
3a5865e
to
cfe107d
Compare
- Sparse output is parsed and stored into the format: file:line:column:message - Parser is called from report converter CLI with type 'sparse'
- Sparse Parser is tested with sample.c, sample.h and sample.out files
- Sparse documentation in report converter explains the usage of sparse tool on kernel sources - Sparse is accessible from the main readme file and supported code analyzer file - Sparse updated in usage
cfe107d
to
eb42f47
Compare
@csordasmarton I have made the changes suggested by you! Kindly have a look😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you for your hard work 😊
Sparse report converter tool for parsing Sparse output of kernel sources