【Bash百宝箱】gdb命令

时间:2022-05-19 16:38:59

gdb即The GNU Debugger,是一种调试工具,使用gdb可以查看一个程序在运行时或crash时的内部信息,主要有以下四种功能。

a 启动程序,按自定义的方式运行程序。
b 在特定条件下(即断点处)停止程序。
c 程序停止时,检查程序中所发生的事情。
d 改变程序执行环境,修正bug行为。

gdb可以调试C、C++程序,在shell终端启动gdb有多种方式。

1、直接运行gdb而不带任何参数。

$ gdb
GNU gdb (GDB) 7.5.91.20130417-cvs-ubuntu
Copyright (C) 2013 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 "showcopying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb)

2、带参数运行gdb的几种形式。

$ gdb program
$ gdb program core
$ gdb program pid
$ gdb -p pid

program是可执行文件,core是程序非法执行时coredump产生的文件,当程序已经运行时,可连接其进程号pid,实际上打开了一个特殊文件“/proc/pid/status”,“-p”选项可省略program,对于已知的pid还可以使用命令“attach”和“detach”来连接和取消连接程序。

下面是几个常用的gdb命令,这些命令是在进入gdb后使用的。

break [file:]function:在(file文件的)function函数上设置断点。

run [arglist]:运行程序(可以指定运行参数arglist)。

bt:即backtrace,显示程序堆栈信息。

print expr:显示表达式expr的值。

c:即continue,继续执行程序,例如程序停在某个断点之后恢复执行。

next:程序停止后继续执行程序下一行,会跳过(与step不同)代码行调用的函数。

edit [file:]function:在程序当前停止的地方查看程序代码行。

list [file:]function:打印程序当前停止地方附近的文本。

step:程序停止后执行程序下一行,会进入(与next不同)代码行调用的函数。

help [name]:显示帮助信息,name是某个gdb命令。

quit:退出gdb。

下面是几个常用的gdb选项,启动gdb时使用。

-help、-h:列出所有的选项,包括对应的简短说明。

-symbols=file、-s file:从文件file中读取符号表。

-write:允许写入到可执行文件和core文件。

-exec=file、-e file:把文件file当作可执行文件,coredump发生时会对其数据进行检查。

-se=file:从文件file中读取符号表,且把文件file当作可执行文件。

-core=file、-c file:coredump执行文件。

-command=file、-x file:从文件file中读取gdb命令。

-ex command:执行gdb命令command。

-directory=directory、-d directory:添加目录directory到源文件的搜索列表。

-nh:不执行特殊文件“~/.gdbinit”中的命令。

-nx、-n:不执行任何文件“.gdbinit”中的命令。

-quiet、-q:不打印gdb介绍和版权信息,这些信息在“batch”模式下是不会输出的。

-batch:在“batch”模式下执行。

-cd=directory:指定运行gdb的工作目录为directory,而非当前目录。

-fullname、-f:Emacs在子进程中运行gdb时设置这个选项,使得gdb输出完整的文件名和行号。

-b bps:设置串口输出行的速度,即波特率。

-tty=device:设置输入、输出设备为device。

下面以一个具体的例子简单“main.c”说明gdb的用法。

// main.c
#include <stdio.h>

int sum(int n)
{
int ret = 0;
int i = 0;
for (i = 1; i <= n; ++i) {
ret += i;
}
return ret;
}

int main()
{
int n = 10;
int result = 0;
int j = 0;
for (j = 1; j <= n; ++j) {
result += j;
}
int result2 = sum(n);
printf("result = %d\n", result);
printf("result2 = %d\n", result2);

return 0;
}

在linux终端编译main.c生成可执行文件test,使用gcc的“-g”选项以生成调试所需信息。

$ gcc -g main.c -o test

用gdb启动test。

$ gdb test
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.04) 7.11.1
Copyright (C) 2016 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:
<http://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"...
Reading symbols from test...done.
(gdb)

用list(缩写为l)从文件非注释的第一行开始显示源码,默认每次显示10行,按回车键继续执行上一次的命令,结束时会提示行号无效。

(gdb) l
2 #include <stdio.h>
3
4 int sum(int n)
5 {
6 int ret = 0;
7 int i = 0;
8 for (i = 1; i <= n; ++i) {
9 ret += i;
10 }
11 return ret;
(gdb)
12 }
13
14 int main()
15 {
16 int n = 10;
17 int result = 0;
18 int j = 0;
19 for (j = 1; j <= n; ++j) {
20 result += j;
21 }
(gdb)
22 int result2 = sum(n);
23 printf("result = %d\n", result);
24 printf("result2 = %d\n", result2);
25
26 return 0;
27 }
(gdb)
Line number 28 out of range; main.c has 27 lines.

用break(缩写为b)在程序第16行和sum函数入口设置断点。

(gdb) b 16
Breakpoint 1 at 0x400557: file main.c, line 16.
(gdb) b sum
Breakpoint 2 at 0x400521: file main.c, line 6.

用info(缩写为i)查看断点break(缩写为b)信息。

(gdb) i b
Num Type Disp Enb Address What
1 breakpoint keep y 0x0000000000400557 in main at main.c:16
2 breakpoint keep y 0x0000000000400521 in sum at main.c:6

用run(缩写为r)执行程序(停在了断点处)。

(gdb) r
Starting program: /home/hanjunjie/test

Breakpoint 1, main () at main.c:16
16 int n
= 10;

用next(缩写为n)执行程序下一行,continue(缩写为c)继续运行程序(直到下一个断点或者程序结束),print(缩写为p)打印某个变量的值,这个变量的值为当前行前面的最新的值。

