1. linux0.12的代码
基于hufeng的可在Ubuntu12.4,gcc4.6.3下编译运行的linux-0.12代码
%3D1%26amp%3Bfilter%3Ddigest
二. bochs的安装及使用
1. ubuntu14.04 64位下安装bochs
-
cong@msi:/tmp$ sudo apt-get install bochs --> 这样安装完成后会运行会出现下面的错误
-
-
Message: dlopen failed for module 'x': file not found
-
cong@msi:/tmp$ sudo apt-get install bochs-x --> 安装完bochs-x后,再运行还会出现下面的错误
-
-
bochs-bin: symbol lookup error: /usr/lib/bochs/plugins/libbx_x.so: undefined symbol: XpmCreatePixmapFromData
-
cong@msi:/tmp$ sudo apt-get install bochs-sdl --> 缺少显示sdl库,仅安装不行,
-
--> 还需要在bochrc中加上display_library: sdl
2. 一个基本的bochrc
cong@msi:/work/oldlinux/linux12$ cat bochrc
-
megs: 32
-
romimage: file=$BXSHARE/BIOS-bochs-latest
-
vgaromimage: file=$BXSHARE/VGABIOS-lgpl-latest
-
floppya: 1_44="Image", status=inserted
-
ata0-master: type=disk, path="rootimage-0.12-hd", mode=flat, cylinders=487, heads=16, spt=63
-
boot: floppy
-
mouse: enabled=0
-
log: ../bochsout.txt
-
panic: action=ask
-
error: action=report
-
info: action=report
-
debug: action=ignore
-
#debug: action=ignore
-
vga_update_interval: 300000
-
display_library: sdl
a. 去http://oldlinux.org/Linux.old/bochs-images/ 下载linux-0.12-080324.zip,
解压出里面的rootimage-0.12-hd,作为硬盘文件系统
b. 上面的$BXSHARE默认设为/usr/share/bochs
所以romimage与vgaromimage的路径都得在/usr/share/bochs/下找到才行
3. bochs下的gdb调试
a. 源码编译出带gdb调试的bochs
-
cong@msi:/work/os/bochs-2.6.8_gdb mkdir install -->将install后的bochs放在这个目录下
-
cong@msi:/work/os/bochs-2.6.8_gdb ./configure --prefix=`pwd`/install --enable-disasm --enable-gdb-stub -->配置成gdb
-
cong@msi:/work/os/bochs-2.6.8_gdb make -j16 && make install
-
cong@msi:/work/os/bochs-2.6.8_gdb ls install
-
bin share
b. bochs的配置文件bochsrc_gdb
-
cong@msi:/work/os/linux12$ diff ./bochrc_fd bochrc_gdb
-
1135a1136
-
> gdbstub: enabled=1, port=1234, text_base=0, data_base=0, bss_base=0 -->默认这个enable=0
c. 运行bochs
-
/work/os/bochs-2.6.8_gdb/install/bin/bochs -q -f ./bochrc_gdb
-
========================================================================
-
Bochs x86 Emulator 2.6.8
-
Built from SVN snapshot on May 3, 2015
-
Compiled on Sep 2 2016 at 11:06:47
-
========================================================================
-
00000000000i[ ] BXSHARE not set. using compile time default '/work/os/bochs-2.6.8_gdb/install/share/bochs'
-
00000000000i[ ] reading configuration from ./bochrc_gdb
-
00000000000e[ ] ./bochrc_gdb:715: ataX-master/slave CHS set to 0/0/0 - autodetection enabled
-
00000000000i[ ] Enabled gdbstub -->enable=1之后会打印Enable
-
00000000000i[ ] installing x module as the Bochs GUI
-
00000000000i[ ] using log file /tmp/bochsout.txt
-
Waiting for gdb connection on port 1234 -->会停在这儿
d. 启动另一个terminal
-
cong@msi:/work/os/linux12$ gdb tools/system
-
Reading symbols from tools/system...done.
-
(gdb) target remote localhost:1234 -->这时bochs端会打印 Connected to 127.0.0.1
-
Remote debugging using localhost:1234
-
0x0000fff0 in sys_mount (dev_name=0x0 <startup_32>, dir_name=0x0 <startup_32>, rw_flag=0) at super.c:231
-
231 iput(dir_i);
-
(gdb) b main
-
Breakpoint 1 at 0x67d8: file init/main.c, line 130.
-
(gdb) c
-
Continuing.
-
-
Breakpoint 1, main () at init/main.c:130
-
130 { /* The startup routine assumes (well, ...) this */
-
(gdb) n
-
135 ROOT_DEV = ORIG_ROOT_DEV;
-
(gdb)
-
136 SWAP_DEV = ORIG_SWAP_DEV;
-
(gdb) p /x ROOT_DEV
-
$1 = 0x21d
e. 为了避免每次都要敲一堆命令,建立一个.gdbinit脚本
-
cong@msi:/work/os/linux12$ cat .gdbinit
-
break main
-
target remote localhost:1234
e.1 发现一个问题,这个.gdbinit脚本不起作用
-
cong@msi:/work/os/linux12$ gdb -q tools/system
-
Reading symbols from tools/system...done.
-
warning: File "/work/os/linux12/.gdbinit" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".
-
To enable execution of this file add
-
add-auto-load-safe-path /work/os/linux12/.gdbinit
-
line to your configuration file "/home/cong/.gdbinit".
-
To completely disable this security protection add
-
set auto-load safe-path /
-
line to your configuration file "/home/cong/.gdbinit".
-
For more information about this security protection see the
-
"Auto-loading safe path" section in the GDB manual. E.g., run from the shell:
-
info "(gdb)Auto-loading safe path"
-
(gdb)
解决方法上面都说了在/home/cong/.gdbinit下加上一行就可以了
-
cong@msi:~$ cat .gdbinit
-
add-auto-load-safe-path /work/os/linux12/.gdbinit
注意: 是在~目录下新建一个.gdbinit,不是在linux0.12的目录下
阅读(1850) | 评论(0) | 转发(0) |