Re: [PATCH 12/18] tracing: Add accessing direct address from function based events

From: Steven Rostedt
Date: Mon Feb 12 2018 - 11:47:12 EST


On Tue, 13 Feb 2018 00:47:50 +0900
Masami Hiramatsu <mhiramat@xxxxxxxxxx> wrote:

> > > if (WARN_ON(!fevent->last_arg))
> > > break;
> > > - ret = kstrtoul(token, 0, &val);
> > > - if (ret < 0)
> > > - break;
> > > + if (isalpha(token[0]) || token[0] != '_') {
> >
> > I guess you wanted the token[0] being '_'. Maybe it'd be better adding
> >
> > #define isident0(x) (isalpha(x) || (x) == '_')
>
> If this '$' is only for the symbol or direct address(with 0x prefix),
> you just need to check by !isdigit(token[0]), isn't it?
> (and if it is insane get_symbol just fails)

I modified a lot of this code for the next version (which I'm still
tweaking).

I have this for next_token() (which I may add for the
trace_events_filter.c code as Al Viro has recently pointed out issues
with its parsing):

static char *next_token(char **ptr, char *last)
{
char *arg;
char *str;

if (!*ptr)
return NULL;

arg = *ptr;

if (*last)
*arg = *last;

if (!*arg)
return NULL;

for (str = arg; *str; str++) {
if (!isalnum(*str) && *str != '_')
break;
}
if (*str) {
if (str == arg)
str++;
*last = *str;
*str = 0;
*ptr = str;
return arg;
}

*last = 0;
*ptr = NULL;
return arg;
}


And this:

static bool valid_name(const char *token)
{
return isalpha(token[0]) || token[0] == '_';
}

As all tokens will now be either entirely alphanumeric with '_' or a
single character.

-- Steve