mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:37:43 +00:00
Profiler: Share the mapped kernel between Profile and DisassemblyModel
There is no point in keeping around a separate MappedFile object for /boot/Kernel.debug for each DisassemblyModel we create and re-parsing the kernel image multiple times. This will significantly speed up browsing through profile entries from the kernel in disassembly view.
This commit is contained in:
parent
c19c306744
commit
80b660132c
4 changed files with 18 additions and 18 deletions
|
@ -211,6 +211,8 @@ void Profile::rebuild_tree()
|
|||
m_model->invalidate();
|
||||
}
|
||||
|
||||
Optional<MappedObject> g_kernel_debuginfo_object;
|
||||
|
||||
Result<NonnullOwnPtr<Profile>, String> Profile::load_from_perfcore_file(const StringView& path)
|
||||
{
|
||||
auto file = Core::File::construct(path);
|
||||
|
@ -223,10 +225,14 @@ Result<NonnullOwnPtr<Profile>, String> Profile::load_from_perfcore_file(const St
|
|||
|
||||
auto& object = json.value().as_object();
|
||||
|
||||
auto file_or_error = MappedFile::map("/boot/Kernel.debug");
|
||||
OwnPtr<ELF::Image> kernel_elf;
|
||||
if (!file_or_error.is_error())
|
||||
kernel_elf = make<ELF::Image>(file_or_error.value()->bytes());
|
||||
if (!g_kernel_debuginfo_object.has_value()) {
|
||||
auto debuginfo_file_or_error = MappedFile::map("/boot/Kernel.debug");
|
||||
if (!debuginfo_file_or_error.is_error()) {
|
||||
auto debuginfo_file = debuginfo_file_or_error.release_value();
|
||||
auto debuginfo_image = ELF::Image(debuginfo_file->bytes());
|
||||
g_kernel_debuginfo_object = { { debuginfo_file, move(debuginfo_image) } };
|
||||
}
|
||||
}
|
||||
|
||||
auto strings_value = object.get_ptr("strings"sv);
|
||||
if (!strings_value || !strings_value->is_array())
|
||||
|
@ -380,8 +386,8 @@ Result<NonnullOwnPtr<Profile>, String> Profile::load_from_perfcore_file(const St
|
|||
String symbol;
|
||||
|
||||
if (maybe_kernel_base.has_value() && ptr >= maybe_kernel_base.value()) {
|
||||
if (kernel_elf) {
|
||||
symbol = kernel_elf->symbolicate(ptr - maybe_kernel_base.value(), &offset);
|
||||
if (g_kernel_debuginfo_object.has_value()) {
|
||||
symbol = g_kernel_debuginfo_object->elf.symbolicate(ptr - maybe_kernel_base.value(), &offset);
|
||||
} else {
|
||||
symbol = String::formatted("?? <{:p}>", ptr);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue