Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: SamT on July 15, 2006, 02:36:08 am

Title: How to watch each value in an array during debugging?
Post by: SamT on July 15, 2006, 02:36:08 am
Hi,

I try to use the debug function in CB to debug my program. When I "watch" an array, I can't get any thing I wanted. Only a pointer shows in the watch table. I have to dereference twice and then I can get the value. for example:

An array define as below:

Code: c
unsigned char Packet[10];

Add an watch *(*Packet+1) in watch table. Then I can find the value of Packet[1].

BUT it's tired to repeat 10 times for this work. I notics about that there are two input box(start and count) for array size when add a watch. How can I use that together with array?

Thanks for you help! 
Title: Re: How to watch each value in an array during debugging?
Post by: SamT on July 17, 2006, 02:30:54 pm
Maybe my question is not very clear to everybody. :?

Anyway, I find out an alternative solution by myself is to use 'Memory Dump' function. All the data in the 'Array' can be shown on the screen. I don't need to rely on symbol watch table to check the data in an array.
Title: Re: How to watch each value in an array during debugging?
Post by: BordRider on July 17, 2006, 05:59:48 pm
I think this is a known issue...and as far as I know there is no fix.  I've had the same problem, and resorted to using GDB command line to help, and I even switched to Xcode for a bit.  Finally I resorted to creating a binary file with the data I need and reading it into another program.  However, the mouse-over display of a pointer will show the correct order, repeated values, but (i'm not entirely sure about this) sometimes not the entire array.

You're right though, information about this topic is kind of hard to find/buried.  I was unaware of the 'memory dump' function...how is that accessed?

Debugging numerical/data driven programs in C doesn't seem to be a focus in most IDE's.  But hey we're engineers, we can learn ways around things. 

For anyone else having a problem with the watch display, you may find this information useful:


These limitations make debugging code that passes large amounts of memory to functions via pointer...a nightmare, but then again, as I said before, this IDE probably wasn't built with numerical debugging in mind.  It's still a greate IDE (i tried setting up my project in .NET - what a nightmare, it thought every carriage return was an EOF marker... :( ) and I will continue to use it!
Title: Re: How to watch each value in an array during debugging?
Post by: BordRider on July 20, 2006, 07:59:31 pm
bump