Remove old diff.py wrapper (superseded by botw-check) and update docs

This commit is contained in:
Léo Lam 2021-08-06 01:25:12 +02:00
parent e37272f14a
commit 0f6a9d95b5
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
2 changed files with 4 additions and 56 deletions

View File

@ -154,7 +154,7 @@ public:
* Be sure to change the status column from `U` (undecompiled) to `O` (OK). * Be sure to change the status column from `U` (undecompiled) to `O` (OK).
* Example: `0x00000071010c0d60,O,136,_ZN4ksys4util13TaskQueueBaseD1Ev` * Example: `0x00000071010c0d60,O,136,_ZN4ksys4util13TaskQueueBaseD1Ev`
7. **Compare the assembly** with `./diff.py --source <mangled function name>` 7. **Compare the assembly** with `botw-check --source <mangled function name>`
* This will bring up a two-column diff. The code on the left is the original code; the code on the right is your version of the function. * This will bring up a two-column diff. The code on the left is the original code; the code on the right is your version of the function.
* You may ignore address differences (which often show up in adrp+ldr pairs or bl or b). * You may ignore address differences (which often show up in adrp+ldr pairs or bl or b).
@ -170,7 +170,7 @@ public:
* If there are still minor differences left, wrap the function in an `#ifdef NON_MATCHING`, add a comment to explain what is wrong, and change the status to `m` (minor difference) in the CSV. * If there are still minor differences left, wrap the function in an `#ifdef NON_MATCHING`, add a comment to explain what is wrong, and change the status to `m` (minor difference) in the CSV.
* For major differences (lots of entirely red/green/blue lines in the diff), use a capital `M` (major difference) in place of `m`. * For major differences (lots of entirely red/green/blue lines in the diff), use a capital `M` (major difference) in place of `m`.
10. Before opening a PR, reformat the code with clang-format and run `tools/check.py`. 10. Before opening a PR, reformat the code with clang-format and run `botw-check`.
## Non-inlined functions ## Non-inlined functions
@ -199,8 +199,8 @@ This project sometimes uses small hacks to force particular code to be generated
## Project tools ## Project tools
* Check all decompiled functions for issues: `tools/check.py` * Check all decompiled functions for issues: `botw-check`
* To compare assembly: `./diff.py <mangled function name>` * To compare assembly: `botw-check <mangled function name>`
* The function **must be listed in data/uking_functions.csv first**. * The function **must be listed in data/uking_functions.csv first**.
* To do so, search for the name or the address of function you have decompiled, and add the mangled function name to the last column. * To do so, search for the name or the address of function you have decompiled, and add the mangled function name to the last column.
* Pass the `--source` flag to show source code interleaved with assembly code. * Pass the `--source` flag to show source code interleaved with assembly code.

View File

@ -1,52 +0,0 @@
#!/usr/bin/env python3
import argparse
import subprocess
import cxxfilt
from colorama import Fore, Style
from util import utils
parser = argparse.ArgumentParser(description="Diff assembly")
parser.add_argument(
"function", help="Name of the function to diff. Pass | to get a WIP function", nargs="?", default="|")
args, unknown = parser.parse_known_args()
find_wip = args.function == "|"
def find_function_info(name: str):
for info in utils.get_functions():
if info.decomp_name == name or (find_wip and info.status == utils.FunctionStatus.Wip):
return info
for info in utils.get_functions():
if name in cxxfilt.demangle(info.decomp_name):
return info
return None
info = find_function_info(args.function)
if info is not None:
if not info.decomp_name:
utils.fail(f"{args.function} has not been decompiled")
print(
f"diffing: {Style.BRIGHT}{Fore.BLUE}{cxxfilt.demangle(info.decomp_name)}{Style.RESET_ALL} {Style.DIM}({info.decomp_name}){Style.RESET_ALL}")
addr_end = info.addr + info.size
subprocess.call(["tools/asm-differ/diff.py", "-I", "-e", info.decomp_name, "0x%016x" %
info.addr, "0x%016x" % addr_end] + unknown)
if info.status == utils.FunctionStatus.NonMatching:
utils.warn(
f"{info.decomp_name} is marked as non-matching and possibly NOT functionally equivalent")
elif info.status == utils.FunctionStatus.Equivalent:
utils.warn(f"{info.decomp_name} is marked as functionally equivalent but non-matching")
else:
if find_wip:
utils.fail("no WIP function")
utils.fail(
f"unknown function '{args.function}'\nfor constructors and destructors, list the complete object constructor (C1) or destructor (D1)")