Skip to content

Commit

Permalink
Fixed pmdsky-debug sync adding to out-of-range subsymbol dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
AnonymousRandomPerson committed Oct 24, 2024
1 parent 4be2971 commit 331952f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tools/sync_pmdsky_debug/sync_to_pmdsky_debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def find_symbol_in_header(symbol_name: str, is_data: bool, header_contents: List
class SubsymbolDir:
file_path: str
addresses: Dict[str, int]
length: Dict[str, int]

subsymbol_dirs = {}

Expand Down Expand Up @@ -99,12 +100,13 @@ def sync_xmap_symbol(address: int, symbol: SymbolDetails, language: str, section
file_path = os.path.join(root, file)
with open(file_path, 'r') as yaml_file:
yaml_contents = yaml.load(yaml_file)
subsymbol_dirs[subsymbol_dir].append(SubsymbolDir(file_path, yaml_contents[file[:-4]]['address']))
subsymbol_dirs[subsymbol_dir].append(SubsymbolDir(file_path, yaml_contents[file[:-4]]['address'], yaml_contents[file[:-4]]['length']))

if subsymbol_dirs[subsymbol_dir] is not None:
matching_subsymbol_file = None
for file in subsymbol_dirs[subsymbol_dir]:
if address > file.addresses[language_key] and (matching_subsymbol_file is None or file.addresses[language_key] > matching_subsymbol_file.addresses[language_key]):
file_address = file.addresses[language_key]
if address > file_address and address < file_address + file.length[language_key] and (matching_subsymbol_file is None or file_address > matching_subsymbol_file.addresses[language_key]):
matching_subsymbol_file = file
if matching_subsymbol_file is not None:
symbol_path = matching_subsymbol_file.file_path
Expand Down

0 comments on commit 331952f

Please sign in to comment.