Bpftrace: join() as a printf() argument

Created on 1 Sep 2018  路  4Comments  路  Source: iovisor/bpftrace

This doesn't work:

bpftrace -e 'kprobe:sys_execve { printf("%s\n", join(arg1)); }'

(See #25 for notes about kprobe:sys_execve going away.)

Is it possible to have join() be used as a printf() argument? This may be more trouble that it's worth.

breaking changes enhancement llvm

Most helpful comment

This needs fixing. The join() builtin really should return a string so that it can be used with maps / printf's / whatever. In its current form it's not very usable.

All 4 comments

This needs fixing. The join() builtin really should return a string so that it can be used with maps / printf's / whatever. In its current form it's not very usable.

I agree with @tyroguru, join() would be way more useful if it returned a string. I think the bigger question is: should we keep the current behavior as well (print if the return value is not used), or should we change it to always return a string?

Considering all the problems raised in #769, do we still want this to be implemented?

I think we should change the join behaviour despite the problems raised.

We can block its use in situations which are currently not possible, e.g. assigning to variables and maps, but allow it as a printf argument. This gets us better formatting of joins by allowing them in printfs and means that the syntax will not have to change when any new kernel/compiler features come in which allow the broken cases to work.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tty5 picture tty5  路  3Comments

danobi picture danobi  路  8Comments

gbansal2 picture gbansal2  路  5Comments

brendangregg picture brendangregg  路  7Comments

NotAFile picture NotAFile  路  6Comments