Re: [PATCH] perf uprobe: Skip prologue if program compiled without optimization

From: Ravi Bangoria
Date: Wed Aug 03 2016 - 08:06:45 EST


Thanks Masami,

On Tuesday 02 August 2016 08:22 PM, Masami Hiramatsu wrote:
On Mon, 1 Aug 2016 14:19:28 +0530
Ravi Bangoria <ravi.bangoria@xxxxxxxxxxxxxxxxxx> wrote:

Function prologue prepares stack and registers before executing function
logic. When target program is compiled without optimization, function
parameter information is only valid after prologue. When we probe entrypc
of the function, and try to record function parameter, it contains
garbage value.

[SNIP]
+
+ /* Only FUNC and FUNC@SRC are eligible. */
+ if (!pp->function || pp->line || pp->retprobe || pp->lazy_line ||
+ pp->offset || pp->abs_address)
+ return;
+
+ /* Not interested in func parameter? */
+ if (!pf->pev->nargs)
+ return;
Hmm, this is not enough, since perf-probe accepts registers and stacks.
At least you should check if all argument are !is_c_varname(), !PROBE_ARG_VARS and
!PROBE_ARG_PARAMS here, instead of checking nargs.

+
+ pr_info("Target program is compiled without optimization. Skipping prologue.\n"
+ "Use %s:1 or absolute address 0x%lx to force probe on entry point.\n\n",
Hmm, is <Function>:1 always available? I think we should just recommend to use only
the address.
(moreover, pf->addr may not the absolute address in uprobe event, we'd better say
"the address 0x%x")

Nice catch. :)

Sent v2. Please review it.

-Ravi