mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-07 11:39:44 +03:00
Profiler: Symbolicate addresses in non-PIE ELF objects
This is a little bit messy, but basically if an ELF object is non-PIE, we have to account for the executable mapping being at a hard-coded offset and subtract that when doing symbolication. There's probably a nicer way to solve this, I just hacked this together so we can see "cc1plus" and friends in profiles. :^)
This commit is contained in:
parent
538975b713
commit
373a595c56
Notes:
sideshowbarker
2024-07-18 21:44:25 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/373a595c567
@ -316,11 +316,7 @@ Result<NonnullOwnPtr<Profile>, String> Profile::load_from_perfcore_file(const St
|
|||||||
library_metadata = it->library_metadata.ptr();
|
library_metadata = it->library_metadata.ptr();
|
||||||
if (auto* library = library_metadata ? library_metadata->library_containing(ptr) : nullptr) {
|
if (auto* library = library_metadata ? library_metadata->library_containing(ptr) : nullptr) {
|
||||||
object_name = library->name;
|
object_name = library->name;
|
||||||
if (library->object) {
|
symbol = library->symbolicate(ptr, &offset);
|
||||||
symbol = library->object->elf.symbolicate(ptr - library->base, &offset);
|
|
||||||
} else {
|
|
||||||
symbol = "??";
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
symbol = "??";
|
symbol = "??";
|
||||||
}
|
}
|
||||||
@ -455,10 +451,25 @@ LibraryMetadata::LibraryMetadata(JsonArray regions)
|
|||||||
if (!mapped_object)
|
if (!mapped_object)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
m_libraries.set(name, adopt_own(*new Library { base, size, name, mapped_object }));
|
FlatPtr text_base {};
|
||||||
|
mapped_object->elf.for_each_program_header([&](const ELF::Image::ProgramHeader& ph) {
|
||||||
|
if (ph.is_executable())
|
||||||
|
text_base = ph.vaddr().get();
|
||||||
|
return IterationDecision::Continue;
|
||||||
|
});
|
||||||
|
|
||||||
|
m_libraries.set(name, adopt_own(*new Library { base, size, name, text_base, mapped_object }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String LibraryMetadata::Library::symbolicate(FlatPtr ptr, u32* offset) const
|
||||||
|
{
|
||||||
|
if (!object)
|
||||||
|
return "??"sv;
|
||||||
|
|
||||||
|
return object->elf.symbolicate(ptr - base + text_base, offset);
|
||||||
|
}
|
||||||
|
|
||||||
const LibraryMetadata::Library* LibraryMetadata::library_containing(FlatPtr ptr) const
|
const LibraryMetadata::Library* LibraryMetadata::library_containing(FlatPtr ptr) const
|
||||||
{
|
{
|
||||||
for (auto& it : m_libraries) {
|
for (auto& it : m_libraries) {
|
||||||
|
@ -59,7 +59,10 @@ public:
|
|||||||
FlatPtr base;
|
FlatPtr base;
|
||||||
size_t size;
|
size_t size;
|
||||||
String name;
|
String name;
|
||||||
|
FlatPtr text_base;
|
||||||
MappedObject* object { nullptr };
|
MappedObject* object { nullptr };
|
||||||
|
|
||||||
|
String symbolicate(FlatPtr, u32* offset) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
const Library* library_containing(FlatPtr) const;
|
const Library* library_containing(FlatPtr) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user