예제 #1
0
    def handle(self, *args, **options):
        do_gen_html = options.get('html', False)
        syms = SymbolManager(self.symbol_search_path())

        coverage = self._get_addr_coverage()
        for module_path, addr_counts in coverage.iteritems():
            try:
                cov = options.get('include_covered_files_only', False)
                file_line_info = syms.get_coverage(module_path, addr_counts,
                                                   cov)

                module = os.path.basename(module_path)

                # genhtml will throw an error if there are missing files, so we skip them
                # if the user enabled html reports.
                lcov_info_path = self._save_coverage_info(
                    module + '.info', file_line_info, do_gen_html)

                if do_gen_html:
                    lcov_html_dir = self._gen_html(module, lcov_info_path)
                    logger.info(
                        'Line coverage saved to %s. An HTML report is available in %s',
                        lcov_info_path, lcov_html_dir)

                logger.success('Line coverage saved to %s', lcov_info_path)

            except Exception as e:
                logger.error(e)
                continue
예제 #2
0
파일: lcov.py 프로젝트: S2E/s2e-env
    def handle(self, *args, **options):
        do_gen_html = options.get('html', False)
        syms = SymbolManager(self.install_path(), self.symbol_search_path)

        lcov_out_dir = options.get('lcov_out_dir')
        if not lcov_out_dir:
            lcov_out_dir = self.project_path('s2e-last')

        coverage = {}
        for directory in self._get_output_folders(**options):
            logger.info('Extracting coverage info from %s...', directory)
            _get_addr_coverage(directory, coverage)

        for module_path, addr_counts in coverage.items():
            try:
                cov = options.get('include_covered_files_only', False)
                file_line_info = syms.get_coverage(module_path, addr_counts,
                                                   cov)

                module = os.path.basename(module_path)

                # genhtml will throw an error if there are missing files, so we skip them
                # if the user enabled html reports.
                lcov_info_path = os.path.join(lcov_out_dir, module + '.info')
                _save_coverage_info(lcov_info_path, file_line_info,
                                    do_gen_html)

                logger.success('Line coverage saved to %s', lcov_info_path)

                if do_gen_html:
                    lcov_html_dir = os.path.join(lcov_out_dir,
                                                 f'{module}_lcov')
                    _gen_html(lcov_info_path, lcov_html_dir)
                    logger.success(
                        'An HTML report is available in %s/index.html',
                        lcov_html_dir)

            except Exception as e:
                logger.error(e)
                continue
예제 #3
0
파일: forkprofile.py 프로젝트: sung3r/KOOBE
    def handle(self, *args, **options):
        # Parse the ExecutionTracer.dat file(s) and generate an execution tree
        # for the given path IDs
        results_dir = self.project_path('s2e-last')
        execution_tree = parse_execution_tree(results_dir)
        if not execution_tree:
            raise CommandError('The execution trace is empty')

        syms = SymbolManager(self.install_path(), self.symbol_search_path)

        fp = ForkProfiler(execution_tree, syms)
        fp.get()
        fp.dump()