GDB带参数调试

来源:互联网 发布:长城网络还原大师bios 编辑:程序博客网 时间:2024/05/19 01:29

参考地址

http://blog.sina.com.cn/s/blog_4b6f784001011yvh.html


步骤如下:

比如程序的名字为hello 参数为a b c

则运行该程序的命令为:

$ ./hello  a  b  c

那么调试的时候 可以这样:

$ gdb hello

(gdb) set args a b c

(gdb) r

(gdb)

(gdb) quit ( or q )

$


另外一种调试方法:先设置断点 然后再启动程序

从main函数启动程序

$ gdb ./online

(gdb)  b main

(gdb)  set args ../conf/bench.conf

(gdb)  r

(gdb) n

(gdb) p argv[0]

(gdb)

(gdb) quit

$






0 0
原创粉丝点击