Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp67905imm; Wed, 5 Sep 2018 15:07:44 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYUe4JHdrSMcY600b1JHw3Gg/dX8+JVD2uSWOdIQfKKusO5w0sK+tS6IbzJBrCkay8Mdtb4 X-Received: by 2002:a63:221b:: with SMTP id i27-v6mr31168027pgi.212.1536185264628; Wed, 05 Sep 2018 15:07:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536185264; cv=none; d=google.com; s=arc-20160816; b=x/xw2Hkkx1ucktXgKvbB9QWiLbHlRkiET8vDuekUnEwY7wmdCDD1O/GCHtY8HvFkCC DIU0kOqaZg7FSCVFHL2vIhmLo31CFD5AZILkIIus9yEvdlqBQEhRGOR13uIziiEbO8Pf lvcZs+DvJfC2ezLjXe9lQvE8M4ctdFw0mhTNMbch4YWQGho3uCyhntRL+vk6P0sWzukA MkmS9+WqcHqmF3NkyqWQyM6+Xc5EL1pVsJBh+h8Vsd6vXBkpSh2c9AYY4+jLLOOOnO+S qLrlQ/2yaILzmVuI2m53QIYutQAARG8lV4IpGrZv/Bs60oh6R7O2gMVEcFxF3q+kB2hx Jjdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=bIvUMX2UJZs4gg/FutTuuIlTgTkRQpAp5jpd1Wv1OJA=; b=TFC6J12+O0GLBHeaYu5UjgDHlxPoe7NdZk1upS4eeWpk0QO2v0hCaBWThdpXlojVqp AQt+NEp5A3nHtzV3NwImX4VehPTms+fcwquKKQQVEcEffcMIjp36GGFjexM9WkNn8lBj VBBv9wb7ClRAy6TH829KnPJ4EUuSheI4x90/eapJmHffybcUKjIfreWHyg04V1xURnrP qlGYaCedKHhuahTqYXMV/OdlkfFrA3heBsFuDQXesDIG6ZmIuJAZY7EeQ7W9hRvAFAx2 YC2SIEvYdHOBpZBpNObKow/bemNmdAww/n0Cqx1gNhcB4C7fPSeDnkfD9jU1OtxgCoce 55yQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oWwVuSFB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f15-v6si3188072pgb.666.2018.09.05.15.07.29; Wed, 05 Sep 2018 15:07:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oWwVuSFB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728349AbeIFCh6 (ORCPT + 99 others); Wed, 5 Sep 2018 22:37:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:52318 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727518AbeIFCh5 (ORCPT ); Wed, 5 Sep 2018 22:37:57 -0400 Received: from jouet.infradead.org (unknown [179.97.41.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9209A20652; Wed, 5 Sep 2018 22:05:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1536185146; bh=BPCLN+Ls1a3G1bAqAlFvfAdKjoGd3no4zAEwhKbMilI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oWwVuSFBvOISw60TS1cTqjvyWzOuQxXE9pmK3sUI4RSvjXdU5abB1ddoe4bUyfYwN dfE4Hvb4q725hrlpfNPFi8ZTVwGsA502VdNgufoD+01qtzR8blWMB7ulg8slAmGZtO vUnEwV9VhMumkcy1wV0MCOPTA6rWVHo5iioYJj2Y= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, "Tzvetomir Stoyanov (VMware)" , Jiri Olsa , Namhyung Kim , Steven Rostedt , Arnaldo Carvalho de Melo Subject: [PATCH 20/77] tools lib traceevent, perf tools: Split trace-seq related APIs in a separate header file Date: Wed, 5 Sep 2018 19:03:43 -0300 Message-Id: <20180905220440.20256-21-acme@kernel.org> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180905220440.20256-1-acme@kernel.org> References: <20180905220440.20256-1-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Tzvetomir Stoyanov (VMware)" 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) Cc: Jiri Olsa Cc: Namhyung Kim Link: http://lkml.kernel.org/r/20180828185038.2dcb2743@gandalf.local.home Signed-off-by: Steven Rostedt Signed-off-by: Arnaldo Carvalho de Melo --- tools/lib/traceevent/event-parse.c | 1 + tools/lib/traceevent/event-parse.h | 46 ++----------------------- tools/lib/traceevent/event-plugin.c | 1 + tools/lib/traceevent/plugin_function.c | 1 + tools/lib/traceevent/plugin_hrtimer.c | 1 + tools/lib/traceevent/plugin_jbd2.c | 1 + tools/lib/traceevent/plugin_kmem.c | 1 + tools/lib/traceevent/plugin_kvm.c | 1 + tools/lib/traceevent/plugin_mac80211.c | 1 + tools/lib/traceevent/plugin_sched_switch.c | 1 + tools/lib/traceevent/plugin_scsi.c | 1 + tools/lib/traceevent/plugin_xen.c | 1 + tools/lib/traceevent/trace-seq.c | 2 ++ tools/lib/traceevent/trace-seq.h | 55 ++++++++++++++++++++++++++++++ tools/perf/util/trace-event.h | 1 + 15 files changed, 71 insertions(+), 44 deletions(-) create mode 100644 tools/lib/traceevent/trace-seq.h diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c index ce1e20227c64..70a42bec6931 100644 --- a/tools/lib/traceevent/event-parse.c +++ b/tools/lib/traceevent/event-parse.c @@ -24,6 +24,7 @@ #include #include "event-parse.h" #include "event-utils.h" +#include "trace-seq.h" static const char *input_buf; static unsigned long long input_buf_ptr; diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h index 44b7c2d41f9f..fa665c66bfa4 100644 --- a/tools/lib/traceevent/event-parse.h +++ b/tools/lib/traceevent/event-parse.h @@ -26,17 +26,12 @@ #include #include +#include "trace-seq.h" + #ifndef __maybe_unused #define __maybe_unused __attribute__((unused)) #endif -/* ----------------------- trace_seq ----------------------- */ - - -#ifndef TRACE_SEQ_BUF_SIZE -#define TRACE_SEQ_BUF_SIZE 4096 -#endif - #ifndef DEBUG_RECORD #define DEBUG_RECORD 0 #endif @@ -59,43 +54,6 @@ struct tep_record { #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 ----------------------- */ struct tep_handle; diff --git a/tools/lib/traceevent/event-plugin.c b/tools/lib/traceevent/event-plugin.c index f17e25097e1e..ec16a103c0cc 100644 --- a/tools/lib/traceevent/event-plugin.c +++ b/tools/lib/traceevent/event-plugin.c @@ -15,6 +15,7 @@ #include #include "event-parse.h" #include "event-utils.h" +#include "trace-seq.h" #define LOCAL_PLUGIN_DIR ".traceevent/plugins" diff --git a/tools/lib/traceevent/plugin_function.c b/tools/lib/traceevent/plugin_function.c index 424747475d37..2919042e7dc2 100644 --- a/tools/lib/traceevent/plugin_function.c +++ b/tools/lib/traceevent/plugin_function.c @@ -23,6 +23,7 @@ #include "event-parse.h" #include "event-utils.h" +#include "trace-seq.h" static struct func_stack { int size; diff --git a/tools/lib/traceevent/plugin_hrtimer.c b/tools/lib/traceevent/plugin_hrtimer.c index b43bfec565d8..29b608076ea0 100644 --- a/tools/lib/traceevent/plugin_hrtimer.c +++ b/tools/lib/traceevent/plugin_hrtimer.c @@ -23,6 +23,7 @@ #include #include "event-parse.h" +#include "trace-seq.h" static int timer_expire_handler(struct trace_seq *s, struct tep_record *record, diff --git a/tools/lib/traceevent/plugin_jbd2.c b/tools/lib/traceevent/plugin_jbd2.c index 45a9acd19640..a5e34135dd6a 100644 --- a/tools/lib/traceevent/plugin_jbd2.c +++ b/tools/lib/traceevent/plugin_jbd2.c @@ -22,6 +22,7 @@ #include #include "event-parse.h" +#include "trace-seq.h" #define MINORBITS 20 #define MINORMASK ((1U << MINORBITS) - 1) diff --git a/tools/lib/traceevent/plugin_kmem.c b/tools/lib/traceevent/plugin_kmem.c index 73966b05abce..a7a162575e2c 100644 --- a/tools/lib/traceevent/plugin_kmem.c +++ b/tools/lib/traceevent/plugin_kmem.c @@ -22,6 +22,7 @@ #include #include "event-parse.h" +#include "trace-seq.h" static int call_site_handler(struct trace_seq *s, struct tep_record *record, struct event_format *event, void *context) diff --git a/tools/lib/traceevent/plugin_kvm.c b/tools/lib/traceevent/plugin_kvm.c index 1d0d15906225..a0dfd3d0f197 100644 --- a/tools/lib/traceevent/plugin_kvm.c +++ b/tools/lib/traceevent/plugin_kvm.c @@ -23,6 +23,7 @@ #include #include "event-parse.h" +#include "trace-seq.h" #ifdef HAVE_UDIS86 diff --git a/tools/lib/traceevent/plugin_mac80211.c b/tools/lib/traceevent/plugin_mac80211.c index de50a5316203..0b7779444b63 100644 --- a/tools/lib/traceevent/plugin_mac80211.c +++ b/tools/lib/traceevent/plugin_mac80211.c @@ -22,6 +22,7 @@ #include #include "event-parse.h" +#include "trace-seq.h" #define INDENT 65 diff --git a/tools/lib/traceevent/plugin_sched_switch.c b/tools/lib/traceevent/plugin_sched_switch.c index eecb4bd95c11..582d3be2849b 100644 --- a/tools/lib/traceevent/plugin_sched_switch.c +++ b/tools/lib/traceevent/plugin_sched_switch.c @@ -22,6 +22,7 @@ #include #include "event-parse.h" +#include "trace-seq.h" static void write_state(struct trace_seq *s, int val) { diff --git a/tools/lib/traceevent/plugin_scsi.c b/tools/lib/traceevent/plugin_scsi.c index 5ec346f6b842..4eba25cc1431 100644 --- a/tools/lib/traceevent/plugin_scsi.c +++ b/tools/lib/traceevent/plugin_scsi.c @@ -3,6 +3,7 @@ #include #include #include "event-parse.h" +#include "trace-seq.h" typedef unsigned long sector_t; typedef uint64_t u64; diff --git a/tools/lib/traceevent/plugin_xen.c b/tools/lib/traceevent/plugin_xen.c index b2acbd6e9c86..bc0496e4c296 100644 --- a/tools/lib/traceevent/plugin_xen.c +++ b/tools/lib/traceevent/plugin_xen.c @@ -3,6 +3,7 @@ #include #include #include "event-parse.h" +#include "trace-seq.h" #define __HYPERVISOR_set_trap_table 0 #define __HYPERVISOR_mmu_update 1 diff --git a/tools/lib/traceevent/trace-seq.c b/tools/lib/traceevent/trace-seq.c index e3bac4543d3b..8ff1d55954d1 100644 --- a/tools/lib/traceevent/trace-seq.c +++ b/tools/lib/traceevent/trace-seq.c @@ -3,6 +3,8 @@ * Copyright (C) 2009 Red Hat Inc, Steven Rostedt * */ +#include "trace-seq.h" + #include #include #include diff --git a/tools/lib/traceevent/trace-seq.h b/tools/lib/traceevent/trace-seq.h new file mode 100644 index 000000000000..d68ec69f8d1a --- /dev/null +++ b/tools/lib/traceevent/trace-seq.h @@ -0,0 +1,55 @@ +// SPDX-License-Identifier: LGPL-2.1 +/* + * Copyright (C) 2009, 2010 Red Hat Inc, Steven Rostedt + * + */ + +#ifndef _TRACE_SEQ_H +#define _TRACE_SEQ_H + +#include +#include + +/* ----------------------- 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 */ diff --git a/tools/perf/util/trace-event.h b/tools/perf/util/trace-event.h index 40204ec3a7a2..c69d77d7cf55 100644 --- a/tools/perf/util/trace-event.h +++ b/tools/perf/util/trace-event.h @@ -3,6 +3,7 @@ #define _PERF_UTIL_TRACE_EVENT_H #include +#include #include "parse-events.h" struct machine; -- 2.14.4