debug(elf,main): 打印 read_len 与 spawn_elf 返回 pid 实际值——fat32.read 内部 br=64 但 load_elf 收到 <64、spawn ret pid=1 但 main 收到 0,定位跨模块返回值间歇性丢失
This commit is contained in:
1 parent
a621b0d264
commit
d0b512f159
2 files changed
+9
No files matched your search
@@ -130,6 +130,11 @@ def load_elf(path: t.CConst | str, do_map: t.CInt = 1) -> t.CVoid | t.CPtr:
|
||||
ehdr_buf: t.CArray[t.CUInt8T, 64]
|
||||
string.memset(c.Addr(ehdr_buf), 0, 64)
|
||||
read_len: t.CUInt32T = fat32.read(fp, c.Addr(ehdr_buf), 64)
|
||||
# [DIAG] read_len 实际值(fat32.read 内部打印 br=64 但 load_elf 收到 <64
|
||||
# 触发 "failed to read ehdr" —— 跨模块返回值间歇性丢失)
|
||||
_dbrl: t.CArray[t.CChar, 64]
|
||||
viperlib.snprintf(c.Addr(_dbrl), 64, "[elf] read_len=%lu\n", read_len)
|
||||
serial.puts(c.Addr(_dbrl))
|
||||
if read_len < 64:
|
||||
serial.puts("[elf] failed to read ehdr\n")
|
||||
fat32.close(fp)
|
||||
|
||||
@@ -243,6 +243,10 @@ class ViperKernel:
|
||||
viperlib.snprintf(c.Addr(slog), 64, "[main] Hello spawned as pid=%d\n", hello_pid)
|
||||
serial.puts(slog)
|
||||
term_pid: t.CInt = elf.spawn_elf("/APPS/terminal.elf")
|
||||
# [DIAG] spawn_elf 返回 pid=1 但 main 收到 0 —— 跨模块返回值间歇性丢失
|
||||
_dbtp: t.CArray[t.CChar, 64]
|
||||
viperlib.snprintf(c.Addr(_dbtp), 64, "[main] term_pid=%d\n", term_pid)
|
||||
serial.puts(c.Addr(_dbtp))
|
||||
if term_pid < 0:
|
||||
serial.puts("[main] Terminal spawn failed\n")
|
||||
else:
|
||||
|
||||
Reference in new issue
Block a user