Provider for symbol (label) resolution in disassembly. More...
#include <symbol_provider.h>
Public Member Functions | |
| SymbolProvider ()=default | |
| absl::Status | LoadAsarAsmFile (const std::string &path) |
| Load symbols from an Asar-style ASM file (usdasm format) | |
| absl::Status | LoadAsarAsmDirectory (const std::string &directory_path) |
| Load symbols from a directory of ASM files. | |
| absl::Status | LoadSymbolFile (const std::string &path, SymbolFormat format=SymbolFormat::kAuto) |
| Load symbols from a .sym file (various formats) | |
| void | AddSymbol (const Symbol &symbol) |
| Add a single symbol manually. | |
| void | AddAsarSymbols (const std::vector< Symbol > &symbols) |
| Add symbols from Asar patch results. | |
| void | Clear () |
| Clear all loaded symbols. | |
| std::string | GetSymbolName (uint32_t address) const |
| Get symbol name for an address. | |
| std::optional< Symbol > | GetSymbol (uint32_t address) const |
| Get full symbol info for an address. | |
| std::vector< Symbol > | GetSymbolsAtAddress (uint32_t address) const |
| Get all symbols at an address (there may be multiple) | |
| std::optional< Symbol > | FindSymbol (const std::string &name) const |
| Find symbol by name. | |
| std::vector< Symbol > | FindSymbolsMatching (const std::string &pattern) const |
| Find symbols matching a pattern (supports wildcards) | |
| std::vector< Symbol > | GetSymbolsInRange (uint32_t start, uint32_t end) const |
| Get all symbols in an address range. | |
| std::optional< Symbol > | GetNearestSymbol (uint32_t address) const |
| Get nearest symbol at or before an address. | |
| std::string | FormatAddress (uint32_t address, uint32_t max_offset=0x100) const |
| Format an address with symbol info. | |
| size_t | GetSymbolCount () const |
| Get total number of loaded symbols. | |
| bool | HasSymbols () const |
| Check if any symbols are loaded. | |
| std::function< std::string(uint32_t)> | CreateResolver () const |
| Create a symbol resolver function for the disassembler. | |
Private Member Functions | |
| absl::Status | ParseAsarAsmContent (const std::string &content, const std::string &filename) |
| absl::Status | ParseWlaDxSymFile (const std::string &content) |
| absl::Status | ParseMesenMlbFile (const std::string &content) |
| absl::Status | ParseBsnesSymFile (const std::string &content) |
| SymbolFormat | DetectFormat (const std::string &content, const std::string &extension) const |
Private Attributes | |
| std::multimap< uint32_t, Symbol > | symbols_by_address_ |
| std::map< std::string, Symbol > | symbols_by_name_ |
Provider for symbol (label) resolution in disassembly.
This class manages symbol tables from multiple sources:
AI agents use this to see meaningful label names instead of raw addresses when debugging 65816 assembly code.
Usage: SymbolProvider symbols; symbols.LoadAsarAsmFile("bank_00.asm"); symbols.LoadAsarAsmFile("bank_01.asm");
auto name = symbols.GetSymbolName(0x008034); // Returns "MainGameLoop" auto addr = symbols.FindSymbol("Reset"); // Returns Symbol at $008000
Definition at line 66 of file symbol_provider.h.
|
default |
| absl::Status yaze::emu::debug::SymbolProvider::LoadAsarAsmFile | ( | const std::string & | path | ) |
Load symbols from an Asar-style ASM file (usdasm format)
Parses labels like: MainGameLoop: #_008034: LDA.b $12
| path | Path to .asm file |
Definition at line 120 of file symbol_provider.cc.
References ParseAsarAsmContent().
Referenced by LoadAsarAsmDirectory().

| absl::Status yaze::emu::debug::SymbolProvider::LoadAsarAsmDirectory | ( | const std::string & | directory_path | ) |
Load symbols from a directory of ASM files.
Scans for all bank_XX.asm files and loads them
| directory_path | Path to directory containing ASM files |
Definition at line 129 of file symbol_provider.cc.
References LoadAsarAsmFile().
Referenced by yaze::agent::EmulatorServiceImpl::LoadSymbols().

| absl::Status yaze::emu::debug::SymbolProvider::LoadSymbolFile | ( | const std::string & | path, |
| SymbolFormat | format = SymbolFormat::kAuto ) |
Load symbols from a .sym file (various formats)
| path | Path to symbol file |
| format | Symbol file format (kAuto for auto-detect) |
Definition at line 166 of file symbol_provider.cc.
References DetectFormat(), yaze::emu::debug::kAsar, yaze::emu::debug::kAuto, yaze::emu::debug::kBsnes, yaze::emu::debug::kMesen, yaze::emu::debug::kNo$snes, yaze::emu::debug::kWlaDx, ParseAsarAsmContent(), ParseBsnesSymFile(), ParseMesenMlbFile(), and ParseWlaDxSymFile().
Referenced by yaze::agent::EmulatorServiceImpl::LoadSymbols().
| void yaze::emu::debug::SymbolProvider::AddSymbol | ( | const Symbol & | symbol | ) |
Add a single symbol manually.
Definition at line 196 of file symbol_provider.cc.
References yaze::emu::debug::Symbol::address, yaze::emu::debug::Symbol::name, symbols_by_address_, and symbols_by_name_.
Referenced by AddAsarSymbols(), ParseAsarAsmContent(), ParseBsnesSymFile(), ParseMesenMlbFile(), and ParseWlaDxSymFile().
| void yaze::emu::debug::SymbolProvider::AddAsarSymbols | ( | const std::vector< Symbol > & | symbols | ) |
Add symbols from Asar patch results.
Definition at line 201 of file symbol_provider.cc.
References AddSymbol().

