基于OSDev Wiki自制内核在QEMU启动无输出及调试异常问题
自制内核无预期输出且GDB调试连接失败
我正在基于osdev.org的代码编写自制内核,但始终无法得到预期输出。
QEMU启动无预期输出
使用以下命令启动内核:
qemu-system-i386 -kernel myos.elf -serial stdio
内核本应输出Hello, kernel World!\n,但实际仅输出:
$ qemu-system-i386 -kernel myos.elf -serial stdio VNC server running on 127.0.0.1:5900
GDB调试连接异常
尝试用GDB调试时,连接远程端后立即断开:
终端1启动QEMU
$ qemu-system-i386 -s -S -kernel myos.elf -serial stdio VNC server running on 127.0.0.1:5900
终端2启动GDB
$PREFIX/bin/i686-elf-gdb ./myos.elf GNU gdb (GDB) 13.1 Copyright (C) 2023 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "--host=x86_64-pc-linux-gnu --target=i686-elf". Type "show configuration" for configuration details. For bug reporting instructions, please see the GDB bug reporting page. Find the GDB manual and other documentation resources online at the official GDB documentation site. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from ./myos.elf... (gdb) target remote 127.0.0.1:5900 Remote debugging using 127.0.0.1:5900 Remote connection closed (gdb)
已做的排查
- 使用
-d int参数查看运行日志,输出包含Servicing hardware INT=0x08,说明内核可能在正常运行,但仍无预期输出。 - 运行环境:VMware上的Ubuntu 22.04,自行编译了binutils、gdb、gcc、qemu、grub等所需工具。
- 代码已尝试两个版本:osdev.org官方Bare Bones代码,以及另一社区贡献的Bare Bones代码,均出现相同问题。
希望找出问题根源并得到简单解释。
内容的提问来源于stack exchange,提问作者PeterLiuAll
相关产品推荐
相关产品推荐

