Skip to content

Commit 1d898e0

Browse files
committed
REP: allow patch candidate targets to be unspecified
in that case we will include all targets, instead of none
1 parent add139d commit 1d898e0

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

chb/cmdline/chkx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,8 +1184,9 @@ def parse() -> argparse.Namespace:
11841184
report_patchcandidates.add_argument(
11851185
"--targets",
11861186
nargs="*",
1187-
default=[],
1188-
help="list of target library functions to include")
1187+
default=['all'],
1188+
help="list of target library functions to include. If not passed, all "
1189+
"library functions found will be included.")
11891190
report_patchcandidates.add_argument(
11901191
"--verbose", "-v",
11911192
action="store_true",

chb/cmdline/reportcmds.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@
6666
from chb.util.loggingutil import chklogger
6767

6868
if TYPE_CHECKING:
69-
from chb.api.CallTarget import StubTarget
69+
from chb.api.CallTarget import (
70+
StubTarget, CallTarget)
7071
from chb.api.FunctionStub import SOFunction
7172
from chb.app.AppAccess import AppAccess
7273
from chb.app.Instruction import Instruction
@@ -1156,14 +1157,21 @@ def report_patch_candidates(args: argparse.Namespace) -> NoReturn:
11561157
n_calls: int = 0
11571158
libcalls = LibraryCallCallsites()
11581159

1160+
include_all = xtargets == ['all']
1161+
1162+
def include_target(target: 'CallTarget') -> bool:
1163+
if include_all:
1164+
return True
1165+
return target.name in xtargets
1166+
11591167
for (faddr, blocks) in app.call_instructions().items():
11601168
fn = app.function(faddr)
11611169

11621170
for (baddr, instrs) in blocks.items():
11631171
for instr in instrs:
11641172
n_calls += 1
11651173
calltgt = instr.call_target
1166-
if calltgt.is_so_target and calltgt.name in xtargets:
1174+
if calltgt.is_so_target and include_target(calltgt):
11671175
libcalls.add_library_callsite(faddr, instr)
11681176

11691177
print("Number of calls: " + str(n_calls))

0 commit comments

Comments
 (0)