Ejemplo n.º 1
0
int event__preprocess_sample(const event_t *self, struct perf_session *session,
                             struct addr_location *al, symbol_filter_t filter)
{
    u8 cpumode = self->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
    struct thread *thread = perf_session__findnew(session, self->ip.pid);

    if (thread == NULL)
        return -1;

    if (symbol_conf.comm_list &&
            !strlist__has_entry(symbol_conf.comm_list, thread->comm))
        goto out_filtered;

    dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid);

    thread__find_addr_location(thread, session, cpumode, MAP__FUNCTION,
                               self->ip.ip, al, filter);
    dump_printf(" ...... dso: %s\n",
                al->map ? al->map->dso->long_name :
                al->level == 'H' ? "[hypervisor]" : "<not found>");
    /*
     * We have to do this here as we may have a dso with no symbol hit that
     * has a name longer than the ones with symbols sampled.
     */
    if (al->map && !sort_dso.elide && !al->map->dso->slen_calculated)
        dso__calc_col_width(al->map->dso);

    if (symbol_conf.dso_list &&
            (!al->map || !al->map->dso ||
             !(strlist__has_entry(symbol_conf.dso_list, al->map->dso->short_name) ||
               (al->map->dso->short_name != al->map->dso->long_name &&
                strlist__has_entry(symbol_conf.dso_list, al->map->dso->long_name)))))
        goto out_filtered;

    if (symbol_conf.sym_list && al->sym &&
            !strlist__has_entry(symbol_conf.sym_list, al->sym->name))
        goto out_filtered;

    al->filtered = false;
    return 0;

