perf evsel: Allow passing a left alignment when printing a symbol
[deliverable/linux.git] / tools / perf / util / session.c
index 40b7a0d0905b8d7f01972c6e38e225f108b15133..62b6d4051b99c1e5c6e9fd4a6061116f9951cc50 100644 (file)
@@ -240,14 +240,6 @@ static int process_event_stub(struct perf_tool *tool __maybe_unused,
        return 0;
 }
 
-static int process_build_id_stub(struct perf_tool *tool __maybe_unused,
-                                union perf_event *event __maybe_unused,
-                                struct perf_session *session __maybe_unused)
-{
-       dump_printf(": unhandled!\n");
-       return 0;
-}
-
 static int process_finished_round_stub(struct perf_tool *tool __maybe_unused,
                                       union perf_event *event __maybe_unused,
                                       struct ordered_events *oe __maybe_unused)
@@ -260,23 +252,6 @@ static int process_finished_round(struct perf_tool *tool,
                                  union perf_event *event,
                                  struct ordered_events *oe);
 
-static int process_id_index_stub(struct perf_tool *tool __maybe_unused,
-                                union perf_event *event __maybe_unused,
-                                struct perf_session *perf_session
-                                __maybe_unused)
-{
-       dump_printf(": unhandled!\n");
-       return 0;
-}
-
-static int process_event_auxtrace_info_stub(struct perf_tool *tool __maybe_unused,
-                               union perf_event *event __maybe_unused,
-                               struct perf_session *session __maybe_unused)
-{
-       dump_printf(": unhandled!\n");
-       return 0;
-}
-
 static int skipn(int fd, off_t n)
 {
        char buf[4096];
@@ -303,10 +278,9 @@ static s64 process_event_auxtrace_stub(struct perf_tool *tool __maybe_unused,
        return event->auxtrace.size;
 }
 
-static
-int process_event_auxtrace_error_stub(struct perf_tool *tool __maybe_unused,
-                                     union perf_event *event __maybe_unused,
-                                     struct perf_session *session __maybe_unused)
+static int process_event_op2_stub(struct perf_tool *tool __maybe_unused,
+                                 union perf_event *event __maybe_unused,
+                                 struct perf_session *session __maybe_unused)
 {
        dump_printf(": unhandled!\n");
        return 0;
@@ -410,7 +384,7 @@ void perf_tool__fill_defaults(struct perf_tool *tool)
        if (tool->tracing_data == NULL)
                tool->tracing_data = process_event_synth_tracing_data_stub;
        if (tool->build_id == NULL)
-               tool->build_id = process_build_id_stub;
+               tool->build_id = process_event_op2_stub;
        if (tool->finished_round == NULL) {
                if (tool->ordered_events)
                        tool->finished_round = process_finished_round;
@@ -418,13 +392,13 @@ void perf_tool__fill_defaults(struct perf_tool *tool)
                        tool->finished_round = process_finished_round_stub;
        }
        if (tool->id_index == NULL)
-               tool->id_index = process_id_index_stub;
+               tool->id_index = process_event_op2_stub;
        if (tool->auxtrace_info == NULL)
-               tool->auxtrace_info = process_event_auxtrace_info_stub;
+               tool->auxtrace_info = process_event_op2_stub;
        if (tool->auxtrace == NULL)
                tool->auxtrace = process_event_auxtrace_stub;
        if (tool->auxtrace_error == NULL)
-               tool->auxtrace_error = process_event_auxtrace_error_stub;
+               tool->auxtrace_error = process_event_op2_stub;
        if (tool->thread_map == NULL)
                tool->thread_map = process_event_thread_map_stub;
        if (tool->cpu_map == NULL)
@@ -435,6 +409,8 @@ void perf_tool__fill_defaults(struct perf_tool *tool)
                tool->stat = process_stat_stub;
        if (tool->stat_round == NULL)
                tool->stat_round = process_stat_round_stub;
+       if (tool->time_conv == NULL)
+               tool->time_conv = process_event_op2_stub;
 }
 
 static void swap_sample_id_all(union perf_event *event, void *data)
@@ -820,6 +796,7 @@ static perf_event__swap_op perf_event__swap_ops[] = {
        [PERF_RECORD_STAT]                = perf_event__stat_swap,
        [PERF_RECORD_STAT_ROUND]          = perf_event__stat_round_swap,
        [PERF_RECORD_EVENT_UPDATE]        = perf_event__event_update_swap,
+       [PERF_RECORD_TIME_CONV]           = perf_event__all64_swap,
        [PERF_RECORD_HEADER_MAX]          = NULL,
 };
 
@@ -1133,12 +1110,11 @@ static struct machine *machines__find_for_cpumode(struct machines *machines,
                                               union perf_event *event,
                                               struct perf_sample *sample)
 {
-       const u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
        struct machine *machine;
 
        if (perf_guest &&
-           ((cpumode == PERF_RECORD_MISC_GUEST_KERNEL) ||
-            (cpumode == PERF_RECORD_MISC_GUEST_USER))) {
+           ((sample->cpumode == PERF_RECORD_MISC_GUEST_KERNEL) ||
+            (sample->cpumode == PERF_RECORD_MISC_GUEST_USER))) {
                u32 pid;
 
                if (event->header.type == PERF_RECORD_MMAP
@@ -1368,6 +1344,9 @@ static s64 perf_session__process_user_event(struct perf_session *session,
                return tool->stat(tool, event, session);
        case PERF_RECORD_STAT_ROUND:
                return tool->stat_round(tool, event, session);
+       case PERF_RECORD_TIME_CONV:
+               session->time_conv = event->time_conv;
+               return tool->time_conv(tool, event, session);
        default:
                return -EINVAL;
        }
@@ -1975,8 +1954,9 @@ struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session,
 }
 
 void perf_evsel__print_ip(struct perf_evsel *evsel, struct perf_sample *sample,
-                         struct addr_location *al,
-                         unsigned int print_opts, unsigned int stack_depth)
+                         struct addr_location *al, int left_alignment,
+                         unsigned int print_opts, unsigned int stack_depth,
+                         FILE *fp)
 {
        struct callchain_cursor_node *node;
        int print_ip = print_opts & PRINT_IP_OPT_IP;
@@ -2012,34 +1992,38 @@ void perf_evsel__print_ip(struct perf_evsel *evsel, struct perf_sample *sample,
                        if (node->sym && node->sym->ignore)
                                goto next;
 
+                       fprintf(fp, "%-*.*s", left_alignment, left_alignment, " ");
+
                        if (print_ip)
-                               printf("%c%16" PRIx64, s, node->ip);
+                               fprintf(fp, "%c%16" PRIx64, s, node->ip);
 
                        if (node->map)
                                addr = node->map->map_ip(node->map, node->ip);
 
                        if (print_sym) {
-                               printf(" ");
+                               fprintf(fp, " ");
                                if (print_symoffset) {
                                        node_al.addr = addr;
                                        node_al.map  = node->map;
-                                       symbol__fprintf_symname_offs(node->sym, &node_al, stdout);
+                                       symbol__fprintf_symname_offs(node->sym,
+                                                                    &node_al,
+                                                                    fp);
                                } else
-                                       symbol__fprintf_symname(node->sym, stdout);
+                                       symbol__fprintf_symname(node->sym, fp);
                        }
 
                        if (print_dso) {
-                               printf(" (");
-                               map__fprintf_dsoname(node->map, stdout);
-                               printf(")");
+                               fprintf(fp, " (");
+                               map__fprintf_dsoname(node->map, fp);
+                               fprintf(fp, ")");
                        }
 
                        if (print_srcline)
                                map__fprintf_srcline(node->map, addr, "\n  ",
-                                                    stdout);
+                                                    fp);
 
                        if (!print_oneline)
-                               printf("\n");
+                               fprintf(fp, "\n");
 
                        stack_depth--;
 next:
@@ -2050,26 +2034,28 @@ next:
                if (al->sym && al->sym->ignore)
                        return;
 
+               fprintf(fp, "%-*.*s", left_alignment, left_alignment, " ");
+
                if (print_ip)
-                       printf("%16" PRIx64, sample->ip);
+                       fprintf(fp, "%16" PRIx64, sample->ip);
 
                if (print_sym) {
-                       printf(" ");
+                       fprintf(fp, " ");
                        if (print_symoffset)
                                symbol__fprintf_symname_offs(al->sym, al,
-                                                            stdout);
+                                                            fp);
                        else
-                               symbol__fprintf_symname(al->sym, stdout);
+                               symbol__fprintf_symname(al->sym, fp);
                }
 
                if (print_dso) {
-                       printf(" (");
-                       map__fprintf_dsoname(al->map, stdout);
-                       printf(")");
+                       fprintf(fp, " (");
+                       map__fprintf_dsoname(al->map, fp);
+                       fprintf(fp, ")");
                }
 
                if (print_srcline)
-                       map__fprintf_srcline(al->map, al->addr, "\n  ", stdout);
+                       map__fprintf_srcline(al->map, al->addr, "\n  ", fp);
        }
 }
 
This page took 0.030046 seconds and 5 git commands to generate.