June 11th, 2013, 05:21 AM
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.
Here's what I did:
a = 2.0;
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.
June 11th, 2013, 06:15 AM
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?
June 11th, 2013, 06:22 AM
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.
June 11th, 2013, 07:00 AM
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.
June 11th, 2013, 01:28 PM
I just downloaded it a few days ago; it's 12.11.
I put the breakpoint on the line .
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.
June 11th, 2013, 02:35 PM
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.
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.
June 11th, 2013, 03:48 PM
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:
June 11th, 2013, 03:59 PM
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.
June 11th, 2013, 07:09 PM
Thank you so much for the help.