lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sat, 14 May 2016 08:19:25 +0000
From:	He Kuang <hekuang@...wei.com>
To:	<peterz@...radead.org>, <mingo@...hat.com>, <acme@...nel.org>,
	<alexander.shishkin@...ux.intel.com>, <jolsa@...hat.com>,
	<wangnan0@...wei.com>, <hekuang@...wei.com>, <jpoimboe@...hat.com>,
	<ak@...ux.intel.com>, <eranian@...gle.com>, <namhyung@...nel.org>,
	<adrian.hunter@...el.com>, <sukadev@...ux.vnet.ibm.com>,
	<masami.hiramatsu.pt@...achi.com>, <tumanova@...ux.vnet.ibm.com>,
	<kan.liang@...el.com>, <penberg@...nel.org>, <dsahern@...il.com>
CC:	<linux-kernel@...r.kernel.org>
Subject: [PATCH v3 3/7 UPDATE] perf tools: Add option for the path of buildid dsos under symfs

In the cross-platform perf record/script scenario, we need vdsos in
buildid-cache dir and other libs in symfs dir at the same time. For
the reason that to have every single file opened by perf is relative
to symfs dirctory, perf skips the buildid dir if symfs is given.

This patch references the buildid dir under symfs if '--symfs' is
used, and adds new option '--dso-prefix' to specify the subdir path in
symfs which contains the buildid dsos.

Signed-off-by: He Kuang <hekuang@...wei.com>
---
 tools/perf/builtin-script.c |  2 ++
 tools/perf/util/config.c    | 10 ++++++++++
 tools/perf/util/dso.c       |  6 ++++--
 tools/perf/util/symbol.c    |  1 +
 tools/perf/util/symbol.h    |  1 +
 tools/perf/util/util.h      |  1 +
 6 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 8f6ab2a..52526e8 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -2043,6 +2043,8 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
 			"Enable symbol demangling"),
 	OPT_BOOLEAN(0, "demangle-kernel", &symbol_conf.demangle_kernel,
 			"Enable kernel symbol demangling"),
+	OPT_STRING(0, "dso-prefix", &symbol_conf.dso_prefix, "direcotry",
+			"Look for dsos relative to this directory under symfs"),
 
 	OPT_END()
 	};
diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c
index 664490b..17bee62 100644
--- a/tools/perf/util/config.c
+++ b/tools/perf/util/config.c
@@ -553,3 +553,13 @@ void set_buildid_dir(const char *dir)
 	/* for communicating with external commands */
 	setenv("PERF_BUILDID_DIR", buildid_dir, 1);
 }
+
+static bool buildid_dir_under_symfs_flag;
+void set_buildid_dir_under_symfs(void)
+{
+	if (!buildid_dir_under_symfs_flag && symbol_conf.symfs[0]) {
+		__symbol__join_symfs(buildid_dir, MAXPATHLEN-1,
+				     symbol_conf.dso_prefix);
+		buildid_dir_under_symfs_flag = true;
+	}
+}
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index b39b80c..fb34274 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -64,8 +64,10 @@ int dso__read_binary_type_filename(const struct dso *dso,
 		break;
 	case DSO_BINARY_TYPE__BUILD_ID_CACHE:
 		/* skip the locally configured cache if a symfs is given */
-		if (symbol_conf.symfs[0] ||
-		    (dso__build_id_filename(dso, filename, size) == NULL))
+		if (symbol_conf.symfs[0])
+			set_buildid_dir_under_symfs();
+
+		if (dso__build_id_filename(dso, filename, size) == NULL)
 			ret = -1;
 		break;
 
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index e7588dc..7aa34ca 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -40,6 +40,7 @@ struct symbol_conf symbol_conf = {
 	.show_hist_headers	= true,
 	.symfs			= "",
 	.event_group		= true,
+	.dso_prefix		= "",
 };
 
 static enum dso_binary_type binary_type_symtab[] = {
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index c8b7544..c0fefdb 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -136,6 +136,7 @@ struct symbol_conf {
 	struct intlist	*pid_list,
 			*tid_list;
 	const char	*symfs;
+	const char	*dso_prefix;
 };
 
 extern struct symbol_conf symbol_conf;
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 3bf3de8..f8e5582 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -142,6 +142,7 @@ void set_warning_routine(void (*routine)(const char *err, va_list params));
 
 int prefixcmp(const char *str, const char *prefix);
 void set_buildid_dir(const char *dir);
+void set_buildid_dir_under_symfs(void);
 
 #ifdef __GLIBC_PREREQ
 #if __GLIBC_PREREQ(2, 1)
-- 
1.8.5.2

Powered by blists - more mailing lists