LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-03-2012, 04:10 AM   #1
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Rep: Reputation: 76
gdb


Hi:

I have program foo which takes an argument. How do I tell gdb foo takes an argument (in the command line)?
 
Old 07-03-2012, 04:13 AM   #2
414N
Member
 
Registered: Sep 2011
Location: Italy
Distribution: Slackware
Posts: 647

Rep: Reputation: 189Reputation: 189
You should be good with
Code:
gdb foo
[...]
(gdb)r arg1 arg2 arg3 arg4
 
1 members found this post helpful.
Old 07-03-2012, 04:20 AM   #3
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
It work. Thanks 414N.
 
Old 07-03-2012, 06:59 AM   #4
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Within gdb,

(gdb) r arg1

runs the program from where the pc is at that time with argument arg1. If I want to start a program from main, but telling gdb the program accepts argument arg1, but single stepping, how do I do?
 
Old 07-03-2012, 07:26 AM   #5
414N
Member
 
Registered: Sep 2011
Location: Italy
Distribution: Slackware
Posts: 647

Rep: Reputation: 189Reputation: 189
You should set a breakpoint on the main function:
Code:
(gdb)break main
prior to running the program. When the breakpoint is reached, you can step through the lines of your program with the step command (s).
 
1 members found this post helpful.
Old 07-04-2012, 03:03 AM   #6
kauuttt
Member
 
Registered: Dec 2008
Location: Atlanta, GA, USA
Distribution: Ubuntu
Posts: 135

Rep: Reputation: 26
Please refer the below links..

http://darkdust.net/files/GDB%20Cheat%20Sheet.pdf
http://erik.cabetas.com/stuff/debug/gdb-essentials.pdf
http://www.yolinux.com/TUTORIALS/GDB-Commands.html

Hope it helps!

-kd
 
Old 07-17-2012, 03:19 PM   #7
resetreset
Senior Member
 
Registered: Mar 2008
Location: Cyberspace
Distribution: Dynebolic, Ubuntu 10.10
Posts: 1,340

Rep: Reputation: 62
hey kauttt, what are you doing that makes you interested in things like this? I am too, and I'm also Indian, can we get in touch? could you tell me how I can email you?
 
Old 07-18-2012, 02:12 AM   #8
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
Have you guys tried using ddd
it's a nice front-end to gdb

(and other debuggers, and even perl I think)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
zypper install gdb, does not install the latest version of GDB Aquarius_Girl SUSE / openSUSE 4 12-30-2010 03:00 AM
Need help with GDB sailwind Programming 2 05-16-2006 11:08 AM
normal gdb and spec gdb for kgdb Igor007 Programming 1 09-23-2005 04:15 PM
normal gdb and spec gdb for kgdb Igor007 Linux - Newbie 1 09-23-2005 01:41 PM
gdb .. looking for 32 bit gdb.. for ia64 suse.. nkshirsagar SUSE / openSUSE 0 12-09-2004 03:02 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration