Skip to content

Commit 9e1bfff

Browse files
waskyosipma
authored andcommitted
REP: allow patch candidate targets to be unspecified
in that case we will include all targets, instead of none
1 parent 3574f21 commit 9e1bfff

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.BasicBlock import BasicBlock
@@ -1172,14 +1173,21 @@ def find_spare_instruction(
11721173
n_calls: int = 0
11731174
libcalls = LibraryCallCallsites()
11741175

1176+
include_all = xtargets == ['all']
1177+
1178+
def include_target(target: 'CallTarget') -> bool:
1179+
if include_all:
1180+
return True
1181+
return target.name in xtargets
1182+
11751183
for (faddr, blocks) in app.call_instructions().items():
11761184
fn = app.function(faddr)
11771185

11781186
for (baddr, instrs) in blocks.items():
11791187
for instr in instrs:
11801188
n_calls += 1
11811189
calltgt = instr.call_target
1182-
if calltgt.is_so_target and calltgt.name in xtargets:
1190+
if calltgt.is_so_target and include_target(calltgt):
11831191
libcalls.add_library_callsite(faddr, baddr, instr)
11841192

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

0 commit comments

Comments
 (0)