summaryrefslogtreecommitdiff
path: root/DevTools/Profiler
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2020-08-15 20:01:35 -0400
committerAndreas Kling <kling@serenityos.org>2020-08-16 19:37:58 +0200
commitfd73de684efc17170fbaa3613f1e222c3c22e4f3 (patch)
treec2345cfd16640f1f94e856b40317418e5ab3ce3b /DevTools/Profiler
parentd3967660588a02dd7965dda40b27a11117f0d137 (diff)
downloadserenity-fd73de684efc17170fbaa3613f1e222c3c22e4f3.zip
X86+Profiler+UserspaceEmulator: Deduplicate ELFSymbolProvider to LibX86
From a layering perspective, it's maybe a bit surprising that the X86::SymbolProvider implementation also lives in LibX86, but since everything depends on LibELF via LibC, and since all current LibX86-based disassemblers want to use ELFSymbolProvider, it makes some amount of sense to put it there.
Diffstat (limited to 'DevTools/Profiler')
-rw-r--r--DevTools/Profiler/DisassemblyModel.cpp19
1 files changed, 2 insertions, 17 deletions
diff --git a/DevTools/Profiler/DisassemblyModel.cpp b/DevTools/Profiler/DisassemblyModel.cpp
index 732210e221..89a338225a 100644
--- a/DevTools/Profiler/DisassemblyModel.cpp
+++ b/DevTools/Profiler/DisassemblyModel.cpp
@@ -30,6 +30,7 @@
#include <LibELF/Loader.h>
#include <LibGUI/Painter.h>
#include <LibX86/Disassembler.h>
+#include <LibX86/ELFSymbolProvider.h>
#include <ctype.h>
#include <stdio.h>
@@ -50,22 +51,6 @@ static Color color_for_percent(int percent)
return heat_gradient().get_pixel(percent, 0);
}
-class ELFSymbolProvider final : public X86::SymbolProvider {
-public:
- ELFSymbolProvider(ELF::Loader& loader)
- : m_loader(loader)
- {
- }
-
- virtual String symbolicate(FlatPtr address, u32* offset = nullptr) const
- {
- return m_loader.symbolicate(address, offset);
- }
-
-private:
- ELF::Loader& m_loader;
-};
-
DisassemblyModel::DisassemblyModel(Profile& profile, ProfileNode& node)
: m_profile(profile)
, m_node(node)
@@ -89,7 +74,7 @@ DisassemblyModel::DisassemblyModel(Profile& profile, ProfileNode& node)
auto view = symbol.value().raw_data();
- ELFSymbolProvider symbol_provider(*elf_loader);
+ X86::ELFSymbolProvider symbol_provider(*elf_loader);
X86::SimpleInstructionStream stream((const u8*)view.characters_without_null_termination(), view.length());
X86::Disassembler disassembler(stream);