gdb - 调试带参数的程序
2014-03-17 11:42
260 查看
例子:
#include <stdio.h> int main(int argc,char *argv[]) { int i = argc; printf("argc:%d\n",i); for(i = 0;i < argc;i++) printf("argv[%d]:%s\n",i,argv[i]); return 1; }输出:
[root@(none) ~]# gcc -g -o main main.c [root@(none) ~]# ./main a b c argc:4 argv[0]:./main argv[1]:a argv[2]:b argv[3]:c调试:
[root@(none) ~]# gdb main GNU gdb Red Hat Linux (6.6-8.fc7rh) Copyright (C) 2006 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License,and you are welcome to change it and/or distribute copies of it under certainconditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type"show warranty" for details. This GDB was configured as "i386-redhat-linux-gnu"... Using host libthread_db library "/lib/libthread_db.so.1". (gdb) set args a b c (gdb) r Starting program: /root/main a b c argc:4 argv[0]:/root/main argv[1]:a argv[2]:b argv[3]:c Program exited with code 01. (gdb)或者用 r a bc也可以的
相关文章推荐
- gdb调试带参数程序
- gdb调试带参数程序
- gdb调试带参数的程序 (转载)
- GDB调试带参数程序
- gdb带参数调试程序
- 使用gdb调试程序详解和GCC参数详解
- gdb调试带参数程序
- gdb 调试带参数的程序
- gdb调试带参数的程序
- gdb调试带参数的程序
- gdb 调试带参数的程序-转
- gdb调试带参数程序
- GDB调试带参数的程序
- gdb 调试带参数的程序
- GDB 调试带参数程序的方法int main(int argc,char *argv[])
- 使用gdb调试程序详解和GCC参数详解
- gdb调试带参数程序
- gdb调试带参数程序
- gdb 调试带参数的程序
- gdb调试运行程序带参数(调用动态链接库),debug过程记录