aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-record.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/builtin-record.c')
-rw-r--r--tools/perf/builtin-record.c41
1 files changed, 22 insertions, 19 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 10b1f1f25ed..4dcf27057bd 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -44,7 +44,6 @@ struct perf_record {
44 struct perf_evlist *evlist; 44 struct perf_evlist *evlist;
45 struct perf_session *session; 45 struct perf_session *session;
46 const char *progname; 46 const char *progname;
47 const char *uid_str;
48 int output; 47 int output;
49 unsigned int page_size; 48 unsigned int page_size;
50 int realtime_prio; 49 int realtime_prio;
@@ -218,7 +217,7 @@ try_again:
218 if (err == EPERM || err == EACCES) { 217 if (err == EPERM || err == EACCES) {
219 ui__error_paranoid(); 218 ui__error_paranoid();
220 exit(EXIT_FAILURE); 219 exit(EXIT_FAILURE);
221 } else if (err == ENODEV && opts->cpu_list) { 220 } else if (err == ENODEV && opts->target.cpu_list) {
222 die("No such device - did you specify" 221 die("No such device - did you specify"
223 " an out-of-range profile CPU?\n"); 222 " an out-of-range profile CPU?\n");
224 } else if (err == EINVAL) { 223 } else if (err == EINVAL) {
@@ -578,7 +577,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
578 perf_session__process_machines(session, tool, 577 perf_session__process_machines(session, tool,
579 perf_event__synthesize_guest_os); 578 perf_event__synthesize_guest_os);
580 579
581 if (!opts->system_wide) 580 if (!opts->target.system_wide)
582 perf_event__synthesize_thread_map(tool, evsel_list->threads, 581 perf_event__synthesize_thread_map(tool, evsel_list->threads,
583 process_synthesized_event, 582 process_synthesized_event,
584 machine); 583 machine);
@@ -765,9 +764,9 @@ const struct option record_options[] = {
765 parse_events_option), 764 parse_events_option),
766 OPT_CALLBACK(0, "filter", &record.evlist, "filter", 765 OPT_CALLBACK(0, "filter", &record.evlist, "filter",
767 "event filter", parse_filter), 766 "event filter", parse_filter),
768 OPT_STRING('p', "pid", &record.opts.target_pid, "pid", 767 OPT_STRING('p', "pid", &record.opts.target.pid, "pid",
769 "record events on existing process id"), 768 "record events on existing process id"),
770 OPT_STRING('t', "tid", &record.opts.target_tid, "tid", 769 OPT_STRING('t', "tid", &record.opts.target.tid, "tid",
771 "record events on existing thread id"), 770 "record events on existing thread id"),
772 OPT_INTEGER('r', "realtime", &record.realtime_prio, 771 OPT_INTEGER('r', "realtime", &record.realtime_prio,
773 "collect data with this RT SCHED_FIFO priority"), 772 "collect data with this RT SCHED_FIFO priority"),
@@ -775,11 +774,11 @@ const struct option record_options[] = {
775 "collect data without buffering"), 774 "collect data without buffering"),
776 OPT_BOOLEAN('R', "raw-samples", &record.opts.raw_samples, 775 OPT_BOOLEAN('R', "raw-samples", &record.opts.raw_samples,
777 "collect raw sample records from all opened counters"), 776 "collect raw sample records from all opened counters"),
778 OPT_BOOLEAN('a', "all-cpus", &record.opts.system_wide, 777 OPT_BOOLEAN('a', "all-cpus", &record.opts.target.system_wide,
779 "system-wide collection from all CPUs"), 778 "system-wide collection from all CPUs"),
780 OPT_BOOLEAN('A', "append", &record.append_file, 779 OPT_BOOLEAN('A', "append", &record.append_file,
781 "append to the output file to do incremental profiling"), 780 "append to the output file to do incremental profiling"),
782 OPT_STRING('C', "cpu", &record.opts.cpu_list, "cpu", 781 OPT_STRING('C', "cpu", &record.opts.target.cpu_list, "cpu",
783 "list of cpus to monitor"), 782 "list of cpus to monitor"),
784 OPT_BOOLEAN('f', "force", &record.force, 783 OPT_BOOLEAN('f', "force", &record.force,
785 "overwrite existing data file (deprecated)"), 784 "overwrite existing data file (deprecated)"),
@@ -813,7 +812,8 @@ const struct option record_options[] = {
813 OPT_CALLBACK('G', "cgroup", &record.evlist, "name", 812 OPT_CALLBACK('G', "cgroup", &record.evlist, "name",
814 "monitor event in cgroup name only", 813 "monitor event in cgroup name only",
815 parse_cgroups), 814 parse_cgroups),
816 OPT_STRING('u', "uid", &record.uid_str, "user", "user to profile"), 815 OPT_STRING('u', "uid", &record.opts.target.uid_str, "user",
816 "user to profile"),
817 817
818 OPT_CALLBACK_NOOPT('b', "branch-any", &record.opts.branch_stack, 818 OPT_CALLBACK_NOOPT('b', "branch-any", &record.opts.branch_stack,
819 "branch any", "sample any taken branches", 819 "branch any", "sample any taken branches",
@@ -842,8 +842,9 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
842 842
843 argc = parse_options(argc, argv, record_options, record_usage, 843 argc = parse_options(argc, argv, record_options, record_usage,
844 PARSE_OPT_STOP_AT_NON_OPTION); 844 PARSE_OPT_STOP_AT_NON_OPTION);
845 if (!argc && !rec->opts.target_pid && !rec->opts.target_tid && 845 if (!argc && !rec->opts.target.pid && !rec->opts.target.tid &&
846 !rec->opts.system_wide && !rec->opts.cpu_list && !rec->uid_str) 846 !rec->opts.target.system_wide && !rec->opts.target.cpu_list &&
847 !rec->opts.target.uid_str)
847 usage_with_options(record_usage, record_options); 848 usage_with_options(record_usage, record_options);
848 849
849 if (rec->force && rec->append_file) { 850 if (rec->force && rec->append_file) {
@@ -856,7 +857,7 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
856 rec->write_mode = WRITE_FORCE; 857 rec->write_mode = WRITE_FORCE;
857 } 858 }
858 859
859 if (nr_cgroups && !rec->opts.system_wide) { 860 if (nr_cgroups && !rec->opts.target.system_wide) {
860 fprintf(stderr, "cgroup monitoring only available in" 861 fprintf(stderr, "cgroup monitoring only available in"
861 " system-wide mode\n"); 862 " system-wide mode\n");
862 usage_with_options(record_usage, record_options); 863 usage_with_options(record_usage, record_options);
@@ -883,17 +884,19 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
883 goto out_symbol_exit; 884 goto out_symbol_exit;
884 } 885 }
885 886
886 rec->opts.uid = parse_target_uid(rec->uid_str, rec->opts.target_tid, 887 rec->opts.target.uid = parse_target_uid(rec->opts.target.uid_str,
887 rec->opts.target_pid); 888 rec->opts.target.tid,
888 if (rec->uid_str != NULL && rec->opts.uid == UINT_MAX - 1) 889 rec->opts.target.pid);
890 if (rec->opts.target.uid_str != NULL &&
891 rec->opts.target.uid == UINT_MAX - 1)
889 goto out_free_fd; 892 goto out_free_fd;
890 893
891 if (rec->opts.target_pid) 894 if (rec->opts.target.pid)
892 rec->opts.target_tid = rec->opts.target_pid; 895 rec->opts.target.tid = rec->opts.target.pid;
893 896
894 if (perf_evlist__create_maps(evsel_list, rec->opts.target_pid, 897 if (perf_evlist__create_maps(evsel_list, rec->opts.target.pid,
895 rec->opts.target_tid, rec->opts.uid, 898 rec->opts.target.tid, rec->opts.target.uid,
896 rec->opts.cpu_list) < 0) 899 rec->opts.target.cpu_list) < 0)
897 usage_with_options(record_usage, record_options); 900 usage_with_options(record_usage, record_options);
898 901
899 list_for_each_entry(pos, &evsel_list->entries, node) { 902 list_for_each_entry(pos, &evsel_list->entries, node) {