mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 13:30:31 +00:00
LibELF: Add MemoryRegionInfo::object_name()
We had multiple implementations of this function, and it's a small helper related to MemoryRegionInfo's region_name, so let's move it there.
This commit is contained in:
parent
c39323401c
commit
e2e2b2c08e
Notes:
sideshowbarker
2024-07-19 00:26:46 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/e2e2b2c08ef Pull-request: https://github.com/SerenityOS/serenity/pull/4626 Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/devsh0
2 changed files with 12 additions and 12 deletions
|
@ -47,15 +47,6 @@ static void sort_profile_nodes(Vector<NonnullRefPtr<ProfileNode>>& 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<MappedFile> file;
|
||||
ELF::Image lib_elf;
|
||||
|
@ -66,9 +57,7 @@ static String symbolicate(FlatPtr eip, const ELF::Core::MemoryRegionInfo* region
|
|||
|
||||
static HashMap<String, OwnPtr<CachedLibData>> 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"))
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <AK/Types.h>
|
||||
#include <LibC/sys/arch/i386/regs.h>
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue