crashtest.hxsmith.compare
Opcode-level comparison of the user functions of two images of the same program.
compare
def compare(original: Bytecode, recompiled: Bytecode, modules: Collection[str]) -> Tuple[float, List[Tuple[str, float]]]
Mean opcode-sequence similarity over the original's user functions (a function the recompiled image lacks counts as 0), and the ones that are not identical, worst first.
named_functions
def named_functions(code: Bytecode) -> Dict[str, Function]
Every named function of the image, whichever file its code is in.
pair
def pair(before: Dict[str, Function], after: Dict[str, Function], all_before: Optional[Dict[str, Function]] = None, all_after: Optional[Dict[str, Function]] = None) -> Tuple[List[Tuple[str, Function, Optional[Function]]], List[str]]
Match the two images' functions: by name, and the anonymous ones to their most similar counterpart (a closure's findex order differs between the images). Returns the original's functions with their match (None when the recompiled image has none) and the names of the recompiled functions nothing matched.
prove
def prove(original: Bytecode, recompiled: Bytecode, modules: Collection[str]) -> bool
Whether every user function of the original is proven equivalent to its counterpart.
Equivalence here is crashlink.equivalence: equal signatures prove equal behaviour, so a
False means "not shown", not "different". Lifted closures are not paired one by one: a
closure is part of the signature of whatever creates it, so a reachable one is covered by its
creator, and one nothing reaches cannot change behaviour. Any other function the recompiled
image gained or lost, or a function with no signature, leaves the program unproven.
user_functions
def user_functions(code: Bytecode, modules: Collection[str]) -> Dict[str, Function]
The functions whose code is mostly in one of <module>.hx, by full name. Std code, which
the generated program pulls in and inlines, would only add noise. Anonymous functions share
no usable name between the two images, so they get <anon>#k in findex order.
ANON
ANON = '<anon>#'