Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751593AbbEXIa2 (ORCPT ); Sun, 24 May 2015 04:30:28 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:28113 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750882AbbEXI2h (ORCPT ); Sun, 24 May 2015 04:28:37 -0400 From: He Kuang To: , , , , , , , , , , , CC: , Subject: [RFC PATCH v2 08/15] bpf tools: Fetch calling regs to bpf arglist Date: Sun, 24 May 2015 08:28:04 +0000 Message-ID: <1432456091-73384-9-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.55618BB2.0050,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: 61dedcb60e140af2d36075c4eb0ac5a1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1608 Lines: 56 For generating bpf prologue which fetches function formal parameters when debuginfo is not provided. Signed-off-by: He Kuang --- tools/lib/bpf/gen_prologue.c | 19 +++++++++++++++++++ tools/lib/bpf/libbpf.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/tools/lib/bpf/gen_prologue.c b/tools/lib/bpf/gen_prologue.c index ca8aa1c..d25693a 100644 --- a/tools/lib/bpf/gen_prologue.c +++ b/tools/lib/bpf/gen_prologue.c @@ -106,3 +106,22 @@ unsigned int bpf_prologue_end(char *new_prog, int nargs) return (char *)new_insn - new_prog; } + +unsigned int bpf_prologue_formal_parameters(char *new_prog, int offset, + int index) +{ + struct bpf_insn *new_insn; + + if (index >= BPF_PROLOGUE_NRARGS_MAX) + return 0; + + new_insn = (struct bpf_insn *)new_prog; + + /* load ctx to r3 */ + if (new_prog) + *new_insn = BPF_LDX_MEM(BPF_DW, BPF_REG_ARG2 + index, + BPF_REG_ARG1, offset); + new_insn++; + + return (char *)new_insn - new_prog; +} diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h index cf22a6a..9d6d4f7 100644 --- a/tools/lib/bpf/libbpf.h +++ b/tools/lib/bpf/libbpf.h @@ -72,5 +72,7 @@ unsigned int bpf_prologue_arg_deref(int offset, int depth, char *new_prog, bool last); +unsigned int bpf_prologue_formal_parameters(char *new_prog, int offset, + int index); #endif -- 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/