启动程序

命令解释

r(run)

执行命令

r <args>

使用指定参数运行

attach -p 123

attach 到进程

process attach --name a.out

attach 到名为 a.out 的进程

gdb-remove (localhost:)8000

连接到 gdb-server

断点

基本的断点语法和 gdb 相同,如果需要条件断点,可以使用两种语法:

  • breakpoint set --name foo --condition '(int)strcmp(y,"hello") == 0'

  • br s -n foo -c '(int)strcmp(y,"hello") == 0'

如果需要在指定线程上打断点,只需要添加以下几种参数:

参数解释

--thread-id

The breakpoint stops only for the thread whose TID matches this argument. The token 'current' resolves to the current thread’s ID.

--thread-index

The breakpoint stops only for the thread whose index matches this argument.

--thread-name

The breakpoint stops only for the thread whose thread name matches this argument.

多线程调试

命令作用

thread list

列出线程

t 1

切换到线程 1

bt

thread backtrace

bt all

所有线程的 backtrace

bt 5

查看当前线程 frame 的前五行

f(frame) 12

查看 第 12 行 frame

frame info

查看当前线程 frame 信息

内存

命令作用

memory read --size 4 --format x --count 4 -xbffff3c0

读取 0xbffff3c0 处的内存值

x/4xw 0xbffff3c0

读取 0xbffff3c0 处的内存值

memory read `argv[0]`

读取 argv[0] 的值

Last moify: 2023-07-18 12:51:19
Build time:2025-07-18 09:41:42
Powered By asphinx