Merge branch 'cando' into for-linus
[linux-2.6-microblaze.git] / tools / perf / util / event.c
index 23d5dfd..50771b5 100644 (file)
@@ -7,6 +7,23 @@
 #include "strlist.h"
 #include "thread.h"
 
+const char *event__name[] = {
+       [0]                      = "TOTAL",
+       [PERF_RECORD_MMAP]       = "MMAP",
+       [PERF_RECORD_LOST]       = "LOST",
+       [PERF_RECORD_COMM]       = "COMM",
+       [PERF_RECORD_EXIT]       = "EXIT",
+       [PERF_RECORD_THROTTLE]   = "THROTTLE",
+       [PERF_RECORD_UNTHROTTLE] = "UNTHROTTLE",
+       [PERF_RECORD_FORK]       = "FORK",
+       [PERF_RECORD_READ]       = "READ",
+       [PERF_RECORD_SAMPLE]     = "SAMPLE",
+       [PERF_RECORD_HEADER_ATTR]        = "ATTR",
+       [PERF_RECORD_HEADER_EVENT_TYPE]  = "EVENT_TYPE",
+       [PERF_RECORD_HEADER_TRACING_DATA]        = "TRACING_DATA",
+       [PERF_RECORD_HEADER_BUILD_ID]    = "BUILD_ID",
+};
+
 static pid_t event__synthesize_comm(pid_t pid, int full,
                                    event__handler_t process,
                                    struct perf_session *session)
@@ -368,7 +385,7 @@ int event__process_comm(event_t *self, struct perf_session *session)
 int event__process_lost(event_t *self, struct perf_session *session)
 {
        dump_printf(": id:%Ld: lost:%Ld\n", self->lost.id, self->lost.lost);
-       session->events_stats.lost += self->lost.lost;
+       session->hists.stats.total_lost += self->lost.lost;
        return 0;
 }
 
@@ -493,8 +510,10 @@ int event__process_mmap(event_t *self, struct perf_session *session)
                return 0;
        }
 
-       thread = perf_session__findnew(session, self->mmap.pid);
        machine = perf_session__find_host_machine(session);
+       if (machine == NULL)
+               goto out_problem;
+       thread = perf_session__findnew(session, self->mmap.pid);
        map = map__new(&machine->user_dsos, self->mmap.start,
                        self->mmap.len, self->mmap.pgoff,
                        self->mmap.pid, self->mmap.filename,
@@ -552,6 +571,10 @@ void thread__find_addr_map(struct thread *self,
        if (cpumode == PERF_RECORD_MISC_KERNEL && perf_host) {
                al->level = 'k';
                machine = perf_session__find_host_machine(session);
+               if (machine == NULL) {
+                       al->map = NULL;
+                       return;
+               }
                mg = &machine->kmaps;
        } else if (cpumode == PERF_RECORD_MISC_USER && perf_host) {
                al->level = '.';
@@ -559,7 +582,7 @@ void thread__find_addr_map(struct thread *self,
        } else if (cpumode == PERF_RECORD_MISC_GUEST_KERNEL && perf_guest) {
                al->level = 'g';
                machine = perf_session__find_machine(session, pid);
-               if (!machine) {
+               if (machine == NULL) {
                        al->map = NULL;
                        return;
                }
@@ -650,6 +673,16 @@ int event__preprocess_sample(const event_t *self, struct perf_session *session,
                goto out_filtered;
 
        dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid);
+       /*
+        * Have we already created the kernel maps for the host machine?
+        *
+        * This should have happened earlier, when we processed the kernel MMAP
+        * events, but for older perf.data files there was no such thing, so do
+        * it now.
+        */
+       if (cpumode == PERF_RECORD_MISC_KERNEL &&
+           session->host_machine.vmlinux_maps[MAP__FUNCTION] == NULL)
+               machine__create_kernel_maps(&session->host_machine);
 
        thread__find_addr_map(thread, session, cpumode, MAP__FUNCTION,
                              self->ip.pid, self->ip.ip, al);
@@ -676,6 +709,13 @@ int event__preprocess_sample(const event_t *self, struct perf_session *session,
                        dso__calc_col_width(al->map->dso);
 
                al->sym = map__find_symbol(al->map, al->addr, filter);
+       } else {
+               const unsigned int unresolved_col_width = BITS_PER_LONG / 4;
+
+               if (dsos__col_width < unresolved_col_width &&
+                   !symbol_conf.col_width_list_str && !symbol_conf.field_sep &&
+                   !symbol_conf.dso_list)
+                       dsos__col_width = unresolved_col_width;
        }
 
        if (symbol_conf.sym_list && al->sym &&