ply icon indicating copy to clipboard operation
ply copied to clipboard

Maps should be able to store record values (anonymous structs)

Open wells39 opened this issue 3 years ago • 5 comments

I am very interesting to this tool,have any material to understand this tool deeply. Whether the map can store a struct for take more data one time? If i want to implenment this demand, what can i do

wells39 avatar Feb 09 '22 11:02 wells39

Regarding getting a deeper understanding of ply, have you looked at the manual? https://wkz.github.io/ply/ply.1.html

Can can easily key a map using multiple variables, i.e. something like:

ply 't:sched/sched_wakeup { @[data->comm, data->pid] = count(); }'

You can also use an entire struct as the key:

ply 't:sched/sched_wakeup { @[*data] = count(); }'

Similarly you can also have a struct as the value of a map:

ply 't:sched/sched_wakeup { log[time] = *data; }'

I have though about adding support for creating custom "records" in the same way that you can compose map keys arbitrarily. Something like:

ply 't:sched/sched_wakeup { log[time] = [data->comm, data->pid]; }'

Is that what you are looking for? Could you give an example of what you mean? Or a problem you want to solve?

wkz avatar Feb 10 '22 10:02 wkz

great,this is my wanna. Thanks. and bytheway, could this apply to a kprobe/kretprobe providers ?

wells39 avatar Mar 10 '22 14:03 wells39

Are you saying that you need the record feature that I described at the bottom of my reply, or are you happy with what is already available?

Guessing that you are talking about records, then yes, when implemented, that would apply to all kinds of providers.

wkz avatar Mar 10 '22 19:03 wkz

em. yes, i am interesting with the ability about record. i mistake for it had already implemented.

wells39 avatar Mar 11 '22 09:03 wells39

I see, no that is not supported yet I'm afraid. Should be pretty easy to add though.

I'll update the subject of the issue so that I remember what it is about.

wkz avatar Mar 11 '22 23:03 wkz