1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-03 00:52:12 +00:00

Kernel: Include the current instruction pointer in profile samples

We were missing the innermost instruction pointer when sampling.
This makes the instruction-level profile info a lot cooler! :^)
This commit is contained in:
Andreas Kling 2020-04-11 20:39:27 +02:00
parent c106451daf
commit b7ff3b5ad1
4 changed files with 7 additions and 6 deletions

View file

@ -66,11 +66,12 @@ KResult PerformanceEventBuffer::append(int type, FlatPtr arg1, FlatPtr arg2)
FlatPtr ebp;
asm volatile("movl %%ebp, %%eax"
: "=a"(ebp));
//copy_from_user(&ebp, (FlatPtr*)current->get_register_dump_from_stack().ebp);
FlatPtr eip;
copy_from_user(&eip, (FlatPtr*)&Thread::current->get_register_dump_from_stack().eip);
Vector<FlatPtr> backtrace;
{
SmapDisabler disabler;
backtrace = Thread::current->raw_backtrace(ebp);
backtrace = Thread::current->raw_backtrace(ebp, eip);
}
event.stack_size = min(sizeof(event.stack) / sizeof(FlatPtr), static_cast<size_t>(backtrace.size()));
memcpy(event.stack, backtrace.data(), event.stack_size * sizeof(FlatPtr));