debug(sched): create_thread 打印 tid/func/stack 实际值,定位线程首次调度跳栈 #UD(rip 在栈区域)根因

This commit is contained in:
TermiNexus committed 2026-08-26 23:30:28 +08:00
1 parent 4c25e0e35c
commit a8f7c0b0b3
1 file changed
+8 -4
+8 -4
View File
@@ -1,4 +1,4 @@
import mm
import mm.mm as mm
import asm
import sched.process as proc
import drivers.serial.uart.serial as serial
@@ -201,6 +201,10 @@ class Scheduler:
th.arg = arg
stack_size: t.CUInt64T = THREAD_STACK_SIZE
stack_ptr: t.CVoid | t.CPtr = mm.malloc(stack_size)
_dbg_ct: t.CArray[t.CChar, 96]
viperlib.snprintf(c.Addr(_dbg_ct), 96, "[sched] ct t%d func=0x%lx stack=0x%lx\n",
tid, t.CUInt64T(th.func), t.CUInt64T(stack_ptr))
serial.puts(c.Addr(_dbg_ct))
if not stack_ptr: return None
th.stack = stack_ptr
th.stack_size = stack_size
@@ -225,9 +229,9 @@ class Scheduler:
_sched_storage: Scheduler = Scheduler()
_sched_ptr: Scheduler | t.CPtr = c.Addr(_sched_storage)
_switch_old_rsp: t.CVoid | t.CPtr
_switch_new_rsp: t.CVoid | t.CPtr
_sched_ptr: Scheduler | t.CPtr | t.CExport = c.Addr(_sched_storage)
_switch_old_rsp: t.CVoid | t.CPtr | t.CExport
_switch_new_rsp: t.CVoid | t.CPtr | t.CExport
@c.Attribute(t.attr.naked)
def _do_switch():