Click here to Skip to main content
15,868,164 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hello,

I had created a sample application in c.
For compilation and execution on unix, i created makefile.
I want to debug my c code, when i execute it from Unix.

How can I debug my c code on unix platform?

Thanks in advance. :-O
Posted
Updated 9-Apr-10 7:50am
v2

I would suggest the following:
- Console tool[^]
- GUI tool[^] <- very comfortable :)
 
Share this answer
 
As well as Eugen's suggestions, I'd recommend Valgrind[^].
 
Share this answer
 
Nice answers, but Poonamol was asking about Unix, and these are all Linux tools.
Most Unices will include dbx: http://en.wikipedia.org/wiki/Dbx_(debugger)
In some cases you may have to rely on adb: http://en.wikipedia.org/wiki/Absolute_Debugger.

Check with the compiler manufacturer. Most compilers will also throw a nice debugger in with the package.
sdb is also an option (C only): http://en.wikipedia.org/wiki/Sdb_(debugger)
 
Share this answer
 
I am using xlc_r compiler version 8.0 on AIX.

To use dbx.
on AIX command prompt I typed:
dbx help
It goes into (dbx) prompt
But after that i do not know what to do to put breakpoints in my program and how to run step by step.

Help me out ASAP.
Thanks in advance.
 
Share this answer
 
v2
you can use a software named gba to debug your program. gba is a useful debuger of c/c++.it can help you to observe the inner structure and the memory of the program.so i suggest you to have a try.
 
Share this answer
 
I am not using gcc command to compile code.

I had created makefile using cc command.
How can I set the option to enable the dbx?

can I pass makefile name to dbx?

thanks in advance.
 
Share this answer
 
v2
Hi! It's good that you want to learn the basic debugging tools for the command line (also see tutorial 1[^], tutorial 2[^]), I can only encourage to have some nerdfun and do it! :)

When you develop larger projects you will probably debug from withing the IDE, for example Eclipse. Here are two links that might be interesting:

- C/C++ development with the Eclipse Platform[^]
- Accessing gdb with the Eclipse CDT and MI[^]
 
Share this answer
 
Poonamol wrote:
It goes into (dbx) prompt
But after that i do not know what to do to put breakpoints in my program and how to run step by step.


Try to type help in the prompt mode
and see the second example here[^] :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900