Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
event-parse.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <ctype.h>
#include <errno.h>
#include <stdint.h>
#include <limits.h>
#include "event-parse.h"
#include "event-utils.h"

Go to the source code of this file.

Data Structures

struct  event_handler
 
struct  pevent_func_params
 
struct  pevent_function_handler
 
struct  cmdline
 
struct  cmdline_list
 
struct  func_map
 
struct  func_list
 
struct  printk_map
 
struct  printk_list
 
struct  flag
 

Macros

#define do_warning(fmt,...)
 
#define PRINT_ARGS   0
 

Functions

const charpevent_get_input_buf (void)
 
unsigned long long pevent_get_input_buf_ptr (void)
 
void pevent_buffer_init (const char *buf, unsigned long long size)
 
void breakpoint (void)
 
struct print_argalloc_arg (void)
 
int pevent_pid_is_registered (struct pevent *pevent, int pid)
 
int pevent_register_comm (struct pevent *pevent, const char *comm, int pid)
 
const charpevent_find_function (struct pevent *pevent, unsigned long long addr)
 
unsigned long long pevent_find_function_address (struct pevent *pevent, unsigned long long addr)
 
int pevent_register_function (struct pevent *pevent, char *func, unsigned long long addr, char *mod)
 
void pevent_print_funcs (struct pevent *pevent)
 
int pevent_register_print_string (struct pevent *pevent, char *fmt, unsigned long long addr)
 
void pevent_print_printk (struct pevent *pevent)
 
int pevent_peek_char (void)
 
enum event_type pevent_read_token (char **tok)
 
void pevent_free_token (char *token)
 
: The name of the field

pevent_print_num_field - print a field and a format : The seq to print to : The printf format to print the field with. : the event that the field is for

: The record with the field name. : print default error if failed.

Returns: 0 on success, -1 field not found, or 1 if buffer is full.

voidpevent_get_field_raw (struct trace_seq *s, struct event_format *event, const char *name, struct pevent_record *record, int *len, int err)
 
int pevent_get_field_val (struct trace_seq *s, struct event_format *event, const char *name, struct pevent_record *record, unsigned long long *val, int err)
 
int pevent_get_common_field_val (struct trace_seq *s, struct event_format *event, const char *name, struct pevent_record *record, unsigned long long *val, int err)
 
int pevent_get_any_field_val (struct trace_seq *s, struct event_format *event, const char *name, struct pevent_record *record, unsigned long long *val, int err)
 
int pevent_print_num_field (struct trace_seq *s, const char *fmt, struct event_format *event, const char *name, struct pevent_record *record, int err)
 
.

This searchs the common field names first, then the non-common ones if a common one was not found.

struct format_fieldpevent_find_common_field (struct event_format *event, const char *name)
 
struct format_fieldpevent_find_field (struct event_format *event, const char *name)
 
struct format_fieldpevent_find_any_field (struct event_format *event, const char *name)
 
unsigned long long pevent_read_number (struct pevent *pevent, const void *ptr, int size)
 
int pevent_read_number_field (struct format_field *field, const void *data, unsigned long long *value)
 
struct event_formatpevent_find_event (struct pevent *pevent, int id)
 
: the name of the helper function

pevent_register_print_function - register a helper function : the handle to the pevent : the function to process the helper function : the return type of the helper function

: A list of enum pevent_func_arg_type

Some events may have helper functions in the print format arguments. This allows a plugin to dynamically create a way to process one of these functions.

The is a variable list of pevent_func_arg_type enums that must end with PEVENT_FUNC_ARG_VOID.

int pevent_register_print_function (struct pevent *pevent, pevent_func_handler func, enum pevent_func_arg_type ret_type, char *name,...)
 
int pevent_register_event_handler (struct pevent *pevent, int id, char *sys_name, char *event_name, pevent_event_handler_func func, void *context)
 
struct peventpevent_alloc (void)
 
void pevent_ref (struct pevent *pevent)
 
void pevent_free_format (struct event_format *event)
 
void pevent_free (struct pevent *pevent)
 
void pevent_unref (struct pevent *pevent)
 

is returned.

#define _PE(code, str)   str
 
struct event_formatpevent_find_event_by_name (struct pevent *pevent, const char *sys, const char *name)
 
void pevent_data_lat_fmt (struct pevent *pevent, struct trace_seq *s, struct pevent_record *record)
 
int pevent_data_type (struct pevent *pevent, struct pevent_record *rec)
 
struct event_formatpevent_data_event_from_type (struct pevent *pevent, int type)
 
int pevent_data_pid (struct pevent *pevent, struct pevent_record *rec)
 
