Skip to content

Commit 23ec2ab

Browse files
committed
CMD: add cmdline option to have the analysis fail when one function fails
1 parent 303b1b3 commit 23ec2ab

File tree

5 files changed

+20
-1
lines changed

5 files changed

+20
-1
lines changed

chb/app/CHVersion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
chbversion: str = "0.3.0-20250811"
1+
chbversion: str = "0.3.0-20250812"

chb/cmdline/AnalysisManager.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ def analyze(
289289
extract: bool = False,
290290
verbose: bool = False,
291291
collectdiagnostics: bool = False,
292+
failonfunctionfailure: bool = False,
292293
ignore_stable: bool = False,
293294
save_asm: bool = False,
294295
construct_all_functions: bool = False,
@@ -307,6 +308,7 @@ def analyze(
307308
verbose=verbose,
308309
construct_all_functions=construct_all_functions,
309310
collectdiagnostics=collectdiagnostics,
311+
failonfunctionfailure=failonfunctionfailure,
310312
preamble_cutoff=preamble_cutoff)
311313
return result
312314

@@ -446,6 +448,7 @@ def _analyze_until_stable(
446448
verbose: bool = False,
447449
construct_all_functions: bool = False,
448450
collectdiagnostics: bool = False,
451+
failonfunctionfailure: bool = False,
449452
preamble_cutoff: int = 12) -> int:
450453
cwd = os.getcwd()
451454
os.chdir(self.path) # temporary change in directory
@@ -500,6 +503,8 @@ def _analyze_until_stable(
500503
cmd.extend(["-lineq_block_cutoff", str(self.lineq_block_cutoff)])
501504
if self.include_arm_extension_registers:
502505
cmd.append("-arm_extension_registers")
506+
if failonfunctionfailure:
507+
cmd.append("-fail_on_function_failure")
503508

504509
cmd.extend(["-analyze", self.filename])
505510
jarcmd = ["jar", "cf", functionsjarfile, "-C", analysisdir, "functions"]

chb/cmdline/chkx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,10 @@ def parse() -> argparse.Namespace:
390390
"--collect_diagnostics",
391391
action="store_true",
392392
help="save diagnostics in a separate diagnostics log file")
393+
analyzecmd.add_argument(
394+
"--fail_on_function_failure",
395+
action="store_true",
396+
help="fail immediately if the analysis of one function fails")
393397
analyzecmd.add_argument(
394398
"--thumb",
395399
nargs="*",
@@ -1381,6 +1385,10 @@ def parse() -> argparse.Namespace:
13811385
"--collect_diagnostics",
13821386
action="store_true",
13831387
help="save diagnostic information in diagnostics log")
1388+
relationalprepare.add_argument(
1389+
"--fail_on_function_failure",
1390+
action="store_true",
1391+
help="fail immediately if the analysis of one function fails")
13841392
relationalprepare.add_argument(
13851393
"--hints",
13861394
nargs="*",

chb/cmdline/commandutil.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ def analyzecmd(args: argparse.Namespace) -> NoReturn:
396396
doextract: bool = args.extract
397397
verbose: bool = args.verbose
398398
collectdiagnostics: bool = args.collect_diagnostics
399+
failonfunctionfailure: bool = args.fail_on_function_failure
399400
save_asm: bool = args.save_asm
400401
save_asm_cfg_info: bool = args.save_asm_cfg_info
401402
thumb: List[str] = args.thumb
@@ -425,6 +426,8 @@ def analyzecmd(args: argparse.Namespace) -> NoReturn:
425426
logfilename: Optional[str] = args.logfilename
426427
logfilemode: str = args.logfilemode
427428

429+
failonfunctionfailure = failonfunctionfailure or len(fns_include) == 1
430+
428431
if not os.path.isfile(Config().chx86_analyze):
429432
print_error(
430433
"CodeHawk analyzer executable not found.\n"
@@ -586,6 +589,7 @@ def analyzecmd(args: argparse.Namespace) -> NoReturn:
586589
save_asm=save_asm,
587590
construct_all_functions=construct_all_functions,
588591
collectdiagnostics=collectdiagnostics,
592+
failonfunctionfailure=failonfunctionfailure,
589593
preamble_cutoff=preamble_cutoff)
590594
except subprocess.CalledProcessError as e:
591595
print_error(

chb/cmdline/relationalcmds.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ def relational_prepare_command(args: argparse.Namespace) -> NoReturn:
154154
xprint: bool = not args.json
155155
xssa: bool = args.ssa
156156
collectdiagnostics = args.collect_diagnostics
157+
failonfunctionfailure = args.fail_on_function_failure
157158
xconstruct_all_functions: bool = args.construct_all_functions
158159
loglevel: str = args.loglevel
159160
logfilename: Optional[str] = args.logfilename
@@ -311,6 +312,7 @@ def relational_prepare_command(args: argparse.Namespace) -> NoReturn:
311312
iterations=10,
312313
save_asm=xsave_asm,
313314
collectdiagnostics=collectdiagnostics,
315+
failonfunctionfailure=failonfunctionfailure,
314316
construct_all_functions=xconstruct_all_functions)
315317
except subprocess.CalledProcessError as e:
316318
print(e.output)

0 commit comments

Comments
 (0)