Beispiel #1
0
static void init_if_needed() {
  static int is_initialized = 0;
  if (is_initialized) return;

  glGenQueries(num_timer_queries, timer_queries);

  for (int i = 0; i < num_timer_queries; ++i) {
    query_names[i] = NULL;
  }

  checkpoint_times     = map__new(str_hash, str_eq);
  checkpoint_callbacks = map__new(str_hash, str_eq);
  
  is_initialized = 1;
}
Beispiel #2
0
int event__process_mmap(event_t *self)
{
	struct thread *thread = threads__findnew(self->mmap.pid);
	struct map *map = map__new(&self->mmap, MAP__FUNCTION,
				   event__cwd, event__cwdlen);

	dump_printf(" %d/%d: [%p(%p) @ %p]: %s\n",
		    self->mmap.pid, self->mmap.tid,
		    (void *)(long)self->mmap.start,
		    (void *)(long)self->mmap.len,
		    (void *)(long)self->mmap.pgoff,
		    self->mmap.filename);

	if (thread == NULL || map == NULL)
		dump_printf("problem processing PERF_RECORD_MMAP, skipping event.\n");
	else
		thread__insert_map(thread, map);

	return 0;
}
Beispiel #3
0
void gl_timer__add_callback(const char *from, const char *to,
                            gl_timer__Callback cb) {
  assert(from);
  assert(to);
  assert(cb);

  init_if_needed();

  // Retrieve the map (from_name -> callback).
  map__key_value *pair = map__find(checkpoint_callbacks, (void *)to);
  if (pair == NULL) {
    pair = map__set(checkpoint_callbacks,
                    (void *)to, map__new(str_hash, str_eq));
  }
  Map cbs_from_name = (Map)pair->value;

  // We expect that no callback has already be set for this from/to pair.
  assert(map__find(cbs_from_name, (void *)from) == NULL);

  map__set(cbs_from_name, (void *)from, cb);  // Add the new callback.
}
Beispiel #4
0
int event__process_mmap(event_t *self, struct perf_session *session)
{
	struct machine *machine;
	struct thread *thread;
	struct map *map;
	u8 cpumode = self->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
	int ret = 0;

	dump_printf(" %d/%d: [%#Lx(%#Lx) @ %#Lx]: %s\n",
			self->mmap.pid, self->mmap.tid, self->mmap.start,
			self->mmap.len, self->mmap.pgoff, self->mmap.filename);

	if (cpumode == PERF_RECORD_MISC_GUEST_KERNEL ||
	    cpumode == PERF_RECORD_MISC_KERNEL) {
		ret = event__process_kernel_mmap(self, session);
		if (ret < 0)
			goto out_problem;
		return 0;
	}

	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,
			MAP__FUNCTION, session->cwd, session->cwdlen);

	if (thread == NULL || map == NULL)
		goto out_problem;

	thread__insert_map(thread, map);
	return 0;

out_problem:
	dump_printf("problem processing PERF_RECORD_MMAP, skipping event.\n");
	return 0;
}
Beispiel #5
0
int event__process_mmap(event_t *self, struct perf_session *session)
{
    struct thread *thread;
    struct map *map;

    dump_printf(" %d/%d: [%#Lx(%#Lx) @ %#Lx]: %s\n",
                self->mmap.pid, self->mmap.tid, self->mmap.start,
                self->mmap.len, self->mmap.pgoff, self->mmap.filename);

    if (self->mmap.pid == 0) {
        static const char kmmap_prefix[] = "[kernel.kallsyms.";

        if (self->mmap.filename[0] == '/') {
            char short_module_name[1024];
            char *name = strrchr(self->mmap.filename, '/'), *dot;

            if (name == NULL)
                goto out_problem;

            ++name; /* skip / */
            dot = strrchr(name, '.');
            if (dot == NULL)
                goto out_problem;

            snprintf(short_module_name, sizeof(short_module_name),
                     "[%.*s]", (int)(dot - name), name);
            strxfrchar(short_module_name, '-', '_');

            map = perf_session__new_module_map(session,
                                               self->mmap.start,
                                               self->mmap.filename);
            if (map == NULL)
                goto out_problem;

            name = strdup(short_module_name);
            if (name == NULL)
                goto out_problem;

            map->dso->short_name = name;
            map->end = map->start + self->mmap.len;
        } else if (memcmp(self->mmap.filename, kmmap_prefix,
                          sizeof(kmmap_prefix) - 1) == 0) {
            const char *symbol_name = (self->mmap.filename +
                                       sizeof(kmmap_prefix) - 1);
            /*
             * Should be there already, from the build-id table in
             * the header.
             */
            struct dso *kernel = __dsos__findnew(&dsos__kernel,
                                                 "[kernel.kallsyms]");
            if (kernel == NULL)
                goto out_problem;

            kernel->kernel = 1;
            if (__perf_session__create_kernel_maps(session, kernel) < 0)
                goto out_problem;

            session->vmlinux_maps[MAP__FUNCTION]->start = self->mmap.start;
            session->vmlinux_maps[MAP__FUNCTION]->end   = self->mmap.start + self->mmap.len;
            /*
             * Be a bit paranoid here, some perf.data file came with
             * a zero sized synthesized MMAP event for the kernel.
             */
            if (session->vmlinux_maps[MAP__FUNCTION]->end == 0)
                session->vmlinux_maps[MAP__FUNCTION]->end = ~0UL;

            perf_session__set_kallsyms_ref_reloc_sym(session, symbol_name,
                    self->mmap.pgoff);
        }
        return 0;
    }

    thread = perf_session__findnew(session, self->mmap.pid);
    map = map__new(&self->mmap, MAP__FUNCTION,
                   session->cwd, session->cwdlen);

    if (thread == NULL || map == NULL)
        goto out_problem;

    thread__insert_map(thread, map);
    return 0;

out_problem:
    dump_printf("problem processing PERF_RECORD_MMAP, skipping event.\n");
    return 0;
}