mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:27:43 +00:00
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.
This commit is contained in:
parent
d396766058
commit
fd73de684e
3 changed files with 52 additions and 34 deletions
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue