This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: Accessing size of arrays allocated on the stack
- From: fche at redhat dot com (Frank Ch. Eigler)
- To: <Alex dot Hoole at ece dot uvic dot ca>
- Cc: <systemtap at sourceware dot org>
- Date: Wed, 12 Dec 2012 18:19:39 -0500
- Subject: Re: Accessing size of arrays allocated on the stack
- References: <45431.3344126151$1355336405@news.gmane.org>
Hi, Alexander --
Alexander.Hoole wrote:
> I noticed that systemtap is able to know that a local variable, allocated on
> the stack, is an array. [...]
> Does SystemTap presently support the ability to determine the size of local
> arrays using either built-in functionality or embedded C?
Not well. There is a sizeof.stp sample, but that works for type names
that are resolvable via the @cast() construct, not general C type
declaration strings, and not references to a varable. Via embedded-C
of course one can do anything one wants (return sizeof(some_c_type))
but that code doesn't have access to the DWARF data stap has
processed.
To get array bounds, stap would have to search for stuff like
DW_TAG_subrange_type -> DW_AT_upper_bound (which "extern array[];"
declarations won't have). Stap would have to export this through
some new language feature, perhaps @byte_size($foo) (if one wants
all the array dimensions/element-sizes multiplied out).
- FChE