reccmp: Unique addresses and stub reporting (#554)

This commit is contained in:
MS
2024-02-13 20:25:51 -05:00
committed by GitHub
parent eb3b339454
commit 1b696e4bd8
8 changed files with 326 additions and 99 deletions

View File

@@ -95,6 +95,10 @@ def print_match_verbose(match, show_both_addrs: bool = False, is_plain: bool = F
else:
addrs = hex(match.orig_addr)
if match.is_stub:
print(f"{addrs}: {match.name} is a stub. No diff.")
return
if match.effective_ratio == 1.0:
ok_text = (
"OK!"
@@ -125,7 +129,10 @@ def print_match_oneline(match, show_both_addrs: bool = False, is_plain: bool = F
else:
addrs = hex(match.orig_addr)
print(f" {match.name} ({addrs}) is {percenttext} similar to the original")
if match.is_stub:
print(f" {match.name} ({addrs}) is a stub.")
else:
print(f" {match.name} ({addrs}) is {percenttext} similar to the original")
def parse_args() -> argparse.Namespace:
@@ -180,6 +187,11 @@ def parse_args() -> argparse.Namespace:
action="store_true",
help="Print addresses of recompiled functions too",
)
parser.add_argument(
"--silent",
action="store_true",
help="Don't display text summary of matches",
)
parser.set_defaults(loglevel=logging.INFO)
parser.add_argument(
@@ -244,25 +256,31 @@ def main():
htmlinsert = []
for match in isle_compare.compare_all():
print_match_oneline(
match, show_both_addrs=args.print_rec_addr, is_plain=args.no_color
)
if not args.silent:
print_match_oneline(
match, show_both_addrs=args.print_rec_addr, is_plain=args.no_color
)
if match.match_type == SymbolType.FUNCTION:
if match.match_type == SymbolType.FUNCTION and not match.is_stub:
function_count += 1
total_accuracy += match.ratio
total_effective_accuracy += match.effective_ratio
# If html, record the diffs to an HTML file
if args.html is not None:
htmlinsert.append(
{
"address": f"0x{match.orig_addr:x}",
"name": match.name,
"matching": match.effective_ratio,
"diff": "\n".join(match.udiff),
}
)
html_obj = {
"address": f"0x{match.orig_addr:x}",
"name": match.name,
"matching": match.effective_ratio,
}
if match.udiff is not None:
html_obj["diff"] = "\n".join(match.udiff)
if match.is_stub:
html_obj["stub"] = True
htmlinsert.append(html_obj)
## Generate files and show summary.

View File

@@ -110,7 +110,14 @@
var decCel = row.appendChild(document.createElement('td'));
decCel.colSpan = 3;
var diff = data[this.dataset.index].diff;
if (diff == '') {
const stub = "stub" in data[this.dataset.index];
if (stub) {
diff = document.createElement('div');
diff.className = 'identical';
diff.innerText = 'Stub. No diff.';
decCel.appendChild(diff);
} else if (diff == '') {
diff = document.createElement('div');
diff.className = 'identical';
diff.innerText = 'Identical function - no diff';
@@ -132,7 +139,7 @@
}
}
const filterOptions = { text: '', hidePerfect: false };
const filterOptions = { text: '', hidePerfect: false, hideStub: false };
function filter() {
closeAllDiffs();
@@ -144,13 +151,15 @@
for (var ele of collection) {
var eledata = data[ele.dataset.index];
const stubOk = (!filterOptions.hideStub || !("stub" in eledata));
const textOk = (ltext == ''
|| eledata.address.toLowerCase().includes(ltext)
|| eledata.name.toLowerCase().includes(ltext));
const perfOk = (!filterOptions.hidePerfect || (eledata.matching < 1));
if (textOk && perfOk) {
if (stubOk && textOk && perfOk) {
ele.style.display = '';
searchCount++;
} else {
@@ -233,9 +242,14 @@
addrCel.innerText = addrCel.dataset.value = element.address;
nameCel.innerText = nameCel.dataset.value = element.name;
var effectiveNote = (element.matching == 1 && element.diff != '') ? '*' : '';
matchCel.innerHTML = (element.matching * 100).toFixed(2) + '%' + effectiveNote;
matchCel.dataset.value = element.matching;
if ("stub" in element) {
matchCel.innerHTML = 'stub'
matchCel.dataset.value = -1;
} else {
var effectiveNote = (element.matching == 1 && element.diff != '') ? '*' : '';
matchCel.innerHTML = (element.matching * 100).toFixed(2) + '%' + effectiveNote;
matchCel.dataset.value = element.matching;
}
row.classList.add('funcrow');
row.addEventListener('click', rowClick);
@@ -255,6 +269,12 @@
filter();
})
const cbHideStub = document.querySelector('#cbHideStub');
cbHideStub.addEventListener('change', evt => {
filterOptions.hideStub = evt.target.checked;
filter();
})
sortByColumn(0);
});
</script>
@@ -266,6 +286,8 @@
<div class="filters">
<label for="cbHidePerfect">Hide 100% match</label>
<input type="checkbox" id="cbHidePerfect" />
<label for="cbHideStub">Hide stubs</label>
<input type="checkbox" id="cbHideStub" />
</div>
<table id="listing">
<tr id='listingheader'><th style='width: 20%'>Address</th><th style="width:60%">Name</th><th style='width: 20%'>Matching</th></tr>