Skip to content

Commit

Permalink
Use arch of the analizer machine instead of the original one.
Browse files Browse the repository at this point in the history
When creating the content of the ctu-dir the target architecture was
used to which compilation happened. If the analysis runs on a different
architecture (e.g. for debugging reasons) then the analyzer can't find
the necessary files of which the paths are named after the architecture.
  • Loading branch information
bruntib committed Jan 22, 2018
1 parent 58caed9 commit f8f79d8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
5 changes: 2 additions & 3 deletions libcodechecker/analyze/ctu_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import glob
import multiprocessing
import os
import platform
import shutil
import signal
import sys
Expand Down Expand Up @@ -196,9 +197,7 @@ def collect_build_action(params):
analyzer_environment = analyzer_env.get_check_env(
context.path_env_extra,
context.ld_lib_path_extra)
triple_arch = ctu_triple_arch.get_triple_arch(action, source,
config,
analyzer_environment)
triple_arch = platform.machine()
if not config.ctu_in_memory:
generate_ast(triple_arch, action, source, config,
analyzer_environment)
Expand Down
16 changes: 15 additions & 1 deletion scripts/debug_tools/prepare_all_cmd_for_ctu.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import argparse
import json
import os
import platform
import subprocess

import prepare_compile_cmd
Expand Down Expand Up @@ -35,6 +36,18 @@ def execute(cmd):
raise


def get_triple_arch(analyze_command_file):
with open(analyze_command_file) as f:
cmd = f.readline()

cmd = cmd.split()
for flag in cmd:
if flag.startswith('--target='):
return flag[9:].split('-')[0] # 9 == len('--target=')

return platform.machine()


if __name__ == '__main__':
parser = argparse.ArgumentParser(
description='Prepare all commands '
Expand Down Expand Up @@ -95,6 +108,7 @@ def execute(cmd):
"--verbose", "debug"])

analyzer_command_debug = "analyzer-command_DEBUG"
target = get_triple_arch('./analyzer-command')
with open(analyzer_command_debug, 'w') as f:
f.write(
prepare_analyzer_cmd.prepare(
Expand All @@ -104,7 +118,7 @@ def execute(cmd):
args.clang,
args.clang_plugin_name,
args.clang_plugin_path,
"./report_debug/ctu-dir/x86_64")))
"./report_debug/ctu-dir/" + target)))

print(
"Preparation of files for debugging is done. "
Expand Down

0 comments on commit f8f79d8

Please sign in to comment.