Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SymbolDatabase::first_symbol_from_starting_address function #157

Merged
merged 1 commit into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/ccc/symbol_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,15 +587,19 @@ s32 SymbolDatabase::symbol_count() const
return sum;
}

bool SymbolDatabase::symbol_exists_with_starting_address(Address address) const
const Symbol* SymbolDatabase::first_symbol_from_starting_address(Address address) const
{
#define CCC_X(SymbolType, symbol_list) \
if(symbol_list.first_handle_from_starting_address(address).valid()) { \
return true; \
if constexpr(SymbolType::FLAGS & WITH_ADDRESS_MAP) { \
const SymbolHandle<SymbolType> handle = symbol_list.first_handle_from_starting_address(address); \
const SymbolType* symbol = symbol_list.symbol_from_handle(handle); \
if(symbol) { \
return symbol; \
} \
}
CCC_FOR_EACH_SYMBOL_TYPE_DO_X
#undef CCC_X
return false;
return nullptr;
}

Result<SymbolSourceHandle> SymbolDatabase::get_symbol_source(const std::string& name)
Expand Down
6 changes: 4 additions & 2 deletions src/ccc/symbol_database.h
Original file line number Diff line number Diff line change
Expand Up @@ -550,8 +550,10 @@ class SymbolDatabase {
// Sum up the symbol counts for each symbol list.
s32 symbol_count() const;

// Check if a symbol has already been added to the database.
bool symbol_exists_with_starting_address(Address address) const;
// Find a symbol of any type that exists at the specified address. Symbols
// of the types specified higher up in the CCC_FOR_EACH_SYMBOL_TYPE_DO_X
// macro are checked for first.
const Symbol* first_symbol_from_starting_address(Address address) const;

// Finds a symbol source object with the given name or creates one if it
// doesn't already exist.
Expand Down