This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[Bug bpf/24953] foreach statement not retrieving correct array values in stapbpf
- From: "sapatel at redhat dot com" <sourceware-bugzilla at sourceware dot org>
- To: systemtap at sourceware dot org
- Date: Fri, 30 Aug 2019 18:52:11 +0000
- Subject: [Bug bpf/24953] foreach statement not retrieving correct array values in stapbpf
- Auto-submitted: auto-generated
- References: <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.