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:
Andreas Kling 2020-02-22 10:05:03 +01:00
commit 983b4bd9f2
Notes: sideshowbarker 2024-07-19 09:10:43 +09:00
5 changed files with 32 additions and 62 deletions

View file

@ -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();
}