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

Kernel: Fix retreiving frame pointer from a thread

If we're trying to walk the stack for another thread, we can
no longer retreive the EBP register from Thread::m_tss. Instead,
we need to look at the top of the kernel stack, because all threads
not currently running were last in kernel mode. Context switches
now always trigger a brief switch to kernel mode, and Thread::m_tss
only is used to save ESP and EIP.

Fixes #2678
This commit is contained in:
Tom 2020-07-03 12:12:34 -06:00 committed by Andreas Kling
parent 6d5bd8c76b
commit bb84fad0bf
4 changed files with 67 additions and 28 deletions

View file

@ -104,7 +104,7 @@ public:
Process& process() { return m_process; }
const Process& process() const { return m_process; }
String backtrace(ProcessInspectionHandle&) const;
String backtrace(ProcessInspectionHandle&);
Vector<FlatPtr> raw_backtrace(FlatPtr ebp, FlatPtr eip) const;
const String& name() const { return m_name; }
@ -283,7 +283,6 @@ public:
u32 affinity() const { return m_cpu_affinity; }
void set_affinity(u32 affinity) { m_cpu_affinity = affinity; }
u32 frame_ptr() const { return m_tss.ebp; }
u32 stack_ptr() const { return m_tss.esp; }
RegisterState& get_register_dump_from_stack();
@ -465,7 +464,7 @@ private:
friend class WaitQueue;
bool unlock_process_if_locked(u32& prev_crit);
void relock_process(bool did_unlock, u32 prev_crit);
String backtrace_impl() const;
String backtrace_impl();
void reset_fpu_state();
Process& m_process;