操作系统真相还原之bochs环境配置

2022-09-21  本文已影响0人  mecury

bochs 2.6.2 下载地址:https://sourceforge.net/projects/bochs/files/bochs/2.6.2/

configure

./configure \
--prefix=/home/lihaifei/bochs-2.6.2 \
--enable-debugger \
--enable-disasm \
--enable-iodebug \
--enable-x86-debugger \
--with-x \
--with-x11

报错1: configure: error: no acceptable C compiler found in $PATH

sudo yum install gcc

报错2:configure: error: C++ preprocessor "/lib/cpp" fails sanity check

yum install -y gcc-c++

make

报错1: gtk_enh_dbg_osdep.cc:20:21: fatal error: gtk/gtk.h: No such file or directory

sudo yum install gtk2 gtk2-devel gtk2-devel-docs

需要重新执行 configure

** 报错2:**

/usr/bin/ld: gui/libgui.a(gtk_enh_dbg_osdep.o): undefined reference to symbol 'pthread_create@@GLIBC_2.2.5'
//usr/lib64/libpthread.so.0: error adding symbols: DSO missing from command line

解决:vim Makefile 文件, 在 92 行增加 -lphread.然后重新 make

bochs初启动

# 设置虚拟机内存为32MB
megs: 32
# 设置BIOS镜像
romimage: file=$BXSHARE/BIOS-bochs-latest 
# 设置VGA BIOS镜像
vgaromimage: file=$BXSHARE/VGABIOS-lgpl-latest
# 设置从硬盘启动
boot: disk
# 设置日志文件
log: bochsout.txt
# 关闭鼠标
mouse: enabled=0
# 打开键盘
keyboard: type=mf, serial_delay=250
# 设置硬盘
ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
# 添加gdb远程调试支持
gdbstub: enabled=1, port=1234, text_base=0, data_base=0, bss_base=0

执行步骤:

  1. bin/bochs -f ./bochsrc.disk
  2. bin/bximage -hd -mode='flat' -size=60 -q hd60M.img
  3. 在代码文件中ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14增加:
    ata0-master: type=disk, path="hd60M.img", mode=flat, cylinders=121, heads=16, spt=63
  4. bin/bochs -f ./bochsrc.disk,执行成功后按下 c ,继续下一步。

问题1:

[lihaifei@192 bochs-2.6.2]$ bin/bochs
========================================================================
                       Bochs x86 Emulator 2.6.2
                Built from SVN snapshot on May 26, 2013
                  Compiled on Sep 20 2022 at 09:43:08
========================================================================
00000000000i[     ] reading configuration from .bochsrc
00000000000e[     ] .bochsrc:192: invalid choice 'core2_penryn_t9600' parameter 'model'
00000000000p[     ] >>PANIC<< .bochsrc:192: cpu directive malformed.
00000000000e[CTRL ] notify called, but no bxevent_callback function is registered
========================================================================
Bochs is exiting with the following message:
[     ] .bochsrc:192: cpu directive malformed.
========================================================================
00000000000i[CPU0 ] CPU is in real mode (active)
00000000000i[CPU0 ] CS.mode = 16 bit
00000000000i[CPU0 ] SS.mode = 16 bit
00000000000i[CPU0 ] EFER   = 0x00000000
00000000000i[CPU0 ] | EAX=00000000  EBX=00000000  ECX=00000000  EDX=00000000
00000000000i[CPU0 ] | ESP=00000000  EBP=00000000  ESI=00000000  EDI=00000000
00000000000i[CPU0 ] | IOPL=0 id vip vif ac vm rf nt of df if tf sf ZF af PF cf
00000000000i[CPU0 ] | SEG sltr(index|ti|rpl)     base    limit G D
00000000000i[CPU0 ] |  CS:0000( 0000| 0|  0) 00000000 00000000 0 0
00000000000i[CPU0 ] |  DS:0000( 0000| 0|  0) 00000000 00000000 0 0
00000000000i[CPU0 ] |  SS:0000( 0000| 0|  0) 00000000 00000000 0 0
00000000000i[CPU0 ] |  ES:0000( 0000| 0|  0) 00000000 00000000 0 0
00000000000i[CPU0 ] |  FS:0000( 0000| 0|  0) 00000000 00000000 0 0
00000000000i[CPU0 ] |  GS:0000( 0000| 0|  0) 00000000 00000000 0 0
00000000000i[CPU0 ] | EIP=00000000 (00000000)
00000000000i[CPU0 ] | CR0=0x00000000 CR2=0x00000000
00000000000i[CPU0 ] | CR3=0x00000000 CR4=0x00000000
bx_dbg_read_linear: physical memory read error (phy=0x000000000000, lin=0x00000000)
00000000000i[CTRL ] quit_sim called with exit code 1

