用到两个命令:set和show。
set命令,tab键两下,如下:
(gdb) set
Display all 131 possibilities? (y or n)
ada may-insert-breakpoints
agent may-insert-fast-tracepoints
annotate may-insert-tracepoints
architecture may-interrupt
args may-write-memory
auto-connect-native-target may-write-registers
auto-load mem
auto-solib-add mi-async
backtrace mpx
basenames-may-differ multiple-symbols
breakpoint non-stop
can-use-hw-watchpoints observer
case-sensitive opaque-type-resolution
charset osabi
check output-radix
circular-trace-buffer overload-resolution
code-cache pagination
coerce-float-to-double print
compile-args prompt
complaints python
confirm radix
cp-abi range-stepping
data-directory record
--More--
set命令设置完之后,用show查看,可以单独查看某个变量的设置情况,
(gdb) show
ada print-signatures: Whether the output of formal and return types for functions in the overloads selection menu is activated is on.
ada trust-PAD-over-XVS: Whether an optimization trusting PAD types over XVS types is activated is on.
agent: Debugger's willingness to use agent in inferior as a helper is off.
annotate: Annotation_level is 0.
architecture: The target architecture is set automatically (currently i386)
args: Argument list to give program being debugged when it is started is "".
auto-connect-native-target: Whether GDB may automatically connect to the native target is on.
auto-load gdb-scripts: Auto-loading of canned sequences of commands scripts is on.
auto-load libthread-db: Auto-loading of inferior specific libthread_db is on.
auto-load local-gdbinit: Auto-loading of .gdbinit script from current directory is on.
auto-load python-scripts: Auto-loading of Python scripts is on.
auto-load safe-path: List of directories from which it is safe to auto-load files is $debugdir:$datadir/auto-load.
auto-load scripts-directory: List of directories from which to load auto-loaded scripts is $debugdir:$datadir/auto-load.
auto-load-scripts: Auto-loading of Python scripts is on.
auto-solib-add: Autoloading of shared library symbols is on.
backtrace limit: An upper bound on the number of backtrace levels is unlimited.---Type <return> to continue, or q <return> to quit---
里面有个args被我set args 10之后,设置成10了。
又比如,修改list显示内容10行为20行,
(gdb) set list 20
(gdb) show list
Number of source lines gdb will list by default is 20.
(gdb) file strcopy
Reading symbols from strcopy...done.
(gdb) l
5 char *MyStrCopy1(const char *s1)
6 {
7 if(NULL == s1)
8 {
9 return "string is NULL";
10 }
11 else
12 {
13
14 char *s2 = (char *)malloc(strlen(s1)+1);
15 if(NULL == s2)
16 {
17 return "malloc error";
18 }
19 char *p = s2;
20 while((*s2++ = *s1++));
21 return p;
22 }
23 }
24
(gdb)
其实就是配置gdb。