Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #10924 from Pokechu22/symbols-missing-last-function
PPCSymbolDB: Fix getting symbol for the last function
  • Loading branch information
AdmiralCurtiss committed Jul 30, 2022
2 parents ecc4bc5 + 1f17a3b commit 92c7566
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions Source/Core/Core/PowerPC/PPCSymbolDB.cpp
Expand Up @@ -92,18 +92,20 @@ void PPCSymbolDB::AddKnownSymbol(u32 startAddr, u32 size, const std::string& nam
Common::Symbol* PPCSymbolDB::GetSymbolFromAddr(u32 addr)
{
auto it = m_functions.lower_bound(addr);
if (it == m_functions.end())
return nullptr;

// If the address is exactly the start address of a symbol, we're done.
if (it->second.address == addr)
return &it->second;

// Otherwise, check whether the address is within the bounds of a symbol.
if (it != m_functions.end())
{
// If the address is exactly the start address of a symbol, we're done.
if (it->second.address == addr)
return &it->second;
}
if (it != m_functions.begin())
{
// Otherwise, check whether the address is within the bounds of a symbol.
--it;
if (addr >= it->second.address && addr < it->second.address + it->second.size)
return &it->second;
if (addr >= it->second.address && addr < it->second.address + it->second.size)
return &it->second;
}

return nullptr;
}
Expand Down

0 comments on commit 92c7566

Please sign in to comment.