#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    142
    Rep Power
    2

    Debugging in code::blocks


    I read the wiki article (http://wiki.codeblocks.org/index.php?title=Debugging_with_Code::Blocks) and tried to use the watch feature but it doesn't work.

    Here's my code.
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    int main(void)
    {
        double a;
    
        a = 2.0;
    
        printf("%f", a);
        return 0;
    }
    Here's what I did:
    1. create project as instructed.
    2. since i didn't know what I was supposed to do next from the wiki article, I went to stack overflowstack overflow .
    3. toggle break point, and hit shift + F7

    But nothing happened.
    Nothing was added to the watch windows, and I didn't see the small window that says "Local variables" and "Function arguments" as shown in the wiki.

    How am I supposed to use this watch feature?
    I read some pages and I still have no clue.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    3
    Rep Power
    0
    the code is fine, and btw %lf can be used in order to represent double(not only %f).

    I dont really get your problem, what is your compiler name? what kind of eror message did u recive?
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    142
    Rep Power
    2
    The problem is that nothing happens.
    According to the pages I read, the value of the variable a, which is 2.0 is supposed to show up somewhere in the watches window, but I don't see anything.

    If you mean the name of the compiler under
    Project > Build Options,
    the selected compiler is GNU GCC Compiler.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    159
    Rep Power
    19
    On what line did you place the breakpoint?

    What version of Code::Blocks are you using. On my version of Code::Blocks, after setting the breakpoint the key combination is F8 to start the debugging process then F7 to single step, Shift F7 to step into a function or single step.

    You must first start the debugger with the F8 before anything will happen.

    Jim
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    142
    Rep Power
    2
    What version of Code::Blocks are you using.
    I just downloaded it a few days ago; it's 12.11.

    I put the breakpoint on the line
    Code:
    a = 2.0;
    .
    You must first start the debugger with the F8 before anything will happen.
    I tried that, and I saw an yellow triangle appear at the same line as the breakpoint.
    Otherwise nothing happened.
    So I right-clicked the variable 'a' on the breakpoint line mentioned above, and selected "Watch 'a'". (I don't see any "Add to watch" option, which the articles I've read tell me I'm supposed to)
    Then a row entry was created in the Watch window with a; nan(0xdf0007ffdfc00); double.
    I understand the first and third entries are the name and the data type of the variable, but what is the middle entry?
    When I hover my mouse over it, it says "a=nan(0xdf0007ffdfc00)", so apparently it's a's value.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    159
    Rep Power
    19
    You can check which debug windows are visible during a debug session by viewing the Debugging Windows menu item under the Debug menu item. See the attached images.

    I understand the first and third entries are the name and the data type of the variable, but what is the middle entry?
    The middle entry is because at this time a is uninitialized, if you press F7 you should then see that 'a' now has a value.

    Jim
    Attached Images
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    142
    Rep Power
    2
    Thank you, I can now see the change in the value of a.

    So does this mean that debugging is completed for all the lines before the yellow arrow, and for the line at which the yellow arrow points, debugging is not yet completed?
    (In other words, the next step begins at the line with the arrow, not the one below it. )

    But I still have an issue with the watches window.
    Although I checked the Call Stack and Watch for the windows setting, my watches window doesn't have a list of "Local Variables" and "Function arguments" like yours.
    Instead, it's a table.
    Is this because I have a different version, or did I get something wrong?

    The link below is a screenshot:
    http://snag.gy/Qw3LN.jpg
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    159
    Rep Power
    19
    So does this mean that debugging is completed for all the lines before the yellow arrow, and for the line at which the yellow arrow points, debugging is not yet completed?
    Yes.

    Although I checked the Call Stack and Watch for the windows setting, my watches window doesn't have a list of "Local Variables" and "Function arguments" like yours.
    Instead, it's a table.
    Is this because I have a different version, or did I get something wrong?
    This is either a difference between the versions of Code::Blocks or a difference because of the operating system. My output is from Linux using version 10.05. I get the table if I run Code::Blocks 12 in Windows. I don't have version 12 on Linux so I don't really know the exact cause of the differences.

    Jim
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    142
    Rep Power
    2
    This is either a difference between the versions of Code::Blocks or a difference because of the operating system. My output is from Linux using version 10.05. I get the table if I run Code::Blocks 12 in Windows. I don't have version 12 on Linux so I don't really know the exact cause of the differences.
    I see.
    Thank you so much for the help.

IMN logo majestic logo threadwatch logo seochat tools logo