out_filtered:
    al->filtered = true;
    return 0;
}
Ejemplo n.º 2
0
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)
            dsos__col_width = slen;
    }

    self->slen_calculated = 1;
}
Ejemplo n.º 3
0
static void thread__comm_adjust(struct thread *self, struct hists *hists)
{
	char *comm = self->comm;

	if (!symbol_conf.col_width_list_str && !symbol_conf.field_sep &&
	    (!symbol_conf.comm_list ||
	     strlist__has_entry(symbol_conf.comm_list, comm))) {
		u16 slen = strlen(comm);

		if (hists__new_col_len(hists, HISTC_COMM, slen))
			hists__set_col_len(hists, HISTC_THREAD, slen + 6);
	}
}
Ejemplo n.º 4
0
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))) {
		u16 slen = self->short_name_len;
		if (verbose)
			slen = self->long_name_len;
		if (dsos__col_width < slen)
			dsos__col_width = slen;
	}

	self->slen_calculated = 1;
}
Ejemplo n.º 5
0
static int should_copy_scn(Elf *elf, GElf_Shdr *shdr, struct strlist *scns)
{
	char *name;
	size_t shstrndx;

	if (elf_getshdrstrndx(elf, &shstrndx) < 0)
		return 0;
	name = elf_strptr(elf, shstrndx, shdr->sh_name);
	if (name == NULL)
		return 0;

	if (strlist__has_entry(scns, name))
		return 1;
	return 0;
}
Ejemplo n.º 6
0
static void thread__comm_adjust(struct thread *self)
{
    char *comm = self->comm;

    if (!symbol_conf.col_width_list_str && !symbol_conf.field_sep &&
            (!symbol_conf.comm_list ||
             strlist__has_entry(symbol_conf.comm_list, comm))) {
        unsigned int slen = strlen(comm);

        if (slen > comms__col_width) {
            comms__col_width = slen;
            threads__col_width = slen + 6;
        }
    }
}
Ejemplo n.º 7
0
int sample__fprintf_callchain(struct perf_sample *sample, int left_alignment,
			      unsigned int print_opts, struct callchain_cursor *cursor,
			      FILE *fp)
{
	int printed = 0;
	struct callchain_cursor_node *node;
	int print_ip = print_opts & EVSEL__PRINT_IP;
	int print_sym = print_opts & EVSEL__PRINT_SYM;
	int print_dso = print_opts & EVSEL__PRINT_DSO;
	int print_symoffset = print_opts & EVSEL__PRINT_SYMOFFSET;
	int print_oneline = print_opts & EVSEL__PRINT_ONELINE;
	int print_srcline = print_opts & EVSEL__PRINT_SRCLINE;
	int print_unknown_as_addr = print_opts & EVSEL__PRINT_UNKNOWN_AS_ADDR;
	int print_arrow = print_opts & EVSEL__PRINT_CALLCHAIN_ARROW;
	int print_skip_ignored = print_opts & EVSEL__PRINT_SKIP_IGNORED;
	char s = print_oneline ? ' ' : '\t';
	bool first = true;

	if (sample->callchain) {
		struct addr_location node_al;

		callchain_cursor_commit(cursor);

		while (1) {
			u64 addr = 0;

			node = callchain_cursor_current(cursor);
			if (!node)
				break;

			if (node->sym && node->sym->ignore && print_skip_ignored)
				goto next;

			printed += fprintf(fp, "%-*.*s", left_alignment, left_alignment, " ");

			if (print_arrow && !first)
				printed += fprintf(fp, " <-");

			if (print_ip)
				printed += fprintf(fp, "%c%16" PRIx64, s, node->ip);

			if (node->map)
				addr = node->map->map_ip(node->map, node->ip);

			if (print_sym) {
				printed += fprintf(fp, " ");
				node_al.addr = addr;
				node_al.map  = node->map;

				if (print_symoffset) {
					printed += __symbol__fprintf_symname_offs(node->sym, &node_al,
										  print_unknown_as_addr,
										  true, fp);
				} else {
					printed += __symbol__fprintf_symname(node->sym, &node_al,
									     print_unknown_as_addr, fp);
				}
			}

			if (print_dso && (!node->sym || !node->sym->inlined)) {
				printed += fprintf(fp, " (");
				printed += map__fprintf_dsoname(node->map, fp);
				printed += fprintf(fp, ")");
			}

			if (print_srcline)
				printed += map__fprintf_srcline(node->map, addr, "\n  ", fp);

			if (node->sym && node->sym->inlined)
				printed += fprintf(fp, " (inlined)");

			if (!print_oneline)
				printed += fprintf(fp, "\n");

			/* Add srccode here too? */
			if (symbol_conf.bt_stop_list &&
			    node->sym &&
			    strlist__has_entry(symbol_conf.bt_stop_list,
					       node->sym->name)) {
				break;
			}

			first = false;
next:
			callchain_cursor_advance(cursor);
		}
	}

	return printed;
}
Ejemplo n.º 8
0
int event__preprocess_sample(const event_t *self, struct perf_session *session,
			     struct addr_location *al, symbol_filter_t filter)
{
	u8 cpumode = self->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
	struct thread *thread = perf_session__findnew(session, self->ip.pid);

	if (thread == NULL)
		return -1;

	if (symbol_conf.comm_list &&
	    !strlist__has_entry(symbol_conf.comm_list, thread->comm))
		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);
	dump_printf(" ...... dso: %s\n",
		    al->map ? al->map->dso->long_name :
			al->level == 'H' ? "[hypervisor]" : "<not found>");
	al->sym = NULL;

	if (al->map) {
		if (symbol_conf.dso_list &&
		    (!al->map || !al->map->dso ||
		     !(strlist__has_entry(symbol_conf.dso_list,
					  al->map->dso->short_name) ||
		       (al->map->dso->short_name != al->map->dso->long_name &&
			strlist__has_entry(symbol_conf.dso_list,
					   al->map->dso->long_name)))))
			goto out_filtered;
		/*
		 * We have to do this here as we may have a dso with no symbol
		 * hit that has a name longer than the ones with symbols
		 * sampled.
		 */
		if (!sort_dso.elide && !al->map->dso->slen_calculated)
			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 &&
	    !strlist__has_entry(symbol_conf.sym_list, al->sym->name))
		goto out_filtered;

	return 0;

out_filtered:
	al->filtered = true;
	return 0;
}