Skip to content

Commit 662eaec

Browse files
committed
CMD: add option to analyze named functions only
1 parent af50634 commit 662eaec

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

chb/cmdline/chkx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# ------------------------------------------------------------------------------
66
# The MIT License (MIT)
77
#
8-
# Copyright (c) 2021-2024 Aarno Labs, LLC
8+
# Copyright (c) 2021-2025 Aarno Labs, LLC
99
#
1010
# Permission is hereby granted, free of charge, to any person obtaining a copy
1111
# of this software and associated documentation files (the "Software"), to deal
@@ -469,6 +469,10 @@ def parse() -> argparse.Namespace:
469469
nargs="*",
470470
default=[],
471471
help="addresses of function to include in the analysis")
472+
analyzecmd.add_argument(
473+
"--analyze_all_named",
474+
help="include all functions named in userdata in the analysis",
475+
action="store_true")
472476
analyzecmd.add_argument(
473477
"--gc_compact",
474478
type=int,

chb/cmdline/commandutil.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# ------------------------------------------------------------------------------
66
# The MIT License (MIT)
77
#
8-
# Copyright (c) 2021-2024 Aarno Labs, LLC
8+
# Copyright (c) 2021-2025 Aarno Labs, LLC
99
#
1010
# Permission is hereby granted, free of charge, to any person obtaining a copy
1111
# of this software and associated documentation files (the "Software"), to deal
@@ -411,6 +411,7 @@ def analyzecmd(args: argparse.Namespace) -> NoReturn:
411411
fns_no_lineq: List[str] = args.fns_no_lineq # function hex addresses
412412
fns_exclude: List[str] = args.fns_exclude # function hex addresses
413413
fns_include: List[str] = args.fns_include # function hex addresses
414+
analyze_all_named: bool = args.analyze_all_named
414415
gc_compact: int = args.gc_compact
415416
construct_all_functions: bool = args.construct_all_functions
416417
show_function_timing: bool = args.show_function_timing
@@ -447,7 +448,7 @@ def analyzecmd(args: argparse.Namespace) -> NoReturn:
447448
exit(0)
448449

449450
try:
450-
prepare_executable(
451+
userhints = prepare_executable(
451452
path,
452453
xfile,
453454
doreset,
@@ -488,6 +489,11 @@ def analyzecmd(args: argparse.Namespace) -> NoReturn:
488489
print_error("Header file " + f + " not found")
489490
exit(1)
490491

492+
if analyze_all_named:
493+
fnnamed_addrs = userhints.rev_function_names().values()
494+
fns_include = fns_include + list(fnnamed_addrs)
495+
chklogger.logger.warning("Include %d functions", len(fns_include))
496+
491497
am = AnalysisManager(
492498
path,
493499
xfile,

chb/userdata/UserHints.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,6 +1550,10 @@ def add_hints(self, hints: Dict[str, Any]) -> None:
15501550
self.userdata[tag].update(fnames)
15511551
else:
15521552
self.userdata[tag] = FunctionNamesHints(fnames)
1553+
if tag in self.astdata:
1554+
self.astdata[tag].update(fnames)
1555+
else:
1556+
self.astdata[tag] = FunctionNamesHints(fnames)
15531557
else:
15541558
if tag in self.astdata:
15551559
self.astdata[tag].update(fnames)

0 commit comments

Comments
 (0)