As mentioned by Stephane Chazelas on the mailing list: <https://sourceware.org/ml/systemtap/2015-q1/msg00236.html> It might be nice to have DWARF-based sizeof(), array_size(), typeof() operators.
[Thanks David] I don't know about the other ones, but a DWARF-based sizeof() (at least for kernel symbols) should just be a matter of: function sizeof:long (addr:long) %{ /* pure */ /* pragma:symbols */ STAP_RETVALUE = -1; _stp_kallsyms_lookup(STAP_ARG_addr, (unsigned long*)&(STAP_RETVALUE), NULL, NULL, NULL); %} See http://stackoverflow.com/questions/29034267/get-size-of-target-array-in-systemtap for where the request is coming from.
(In reply to Stephane Chazelas from comment #1) > function sizeof:long (addr:long) %{ /* pure */ /* pragma:symbols */ > STAP_RETVALUE = -1; > _stp_kallsyms_lookup(STAP_ARG_addr, (unsigned long*)&(STAP_RETVALUE), > NULL, NULL, NULL); > %} Note that the above great start is not actually DWARF-based - it's just symbol-table based. We might want to do a few things extra: - rename to symsize (since that's what it does) - throw an error if the address can't be resolved to a known symbol, instead of returning a sentinel -1 - having a user-space variant usymsize() that passes 'current' as the last parameter to the underlying lookup function