summaryrefslogtreecommitdiff
path: root/Userland/Services
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-02-05 00:23:58 +0100
committerAndreas Kling <kling@serenityos.org>2021-02-05 00:23:58 +0100
commita4e087e685887ae3ded4bfe34e7f3313281f0549 (patch)
treea332d3992fbad47092bc2aff1af6ccb7fa3a612f /Userland/Services
parent72f96941f2d7b80175e302f810bac01b2d331d19 (diff)
downloadserenity-a4e087e685887ae3ded4bfe34e7f3313281f0549.zip
SymbolServer: Resolve filenames and line numbers from debug info :^)
This makes symbolication take a little longer the first time we load a shared library, but then the cache keeps it warm.
Diffstat (limited to 'Userland/Services')
-rw-r--r--Userland/Services/SymbolServer/CMakeLists.txt2
-rw-r--r--Userland/Services/SymbolServer/ClientConnection.cpp21
2 files changed, 16 insertions, 7 deletions
diff --git a/Userland/Services/SymbolServer/CMakeLists.txt b/Userland/Services/SymbolServer/CMakeLists.txt
index a21db4bda5..4bf28bbe6e 100644
--- a/Userland/Services/SymbolServer/CMakeLists.txt
+++ b/Userland/Services/SymbolServer/CMakeLists.txt
@@ -9,4 +9,4 @@ set(SOURCES
)
serenity_bin(SymbolServer)
-target_link_libraries(SymbolServer LibIPC)
+target_link_libraries(SymbolServer LibIPC LibDebug)
diff --git a/Userland/Services/SymbolServer/ClientConnection.cpp b/Userland/Services/SymbolServer/ClientConnection.cpp
index f788057c3d..849b87d6da 100644
--- a/Userland/Services/SymbolServer/ClientConnection.cpp
+++ b/Userland/Services/SymbolServer/ClientConnection.cpp
@@ -25,6 +25,7 @@
*/
#include <AK/MappedFile.h>
+#include <LibDebug/DebugInfo.h>
#include <LibELF/Image.h>
#include <SymbolServer/ClientConnection.h>
#include <SymbolServer/SymbolClientEndpoint.h>
@@ -33,7 +34,7 @@ namespace SymbolServer {
struct CachedELF {
NonnullRefPtr<MappedFile> mapped_file;
- ELF::Image elf;
+ Debug::DebugInfo debug_info;
};
static HashMap<String, OwnPtr<CachedELF>> s_cache;
@@ -69,13 +70,14 @@ OwnPtr<Messages::SymbolServer::SymbolicateResponse> ClientConnection::handle(con
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()) {
+ auto elf = make<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 = make<CachedELF>(mapped_file.release_value(), move(elf));
+ Debug::DebugInfo debug_info(move(elf));
+ auto cached_elf = make<CachedELF>(mapped_file.release_value(), move(debug_info));
s_cache.set(path, move(cached_elf));
}
@@ -87,9 +89,16 @@ OwnPtr<Messages::SymbolServer::SymbolicateResponse> ClientConnection::handle(con
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->debug_info.elf().symbolicate(message.address(), &offset);
+ auto source_position = cached_elf->debug_info.get_source_position(message.address());
+ String filename;
+ u32 line_number = 0;
+ if (source_position.has_value()) {
+ filename = source_position.value().file_path;
+ line_number = source_position.value().line_number;
+ }
- return make<Messages::SymbolServer::SymbolicateResponse>(true, symbol, offset, String {}, 0);
+ return make<Messages::SymbolServer::SymbolicateResponse>(true, symbol, offset, filename, line_number);
}
}