Repository navigation
Description
Problem
type_match scores an inlined callee's parameters and locals as variables of the function they were inlined into. _parse_function_die (type_match.py:410) descends into every DW_TAG_inlined_subroutine child of the subprogram.
At -O2 most of these are parameters of glibc's _FORTIFY_SOURCE wrappers, and they don't exist in the compiled code. coreutils fmt's emit_bug_reporting_address (void) declares no variables, yet its ground truth has three:
$ python -c 'from pathlib import Path; from decbench.metrics.type_match import extract_ground_truth_types as g; print([(v["name"], v["type"]) for v in g(Path("results/<run>/O2/coreutils/compiled/fmt"))["emit_bug_reporting_address"]])'
[('__fmt', ['void']), ('__fmt', ['void']), ('__fmt', ['void'])]
All three come from inlined printf calls:
DW_TAG_subprogram emit_bug_reporting_address
DW_TAG_inlined_subroutine printf
DW_TAG_formal_parameter __fmt
DW_TAG_inlined_subroutine printf
DW_TAG_formal_parameter __fmt
DW_TAG_inlined_subroutine printf
DW_TAG_formal_parameter __fmt
Each __fmt is a string constant passed straight to __printf_chk, so no decompiler has a variable to match it, and the function can never score perfect. (The void spelling is #94.) O2-noinline is affected too, because -fno-inline still inlines glibc's always_inline wrappers.
How much it matters
These numbers cover coreutils, grep, gzip, diffutils, bzip2, findutils, tar and shadow, over the functions kuna is scored on:
| GT variables | from an inlined callee | |
|---|---|---|
| O2 | 21,038 | 7,148 (34.0%): 4,656 params, 2,492 locals |
| O2-noinline | 23,060 | 3,075 (13.3%) |
The most common names are __fmt (404 at O2), __stream (123), __s and __dest.
With only each function's own variables scored, kuna would go from 74 to 153 perfect functions at O2 and from 380 to 498 at O2-noinline. Other decompilers were not re-scored, but their ground truth is the same, so they would gain the same way.
Proposal
- Skip inlined callees. In
_parse_function_die, skipDW_TAG_inlined_subroutinechildren and keep descending intoDW_TAG_lexical_block.extract_source_evidenceinvariable_match.pyalready has this switch asinclude_inlined(defaultFalse);type_matchhas none. - Optional separate count. Report inlined-callee variables as their own count, so a decompiler that un-inlines a callee and recovers its variables still gets visible credit.
This can't be gamed. type_match already ignores extra decompiled variables, so excluding these never costs a decompiler that does recover them. It only stops charging every tool for variables the binary doesn't have.
🤖 Generated with Claude Code
Activity
type_match: score only a function's own variables, not its inlined ca…