gdb调试工具简介

 gdb调试工具简介                           

一、gdb参数:

Parameter                  Description
-b             Set the line speed of the serial interface for remote debugging
-batch         Run in batch mode
-c             Specify the core dump file to analyze
-cd            Specify the working directory
-d             Specify a directory to search for source files
-e             Specify the file to execute
-f             Output filename and line numbers in standard format when debugging
-nx            Do not execute commands from .gdbinit file
-q             Quiet mode—don’t print introduction
-s             Specify the filename for symbols
-se            Specify the filename for both symbols and to execute
-tty           Set device for standard input and output
-x             Execute gdb commands from the specified file

二、gdb命令介绍:

Command                        Description
break        Set a breakpoint in the source code to stop execution
watch        Set a watchpoint to stop execution when a variable reaches a specific value
info         Observe system elements, such as registers, the stack, and memory
x            Examine memory location
print        Display variable values
run          Start execution of the program within the debugger
list         List specified functions or lines
next         Step to the next instruction in the program
step         Step to the next instruction in the program
cont         Continue executing the program from the stopped point
until        Run the program until it reaches the specified source code line(or greater)

三、常用命令详细介绍:

1. print命令:

    The print command can also be used to display individual register values. Including a modifier can
modify the output format of the print command:
? print/d to display the value in decimal
? print/t to display the value in binary
? print/x to display the value in hexadecimal

    应用举例:(gdb) print/x $ebx

2. x命令:

    The x command is used to display the values of specific memory locations. Similar to the print command,the x command output can be modified by a modifier. The format of the x command is
                              x/nyz
    where n is the number of fields to display, y is the format of the output, and can be
? c for character
? d for decimal
? x for hexadecimal
    and z is the size of the field to be displayed:
? b for byte
? h for 16-bit word (half-word)
? w for 32-bit word

    应用举例:(gdb) x/42cb &output
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值