You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

启动qemu-system-x86_64并GDB附加后,设置i8086架构报错求解决

解决GDB切换到i8086架构失败的问题

问题场景

启动qemu-system-x86_64 -S -s并通过GDB attach到虚拟机后,执行set architecture i8086时出现以下错误:

warning: Selected architecture i8086 is not compatible with reported target architecture i386:x86-64
warning: A handler for the OS ABI "GNU/Linux" is not built into this configuration of GDB. Attempting to continue with the default i8086 settings.
Architecture `i8086' not recognized.
The target architecture is set automatically (currently i386:x86-64)

原因分析

  • QEMU启动的x86_64虚拟机默认运行在64位模式,GDB自动识别为i386:x86-64架构,强制切换到i8086会触发架构不兼容警告。
  • 当前GDB编译时未包含i8086架构的OS ABI处理模块,导致无法识别该架构。

解决方案

1. 让QEMU启动时直接进入实模式

若调试目标是实模式代码,启动QEMU时添加参数强制进入实模式:

qemu-system-x86_64 -S -s -cpu qemu64,+vm86

或者使用i386版本的QEMU模拟纯实环境:

qemu-system-i386 -S -s -cpu 486

重新启动后用GDB attach,执行set architecture i8086即可正常生效。

2. 编译支持i8086 ABI的GDB版本

若必须使用x86_64 QEMU且需切换i8086架构,需重新编译GDB并启用对应支持:

  1. 下载GDB稳定版源码(如12.1)
  2. 配置编译选项:
./configure --enable-targets=i8086-linux
  1. 编译安装:
make
sudo make install

安装完成后,再次执行set architecture i8086即可正常识别。

3. 无需切换架构的实模式调试

若仅需调试实模式代码,可直接通过指定内存地址访问实模式代码段,无需切换架构:

x/10i 0x7c00  # 查看MBR区域的实模式指令

内容的提问来源于stack exchange,提问作者leakerlee

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.25 21:06:28