安装bochs debugger GUI

来源:互联网 发布:交通组织优化方案 编辑:程序博客网 时间:2024/06/08 01:24

1.概述

使用apt-get命令安装的bochs只能运行程序,不能debug程序。需要debug程序就必须用源码安装,能debug程序的bochs也分两种,一种是实用命令行debug,一种是可以使用GUI界面调试,相对来说使用GUI来调试更加方便快捷。
安装之前https://sourceforge.net/projects/bochs/files/bochs/2.4.5/下载bochs-2.4.5,并且使用命令安装gcc和gtk:
sudo apt-get install build-essentialsudo apt-get install libgtk2.0-dev 

2.安装boots debugger命令行

<1>先将bochs解压到bochs-2.4.5文件夹下面,让然后进入文件夹bochs-2.4.5使用configure命令配置编译选项:
bochs-2.4.5$./configure   --enable-debugger --enable-disasm
<2>然后make编译
bochs-2.4.5$make
编译的时候会出错:
usr/bin/ld: gui/libgui.a(gtk_enh_dbg_osdep.o): undefined reference to symbol 'pthread_create@@GLIBC_2.1'//lib/i386-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
修改该错误只需要在Makefile中的LIBS后面添加-lpthread,然后重新make即可。

<3>安装:
sudo  make install

<4>检查安装是否成功,运行bochs出现如下信息表示安装成功:
bochs-2.4.5$ bochs========================================================================                       Bochs x86 Emulator 2.4.5              Build from CVS snapshot, on April 25, 2010========================================================================00000000000i[     ] reading configuration from .bochsrc00000000000e[     ] .bochsrc:366: ataX-master/slave CHS set to 0/0/0 - autodetection enabled------------------------------Bochs Configuration: Main Menu------------------------------This is the Bochs Configuration Interface, where you can describe themachine that you want to simulate.  Bochs has already searched for aconfiguration file (typically called bochsrc.txt) and loaded it if itcould be found.  When you are satisfied with the configuration, goahead and start the simulation.You can also start bochs with the -q option to skip these menus.1. Restore factory default configuration2. Read options from...3. Edit options4. Save options to...5. Restore the Bochs state from...6. Begin simulation7. Quit nowPlease choose one: [6] 700000000000i[CTRL ] quit_sim called with exit code 1

<5>如果运行bochs出现错误:
bochsrc:20: display library 'sdl' not available
  只需要将bochs配置文件bochrc中display_library:sdl删除即可。

<6>运行bochs debug程序,所有的debug命令参考点击打开链接

