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  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1607996131-9340-1-git-send-email-yangtiezhu@loongson.cn>
Date:   Tue, 15 Dec 2020 09:35:31 +0800
From:   Tiezhu Yang <yangtiezhu@...ngson.cn>
To:     Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...hat.com>,
        Namhyung Kim <namhyung@...nel.org>
Cc:     linux-kernel@...r.kernel.org, Xuefeng Li <lixuefeng@...ngson.cn>
Subject: [PATCH v2] perf callchain: Return directly when use '--call-graph dwarf' under !HAVE_DWARF_SUPPORT

DWARF register mappings have not been defined for some architectures,
at least for mips, so we can print an error message and then return
directly when use '--call-graph dwarf'.

E.g. without this patch:

[root@...ux perf]# ./perf record --call-graph dwarf cd
Error:
The sys_perf_event_open() syscall returned with 89 (Function not implemented) for event (cycles).
/bin/dmesg | grep -i perf may provide additional information.

With this patch:

[root@...ux perf]# ./perf record --call-graph dwarf cd
DWARF is not supported for architecture mips64

 Usage: perf record [<options>] [<command>]
    or: perf record [<options>] -- <command> [<options>]

        --call-graph <record_mode[,record_size]>
                          setup and enables call-graph (stack chain/backtrace):

				record_mode:	call graph recording mode (fp|dwarf|lbr)
				record_size:	if record_mode is 'dwarf', max size of stack recording (<bytes>)
						default: 8192 (bytes)

				Default: fp

Signed-off-by: Tiezhu Yang <yangtiezhu@...ngson.cn>
---

v2: Use HAVE_DWARF_SUPPORT to check

 tools/perf/util/callchain.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
index 1b60985..ad08554 100644
--- a/tools/perf/util/callchain.c
+++ b/tools/perf/util/callchain.c
@@ -18,6 +18,7 @@
 #include <math.h>
 #include <linux/string.h>
 #include <linux/zalloc.h>
+#include <sys/utsname.h>
 
 #include "asm/bug.h"
 
@@ -276,6 +277,7 @@ int parse_callchain_record(const char *arg, struct callchain_param *param)
 
 		/* Dwarf style */
 		} else if (!strncmp(name, "dwarf", sizeof("dwarf"))) {
+#ifdef HAVE_DWARF_SUPPORT
 			const unsigned long default_stack_dump_size = 8192;
 
 			ret = 0;
@@ -290,6 +292,15 @@ int parse_callchain_record(const char *arg, struct callchain_param *param)
 				ret = get_stack_size(tok, &size);
 				param->dump_size = size;
 			}
+#else
+			struct utsname uts;
+
+			ret = uname(&uts);
+			pr_err("DWARF is not supported for architecture %s\n",
+				ret ? "unknown" : uts.machine);
+
+			return -ENOTSUP;
+#endif
 		} else if (!strncmp(name, "lbr", sizeof("lbr"))) {
 			if (!strtok_r(NULL, ",", &saveptr)) {
 				param->record_mode = CALLCHAIN_LBR;
-- 
2.1.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