Skip to content

Commit dfd2291

Browse files
donate_cpu_lib.py: fix callstack capture, fix dependency check (danmar#3665)
* donate_cpu_lib.py: fix callstack capture, fix dependency check check_requirements: verify that module psutil is available. scan_package: collect crash callstack regardless of cppcheck_path and cppcheck version * donate_cpu_lib.pu: remove debug code * donate_cpu_lib.py: add parameter capture_callstack
1 parent 01a8890 commit dfd2291

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

tools/donate-cpu.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,12 @@
194194

195195
for ver in cppcheck_versions:
196196
tree_path = os.path.join(work_path, 'tree-'+ver)
197+
capture_callstack = False
197198
if ver == 'head':
198199
tree_path = os.path.join(work_path, 'tree-main')
199200
cppcheck_head_info = get_cppcheck_info(tree_path)
200-
c, errout, info, t, cppcheck_options, timing_info = scan_package(work_path, tree_path, jobs, libraries)
201+
capture_callstack = True
202+
c, errout, info, t, cppcheck_options, timing_info = scan_package(work_path, tree_path, jobs, libraries, capture_callstack)
201203
if c < 0:
202204
if c == -101 and 'error: could not find or open any of the paths given.' in errout:
203205
# No sourcefile found (for example only headers present)

tools/donate_cpu_lib.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# Version scheme (MAJOR.MINOR.PATCH) should orientate on "Semantic Versioning" https://semver.org/
1616
# Every change in this script should result in increasing the version number accordingly (exceptions may be cosmetic
1717
# changes)
18-
CLIENT_VERSION = "1.3.17"
18+
CLIENT_VERSION = "1.3.18"
1919

2020
# Timeout for analysis with Cppcheck in seconds
2121
CPPCHECK_TIMEOUT = 30 * 60
@@ -34,6 +34,11 @@ def check_requirements():
3434
except OSError:
3535
print("Error: '{}' is required".format(app))
3636
result = False
37+
try:
38+
import psutil
39+
except ImportError as e:
40+
print("Error: {}. Module is required. ".format(e))
41+
result = False
3742
return result
3843

3944

@@ -292,7 +297,7 @@ def run_command(cmd):
292297
return return_code, stdout, stderr, elapsed_time
293298

294299

295-
def scan_package(work_path, cppcheck_path, jobs, libraries):
300+
def scan_package(work_path, cppcheck_path, jobs, libraries, capture_callstack = True):
296301
print('Analyze..')
297302
os.chdir(work_path)
298303
libs = ''
@@ -370,7 +375,7 @@ def scan_package(work_path, cppcheck_path, jobs, libraries):
370375
if has_sig:
371376
returncode = -sig_num
372377
stacktrace = ''
373-
if cppcheck_path == 'cppcheck':
378+
if capture_callstack:
374379
# re-run within gdb to get a stacktrace
375380
cmd = 'gdb --batch --eval-command=run --eval-command="bt 50" --return-child-result --args ' + cppcheck_cmd + " -j1 "
376381
if sig_file is not None:

0 commit comments

Comments
 (0)