(gdb) n
17 int result = 0;
(gdb) n
18 int j = 0;
(gdb) n
19 for (j = 1; j <= n; ++j) {
(gdb) n
20 result += j;
(gdb) c
Continuing.

Breakpoint 2, sum (n=10) at main.c:6
6 int ret = 0;
(gdb) n
7 int i = 0;
(gdb) n
8 for (i = 1; i <= n; ++i) {
(gdb) p i
$1 = 0
(gdb) n
9 ret += i;
(gdb) p i
$2 = 1
(gdb) n
8 for (i = 1; i <= n; ++i) {
(gdb) n
9 ret += i;

用backtrace(缩写为bt)查看调用堆栈。

(gdb) bt
#0 sum (n=10) at main.c:9
#1 0x0000000000400591 in main () at main.c:22

用finish结束当前函数,然后通过c继续执行,看到了最终结果。

(gdb) finish
Run till exit from #0 sum (n=10) at main.c:9
0x0000000000400591 in main () at main.c:22
22 int result2 = sum(n);
Value returned is $6 = 55
(gdb) c
Continuing.
result = 55
result2 = 55
[Inferior 1 (process 4069) exited normally]

用quit(缩写为q)退出gdb。

(gdb) quit

在gdb环境中,可通过命令“help”查看详细用法,命令分为几个类型,如下:

aliases -- Aliases of other commands
breakpoints -- Making program stop at certain points
data -- Examining data
files -- Specifying and examining files
internals -- Maintenance commands
obscure -- Obscure features
running -- Running the program
stack -- Examining the stack
status -- Status inquiries
support -- Support facilities
tracepoints -- Tracing of program execution without stopping the program
user-defined -- User-defined commands

下面总结一些gdb常用的命令,在gdb环境中可使用“Tab”键(连续按两次)自动补全命令。

set——

set args:设置运行时参数。
set env <envname> [=envvalue]:设置环境变量。
set var <variable>=<value>:设置程序变量而非gdb的环境变量,或者使用print <name>=<value>
set $<variable>=<value>:自定义变量,使用美元符号。
set listsize <count>:设置程序代码每次显示的最多行数。

show——

show args:查看运行时参数。
show paths:查看程序运行路径。
path <dir>:设置程序运行路径。
show directories:查看原文件的搜索路径。
directory <dirname>:添加原文件的搜索路径。
show env [envname]:查看环境变量。
show language:查看当前程序的语言环境。
show listsize:查看程序代码每次显示的最多行数。

info——

info ternimal:查看程序运行的终端模式,运行时可使用重定向,如“r > run_save”把输出保存到了文件run_save中。
info program:查看程序运行状态。
info breakpoints [num]:查看程序断点及其状态,可指定断点的序号。
info watchpoints:查看程序观察点及其状态。
info frame:查看当前栈帧的信息。
info registers [rname]:查看寄存器的情况,不包括浮点寄存器,可指定寄存器名字。
info all-registers:查看寄存器的情况,包括浮点寄存器。
info line [linespec]:查看当前行在内存中地址,或者通过linespec指定查询的行号或函数名。
disassemble [function]:查看汇编代码。
info args:显示当前函数的参数名及其值。
info locals:显示当前函数中所有局部变量及其值。
info signals、info handle:查看信号处理的相关情况。
info threads:显示线程信息。
info display:显示display设置的自动显示的信息。
info source:显示程序相关的信息,如文件名、执行路径、行数、语言类型、编译器、调试模式等。

print与x——

print <expr>:打印表达式expr的值,变量也是一个表达式,打印的结果依次保存在了变量$1、$2、$3……中。print命令有许多显示选项,可通过set print <option> on|off命令设置,show print [option]命令查看,这些选项如address、array等。
print /<f> <expr>:以指定格式f打印,同C语言的printf函数的格式控制符,包括十六进制x、十进制d、无符号十进制u、八进制o、十六进制a、字符格式c、浮点格式f。

下面是print命令支持的特殊操作符@的用例,另外,同名局部变量会隐藏全局变量,打印全局变量时在变量前添加符号::

int local_array[5] = {2, 4, 1, 3, 10};
int *p = local_array;

(gdb) print local_array
$1 = {2, 4, 1, 3, 10}
(gdb) print p
$2 = (int *) 0x7fffffffdc70
(gdb) print *p
$3 = 2
(gdb) print *p@1
$4 = {2}
(gdb) print *p@2
$5 = {2, 4}
(gdb) print *p@3
$6 = {2, 4, 1}
(gdb) print *p@4
$7 = {2, 4, 1, 3}
(gdb) print *p@5
$8 = {2, 4, 1, 3, 10}

对于一块内存来说,我们可以使用命令x /n/f/u addr查看其值,x为命令,从起始地址addr开始,单位为u(b表示单字节,h表示双字节,w表示四字节,g表示八字节),长度为n(即n个单位长度),格式为f,可以是上面print命令提到的格式,字符串格式使用s,指令格式使用i,下面接着上面的例子打印指针p的内容,单位为4个字节,5个长度,格式为d表示十进制。

(gdb) print p
$2 = (int *) 0x7fffffffdc70
(gdb) x /5dw 0x7fffffffdc70
0x7fffffffdc70: 2 4 1 3
0x7fffffffdc80: 10

list——

list:显示程序当前行后面的代码。
list +:显示程序当前行后面的代码。
list -:显示程序当前行前面的代码。
list <linenum>:显示程序第linenum行周围的代码,linenum可带正负号,表示相对于当前行的偏移量。
list <function>:显示程序某个函数周围的代码。
list <first,last>:显示程序第first行到第last行之间的代码包括第first行和第last行,可省略first或last其中一个。

search——

search <regexp>:搜索匹配正则表达式regexp的代码。
forward-search <regexp>:搜索匹配正则表达式regexp的代码。
reverse-search <regexp>:搜索匹配正则表达式regexp的代码。

display——

display <expr>:程序停止或单步跟踪时,需要自动显示的内容。
display /<format> <expr>:format指定显示格式,同print和x命令的显示格式。
display /<format> <addr>:addr表示内存地址。
undisplay <dnums>:删除序号为dnums的自动显示。
delete display <dnums>:删除序号为dnums的自动显示。
diable display <dnums>:禁用序号为dnums的自动显示。
enable display <dnums>:启用序号为dnums的自动显示。

断点相关——

break <function>:设置函数断点,还可以是filename:function,在C++中可使用class::functionfunction(type,type...)格式来指定函数名。
break <linenum>:在指定行号设置断点,还可以是filename:linenum
break +offset、break -offset:断点位置在当前行号的前面或后面的偏移offset处。
break *address:断点位置在程序运行的某个内存地址。
break:break命令没有参数时,表示在下一条指令处设置断点。
break if <condition>:设置条件断点,满足指定的条件时暂停。
break <linespec> thread <threadno>:给特定的线程设置断点,而不是所有线程。
break <linespec> thread <threadno> if ...:给特定的线程设置条件断点,而不是所有线程。
clear <function>:删除函数断点。
clear <lineno>:删除行断点。
delete:删除所有断点。
delete breakpoints <range>:删除指定序号的断点,如序号“2”或者序号范围“3-7”。
disable [breakpoints] [range]:禁用断点。
enable [breakpoints] [range]:启用断点。
enable breakpoints once <range>:启用断点一次。
enable breakpoints delete <range>:启用断点,使用后就会被删除掉。
condition <bnum> <expression>:修改断点号为bnum的条件断点的停止条件为expression。
condition <bnum>:清除断点号为bnum的条件断点的停止条件。
ignore <bnum> <count>:忽略断点号为bnum的断点的停止,忽略count次。
commands [bnum] [command_list] end:设置断点停止时将要执行的命令command_list。
continue [ignore_count]:恢复程序运行,直到程序结束或者遇到下一个断点,可设置忽略下一个断点的次数,命令continue也可以使用命令fg代替。
step <count>:单步执行,也可以指定执行步数count,会进入调用的函数,另一个相关的命令是“stepi”,简写为“si”,意思是单步跟踪一条机器指令,因为一个代码行可能由多个机器指令构成。
next <count>:单步执行,也可以指定执行步数count,不会进入调用的函数。另一个相关的命令是“nexti”,简写为“ni”,意思是单步跟踪一条机器指令,因为一个代码行可能由多个机器指令构成。
until:运行程序直到退出循环,简写为“u”。
return [expr]:调试断点停在函数中时,强制返回,expr是可选的返回值。
finish:运行程序,直到当前函数返回,并打印函数返回时的堆栈地址和返回值及参数值等信息。
bt [n]:即backtrace,显示当前栈的信息,n可以是正负数,表示显示的栈顶或栈底的层数,具体某一层栈可通过up、down或frame查询。

观察点——

watch <expr>:设置观察点,当变量或者表达式的值变化时停止程序执行。
rwatch <expr>:设置观察点,当变量或者表达式的值被读时停止程序执行。
awatch <expr>:设置观察点,当变量或者表达式的值被读、写时停止程序执行。

捕捉点——

catch <event>:设置捕捉点,即程序运行时的一些事件,它们可以是“throw”、“catch”、“exec”、“fork”、“vfork”、“load”、“load ”、“unload”、“unload ”,捕捉到这些事件时程序停止执行,gdb命令catch可以替换为tcatch,不同的是tcatch捕捉到一次事件后对应的捕捉点就自动删除了。

信号相关——

signal <SIGNAL>:发送信号,信号编号从1到15。single命令和shell的kill命令不同,系统的kill命令发信号给被调试程序时,是由gdb截获的,而single命令所发出一信号则是直接发给被调试程序的。
handle <SIGNAL> [ACTION]:处理信号,可指定信号处理动作,包括stop、nostop、print、noprint、pass、nopass、ignore、noignore。

目录相关——

cd [dir]:切换工作目录。
pwd:显示当前目录。

shell命令——

shell <command>:运行shell中的命令,如果命令是make,可省略关键字shell。

此外,命令jump用于跳转执行,call用于调用程序中的函数。

还可以在gdb中通过命令“help all”查看gdb支持的所有的命令,这些命令如下:

Command class: aliases

ni – Step one instruction
rc – Continue program being debugged but run it in reverse
rni – Step backward one instruction
rsi – Step backward exactly one instruction
si – Step one instruction exactly
stepping – Specify single-stepping behavior at a tracepoint
tp – Set a tracepoint at specified location
tty – Set terminal for future runs of program being debugged
where – Print backtrace of all stack frames
ws – Specify single-stepping behavior at a tracepoint

Command class: breakpoints

awatch – Set a watchpoint for an expression
break – Set breakpoint at specified location
break-range – Set a breakpoint for an address range
catch – Set catchpoints to catch events
catch assert – Catch failed Ada assertions
catch catch – Catch an exception
catch exception – Catch Ada exceptions
catch exec – Catch calls to exec
catch fork – Catch calls to fork
catch load – Catch loads of shared libraries
catch rethrow – Catch an exception
catch signal – Catch signals by their names and/or numbers
catch syscall – Catch system calls by their names and/or numbers
catch throw – Catch an exception
catch unload – Catch unloads of shared libraries
catch vfork – Catch calls to vfork
clear – Clear breakpoint at specified location
commands – Set commands to be executed when a breakpoint is hit
condition – Specify breakpoint number N to break only if COND is true
delete – Delete some breakpoints or auto-display expressions
delete bookmark – Delete a bookmark from the bookmark list
delete breakpoints – Delete some breakpoints or auto-display expressions
delete checkpoint – Delete a checkpoint (experimental)
delete display – Cancel some expressions to be displayed when program stops
delete mem – Delete memory region
delete tracepoints – Delete specified tracepoints
delete tvariable – Delete one or more trace state variables
disable – Disable some breakpoints
disable breakpoints – Disable some breakpoints
disable display – Disable some expressions to be displayed when program stops
disable frame-filter – GDB command to disable the specified frame-filter
disable mem – Disable memory region
disable pretty-printer – GDB command to disable the specified pretty-printer
disable probes – Disable probes
disable tracepoints – Disable specified tracepoints
disable type-printer – GDB command to disable the specified type-printer
disable unwinder – GDB command to disable the specified unwinder
disable xmethod – GDB command to disable a specified (group of) xmethod(s)
dprintf – Set a dynamic printf at specified location
enable – Enable some breakpoints
enable breakpoints – Enable some breakpoints
enable breakpoints count – Enable breakpoints for COUNT hits
enable breakpoints delete – Enable breakpoints and delete when hit
enable breakpoints once – Enable breakpoints for one hit
enable count – Enable breakpoints for COUNT hits
enable delete – Enable breakpoints and delete when hit
enable display – Enable some expressions to be displayed when program stops
enable frame-filter – GDB command to disable the specified frame-filter
enable mem – Enable memory region
enable once – Enable breakpoints for one hit
enable pretty-printer – GDB command to enable the specified pretty-printer
enable probes – Enable probes
enable tracepoints – Enable specified tracepoints
enable type-printer – GDB command to enable the specified type printer
enable unwinder – GDB command to enable unwinders
enable xmethod – GDB command to enable a specified (group of) xmethod(s)
ftrace – Set a fast tracepoint at specified location
hbreak – Set a hardware assisted breakpoint
ignore – Set ignore-count of breakpoint number N to COUNT
rbreak – Set a breakpoint for all functions matching REGEXP
rwatch – Set a read watchpoint for an expression
save – Save breakpoint definitions as a script
save breakpoints – Save current breakpoint definitions as a script
save gdb-index – Save a gdb-index file
save tracepoints – Save current tracepoint definitions as a script
skip – Ignore a function while stepping
skip delete – Delete skip entries
skip disable – Disable skip entries
skip enable – Enable skip entries
skip file – Ignore a file while stepping
skip function – Ignore a function while stepping
strace – Set a static tracepoint at location or marker
tbreak – Set a temporary breakpoint
tcatch – Set temporary catchpoints to catch events
tcatch assert – Catch failed Ada assertions
tcatch catch – Catch an exception
tcatch exception – Catch Ada exceptions
tcatch exec – Catch calls to exec
tcatch fork – Catch calls to fork
tcatch load – Catch loads of shared libraries
tcatch rethrow – Catch an exception
tcatch signal – Catch signals by their names and/or numbers
tcatch syscall – Catch system calls by their names and/or numbers
tcatch throw – Catch an exception
tcatch unload – Catch unloads of shared libraries
tcatch vfork – Catch calls to vfork
thbreak – Set a temporary hardware assisted breakpoint
trace – Set a tracepoint at specified location
watch – Set a watchpoint for an expression

Command class: data

agent-printf – Agent-printf “printf format string”
append – Append target code/data to a local file
append binary – Append target code/data to a raw binary file
append binary memory – Append contents of memory to a raw binary file
append binary value – Append the value of an expression to a raw binary file
append memory – Append contents of memory to a raw binary file
append value – Append the value of an expression to a raw binary file
call – Call a function in the program
disassemble – Disassemble a specified section of memory
display – Print value of expression EXP each time the program stops
dump – Dump target code/data to a local file
dump binary – Write target code/data to a raw binary file
dump binary memory – Write contents of memory to a raw binary file
dump binary value – Write the value of an expression to a raw binary file
dump ihex – Write target code/data to an intel hex file
dump ihex memory – Write contents of memory to an ihex file
dump ihex value – Write the value of an expression to an ihex file
dump memory – Write contents of memory to a raw binary file
dump srec – Write target code/data to an srec file
dump srec memory – Write contents of memory to an srec file
dump srec value – Write the value of an expression to an srec file
dump tekhex – Write target code/data to a tekhex file
dump tekhex memory – Write contents of memory to a tekhex file
dump tekhex value – Write the value of an expression to a tekhex file
dump value – Write the value of an expression to a raw binary file
dump verilog – Write target code/data to a verilog hex file
dump verilog memory – Write contents of memory to a verilog hex file
dump verilog value – Write the value of an expression to a verilog hex file
explore – Explore a value or a type valid in the current context
explore type – Explore a type or the type of an expression valid in the current
explore value – Explore value of an expression valid in the current context
find – Search memory for a sequence of bytes
init-if-undefined – Initialize a convenience variable if necessary
mem – Define attributes for memory region or reset memory region handling to
output – Like “print” but don’t put in value history and don’t print newline
print – Print value of expression EXP
print-object – Ask an Objective-C object to print itself
printf – Printf “printf format string”
ptype – Print definition of type TYPE
restore – Restore the contents of FILE to target memory
set – Evaluate expression EXP and assign result to variable VAR
set ada – Prefix command for changing Ada-specfic settings
set ada print-signatures – Enable or disable the output of formal and return types for functions in the overloads selection menu
set ada trust-PAD-over-XVS – Enable or disable an optimization trusting PAD types over XVS types
set agent – Set debugger’s willingness to use agent as a helper
set annotate – Set annotation_level
set architecture – Set architecture of target
set args – Set argument list to give program being debugged when it is started
set auto-connect-native-target – Set whether GDB may automatically connect to the native target
set auto-load – Auto-loading specific settings
set auto-load gdb-scripts – Enable or disable auto-loading of canned sequences of commands scripts
set auto-load libthread-db – Enable or disable auto-loading of inferior specific libthread_db
set auto-load local-gdbinit – Enable or disable auto-loading of .gdbinit script in current directory
set auto-load python-scripts – Set the debugger’s behaviour regarding auto-loaded Python scripts
set auto-load safe-path – Set the list of files and directories that are safe for auto-loading
set auto-load scripts-directory – Set the list of directories from which to load auto-loaded scripts
set auto-load-scripts – Set the debugger’s behaviour regarding auto-loaded Python scripts
set auto-solib-add – Set autoloading of shared library symbols
set backtrace – Set backtrace specific variables
set backtrace limit – Set an upper bound on the number of backtrace levels
set backtrace past-entry – Set whether backtraces should continue past the entry point of a program
set backtrace past-main – Set whether backtraces should continue past “main”
set basenames-may-differ – Set whether a source file may have multiple base names
set breakpoint – Breakpoint specific settings
set breakpoint always-inserted – Set mode for inserting breakpoints
set breakpoint auto-hw – Set automatic usage of hardware breakpoints
set breakpoint condition-evaluation – Set mode of breakpoint condition evaluation
set breakpoint pending – Set debugger’s behavior regarding pending breakpoints
set can-use-hw-watchpoints – Set debugger’s willingness to use watchpoint hardware
set case-sensitive – Set case sensitivity in name search
set charset – Set the host and target character sets
set check – Set the status of the type/range checker
set check range – Set range checking
set check type – Set strict type checking
set circular-trace-buffer – Set target’s use of circular trace buffer
set code-cache – Set cache use for code segment access
set coerce-float-to-double – Set coercion of floats to doubles when calling functions
set compile-args – Set compile command GCC command-line arguments
set complaints – Set max number of complaints about incorrect symbols
set confirm – Set whether to confirm potentially dangerous operations
set cp-abi – Set the ABI used for inspecting C++ objects
set data-directory – Set GDB’s data directory
set dcache – Use this command to set number of lines in dcache and line-size
set dcache line-size – Set dcache line size in bytes (must be power of 2)
set dcache size – Set number of dcache lines
set debug – Generic command for setting gdb debugging flags
set debug arch – Set architecture debugging
set debug auto-load – Set auto-load verifications debugging
set debug bfd-cache – Set bfd cache debugging
set debug check-physname – Set cross-checking of “physname” code against demangler
set debug coff-pe-read – Set coff PE read debugging
set debug compile – Set compile command debugging
set debug displaced – Set displaced stepping debugging
set debug dwarf-die – Set debugging of the DWARF DIE reader
set debug dwarf-line – Set debugging of the dwarf line reader
set debug dwarf-read – Set debugging of the DWARF reader
set debug entry-values – Set entry values and tail call frames debugging
set debug expression – Set expression debugging
set debug frame – Set frame debugging
set debug infrun – Set inferior debugging
set debug jit – Set JIT debugging
set debug libthread-db – Set libthread-db debugging
set debug lin-lwp – Set debugging of GNU/Linux lwp module
set debug linux-namespaces – Set debugging of GNU/Linux namespaces module
set debug notification – Set debugging of async remote notification
set debug observer – Set observer debugging
set debug overload – Set debugging of C++ overloading
set debug parser – Set parser debugging
set debug py-unwind – Set Python unwinder debugging
set debug record – Set debugging of record/replay feature
set debug remote – Set debugging of remote protocol
set debug serial – Set serial debugging
set debug stap-expression – Set SystemTap expression debugging
set debug symbol-lookup – Set debugging of symbol lookup
set debug symfile – Set debugging of the symfile functions
set debug symtab-create – Set debugging of symbol table creation
set debug target – Set target debugging
set debug timestamp – Set timestamping of debugging messages
set debug varobj – Set varobj debugging
set debug xml – Set XML parser debugging
set debug-file-directory – Set the directories where separate debug symbols are searched for
set default-collect – Set the list of expressions to collect by default
set demangle-style – Set the current C++ demangling style
set detach-on-fork – Set whether gdb will detach the child of a fork
set directories – Set the search path for finding source files
set disable-randomization – Set disabling of debuggee’s virtual address space randomization
set disassemble-next-line – Set whether to disassemble next source line or insn when execution stops
set disassembly-flavor – Set the disassembly flavor
set disconnected-dprintf – Set whether dprintf continues after GDB disconnects
set disconnected-tracing – Set whether tracing continues after GDB disconnects
set displaced-stepping – Set debugger’s willingness to use displaced stepping
set dprintf-channel – Set the channel to use for dynamic printf
set dprintf-function – Set the function to use for dynamic printf
set dprintf-style – Set the style of usage for dynamic printf
set editing – Set editing of command lines as they are typed
set endian – Set endianness of target
set environment – Set environment variable value to give the program
set exec-direction – Set direction of execution
set exec-done-display – Set notification of completion for asynchronous execution commands
set exec-wrapper – Set a wrapper for running programs
set extended-prompt – Set the extended prompt
set extension-language – Set mapping between filename extension and source language
set filename-display – Set how to display filenames
set follow-exec-mode – Set debugger response to a program call of exec
set follow-fork-mode – Set debugger response to a program call of fork or vfork
set frame-filter – Prefix command for ‘set’ frame-filter related operations
set frame-filter priority – GDB command to set the priority of the specified frame-filter
set gnutarget – Set the current BFD target
set guile – Prefix command for Guile preference settings
set guile print-stack – Set mode for Guile exception printing on error
set height – Set number of lines in a page for GDB output pagination
set history – Generic command for setting command history parameters
set history expansion – Set history expansion on command input
set history filename – Set the filename in which to record the command history
set history remove-duplicates – Set how far back in history to look for and remove duplicate entries
set history save – Set saving of the history record on exit
set history size – Set the size of the command history
set host-charset – Set the host character set
set inferior-tty – Set terminal for future runs of program being debugged
set input-radix – Set default input radix for entering numbers
set interactive-mode – Set whether GDB’s standard input is a terminal
set language – Set the current source language
set libthread-db-search-path – Set search path for libthread_db
set listsize – Set number of source lines gdb will list by default
set logging – Set logging options
set logging file – Set the current logfile
set logging off – Disable logging
set logging on – Enable logging
set logging overwrite – Set whether logging overwrites or appends to the log file
set logging redirect – Set the logging output mode
set max-completions – Set maximum number of completion candidates
set max-user-call-depth – Set the max call depth for non-python/scheme user-defined commands
set max-value-size – Set maximum sized value gdb will load from the inferior
set may-insert-breakpoints – Set permission to insert breakpoints in the target
set may-insert-fast-tracepoints – Set permission to insert fast tracepoints in the target
set may-insert-tracepoints – Set permission to insert tracepoints in the target
set may-interrupt – Set permission to interrupt or signal the target
set may-write-memory – Set permission to write into target memory
set may-write-registers – Set permission to write into registers
set mem – Memory regions settings
set mem inaccessible-by-default – Set handling of unknown memory regions
set mi-async – Set whether MI asynchronous mode is enabled
set mpx – Set Intel Memory Protection Extensions specific variables
set mpx bound – Set the memory bounds for a given array/pointer storage in the bound table
set multiple-symbols – Set the debugger behavior when more than one symbol are possible matches
set non-stop – Set whether gdb controls the inferior in non-stop mode
set observer – Set whether gdb controls the inferior in observer mode
set opaque-type-resolution – Set resolution of opaque struct/class/union types (if set before loading symbols)
set osabi – Set OS ABI of target
set output-radix – Set default output radix for printing of values
set overload-resolution – Set overload resolution in evaluating C++ functions
set pagination – Set state of GDB output pagination
set print – Generic command for setting how things print
set print address – Set printing of addresses
set print array – Set pretty formatting of arrays
set print array-indexes – Set printing of array indexes
set print asm-demangle – Set demangling of C++/ObjC names in disassembly listings
set print demangle – Set demangling of encoded C++/ObjC names when displaying symbols
set print elements – Set limit on string chars or array elements to print
set print entry-values – Set printing of function arguments at function entry
set print frame-arguments – Set printing of non-scalar frame arguments
set print inferior-events – Set printing of inferior events (e.g.
set print max-symbolic-offset – Set the largest offset that will be printed in