Commit a34a9854 authored by Masami Hiramatsu's avatar Masami Hiramatsu Committed by Arnaldo Carvalho de Melo

perf probe: Support DW_OP_call_frame_cfa in debuginfo

When building kernel without CONFIG_FRAME_POINTER, gcc uses
CFA (canonical frame address) for frame base. With this patch,
perf probe just gets CFI (call frame information) from debuginfo
and search corresponding CFA from the CFI. IOW, this allows
perf probe works correctly on the kernel without CONFIG_FRAME_POINTER.

<Before>
 ./perf probe -fn sched_slice:12 lw.weight
  Fatal: DW_OP 156 is not supported.
              (^^^ DW_OP_call_frame_cfa)

<After>
./perf probe -fn sched_slice:12 lw.weight
Add new event:
  probe:sched_slice    (on sched_slice:12 with weight=lw.weight)

Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <20100412171728.3790.98217.stgit@localhost6.localdomain6>
Signed-off-by: default avatarMasami Hiramatsu <mhiramat@redhat.com>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 11a1ca35
...@@ -398,7 +398,6 @@ static void convert_location(Dwarf_Op *op, struct probe_finder *pf) ...@@ -398,7 +398,6 @@ static void convert_location(Dwarf_Op *op, struct probe_finder *pf)
const char *regs; const char *regs;
struct kprobe_trace_arg *tvar = pf->tvar; struct kprobe_trace_arg *tvar = pf->tvar;
/* TODO: support CFA */
/* If this is based on frame buffer, set the offset */ /* If this is based on frame buffer, set the offset */
if (op->atom == DW_OP_fbreg) { if (op->atom == DW_OP_fbreg) {
if (pf->fb_ops == NULL) if (pf->fb_ops == NULL)
...@@ -629,11 +628,17 @@ static void convert_probe_point(Dwarf_Die *sp_die, struct probe_finder *pf) ...@@ -629,11 +628,17 @@ static void convert_probe_point(Dwarf_Die *sp_die, struct probe_finder *pf)
/* Get the frame base attribute/ops */ /* Get the frame base attribute/ops */
dwarf_attr(sp_die, DW_AT_frame_base, &fb_attr); dwarf_attr(sp_die, DW_AT_frame_base, &fb_attr);
ret = dwarf_getlocation_addr(&fb_attr, pf->addr, &pf->fb_ops, &nops, 1); ret = dwarf_getlocation_addr(&fb_attr, pf->addr, &pf->fb_ops, &nops, 1);
if (ret <= 0 || nops == 0) if (ret <= 0 || nops == 0) {
pf->fb_ops = NULL; pf->fb_ops = NULL;
} else if (nops == 1 && pf->fb_ops[0].atom == DW_OP_call_frame_cfa &&
pf->cfi != NULL) {
Dwarf_Frame *frame;
ret = dwarf_cfi_addrframe(pf->cfi, pf->addr, &frame);
DIE_IF(ret != 0);
dwarf_frame_cfa(frame, &pf->fb_ops, &nops);
}
/* Find each argument */ /* Find each argument */
/* TODO: use dwarf_cfi_addrframe */
tev->nargs = pf->pev->nargs; tev->nargs = pf->pev->nargs;
tev->args = xzalloc(sizeof(struct kprobe_trace_arg) * tev->nargs); tev->args = xzalloc(sizeof(struct kprobe_trace_arg) * tev->nargs);
for (i = 0; i < pf->pev->nargs; i++) { for (i = 0; i < pf->pev->nargs; i++) {
...@@ -842,6 +847,9 @@ int find_kprobe_trace_events(int fd, struct perf_probe_event *pev, ...@@ -842,6 +847,9 @@ int find_kprobe_trace_events(int fd, struct perf_probe_event *pev,
if (!dbg) if (!dbg)
return -ENOENT; return -ENOENT;
/* Get the call frame information from this dwarf */
pf.cfi = dwarf_getcfi(dbg);
off = 0; off = 0;
line_list__init(&pf.lcache); line_list__init(&pf.lcache);
/* Loop on CUs (Compilation Unit) */ /* Loop on CUs (Compilation Unit) */
......
...@@ -42,6 +42,7 @@ struct probe_finder { ...@@ -42,6 +42,7 @@ struct probe_finder {
struct list_head lcache; /* Line cache for lazy match */ struct list_head lcache; /* Line cache for lazy match */
/* For variable searching */ /* For variable searching */
Dwarf_CFI *cfi; /* Call Frame Information */
Dwarf_Op *fb_ops; /* Frame base attribute */ Dwarf_Op *fb_ops; /* Frame base attribute */
struct perf_probe_arg *pvar; /* Current target variable */ struct perf_probe_arg *pvar; /* Current target variable */
struct kprobe_trace_arg *tvar; /* Current result variable */ struct kprobe_trace_arg *tvar; /* Current result variable */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment