how to debug

I want to know how to debug a C program in linux platform. Is there anything similar to "Add Watch", as in Turbo C DOS platform, in Linux?
Who is Participating?
RobsonConnect With a Mentor Commented:
Yes there is, and much more. Standard debugger in Linux is gdb (Gnu debugger, command line driven). If it's too hard, try graphical interfaces to it: ddd (Data Display Debugger), xxgdb and many, many more. If you use one of popular Linux distrubution, you've probably already got them.
.. and don't forget to compile and link with -g option before using *gdb.
depending on you distribution, and if you have an X server installed, if you do gnorpm you can see all the debuggers installed on your system.  if you are a beginner, I suggest kdbg it is nice easy to use and as stabe as they get. , yeah and don't forget what ahoffmann said about the -g2 option
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  if u have a redhat Linux here is how to debug a c program using the gdb debugger.
  step 1: compile ur c program first.( eg., cc -g -o a.out a.c)

  step 2:now u do gdb with the object file created..
         (eg., gdb a.out)
  step 3: now u will be in the debugging mode, where u can do many debugging operations...
  if u want to set a break point in a particular position of ur program then u type
    b position_where_break_point_is_to_be_set
  u can set any number of break points like this...
  then to start running the program u have to type
    r - r will start running the program...
  u have to type n to execute the next line of the program..
  if u like to see what is the value of a variable u can use p command. that is,
  p variable_name - will print the value of the variable..
  to quit the debugger use q command.
  to do the previous operation again then just press the return key.
  u can also use the help availble.


Try kdevelop.
You can get it at
It is a nice graphical interface, takes care of the dirty work of writing configure scripts, handles CVS and many other useful things. And debugging :o)
Force Accepted

Community Support Moderator @Experts Exchange
All Courses

From novice to tech pro — start learning today.