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: <8e00eda1-4de0-2c44-ce67-d4df48ac1f7c@suse.cz>
Date:   Fri, 12 Aug 2022 13:40:49 +0200
From:   Martin Liška <mliska@...e.cz>
To:     linux-kernel@...r.kernel.org, linux-perf-users@...r.kernel.org
Cc:     Arnaldo Carvalho de Melo <acme@...nel.org>
Subject: [PATCH] perf record: improve error message of -p not_existing_pid

When one uses -p $not_existing_pid, the output of --help is printed:

$ perf record -p 123456789 2>&1 | head -n3

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

Let's change it something similar what perf top -p $not_existing_pid
prints:

$ ./perf top -p 123456789 --stdio
Error:
Couldn't create thread/CPU maps: No such process

Newly suggested error message:

$ ./perf record -p 123456789
Couldn't create thread/CPU maps: No such process

Signed-off-by: Martin Liska <mliska@...e.cz>
---
 tools/perf/builtin-record.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index cf5c5379ceaa..4713f0f3a6cf 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -3996,8 +3996,15 @@ int cmd_record(int argc, const char **argv)
 		arch__add_leaf_frame_record_opts(&rec->opts);
 
 	err = -ENOMEM;
-	if (evlist__create_maps(rec->evlist, &rec->opts.target) < 0)
-		usage_with_options(record_usage, record_options);
+	if (evlist__create_maps(rec->evlist, &rec->opts.target) < 0) {
+		if (rec->opts.target.pid != NULL) {
+			pr_err("Couldn't create thread/CPU maps: %s\n",
+				errno == ENOENT ? "No such process" : str_error_r(errno, errbuf, sizeof(errbuf)));
+			goto out;
+		}
+		else
+			usage_with_options(record_usage, record_options);
+	}
 
 	err = auxtrace_record__options(rec->itr, rec->evlist, &rec->opts);
 	if (err)
-- 
2.37.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