public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: "sapatel at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: systemtap@sourceware.org
Subject: [Bug bpf/24953] foreach statement not retrieving correct array values in stapbpf
Date: Fri, 30 Aug 2019 18:52:00 -0000	[thread overview]
Message-ID: <bug-24953-6586-zDlfNP9MwL@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-24953-6586@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=24953

--- Comment #2 from Sagar Patel <sapatel at redhat dot com> ---
(In reply to William Cohen from comment #1)
> Without the assignment in the foreach gets the values:
> 
> [wcohen@localhost testsuite]$ more ~/foreach2.stp
> global arr 
> 
> probe begin { arr[1] = 1; arr[2] = 2; exit()}
> 
> probe end { foreach ( v in arr) { printf("%d ", v) } }
> [wcohen@localhost testsuite]$ sudo stap --bpf ~/foreach2.stp 
> 2 1 
> 
> Trying to do things like the testsuite systemtap.base/array_slicing.exp or
> systemtap.base/foreach_value.stp?

Sorry, I should've used a clearer example. In the script above, it seems to
"work" because the indices and the actual values in the array are the same.

In the following script, you can observe that without the assignment, 'v' is
referring to the indices and it will print "a b ":

global arr 

probe begin { arr["a"] = 1; arr["b"] = 2; exit() }

probe end {foreach ( v in arr) { printf("%s ", v) } }

One possible alternative is to index into the array using 'v' and that works.

I'm trying to do things like systemtap.base/foreach_value.stp and more
specifically, things like tapset/prometheus.stpm where the indices and array
values are both used in the foreach statement.

-- 
You are receiving this mail because:
You are the assignee for the bug.

  parent reply	other threads:[~2019-08-30 18:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-30 15:59 [Bug bpf/24953] New: " sapatel at redhat dot com
2019-08-30 18:41 ` [Bug bpf/24953] " wcohen at redhat dot com
2019-08-30 18:52 ` sapatel at redhat dot com [this message]
2019-09-03 14:06 ` [Bug bpf/24953] foreach (v = v1,v2) syntax not behaving correctly " me at serhei dot io
2019-09-26 19:55 ` sapatel at redhat dot com

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=bug-24953-6586-zDlfNP9MwL@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --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).