1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 05:57:45 +00:00

Kernel: Implement capturing stack trace on a different CPU

When trying to get a stack trace of a thread on another CPU we send
a SMP message to that processor to capture the stack trace for us.
This commit is contained in:
Tom 2020-10-31 19:32:38 -06:00 committed by Andreas Kling
parent 5b38132e3c
commit 3ee7c21fae
2 changed files with 86 additions and 7 deletions

View file

@ -739,6 +739,7 @@ class Processor {
static ProcessorMessage& smp_get_from_pool();
static void smp_cleanup_message(ProcessorMessage& msg);
bool smp_queue_message(ProcessorMessage& msg);
static void smp_unicast_message(u32 cpu, ProcessorMessage& msg, bool async);
static void smp_broadcast_message(ProcessorMessage& msg, bool async);
static void smp_broadcast_halt();
@ -965,6 +966,23 @@ public:
}
static void smp_broadcast(void (*callback)(), bool async);
static void smp_broadcast(void (*callback)(void*), void* data, void (*free_data)(void*), bool async);
template<typename Callback>
static void smp_unicast(u32 cpu, Callback callback, bool async)
{
auto* data = new Callback(move(callback));
smp_unicast(
cpu,
[](void* data) {
(*reinterpret_cast<Callback*>(data))();
},
data,
[](void* data) {
delete reinterpret_cast<Callback*>(data);
},
async);
}
static void smp_unicast(u32 cpu, void (*callback)(), bool async);
static void smp_unicast(u32 cpu, void (*callback)(void*), void* data, void (*free_data)(void*), bool async);
static void smp_broadcast_flush_tlb(VirtualAddress vaddr, size_t page_count);
template<typename Callback>
@ -999,7 +1017,7 @@ public:
void switch_context(Thread*& from_thread, Thread*& to_thread);
[[noreturn]] static void assume_context(Thread& thread, u32 flags);
u32 init_context(Thread& thread, bool leave_crit);
static bool get_context_frame_ptr(Thread& thread, u32& frame_ptr, u32& eip);
static bool get_context_frame_ptr(Thread& thread, u32& frame_ptr, u32& eip, bool = false);
void set_thread_specific(u8* data, size_t len);
};