perf symbols: Check if a struct machine instance was found
[safe/jmp/linux-2.6] / tools / perf / util / event.c
index 1757b0f..dfc8bf6 100644 (file)
@@ -493,8 +493,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 +554,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 +565,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;
                }
@@ -626,8 +632,10 @@ static void dso__calc_col_width(struct dso *self)
        if (!symbol_conf.col_width_list_str && !symbol_conf.field_sep &&
            (!symbol_conf.dso_list ||
             strlist__has_entry(symbol_conf.dso_list, self->name))) {
-               unsigned int slen = strlen(self->name);
-               if (slen > dsos__col_width)
+               u16 slen = self->short_name_len;
+               if (verbose)
+                       slen = self->long_name_len;
+               if (dsos__col_width < slen)
                        dsos__col_width = slen;
        }
 
@@ -674,6 +682,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 &&
@@ -713,6 +728,7 @@ int event__parse_sample(event_t *event, u64 type, struct sample_data *data)
                array++;
        }
 
+       data->id = -1ULL;
        if (type & PERF_SAMPLE_ID) {
                data->id = *array;
                array++;