Well, how do you usually debug?
ofstreams and other file output methods
weight training so i can throw the monitor through the window with just one hand
This is a discussion on How do you like to debug? within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Well, how do you usually debug?...
Well, how do you usually debug?
"Circular logic is good because it is."
Lately; the debugger as all of my work has involved SDL and I haven't written a printing routine yet. But otherwise it's normally a combination of cout and the debugger, or MessageBox and the debugger if i'm programming with windows.
I dont think I have written a program longer than 1000 lines, so I usually use the printing way of debugging. I have never used a bebugger, I guess I should learn one day.
Your Move:Life is a game, Play it; Life is a challenge, Meet it; Life is an opportunity, capture it.
> I dont think I have written a program longer than 1000 lines,
Wow, I've done that with BASIC(remember hello world is replaced by PRINT "Hell world!" and nothing else). Not that I'm bragging or anything..but, are you SURE? That seems...odd to me.
And, I prefer my compiler's error output messages and a modular program.
And if i'm not getting errors on compiling, I just fiddle till it's fixed.
The world is waiting. I must leave you now.
>Well, how do you usually debug?
I insert many, many breakpoints, isolate the problem, and then swear at it until it goes away.
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie
>swear at it until it goes away.
that never works for me.. have any pointers? have you found particular words that work better?
on-topic, i usually use cout.. though most bugs i have are from typos
bad subscript indexing usually goes away when you make bad jokes about its mother.
Sometimes I think the compiler screwed up, so I compile my
project about 3 more times before I actually try to fix anything.
Staying away from General.
I like your style, man.
Well, if there's no butterfly effect type predicament, I simply comment out a function call until I nail it. Printing works good too, except in Windows sometimes (MSGBOXES can cause crashes, lol).
99% of the time it's a dereferenced null pointer, and index violations of course.
>>99% of the time it's a dereferenced null pointer, and index violations of course.
I use a large combination of techniques. They all have their advantages. The debugger is useful for the stupid mistakes: The aforementioned dereferenced pointers, and index violations, but its not much good for those application specific bugs that dont cause crashing or OS specific errors. So my applications (Windows or otherwise) usually display a running debug output on top of the viewscreen. This way the last consecutivly called functions or areas of the program are displayed in the event of a lockup. Debug data is also always able to be output to file in case of a total system crash. Current functions being executed and any other possible data that can be gathered is also output to file in the event of unexpected termination.
The worst ones are where you reboot and the problem refuses to surface again for three months, at which point you've completly forgotten about it.
"There's always another way"
>BAH! My programs don't have bugs!
mine either. they just have "hidden features"
How bout exeptions? Personally, I think they're too much work - cant be bothered putting them all over the place...yeh and my programs seem to like adding their own little features to them selves
When I programmed in Delphi I used to make extensive use of the debugger. However, when I moved to the first version of C++ Builder, I had real problems with it. So I switched to using MessageBoxes. Later Borland fixed the problems with the debugger, but by that time I had lost all dependence upon it.
Now I have my own DebugLog class which I used in all my projects. I puts everything to file, including class names, method names etc.
>How bout exeptions? Personally, I think they're too much work
Exceptions are a really good idea. They make your errors explicit, denying them a place to hide, and forcing you to fix them. However, I prefer the way Java forces the user to declare exceptions at method interfaces, which is even more work, but reduces errors.
Here's tip. Never ever accept compiler warnings of any kind when compiling your project. Fix them. Years ago I used to ignore warnings because I thought I knew best, but consequently my programs were full of bugs. Now I won't accept them & I have far fewer bugs. In Java, there are no warnings, just errors. This is much better.
OS: Windows XP
Compilers: MinGW (Code::Blocks), BCB 5
Yeh, but what about warnings like those that you're not worried about and are part of your code, like assigning an floating point variable's data to an integer's data, even though you may have wanted this rounding to occur, it still warns you. eg,,Here's tip. Never ever accept compiler warnings of any kind when compiling your project. Fix them. Years ago I used to ignore warnings because I thought I knew best, but consequently my programs were full of bugs. Now I won't accept them & I have far fewer bugs. In Java, there are no warnings, just errors. This is much better.And how about in the following code:Code:int nVar; double fVar = 2.9; nVar = fVar;you would get a warning becuase the return type of strlen() is of unsigned int and you're comparing it to an int (i). Is it needed to change it to this?Code:for(int i = 0; i < strlen(char_array); i++)Code:for(unsigned int i; i < strlen(char_array); i++)
Last edited by face_master; 12-11-2002 at 04:12 AM.