From 018b26a4efe23734309df839cb71a4c96f6f014f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sat, 26 Dec 2020 17:59:19 +0100 Subject: [PATCH] donate_cpu_lib.py: fixed some cases with missing error information / cleanups (#2982) --- tools/donate_cpu_lib.py | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/tools/donate_cpu_lib.py b/tools/donate_cpu_lib.py index a1d86dd22..5110c6f88 100644 --- a/tools/donate_cpu_lib.py +++ b/tools/donate_cpu_lib.py @@ -15,7 +15,7 @@ import shlex # Version scheme (MAJOR.MINOR.PATCH) should orientate on "Semantic Versioning" https://semver.org/ # Every change in this script should result in increasing the version number accordingly (exceptions may be cosmetic # changes) -CLIENT_VERSION = "1.3.1" +CLIENT_VERSION = "1.3.2" # Timeout for analysis with Cppcheck in seconds CPPCHECK_TIMEOUT = 60 * 60 @@ -307,30 +307,34 @@ def scan_package(work_path, cppcheck_path, jobs, libraries): if cppcheck_path == 'cppcheck': # re-run within gdb to get a stacktrace cmd = 'gdb --batch --eval-command=run --eval-command="bt 50" --return-child-result --args ' + cppcheck_cmd + " -j1" - dummy, stdout, stderr, elapsed_time = run_command(cmd) - gdb_pos = stdout.find(" received signal") + dummy, st_stdout, dummy, dummy = run_command(cmd) + gdb_pos = st_stdout.find(" received signal") if not gdb_pos == -1: - last_check_pos = stdout.rfind('Checking ', 0, gdb_pos) + last_check_pos = st_stdout.rfind('Checking ', 0, gdb_pos) if last_check_pos == -1: - stacktrace = stdout[gdb_pos:] + stacktrace = st_stdout[gdb_pos:] else: - stacktrace = stdout[last_check_pos:] + stacktrace = st_stdout[last_check_pos:] + # if no stacktrace was generated return the original stdout + if not stacktrace: + stacktrace = stdout return returncode, stacktrace, '', returncode, options, '' if returncode != 0: print('Error!') if returncode > 0: returncode = -100-returncode return returncode, stdout, '', returncode, options, '' - if stderr.find('Internal error: Child process crashed with signal ') > 0: + err_s = 'Internal error: Child process crashed with signal ' + err_pos = stderr.find(err_s) + if err_pos != -1: print('Error!') - s = 'Internal error: Child process crashed with signal ' - pos1 = stderr.find(s) - pos2 = stderr.find(' [cppcheckError]', pos1) - signr = int(stderr[pos1+len(s):pos2]) + pos2 = stderr.find(' [cppcheckError]', err_pos) + signr = int(stderr[err_pos+len(err_s):pos2]) return -signr, '', '', -signr, options, '' - if stderr.find('#### ThreadExecutor') > 0: + thr_pos = stderr.find('#### ThreadExecutor') + if thr_pos != -1: print('Thread!') - return -222, '', '', -222, options, '' + return -222, stderr[thr_pos:], '', -222, options, '' information_messages_list = [] issue_messages_list = [] count = 0