/* called with note_lock held */
static void oprof_output_map(ulong addr, ulong len, ulong offset,
			     struct file * file, int is_execve)
{
	struct op_note note;

	/* don't bother with /dev/zero mappings etc. */
	if (!len)
		return;

	note.pid = current->pid;
	note.tgid = op_get_tgid();
	note.addr = addr;
	note.len = len;
	note.offset = offset;
	note.type = is_execve ? OP_EXEC : OP_MAP;
	note.hash = hash_path(file);
	if (note.hash == -1)
		return;
	/* holding note lock */
	__oprof_put_note(&note);
}
Exemple #2
0
/*
 * Returns the basename of $path if it matches any of the $words,
 * otherwise returns NULL.  For low number of words this method
 * was found faster than using a GHashTable: (135450000 iterations)
 *
 * match_words():	14.780s
 * GHashTable:		23.178s
 */
static char const *match_words(struct word_st const *words, char const *path)
{
	struct word_st iword;

	if (!words)
		return 0;

	hash_path(&iword, path);
	do
	{
		if (iword.hash != words->hash)
			continue;
		else if (iword.length != words->length)
			continue;
		else if (memcmp(iword.word, words->word, iword.length))
			continue;
		else
			return iword.word;
	} while ((words = words->next) != NULL);

	return NULL;
} /* match_words */
Exemple #3
0
/**
 * Small procedure to create a basic conjunctive query tree from a tokenised path.
 *
 * @param str  Incoming path token.
 * @param data A qelem** in disguise that should be updated.
 * @return Always zero.
 */
static int _path_to_query_proc(const char *str, unsigned long data) {
  DEBUG("str: \"%s\"", str);
  qelem *newnode=NULL;
  qelem **qroot=(qelem**)data;
  int is_tag = get_tag(str);
  unsigned long path_hash = hash_path(str);
  int is_file = have_file_by_hash(path_hash);

  if (is_tag) {
    tdata dblock;
    if (tree_read(is_tag, (tblock*)&dblock)) {
      PMSG(LOG_ERR, "I/O error reading block\n");
      qtree_free(qroot, 1);
      return -EIO;
    }
    if (dblock.flags & DATA_FLAGS_NOSUB) {
      newnode=_qtree_make_is_nosub(str);
    } else {
      newnode=_qtree_make_is(str);
    }

  } else if (is_file) {
    newnode=_qtree_make_is_inode(path_hash);

  } else {
    DEBUG("Tag \"%s\" does not exist");
    qtree_free(qroot, 1);
    return -ENOENT;
  }

  if (*qroot) {
    *qroot=_qtree_make_and(newnode, *qroot);
  } else {
    *qroot=newnode;
  }
  return 0;
}