lkml.org 
[lkml]   [2015]   [Jan]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/2] perf symbols: debuglink should take symfs option into account
Date
Currently code that tries to read corresponding debug symbol
file from .gnu_debuglink section (DSO_BINARY_TYPE__DEBUGLINK)
does not take in account symfs option, so filename__read_debuglink
function cannot open ELF file, if symfs option is used.

Fix is to add proper handling of symfs as it is done in other
places: use __symbol__join_symfs function to get real file name
of target ELF file.

Created malloced copy of target filename in symfs before passing
it to __symbol__join_symfs function because filename will be
modified by it if corresponding debuglink is found.

Signed-off-by: Victor Kamensky <victor.kamensky@linaro.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Waiman Long <Waiman.Long@hp.com>
Cc: David Ahern <dsahern@gmail.com>
---
tools/perf/util/dso.c | 33 ++++++++++++++++++++++-----------
1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 45be944..6a2f663 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -42,19 +42,30 @@ int dso__read_binary_type_filename(const struct dso *dso,
size_t len;

switch (type) {
- case DSO_BINARY_TYPE__DEBUGLINK: {
+ case DSO_BINARY_TYPE__DEBUGLINK:
+ {
char *debuglink;
-
- strncpy(filename, dso->long_name, size);
- debuglink = filename + dso->long_name_len;
- while (debuglink != filename && *debuglink != '/')
- debuglink--;
- if (*debuglink == '/')
- debuglink++;
- ret = filename__read_debuglink(dso->long_name, debuglink,
- size - (debuglink - filename));
- }
+ char *filename_copy;
+
+ filename_copy = malloc(PATH_MAX);
+ if (filename_copy) {
+ len = __symbol__join_symfs(filename, size,
+ dso->long_name);
+ strncpy(filename_copy, filename, PATH_MAX);
+ debuglink = filename + len;
+ while (debuglink != filename && *debuglink != '/')
+ debuglink--;
+ if (*debuglink == '/')
+ debuglink++;
+ ret = filename__read_debuglink(filename_copy, debuglink,
+ size - (debuglink -
+ filename));
+ free(filename_copy);
+ } else
+ ret = -1;
break;
+ }
+
case DSO_BINARY_TYPE__BUILD_ID_CACHE:
/* skip the locally configured cache if a symfs is given */
if (symbol_conf.symfs[0] ||
--
1.9.3


\
 
 \ /
  Last update: 2015-01-13 18:21    [W:0.098 / U:32.924 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site