diff options
author | Andreas Kling <kling@serenityos.org> | 2021-02-04 23:44:01 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-02-04 23:44:01 +0100 |
commit | 72f96941f2d7b80175e302f810bac01b2d331d19 (patch) | |
tree | 03e0474f94bf2626fe8274258346b0d0cea84bd7 /Userland/Services/SymbolServer | |
parent | acabc37c242ab2769eaa2b8bd1ac133f97c9bbf0 (diff) | |
download | serenity-72f96941f2d7b80175e302f810bac01b2d331d19.zip |
SymbolServer: Cache failed ELF loads as well
Remember which paths we've already tried to load. This stops it from
whining about /boot/Kernel not being mappable.
Diffstat (limited to 'Userland/Services/SymbolServer')
-rw-r--r-- | Userland/Services/SymbolServer/ClientConnection.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
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<String, CachedELF> s_cache; +static HashMap<String, OwnPtr<CachedELF>> s_cache; static HashMap<int, RefPtr<ClientConnection>> s_connections; ClientConnection::ClientConnection(NonnullRefPtr<Core::LocalSocket> socket, int client_id) @@ -66,14 +66,16 @@ OwnPtr<Messages::SymbolServer::SymbolicateResponse> 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<Messages::SymbolServer::SymbolicateResponse>(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<Messages::SymbolServer::SymbolicateResponse>(false, String {}, 0, String {}, 0); } - auto cached_elf = CachedELF { mapped_file.release_value(), move(elf) }; + auto cached_elf = make<CachedELF>(mapped_file.release_value(), move(elf)); s_cache.set(path, move(cached_elf)); } @@ -81,8 +83,11 @@ OwnPtr<Messages::SymbolServer::SymbolicateResponse> ClientConnection::handle(con ASSERT(it != s_cache.end()); auto& cached_elf = it->value; + if (!cached_elf) + return make<Messages::SymbolServer::SymbolicateResponse>(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<Messages::SymbolServer::SymbolicateResponse>(true, symbol, offset, String {}, 0); } |