安装bochs debugger GUI

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-essential
sudo 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 .bochsrc
00000000000e[     ] .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 the
machine that you want to simulate.  Bochs has already searched for a
configuration file (typically called bochsrc.txt) and loaded it if it
could be found.  When you are satisfied with the configuration, go
ahead and start the simulation.

You can also start bochs with the -q option to skip these menus.

1. Restore factory default configuration
2. Read options from...
3. Edit options
4. Save options to...
5. Restore the Bochs state from...
6. Begin simulation
7. Quit now

Please choose one: [6] 7
00000000000i[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 the
machine that you want to simulate.  Bochs has already searched for a
configuration file (typically called bochsrc.txt) and loaded it if it
could be found.  When you are satisfied with the configuration, go
ahead and start the simulation.

You can also start bochs with the -q option to skip these menus.

1. Restore factory default configuration
2. Read options from...
3. Edit options
4. Save options to...
5. Restore the Bochs state from...
6. Begin simulation
7. Quit now

Please choose one: [6] 6
....
<bochs:7> r
eax: 0x0000aa55 43605
ecx: 0x00090000 589824
edx: 0x00000000 0
ebx: 0x00000000 0
esp: 0x0000ffd6 65494
ebp: 0x00000000 0
esi: 0x000e46dc 935644
edi: 0x0000ffac 65452
eip: 0x00007c00
eflags 0x00000082: id vip vif ac vm rf nt IOPL=0 of df if tf SF zf af pf cf
<bochs:8> sreg
es:0x0000, dh=0x00009300, dl=0x0000ffff, valid=1
	Data segment, base=0x00000000, limit=0x0000ffff, Read/Write, Accessed
cs:0x0000, dh=0x00009300, dl=0x0000ffff, valid=1
	Data segment, base=0x00000000, limit=0x0000ffff, Read/Write, Accessed
ss:0x0000, dh=0x00009300, dl=0x0000ffff, valid=7
	Data segment, base=0x00000000, limit=0x0000ffff, Read/Write, Accessed
ds:0x0000, dh=0x00009300, dl=0x0000ffff, valid=1
	Data segment, base=0x00000000, limit=0x0000ffff, Read/Write, Accessed
fs:0x0000, dh=0x00009300, dl=0x0000ffff, valid=1
	Data segment, base=0x00000000, limit=0x0000ffff, Read/Write, Accessed
gs:0x0000, dh=0x00009300, dl=0x0000ffff, valid=1
	Data segment, base=0x00000000, limit=0x0000ffff, Read/Write, Accessed
ldtr:0x0000, dh=0x00008200, dl=0x0000ffff, valid=1
tr:0x0000, dh=0x00008b00, dl=0x0000ffff, valid=1
gdtr:base=0x000fb6a7, limit=0x30
idtr:base=0x00000000, limit=0x3ff
<bochs:9> n
Next at t=12943097
(0) [0x00007c02] 0000:7c02 (unk. ctxt): mov ds, ax                ; 8ed8
<bochs:10> trace on
Tracing enabled for CPU0
<bochs:11> n
(0).[12943097] [0x00007c02] 0000:7c02 (unk. ctxt): mov ds, ax                ; 8ed8
Next 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                ; 8ec0
Next at t=12943099
(0) [0x00007c06] 0000:7c06 (unk. ctxt): call .+2 (0x00007c0b)     ; e80200
<bochs:13> trace off
Tracing disabled for CPU0
<bochs:14> n
Next at t=12954674
(0) [0x00007c09] 0000:7c09 (unk. ctxt): jmp .-2 (0x00007c09)      ; ebfe
<bochs:15> info cpu
eax: 0x00001301 4865
ecx: 0x00090010 589840
edx: 0x00000000 0
ebx: 0x0000000c 12
esp: 0x0000ffd6 65494
ebp: 0x00007c1e 31774
esi: 0x000e46dc 935644
edi: 0x0000ffac 65452
eip: 0x00007c09
eflags 0x00000082: id vip vif ac vm rf nt IOPL=0 of df if tf SF zf af pf cf
status  word: 0x0000: b c3 TOS0 c2 c1 c0 es sf pe ue oe ze de ie
control word: 0x0040: inf RC_NEAREST PC_32 pm um om zm dm im
tag word:     0x5555
operand:      0x0000
fip:          0x00000000
fcs:          0x0000
fdp:          0x00000000
fds:          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 ie
XMM[00]: 00000000:00000000:00000000:00000000
XMM[01]: 00000000:00000000:00000000:00000000
XMM[02]: 00000000:00000000:00000000:00000000
XMM[03]: 00000000:00000000:00000000:00000000
XMM[04]: 00000000:00000000:00000000:00000000
XMM[05]: 00000000:00000000:00000000:00000000
XMM[06]: 00000000:00000000:00000000:00000000
XMM[07]: 00000000:00000000:00000000:00000000
<bochs:16> c
00482628000i[     ] 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 ] Exit
00482628000i[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 the
machine that you want to simulate.  Bochs has already searched for a
configuration file (typically called bochsrc.txt) and loaded it if it
could be found.  When you are satisfied with the configuration, go
ahead and start the simulation.

You can also start bochs with the -q option to skip these menus.

1. Restore factory default configuration
2. Read options from...
3. Edit options
4. Save options to...
5. Restore the Bochs state from...
6. Begin simulation
7. Quit now

Please choose one: [6] 6
选择6之后出现一个debug窗口,在debug窗口中可以用按钮调试程序,也可以通过输入命令debug:











  • 4
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值