mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:57:45 +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
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();
|
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 {
|
struct CachedLibData {
|
||||||
OwnPtr<MappedFile> file;
|
OwnPtr<MappedFile> file;
|
||||||
ELF::Image lib_elf;
|
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;
|
static HashMap<String, OwnPtr<CachedLibData>> cached_libs;
|
||||||
|
|
||||||
StringView region_name { region->region_name };
|
auto name = region->object_name();
|
||||||
|
|
||||||
auto name = object_name(region_name);
|
|
||||||
|
|
||||||
String path;
|
String path;
|
||||||
if (name.contains(".so"))
|
if (name.contains(".so"))
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <AK/String.h>
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
#include <LibC/sys/arch/i386/regs.h>
|
#include <LibC/sys/arch/i386/regs.h>
|
||||||
|
|
||||||
|
@ -61,6 +62,16 @@ struct [[gnu::packed]] MemoryRegionInfo
|
||||||
uint32_t region_end;
|
uint32_t region_end;
|
||||||
uint16_t program_header_index;
|
uint16_t program_header_index;
|
||||||
char region_name[]; // Null terminated
|
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…
Add table
Add a link
Reference in a new issue