Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2159590
  • 博文数量: 438
  • 博客积分: 3871
  • 博客等级: 中校
  • 技术积分: 6075
  • 用 户 组: 普通用户
  • 注册时间: 2011-09-10 00:11
个人简介

邮箱: wangcong02345@163.com

文章分类

全部博文(438)

文章存档

2017年(15)

2016年(119)

2015年(91)

2014年(62)

2013年(56)

2012年(79)

2011年(16)

分类: LINUX

2015-01-15 13:42:51

1. linux0.12的代码
基于hufeng的可在Ubuntu12.4,gcc4.6.3下编译运行的linux-0.12代码
%3D1%26amp%3Bfilter%3Ddigest

二. bochs的安装及使用
1. ubuntu14.04 64位下安装bochs
  1. cong@msi:/tmp$ sudo apt-get install bochs          --> 这样安装完成后会运行会出现下面的错误

  2. Message: dlopen failed for module 'x': file not found
  3. cong@msi:/tmp$ sudo apt-get install bochs-x       --> 安装完bochs-x后,再运行还会出现下面的错误

  4. bochs-bin: symbol lookup error: /usr/lib/bochs/plugins/libbx_x.so: undefined symbol: XpmCreatePixmapFromData
  5. cong@msi:/tmp$ sudo apt-get install bochs-sdl    --> 缺少显示sdl库,仅安装不行,
  6.                                                  --> 还需要在bochrc中加上display_library: sdl
2. 一个基本的bochrc
cong@msi:/work/oldlinux/linux12$ cat bochrc
  1. megs: 32
  2. romimage: file=$BXSHARE/BIOS-bochs-latest
  3. vgaromimage: file=$BXSHARE/VGABIOS-lgpl-latest
  4. floppya: 1_44="Image", status=inserted
  5. ata0-master: type=disk, path="rootimage-0.12-hd", mode=flat, cylinders=487, heads=16, spt=63
  6. boot: floppy
  7. mouse: enabled=0
  8. log: ../bochsout.txt
  9. panic: action=ask
  10. error: action=report
  11. info: action=report
  12. debug: action=ignore
  13. #debug: action=ignore
  14. vga_update_interval: 300000
  15. 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
  1. cong@msi:/work/os/bochs-2.6.8_gdb mkdir install -->将install后的bochs放在这个目录下
  2. cong@msi:/work/os/bochs-2.6.8_gdb ./configure --prefix=`pwd`/install --enable-disasm --enable-gdb-stub -->配置成gdb
  3. cong@msi:/work/os/bochs-2.6.8_gdb make -j16 && make install
  4. cong@msi:/work/os/bochs-2.6.8_gdb ls install
  5. bin share
b. bochs的配置文件bochsrc_gdb
  1. cong@msi:/work/os/linux12$ diff ./bochrc_fd bochrc_gdb
  2. 1135a1136
  3. > gdbstub: enabled=1, port=1234, text_base=0, data_base=0, bss_base=0    -->默认这个enable=0
c. 运行bochs
  1. /work/os/bochs-2.6.8_gdb/install/bin/bochs -q -f ./bochrc_gdb
  2. ========================================================================
  3.                        Bochs x86 Emulator 2.6.8
  4.                 Built from SVN snapshot on May 3, 2015
  5.                   Compiled on Sep 2 2016 at 11:06:47
  6. ========================================================================
  7. 00000000000i[ ] BXSHARE not set. using compile time default '/work/os/bochs-2.6.8_gdb/install/share/bochs'
  8. 00000000000i[ ] reading configuration from ./bochrc_gdb
  9. 00000000000e[ ] ./bochrc_gdb:715: ataX-master/slave CHS set to 0/0/0 - autodetection enabled
  10. 00000000000i[ ] Enabled gdbstub                         -->enable=1之后会打印Enable
  11. 00000000000i[ ] installing x module as the Bochs GUI
  12. 00000000000i[ ] using log file /tmp/bochsout.txt
  13. Waiting for gdb connection on port 1234                  -->会停在这
d. 启动另一个terminal
  1. cong@msi:/work/os/linux12$ gdb tools/system
  2. Reading symbols from tools/system...done.
  3. (gdb) target remote localhost:1234       -->这时bochs端会打印 Connected to 127.0.0.1
  4. Remote debugging using localhost:1234
  5. 0x0000fff0 in sys_mount (dev_name=0x0 <startup_32>, dir_name=0x0 <startup_32>, rw_flag=0) at super.c:231
  6. 231            iput(dir_i);
  7. (gdb) b main
  8. Breakpoint 1 at 0x67d8: file init/main.c, line 130.
  9. (gdb) c
  10. Continuing.

  11. Breakpoint 1, main () at init/main.c:130
  12. 130    {            /* The startup routine assumes (well, ...) this */
  13. (gdb) n
  14. 135         ROOT_DEV = ORIG_ROOT_DEV;
  15. (gdb)
  16. 136         SWAP_DEV = ORIG_SWAP_DEV;
  17. (gdb) p /x ROOT_DEV
  18. $1 = 0x21d
e. 为了避免每次都要敲一堆命令,建立一个.gdbinit脚本
  1. cong@msi:/work/os/linux12$ cat .gdbinit
  2. break main
  3. target remote localhost:1234
e.1 发现一个问题,这个.gdbinit脚本不起作用
  1. cong@msi:/work/os/linux12$ gdb -q tools/system
  2. Reading symbols from tools/system...done.
  3. warning: File "/work/os/linux12/.gdbinit" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".
  4. To enable execution of this file add
  5.     add-auto-load-safe-path /work/os/linux12/.gdbinit
  6. line to your configuration file "/home/cong/.gdbinit".
  7. To completely disable this security protection add
  8.     set auto-load safe-path /
  9. line to your configuration file "/home/cong/.gdbinit".
  10. For more information about this security protection see the
  11. "Auto-loading safe path" section in the GDB manual. E.g., run from the shell:
  12.     info "(gdb)Auto-loading safe path"
  13. (gdb)
解决方法上面都说了在/home/cong/.gdbinit下加上一行就可以了
  1. cong@msi:~$ cat .gdbinit
  2. add-auto-load-safe-path /work/os/linux12/.gdbinit
注意: 是在~目录下新建一个.gdbinit,不是在linux0.12的目录下


阅读(1850) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~