From: Jiri Olsa <jolsa@redhat.com>
To: Matija Glavinic Pecotic <matija.glavinic-pecotic.ext@nokia.com>
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
Date: Mon, 22 Aug 2016 17:19:19 +0200 [thread overview]
Message-ID: <20160822151919.GA614@krava> (raw)
In-Reply-To: <2d72fb64-9b9c-7aa1-5ac5-ac710ec5a900@nokia.com>
On Mon, Aug 22, 2016 at 02:32:04PM +0200, Matija Glavinic Pecotic wrote:
SNIP
> Signed-off-by: Matija Glavinic Pecotic <matija.glavinic-pecotic.ext@nokia.com>
> ---
> 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
next prev parent reply other threads:[~2016-08-22 15:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-22 12:32 [PATCH RFC RESEND] Perf: lookup dwarf unwind stack info in debug file pointed by .gnu_debuglink Matija Glavinic Pecotic
2016-08-22 15:19 ` Jiri Olsa [this message]
2016-08-23 5:09 ` Matija Glavinic Pecotic
2016-08-23 11:22 ` Jiri Olsa
2016-08-23 12:33 ` Matija Glavinic Pecotic
2016-08-23 16:18 ` Matija Glavinic Pecotic
2016-08-24 7:30 ` Jiri Olsa
2016-08-24 8:13 ` Matija Glavinic Pecotic
2016-08-26 6:12 ` Namhyung Kim
2016-08-26 7:00 ` Matija Glavinic Pecotic
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160822151919.GA614@krava \
--to=jolsa@redhat.com \
--cc=acme@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matija.glavinic-pecotic.ext@nokia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox