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]

[Bug bpf/24953] foreach statement not retrieving correct array values in stapbpf


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.

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