13

In the IAR Embedded Workbench I have a pointer pointing to a buffer in memory. When watching the pointer, I can see the contents of the word it points to. How can I tell the Watch view to list a range of the buffer, from the pointer onwards, for some specified length of elements?

For example, enter the expression:

myPtr[0..2]

will display information equivalent to the three expressions:

myPtr[0]
myPtr[1]
myPtr[2]
ysap
  • 7,723
  • 7
  • 59
  • 122
  • Nice idea, but I have never come across a debugger that supports interpretation of a pointer as an array of user specified length. In these situations I generally use a memory window, but that is good only for very simple cases. – Clifford Sep 24 '14 at 17:08
  • @Clifford - I am 99.99% sure you're able to do this with MS Visual Studio. Certainly it could be done with past versions. – ysap Sep 25 '14 at 19:34
  • One can do it in literally every debugger. IAR is the first I've seen which lacks the function. – Dummy00001 Jan 22 '15 at 11:26
  • @Clifford - In MSVS the way to do this is use `arrptr + offset, length` to display values from `arrptr[offset]` to `arrptr[offset+length-1]`. – ysap Jan 22 '15 at 12:43

2 Answers2

14

From the Iar Embedded Workbench (9.20) help:

In windows where you can edit the Expression field and in the Quick Watch window, you can specify the number of elements to be displayed in the field by adding a semicolon followed by an integer. For example, to display only the three first elements of an array named myArray, or three elements in sequence starting with the element pointed to by a pointer, write:

myArray;3

To display three elements pointed to by myPtr, myPtr+1, and myPtr+2, write:

myPtr;3

Optionally, add a comma and another integer that specifies which element to start with. For example, to display elements 10–14, write:

myArray;5,10

To display myPtr+10, myPtr+11, myPtr+12, myPtr+13, and myPtr+14, write:

myPtr;5,10
spoorcc
  • 2,907
  • 2
  • 21
  • 29
3

An alternative would be to view it in memory. Select View -> Memory and enter the pointer value (with 0x prefix). You can view and edit the range of data. Maybe not as "clean" as a traditional debugger variable viewer but it does the job.

cutofmyjib
  • 31
  • 3