Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753695AbbBXSt5 (ORCPT ); Tue, 24 Feb 2015 13:49:57 -0500 Received: from mail.kernel.org ([198.145.29.136]:54050 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753251AbbBXSt4 (ORCPT ); Tue, 24 Feb 2015 13:49:56 -0500 Date: Tue, 24 Feb 2015 15:49:47 -0300 From: Arnaldo Carvalho de Melo To: Masami Hiramatsu Cc: Linux Kernel Mailing List , Jiri Olsa , David Ahern Subject: Trying to use 'perf probe' to debug perf itself Message-ID: <20150224184947.GF25009@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4548 Lines: 118 Hi Masami, I'm adding thread refcounting in perf, and in this process I am investigating a problem, so thought about using perf itself to match thread__get with thread__put: [root@ssdandy ~]# perf probe -x ~/bin/perf -V thread__put Available variables at thread__put @ struct thread* thread [root@ssdandy ~]# perf probe -x ~/bin/perf -V thread__get Available variables at thread__get @ struct thread* thread [root@ssdandy ~]# cool, so I thought it would be just a matter of asking to put the probes and get the value of 'thread', then match things, but: [root@ssdandy ~]# perf probe -v ~/bin/perf thread__put thread probe-definition(0): thread__put thread symbol:thread__put file:(null) line:0 offset:0 return:0 lazy:(null) parsing arg: thread into thread 1 arguments Open Debuginfo file: /root/bin/perf Try to find probe point from debuginfo. Probe point found: thread__put+0 Searching 'thread' variable in context. Converting variable thread into trace event. thread type is (null). Found 1 probe_trace_events. Opening /sys/kernel/debug/tracing/uprobe_events write=1 Added new event: Writing event: p:probe_perf/thread__put /root/bin/perf:0xd03d2 thread=-32(%sp):u64 Failed to write event: Invalid argument Error: Failed to add events. Reason: Invalid argument (Code: -22) [root@ssdandy ~]# Not possible :-\ please let me know if you need some file, here is the readelf -wi for those two routines: # readelf -wi ~/bin/perf <1>: Abbrev Number: 35 (DW_TAG_subprogram) DW_AT_external : 1 DW_AT_name : (indirect string, offset: 0x4c5c3): thread__get DW_AT_decl_file : 6 DW_AT_decl_line : 84 DW_AT_prototyped : 1 DW_AT_type : <0xe15cc> DW_AT_low_pc : 0x4d038c DW_AT_high_pc : 0x46 DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa) DW_AT_GNU_all_tail_call_sites: 1 DW_AT_sibling : <0xe2621> <2>: Abbrev Number: 32 (DW_TAG_formal_parameter) DW_AT_name : (indirect string, offset: 0x43dc7): thread DW_AT_decl_file : 6 DW_AT_decl_line : 84 DW_AT_type : <0xe15cc> DW_AT_location : 2 byte block: 91 58 (DW_OP_fbreg: -40) <2>: Abbrev Number: 0 <1>: Abbrev Number: 39 (DW_TAG_subprogram) DW_AT_external : 1 DW_AT_name : (indirect string, offset: 0x4c699): thread__put DW_AT_decl_file : 6 DW_AT_decl_line : 90 DW_AT_prototyped : 1 DW_AT_low_pc : 0x4d03d2 DW_AT_high_pc : 0x6c DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa) DW_AT_GNU_all_tail_call_sites: 1 DW_AT_sibling : <0xe264d> <2>: Abbrev Number: 32 (DW_TAG_formal_parameter) DW_AT_name : (indirect string, offset: 0x43dc7): thread DW_AT_decl_file : 6 DW_AT_decl_line : 90 DW_AT_type : <0xe15cc> Will see what I can do with just: [root@ssdandy ~]# perf probe ~/bin/perf thread__get Added new event: probe_perf:thread__get (on thread__get in /root/bin/perf) You can now use it in all perf tools, such as: perf record -e probe_perf:thread__get -aR sleep 1 [root@ssdandy ~]# perf probe ~/bin/perf thread__put Added new event: probe_perf:thread__put (on thread__put in /root/bin/perf) You can now use it in all perf tools, such as: perf record -e probe_perf:thread__put -aR sleep 1 [root@ssdandy ~]# perf list probe*:* List of pre-defined events (to be used in -e): probe_perf:thread__put [Tracepoint event] probe_perf:thread__get [Tracepoint event] [root@ssdandy ~]# perf probe -l probe_perf:thread__get (on thread__get@util/thread.c in /root/bin/perf) probe_perf:thread__put (on thread__put@util/thread.c in /root/bin/perf) [root@ssdandy ~]# - Arnaldo -- 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/