mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:37:35 +00:00
Profiler: Fix disassembly view to work with shared libraries
Also, update path to kernel image from "boot/kernel" to "boot/Kernel". Fixes #4555
This commit is contained in:
parent
1af2f65df5
commit
4728d0dd6a
2 changed files with 28 additions and 15 deletions
|
@ -55,26 +55,39 @@ DisassemblyModel::DisassemblyModel(Profile& profile, ProfileNode& node)
|
|||
: m_profile(profile)
|
||||
, m_node(node)
|
||||
{
|
||||
String path;
|
||||
if (m_node.address() >= 0xc0000000)
|
||||
path = "/boot/Kernel";
|
||||
else
|
||||
path = profile.executable_path();
|
||||
m_file = make<MappedFile>(path);
|
||||
OwnPtr<ELF::Image> kernel_elf;
|
||||
const ELF::Image* elf;
|
||||
FlatPtr base_address = 0;
|
||||
if (m_node.address() >= 0xc0000000) {
|
||||
if (!m_kernel_file) {
|
||||
m_kernel_file = new MappedFile("/boot/Kernel");
|
||||
if (!m_kernel_file->is_valid())
|
||||
return;
|
||||
}
|
||||
kernel_elf = make<ELF::Image>((const u8*)m_kernel_file->data(), m_kernel_file->size());
|
||||
elf = kernel_elf.ptr();
|
||||
} else {
|
||||
auto library_data = profile.coredump().library_containing(node.address());
|
||||
if (!library_data) {
|
||||
dbgln("no library data");
|
||||
return;
|
||||
}
|
||||
elf = &library_data->lib_elf;
|
||||
base_address = library_data->base_address;
|
||||
}
|
||||
|
||||
if (!m_file->is_valid())
|
||||
return;
|
||||
|
||||
auto elf = ELF::Image((const u8*)m_file->data(), m_file->size());
|
||||
|
||||
auto symbol = elf.find_symbol(node.address());
|
||||
if (!symbol.has_value())
|
||||
ASSERT(elf != nullptr);
|
||||
|
||||
auto symbol = elf->find_symbol(node.address() - base_address);
|
||||
if (!symbol.has_value()) {
|
||||
dbgln("DisassemblyModel: symbol not found");
|
||||
return;
|
||||
}
|
||||
ASSERT(symbol.has_value());
|
||||
|
||||
auto view = symbol.value().raw_data();
|
||||
|
||||
X86::ELFSymbolProvider symbol_provider(elf);
|
||||
X86::ELFSymbolProvider symbol_provider(*elf);
|
||||
X86::SimpleInstructionStream stream((const u8*)view.characters_without_null_termination(), view.length());
|
||||
X86::Disassembler disassembler(stream);
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ private:
|
|||
|
||||
Profile& m_profile;
|
||||
ProfileNode& m_node;
|
||||
OwnPtr<MappedFile> m_file;
|
||||
OwnPtr<MappedFile> m_kernel_file;
|
||||
|
||||
Vector<InstructionData> m_instructions;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue