mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 18:17:34 +00:00
Kernel: Separate out the symbol offsets in profile output
Instead of saying "main +39" and "main +57" etc, we now have a separate field in /proc/profile for the offset-into-the-symbol.
This commit is contained in:
parent
078ee798f7
commit
0f393148da
5 changed files with 19 additions and 8 deletions
|
@ -372,6 +372,7 @@ Optional<KBuffer> procfs$profile(InodeIdentifier)
|
||||||
auto frame_object = frames_array.add_object();
|
auto frame_object = frames_array.add_object();
|
||||||
frame_object.add("address", JsonValue((u32)sample.frames[i]));
|
frame_object.add("address", JsonValue((u32)sample.frames[i]));
|
||||||
frame_object.add("symbol", sample.symbolicated_frames[i]);
|
frame_object.add("symbol", sample.symbolicated_frames[i]);
|
||||||
|
frame_object.add("offset", JsonValue((u32)sample.offsets[i]));
|
||||||
frame_object.finish();
|
frame_object.finish();
|
||||||
}
|
}
|
||||||
frames_array.finish();
|
frames_array.finish();
|
||||||
|
|
|
@ -57,19 +57,24 @@ static void symbolicate(Sample& stack)
|
||||||
for (auto& symbol : recognized_symbols) {
|
for (auto& symbol : recognized_symbols) {
|
||||||
if (!symbol.address)
|
if (!symbol.address)
|
||||||
break;
|
break;
|
||||||
auto& symbol_string_slot = stack.symbolicated_frames[i++];
|
auto& symbol_string_slot = stack.symbolicated_frames[i];
|
||||||
|
auto& offset_slot = stack.offsets[i];
|
||||||
|
++i;
|
||||||
if (!symbol.ksym) {
|
if (!symbol.ksym) {
|
||||||
if (!Scheduler::is_active() && process.elf_loader() && process.elf_loader()->has_symbols())
|
if (!Scheduler::is_active() && process.elf_loader() && process.elf_loader()->has_symbols())
|
||||||
symbol_string_slot = String::format("%s", process.elf_loader()->symbolicate(symbol.address).characters());
|
symbol_string_slot = process.elf_loader()->symbolicate(symbol.address, &offset_slot);
|
||||||
else
|
else
|
||||||
symbol_string_slot = String::empty();
|
symbol_string_slot = String::empty();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
unsigned offset = symbol.address - symbol.ksym->address;
|
u32 offset = symbol.address - symbol.ksym->address;
|
||||||
if (symbol.ksym->address == ksym_highest_address && offset > 4096)
|
if (symbol.ksym->address == ksym_highest_address && offset > 4096) {
|
||||||
symbol_string_slot = String::empty();
|
symbol_string_slot = String::empty();
|
||||||
else
|
offset_slot = 0;
|
||||||
symbol_string_slot = String::format("%s +%u", demangle(symbol.ksym->name).characters(), offset);
|
} else {
|
||||||
|
symbol_string_slot = demangle(symbol.ksym->name);
|
||||||
|
offset_slot = offset;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ struct Sample {
|
||||||
i32 tid;
|
i32 tid;
|
||||||
u64 timestamp;
|
u64 timestamp;
|
||||||
u32 frames[max_stack_frame_count];
|
u32 frames[max_stack_frame_count];
|
||||||
|
u32 offsets[max_stack_frame_count];
|
||||||
String symbolicated_frames[max_stack_frame_count];
|
String symbolicated_frames[max_stack_frame_count];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ char* ELFLoader::symbol_ptr(const char* name)
|
||||||
return found_ptr;
|
return found_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
String ELFLoader::symbolicate(u32 address) const
|
String ELFLoader::symbolicate(u32 address, u32* out_offset) const
|
||||||
{
|
{
|
||||||
SortedSymbol* sorted_symbols = nullptr;
|
SortedSymbol* sorted_symbols = nullptr;
|
||||||
#ifdef KERNEL
|
#ifdef KERNEL
|
||||||
|
@ -139,6 +139,10 @@ String ELFLoader::symbolicate(u32 address) const
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
return "!!";
|
return "!!";
|
||||||
auto& symbol = sorted_symbols[i - 1];
|
auto& symbol = sorted_symbols[i - 1];
|
||||||
|
if (out_offset) {
|
||||||
|
*out_offset = address - symbol.address;
|
||||||
|
return demangle(symbol.name);
|
||||||
|
}
|
||||||
return String::format("%s +%u", demangle(symbol.name).characters(), address - symbol.address);
|
return String::format("%s +%u", demangle(symbol.name).characters(), address - symbol.address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ public:
|
||||||
|
|
||||||
bool has_symbols() const { return m_image.symbol_count(); }
|
bool has_symbols() const { return m_image.symbol_count(); }
|
||||||
|
|
||||||
String symbolicate(u32 address) const;
|
String symbolicate(u32 address, u32* offset = nullptr) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool layout();
|
bool layout();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue