Skip to content

Commit

Permalink
Fix and clean up log output (#80)
Browse files Browse the repository at this point in the history
* Fix numerous `unhandled line` warnings

* Fix "Address not unique!" warnings

* Remove old log suppressions

* Run linter and formatter

---------

Co-authored-by: jonschz <jonschz@users.noreply.github.com>
  • Loading branch information
jonschz and jonschz authored Jan 27, 2025
1 parent 985b988 commit 9000e2f
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 17 deletions.
4 changes: 3 additions & 1 deletion reccmp/isledecomp/compare/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,9 @@ def _match_vtordisp_in_vtable(self, orig_addr, recomp_addr):
thunk_fn.name,
orig_addr,
)
self._db.set_function_pair(orig_addr, recomp_addr)
# Use `tentative` because vtordisps can be shared between different vtables.
# We get a lot of `address not unique!` debug logs otherwise
self._db.set_function_pair_tentative(orig_addr, recomp_addr)

def _unique_names_for_overloaded_functions(self):
"""Our asm sanitize will use the "friendly" name of a function.
Expand Down
4 changes: 4 additions & 0 deletions reccmp/isledecomp/compare/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,10 @@ def set_function_pair(self, orig: int, recomp: int) -> bool:
"""For lineref match or _entry"""
return self.set_pair(orig, recomp, EntityType.FUNCTION)

def set_function_pair_tentative(self, orig: int, recomp: int) -> bool:
"""For lineref match or _entry"""
return self.set_pair_tentative(orig, recomp, EntityType.FUNCTION)

def create_orig_thunk(self, addr: int, name: str) -> bool:
"""Create a thunk function reference using the orig address.
We are here because we have a match on the thunked function,
Expand Down
18 changes: 17 additions & 1 deletion reccmp/isledecomp/cvdump/symbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,17 @@ class CvdumpSymbolsParser:
r"\s*Parent: (?P<parent_addr>\w+), End: (?P<end_addr>\w+), Next: (?P<next_addr>\w+)$"
)

_module_start_regex = re.compile(
r'\*\* Module: "(?P<module>[^"]+)"(?: from "(?P<from>[^"]+)")?$'
)

_compile_key_value = re.compile(r"\s{9}(?P<key>[^:]+):\s(?P<value>.+)$")
"""
For lines like
` Target processor: 80486`
within an `S_COMPILE` symbol.
"""

_flags_frame_pointer_regex = re.compile(r"\s*Flags: Frame Ptr Present$")

_register_stack_symbols = ["S_BPREL32", "S_REGISTER"]
Expand Down Expand Up @@ -109,8 +120,13 @@ def read_line(self, line: str):
)
return
self.current_function.frame_pointer_present = True
elif (match := self._module_start_regex.match(line)) is not None:
# We do not need this info at the moment, might be useful in the future
pass
elif (match := self._compile_key_value.match(line)) is not None:
# We do not need this info at the moment, might be useful in the future
pass
else:
# Most of these are either `** Module: [...]` or data we do not care about
logger.debug("Unhandled line: %s", line[:-1])

def _parse_generic_case(self, line, line_match: Match[str]):
Expand Down
5 changes: 0 additions & 5 deletions reccmp/tools/asmcmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,6 @@ def main():
if not isinstance(recompfile, PEImage):
raise ValueError(f"{target.recompiled_path} is not a PE executable")

if args.verbose is not None:
# Mute logger events from compare engine
logging.getLogger("isledecomp.compare.db").setLevel(logging.CRITICAL)
logging.getLogger("isledecomp.compare.lines").setLevel(logging.CRITICAL)

isle_compare = IsleCompare(
origfile,
recompfile,
Expand Down
5 changes: 0 additions & 5 deletions reccmp/tools/roadmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,6 @@ def parse_args() -> argparse.Namespace:
argparse_add_logging_args(parser)
args = parser.parse_args()
argparse_parse_logging(args=args)
if args.loglevel != logging.DEBUG:
# Mute logger events from compare engine
logging.getLogger("isledecomp.compare.core").setLevel(logging.CRITICAL)
logging.getLogger("isledecomp.compare.db").setLevel(logging.CRITICAL)
logging.getLogger("isledecomp.compare.lines").setLevel(logging.CRITICAL)

return args

Expand Down
5 changes: 0 additions & 5 deletions reccmp/tools/stackcmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,6 @@ def virtual_address(value) -> int:
args = parser.parse_args()

argparse_parse_logging(args=args)
if args.loglevel != logging.DEBUG:
# Mute logger events from compare engine
logging.getLogger("isledecomp.compare.core").setLevel(logging.CRITICAL)
logging.getLogger("isledecomp.compare.db").setLevel(logging.CRITICAL)
logging.getLogger("isledecomp.compare.lines").setLevel(logging.CRITICAL)

return args

Expand Down

0 comments on commit 9000e2f

Please sign in to comment.