How to tell gdb how long my zero-length array is?

A slightly oxymoronic name! Bonus points for Xcode answer, but this is a gdb question.

If I have a standard, a gdb array with a static size will print all its elements [and Xcode will let me see it], but if I have a zero length array , it will not, because it does not know. Obviously, I can print array indices one by one, but I would like to reset all of this.

How to tell gdb how much space I have allocated for an array to allow it to print the array (or allow Xcode to view the array). Is it possible?

+5
source share
3 answers

s->a char [0] ( gcc), , 100, gdb :

(gdb) print *(char (*)[100])&s->a
+2

See 10.4 Artificial Arrays:

(gdb) p *argv@argc
+2
source

All Articles