CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 13 of 13

Thread: De-bugging....?

  1. #1
    Join Date
    Nov 2005
    Posts
    24

    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 ?

  2. #2
    Join Date
    Aug 2002
    Posts
    879

  3. #3
    Join Date
    Nov 2005
    Posts
    24

    Red face 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)

  4. #4
    Join Date
    Aug 2002
    Posts
    879

    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.

  5. #5
    Join Date
    Feb 2005
    Location
    Normandy in France
    Posts
    4,590

    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()!

  6. #6
    Join Date
    Jun 2003
    Location
    India
    Posts
    118

    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

  7. #7
    Join Date
    Nov 2005
    Posts
    24

    Thumbs down 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??

  8. #8
    Join Date
    Jun 2003
    Location
    India
    Posts
    118

    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

  9. #9
    Join Date
    Jun 2003
    Location
    India
    Posts
    118

    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

  10. #10
    Join Date
    Feb 2005
    Location
    "The Capital"
    Posts
    5,306

    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.

  11. #11
    Join Date
    Jun 2003
    Location
    India
    Posts
    118

    Re: De-bugging....?

    Quote 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

  12. #12
    Join Date
    Nov 2005
    Posts
    24

    Thumbs up 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.

  13. #13
    Join Date
    Jun 2003
    Location
    India
    Posts
    118

    Re: De-bugging....?

    Quote 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
  •  





Click Here to Expand Forum to Full Width

Featured