mirror of
https://github.com/isledecomp/isle.git
synced 2025-12-09 23:53:02 +00:00
Sanitize args for assert in BETA10 (#1095)
This commit is contained in:
@@ -300,3 +300,15 @@ def find_effective_match(
|
|||||||
)
|
)
|
||||||
|
|
||||||
return corrections.issuperset(recomp_lines_disputed)
|
return corrections.issuperset(recomp_lines_disputed)
|
||||||
|
|
||||||
|
|
||||||
|
def assert_fixup(asm: List[Tuple[str, str]]):
|
||||||
|
"""Detect assert calls and replace the code filename and line number
|
||||||
|
values with macros (from assert.h)."""
|
||||||
|
for i, (_, line) in enumerate(asm):
|
||||||
|
if "_assert" in line and line.startswith("call"):
|
||||||
|
try:
|
||||||
|
asm[i - 3] = (asm[i - 3][0], "push __LINE__")
|
||||||
|
asm[i - 2] = (asm[i - 2][0], "push __FILE__")
|
||||||
|
except IndexError:
|
||||||
|
continue
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ from isledecomp.parser import DecompCodebase
|
|||||||
from isledecomp.dir import walk_source_dir
|
from isledecomp.dir import walk_source_dir
|
||||||
from isledecomp.types import SymbolType
|
from isledecomp.types import SymbolType
|
||||||
from isledecomp.compare.asm import ParseAsm
|
from isledecomp.compare.asm import ParseAsm
|
||||||
from isledecomp.compare.asm.fixes import find_effective_match
|
from isledecomp.compare.asm.fixes import assert_fixup, find_effective_match
|
||||||
from .db import CompareDb, MatchInfo
|
from .db import CompareDb, MatchInfo
|
||||||
from .diff import combined_diff
|
from .diff import combined_diff
|
||||||
from .lines import LinesDb
|
from .lines import LinesDb
|
||||||
@@ -661,6 +661,11 @@ class Compare:
|
|||||||
if self.debug:
|
if self.debug:
|
||||||
self._dump_asm(orig_combined, recomp_combined)
|
self._dump_asm(orig_combined, recomp_combined)
|
||||||
|
|
||||||
|
# Check for assert calls only if we expect to find them
|
||||||
|
if self.orig_bin.is_debug or self.recomp_bin.is_debug:
|
||||||
|
assert_fixup(orig_combined)
|
||||||
|
assert_fixup(recomp_combined)
|
||||||
|
|
||||||
# Detach addresses from asm lines for the text diff.
|
# Detach addresses from asm lines for the text diff.
|
||||||
orig_asm = [x[1] for x in orig_combined]
|
orig_asm = [x[1] for x in orig_combined]
|
||||||
recomp_asm = [x[1] for x in recomp_combined]
|
recomp_asm = [x[1] for x in recomp_combined]
|
||||||
|
|||||||
Reference in New Issue
Block a user