Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b283d2f3 authored by Ingo Molnar's avatar Ingo Molnar
Browse files

Merge tag 'perf-core-for-mingo' of...

Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux

 into perf/core

Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:

Fixes:

  * Fix inverted error verification bug in thread__fork, from David Ahern.

New features:

  * Shell completion for 'perf kvm', from Ramkumar Ramachandra.

Refactorings:

  * Get rid of panic() like calls in libtraceevent, from Namyung Kim.

  * Start carving out symbol parsing routines from perf, just moving routines to
    topic files in tools/lib/symbol/, tools that want to use it need to integrate
    it directly, i.e. no tools/lib/symbol/Makefile is provided.

  * Assorted refactoring patches, moving code around and adding
    utility evlist methods that will be used in the IPT patchset,
    from Adrian Hunter.

Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parents fe361cfc 41e12e58
Loading
Loading
Loading
Loading
+58 −0
Original line number Diff line number Diff line
#include "symbol/kallsyms.h"
#include <stdio.h>
#include <stdlib.h>

int kallsyms__parse(const char *filename, void *arg,
		    int (*process_symbol)(void *arg, const char *name,
					  char type, u64 start))
{
	char *line = NULL;
	size_t n;
	int err = -1;
	FILE *file = fopen(filename, "r");

	if (file == NULL)
		goto out_failure;

	err = 0;

	while (!feof(file)) {
		u64 start;
		int line_len, len;
		char symbol_type;
		char *symbol_name;

		line_len = getline(&line, &n, file);
		if (line_len < 0 || !line)
			break;

		line[--line_len] = '\0'; /* \n */

		len = hex2u64(line, &start);

		len++;
		if (len + 2 >= line_len)
			continue;

		symbol_type = line[len];
		len += 2;
		symbol_name = line + len;
		len = line_len - len;

		if (len >= KSYM_NAME_LEN) {
			err = -1;
			break;
		}

		err = process_symbol(arg, symbol_name, symbol_type, start);
		if (err)
			break;
	}

	free(line);
	fclose(file);
	return err;

out_failure:
	return -1;
}
+24 −0
Original line number Diff line number Diff line
#ifndef __TOOLS_KALLSYMS_H_
#define __TOOLS_KALLSYMS_H_ 1

#include <elf.h>
#include <linux/ctype.h>
#include <linux/types.h>

#ifndef KSYM_NAME_LEN
#define KSYM_NAME_LEN 256
#endif

static inline u8 kallsyms2elf_type(char type)
{
	if (type == 'W')
		return STB_WEAK;

	return isupper(type) ? STB_GLOBAL : STB_LOCAL;
}

int kallsyms__parse(const char *filename, void *arg,
		    int (*process_symbol)(void *arg, const char *name,
					  char type, u64 start));

#endif /* __TOOLS_KALLSYMS_H_ */
+33 −10
Original line number Diff line number Diff line
@@ -356,12 +356,35 @@ enum pevent_flag {
	_PE(READ_FORMAT_FAILED,	"failed to read event format"),		      \
	_PE(READ_PRINT_FAILED,	"failed to read event print fmt"), 	      \
	_PE(OLD_FTRACE_ARG_FAILED,"failed to allocate field name for ftrace"),\
	_PE(INVALID_ARG_TYPE,	"invalid argument type")
	_PE(INVALID_ARG_TYPE,	"invalid argument type"),		      \
	_PE(INVALID_EXP_TYPE,	"invalid expression type"),		      \
	_PE(INVALID_OP_TYPE,	"invalid operator type"),		      \
	_PE(INVALID_EVENT_NAME,	"invalid event name"),			      \
	_PE(EVENT_NOT_FOUND,	"no event found"),			      \
	_PE(SYNTAX_ERROR,	"syntax error"),			      \
	_PE(ILLEGAL_RVALUE,	"illegal rvalue"),			      \
	_PE(ILLEGAL_LVALUE,	"illegal lvalue for string comparison"),      \
	_PE(INVALID_REGEX,	"regex did not compute"),		      \
	_PE(ILLEGAL_STRING_CMP,	"illegal comparison for string"), 	      \
	_PE(ILLEGAL_INTEGER_CMP,"illegal comparison for integer"), 	      \
	_PE(REPARENT_NOT_OP,	"cannot reparent other than OP"),	      \
	_PE(REPARENT_FAILED,	"failed to reparent filter OP"),	      \
	_PE(BAD_FILTER_ARG,	"bad arg in filter tree"),		      \
	_PE(UNEXPECTED_TYPE,	"unexpected type (not a value)"),	      \
	_PE(ILLEGAL_TOKEN,	"illegal token"),			      \
	_PE(INVALID_PAREN,	"open parenthesis cannot come here"), 	      \
	_PE(UNBALANCED_PAREN,	"unbalanced number of parenthesis"),	      \
	_PE(UNKNOWN_TOKEN,	"unknown token"),			      \
	_PE(FILTER_NOT_FOUND,	"no filter found"),			      \
	_PE(NOT_A_NUMBER,	"must have number field"),		      \
	_PE(NO_FILTER,		"no filters exists"),			      \
	_PE(FILTER_MISS,	"record does not match to filter")

#undef _PE
#define _PE(__code, __str) PEVENT_ERRNO__ ## __code
enum pevent_errno {
	PEVENT_ERRNO__SUCCESS			= 0,
	PEVENT_ERRNO__FILTER_MATCH		= PEVENT_ERRNO__SUCCESS,

	/*
	 * Choose an arbitrary negative big number not to clash with standard
@@ -836,10 +859,11 @@ struct event_filter {

struct event_filter *pevent_filter_alloc(struct pevent *pevent);

#define FILTER_NONE		-2
#define FILTER_NOEXIST		-1
#define FILTER_MISS		0
#define FILTER_MATCH		1
/* for backward compatibility */
#define FILTER_NONE		PEVENT_ERRNO__FILTER_NOT_FOUND
#define FILTER_NOEXIST		PEVENT_ERRNO__NO_FILTER
#define FILTER_MISS		PEVENT_ERRNO__FILTER_MISS
#define FILTER_MATCH		PEVENT_ERRNO__FILTER_MATCH

enum filter_trivial_type {
	FILTER_TRIVIAL_FALSE,
@@ -847,12 +871,11 @@ enum filter_trivial_type {
	FILTER_TRIVIAL_BOTH,
};

int pevent_filter_add_filter_str(struct event_filter *filter,
				 const char *filter_str,
				 char **error_str);
enum pevent_errno pevent_filter_add_filter_str(struct event_filter *filter,
					       const char *filter_str);


int pevent_filter_match(struct event_filter *filter,
enum pevent_errno pevent_filter_match(struct event_filter *filter,
				      struct pevent_record *record);

int pevent_event_filtered(struct event_filter *filter,
+312 −195

File changed.

Preview size limit exceeded, changes collapsed.

+2 −0
Original line number Diff line number Diff line
@@ -2,6 +2,8 @@ tools/perf
tools/scripts
tools/lib/traceevent
tools/lib/lk
tools/lib/symbol/kallsyms.c
tools/lib/symbol/kallsyms.h
include/linux/const.h
include/linux/perf_event.h
include/linux/rbtree.h
Loading