From: Nan Xiao <xiaonan830818@gmail.com>
To: "Frank Ch. Eigler" <fche@redhat.com>
Cc: systemtap@sourceware.org
Subject: Re: What is the function of "VAR" in "foreach (VAR = [VAR1, VAR2, ...] in ARRAY) STMT"?
Date: Fri, 27 Nov 2015 02:30:00 -0000 [thread overview]
Message-ID: <CA+MhoaNEy_kzkiKF-V0f6pScsMyvq0U7RVdvS0JY128b61a57g@mail.gmail.com> (raw)
In-Reply-To: <CA+MhoaOGckAyXYzCCfWNBGotQrR+dizYF52Cd2WhNQD5Yo_+3Q@mail.gmail.com>
Hi Frank,
BTW, I think in this
page(https://sourceware.org/systemtap/langref/Statement_types.html#SECTION00076000000000000000),
use
foreach (VALUE = [VAR1, VAR2, ...] in ARRAY) STMT (man stap)
is better and more understandable than
foreach (VAR = [VAR1, VAR2, ...] in ARRAY) STMT
Thanks!
Best Regards
Nan Xiao
On Fri, Nov 27, 2015 at 10:23 AM, Nan Xiao <xiaonan830818@gmail.com> wrote:
> Hi Frank,
>
> Yeah, it works! Thanks very much for your help!
> Best Regards
> Nan Xiao
>
>
> On Fri, Nov 27, 2015 at 3:56 AM, Frank Ch. Eigler <fche@redhat.com> wrote:
>>
>> xiaonan830818 wrote:
>>
>>> [...]
>>> I can see there is a foreach usage:
>>> foreach (VALUE = [VAR1, VAR2, ...] in ARRAY) STMT
>>
>> See [man stap]. This syntax is for automatically fetching
>> the ARRAY[VAR1,VAR2,...] value into a VALUE variable, so:
>>
>>> But execute the following script generate errors:
>>> [...]
>>> probe timer.s(3)
>>> {
>>> foreach (var = [pid, name] in reads)
>>> printf("%d\n", reads[var]);
>>
>> ... would be correctly written as
>>
>>> printf("%d\n", var)
>>
>>
>> - FChE
prev parent reply other threads:[~2015-11-27 2:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-26 3:47 Nan Xiao
2015-11-26 19:56 ` Frank Ch. Eigler
2015-11-27 2:23 ` Nan Xiao
2015-11-27 2:30 ` Nan Xiao [this message]
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+MhoaNEy_kzkiKF-V0f6pScsMyvq0U7RVdvS0JY128b61a57g@mail.gmail.com \
--to=xiaonan830818@gmail.com \
--cc=fche@redhat.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).