Skip to content

Commit

Permalink
Use the local cache when a callsite is unknown
Browse files Browse the repository at this point in the history
  • Loading branch information
fwsGonzo committed Jan 2, 2025
1 parent 28f8676 commit a9dd01b
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/sandbox_exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,21 @@ static inline String to_hex(gaddr_t value) {
}

void Sandbox::handle_exception(gaddr_t address) {
auto callsite = machine().memory.lookup(address);
riscv::Memory<RISCV_ARCH>::Callsite callsite = machine().memory.lookup(address);
// If the callsite is not found, try to use the cache to find the address
if (callsite.address == 0x0) {
callsite.address = address;
auto it = m_lookup.find(address);
if (it != m_lookup.end()) {
const auto u8str = it->second.name.utf8();
callsite = riscv::Memory<RISCV_ARCH>::Callsite{
.name = std::string(u8str.ptr(), u8str.length()),
.address = it->second.address,
.offset = 0x0,
.size = 0
};
}
}
UtilityFunctions::print(
"[", get_name(), "] Exception when calling:\n ", callsite.name.c_str(), " (0x",
to_hex(callsite.address), ")\n", "Backtrace:");
Expand Down

0 comments on commit a9dd01b

Please sign in to comment.