From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15944 invoked by alias); 30 Aug 2019 18:52:16 -0000 Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org Received: (qmail 15867 invoked by uid 48); 30 Aug 2019 18:52:11 -0000 From: "sapatel at redhat dot com" 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 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: systemtap X-Bugzilla-Component: bpf X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: sapatel at redhat dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: systemtap at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2019-q3/txt/msg00055.txt.bz2 https://sourceware.org/bugzilla/show_bug.cgi?id=3D24953 --- Comment #2 from Sagar Patel --- (In reply to William Cohen from comment #1) > Without the assignment in the foreach gets the values: >=20 > [wcohen@localhost testsuite]$ more ~/foreach2.stp > global arr=20 >=20 > probe begin { arr[1] =3D 1; arr[2] =3D 2; exit()} >=20 > probe end { foreach ( v in arr) { printf("%d ", v) } } > [wcohen@localhost testsuite]$ sudo stap --bpf ~/foreach2.stp=20 > 2 1=20 >=20 > 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=20 probe begin { arr["a"] =3D 1; arr["b"] =3D 2; exit() } probe end {foreach ( v in arr) { printf("%s ", v) } } One possible alternative is to index into the array using 'v' and that work= s. 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. --=20 You are receiving this mail because: You are the assignee for the bug.