-
November 22nd, 2005, 09:46 AM
#1
De-bugging....?
Though I have been doing C programming for a while, still I'm not able to understand what debugging exactly does to a program.Actually, what does a compiler do when asked to debug a program ?
-
November 22nd, 2005, 10:04 AM
#2
-
November 23rd, 2005, 05:03 AM
#3
Re: De-bugging....?
Thanks for the link man...but I just wanted to know what the compiler would do when I click on the DEBUG(coz' I cant see anything special happening)
-
November 23rd, 2005, 05:24 AM
#4
Re: De-bugging....?
I'm not sure what you mean by "when I click on the DEBUG".
But check-out this (debugging in VS)
http://www.cs.virginia.edu/~cs216/la...sual%20C++.htm
Differences release/debug
http://www.programmersheaven.com/2/F...-Debug-Release
Last edited by blueday54555; November 23rd, 2005 at 05:27 AM.
-
November 23rd, 2005, 05:42 AM
#5
Re: De-bugging....?
When an IDE (Integrated Devlopment Environment) is debugging a program, it just means that you can put breakpoints on lines in the program, directly in the editing window of each module.
You can also step through each line, seeing an indicator which says where the program is currently.
There exists probably a "debug" or "run" menu in your IDE, which contains commands such as : "step into", "step over", "breakpoint", "run", "run to", "watch expression", "watch variable".
"inherit to be reused by code that uses the base class, not to reuse base class code", Sutter and Alexandrescu, C++ Coding Standards.
Club of lovers of the C++ typecasts cute syntax: Only recorded member.
Out of memory happens! Handle it properly!
Say no to g_new()!
-
November 23rd, 2005, 06:31 AM
#6
Re: De-bugging....?
Hi,
Debugging is very good utility provided by compiler providers (?). When you starts debugging the program, you can stop the program at any given point i.e. line. Which helps you to determine the value of particular variable and further you can keep a track of that variable.
Lets say, you are encountered to the exception violation in your program. How you will find out that at which line the code is broken ? To find out the cause of exception violation, you need to debug the program.
I belive this explanation will helps you.
-PiyuNewe
-
November 24th, 2005, 05:03 AM
#7
Re: De-bugging....?
Thanks for those links 'Blueday'..really informative
But as i said earlier... i would prefer if any1 of u would explain me the difference between de-bugging a program and running it.
OK...u might be a bit confused.....about what i want to say..-->
<><><><><><><><><><>><><><><><><><><><><><><><><><><>
I have a Dev C++ Bloodshed compiler 4.9.9.2 edition. On the debug menu..there are a no. of options.According to PiyuNewe ==>Debigging helps identify errors..but thats the same thing that running a program also does.When i compile the program..the compiler highlight any error in the source code if there is.Then what's the difference??
-
November 24th, 2005, 05:33 AM
#8
Re: De-bugging....?
Your compiler can't point out "Exception Violation" kind of errors. In my earlier answer Error is not the compiler time "error", but it is run time error.
As you mentioned that, compiler highlights any error in the source code. But it wont highlight you any run time errors.
Consider the code segment below.
main()
{
typedef struct test
{
char *string;
int len;
}TEST_STRUCT;
TEST_STRUCT test;
strcpy( test.string, "test") ;
test.len = strlen( test.string );
}
This program will not give you any error during compilation. But it wont work and you will face access violation at "strcpy" statement. Because the "string" element of structure is not allocated.
To find out the problem (runt-time error) you need debugger.
I hope this explanation is worth to understand the need of debugger.
-PiyuNewe
-
November 24th, 2005, 05:39 AM
#9
Re: De-bugging....?
One more thing !!!
Using my above post you can understand the difference between the Compiler and Debugger. The code segment was too small (it is like nothing). In this code you can easily recognized the run time errors but what about the million lines of code. You will never know which pointer is causing the problem ("Access Violation"), that time you need Debugger.
If your program is not giving an expected result (but you think that you have coded it properly), that time you need a debugger to find out the root cause.
-PiyuNewe
-
November 24th, 2005, 06:32 AM
#10
Re: De-bugging....?
Recently, I have been working on unix systems. You can run the code in both normal executable (non-debug?) mode and debug mode. The compiler option on gcc is -g, I guess. When you do that there is a substantial increase in the size of the executable. What the compiler does is keeps some information (symbols etc) that could be helpful to you (actually not you.. but the debugger for things like retrieving the values of variables in the debug mode, getting the stack trace) when the code is run step by step (by the debugger). You could look into a small introductory article about this here - gdb tutorial. Hope this helps. Regards.
Can you help me with my homework assignment?, Before you post!, Use code tags, How to post!, Codeguru technical FAQs, C++ FAQ Lite, Stroustrup: C++ Style and Technique FAQ, Guru of the Week, Comeau C and C++ FAQs, Comeau C++ Templates FAQs, CUJ @ DDJ, Spam threshold
My Blogs : Learning C++ is fun | Abnegator's reflections
Open Threads : C++ Aha! Moments | Nature of work in C++?
-
November 24th, 2005, 06:57 AM
#11
Re: De-bugging....?
Originally Posted by exterminator
Recently, I have been working on unix systems. You can run the code in both normal executable (non-debug?) mode and debug mode. The compiler option on gcc is -g, I guess. When you do that there is a substantial increase in the size of the executable. What the compiler does is keeps some information (symbols etc) that could be helpful to you (actually not you.. but the debugger for things like retrieving the values of variables in the debug mode, getting the stack trace) when the code is run step by step (by the debugger). You could look into a small introductory article about this here - gdb tutorial. Hope this helps. Regards.
I belive there is a long way to know this debug information.
BTW, this is the link to understand what is RUN-TIME errors http://www.webopedia.com/TERM/R/runtime_error.html.
To findout these errors Debugger is required.
-PiyuNewe
-
November 24th, 2005, 12:54 PM
#12
Re: De-bugging....?
Thanks guys, now i know what the difference is between compile time and run-time errors.
Thanks a lot PiyuNewe.. your explanation was fantastic.
-
November 24th, 2005, 10:45 PM
#13
Re: De-bugging....?
Originally Posted by apoc_akshay
Thanks guys, now i know what the difference is between compile time and run-time errors.
Thanks a lot PiyuNewe.. your explanation was fantastic.
You are welcome !
-PiyuNewe
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|