目录

目录

GDB 使用

目录

类似于 b、c、n 等常用命令,不做解析,提及一些实用,但不常用的指令,在调试时能够给予一些帮助。

  1. 源码搜索路径 1)查看 使用 show dir 来显示当前 GDB 的源码搜索路径列表
(gdb) show dir
Source directories searched: $cdir:$cwd

2)添加 若源文件不在搜索路径中,可以使用 directory 命令来添加新的目录在搜索路劲中

(gdb) dir /path/new

3)替换 若源代码被移动,GDB 仍尝试查找旧路径,能使用命令映射旧路径到新路径

set substitute-path /old/path /new/path

4)当前详细信息

(gdb) info source
Current source file is /workspace/examples/main.c
Compilation directory is /workspace/cmake-build-debug-ubuntu/examples/bond
Located in /workspace/examples/main.c
Contains 883 lines.
Source language is c.
Producer is GNU C11 7.5.0 -mssse3 -msse4.1 -mtune=generic -march=x86-64 -g -std=gnu11 -fPIC -fstack-protector-strong.
Compiled with DWARF 2 debugging format.
Does not include preprocessor macro info.
  1. 内存查看

  2. 手动打印

printf "%s\n", JSON_Print(inJson)