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: What is the function of "VAR" in "foreach (VAR = [VAR1, VAR2, ...] in ARRAY) STMT"?


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


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