diff --git a/Userland/Services/SymbolServer/ClientConnection.cpp b/Userland/Services/SymbolServer/ClientConnection.cpp index fee6bfb02e..f788057c3d 100644 --- a/Userland/Services/SymbolServer/ClientConnection.cpp +++ b/Userland/Services/SymbolServer/ClientConnection.cpp @@ -36,7 +36,7 @@ struct CachedELF { ELF::Image elf; }; -static HashMap s_cache; +static HashMap> s_cache; static HashMap> s_connections; ClientConnection::ClientConnection(NonnullRefPtr socket, int client_id) @@ -66,14 +66,16 @@ OwnPtr ClientConnection::handle(con auto mapped_file = MappedFile::map(path); if (mapped_file.is_error()) { dbgln("Failed to map {}: {}", path, mapped_file.error().string()); + s_cache.set(path, {}); return make(false, String {}, 0, String {}, 0); } auto elf = ELF::Image(mapped_file.value()->bytes()); if (!elf.is_valid()) { dbgln("ELF not valid: {}", path); + s_cache.set(path, {}); return make(false, String {}, 0, String {}, 0); } - auto cached_elf = CachedELF { mapped_file.release_value(), move(elf) }; + auto cached_elf = make(mapped_file.release_value(), move(elf)); s_cache.set(path, move(cached_elf)); } @@ -81,8 +83,11 @@ OwnPtr ClientConnection::handle(con ASSERT(it != s_cache.end()); auto& cached_elf = it->value; + if (!cached_elf) + return make(false, String {}, 0, String {}, 0); + u32 offset = 0; - auto symbol = cached_elf.elf.symbolicate(message.address(), &offset); + auto symbol = cached_elf->elf.symbolicate(message.address(), &offset); return make(true, symbol, offset, String {}, 0); }