$ bochs -f bochsrc ========================================================================                       Bochs x86 Emulator 2.4.5              Build from CVS snapshot, on April 25, 2010========================================================================00000000000i[     ] reading configuration from bochsrc------------------------------Bochs Configuration: Main Menu------------------------------This is the Bochs Configuration Interface, where you can describe themachine that you want to simulate.  Bochs has already searched for aconfiguration file (typically called bochsrc.txt) and loaded it if itcould be found.  When you are satisfied with the configuration, goahead and start the simulation.You can also start bochs with the -q option to skip these menus.1. Restore factory default configuration2. Read options from...3. Edit options4. Save options to...5. Restore the Bochs state from...6. Begin simulation7. Quit nowPlease choose one: [6] 6....<bochs:7> reax: 0x0000aa55 43605ecx: 0x00090000 589824edx: 0x00000000 0ebx: 0x00000000 0esp: 0x0000ffd6 65494ebp: 0x00000000 0esi: 0x000e46dc 935644edi: 0x0000ffac 65452eip: 0x00007c00eflags 0x00000082: id vip vif ac vm rf nt IOPL=0 of df if tf SF zf af pf cf<bochs:8> sreges:0x0000, dh=0x00009300, dl=0x0000ffff, valid=1Data segment, base=0x00000000, limit=0x0000ffff, Read/Write, Accessedcs:0x0000, dh=0x00009300, dl=0x0000ffff, valid=1Data segment, base=0x00000000, limit=0x0000ffff, Read/Write, Accessedss:0x0000, dh=0x00009300, dl=0x0000ffff, valid=7Data segment, base=0x00000000, limit=0x0000ffff, Read/Write, Accessedds:0x0000, dh=0x00009300, dl=0x0000ffff, valid=1Data segment, base=0x00000000, limit=0x0000ffff, Read/Write, Accessedfs:0x0000, dh=0x00009300, dl=0x0000ffff, valid=1Data segment, base=0x00000000, limit=0x0000ffff, Read/Write, Accessedgs:0x0000, dh=0x00009300, dl=0x0000ffff, valid=1Data segment, base=0x00000000, limit=0x0000ffff, Read/Write, Accessedldtr:0x0000, dh=0x00008200, dl=0x0000ffff, valid=1tr:0x0000, dh=0x00008b00, dl=0x0000ffff, valid=1gdtr:base=0x000fb6a7, limit=0x30idtr:base=0x00000000, limit=0x3ff<bochs:9> nNext at t=12943097(0) [0x00007c02] 0000:7c02 (unk. ctxt): mov ds, ax                ; 8ed8<bochs:10> trace onTracing enabled for CPU0<bochs:11> n(0).[12943097] [0x00007c02] 0000:7c02 (unk. ctxt): mov ds, ax                ; 8ed8Next at t=12943098(0) [0x00007c04] 0000:7c04 (unk. ctxt): mov es, ax                ; 8ec0<bochs:12> n(0).[12943098] [0x00007c04] 0000:7c04 (unk. ctxt): mov es, ax                ; 8ec0Next at t=12943099(0) [0x00007c06] 0000:7c06 (unk. ctxt): call .+2 (0x00007c0b)     ; e80200<bochs:13> trace offTracing disabled for CPU0<bochs:14> nNext at t=12954674(0) [0x00007c09] 0000:7c09 (unk. ctxt): jmp .-2 (0x00007c09)      ; ebfe<bochs:15> info cpueax: 0x00001301 4865ecx: 0x00090010 589840edx: 0x00000000 0ebx: 0x0000000c 12esp: 0x0000ffd6 65494ebp: 0x00007c1e 31774esi: 0x000e46dc 935644edi: 0x0000ffac 65452eip: 0x00007c09eflags 0x00000082: id vip vif ac vm rf nt IOPL=0 of df if tf SF zf af pf cfstatus  word: 0x0000: b c3 TOS0 c2 c1 c0 es sf pe ue oe ze de iecontrol word: 0x0040: inf RC_NEAREST PC_32 pm um om zm dm imtag word:     0x5555operand:      0x0000fip:          0x00000000fcs:          0x0000fdp:          0x00000000fds:          0x0000=>FP0 ST0(0):        raw 0x0000:0000000000000000 (0.0000000000) (ZERO)  FP1 ST1(0):        raw 0x0000:0000000000000000 (0.0000000000) (ZERO)  FP2 ST2(0):        raw 0x0000:0000000000000000 (0.0000000000) (ZERO)  FP3 ST3(0):        raw 0x0000:0000000000000000 (0.0000000000) (ZERO)  FP4 ST4(0):        raw 0x0000:0000000000000000 (0.0000000000) (ZERO)  FP5 ST5(0):        raw 0x0000:0000000000000000 (0.0000000000) (ZERO)  FP6 ST6(0):        raw 0x0000:0000000000000000 (0.0000000000) (ZERO)  FP7 ST7(0):        raw 0x0000:0000000000000000 (0.0000000000) (ZERO)MXCSR: 0x00001f80: ule fuz RC:0 PM UM OM ZM DM IM daz pe ue oe ze de ieXMM[00]: 00000000:00000000:00000000:00000000XMM[01]: 00000000:00000000:00000000:00000000XMM[02]: 00000000:00000000:00000000:00000000XMM[03]: 00000000:00000000:00000000:00000000XMM[04]: 00000000:00000000:00000000:00000000XMM[05]: 00000000:00000000:00000000:00000000XMM[06]: 00000000:00000000:00000000:00000000XMM[07]: 00000000:00000000:00000000:00000000<bochs:16> c00482628000i[     ] Ctrl-C detected in signal handler.Next at t=482628000(0) [0x00007c09] 0000:7c09 (unk. ctxt): jmp .-2 (0x00007c09)      ; ebfe<bochs:17> quit...00482628000i[CMOS ] Last time is 1494514266 (Thu May 11 22:51:06 2017)00482628000i[XGUI ] Exit00482628000i[CTRL ] quit_sim called with exit code 0

3.安装 boots debugger GUI

<1>要安装带GUI的bochs, 首先进入文件夹bochs-2.4.5,然后使用configure命令配置bochs编译选项:
$./configure --with-x11 --with-wx --enable-disasm --enable-all-optimizations --enable-readline  --enable-debugger-gui --enable-x86-debugger --enable-a20-pin --enable-fast-function-calls --enable-debugger

<2>在Makefile中的LIBS后面添加-lpthread,然后make:
bochs-2.4.5$make

<3>安装bochs
sudo  make install

<4>修改bochs配置文件bochrc,在文件最后添加:
display_library: x, options="gui_debug"

<5>运行bochs:
$ bochs -f bochsrc ========================================================================                       Bochs x86 Emulator 2.4.5              Build from CVS snapshot, on April 25, 2010========================================================================00000000000i[     ] reading configuration from bochsrc------------------------------Bochs Configuration: Main Menu------------------------------This is the Bochs Configuration Interface, where you can describe themachine that you want to simulate.  Bochs has already searched for aconfiguration file (typically called bochsrc.txt) and loaded it if itcould be found.  When you are satisfied with the configuration, goahead and start the simulation.You can also start bochs with the -q option to skip these menus.1. Restore factory default configuration2. Read options from...3. Edit options4. Save options to...5. Restore the Bochs state from...6. Begin simulation7. Quit nowPlease choose one: [6] 6
选择6之后出现一个debug窗口,在debug窗口中可以用按钮调试程序,也可以通过输入命令debug:











0 0