| void yaze::emu::debug::SymbolProvider::Clear | ( | ) |
Clear all loaded symbols.
Definition at line 207 of file symbol_provider.cc.
References symbols_by_address_, and symbols_by_name_.
| std::string yaze::emu::debug::SymbolProvider::GetSymbolName | ( | uint32_t | address | ) | const |
Get symbol name for an address.
Definition at line 212 of file symbol_provider.cc.
References symbols_by_address_.
Referenced by CreateResolver().
| std::optional< Symbol > yaze::emu::debug::SymbolProvider::GetSymbol | ( | uint32_t | address | ) | const |
Get full symbol info for an address.
Definition at line 220 of file symbol_provider.cc.
References symbols_by_address_.
Referenced by FormatAddress(), and yaze::agent::EmulatorServiceImpl::GetSymbolAt().
| std::vector< Symbol > yaze::emu::debug::SymbolProvider::GetSymbolsAtAddress | ( | uint32_t | address | ) | const |
Get all symbols at an address (there may be multiple)
Definition at line 228 of file symbol_provider.cc.
References symbols_by_address_.
| std::optional< Symbol > yaze::emu::debug::SymbolProvider::FindSymbol | ( | const std::string & | name | ) | const |
Find symbol by name.
Definition at line 238 of file symbol_provider.cc.
References symbols_by_name_.
Referenced by yaze::agent::EmulatorServiceImpl::ResolveSymbol().
| std::vector< Symbol > yaze::emu::debug::SymbolProvider::FindSymbolsMatching | ( | const std::string & | pattern | ) | const |
Find symbols matching a pattern (supports wildcards)
| pattern | Pattern with * as wildcard (e.g., "Module*", "*_Init") |
Definition at line 247 of file symbol_provider.cc.
References symbols_by_name_.
Referenced by yaze::agent::EmulatorServiceImpl::ResolveSymbol().
| std::vector< Symbol > yaze::emu::debug::SymbolProvider::GetSymbolsInRange | ( | uint32_t | start, |
| uint32_t | end ) const |
Get all symbols in an address range.
Definition at line 258 of file symbol_provider.cc.
References symbols_by_address_.
| std::optional< Symbol > yaze::emu::debug::SymbolProvider::GetNearestSymbol | ( | uint32_t | address | ) | const |
Get nearest symbol at or before an address.
Useful for showing "MainGameLoop+$10" style offsets
Definition at line 269 of file symbol_provider.cc.
References symbols_by_address_.
Referenced by FormatAddress(), and yaze::agent::EmulatorServiceImpl::GetSymbolAt().
| std::string yaze::emu::debug::SymbolProvider::FormatAddress | ( | uint32_t | address, |
| uint32_t | max_offset = 0x100 ) const |
Format an address with symbol info.
Returns formats like: "MainGameLoop" (exact match) "MainGameLoop+$10" (offset from nearest symbol) "$00804D" (no nearby symbol)
Definition at line 286 of file symbol_provider.cc.
References GetNearestSymbol(), and GetSymbol().

|
inline |
Get total number of loaded symbols.
Definition at line 173 of file symbol_provider.h.
References symbols_by_address_.
Referenced by yaze::agent::EmulatorServiceImpl::LoadSymbols().
|
inline |
Check if any symbols are loaded.
Definition at line 178 of file symbol_provider.h.
References symbols_by_address_.
| std::function< std::string(uint32_t)> yaze::emu::debug::SymbolProvider::CreateResolver | ( | ) | const |
Create a symbol resolver function for the disassembler.
Definition at line 307 of file symbol_provider.cc.
References GetSymbolName().

|
private |
Definition at line 313 of file symbol_provider.cc.
References yaze::emu::debug::Symbol::address, AddSymbol(), yaze::emu::debug::Symbol::file, yaze::emu::debug::Symbol::is_local, yaze::emu::debug::Symbol::line, and yaze::emu::debug::Symbol::name.
Referenced by LoadAsarAsmFile(), and LoadSymbolFile().

|
private |
Definition at line 390 of file symbol_provider.cc.
References AddSymbol().
Referenced by LoadSymbolFile().

|
private |
Definition at line 431 of file symbol_provider.cc.
References AddSymbol().
Referenced by LoadSymbolFile().

|
private |
Definition at line 459 of file symbol_provider.cc.
References AddSymbol().
Referenced by LoadSymbolFile().

|
private |
Definition at line 486 of file symbol_provider.cc.
References yaze::emu::debug::kAsar, yaze::emu::debug::kBsnes, yaze::emu::debug::kMesen, and yaze::emu::debug::kWlaDx.
Referenced by LoadSymbolFile().
|
private |
Definition at line 198 of file symbol_provider.h.
Referenced by AddSymbol(), Clear(), GetNearestSymbol(), GetSymbol(), GetSymbolCount(), GetSymbolName(), GetSymbolsAtAddress(), GetSymbolsInRange(), and HasSymbols().
|
private |
Definition at line 201 of file symbol_provider.h.
Referenced by AddSymbol(), Clear(), FindSymbol(), and FindSymbolsMatching().