aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-script.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/builtin-script.c')
-rw-r--r--tools/perf/builtin-script.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index c0783b4f7b6c..66d62c98dff9 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -830,6 +830,7 @@ struct perf_script {
830 bool show_task_events; 830 bool show_task_events;
831 bool show_mmap_events; 831 bool show_mmap_events;
832 bool show_switch_events; 832 bool show_switch_events;
833 bool show_namespace_events;
833 bool allocated; 834 bool allocated;
834 struct cpu_map *cpus; 835 struct cpu_map *cpus;
835 struct thread_map *threads; 836 struct thread_map *threads;
@@ -1118,6 +1119,41 @@ out:
1118 return ret; 1119 return ret;
1119} 1120}
1120 1121
1122static int process_namespaces_event(struct perf_tool *tool,
1123 union perf_event *event,
1124 struct perf_sample *sample,
1125 struct machine *machine)
1126{
1127 struct thread *thread;
1128 struct perf_script *script = container_of(tool, struct perf_script, tool);
1129 struct perf_session *session = script->session;
1130 struct perf_evsel *evsel = perf_evlist__id2evsel(session->evlist, sample->id);
1131 int ret = -1;
1132
1133 thread = machine__findnew_thread(machine, event->namespaces.pid,
1134 event->namespaces.tid);
1135 if (thread == NULL) {
1136 pr_debug("problem processing NAMESPACES event, skipping it.\n");
1137 return -1;
1138 }
1139
1140 if (perf_event__process_namespaces(tool, event, sample, machine) < 0)
1141 goto out;
1142
1143 if (!evsel->attr.sample_id_all) {
1144 sample->cpu = 0;
1145 sample->time = 0;
1146 sample->tid = event->namespaces.tid;
1147 sample->pid = event->namespaces.pid;
1148 }
1149 print_sample_start(sample, thread, evsel);
1150 perf_event__fprintf(event, stdout);
1151 ret = 0;
1152out:
1153 thread__put(thread);
1154 return ret;
1155}
1156
1121static int process_fork_event(struct perf_tool *tool, 1157static int process_fork_event(struct perf_tool *tool,
1122 union perf_event *event, 1158 union perf_event *event,
1123 struct perf_sample *sample, 1159 struct perf_sample *sample,
@@ -1293,6 +1329,8 @@ static int __cmd_script(struct perf_script *script)
1293 } 1329 }
1294 if (script->show_switch_events) 1330 if (script->show_switch_events)
1295 script->tool.context_switch = process_switch_event; 1331 script->tool.context_switch = process_switch_event;
1332 if (script->show_namespace_events)
1333 script->tool.namespaces = process_namespaces_event;
1296 1334
1297 ret = perf_session__process_events(script->session); 1335 ret = perf_session__process_events(script->session);
1298 1336
@@ -2097,6 +2135,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
2097 .mmap = perf_event__process_mmap, 2135 .mmap = perf_event__process_mmap,
2098 .mmap2 = perf_event__process_mmap2, 2136 .mmap2 = perf_event__process_mmap2,
2099 .comm = perf_event__process_comm, 2137 .comm = perf_event__process_comm,
2138 .namespaces = perf_event__process_namespaces,
2100 .exit = perf_event__process_exit, 2139 .exit = perf_event__process_exit,
2101 .fork = perf_event__process_fork, 2140 .fork = perf_event__process_fork,
2102 .attr = process_attr, 2141 .attr = process_attr,
@@ -2180,6 +2219,8 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
2180 "Show the mmap events"), 2219 "Show the mmap events"),
2181 OPT_BOOLEAN('\0', "show-switch-events", &script.show_switch_events, 2220 OPT_BOOLEAN('\0', "show-switch-events", &script.show_switch_events,
2182 "Show context switch events (if recorded)"), 2221 "Show context switch events (if recorded)"),
2222 OPT_BOOLEAN('\0', "show-namespace-events", &script.show_namespace_events,
2223 "Show namespace events (if recorded)"),
2183 OPT_BOOLEAN('f', "force", &symbol_conf.force, "don't complain, do it"), 2224 OPT_BOOLEAN('f', "force", &symbol_conf.force, "don't complain, do it"),
2184 OPT_BOOLEAN(0, "ns", &nanosecs, 2225 OPT_BOOLEAN(0, "ns", &nanosecs,
2185 "Use 9 decimal places when displaying time"), 2226 "Use 9 decimal places when displaying time"),