Re: [PATCH v6 21/21] perf-probe: Add array argument support

From: Ravi Bangoria
Date: Mon Mar 19 2018 - 03:57:44 EST


Hi Masami,

On 03/17/2018 06:23 PM, Masami Hiramatsu wrote:
> Since kprobes events support an array argument, perf-probe
> can also support dumping array now.
> The syntax are
>
> <array-var>[<range>]
> or
> <pointer-var>[<range>]
>
> where the <range> is <start>..<end>. e.g. array[0..5].
> This can also be available with string type. In this
> case, the string array should be "char *array[]" or
> "char **array_ptr".
>
> Note that this feature is only available on the kernel which
> supports array type.

User can still do,

# perf probe -x ~/hello main:3 'a=a:x32[3]'

which will successfully be installed in uprobe_events. But for a
perf tool, x32[3] is not a valid type. And it seems perf tool don't
validate the 'type' field:

ÂÂÂ static int parse_perf_probe_arg(char *str, struct perf_probe_arg *arg)
ÂÂÂ {
ÂÂÂÂÂÂÂ ....
ÂÂÂÂÂÂÂ tmp = strchr(str, ':');
ÂÂÂÂÂÂÂ if (tmp) {ÂÂÂÂÂ /* Type setting */
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ *tmp = '\0';
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ arg->type = strdup(tmp + 1);
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ if (arg->type == NULL)
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ return -ENOMEM;
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ pr_debug("type:%s ", arg->type);
ÂÂÂÂÂÂÂ }

Is it okay to allow user to specify array size with type field?

Thanks,
Ravi