0

I'm looking for a way to display the Entries of an Array of structs in separate arrays with natvis in visual studio 2015.

Display this

+-x[0]
  +-a
  +-b
  +-c
+-x[1]
  +-a
  +-b
  +-c
...

as

a
+-[0]    (= x[0].a)
+-[1]    (= x[1].a)
...
b
+-[0]    (= x[0].b)
+-[1]    (= x[1].b)
...
c
+-[0]    (= x[0].c)
+-[1]    (= x[1].c)
heitho
  • 61
  • 1
  • 7
  • Could you share a screen shot about the default watch window for the array in your side? Does it mean that you want to display one arrow items' value one by one in the same level? Since all the default value shared as the child item under one parent item in default. – Jack Zhai Nov 11 '16 at 03:01

1 Answers1

0

Edit: Following the comment, this is a working solution, but it requires alignment of your proxy types, which in my case can only be done with power-of-two values.

#define A(t) __declspec(align(t))

struct C
{
    int a;
    int b;
    int c;
    int junk;
};

A(16) struct D
{
    int z;
};

A(16) struct DB {
    int junk;
    int z;
};

A(16) struct DC {
    int junk[2];
    int z;
};

typedef union
{
    D da;
    DB db;
    DC dc;
} Ui;

typedef union
{
    C c[50];
    Ui d[50];
} U;

Original (incomplete) answer:

Each type is individually parsed and visualized. So when parsing each x element there's no way on storing that data for later aggregate of a,b and c.

You can however change your code such that an overlapping (union) type will exactly match your array. Then write separate visualizers for each type:

__decltypestruct C { int a,b,c; };
struct D { int a[10], b[10], c[10]; };
union {
C c[10];
D d;
};
liorda
  • 1,552
  • 2
  • 15
  • 38
  • thanks for the answer but I think that would not be the same data in the union. d.a[3] would be c[1].c. – heitho Jan 12 '17 at 14:57