This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to debug a pointer to an array?

Using the watch or memory debug windows, does anyone know of a way to view a pointer as if it were an array?

i.e.

uint8_t myArray[4];
uint8_t* myPtr = myArray;

Normally, you'll only be able to see myArray[0] when viewing myPtr in the debugger. I'd like to view the entire array. Visual Studio offers a way of essentially casting the pointer inside their debug window into an array - is there anything similar that's available in uVision?

Here's the example of how to do it in VS: blogs.msdn.microsoft.com/.../

thanks!

  • Hey Brian,

    I like that feature, too. As an work-around to the lack of it, you could create a debug function (under Debug->Function Editor). Save it to a file and just import the file in the command window, then call some_name() any time you want to get an update on the values in the array.

    pseudo code:

    FUNC void some_name(count, * to_first_element){

    for(int i = 0; i < count; i++){ printf("%#x,", *to_first_element); }
    }