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

From: Steven Rostedt
Date: Thu Feb 08 2018 - 20:10:12 EST


On Fri, 9 Feb 2018 09:34:36 +0900
Namhyung Kim <namhyung@xxxxxxxxxx> wrote:

> > +Direct memory access
> > +====================
> > +
> > +Function arguments are not the only thing that can be recorded from a function
> > +based event. Memory addresses can also be examined. If there's a global variable
> > +that you want to monitor via an interrupt, you can put in the address directly.
> > +
> > + # grep total_forks /proc/kallsyms
> > +ffffffff82354c18 B total_forks
> > +
> > + # echo 'do_IRQ(int total_forks=0xffffffff82354c18)' > function_events
>
> Couldn't we use the symbol name directly? Maybe it needs a syntax to
> indicate global variable. Like this?
>
> # echo 'do_IRQ(int $total_forks)' > function_events

Or perhaps use "@"?

But that's a good idea and not hard to implement.


> > case FUNC_STATE_TYPE:
> > - if (!isalpha(token[0]) || token[0] == '_')
> > - break;
> > if (WARN_ON(!fevent->last_arg))
> > break;
> > - fevent->last_arg->name = kstrdup(token, GFP_KERNEL);
> > - if (!fevent->last_arg->name)
> > + if (update_arg_name(fevent, token) < 0)
> > + break;
> > + if (strncmp(token, "0x", 2) == 0)
> > + goto equal;
>
> Not sure it's needed here. IIUC it should see '=' first and you used
> the same token with arg->name. Hmm.. do you want support accessing to
> an unnamed address directly like below?
>
> # echo 'do_IRQ(int 0xffffffff82354c18)' > function_events

Yes this works, and was the original way. Someone at DevConf.cz
(Arnaldo maybe, can't remember) recommended giving a name and then we
came up with the "=" sign to use.

>
> > + if (!isalpha(token[0]) && token[0] != '_')
> > break;
>
> Maybe you want to check it before the update_arg_name().

Hmm, perhaps, I guess I should see what the error messages shows.

Thanks!

-- Steve