Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751621AbbEXIad (ORCPT ); Sun, 24 May 2015 04:30:33 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:28112 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750875AbbEXI2h (ORCPT ); Sun, 24 May 2015 04:28:37 -0400 From: He Kuang To: , , , , , , , , , , , CC: , Subject: [RFC PATCH v2 12/15] perf bpf: Generate bpf prologue without debuginfo Date: Sun, 24 May 2015 08:28:08 +0000 Message-ID: <1432456091-73384-13-git-send-email-hekuang@huawei.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1432456091-73384-1-git-send-email-hekuang@huawei.com> References: <1432456091-73384-1-git-send-email-hekuang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.107.197.210] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020206.55618BB1.0126,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 53066d1c834874e06b536cfcc8b14200 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2867 Lines: 102 When probing at function entry, fallback to generate bpf prologue by calling args if '$param' is the only args and no debuginfo is provided. Signed-off-by: He Kuang --- tools/perf/util/probe-event.c | 54 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index ccbf4d9..0de5879 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c @@ -46,6 +46,7 @@ #include "probe-event.h" #include "probe-finder.h" #include "session.h" +#include #include #define MAX_CMDLEN 256 @@ -287,6 +288,45 @@ static void clear_probe_trace_events(struct probe_trace_event *tevs, int ntevs) clear_probe_trace_event(tevs + i); } +static int convert_parameters_to_bpf_prologue(char *new_prog, int *new_len) +{ + char *new_insn = new_prog; + int i; + int offset; + + /* Find each argument */ + for (i = 0; i < BPF_PROLOGUE_NRARGS_MAX; i++) { + offset = get_arch_calling_reg_offset(i); + if (offset < 0) + break; + + new_insn += bpf_prologue_formal_parameters( + new_prog ? new_insn : NULL, + offset, i); + } + *new_len = new_insn - new_prog; + + return 0; +} + +static int get_bpf_prologue_default(char **result, int *count) +{ + char *new_prog; + + convert_parameters_to_bpf_prologue(NULL, count); + if (*count == 0) + return 0; + + new_prog = malloc(*count); + if (!new_prog) + return -ENOMEM; + + convert_parameters_to_bpf_prologue(new_prog, count); + *result = (char *)new_prog; + + return 0; +} + static bool perf_probe_is_function_entry(struct perf_probe_event *pev) { if (pev->point.file || pev->point.line || pev->point.lazy_line) @@ -931,7 +971,13 @@ int get_bpf_prologue(struct perf_probe_event *pev, char **result, int *count) if (!dinfo) { if (need_dwarf) return -ENOENT; - pr_debug("Could not open debuginfo. Try to use symbols.\n"); + pr_debug("Could not open debuginfo. Generate default prologue.\n"); + + if (perf_probe_is_function_entry(pev) && + pev->nargs == 1 && + !strcmp(pev->args[0].var, "$params")) + return get_bpf_prologue_default(result, count); + return 0; } @@ -943,6 +989,12 @@ int get_bpf_prologue(struct perf_probe_event *pev, char **result, int *count) } #else /* !HAVE_DWARF_SUPPORT */ +int get_bpf_prologue(struct perf_probe_event *pev __maybe_unused, + char **result, int *count) +{ + return -ENOTSUP; +} + static int find_perf_probe_point_from_dwarf(struct probe_trace_point *tp __maybe_unused, struct perf_probe_point *pp __maybe_unused, -- 1.8.5.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/