From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932484AbcHVPTX (ORCPT ); Mon, 22 Aug 2016 11:19:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41340 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932457AbcHVPTV (ORCPT ); Mon, 22 Aug 2016 11:19:21 -0400 Date: Mon, 22 Aug 2016 17:19:19 +0200 From: Jiri Olsa To: Matija Glavinic Pecotic Cc: acme@redhat.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH RFC RESEND] Perf: lookup dwarf unwind stack info in debug file pointed by .gnu_debuglink Message-ID: <20160822151919.GA614@krava> References: <2d72fb64-9b9c-7aa1-5ac5-ac710ec5a900@nokia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2d72fb64-9b9c-7aa1-5ac5-ac710ec5a900@nokia.com> User-Agent: Mutt/1.7.0 (2016-08-17) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 22 Aug 2016 15:19:21 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 22, 2016 at 02:32:04PM +0200, Matija Glavinic Pecotic wrote: SNIP > Signed-off-by: Matija Glavinic Pecotic > --- > tools/perf/util/unwind-libunwind-local.c | 36 ++++++++++++++++++++++++++++---- > 1 file changed, 32 insertions(+), 4 deletions(-) > > diff --git a/tools/perf/util/unwind-libunwind-local.c b/tools/perf/util/unwind-libunwind-local.c > index 97c0f8f..5d40acd 100644 > --- a/tools/perf/util/unwind-libunwind-local.c > +++ b/tools/perf/util/unwind-libunwind-local.c > @@ -35,6 +35,7 @@ > #include "util.h" > #include "debug.h" > #include "asm/bug.h" > +#include "dso.h" > > extern int > UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as, > @@ -292,10 +293,13 @@ static int read_unwind_spec_eh_frame(struct dso *dso, struct machine *machine, > > #ifndef NO_LIBUNWIND_DEBUG_FRAME > static int read_unwind_spec_debug_frame(struct dso *dso, > - struct machine *machine, u64 *offset) > + struct machine *machine, u64 *offset, > + char **symfile) > { > int fd; > u64 ofs = dso->data.debug_frame_offset; > + char *debuglink = malloc(PATH_MAX); > + int ret = 0; > > if (ofs == 0) { > fd = dso__data_get_fd(dso, machine); > @@ -312,6 +316,26 @@ static int read_unwind_spec_debug_frame(struct dso *dso, > if (*offset) > return 0; > > + /* If not found, try to lookup in debuglink */ > + ret = dso__read_binary_type_filename( > + dso, DSO_BINARY_TYPE__DEBUGLINK, > + machine->root_dir, debuglink, PATH_MAX); > + if (!ret) { > + pr_debug("%s: dso: %s, ret: %d, debuglink: <%s>\n", > + __func__, dso->short_name, ret, debuglink); > + > + fd = open(debuglink, O_RDONLY); > + if (fd >= 0) { > + ofs = elf_section_offset(fd, ".debug_frame"); > + close(fd); should you also set following? *offset = ofs dso->debug_frame_offset = ofs; I guess if we found the debuglink section with file having .debug_frame section, we want to use it for this dso from now on.. I'd think let's have read_unwind_spec_debug_frame to find .debug_frame and provide that info under dso object for subsequent reads > + > + if (ofs) { > + *symfile = debuglink; > + return 0; > + } > + } > + } > + > return -EINVAL; > } > #endif > @@ -343,6 +367,7 @@ find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi, > unw_dyn_info_t di; > u64 table_data, segbase, fde_count; > int ret = -EINVAL; > + char *symfile = NULL; > > map = find_map(ip, ui); > if (!map || !map->dso) > @@ -368,16 +393,19 @@ find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi, > #ifndef NO_LIBUNWIND_DEBUG_FRAME > /* Check the .debug_frame section for unwinding info */ > if (ret < 0 && > - !read_unwind_spec_debug_frame(map->dso, ui->machine, &segbase)) { > + !read_unwind_spec_debug_frame( > + map->dso, ui->machine, &segbase, &symfile)) { > int fd = dso__data_get_fd(map->dso, ui->machine); > int is_exec = elf_is_exec(fd, map->dso->name); > unw_word_t base = is_exec ? 0 : map->start; > - const char *symfile; > > if (fd >= 0) > dso__data_put_fd(map->dso); > > - symfile = map->dso->symsrc_filename ?: map->dso->name; > + if (!symfile) > + symfile = map->dso->symsrc_filename ?: map->dso->name; so in case we find debuglink-ed file, it has precedence over the file we found symtab in? assuming thats what dso->symsrc_filename is.. thanks, jirka