mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-26 19:29:16 +00:00
Kernel+ProfileViewer: Move symbolication to userspace for time profiles
This makes the time profiles look like the memory profiles so we can use the userspace symbolication code in ProfileViewer.
This commit is contained in:
@@ -398,29 +398,31 @@ Optional<KBuffer> procfs$profile(InodeIdentifier)
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
KBufferBuilder builder;
|
||||
JsonArraySerializer array(builder);
|
||||
|
||||
JsonObjectSerializer object(builder);
|
||||
object.add("pid", Profiling::pid());
|
||||
object.add("executable", Profiling::executable_path());
|
||||
|
||||
auto array = object.add_array("events");
|
||||
bool mask_kernel_addresses = !Process::current->is_superuser();
|
||||
Profiling::for_each_sample([&](auto& sample) {
|
||||
auto object = array.add_object();
|
||||
object.add("pid", sample.pid);
|
||||
object.add("type", "sample");
|
||||
object.add("tid", sample.tid);
|
||||
object.add("timestamp", sample.timestamp);
|
||||
auto frames_array = object.add_array("frames");
|
||||
auto frames_array = object.add_array("stack");
|
||||
for (size_t i = 0; i < Profiling::max_stack_frame_count; ++i) {
|
||||
if (sample.frames[i] == 0)
|
||||
break;
|
||||
auto frame_object = frames_array.add_object();
|
||||
u32 address = (u32)sample.frames[i];
|
||||
if (mask_kernel_addresses && !is_user_address(VirtualAddress(address)))
|
||||
address = 0xdeadc0de;
|
||||
frame_object.add("address", address);
|
||||
frame_object.add("symbol", sample.symbolicated_frames[i]);
|
||||
frame_object.add("offset", JsonValue((u32)sample.offsets[i]));
|
||||
frame_object.finish();
|
||||
frames_array.add(address);
|
||||
}
|
||||
frames_array.finish();
|
||||
});
|
||||
array.finish();
|
||||
object.finish();
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user