Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to view contents of an array while debugging in Code Blocks?

This is probably a silly question and i am posting this Post-Googling, The question is,

How do i view the contents of an array while debugging, Provided the Breakpoint is in function not Main?

I am using code::blocks 13.12 version and i set a break point in my sample simple c++ code, and i want to observe how the contents of the array change with the code but all i see is the the address of the array under watch window, It is however displaying the values of other integer variables correctly,

enter image description here

a is an array

I forgot to mention that i am tracking the array in a function and not in main,and i am aware that main passes the address of the array to the function being called(by reference i meant)

I am relatively new to codeblocks, Am i missing some setting or something?

like image 356
Ravi Yenugu Avatar asked Mar 08 '14 03:03

Ravi Yenugu


3 Answers

Right click on the cell, then select "Properties", there you can tell it to "watch as array", and tell it the index range to watch.

like image 147
Calmarius Avatar answered Sep 30 '22 16:09

Calmarius


i am using 12.11. I select the array variable suppose a, choose "watch a" in the right button down menu, and I can see the values in the array a.

like image 24
michaeltang Avatar answered Sep 30 '22 14:09

michaeltang


Another thing that I use is watching under cursor.

If you go Settings -> Debugger... -> GDB/CDB debugger -> Default and you enable selection "Evaluate expressions under cursor", every time you leave mouse pointer above a variable in the code, it will be watched.

It's not the same with having it in Watches toolbar, but strangely it will show array's fields.

like image 24
nikniknik Avatar answered Sep 30 '22 16:09

nikniknik