Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752282AbbGWLzS (ORCPT ); Thu, 23 Jul 2015 07:55:18 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:65245 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751721AbbGWLzM (ORCPT ); Thu, 23 Jul 2015 07:55:12 -0400 Subject: Re: [RFC PATCH v4 3/3] bpf: Introduce function for outputing data to perf event To: Alexei Starovoitov , "Wangnan (F)" , pi3orama , Namhyung Kim References: <1436522587-136825-1-git-send-email-hekuang@huawei.com> <1436522587-136825-4-git-send-email-hekuang@huawei.com> <55A042DC.6030809@plumgrid.com> <55A3404B.6020904@huawei.com> <20150713135223.GB9917@danjae.kornet> <4D441676-21A7-46EE-AAB0-EB529D408082@163.com> <20150713140915.GD9917@danjae.kornet> <55A46928.9090708@plumgrid.com> <55A4F869.1020705@huawei.com> <55A88085.8090407@plumgrid.com> <55A88137.7020609@huawei.com> <55A88449.3030008@plumgrid.com> CC: "rostedt@goodmis.org" , "masami.hiramatsu.pt@hitachi.com" , "acme@kernel.org" , "a.p.zijlstra@chello.nl" , "mingo@redhat.com" , "jolsa@kernel.org" , "linux-kernel@vger.kernel.org" From: He Kuang Message-ID: <55B0D5FC.6050406@huawei.com> Date: Thu, 23 Jul 2015 19:54:36 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.0 MIME-Version: 1.0 In-Reply-To: <55A88449.3030008@plumgrid.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.110.54.65] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020204.55B0D60D.014D,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: 57540210554e56f7d1c308649282595b Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3912 Lines: 102 Hi, Alexi Thank you for your guidence, and by referencing your last mail and other llvm backends, I found setting BPFMCAsmInfo::SupportsDebugInformation = true in BPFMCAsmInfo.h and fix some unhandeled switch can make llc output debug_info, but important information is missing in the result: bpf: <1><2a>: Abbrev Number: 2 (DW_TAG_subprogram) <2b> DW_AT_low_pc : 0x0 <33> DW_AT_high_pc : 0x60 <37> Unknown AT value: 3fe7: 1 <37> DW_AT_frame_base : 1 byte block: 5a (DW_OP_reg10 (r10)) <39> DW_AT_name : (indirect string, offset: 0x0): clang version 3.7.0 (http://llvm.org/git/clang.git.. <3d> DW_AT_decl_file : 1 <3e> DW_AT_decl_line : 3 <3f> DW_AT_prototyped : 1 <3f> DW_AT_type : <0x65> <43> DW_AT_external : 1 <43> Unknown AT value: 3fe1: 1 <2><43>: Abbrev Number: 3 (DW_TAG_formal_parameter) <44> DW_AT_name : (indirect string, offset: 0x0): clang version 3.7.0 (http://llvm.org/git/clang.git.. <48> DW_AT_decl_file : 1 <49> DW_AT_decl_line : 3 <4a> DW_AT_type : <0x65> Compares to x86 platform result: <1><26>: Abbrev Number: 2 (DW_TAG_subprogram) <27> DW_AT_low_pc : 0x0 <2b> DW_AT_high_pc : 0x16 <2f> Unknown AT value: 3fe7: 1 <2f> DW_AT_frame_base : 1 byte block: 54 (DW_OP_reg4 (esp)) <31> DW_AT_name : (indirect string, offset: 0xcf): testprog <35> DW_AT_decl_file : 1 <36> DW_AT_decl_line : 3 <37> DW_AT_prototyped : 1 <37> DW_AT_type : <0x65> <3b> DW_AT_external : 1 <3b> Unknown AT value: 3fe1: 1 <2><3b>: Abbrev Number: 3 (DW_TAG_formal_parameter) <3c> DW_AT_location : 2 byte block: 91 4 (DW_OP_fbreg: 4) <3f> DW_AT_name : (indirect string, offset: 0xdc): myvar_a <43> DW_AT_decl_file : 1 <44> DW_AT_decl_line : 3 <45> DW_AT_type : <0x65> The bpf result lacks of DW_AT_location, and DW_AT_name gives no infomation. Then I used 'llc print-after*' command to check each pass and wanted to find by which step the debug infomation is dropped, things looks similar until the passes between 'verify' and 'expand-isel-pseudos': x86: $ llc -march=x86 --print-before-all -print-after-all -stop-after=expand-isel-pseudos test.ll # *** IR Dump Before Expand ISel Pseudo-instructions ***: # Machine code for function testprog: SSA Frame Objects: fi#-2: size=4, align=4, fixed, at location [SP+8] fi#-1: size=4, align=16, fixed, at location [SP+4] BB#0: derived from LLVM BB %entry DBG_VALUE , 0, !"myvar_a", ; line no:3 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DBG_VALUE , 0, !"myvar_b", ; line no:3 %vreg0 = MOV32rm , 1, %noreg, 0, %noreg; mem:LD4[FixedStack-2] ; GR32:%vreg0 bpf: $ llc -march=bpf --print-before-all -print-after-all -stop-after=expand-isel-pseudos test.ll # *** IR Dump Before Expand ISel Pseudo-instructions ***: # Machine code for function testprog: SSA Function Live Ins: %R1 in %vreg0, %R2 in %vreg1 BB#0: derived from LLVM BB %entry Live Ins: %R1 %R2 %vreg1 = COPY %R2; GPR:%vreg1 %vreg0 = COPY %R1; GPR:%vreg0 %vreg2 = LD_imm64 2147483648; GPR:%vreg2 I think maybe this missing 'DBG_VALUE' causes the problem, but I'm stuck here and hope you can give more advice. Thank you! On 2015/7/17 12:27, Alexei Starovoitov wrote: > clang -O2 -emit-llvm -g a.c -S -o a.ll -- 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/