From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
Ingo Molnar <mingo@kernel.org>, Paul Mackerras <paulus@samba.org>,
Namhyung Kim <namhyung.kim@lge.com>,
Namhyung Kim <namhyung@kernel.org>,
LKML <linux-kernel@vger.kernel.org>, Jiri Olsa <jolsa@redhat.com>,
David Ahern <dsahern@gmail.com>, Minchan Kim <minchan@kernel.org>
Subject: [PATCH 1/2] perf tools: Ensure --symfs ends with '/'
Date: Fri, 25 Jul 2014 10:31:47 +0900 [thread overview]
Message-ID: <1406251908-8195-1-git-send-email-namhyung@kernel.org> (raw)
Minchan reported that perf failed to load vmlinux if --symfs argument
doesn't end with '/' character. So make sure that the symfs always
ends with the '/'.
Reported-by: Minchan Kim <minchan@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/util/symbol.c | 41 +++++++++++++++++++++++++++++------------
1 file changed, 29 insertions(+), 12 deletions(-)
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index eb06746b06b2..90723a12e947 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1829,7 +1829,7 @@ static bool symbol__read_kptr_restrict(void)
int symbol__init(void)
{
- const char *symfs;
+ char *symfs;
if (symbol_conf.initialized)
return 0;
@@ -1862,23 +1862,40 @@ int symbol__init(void)
symbol_conf.sym_list_str, "symbol") < 0)
goto out_free_comm_list;
- /*
- * A path to symbols of "/" is identical to ""
- * reset here for simplicity.
- */
- symfs = realpath(symbol_conf.symfs, NULL);
- if (symfs == NULL)
- symfs = symbol_conf.symfs;
- if (strcmp(symfs, "/") == 0)
- symbol_conf.symfs = "";
- if (symfs != symbol_conf.symfs)
- free((void *)symfs);
+ if (*symbol_conf.symfs) {
+ symfs = realpath(symbol_conf.symfs, NULL);
+ if (symfs == NULL)
+ symfs = (char *)symbol_conf.symfs;
+
+ /*
+ * A path to symbols of "/" is identical to ""
+ * reset here for simplicity.
+ */
+ if (strcmp(symfs, "/") == 0)
+ symbol_conf.symfs = "";
+
+ /* ensure symfs ends with '/' */
+ if (symfs[strlen(symfs)-1] != '/') {
+ char *tmp = realloc(symfs, strlen(symfs) + 2);
+ if (tmp == NULL)
+ goto out_free;
+
+ tmp[strlen(tmp)+1] = '\0';
+ tmp[strlen(tmp)] = '/';
+
+ symbol_conf.symfs = tmp;
+ } else {
+ free(symfs);
+ }
+ }
symbol_conf.kptr_restrict = symbol__read_kptr_restrict();
symbol_conf.initialized = true;
return 0;
+out_free:
+ free(symfs);
out_free_comm_list:
strlist__delete(symbol_conf.comm_list);
out_free_dso_list:
--
2.0.0
next reply other threads:[~2014-07-25 1:31 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-25 1:31 Namhyung Kim [this message]
2014-07-25 1:31 ` [PATCH 2/2] perf tools: Check validity of --symfs value Namhyung Kim
2014-07-25 13:15 ` [PATCH 1/2] perf tools: Ensure --symfs ends with '/' Arnaldo Carvalho de Melo
2014-07-28 1:04 ` Namhyung Kim
2014-07-29 5:02 ` Minchan Kim
2014-07-29 12:33 ` Arnaldo Carvalho de Melo
2014-07-29 13:26 ` Minchan Kim
2014-07-29 13:43 ` Arnaldo Carvalho de Melo
2014-07-29 15:12 ` Arnaldo Carvalho de Melo
2014-07-29 13:57 ` David Ahern
2014-07-29 23:52 ` Namhyung Kim
2014-07-30 15:19 ` Arnaldo Carvalho de Melo
2014-07-30 20:55 ` Arnaldo Carvalho de Melo
2014-07-30 22:20 ` David Ahern
2014-07-31 4:25 ` Namhyung Kim
2014-07-31 12:26 ` Arnaldo Carvalho de Melo
2014-07-31 23:38 ` Namhyung Kim
2014-08-01 20:15 ` Arnaldo Carvalho de Melo
2014-08-11 7:38 ` Namhyung Kim
2014-08-11 13:15 ` Arnaldo Carvalho de Melo
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=1406251908-8195-1-git-send-email-namhyung@kernel.org \
--to=namhyung@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=dsahern@gmail.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=minchan@kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung.kim@lge.com \
--cc=paulus@samba.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome