Re: [PATCH v6 31/37] tracing: Add 'last error' error facility for hist triggers

Namhyung Kim
2017-11-23T06:22:35Z

On Fri, Nov 17, 2017 at 02:33:10PM -0600, Tom Zanussi wrote:
> With the addition of variables and actions, it's become necessary to
> provide more detailed error information to users about syntax errors.
>
> Add a 'last error' facility accessible via the erroring event's 'hist'
> file. Reading the hist file after an error will display more detailed
> information about what went wrong, if information is available. This
> extended error information will be available until the next hist
> trigger command for that event.
>
> # echo xxx > /sys/kernel/debug/tracing/events/sched/sched_wakeup/trigger
> echo: write error: Invalid argument
>
> # cat /sys/kernel/debug/tracing/events/sched/sched_wakeup/hist
>
> ERROR: Couldn't yyy: zzz
> Last command: xxx
>
> Also add specific error messages for variable and action errors.
>
> Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
> ---
> @@ -2271,9 +2333,18 @@ static struct hist_field *create_var_ref(struct hist_field *var_field,
> return ref_field;
> }
>
> +static bool is_common_field(char *var_name)
> +{
> + if (strncmp(var_name, "$common_timestamp", strlen("$common_timestamp")) == 0)
> + return true;
> +
> + return false;
> +}
> +
> static bool is_var_ref(char *var_name)
> {
> - if (!var_name || strlen(var_name) < 2 || var_name[0] != '$')
> + if (!var_name || strlen(var_name) < 2 || var_name[0] != '$' ||
> + is_common_field(var_name))

Looks like it's not a part of this change.

Thanks,
Namhyung

> return false;
>
> return true;