Bochs is an ia32 (x86) architecture simulator that can run on multiple platforms.
The Installation Process in Ubuntu is as follows:
(1) install vgabios bochs-x bximage
$ sudo apt-get install vgabios bochs-x bximage
(2) install bochs
Download the source code from the official website: bochs-2.4.5.tar.gz, decompress the generated bochs-2.4.5 directory, and then enter the Directory and install:
$ cd bochs-2.4.5/$ ./configure --enable-debugger --enable-disasm$ make$ sudo make install
Introduction to bochs:
(1) Use bximage to create a disk image:
$ bximage ======================================================================== bximage Disk Image Creation Tool for Bochs $Id: bximage.c,v 1.34 2009/04/14 09:45:22 sshwarts Exp $========================================================================Do you want to create a floppy disk image or a hard disk image?Please type hd or fd. [hd] fdChoose the size of floppy disk image to create, in megabytes.Please type 0.16, 0.18, 0.32, 0.36, 0.72, 1.2, 1.44, 1.68, 1.72, or 2.88. [1.44] I will create a floppy image with cyl=80 heads=2 sectors per track=18 total sectors=2880 total bytes=1474560What should I name the image?[a.img] bb.imgWriting: [] Done.I wrote 1474560 bytes to bb.img.The following line should appear in your bochsrc: floppya: image="bb.img", status=inserted
As shown above, a disk image named BB. IMG is created in the current directory.
(2) bochsrc configuration file
If no configuration file is specified when bochs is started, the default configuration file will be searched. The search order is as follows:
. BochsrcCurrent Directory
BochsrcCurrent Directory
Bochsrc.txtCurrent Directory
(Win32 only)Bochsrc. bxrcCurrent Directory
(Unix only). BochsrcMain directory of the current user
(Unix only)BochsrcIn the/etc directory
For the configuration file writing format, refer to the following:
###############################################################2 # Configuration file for Bochs3 ###############################################################45 # how much memory the emulated machine will have6 megs: 3278 # filename of ROM images9 romimage: file=/usr/share/bochs/BIOS-bochs-latest10 vgaromimage: file=/usr/share/vgabios/vgabios.bin1112 # what disk images will be used13 floppya: 1_44=a.img, status=inserted1415 # choose the boot disk.16 boot: floppy1718 # where do we send log messages?19 log: bochsout.txt2021 # disable the mouse22 mouse: enabled=02324 # enable key mapping, using US layout as default.25 keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map
For more detailed configuration, refer to the official documentation:
Http://bochs.sourceforge.net/cgi-bin/topper.pl? Name = new + bochs + documentation & url = http://bochs.sourceforge.net/doc/docbook
(3) bochs debugging
Action |
Command |
Example |
Set a breakpoint at a physical address |
B ADDR |
B 0x30400 |
Display All current breakpoint Information |
Info break |
Info break |
Continue until a breakpoint occurs. |
C |
C |
One-step execution |
S |
S |
One-step execution (skip in case of a function) |
N |
N |
View register information |
Info CPU R Fp Sreg CREG |
Info CPU R Fp Sreg CREG |
View stacks |
Print-Stack |
Print-Stack |
View memory physical address content |
XP/nuf ADDR |
XP/40bx 0x9013e |
View linear address content |
X/nuf ADDR |
X/40bx 0x13e |
Disassemble a piece of memory |
U start end |
U 0x30400 0x3040d |
Every instruction executed by Disassembly |
Trace-on |
Trace-on |
CPU information is printed every time a command is executed. |
Trace-Reg |
Trace-Reg on
|