const charpevent_data_comm_from_pid (struct pevent *pevent, int pid)
 
void pevent_event_info (struct trace_seq *s, struct event_format *event, struct pevent_record *record)
 
void pevent_print_event (struct pevent *pevent, struct trace_seq *s, struct pevent_record *record)
 
struct event_format ** pevent_list_events (struct pevent *pevent, enum event_sort_type sort_type)
 
struct format_field ** pevent_event_common_fields (struct event_format *event)
 
struct format_field ** pevent_event_fields (struct event_format *event)
 
int pevent_parse_header_page (struct pevent *pevent, char *buf, unsigned long size, int long_size)
 
enum pevent_errno __pevent_parse_format (struct event_format **eventp, struct pevent *pevent, const char *buf, unsigned long size, const char *sys)
 
enum pevent_errno pevent_parse_format (struct event_format **eventp, const char *buf, unsigned long size, const char *sys)
 
enum pevent_errno pevent_parse_event (struct pevent *pevent, const char *buf, unsigned long size, const char *sys)
 
int pevent_strerror (struct pevent *pevent, enum pevent_errno errnum, char *buf, size_t buflen)
 
int get_field_val (struct trace_seq *s, struct format_field *field, const char *name, struct pevent_record *record, unsigned long long *val, int err)
 

Macro Definition Documentation

#define _PE (   code,
  str 
)    str

Definition at line 5067 of file event-parse.c.

