gdb学习8:设置程序运行时的参数

用到两个命令: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。

参考:https://blog.csdn.net/dadalan/article/details/3758025

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值