This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Accessing size of arrays allocated on the stack


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]