12af3
![]() |
|
|
|
|
|||||||
| Userland Programming & Scripting C, Shell, Perl, Sed & Awk |
![]() |
|
|
Thread Tools | Display Modes |
|
#1
|
||||
|
||||
|
What kind of tools do you use to debug c/c++ code?
I'm learning c/c++, tools tips&tricks welcomed here
|
|
#2
|
||||
|
||||
I also recommend - "The Art of Debugging with GDB, DDD, and Eclipse (No Starch Press, September 2008, 280 pp, ISBN 9781593271749)" book. It has lots of info which I wasn't aware of..
__________________
Neither in this world nor elsewhere is there any happiness in store for him who always doubts. If you enjoyed my answer please consider donating some money to FreeBSD foundation @ http://www.freebsdfoundation.org/ |
|
#3
|
||||
|
||||
|
Personally I prefer the larger IDE's. I started coding both C and java in Eclipse but have since then moved to Netbeans as I find the UI a bit more responsive than Eclipse. Both of these has a built in debugger, editor etc(as they are IDE's). My personal opinion is that module management(extra programming language support etc) is a bit better in NetBeans than Eclipse.
A book that have had good use of is "Practical C Programming" from O'Reilly, as you always do something stupid and totally obvious once you have found the error. |
|
#4
|
|||
|
|||
|
C:
gdb, valgrind (hopefully an amd64 version will be out soon...), printf
Last edited by hydra; February 16th, 2009 at 14:03. |
|
#5
|
||||
|
||||
|
Gdb when I really need it, although I tend to debug the old-fahioned way using printf(C)/cout(C++)/System.out.printf(java) statements.
I know it's kinda bad practice but I tend to only turn to a proper debugger (which for me would be gdb) when I really really need it pretty badly. In fact, another practice is breaking down your code into small chunks (e.g. functions with clear and cut purpose) and writing tests for all those chunks, as well as keeping track of pre-/postconditions and loop invariants. I'm often too lazy for this, but if you can bring up the discipline it really helps. Alphons
__________________
Ken sent me. |
|
#6
|
||||
|
||||
|
atm i do the same
|
|
#7
|
||||
|
||||
|
I remember it was easy in the old days when I used Borland C or Borland Pascal. Their builtin debugger was pretty easy to use (*) so it would have been kinda silly not to use it. But since I started coding on UNIX boxes with vi(m) and gcc it's pretty much been the printf() method except for some odd cases where I really needed to use an actual debugger.
But then again, I'm too lazy to properly document pre-/postconditions and loop invariants. Plus that I find all those comments somewhat cluttering. That is in fact what I dislike most about javadoc. In itself it's a great idea but all those comments drive me nuts at times. When I'm coding in Java it occasionally occurs to me that I'm writing more comments than actual code (edit: ditto in terms of thinking time)Alphons Ad (*): Actually, so was their entire IDE. You could do pretty much anything with just a simple key combo. Those old Borland products were the only IDEs I've ever found usable and I haven't used any IDEs since I discovered UNIX a little over 10 years ago.
__________________
Ken sent me. Last edited by fonz; February 14th, 2009 at 00:46. Reason: Small side remark added |
|
#8
|
|||
|
|||
|
Quote:
|
|
#9
|
||||
|
||||
|
I use gdb. But really only to read backtraces.
__________________
sysutils/bsdadminscripts: binary package maintenance, library integrity checking, ... sysutils/automounter: amd(8) based automounting without HAL contact: kamikaze@bsdforen.de Disclaimer: My posts represent my perception. Errors and incompleteness are to be expected, I deny any responsibility to know everything. |
|
#10
|
||||
|
||||
|
Code:
main ()
{
#ifdef DEBUG
printf("It reached checkpoint A");
#endif
return 0;
}
I know it is too primitive, but it works for me (I wanna learn to use the gdb mentioned above. Greetings from Mexico Sergio Ligregni
__________________
Is UNIX hot enough for you? | FreeBSD |
|
#11
|
||||
|
||||
|
There is a similar macro NDEBUG, which is standard (when defined, assert() calls are ignored).
__________________
:wq |
![]() |
| Thread Tools | |
| Display Modes | |
|
|