From: Matija Glavinic Pecotic <matija.glavinic-pecotic.ext@nokia.com>
To: Jiri Olsa <jolsa@redhat.com>
Cc: <acme@redhat.com>, <linux-kernel@vger.kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Masami Hiramatsu <mhiramat@kernel.org>
Subject: Re: [PATCH RFC RESEND] Perf: lookup dwarf unwind stack info in debug file pointed by .gnu_debuglink
Date: Wed, 24 Aug 2016 10:13:58 +0200 [thread overview]
Message-ID: <4bd5fc49-95c2-e4ff-bfb4-a5da696a5c8a@nokia.com> (raw)
In-Reply-To: <20160824073010.GA3202@krava>
On 24/08/16 09:30, Jiri Olsa wrote:
> On Tue, Aug 23, 2016 at 06:18:10PM +0200, Matija Glavinic Pecotic wrote:
>> - ret = filename__read_debuglink(filename, debuglink,
>> - size - (debuglink - filename));
>> + ret = filename__read_debuglink(filename, symfile, PATH_MAX);
>> + if (ret)
>> + break;
>> +
>> + /* Check predefined locations where debug file might reside:
>> + * - if debuglink is absolute path, check only that one
>> + * If debuglink provides name w/o path, look for debug file:
>> + * - in the same directory as dso
>> + * - in the .debug subdirectory of dso directory
>> + * - in the /usr/lib/debug/[dso directory]
>> + * */
>> + ret = 0;
>> + if (symfile[0] == '/') {
>> + if (!is_regular_file(symfile))
>> + ret = -1;
>> + else
>> + strncpy(filename, symfile, size);
>> + break;
>> }
>> +
>> + snprintf(filename, size, "%s/%s", dso_dir, symfile);
>> + if(is_regular_file(filename))
>> + break;
>> +
>> + snprintf(filename, size, "%s/.debug/%s", dso_dir, symfile);
>> + if(is_regular_file(filename))
>> + break;
>> +
>> + snprintf(filename, size, "/usr/lib/debug/%s/%s",
>> + dso_dir, symfile);
>> + if(is_regular_file(filename))
>> + break;
>
> it might be more clear to follow the same way we do for vmlinux search,
> like array of possible paths and generic code to check.. search for
> vmlinux_path in symbol.c
It indeed looks better:
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 774f6ec..3ea205cc 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -35,6 +35,13 @@ char dso__symtab_origin(const struct dso *dso)
return origin[dso->symtab_type];
}
+static const char * const debuglink_paths[] = {
+ "%.0s%s",
+ "%s/%s",
+ "%s/.debug/%s",
+ "/usr/lib/debug%s/%s"
+};
+
int dso__read_binary_type_filename(const struct dso *dso,
enum dso_binary_type type,
char *root_dir, char *filename, size_t size)
@@ -44,24 +51,44 @@ int dso__read_binary_type_filename(const struct dso *dso,
size_t len;
switch (type) {
- case DSO_BINARY_TYPE__DEBUGLINK: {
- char *debuglink;
+ case DSO_BINARY_TYPE__DEBUGLINK:
+ {
+ const char *last_slash;
+ char dso_dir[PATH_MAX];
+ char symfile[PATH_MAX];
+ unsigned int i;
len = __symbol__join_symfs(filename, size, dso->long_name);
- debuglink = filename + len;
- while (debuglink != filename && *debuglink != '/')
- debuglink--;
- if (*debuglink == '/')
- debuglink++;
+ last_slash = filename + len;
+ while (last_slash != filename && *last_slash != '/')
+ last_slash--;
- ret = -1;
- if (!is_regular_file(filename))
+ strncpy(dso_dir, filename, last_slash - filename);
+ dso_dir[last_slash-filename] = '\0';
+
+ if (!is_regular_file(filename)) {
+ ret = -1;
+ break;
+ }
+
+ ret = filename__read_debuglink(filename, symfile, PATH_MAX);
+ if (ret)
break;
- ret = filename__read_debuglink(filename, debuglink,
- size - (debuglink - filename));
+ /* Check predefined locations where debug file might reside */
+ ret = -1;
+ for (i = 0; i < ARRAY_SIZE(debuglink_paths); i++) {
+ snprintf(filename, size,
+ debuglink_paths[i], dso_dir, symfile);
+ if(is_regular_file(filename)) {
+ ret = 0;
+ break;
+ }
}
+
break;
+ }
Thanks,
Matija
next prev parent reply other threads:[~2016-08-24 8:32 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
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 [this message]
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=4bd5fc49-95c2-e4ff-bfb4-a5da696a5c8a@nokia.com \
--to=matija.glavinic-pecotic.ext@nokia.com \
--cc=acme@redhat.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=namhyung@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.