Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: myle on April 26, 2008, 03:52:19 pm

Title: Variables in Heap: View values (debugger)
Post by: myle on April 26, 2008, 03:52:19 pm
I am running Ubuntu 8.04 and I have installed the Code::Blocks from the repositories:
deb http://lgp203.free.fr/ubuntu/ hardy universe
deb http://apt.wxwidgets.org/ hardy-wx main

The problem which I face is that I can't see the value of some specific position of an array allocated in heap (via new or malloc, I think I tried it both on C and C++). The local variables or the function arguments are properly shown in the Debug > Debugging Windows > Watches but not in Debug > Debugging Windows > Examine Memory if I write &var where var is a local variable. It displays nothing.
Same goes to the variables which are allocated dynamically but the problem is that I don't know any other way to see their values (using C::B)

I guess I am doing something wrong. What is it and how can I see the values of the variables?

Thanks for your replies,
if my question is silly, I am sorry but I am a newbie here.
Title: Re: Variables in Heap: View values (debugger)
Post by: thomas on April 28, 2008, 10:05:01 am
The debugger doesn't have enough information to show the values. Neither does it know that the pointer points to an array, nor the array's size.

You can get it to print your array by sending a manual command to the debugger (last menu item in the debug menu):
p *array@size   (if your variable name is x and the array has 20 elements, type p *x@20)

http://www.delorie.com/gnu/docs/gdb/gdb_54.html
Title: Re: Variables in Heap: View values (debugger)
Post by: myle on April 28, 2008, 03:51:09 pm
Thanks Thomas.
The values are shown in the debugger tab of Logs & others.