bochs debugging method

bochs general usage

bochs is an open source x86 virtual machine software. In his definition of implementation of the various data structures used to simulate hardware, software simulation hardware is slow.
: bochs hardware debugging reflected in
1) can view the page table, GDT, IDT and other data structures
. 2) may view the stack data
3) can disassemble arbitrary memory
4) real mode, protected mode converting each alert
5) interrupt occurs alert
bochs x and xp memory commands are used to view, their difference is that two linear address x command for viewing, and to view the physical address xp. The previous section only introduced the concept of the physical address, the address of the linear protected mode only in real mode. So the real mode can only be used xp command.
"The word" Note bochs in is 4 bytes.
Indicating the size of the unit:
B byte
h half word, 2 bytes
w a word, four bytes
g double words, eight bytes
content with xp and x is a command to check the "display unit" units not in bytes. Therefore, if the data size is not specified, the default of 4 bytes.
bochs different wording in each hex
octal: 011 (beginning with 0)
Decimal: 11
Hex: 0x11 (beginning only supports 0x)
XP command usage xp /nuf<addr>, nuf is a sequence of numbers, each letter has a corresponding meaning.
n is used to specify the number of units to be displayed.
u refers to the size of the display unit. To display the final few bytes, is determined n * u
f refers to the display as the format.
The following is not the BIOS loads the MBR of the case before the memory view, respectively, showing a different display.
Here Insert Picture Description
View the BIOS program. See cs: ip, this address is the BIOS program
Here Insert Picture Description
u disassembly instruction, the binary data can be disassembled into assembler instructions.
Here Insert Picture Description
Whereby the BIOS can be found in a far jump instruction at that location.
Debugger control class instructions
q | quit | exit, any one can be left exit debug state, shut down the VM
set instruction group, more commonly used for setting register
1), for example, set reg = val. Lake color registers may comprise a general purpose registers and segment registers
2) may be provided to stop each time it performs, whether or disassembled instruction: U SET ON | OFF
Show command group
1.show mode
each time the CPU proceeds transform mode when prompted , real mode, protected mode switching and the like.
2.show int
every time there is a time interrupted to suggest, at the same time display the type 3 interrupt, softint, extint and iret. Interruption of some sort may be displayed alone as performed shows only show siftint soft interrupt, show extint shows only interrupts from an external device, show iret only interruption related information iretd instructions.
3.show call
every time there is a function call on the tips.
trace on | off If set to on, each execution of an instruction, bochs disassembled code will be printed to the console
Execution control class instruction
c | cont | continue, listed on the left represents the instruction execution down, if there is no break it will have been implemented.
s | step [count] instruction execution count, count is the number of instructions executed by the single step, if the default is designated 1, into the call will encounter call execution
p | n | next single step through instructions encountered call will execute one instruction as a whole call.
Breakpoint management class of instructions
vb | vbreak [seg: off] is added to the virtual address breakpoint, the program execution stops when the virtual address, the offset of the note in the form of a virtual address period.
lb | lbreak [addr] to add a linear address breakpoints, program execution stops when this linear address.
pb | pbreak | b | break [ addr] to add a physical address breakpoint. Stop program execution to this physical address. b more common.
sb [delta] delta represents the increment, which means re-execute delta instruction program is interrupted.
sba [time] CPU from the operation start, interrupt execution of tim instruction, the instruction from the number of zero.
IO to read some break point:
Watch also subcommands, the following two conventional
watch r | read [phy_addr] Reading breakpoint setting, if the physical address is read phy_addr has stopped.
watch w | write [phy_addr] set the write breakpoint, if the physical address phy_addr write operation is stopped. This command is useful if a block address memory do not know when to be rewritten, you can set this interruption.
watch displays all read off
unwatch remove all breakpoints
unwatch [phy_addr] Clear read more on this breakpoint address
blist show all breakpoint information, functionally equivalent to the info b
bpd | bpe [n] Disable breakpoint / Enable breakpoint, n is the breakpoint number, can be used blist instructions to find out.
d | del | delete [n] to delete a breakpoint.
CPU and memory contents class of instructions
x / nuf [line_addr] linear address of the display content. n, u, f three parameters are optional, if not specified, n is 1, is a four-byte, f is hexadecimal.
n shows the number of units
u number per unit size, u can be one of the following:
. 1). 1 byte B
2) h 2 Byte
3) w 4 bytes
4) g 8-byte
f display format, f may be one of the following:
. 1) hex X
2) d decimal
3) u unsigned
4) o octal
5) t binary
6) c character display
7) s display according ASCIIz
8) i instr display according to
xp / nuf [phy_addr ] x instruction the same parameter used to display the physical address.
setpmem [phy_addr] [size] [ val] to set the start address of the physical phy_addr, content size consecutive bytes of val.
size can only be set up to 4 bytes data width.
r | reg | regs | any one of four registers command register display means + eflag + eip register 8 general-purpose registers
ptime Bochs display after start, the total number of instructions executed.
printf-stack [num] show that stack, num defaults to 16, said print stack entries. Content is output on top of the stack, in the low address, high address next.
? | calc built-in calculator
info is instruction family, you can view all of their support sub-command execution help info, as follows:
info pb | pbreak | b | BREAK
info CPU displays the value of all CPU registers
info fpu display FPU status
info idt display interrupt vector table
info gdt [num] display global descriptor table GDT, if added num, num show only gdt in item descriptor.
info ldt display global descriptor table LDT.
display info tss TSS TSS
info ivt [NUM] display Interrupt Vector Table IVT. And gdt the same, if developed num, interrupt vectors will only display the first item num.
Here Insert Picture Description
info flags | eflags display state register, r can do
sreg display the values of all segment registers.
creg all the values of the control registers.
info tab displays a page table mapping the linear addresses to physical addresses.
Display page line_addr independent address to the linear address mapping simple.

Published 30 original articles · won praise 5 · Views 1931

Guess you like

Origin blog.csdn.net/AlexSmoker/article/details/104107438
Recommended