GDB - COMMANDS

本文介绍了GDB调试器中最常用的命令,包括设置断点、运行程序、继续执行、单步执行等功能,适用于进行程序调试的开发者。
部署运行你感兴趣的模型镜像

引言

转载自:GDB - Commands

在做 CSAPP 的 Lab 时,找到这个:最常用的 GDB 命令

内容

GDB offers a big list of commands, however the following commands are the ones used most frequently:

  • b main - Puts a breakpoint at the beginning of the program
  • b - Puts a breakpoint at the current line
  • b N - Puts a breakpoint at line N
  • b + N - Puts a breakpoint N lines down from the current line
  • b fn - Puts a breakpoint at the beginning of function “fn”
  • d N - Deletes breakpoint number N
  • info break - list breakpoints
  • r - Runs the program until a breakpoint or error
  • c - Continues running the program until the next breakpoint or error
  • f - Runs until the current function is finished
  • s - Runs the next line of the program
  • s N - Runs the next N lines of the program
  • n - Like s, but it does not step into functions
  • u N - Runs until you get N lines in front of the current line
  • p var - Prints the current value of the variable “var”
  • bt - Prints a stack trace
  • u - Goes up a level in the stack
  • d - Goes down a level in the stack
  • q - Quits gdb

后记

如何用 Vim 完成上面的内容呢?

1、需要加上关于无序列表的标记

Ctrl + v进入 Visual Block Mode,然后选中多行。接着,如果想要在行首插入,我们用 0 扩展 visual block 到每行的行首; 如果想要在行尾插入,用 $ 扩展 visual block 到每行的行尾。用 A 在每行 visual block 的尾部插入; 用 I 在每行 visual block 的头部插入。

2、然后加上加粗的标记

用宏记录。

您可能感兴趣的与本文相关的镜像

ComfyUI

ComfyUI

AI应用
ComfyUI

ComfyUI是一款易于上手的工作流设计工具,具有以下特点:基于工作流节点设计,可视化工作流搭建,快速切换工作流,对显存占用小,速度快,支持多种插件,如ADetailer、Controlnet和AnimateDIFF等

GDB(GNU Debugger)是 GNU 项目发布的一款功能强大的调试工具,广泛应用于 C、C++ 等程序的错误查找与修复。而“gdb-headless”模式并不是 GDB 内置的一个官方术语或选项;不过根据上下文推测,这里提到的应该是 GDB 的非交互式(即后台运行、无需用户干预)操作方式。 在某些场景下,特别是远程服务器管理和 CI/CD 流水线中,我们可能需要让 GDB 自动完成一系列任务而不需人工介入。“headless”一般指没有图形界面的服务端应用,在这里是借用这一概念来形容不需要手动控制台输入的自动化流程。下面是几种可以在类似意义上使用 GDB 的方法: ### 使用批处理命令 通过 `-batch` 参数可以让 GDB 执行指定的一系列命令然后退出。这通常结合脚本一起使用。 ```bash gdb -batch -ex "target remote localhost:1234" -ex "continue" ``` ### 脚本化调试过程 编写包含所需所有命令的 `.gdbinit` 文件或其他形式的文本文件,并告诉 GDB 加载它们: ```bash echo "-file-exec-and-symbols program" > commands.txt echo "run arg0 arg1" >> commands.txt echo "backtrace full" >> commands.txt gdb -x commands.txt --quiet ``` ### 非阻塞模式 如果是在开发环境中做测试驱动开发或者持续集成管道里跑单元测试的话,“non-q -batch \ -ex 'set non_stop on' \ -ex 'target extended-remote :9999' \ -ex 'attach PID' ``` 综上所述,“gdb-headless”的含义实际上是指利用上述各种手段之一使得 GDB 可以无人值守地自动进行特定的任务。这种方式非常适合集成进自动化构建和服务部署的过程中去解决问
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值