Bochs User Manual
  Chapter 8. Tips and Techniques  

8.12. Using Bochs internal debugger

Note, if you are looking for a graphical front-end for the bochs debugger, you may want to check out BFE. This is a package written by a Bochs user which can interface with the text based Bochs debugger. No linking is necessary. It's not part of Bochs, but you may find it useful.

You can now conditionally compile in a GDB like command line debugger, that allows you to set breakpoints, step through instructions, and other useful functions. If there isn't a command for something you believe is generally useful for the debugger, let me know and I'll implement it if possible.

To use the debugger, you must configure Bochs with the --enable-debugger and --enable-disasm flags. For example:

  ./configure --enable-debugger --enable-disasm

Note: You must use flex version 2.5.4 or greater. I have heard that version 2.5.2 will not work.

When you first start up Bochs, you will see the command line prompt

  bochs:1>

From here, you may use the following commands:

8.12.1. Execution Control

  c                           continue executing
cont
continue s [count] execute count instructions, default is 1
step [count] s [cpu] [count] for SMP simulation, execute count instructions on cpu, default is 1
step [cpu] [count] s all [count] for SMP simulation, execute count instructions on all cpus
step all [count] Ctrl-C stop execution, and return to command line prompt
Ctrl-D if at empty line on command line, exit q quit debugger and execution
quit
exit

8.12.2. BreakPoints

  NOTE: The format of 'seg', 'off', and 'addr' in these descriptions,
are as follows. I don't have any way to set the current radix. hexidecimal: 0xcdef0123
decimal: 123456789
octal: 01234567 vbreak seg:off Set a virtual address instruction breakpoint
vb seg:off lbreak addr Set a linear address instruction breakpoint
lb addr pbreak [*] addr Set a physical address instruction breakpoint
pb [*] addr (the '*' is optional for GDB compatibility)
break [*] addr
b [*] addr info break Display state of all current breakpoints
bpe n Enable a breakpoint
bpd n Disable a breakpoint
delete n Delete a breakpoint
del n
d n

8.12.3. Memory WatchPoints

  watch read  addr            Insert a read watch point at physical address addr
watch r addr Insert a read watch point at physical address addr watch write addr Insert a write watch point at physical address addr
watch w addr Insert a write watch point at physical address addr watch Display state of current memory watchpoints watch stop Stop simulation when a watchpoint is encountered (default)
watch continue Do not stop simulation when a watchpoint is encountered unwatch addr Remove watchpoint to specific physical address
unwatch Remove all watch points trace-mem on/off Enable/Disable memory access tracing

8.12.4. Manipulating Memory

  x  /nuf addr      Examine memory at linear address addr
xp /nuf addr Examine memory at physical address addr
n Count of how many units to display
u Unit size; one of
b Individual bytes
h Halfwords (2 bytes)
w Words (4 bytes)
g Giant words (8 bytes)
NOTE: these are *not* typical Intel nomenclature sizes,
but they are consistent with GDB convention.
f Printing format. one of
x Print in hexadecimal
d Print in decimal
u Print in unsigned decimal
o Print in octal
t Print in binary n, f, and u are optional parameters. u and f default to the last values
you used, or to w(words) and x(hex) if none have been supplied.
n currently defaults to 1. If none of these optional parameters are
used, no slash should be typed. addr is also optional. If you don't
specify it, it will be the value the next address (as if you had
specified n+1 in the last x command). setpmem addr datasize val Set physical memory location of size
datasize to value val. writemem dump a number of bytes of virtual memory starting from
the specified linear address into a file crc addr1 addr2 Show CRC32 for physical memory range addr1..addr2

8.12.5. Info commands

  r|reg|regs|registers         List of CPU integer registers and their contents
fp|fpu List of all FPU registers and their contents
mmx List of all MMX registers and their contents
sse|xmm List of all SSE registers and their contents
ymm List of all AVX registers and their contents
sreg Show segment registers and their contents
dreg Show debug registers and their contents
creg Show control registers and their contents info cpu List of all CPU registers and their contents
info eflags Show decoded EFLAGS register
info break Information about current breakpoint status
info tab Show paging address translation
info device Show state of the specified device

8.12.6. Manipulating CPU Registers

  set reg = expr    Change a CPU register to value of expression.
Currently only general purpose registers and instruction pointer
are supported. You may not change eflags, segment registers,
floating point or SIMD registers. Examples: set eax = 2+2/2
set esi = 2*eax+ebx registers List of CPU registers and their contents
regs
reg
r

8.12.7. Disassembly commands

  disassemble start end       Disassemble instructions in given linear address
range, inclusive of start, exclusive of end.
Use "set $disassemble_size =" to tell
debugger desired segment size. Use a value for
end of less than start (or zero) if you only
want the first instruction disassembled. disassemble switch-mode Switch between Intel and AT&T disassebly styles
for debugger disassembler. disassemble size = n Tell debugger what segment size to use when
the "disassemble" command is used. Use values
of 0, 16 or 32 for n. Value of 0 means
"use segment size specified by current CS
segment". Default is 0. set $auto_disassemble = n Cause debugger to disassemble current instruction
every time execution stops if n=1. Default is 0.
Segment size of current CPU context is used for
disassembly, so the "disassemble size" variable is
ignored. set disassemble on The same as 'set $auto_disassemble = 1'
set disassemble off The same as 'set $auto_disassemble = 0'

