file #载入可执行文件 start #停到程序入口点处 run #运行程序,直到遇见断点 step #步入 next #步过 c #继续,直到遇到下个断点或者输入 b 函数名 #在函数处打断点,可能需要符号表 b *地址 #在地址处打断点, x/类型 地址或寄存器 #x/s 0xfffff或者 x/s $rax斜杠后面的参数名可见下面参数列表,注意此处的*是起解引用的作用而不是指指针了 set args 参数1 参数2 #设置参数,字符串可用双引号包裹
db defined byte 字节型
dw defined word 字型,2字节
dd 双字型,4字节
dq 四字,8字节
s string
peda安装
安装peda
1 2 3
git clone https://github.com/longld/peda cd peda echo "source ~/peda/peda.py" >> ~/.gdbinit
输入gdb验证peda是否安装成功(注意linux需要有python环境)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
$ gdb GNU gdb (Debian 13.2-1) 13.2 Copyright (C) 2023 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: <https://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>.
For help, type "help". Type "apropos word" to search for commands related to "word". gdb-peda$