Centos 6.0 源码编译安装 bochs -2.5.1 有调试功能


下载 bochs -2.5.1
http://sourceforge.net/projects/bochs/files/bochs/

[root@localhost bochs-2.5.1]# ./configure --enable-debugger --enable-disasm --with-wx
[root@localhost bochs-2.5.1]# make
[root@localhost bochs-2.5.1]# make install

#############  下面命令可以不执行

[root@localhost bochs-2.5.1]# find / -name bochs
/usr/local/bin/bochs
/usr/local/share/doc/bochs
/usr/local/share/bochs
[root@localhost bochs-2.5.1]#

[root@localhost bochs-2.5.1]# cat /etc/redhat-release
CentOS Linux release 6.0 (Final)
[root@localhost bochs-2.5.1]# make uninstall
rm -rf /usr/local/share/bochs
rm -rf /usr/local/share/doc/bochs
rm -rf /usr/local/lib/bochs
for i in bochs bximage bxcommit bochs-dlx; do rm -f /usr/local/bin/$i; done
for i in bochs bximage bxcommit bochs-dlx; do rm -f /usr/local/share/man/man1/$i.1.gz; done
for i in bochsrc; do rm -f /usr/local/share/man/man5/$i.5.gz; done
[root@localhost bochs-2.5.1]#

#############  上面命令可以不执行

###### 下载 bootimage-0.11-20040305  和  rootimage-0.11-20040305

下载 bootroot-0.11
http://www.oldlinux.org/Linux.old/images/

[root@localhost ~]# gedit bochsrc               //编辑 bochs 配置文件,内容如下红色字体
[root@localhost ~]# cat bochsrc                  //查看 bochs 配置文件的内容

###############################################################
# Configuration file for Bochs
###############################################################

# how much memory the emulated machine will have
megs: 32

# filename of ROM images
romimage: file=/usr/local/share/bochs/BIOS-bochs-latest
vgaromimage: file=/usr/local/share/bochs/VGABIOS-lgpl-latest

# what disk images will be used
# floppya: 1_44=/root/bootimage-0.11-20040305, status=inserted
# floppyb: 1_44=/root/rootimage-0.11-20040305, status=inserted
floppya: 1_44=/root/bootroot-0.11, status=inserted

# choose the boot disk.
boot: a

# where do we send log messages?
log: bochsout.txt

# disable the mouse
mouse: enabled=1

# enable key mapping, using US layout as default.
keyboard_mapping: enabled=1, map=/usr/local/share/bochs/keymaps/x11-pc-us.map

#enabled debug using xchg bx, bx

#magic_break:enabled=1

###########################################################


[root@localhost ~]# bochs -f bochsrc

当虚拟机启动后,会在第一条指令执行前暂停下来,在PC中一般在f000:fff0地址处,这个地址所对应的指令是jmp far f000:e05b,控制台的输出如下

(0) [0x00000000fffffff0] f000:fff0 (unk. ctxt): jmp far f000:e05b         ; ea5be000f0

  此时只要输入“s”再回车就可以执行这条指令,如果想要程序流一直执行下去直到断点才停,可以输入“c" 再回车,程序执行后将停在断点处。设置断点方法如下

b 0x7c00

  表示在地址为0x7c00处设置一个断点,指令执行到地址为0x7c00处将暂停。

  "n"也是单步执行指令,但遇到函数后将跳过函数体,不会单步进入函数中。

更详细的信息可查阅Bochs的帮助文档。



到此成功




配置bochs出现的个错误及解决办法

当启用bochs 的debugger时,配置./configure --enable-debugger后make就出现下面的错误:

gui/libgui.a(gtk_enh_dbg_osdep.o): In function `MakeGTKthreads()':
/home/bcos/Desktop/bochs-test/bochs-2.4.pre1/gui/gtk_enh_dbg_osdep.cc:2120: undefined reference to `pthread_create'
collect2: ld returned 1 exit status
make: *** [bochs] Error 1

解决方法1:修改"Makefile.in" 92 和 93行 为 "CC = @CC@ -pthread" and "CXX = @CXX@ -pthread"

解决方法2:在Makefile.in中183行

bochs@EXE@: @IODEV_LIB_VAR@ @DEBUGGER_VAR@ \
cpu/libcpu.a memory/libmemory.a gui/libgui.a \
@DISASM_VAR@ @INSTRUMENT_VAR@ $(BX_OBJS) \
$(SIMX86_OBJS) @FPU_VAR@ @GDBSTUB_VAR@ @PLUGIN_VAR@
@LINK@ @EXPORT_DYNAMIC@ $(BX_OBJS) $(SIMX86_OBJS) \
@IODEV_LIB_VAR@ @DEBUGGER_VAR@ cpu/libcpu.a memory/libmemory.a gui/libgui.a \
@DISASM_VAR@ @INSTRUMENT_VAR@ @PLUGIN_VAR@ \
@GDBSTUB_VAR@ @FPU_VAR@ \
@NONPLUGIN_GUI_LINK_OPTS@ \
$(MCH_LINK_FLAGS) \
$(SIMX86_LINK_FLAGS) \
$(READLINE_LIB) \
$(EXTRA_LINK_OPTS) \
$(LIBS)

在最后$(LIBS)后面加上 \ -lpthread如下:

bochs@EXE@: @IODEV_LIB_VAR@ @DEBUGGER_VAR@ \
cpu/libcpu.a memory/libmemory.a gui/libgui.a \
@DISASM_VAR@ @INSTRUMENT_VAR@ $(BX_OBJS) \
.
.
.
$(LIBS)\
-lpthread

即可编译通过。

 

注意:Makefile.in就是用于configure来生成Makefile的,所以修改这个文件后,

需要重新执行:./configure --enable-debugger 来生成Makefile,

如果是在configure后修改Makefile.in,然后执行make,这个时候的Makefile还是编译出错。



<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
阅读(2164) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~
评论热议
posted @ 2016-03-30 10:36  张同光  阅读(168)  评论(0编辑  收藏  举报