From d9913ead83fc34197417f6ac88c01aac59ac1041 Mon Sep 17 00:00:00 2001 From: MS Date: Mon, 25 Mar 2024 11:34:20 -0400 Subject: [PATCH] Virtual inheritance follow-up (#727) --- tools/isledecomp/isledecomp/compare/db.py | 18 +++++++++++------- tools/isledecomp/isledecomp/cvdump/analysis.py | 7 +++++++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/tools/isledecomp/isledecomp/compare/db.py b/tools/isledecomp/isledecomp/compare/db.py index f758be0c..50cac87f 100644 --- a/tools/isledecomp/isledecomp/compare/db.py +++ b/tools/isledecomp/isledecomp/compare/db.py @@ -358,24 +358,28 @@ def match_function(self, addr: int, name: str) -> bool: def match_vtable( self, addr: int, name: str, base_class: Optional[str] = None ) -> bool: + # Set up our potential match names + bare_vftable = f"{name}::`vftable'" + for_name = base_class if base_class is not None else name + for_vftable = f"{name}::`vftable'{{for `{for_name}'}}" + # Only allow a match against "Class:`vftable'" # if this is the derived class. - name = ( - f"{name}::`vftable'" - if base_class is None or base_class == name - else f"{name}::`vftable'{{for `{base_class}'}}" - ) + if base_class is None or base_class == name: + name_options = (for_vftable, bare_vftable) + else: + name_options = (for_vftable, for_vftable) row = self._db.execute( """ SELECT recomp_addr FROM `symbols` WHERE orig_addr IS NULL - AND name = ? + AND (name = ? OR name = ?) AND (compare_type = ?) LIMIT 1 """, - (name, SymbolType.VTABLE.value), + (*name_options, SymbolType.VTABLE.value), ).fetchone() if row is not None and self.set_pair(addr, row[0], SymbolType.VTABLE): diff --git a/tools/isledecomp/isledecomp/cvdump/analysis.py b/tools/isledecomp/isledecomp/cvdump/analysis.py index 4ef654c5..bd8734fa 100644 --- a/tools/isledecomp/isledecomp/cvdump/analysis.py +++ b/tools/isledecomp/isledecomp/cvdump/analysis.py @@ -43,6 +43,13 @@ def set_decorated(self, name: str): self.node_type = SymbolType.VTABLE self.friendly_name = demangle_vtable(self.decorated_name) + elif self.decorated_name.startswith("??_8"): + # This is the `vbtable' symbol for virtual inheritance. + # Should be okay to reuse demangle_vtable. We still want to + # remove things like "const" from the output. + self.node_type = SymbolType.DATA + self.friendly_name = demangle_vtable(self.decorated_name) + elif self.decorated_name.startswith("??_C@"): self.node_type = SymbolType.STRING (strlen, _) = demangle_string_const(self.decorated_name)