]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - tools/perf/builtin-trace.c
perf tools: Merge trace.info content into perf.data
[mirror_ubuntu-zesty-kernel.git] / tools / perf / builtin-trace.c
index 914ab366e369a75142c86207af6cc294416c983b..d9abb4ae5f795fbe40db652643652265b959abae 100644 (file)
@@ -35,14 +35,14 @@ process_comm_event(event_t *event, unsigned long offset, unsigned long head)
 
        thread = threads__findnew(event->comm.pid, &threads, &last_match);
 
-       dump_printf("%p [%p]: PERF_EVENT_COMM: %s:%d\n",
+       dump_printf("%p [%p]: PERF_RECORD_COMM: %s:%d\n",
                (void *)(offset + head),
                (void *)(long)(event->header.size),
                event->comm.comm, event->comm.pid);
 
        if (thread == NULL ||
            thread__set_comm(thread, event->comm.comm)) {
-               dump_printf("problem processing PERF_EVENT_COMM, skipping event.\n");
+               dump_printf("problem processing PERF_RECORD_COMM, skipping event.\n");
                return -1;
        }
        total_comm++;
@@ -53,16 +53,12 @@ process_comm_event(event_t *event, unsigned long offset, unsigned long head)
 static int
 process_sample_event(event_t *event, unsigned long offset, unsigned long head)
 {
-       char level;
-       int show = 0;
-       struct dso *dso = NULL;
        struct thread *thread;
        u64 ip = event->ip.ip;
        u64 timestamp = -1;
        u32 cpu = -1;
        u64 period = 1;
        void *more_data = event->ip.__more_data;
-       int cpumode;
 
        thread = threads__findnew(event->ip.pid, &threads, &last_match);
 
@@ -82,7 +78,7 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head)
                more_data += sizeof(u64);
        }
 
-       dump_printf("%p [%p]: PERF_EVENT_SAMPLE (IP, %d): %d/%d: %p period: %Ld\n",
+       dump_printf("%p [%p]: PERF_RECORD_SAMPLE (IP, %d): %d/%d: %p period: %Ld\n",
                (void *)(offset + head),
                (void *)(long)(event->header.size),
                event->header.misc,
@@ -98,30 +94,6 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head)
                return -1;
        }
 
-       cpumode = event->header.misc & PERF_EVENT_MISC_CPUMODE_MASK;
-
-       if (cpumode == PERF_EVENT_MISC_KERNEL) {
-               show = SHOW_KERNEL;
-               level = 'k';
-
-               dso = kernel_dso;
-
-               dump_printf(" ...... dso: %s\n", dso->name);
-
-       } else if (cpumode == PERF_EVENT_MISC_USER) {
-
-               show = SHOW_USER;
-               level = '.';
-
-       } else {
-               show = SHOW_HV;
-               level = 'H';
-
-               dso = hypervisor_dso;
-
-               dump_printf(" ...... dso: [hypervisor]\n");
-       }
-
        if (sample_type & PERF_SAMPLE_RAW) {
                struct {
                        u32 size;
@@ -146,19 +118,19 @@ process_event(event_t *event, unsigned long offset, unsigned long head)
        trace_event(event);
 
        switch (event->header.type) {
-       case PERF_EVENT_MMAP ... PERF_EVENT_LOST:
+       case PERF_RECORD_MMAP ... PERF_RECORD_LOST:
                return 0;
 
-       case PERF_EVENT_COMM:
+       case PERF_RECORD_COMM:
                return process_comm_event(event, offset, head);
 
-       case PERF_EVENT_EXIT ... PERF_EVENT_READ:
+       case PERF_RECORD_EXIT ... PERF_RECORD_READ:
                return 0;
 
-       case PERF_EVENT_SAMPLE:
+       case PERF_RECORD_SAMPLE:
                return process_sample_event(event, offset, head);
 
-       case PERF_EVENT_MAX:
+       case PERF_RECORD_MAX:
        default:
                return -1;
        }
@@ -171,12 +143,12 @@ static int __cmd_trace(void)
        int ret, rc = EXIT_FAILURE;
        unsigned long offset = 0;
        unsigned long head = 0;
+       unsigned long shift;
        struct stat perf_stat;
        event_t *event;
        uint32_t size;
        char *buf;
 
-       trace_report();
        register_idle_thread(&threads, &last_match);
 
        input = open(input_name, O_RDONLY);
@@ -208,6 +180,10 @@ static int __cmd_trace(void)
                return EXIT_FAILURE;
        }
 
+       shift = page_size * (head / page_size);
+       offset += shift;
+       head -= shift;
+
 remap:
        buf = (char *)mmap(NULL, page_size * mmap_window, PROT_READ,
                           MAP_SHARED, input, offset);
@@ -219,14 +195,10 @@ remap:
 more:
        event = (event_t *)(buf + head);
 
-       size = event->header.size;
-       if (!size)
-               size = 8;
-
        if (head + event->header.size >= page_size * mmap_window) {
-               unsigned long shift = page_size * (head / page_size);
                int res;
 
+               shift = page_size * (head / page_size);
                res = munmap(buf, page_size * mmap_window);
                assert(res == 0);
 
@@ -237,7 +209,6 @@ more:
 
        size = event->header.size;
 
-
        if (!size || process_event(event, offset, head) < 0) {
 
                /*
@@ -290,7 +261,6 @@ int cmd_trace(int argc, const char **argv, const char *prefix __used)
                        usage_with_options(annotate_usage, options);
        }
 
-
        setup_pager();
 
        return __cmd_trace();