mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:17:45 +00:00
LibCoreDump: Make symbolication work when .text isn't the first segment
This can happen with binaries built with Clang or with a custom linker script.
This commit is contained in:
parent
99d46caa28
commit
c9118b84b7
3 changed files with 21 additions and 3 deletions
|
@ -79,14 +79,18 @@ Backtrace::~Backtrace()
|
||||||
|
|
||||||
void Backtrace::add_entry(const Reader& coredump, FlatPtr ip)
|
void Backtrace::add_entry(const Reader& coredump, FlatPtr ip)
|
||||||
{
|
{
|
||||||
auto* region = coredump.region_containing((FlatPtr)ip);
|
auto* ip_region = coredump.region_containing((FlatPtr)ip);
|
||||||
if (!region) {
|
if (!ip_region) {
|
||||||
m_entries.append({ ip, {}, {}, {} });
|
m_entries.append({ ip, {}, {}, {} });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto object_name = region->object_name();
|
auto object_name = ip_region->object_name();
|
||||||
if (object_name == "Loader.so")
|
if (object_name == "Loader.so")
|
||||||
return;
|
return;
|
||||||
|
// We need to find the first region for the object, just in case
|
||||||
|
// the PT_LOAD header for the .text segment isn't the first one
|
||||||
|
// in the object file.
|
||||||
|
auto region = coredump.first_region_for_object(object_name);
|
||||||
auto* object_info = object_info_for_region(*region);
|
auto* object_info = object_info_for_region(*region);
|
||||||
if (!object_info)
|
if (!object_info)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -137,6 +137,19 @@ const JsonObject Reader::process_info() const
|
||||||
// FIXME: Maybe just cache this on the Reader instance after first access.
|
// FIXME: Maybe just cache this on the Reader instance after first access.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ELF::Core::MemoryRegionInfo const* Reader::first_region_for_object(StringView object_name) const
|
||||||
|
{
|
||||||
|
ELF::Core::MemoryRegionInfo const* ret = nullptr;
|
||||||
|
for_each_memory_region_info([&ret, &object_name](auto& region_info) {
|
||||||
|
if (region_info.object_name() == object_name) {
|
||||||
|
ret = ®ion_info;
|
||||||
|
return IterationDecision::Break;
|
||||||
|
}
|
||||||
|
return IterationDecision::Continue;
|
||||||
|
});
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
const ELF::Core::MemoryRegionInfo* Reader::region_containing(FlatPtr address) const
|
const ELF::Core::MemoryRegionInfo* Reader::region_containing(FlatPtr address) const
|
||||||
{
|
{
|
||||||
const ELF::Core::MemoryRegionInfo* ret = nullptr;
|
const ELF::Core::MemoryRegionInfo* ret = nullptr;
|
||||||
|
|
|
@ -32,6 +32,7 @@ public:
|
||||||
const ELF::Image& image() const { return m_coredump_image; }
|
const ELF::Image& image() const { return m_coredump_image; }
|
||||||
|
|
||||||
Optional<FlatPtr> peek_memory(FlatPtr address) const;
|
Optional<FlatPtr> peek_memory(FlatPtr address) const;
|
||||||
|
ELF::Core::MemoryRegionInfo const* first_region_for_object(StringView object_name) const;
|
||||||
const ELF::Core::MemoryRegionInfo* region_containing(FlatPtr address) const;
|
const ELF::Core::MemoryRegionInfo* region_containing(FlatPtr address) const;
|
||||||
|
|
||||||
struct LibraryData {
|
struct LibraryData {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue