mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 10:05:10 +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:
parent
94652fd2fb
commit
983b4bd9f2
5 changed files with 32 additions and 62 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue