Skip to content

Commit

Permalink
Merge pull request Ericsson#1941 from rnkovacs/debug-scripts
Browse files Browse the repository at this point in the history
Use compiler_info.json file in debug scripts
  • Loading branch information
gyorb authored Apr 9, 2019
2 parents b1c5a8e + 9e12f11 commit 3521295
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 58 deletions.
7 changes: 7 additions & 0 deletions scripts/debug_tools/failure_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import json
import os
import re
import subprocess


Expand Down Expand Up @@ -40,6 +41,12 @@ def change_paths(string, pathModifierFun):
# Note, this supports only POSIX paths.
if string[i] == '/':
path, path_end = find_path_end(string, i)
# Make sure that the prospective output folder exists.
pattern = re.compile(r'[\s\S]*-o *\Z')
if pattern.match(string[:i]):
out_dir = "./sources-root" + os.path.dirname(path)
if not os.path.isdir(out_dir):
os.mkdir(out_dir)
path = pathModifierFun(path)
result += path
i = path_end - 1
Expand Down
23 changes: 6 additions & 17 deletions scripts/debug_tools/prepare_all_cmd_for_ctu.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
import subprocess

import prepare_compile_cmd
import prepare_compiler_includes
import prepare_compiler_target
import prepare_compiler_info
import prepare_analyzer_cmd


Expand Down Expand Up @@ -84,29 +83,19 @@ def get_triple_arch(analyze_command_file):
args.sources_root),
indent=4))

compiler_includes_debug = "compiler_includes_DEBUG.json"
with open(compiler_includes_debug, 'w') as f:
compiler_info_debug = "compiler_info_DEBUG.json"
with open(compiler_info_debug, 'w') as f:
f.write(
json.dumps(
prepare_compiler_includes.prepare(
os.path.join(args.report_dir, "compiler_includes.json"),
args.sources_root),
indent=4))

compiler_target_debug = "compiler_target_DEBUG.json"
with open(compiler_target_debug, 'wb') as f:
f.write(
json.dumps(
prepare_compiler_target.prepare(
os.path.join(args.report_dir, "compiler_target.json"),
prepare_compiler_info.prepare(
os.path.join(args.report_dir, "compiler_info.json"),
args.sources_root),
indent=4))

# ctu-collect
out = execute(["CodeChecker", "analyze", "--ctu-collect",
compile_cmd_debug,
"--compiler-includes-file", compiler_includes_debug,
"--compiler-target-file", compiler_target_debug,
"--compiler-info-file", compiler_info_debug,
"-o", "report_debug",
"--verbose", "debug"])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,46 @@
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
# -------------------------------------------------------------------------

from __future__ import print_function
from __future__ import division
from __future__ import absolute_import

import argparse
import json
import os

import failure_lib as lib


def prepare(compiler_includes_file, sources_root):
json_data = lib.load_json_file(compiler_includes_file)
new_json_data = dict()
def prepare(compiler_info_file, sources_root):
json_data = lib.load_json_file(compiler_info_file)
sources_root_abs = os.path.abspath(sources_root)
for key, value in json_data.items():
lines = value.split("\n")
new_json_data = dict()
for compiler in json_data:
lines = json_data[compiler]['includes']
changed_lines = []
for line in lines:
changed_lines.append(
lib.change_paths(line,
lib.IncludePathModifier(sources_root_abs)))
new_json_data[key] = "\n".join(changed_lines)
new_json_data[compiler] = {
'includes': changed_lines,
'target': json_data[compiler]['target'],
'default_standard': json_data[compiler]['default_standard']
}
return new_json_data


if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Prepare compiler includes '
parser = argparse.ArgumentParser(description='Prepare compiler info '
'json to execute in local environmennt.')
parser.add_argument('compiler_includes_file')
parser.add_argument('compiler_info_file')
parser.add_argument('--sources_root', default='./sources-root')
args = parser.parse_args()

print(
json.dumps(
prepare(
args.compiler_includes_file,
args.compiler_info_file,
args.sources_root)))
32 changes: 0 additions & 32 deletions scripts/debug_tools/prepare_compiler_target.py

This file was deleted.

0 comments on commit 3521295

Please sign in to comment.