This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: Dealing with empty aggregates?
- From: fche at redhat dot com (Frank Ch. Eigler)
- To: "Bryn M. Reeves" <bmr at redhat dot com>
- Cc: systemtap at sources dot redhat dot com
- Date: Thu, 19 May 2011 10:36:35 -0400
- Subject: Re: Dealing with empty aggregates?
- References: <4DD4FF2A.2060809@redhat.com>
"Bryn M. Reeves" <bmr@redhat.com> writes:
> [...]
> ERROR: empty aggregate near identifier '@sum' at <input>:1:42
> [...]
> probe timer.ms(1000) {
> if (have_stuff) {
> printf("Sum of stuff: %d\n", @sum(stuff))
> } else {
> print("Sum of stuff: n/a\n")
> }
> }
The canonical construct doesn't require a hand-maintained flag:
probe timer.ms(1000) {
if (@count(stuff))
printf("Sum of stuff: %d\n", @sum(stuff))
else
printf("No stuff.")
}
- FChE