GDB debugging a program with parameters

Source: Internet
Author: User

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

Example:
  #include <stdio.h>int  Main (int  argc,char  *argv[] { int  i = argc; printf (  argc:%d\n   " ,i);  for  (i = 0 ; i < Argc;i++  argv[%d]:%s\n   " ,i,argv[i]);  return  1    
Output:
gcc -G-~]#./Main a b cargc:4argv[0]:./mainargv[  1]:aargv[2]:bargv[3]:c
Debug:
[[Email protected] (none) ~]# gdb maingnu gdb Red Hat Linux (6.6-8. Fc7rh) Copyright (C)2006Free software Foundation, Inc.gdb is Freesoftware, covered by the GNU general public License, and your arewelcome to change it and/or distribute copies of it under certain conditions. Type"Show Copying"To see the conditions. There is absolutely no warranty forGdb. Type"Show Warranty"  fordetails. This GDB is configured as"I386-redhat-linux-gnu"... Using Host libthread_db Library"/lib/libthread_db.so.1". (GDB) set args a b c (GDB) rstarting program:/root/main a b cargc:4argv[0]:/root/mainargv[1]:aargv[2]:bargv[3]:cprogram exited with code on. (GDB)
or you can use R a B c as well.

GDB debugging a program with parameters

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.