在bochs启动过程中出现错误“invalid choise core2_penryn_t9600”引起“cpu directive malformed”

解决:

1. bochs -help cpu
将显示出所有支持的CPU类型
2. 修改.bochsrc文件中cpu: model=core2+penryn_t9600为cpu: model=上一条查到的所支持的CPU类型之一
————————————————
版权声明:本文为CSDN博主「lvsi12」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/lvsi12/article/details/24393089

问题2 :Bochs is not compiled with gdbstub support

[lihaifei@192 bochs-2.6.2]$ bin/bochs -f ./bochsrc.disk
========================================================================
                       Bochs x86 Emulator 2.6.2
                Built from SVN snapshot on May 26, 2013
                  Compiled on Sep 20 2022 at 09:43:08
========================================================================
00000000000i[     ] reading configuration from ./bochsrc.disk
00000000000e[     ] ./bochsrc.disk:12: 'keyboard_mapping' will be replaced by new 'keyboard' option.
00000000000p[     ] >>PANIC<< ./bochsrc.disk:16: Bochs is not compiled with gdbstub support
00000000000e[CTRL ] notify called, but no bxevent_callback function is registered
========================================================================
Bochs is exiting with the following message:
[     ] ./bochsrc.disk:16: Bochs is not compiled with gdbstub support
========================================================================
00000000000i[CPU0 ] CPU is in real mode (active)
00000000000i[CPU0 ] CS.mode = 16 bit
00000000000i[CPU0 ] SS.mode = 16 bit
00000000000i[CPU0 ] EFER   = 0x00000000
00000000000i[CPU0 ] | EAX=00000000  EBX=00000000  ECX=00000000  EDX=00000000
00000000000i[CPU0 ] | ESP=00000000  EBP=00000000  ESI=00000000  EDI=00000000
00000000000i[CPU0 ] | IOPL=0 id vip vif ac vm rf nt of df if tf sf ZF af PF cf
00000000000i[CPU0 ] | SEG sltr(index|ti|rpl)     base    limit G D
00000000000i[CPU0 ] |  CS:0000( 0000| 0|  0) 00000000 00000000 0 0
00000000000i[CPU0 ] |  DS:0000( 0000| 0|  0) 00000000 00000000 0 0
00000000000i[CPU0 ] |  SS:0000( 0000| 0|  0) 00000000 00000000 0 0
00000000000i[CPU0 ] |  ES:0000( 0000| 0|  0) 00000000 00000000 0 0
00000000000i[CPU0 ] |  FS:0000( 0000| 0|  0) 00000000 00000000 0 0
00000000000i[CPU0 ] |  GS:0000( 0000| 0|  0) 00000000 00000000 0 0
00000000000i[CPU0 ] | EIP=00000000 (00000000)
00000000000i[CPU0 ] | CR0=0x00000000 CR2=0x00000000
00000000000i[CPU0 ] | CR3=0x00000000 CR4=0x00000000
bx_dbg_read_linear: physical memory read error (phy=0x000000000000, lin=0x00000000)
00000000000i[CTRL ] quit_sim called with exit code 1

解决方法:
注释最后一行,禁用gdb调试。参考:https://zhuanlan.zhihu.com/p/390664291

上一篇下一篇

猜你喜欢

热点阅读