#define do_warning (   fmt,
  ... 
)
Value:
do { \
if (show_warning) \
warning(fmt, ##__VA_ARGS__); \
} while (0)

Definition at line 48 of file event-parse.c.

#define PRINT_ARGS   0

Function Documentation

enum pevent_errno __pevent_parse_format ( struct event_format **  eventp,
struct pevent pevent,
const char buf,
unsigned long  size,
const char sys 
)

__pevent_parse_format - parse the event format : the buffer storing the event format string : the size of : the system the event belongs to

This parses the event format and creates an event structure to quickly parse raw data for a given event.

These files currently come from:

/sys/kernel/debug/tracing/events/.../.../format

Definition at line 4901 of file event-parse.c.

struct print_arg* alloc_arg ( void  )
read

Definition at line 119 of file event-parse.c.

void breakpoint ( void  )

Definition at line 113 of file event-parse.c.

int get_field_val ( struct trace_seq s,
struct format_field field,
const char name,
struct pevent_record record,
unsigned long long val,
int  err 
)

Definition at line 5114 of file event-parse.c.

struct pevent* pevent_alloc ( void  )
read

pevent_alloc - create a pevent handle

Definition at line 5478 of file event-parse.c.

void pevent_buffer_init ( const char buf,
unsigned long long  size 
)

pevent_buffer_init - init buffer for parsing : buffer to parse : the size of the buffer

For use with pevent_read_token(), this initializes the internal buffer that pevent_read_token() will parse.

Definition at line 108 of file event-parse.c.

const char* pevent_data_comm_from_pid ( struct pevent pevent,
int  pid 
)

pevent_data_comm_from_pid - return the command line from PID : a handle to the pevent : the PID of the task to search for

This returns a pointer to the command line that has the given .

Definition at line 4371 of file event-parse.c.

struct event_format* pevent_data_event_from_type ( struct pevent pevent,
int  type 
)
read

pevent_data_event_from_type - find the event by a given type : a handle to the pevent : the type of the event.

This returns the event form a given ;

Definition at line 4346 of file event-parse.c.

void pevent_data_lat_fmt ( struct pevent pevent,
struct trace_seq s,
struct pevent_record record 
)

pevent_data_lat_fmt - parse the data for the latency format : a handle to the pevent : the trace_seq to write to : the record to read from

This parses out the Latency format (interrupts disabled, need rescheduling, in hard/soft interrupt, preempt count and lock depth) and places it into the trace_seq.

Definition at line 4254 of file event-parse.c.

int pevent_data_pid ( struct pevent pevent,
struct pevent_record rec 
)

pevent_data_pid - parse the PID from raw data : a handle to the pevent : the record to parse

This returns the PID from a raw data.

Definition at line 4358 of file event-parse.c.

int pevent_data_type ( struct pevent pevent,
struct pevent_record rec 
)

pevent_data_type - parse out the given event type : a handle to the pevent : the record to read from

This returns the event id from the .

Definition at line 4334 of file event-parse.c.

struct format_field** pevent_event_common_fields ( struct event_format event)
read

pevent_event_common_fields - return a list of common fields for an event : the event to return the common fields of.

Returns an allocated array of fields. The last item in the array is NULL. The array must be freed with free().

Definition at line 4600 of file event-parse.c.

struct format_field** pevent_event_fields ( struct event_format event)
read

pevent_event_fields - return a list of event specific fields for an event : the event to return the fields of.

Returns an allocated array of fields. The last item in the array is NULL. The array must be freed with free().

Definition at line 4614 of file event-parse.c.

void pevent_event_info ( struct trace_seq s,
struct event_format event,
struct pevent_record record 
)

pevent_data_comm_from_pid - parse the data into the print format : the trace_seq to write to : the handle to the event : the record to read from

This parses the raw using the given information and writes the print format into the trace_seq.

Definition at line 4388 of file event-parse.c.

struct format_field* pevent_find_any_field ( struct event_format event,
const char name 
)
read

Definition at line 2976 of file event-parse.c.

struct format_field* pevent_find_common_field ( struct event_format event,
const char name 
)
read

Definition at line 2931 of file event-parse.c.

struct event_format* pevent_find_event ( struct pevent pevent,
int  id 
)
read

pevent_find_event - find an event by given id : a handle to the pevent : the id of the event

Returns an event that has a given .

Definition at line 3132 of file event-parse.c.

struct event_format* pevent_find_event_by_name ( struct pevent pevent,
const char sys,
const char name 
)
read

Definition at line 3165 of file event-parse.c.

struct format_field* pevent_find_field ( struct event_format event,
const char name 
)
read

Definition at line 2953 of file event-parse.c.

const char* pevent_find_function ( struct pevent pevent,
unsigned long long  addr 
)

pevent_find_function - find a function by a given address : handle for the pevent : the address to find the function with

Returns a pointer to the function stored that has the given address. Note, the address does not have to be exact, it will select the function that would contain the address.

Definition at line 421 of file event-parse.c.

unsigned long long pevent_find_function_address ( struct pevent pevent,
unsigned long long  addr 
)

pevent_find_function_address - find a function address by a given address : handle for the pevent : the address to find the function with

Returns the address the function starts at. This can be used in conjunction with pevent_find_function to print both the function name and the function offset.

Definition at line 442 of file event-parse.c.

void pevent_free ( struct pevent pevent)

pevent_free - free a pevent handle : the pevent handle to free

Definition at line 5529 of file event-parse.c.

void pevent_free_format ( struct event_format event)

Definition at line 5512 of file event-parse.c.

void pevent_free_token ( char token)

pevent_free_token - free a token returned by pevent_read_token : the token to free

Definition at line 1062 of file event-parse.c.

int pevent_get_any_field_val ( struct trace_seq s,
struct event_format event,
const char name,
struct pevent_record record,
unsigned long long val,
int  err 
)

Definition at line 5244 of file event-parse.c.

int pevent_get_common_field_val ( struct trace_seq s,
struct event_format event,
const char name,
struct pevent_record record,
unsigned long long val,
int  err 
)

Definition at line 5219 of file event-parse.c.

void* pevent_get_field_raw ( struct trace_seq s,
struct event_format event,
const char name,
struct pevent_record record,
int len,
int  err 
)

Definition at line 5147 of file event-parse.c.

int pevent_get_field_val ( struct trace_seq s,
struct event_format event,
const char name,
struct pevent_record record,
unsigned long long val,
int  err 
)

Definition at line 5194 of file event-parse.c.

const char* pevent_get_input_buf ( void  )

Definition at line 61 of file event-parse.c.

unsigned long long pevent_get_input_buf_ptr ( void  )

Definition at line 66 of file event-parse.c.

struct event_format** pevent_list_events ( struct pevent pevent,
enum event_sort_type  sort_type 
)
read

Definition at line 4515 of file event-parse.c.

enum pevent_errno pevent_parse_event ( struct pevent pevent,
const char buf,
unsigned long  size,
const char sys 
)

pevent_parse_event - parse the event format : the handle to the pevent : the buffer storing the event format string : the size of : the system the event belongs to

This parses the event format and creates an event structure to quickly parse raw data for a given event.

These files currently come from:

/sys/kernel/debug/tracing/events/.../.../format

Definition at line 5041 of file event-parse.c.

enum pevent_errno pevent_parse_format ( struct event_format **  eventp,
const char buf,
unsigned long  size,
const char sys 
)

pevent_parse_format - parse the event format : the buffer storing the event format string : the size of : the system the event belongs to

This parses the event format and creates an event structure to quickly parse raw data for a given event.

These files currently come from:

/sys/kernel/debug/tracing/events/.../.../format

Definition at line 5021 of file event-parse.c.

int pevent_parse_header_page ( struct pevent pevent,
char buf,
unsigned long  size,
int  long_size 
)

pevent_parse_header_page - parse the data stored in the header page : the handle to the pevent : the buffer storing the header page format string : the size of : the long size to use if there is no header

This parses the header page format for information on the ring buffer used. The should be copied from

/sys/kernel/debug/tracing/events/header_page

Definition at line 4807 of file event-parse.c.

int pevent_peek_char ( void  )

pevent_peek_char - peek at the next character that will be read

Returns the next character read, or -1 if end of buffer.

Definition at line 805 of file event-parse.c.

int pevent_pid_is_registered ( struct pevent pevent,
int  pid 
)

pevent_pid_is_registered - return if a pid has a cmdline registered : handle for the pevent : The pid to check if it has a cmdline registered with.

Returns 1 if the pid has a cmdline mapped to it 0 otherwise.

Definition at line 206 of file event-parse.c.

void pevent_print_event ( struct pevent pevent,
struct trace_seq s,
struct pevent_record record 
)

Definition at line 4408 of file event-parse.c.

void pevent_print_funcs ( struct pevent pevent)

pevent_print_funcs - print out the stored functions : handle for the pevent

This prints out the stored functions.

Definition at line 504 of file event-parse.c.

int pevent_print_num_field ( struct trace_seq s,
const char fmt,
struct event_format event,
const char name,
struct pevent_record record,
int  err 
)

Definition at line 5269 of file event-parse.c.

void pevent_print_printk ( struct pevent pevent)

pevent_print_printk - print out the stored strings : handle for the pevent

This prints the string formats that were stored.

Definition at line 635 of file event-parse.c.

unsigned long long pevent_read_number ( struct pevent pevent,
const void ptr,
int  size 
)

pevent_read_number - read a number from data : handle for the pevent : the raw data : the size of the data that holds the number

Returns the number (converted to host) from the raw data.

Definition at line 2995 of file event-parse.c.

int pevent_read_number_field ( struct format_field field,
const void data,
unsigned long long value 
)

pevent_read_number_field - read a number from data : a handle to the field : the raw data to read : the value to place the number in

Reads raw data according to a field offset and size, and translates it into .

Returns 0 on success, -1 otherwise.

Definition at line 3024 of file event-parse.c.

enum event_type pevent_read_token ( char **  tok)

pevent_read_token - access to utilites to use the pevent parser : The token to return

This will parse tokens from the string given by pevent_init_data().

Returns the token type.

Definition at line 1053 of file event-parse.c.

void pevent_ref ( struct pevent pevent)

Definition at line 5488 of file event-parse.c.

int pevent_register_comm ( struct pevent pevent,
const char comm,
int  pid 
)

pevent_register_comm - register a pid / comm mapping : handle for the pevent : the command line to register : the pid to map the command line to

This adds a mapping to search for command line names with a given pid. The comm is duplicated.

Definition at line 284 of file event-parse.c.

int pevent_register_event_handler ( struct pevent pevent,
int  id,
char sys_name,
char event_name,
pevent_event_handler_func  func,
void context 
)

pevent_register_event_handler - register a way to parse an event : the handle to the pevent : the id of the event to register : the system name the event belongs to : the name of the event : the function to call to parse the event information : the data to be passed to

This function allows a developer to override the parsing of a given event. If for some reason the default print format is not sufficient, this function will register a function for an event to be used to parse the data instead.

If is >= 0, then it is used to find the event. else and are used.

Definition at line 5414 of file event-parse.c.

int pevent_register_function ( struct pevent pevent,
char func,
unsigned long long  addr,
char mod 
)

pevent_register_function - register a function with a given address : handle for the pevent : the function name to register : the address the function starts at : the kernel module the function may be in (NULL for none)

This registers a function name with an address and module. The passed in is duplicated.

Definition at line 463 of file event-parse.c.

int pevent_register_print_function ( struct pevent pevent,
pevent_func_handler  func,
enum pevent_func_arg_type  ret_type,
char name,
  ... 
)

Definition at line 5320 of file event-parse.c.

int pevent_register_print_string ( struct pevent pevent,
char fmt,
unsigned long long  addr 
)

pevent_register_print_string - register a string by its address : handle for the pevent : the string format to register : the address the string was located at

This registers a string by the address it was stored in the kernel. The passed in is duplicated.

Definition at line 603 of file event-parse.c.

int pevent_strerror ( struct pevent pevent,
enum pevent_errno  errnum,
char buf,
size_t  buflen 
)

Definition at line 5073 of file event-parse.c.

void pevent_unref ( struct pevent pevent)

Definition at line 5612 of file event-parse.c.