Skip to content

Commit

Permalink
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux…
Browse files Browse the repository at this point in the history
…/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: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Ingo Molnar committed Dec 16, 2013
2 parents fe361cf + 41e12e5 commit b283d2f
Show file tree
Hide file tree
Showing 21 changed files with 550 additions and 303 deletions.
58 changes: 58 additions & 0 deletions tools/lib/symbol/kallsyms.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#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 changes: 24 additions & 0 deletions tools/lib/symbol/kallsyms.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#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_ */
43 changes: 33 additions & 10 deletions tools/lib/traceevent/event-parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -836,24 +859,24 @@ 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,
FILTER_TRIVIAL_TRUE,
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,
struct pevent_record *record);
enum pevent_errno pevent_filter_match(struct event_filter *filter,
struct pevent_record *record);

int pevent_event_filtered(struct event_filter *filter,
int event_id);
Expand Down
Loading

0 comments on commit b283d2f

Please sign in to comment.