Author Topic: How to watch each value in an array during debugging?  (Read 8417 times)

Offline SamT

  • Multiple posting newcomer
  • *
  • Posts: 41
How to watch each value in an array during debugging?
« 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! 

Offline SamT

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: How to watch each value in an array during debugging?
« Reply #1 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.

BordRider

  • Guest
Re: How to watch each value in an array during debugging?
« Reply #2 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:

  • Will not display more than 200 values in a locally declared array
  • Repeated values are shown only once
  • Display of array does not necessarily reflect the order in memory
  • When you tell the watch window that a pointer points to an array, no matter what size, it still only shows the first value in memory
  • Mouse-over display works only for locally defined variables or function arguments

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!

BordRider

  • Guest
Re: How to watch each value in an array during debugging?
« Reply #3 on: July 20, 2006, 07:59:31 pm »
bump