iovisor / ply

Dynamic Tracing in Linux
GNU General Public License v2.0
969 stars 90 forks source link

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

Open wells39 opened 2 years ago

wells39 commented 2 years ago

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

wkz commented 2 years ago

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?

wells39 commented 2 years ago

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

wkz commented 2 years ago

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.

wells39 commented 2 years ago

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

wkz commented 2 years ago

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.