We were treating arrays described by DW_AT_count and DW_AT_upper_bound
identically, but in a language like C with zero-based arrays they are not:
DW_AT_upper_bound does not give the number of members unless you add one
to it.
Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
return 0;
dwarf_formudata(&nelem_attr, &nelems);
+
+ /*
+ * Upper bounds indicate that we have one more element than that, since
+ * C starts counting at zero.
+ */
+ if (dwarf_hasattr(die, DW_AT_upper_bound))
+ nelems++;
+
return nelems;
}