From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S938664AbdAESst (ORCPT ); Thu, 5 Jan 2017 13:48:49 -0500 Received: from mail.kernel.org ([198.145.29.136]:45510 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S938651AbdAESs2 (ORCPT ); Thu, 5 Jan 2017 13:48:28 -0500 Date: Thu, 5 Jan 2017 15:47:43 -0300 From: Arnaldo Carvalho de Melo To: Masami Hiramatsu Cc: linux-kernel@vger.kernel.org, Jiri Olsa , Peter Zijlstra , Ingo Molnar , Namhyung Kim Subject: Re: [PATCH perf/core 3/3] perf-probe: Fix to probe on gcc generated functions in modules Message-ID: <20170105184743.GO27864@kernel.org> References: <148350046263.19001.16486219029429895749.stgit@devbox> <148350067886.19001.17914403329655231652.stgit@devbox> <20170104144856.GL27864@kernel.org> <20170105202019.4764dbb16f4076304bc5de3c@kernel.org> <20170105153037.GN27864@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170105153037.GN27864@kernel.org> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.7.1 (2016-10-04) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Thu, Jan 05, 2017 at 12:30:37PM -0300, Arnaldo Carvalho de Melo escreveu: > Em Thu, Jan 05, 2017 at 08:20:19PM +0900, Masami Hiramatsu escreveu: > > On Wed, 4 Jan 2017 11:48:56 -0300 > > Arnaldo Carvalho de Melo wrote: > > > [acme@jouet linux]$ grep e1000_xmit_frame /proc/kallsyms > > > ffffffffc046fc10 t e1000_xmit_frame [e1000e] > > > [acme@jouet linux]$ > > OK, it sounds reasonable to me too. BTW, how can I get the map for kallsyms? > > May machine__findnew_module_map(host_machine, ,"[kernel.kallsyms]") > > include module symbols too? > Probably what you want is: > symbol = machine__find_kernel_function_by_name(machine, name, &map); > Then, if symbol is not NULL, map->dso->name will have your module name, > map->dso->long_name will have the .ko path, etc. Take a look at 'perf kallsyms' a simple toy cmd that exercises the APIs you need: https://git.kernel.org/cgit/linux/kernel/git/acme/linux.git/commit/?h=perf/core&id=25c92235676d2655e3f31ffe02bd4355d838e5e9 Basically: struct machine *machine = machine__new_kallsyms(); struct map *map; struct symbol *symbol = machine__find_kernel_function_by_name(machine, symbol_name, &map); Then you have symbol->{addr,end,name,etc} and map->dso->{long,short}_name $ perf kallsyms e1000_xmit_frame usb_stor_set_xfer_buf e1000_xmit_frame: [e1000e] /lib/modules/4.9.0+/kernel/drivers/net/ethernet/intel/e1000e/e1000e.ko 0xffffffffc046fc10-0xffffffffc0470bb0 (0x19c80-0x1ac20) usb_stor_set_xfer_buf: [usb_storage] /lib/modules/4.9.0+/kernel/drivers/usb/storage/usb-storage.ko 0xffffffffc057aea0-0xffffffffc057af19 (0xf10-0xf89) - Arnaldo