环境: ubuntu 9.04 或 redhat 9.0
bochs: bochs-2.4.6.tar.gz 更新了bochs-2.6.8的安装
一、ubuntu 下apt安装
1.1 编译环境
-
cong@msi:/work/os/bak/bochs-2.6.8$ sudo apt-get install build-essential
-
cong@msi:/work/os/bak/bochs-2.6.8$ sudo apt-get install xorg-dev -->这个必须安装
-
cong@msi:/work/os/bak/bochs-2.6.8$ sudo apt-get install libgtk2.0-dev
1.2 编译不带任何调试的bochs
-
cong@msi:/work/os/bak/bochs-2.6.8$ mkdir install -->以后install把生成的bochs都放在这个目录下面
-
cong@msi:/work/os/bak/bochs-2.6.8$ ./configure --prefix=`pwd`/install
-
cong@msi:/work/os/bak/bochs-2.6.8$ make -j8 -->直接编译即可
-
cong@msi:/work/os/bak/bochs-2.6.8$ make install
1.3 出错及问题解决
-
a.出错: ERROR: X windows gui was selected, but X windows libraries were not found.
-
root@ubuntu:~# aptitude install xorg-dev
-
-
b.出错: ERROR: pkg-config was not found, or unable to access the gtk+-2.0 package.
-
root@ubuntu:~# aptitude install libgtk2.0-dev
-
-
c.在configure时同时配了debugger&&gdb-stub会有如下错误./configure --enable-gdb-stub --enable-disasm --enable-debugger
-
configure: error: --enable-debugger and --enable-gdb-stub are mutually exclusive
1.4 编译带asm调试功能的bochs
-
cong@msi:/work/os/bak/bochs-2.6.8_asm$ ./configure --prefix=`pwd`/install --enable-debugger --enable-disasm
如果加上--enable-plugins会出现
>>PANIC<< dlopen failed for module 'unmapped': file not found
1.5
编译带gdb调试功能的bochs
-
cong@msi:/work/os/bak/bochs-2.6.8_gdb$ ./configure --prefix=`pwd`/install --enable-disasm --enable-gdb-stub
-
cong@msi:/work/os/bak/bochs-2.6.8_gdb$ make -j8
-
cong@msi:/work/os/bak/bochs-2.6.8_gdb$ make install
1.6 注意:
a.用apt-get install 安装的bochs 版本不能调试,如果需要加调试功能需要从源码添加编译选项
b. Linux 没有bochsbgb工具,在configure时加了enable-debugger选项,重新编译后的bochs就带有调试功能。
二、Redhat 9.0 编译安装
环境: RedHat 9.0
gcc版本: gcc (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
2.1 编译安装 bochs 不带调试信息
tar xvfz bochs-2.3.5.tar.gz
cd bochs-2.3.5
./configure --prefix=/opt/bochs/run
make ; make install
2.2编译安装 bochs 带汇编调试
./configure --prefix=/opt/bochs/debug --enable-plugins --enable-debugger --enable-disasm
make
make install
2.3 编译安装 bochs 带gdb调试
./configure --prefix=/opt/bochs/gdbstub --enable-plugins --enable-disasm --enable-gdb-stub
make
make install
注意:这里编译两次bochs 是因为如果一步到位configure
./configure --enable-gdb-stub --enable-disasm --enable-debugger
它会很生气
configure: error: --enable-debugger and --enable-gdb-stub are mutually exclusive
2.4
gdb+bochs调试linux0.11的总出现缺页中断问题
a. bochs-2.6.8下修改 src/gdbstub.cc,增加如下红色部分
b. gdbstub.cc L492
-
else if (last_stop_reason == GDBSTUB_STOP_NO_REASON)
-
{
-
write_signal(&buf[1], SIGSEGV);
-
}
c. 编译安装之后
启动gdb,在gdb的shell中输入 handle SIGSEGV nostop noprint ignore 即可
以上出自《gdb+bochs调试linux0.11的总出现缺页中断问题。》
http://blog.chinaunix.net/uid-7480243-id-2051574.html
3. 在RedHat9.0下编译时会出现如下的错误:
/usr/X11R6/lib/libXrandr.so: undefined reference to `XextAddDisplay'
/usr/X11R6/lib/libXrandr.so: undefined reference to `XextFindDisplay'
/usr/X11R6/lib/libXrandr.so: undefined reference to `XRenderSetSubpixelOrder'
/usr/X11R6/lib/libXrandr.so: undefined reference to `XextRemoveDisplay'
/usr/X11R6/lib/libXrandr.so: undefined reference to `XMissingExtension'
-
提示缺少库,编个小脚本练习一下。
-
#******test.sh ******#
-
#!/bin/sh
-
for file in `find /usr/X11R6/lib/*.a`
-
do
-
echo $file
-
nm $file | grep XextAddDisplay
-
done
-
-
执行:
-
[root@localhost tmp]# ./test.sh
-
/usr/X11R6/lib/libGL.a
-
U XextAddDisplay
-
U XextAddDisplay
-
/usr/X11R6/lib/libXext.a
-
00000060 T XextAddDisplay
-
U XextAddDisplay
-
/usr/X11R6/lib/libXfontcache.a
-
U XextAddDisplay
-
/usr/X11R6/lib/libXft.a
-
/usr/X11R6/lib/libXi.a
-
U XextAddDisplay
-
/usr/X11R6/lib/libXinerama.a
-
U XextAddDisplay
-
-
上述打印中:
-
U XextAddDisplay 说明XextAddDisplay 没有定义
-
00000060 T XextAddDisplay 说明 XextAddDisplay己定义
依次grep 可以找出缺失的两个库 -lXext -lXrender 在Makefile中加上就可以了。
GUI_LINK_OPTS_X = $(X_LIBS) $(X_PRE_LIBS) -lX11 $(XPM_LIB) -lXrandr -lXext -lXrender
三.bochs调试指令
-
<bochs:1> help
-
h|help - show list of debugger commands
-
h|help command - show short command description
-
-*- Debugger control -*-
-
help, q|quit|exit, set, instrument, show, trace, trace-reg,
-
trace-mem, u|disasm, ldsym, slist
-
-*- Execution control -*-
-
c|cont|continue, s|step, p|n|next, modebp, vmexitbp
-
-*- Breakpoint management -*-
-
vb|vbreak, lb|lbreak, pb|pbreak|b|break, sb, sba, blist,
-
bpe, bpd, d|del|delete, watch, unwatch
-
-*- CPU and memory contents -*-
-
x, xp, setpmem, writemem, crc, info,
-
r|reg|regs|registers, fp|fpu, mmx, sse, sreg, dreg, creg,
-
page, set, ptime, print-stack, ?|calc
-
-*- Working with bochs param tree -*-
-
show "param", restore
3.1 查看内存中的数据
-
<bochs:2> help x
-
x /nuf <addr> - examine memory at linear address
-
xp /nuf <addr> - examine memory at physical address
-
nuf is a sequence of numbers (how much values to display)
-
and one or more of the [mxduotcsibhwg] format specificators:
-
x,d,u,o,t,c,s,i select the format of the output (they stand for hex, decimal, unsigned, octal, binary, char, asciiz, instr)
-
b,h,w,g select the size of a data element (for byte, half-word, word and giant word)
-
m selects an alternative output format (memory dump)
a. 例如要查看0x102000处的数据-->按16进制4字节打印
-
<bochs:3> x /8wx 0x102000
-
0x00102000 <bogus+ 0>: 0x00000007 0x00001007 0x00002007 0x00003007
-
0x00102010 <bogus+ 16>: 0x00004007 0x00000000 0x00000000 0x00000000
b.
例如要查看0x102000处的数据-->按16进制单字节打印
-
<bochs:4> x /8bx 0x102000
-
0x00102000 <bogus+ 0>: 0x07 0x00 0x00 0x00 0x07 0x10 0x00 0x00
3.2 反汇编
-
<bochs:5> help u
-
u|disasm [/count] <start> <end> - disassemble instructions for given linear address
-
Optional 'count' is the number of disassembled instructions
-
u|disasm switch-mode - switch between Intel and AT&T disassembler syntax
-
u|disasm hex on/off - control disasm offsets and displacements format
-
u|disasm size = n - tell debugger what segment size [16|32|64] to use
-
when "disassemble" command is used.
a. 例如要反汇编当前指令之后的32条指令
-
<bochs:6> u /32
-
00100035: ( ): add eax, 0x00001000 ; 0500100000
-
0010003a: ( ): cmp edi, 0x00104000 ; 81ff00401000
b. 例如要反汇编0x100000之后的32条指令
-
<bochs:7> u /32 0x100000
-
00100000: ( ): cld ; fc
-
00100001: ( ): mov eax, 0x00000018 ; b818000000
3.3设断点
-
<bochs:8> help b
-
p|pb|break|pbreak <addr> - set a physical address instruction breakpoint
-
<bochs:9> help lb
-
lb|lbreak <addr> - set a linear address instruction breakpoint
lb 0x100000
b 0x7c00
阅读(5680) | 评论(0) | 转发(0) |