tools lib traceevent, perf tools: Split trace-seq related APIs in a separate header file
In order to make libtraceevent into a proper library, all its APIs should be defined in corresponding header files. This patch splits trace-seq related APIs in a separate header file: trace-seq.h Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Link: http://lkml.kernel.org/r/20180828185038.2dcb2743@gandalf.local.home Signed-off-by: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
766e0618e4
commit
266b851cc2
|
@ -24,6 +24,7 @@
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include "event-parse.h"
|
#include "event-parse.h"
|
||||||
#include "event-utils.h"
|
#include "event-utils.h"
|
||||||
|
#include "trace-seq.h"
|
||||||
|
|
||||||
static const char *input_buf;
|
static const char *input_buf;
|
||||||
static unsigned long long input_buf_ptr;
|
static unsigned long long input_buf_ptr;
|
||||||
|
|
|
@ -26,17 +26,12 @@
|
||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "trace-seq.h"
|
||||||
|
|
||||||
#ifndef __maybe_unused
|
#ifndef __maybe_unused
|
||||||
#define __maybe_unused __attribute__((unused))
|
#define __maybe_unused __attribute__((unused))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ----------------------- trace_seq ----------------------- */
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef TRACE_SEQ_BUF_SIZE
|
|
||||||
#define TRACE_SEQ_BUF_SIZE 4096
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef DEBUG_RECORD
|
#ifndef DEBUG_RECORD
|
||||||
#define DEBUG_RECORD 0
|
#define DEBUG_RECORD 0
|
||||||
#endif
|
#endif
|
||||||
|
@ -59,43 +54,6 @@ struct tep_record {
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
enum trace_seq_fail {
|
|
||||||
TRACE_SEQ__GOOD,
|
|
||||||
TRACE_SEQ__BUFFER_POISONED,
|
|
||||||
TRACE_SEQ__MEM_ALLOC_FAILED,
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Trace sequences are used to allow a function to call several other functions
|
|
||||||
* to create a string of data to use (up to a max of PAGE_SIZE).
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct trace_seq {
|
|
||||||
char *buffer;
|
|
||||||
unsigned int buffer_size;
|
|
||||||
unsigned int len;
|
|
||||||
unsigned int readpos;
|
|
||||||
enum trace_seq_fail state;
|
|
||||||
};
|
|
||||||
|
|
||||||
void trace_seq_init(struct trace_seq *s);
|
|
||||||
void trace_seq_reset(struct trace_seq *s);
|
|
||||||
void trace_seq_destroy(struct trace_seq *s);
|
|
||||||
|
|
||||||
extern int trace_seq_printf(struct trace_seq *s, const char *fmt, ...)
|
|
||||||
__attribute__ ((format (printf, 2, 3)));
|
|
||||||
extern int trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args)
|
|
||||||
__attribute__ ((format (printf, 2, 0)));
|
|
||||||
|
|
||||||
extern int trace_seq_puts(struct trace_seq *s, const char *str);
|
|
||||||
extern int trace_seq_putc(struct trace_seq *s, unsigned char c);
|
|
||||||
|
|
||||||
extern void trace_seq_terminate(struct trace_seq *s);
|
|
||||||
|
|
||||||
extern int trace_seq_do_fprintf(struct trace_seq *s, FILE *fp);
|
|
||||||
extern int trace_seq_do_printf(struct trace_seq *s);
|
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------- pevent ----------------------- */
|
/* ----------------------- pevent ----------------------- */
|
||||||
|
|
||||||
struct tep_handle;
|
struct tep_handle;
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include "event-parse.h"
|
#include "event-parse.h"
|
||||||
#include "event-utils.h"
|
#include "event-utils.h"
|
||||||
|
#include "trace-seq.h"
|
||||||
|
|
||||||
#define LOCAL_PLUGIN_DIR ".traceevent/plugins"
|
#define LOCAL_PLUGIN_DIR ".traceevent/plugins"
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#include "event-parse.h"
|
#include "event-parse.h"
|
||||||
#include "event-utils.h"
|
#include "event-utils.h"
|
||||||
|
#include "trace-seq.h"
|
||||||
|
|
||||||
static struct func_stack {
|
static struct func_stack {
|
||||||
int size;
|
int size;
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "event-parse.h"
|
#include "event-parse.h"
|
||||||
|
#include "trace-seq.h"
|
||||||
|
|
||||||
static int timer_expire_handler(struct trace_seq *s,
|
static int timer_expire_handler(struct trace_seq *s,
|
||||||
struct tep_record *record,
|
struct tep_record *record,
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "event-parse.h"
|
#include "event-parse.h"
|
||||||
|
#include "trace-seq.h"
|
||||||
|
|
||||||
#define MINORBITS 20
|
#define MINORBITS 20
|
||||||
#define MINORMASK ((1U << MINORBITS) - 1)
|
#define MINORMASK ((1U << MINORBITS) - 1)
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "event-parse.h"
|
#include "event-parse.h"
|
||||||
|
#include "trace-seq.h"
|
||||||
|
|
||||||
static int call_site_handler(struct trace_seq *s, struct tep_record *record,
|
static int call_site_handler(struct trace_seq *s, struct tep_record *record,
|
||||||
struct event_format *event, void *context)
|
struct event_format *event, void *context)
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "event-parse.h"
|
#include "event-parse.h"
|
||||||
|
#include "trace-seq.h"
|
||||||
|
|
||||||
#ifdef HAVE_UDIS86
|
#ifdef HAVE_UDIS86
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "event-parse.h"
|
#include "event-parse.h"
|
||||||
|
#include "trace-seq.h"
|
||||||
|
|
||||||
#define INDENT 65
|
#define INDENT 65
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "event-parse.h"
|
#include "event-parse.h"
|
||||||
|
#include "trace-seq.h"
|
||||||
|
|
||||||
static void write_state(struct trace_seq *s, int val)
|
static void write_state(struct trace_seq *s, int val)
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include "event-parse.h"
|
#include "event-parse.h"
|
||||||
|
#include "trace-seq.h"
|
||||||
|
|
||||||
typedef unsigned long sector_t;
|
typedef unsigned long sector_t;
|
||||||
typedef uint64_t u64;
|
typedef uint64_t u64;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "event-parse.h"
|
#include "event-parse.h"
|
||||||
|
#include "trace-seq.h"
|
||||||
|
|
||||||
#define __HYPERVISOR_set_trap_table 0
|
#define __HYPERVISOR_set_trap_table 0
|
||||||
#define __HYPERVISOR_mmu_update 1
|
#define __HYPERVISOR_mmu_update 1
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
* Copyright (C) 2009 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
|
* Copyright (C) 2009 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
#include "trace-seq.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
// SPDX-License-Identifier: LGPL-2.1
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2009, 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _TRACE_SEQ_H
|
||||||
|
#define _TRACE_SEQ_H
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
/* ----------------------- trace_seq ----------------------- */
|
||||||
|
|
||||||
|
#ifndef TRACE_SEQ_BUF_SIZE
|
||||||
|
#define TRACE_SEQ_BUF_SIZE 4096
|
||||||
|
#endif
|
||||||
|
|
||||||
|
enum trace_seq_fail {
|
||||||
|
TRACE_SEQ__GOOD,
|
||||||
|
TRACE_SEQ__BUFFER_POISONED,
|
||||||
|
TRACE_SEQ__MEM_ALLOC_FAILED,
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Trace sequences are used to allow a function to call several other functions
|
||||||
|
* to create a string of data to use (up to a max of PAGE_SIZE).
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct trace_seq {
|
||||||
|
char *buffer;
|
||||||
|
unsigned int buffer_size;
|
||||||
|
unsigned int len;
|
||||||
|
unsigned int readpos;
|
||||||
|
enum trace_seq_fail state;
|
||||||
|
};
|
||||||
|
|
||||||
|
void trace_seq_init(struct trace_seq *s);
|
||||||
|
void trace_seq_reset(struct trace_seq *s);
|
||||||
|
void trace_seq_destroy(struct trace_seq *s);
|
||||||
|
|
||||||
|
extern int trace_seq_printf(struct trace_seq *s, const char *fmt, ...)
|
||||||
|
__attribute__ ((format (printf, 2, 3)));
|
||||||
|
extern int trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args)
|
||||||
|
__attribute__ ((format (printf, 2, 0)));
|
||||||
|
|
||||||
|
extern int trace_seq_puts(struct trace_seq *s, const char *str);
|
||||||
|
extern int trace_seq_putc(struct trace_seq *s, unsigned char c);
|
||||||
|
|
||||||
|
extern void trace_seq_terminate(struct trace_seq *s);
|
||||||
|
|
||||||
|
extern int trace_seq_do_fprintf(struct trace_seq *s, FILE *fp);
|
||||||
|
extern int trace_seq_do_printf(struct trace_seq *s);
|
||||||
|
|
||||||
|
#endif /* _TRACE_SEQ_H */
|
|
@ -3,6 +3,7 @@
|
||||||
#define _PERF_UTIL_TRACE_EVENT_H
|
#define _PERF_UTIL_TRACE_EVENT_H
|
||||||
|
|
||||||
#include <traceevent/event-parse.h>
|
#include <traceevent/event-parse.h>
|
||||||
|
#include <traceevent/trace-seq.h>
|
||||||
#include "parse-events.h"
|
#include "parse-events.h"
|
||||||
|
|
||||||
struct machine;
|
struct machine;
|
||||||
|
|
Loading…
Reference in New Issue