8.12.8. Instruction tracing

  trace on                    Disassemble every executed instruction. Note
that instructions which caused exceptions are
not really executed, and therefore not traced. trace off Disable instruction tracing.

8.12.9. Instrumentation

To use instrumentation features in bochs, you must compile in support for it. You should build a custom instrumentation library in a separate directory in the "instrument/" directory. To tell configure which instrumentation library you want to use, use the --enable-instrumentation option. The default library consists of a set of stubs, and the following are equivalent:

  ./configure [...] --enable-instrumentation
./configure [...] --enable-instrumentation="instrument/stubs"

You could make a separate directory with your custom library, for example "instrument/myinstrument", copy the contents of the "instrument/stubs" directory to it, then customize it. Use:

  ./configure [...] --enable-instrumentation="instrument/myinstrument"

8.12.10. Instrumentation commands

  instrument [command]        calls BX_INSTR_DEBUG_CMD instrumentation callback with [command]

8.12.11. Other Commands

ptime

Print the current time (number of ticks since start of simulation).

sb delta

Insert a time break point "delta" instructions into the future ("delta" is a 64-bit integer followed by "L", for example 1000L).

sba time

Insert a time break point at "time" ("time" is a 64-bit integer followed by "L", for example 1000L).

print-stack [num words]

Print the num words top 16-bit words on the stack. Num words defaults to 16. Only works reliably in protected mode when the base address of the stack segment is zero.

modebp

Toggles CPU mode switch breakpoint.

ldsym [global] filename [offset]

Load symbols from file filename. If the global keyword is added, then the the symbols will be visible in all contexts for which symbols have not been loaded. Offset (default is 0) is added to every symbol entry. The symbols are loaded in the current (executing) context.

The symbol file consists of zero or more lines of the format

"%x %s"

.

show [string]
  Toggles show symbolic info (calls to begin with).
show - shows current show mode
show mode - show, when processor switch mode
show int - show, when interrupt is happens
show call - show, when call is happens
show ret - show, when iret is happens
show off - toggles off symbolic info
show dbg-all - turn on all show flags
show dbg-none - turn off all show flags

BochsDebug的更多相关文章

随机推荐

  1. Windows 32 程序设计

    C语言版 开发语言:C语言 开发工具:Visual Studio 2015 目      标:使用C语言,直接调用Windows API,创建Windows程序. 参考图书:<Windows程序 ...

  2. python 最长公共子序列

    网上有很多,但有bug,特别是这个:http://www.oschina.net/code/snippet_16840_2015 好大的坑... get length def lcs_len(a,b) ...

  3. 在viewPager中的textview参数singleLine和gravity为center冲突bug

    在viewPager中有textview. 当textview的参数为singleLine和gravity为center时, onfling事件将会被读取为onclick事件. 这是andriod的一 ...

  4. 【转】开源性能测试工具 - Apache ab 介绍

    版权声明:本文可以被转载,但是在未经本人许可前,不得用于任何商业用途或其他以盈利为目的的用途.本人保留对本文的一切权利.如需转载,请在转载是保留此版权声明,并保证本文的完整性.也请转贴者理解创作的辛劳 ...

  5. Configuring HugePages for Oracle on Linux (x86-64)

    Introduction Configuring HugePages Force Oracle to use HugePages (USE_LARGE_PAGES) Disabling Transpa ...

  6. C程序之修改Windows的控制台颜色(转载)

    Windows的CMD可以和Linux下的终端一样可以有五颜六色,目前我在网上找到2种方法可以修改Windows的CMD,当然都是在代码中修改的.在“CMD”->“属性”->“颜色”,这种 ...

  7. Flash图表控件FusionCharts如何自定义图表的工具提示

    什么是FusionCharts的工具提示 当鼠标指示到FusionCharts图表中一个特定的数据点时所显示出来的信息就是工具提示.提示的信息可以是以下内容: 单系列图(除了饼图和环图):名称和值 饼 ...

  8. kubernetes源码解析---- apiserver路由构建解析(1)

    kubernetes源码解析---- apiserver路由构建解析(1) apiserver作为k8s集群的唯一入口,内部主要实现了两个功能,一个是请求的路由和处理,简单说就是监听一个端口,把接收到 ...

  9. 【练习】如何显示本地主机上的MySQL客户机版本

    在终端窗口以oracle用户身份登录 [root@enmo ~]# su - oracle [oracle@enmo ~]$ mysql -V mysql Ver , for Linux (x86_6 ...

  10. 8051学习笔记——IIC与EEPROM实验

    main.c #include <reg51.h> #include "iic.h" #define AT24C02 0xa0 //AT24C02 地址 sbit LS ...