Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from typing import Optional

from codechecker_report_converter.report.parser.base import AnalyzerInfo
from codechecker_report_converter.report import report_file
from codechecker_report_converter.report import report_file, error_file
from codechecker_report_converter.report.hash import get_report_hash, HashType
from codechecker_common.logger import get_logger
from codechecker_common.skiplist_handler import SkipListHandlers
Expand Down Expand Up @@ -43,6 +43,11 @@ def postprocess_result(
Generate analyzer result output file which can be parsed and stored
into the database.
"""
error_file.update(
self.analyzer_result_file, self.analyzer_returncode,
self.analyzer_info, self.analyzer_cmd,
self.analyzer_stdout, self.analyzer_stderr)

if os.path.exists(self.analyzer_result_file):
reports = report_file.get_reports(
self.analyzer_result_file, self.checker_labels,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
AnalyzerResult
from codechecker_report_converter.analyzers.clang_tidy.parser import Parser
from codechecker_report_converter.report.parser.base import AnalyzerInfo
from codechecker_report_converter.report import report_file
from codechecker_report_converter.report import report_file, error_file
from codechecker_report_converter.report.hash import get_report_hash, HashType

from codechecker_common.logger import get_logger
Expand Down Expand Up @@ -76,3 +76,8 @@ def postprocess_result(
report_file.create(
self.analyzer_result_file, reports, self.checker_labels,
self.analyzer_info)

error_file.update(
self.analyzer_result_file, self.analyzer_returncode,
self.analyzer_info, self.analyzer_cmd,
self.analyzer_stdout, self.analyzer_stderr)
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from codechecker_report_converter.analyzers.cppcheck.analyzer_result import \
AnalyzerResult
from codechecker_report_converter.report import BugPathEvent, \
Range, report_file
Range, report_file, error_file
from codechecker_report_converter.report.hash import get_report_hash, HashType

from codechecker_common.logger import get_logger
Expand Down Expand Up @@ -95,3 +95,8 @@ def postprocess_result(
report_file.create(
self.analyzer_result_file, reports, self.checker_labels,
self.analyzer_info)

error_file.update(
self.analyzer_result_file, self.analyzer_returncode,
self.analyzer_info, self.analyzer_cmd,
self.analyzer_stdout, self.analyzer_stderr)
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from codechecker_report_converter.report.parser.base import AnalyzerInfo
from codechecker_report_converter.analyzers.gcc.analyzer_result import \
AnalyzerResult
from codechecker_report_converter.report import report_file
from codechecker_report_converter.report import report_file, error_file
from codechecker_report_converter.report.hash import get_report_hash, HashType

from codechecker_common.logger import get_logger
Expand Down Expand Up @@ -118,3 +118,8 @@ def postprocess_result(
report_file.create(
self.analyzer_result_file, reports, self.checker_labels,
self.analyzer_info)

error_file.update(
self.analyzer_result_file, self.analyzer_returncode,
self.analyzer_info, self.analyzer_cmd,
self.analyzer_stdout, self.analyzer_stderr)
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from codechecker_report_converter.report.parser.base import AnalyzerInfo
from codechecker_report_converter.analyzers.infer.analyzer_result import \
AnalyzerResult
from codechecker_report_converter.report import report_file
from codechecker_report_converter.report import report_file, error_file
from codechecker_report_converter.report.hash import get_report_hash, HashType

from codechecker_common.logger import get_logger
Expand Down Expand Up @@ -74,4 +74,9 @@ def postprocess_result(
self.analyzer_result_file, reports, self.checker_labels,
self.analyzer_info)

error_file.update(
self.analyzer_result_file, self.analyzer_returncode,
self.analyzer_info, self.analyzer_cmd,
self.analyzer_stdout, self.analyzer_stderr)

shutil.rmtree(Path(self.workspace, "infer", self.buildaction_hash))
42 changes: 4 additions & 38 deletions analyzer/codechecker_analyzer/analyzers/result_handler_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@
Result handlers to manage the output of the static analyzers.
"""

import hashlib
import os
import shlex

from abc import ABCMeta
from typing import Optional

from codechecker_analyzer import analyzer_context
from codechecker_analyzer.util import analyzer_action_hash
from codechecker_common.logger import get_logger
from codechecker_common.skiplist_handler import SkipListHandlers
from codechecker_common.review_status_handler import ReviewStatusHandler
Expand Down Expand Up @@ -99,43 +98,10 @@ def analyzer_action_str(self):
"""
analyzed_file_name = os.path.basename(self.analyzed_source_file)

source_file = os.path.normpath(
os.path.join(self.buildaction.directory,
self.analyzed_source_file))

# In case of "make 4.3" depending on compile-time options "make" tool
# can be built so a subprocess named cc1build will be logged by
# "CodeChecker log".
# See posix_spawn() option:
# https://lists.gnu.org/archive/html/info-gnu/2020-01/msg00004.html
# In this case the -o output argument of cc1build command is a randomly
# named temporary file. We can't afford dynamic parts in the original
# build command, because its hash is used for identification in the
# plist file name.
#
# The proper logging of this "make 4.3" version has been done in
# bf140d6, so it is unlikely happen that two build actions differ only
# in their "-o" flags. This workaround is still kept for any case.
#
# Note that some information loss occurs during the following algorithm
# because ' '.join(shlex.split(cmd)) is not necessarily equal to cmd:
# g++ -DVAR="hello world" main.cpp

args = shlex.split(self.buildaction.original_command)
indices = [idx for idx, v in enumerate(args) if v.startswith('-o')]

for idx in reversed(indices):
# Output can be given separate or joint:
# -o a.out vs. -oa.out
# In the first case we delete its argument too.
if args[idx] == '-o':
del args[idx]
del args[idx]

build_info = source_file + '_' + ' '.join(args)

self.buildaction_hash = \
hashlib.md5(build_info.encode(errors='ignore')).hexdigest()
analyzer_action_hash(self.analyzed_source_file,
self.buildaction.directory,
self.buildaction.original_command)

return analyzed_file_name + '_' + \
str(self.buildaction.analyzer_type) + '_' + \
Expand Down
Loading
Loading