diff --git a/DevTools/Profiler/Profile.cpp b/DevTools/Profiler/Profile.cpp index 513756d1af8..a56f41baf51 100644 --- a/DevTools/Profiler/Profile.cpp +++ b/DevTools/Profiler/Profile.cpp @@ -47,15 +47,6 @@ static void sort_profile_nodes(Vector>& nodes) child->sort_children(); } -static String object_name(StringView memory_region_name) -{ - if (memory_region_name.contains("Loader.so")) - return "Loader.so"; - if (!memory_region_name.contains(":")) - return {}; - return memory_region_name.substring_view(0, memory_region_name.find_first_of(":").value()).to_string(); -} - struct CachedLibData { OwnPtr file; ELF::Image lib_elf; @@ -66,9 +57,7 @@ static String symbolicate(FlatPtr eip, const ELF::Core::MemoryRegionInfo* region static HashMap> cached_libs; - StringView region_name { region->region_name }; - - auto name = object_name(region_name); + auto name = region->object_name(); String path; if (name.contains(".so")) diff --git a/Libraries/LibELF/CoreDump.h b/Libraries/LibELF/CoreDump.h index 88db56094cc..531f5eaddeb 100644 --- a/Libraries/LibELF/CoreDump.h +++ b/Libraries/LibELF/CoreDump.h @@ -26,6 +26,7 @@ #pragma once +#include #include #include @@ -61,6 +62,16 @@ struct [[gnu::packed]] MemoryRegionInfo uint32_t region_end; uint16_t program_header_index; char region_name[]; // Null terminated + + String object_name() const + { + StringView memory_region_name { region_name }; + if (memory_region_name.contains("Loader.so")) + return "Loader.so"; + if (!memory_region_name.contains(":")) + return {}; + return memory_region_name.substring_view(0, memory_region_name.find_first_of(":").value()).to_string(); + } }; }