perf evsel: Allow passing a left alignment when printing a symbol
[deliverable/linux.git] / tools / perf / util / session.c
index 60b3593d210dbc3b52997a693bcc8f9645687f08..62b6d4051b99c1e5c6e9fd4a6061116f9951cc50 100644 (file)
@@ -409,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)
@@ -794,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,
 };
 
@@ -1107,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
@@ -1342,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;
        }
@@ -1949,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;
@@ -1986,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:
@@ -2024,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.038175 seconds and 5 git commands to generate.