From 364daa111b48aa0bccdc259a32354b4d3183ffcc Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Thu, 27 Aug 2026 01:11:05 +0800 Subject: [PATCH] =?UTF-8?q?debug(fat32,elf):=20win=5Fread=20=E6=89=93?= =?UTF-8?q?=E5=8D=B0=20abs=5Fsector/hidden=5Fsectors/win=20=E5=89=8D4?= =?UTF-8?q?=E5=AD=97=E8=8A=82=EF=BC=88win[0..1]=20=E8=A2=AB=E6=B8=85?= =?UTF-8?q?=E9=9B=B6=EF=BC=89=EF=BC=9Bnot=20x86=5F64=20=E5=88=86=E6=94=AF?= =?UTF-8?q?=20dump=20ehdr=20=E5=89=8D20=E5=AD=97=E8=8A=82=EF=BC=88read=5Fl?= =?UTF-8?q?en=3D64=20=E4=BD=86=E5=86=85=E5=AE=B9=E9=94=99=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VKernel/Kernel/drivers/fs/fat32/fat32_types.vp | 7 +++++++ VKernel/Kernel/execrunner/elf.vp | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/VKernel/Kernel/drivers/fs/fat32/fat32_types.vp b/VKernel/Kernel/drivers/fs/fat32/fat32_types.vp index 75f89c5..71eac35 100644 --- a/VKernel/Kernel/drivers/fs/fat32/fat32_types.vp +++ b/VKernel/Kernel/drivers/fs/fat32/fat32_types.vp @@ -360,6 +360,13 @@ class volinfo: res2: DRESULT = diskio.read(self.pdrv, win_addr, t.CUInt32T(abs_sector), 1) self.lock.unlock() if res2 != DRESULT.RES_OK: return FRESULT.FR_DISK_ERR + # [DIAG] 定位 win[0..1] 被清零(L271 win=00 00 20...):区分读错扇区 + # vs 读后被覆盖——打印 abs_sector 与读后 win 前 4 字节。 + _dwr: t.CArray[t.CChar, 96] + viperlib.snprintf(c.Addr(_dwr), 96, "[wr] sec=%lx abs=%lx hid=%lx w0=%02x %02x %02x %02x\n", + sector, abs_sector, t.CUInt64T(self.hidden_sectors), + self.win[0], self.win[1], self.win[2], self.win[3]) + serial.puts(c.Addr(_dwr)) self.winsect = sector return FRESULT.FR_OK diff --git a/VKernel/Kernel/execrunner/elf.vp b/VKernel/Kernel/execrunner/elf.vp index fedc766..a2b4aca 100644 --- a/VKernel/Kernel/execrunner/elf.vp +++ b/VKernel/Kernel/execrunner/elf.vp @@ -175,6 +175,16 @@ def load_elf(path: t.CConst | str, do_map: t.CInt = 1) -> t.CVoid | t.CPtr: if ehdr.e_machine != EM_X86_64: serial.puts("[elf] not x86_64\n") + # [DIAG] e_machine 错:dump ehdr 前 24 字节(read_len=64 正确但内容错) + _dbg_em: t.CArray[t.CChar, 128] + viperlib.snprintf(c.Addr(_dbg_em), 128, + "[elf] ehdr=%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x rl=%lu\n", + ehdr_buf[0], ehdr_buf[1], ehdr_buf[2], ehdr_buf[3], + ehdr_buf[4], ehdr_buf[5], ehdr_buf[6], ehdr_buf[7], + ehdr_buf[8], ehdr_buf[9], ehdr_buf[10], ehdr_buf[11], + ehdr_buf[12], ehdr_buf[13], ehdr_buf[14], ehdr_buf[15], + ehdr_buf[16], ehdr_buf[17], ehdr_buf[18], ehdr_buf[19], read_len) + serial.puts(c.Addr(_dbg_em)) fat32.close(fp) return None