From: Nan Xiao <xiaonan830818@gmail.com>
To: systemtap@sourceware.org
Subject: What is the function of "VAR" in "foreach (VAR = [VAR1, VAR2, ...] in ARRAY) STMT"?
Date: Thu, 26 Nov 2015 03:47:00 -0000 [thread overview]
Message-ID: <CA+MhoaNFvx+uvxcXsvt2GtHCaa_-tU=9CLYr8ME3jdG8_Zjq-g@mail.gmail.com> (raw)
Hi all,
From the "foreach" section in SystemTap
doc(https://sourceware.org/systemtap/langref/Statement_types.html#SECTION00076000000000000000),
I can see there is a foreach usage:
foreach (VAR = [VAR1, VAR2, ...] in ARRAY) STMT
But execute the following script generate errors:
# cat test.stp
#!/usr/bin/stap
global reads
probe vfs.read
{
reads[pid(), execname()]++
}
probe timer.s(3)
{
foreach (var = [pid, name] in reads)
printf("%d\n", reads[var]);
exit()
}
# ./test.stp
semantic error: inconsistent arity (2 vs 1): identifier 'reads' at
./test.stp:13:18
source: printf("%d\n", reads[var]);
^
semantic error: arity 2 first inferred here: identifier 'reads' at :7:2
source: reads[pid(), execname()]++
^
Pass 2: analysis failed. [man error::pass2]
What is the function of "VAR" in "foreach (VAR = [VAR1, VAR2, ...] in
ARRAY) STMT"? How to use it?
Thanks in advance!
Best Regards
Nan Xiao
next reply other threads:[~2015-11-26 3:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-26 3:47 Nan Xiao [this message]
2015-11-26 19:56 ` Frank Ch. Eigler
2015-11-27 2:23 ` Nan Xiao
2015-11-27 2:30 ` Nan Xiao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CA+MhoaNFvx+uvxcXsvt2GtHCaa_-tU=9CLYr8ME3jdG8_Zjq-g@mail.gmail.com' \
--to=xiaonan830818@gmail.com \
--cc=systemtap@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).