Linux-Trace-Devel Archive on lore.kernel.org
 help / Atom feed
From: Tzvetomir Stoyanov <tstoyanov@vmware.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 6/6] trace-cmd: Remove tep_data_event_from_type() API
Date: Wed, 30 Jan 2019 12:44:25 +0200
Message-ID: <20190130104425.8813-7-tstoyanov@vmware.com> (raw)
In-Reply-To: <20190130104425.8813-1-tstoyanov@vmware.com>

In order to make libtraceevent into a proper library, its API
should be straightforward.

After discussion with Steven Rostedt, we decided to remove the
tep_data_event_from_type() API and to replace it with tep_find_event(),
as it does the same.

Signed-off-by: Tzvetomir Stoyanov <tstoyanov@vmware.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/20181201040852.913841066@goodmis.org
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 include/traceevent/event-parse.h |  1 -
 kernel-shark/src/libkshark.c     |  7 +++----
 lib/traceevent/event-parse.c     | 12 ------------
 python/tracecmd.py               |  8 ++++----
 tracecmd/trace-hist.c            |  4 ++--
 tracecmd/trace-mem.c             |  2 +-
 tracecmd/trace-record.c          |  2 +-
 7 files changed, 11 insertions(+), 25 deletions(-)

diff --git a/include/traceevent/event-parse.h b/include/traceevent/event-parse.h
index 2dc5822..bdc6101 100644
--- a/include/traceevent/event-parse.h
+++ b/include/traceevent/event-parse.h
@@ -515,7 +515,6 @@ tep_find_event_by_record(struct tep_handle *pevent, struct tep_record *record);
 void tep_data_lat_fmt(struct tep_handle *pevent,
 		      struct trace_seq *s, struct tep_record *record);
 int tep_data_type(struct tep_handle *pevent, struct tep_record *rec);
-struct tep_event *tep_data_event_from_type(struct tep_handle *pevent, int type);
 int tep_data_pid(struct tep_handle *pevent, struct tep_record *rec);
 int tep_data_preempt_count(struct tep_handle *pevent, struct tep_record *rec);
 int tep_data_flags(struct tep_handle *pevent, struct tep_record *rec);
diff --git a/kernel-shark/src/libkshark.c b/kernel-shark/src/libkshark.c
index 5033e47..6a26f28 100644
--- a/kernel-shark/src/libkshark.c
+++ b/kernel-shark/src/libkshark.c
@@ -1187,7 +1187,7 @@ const char *kshark_get_event_name_easy(struct kshark_entry *entry)
 	 * Use a mutex to protect the access.
 	 */
 	pthread_mutex_lock(&kshark_ctx->input_mutex);
-	event = tep_data_event_from_type(kshark_ctx->pevent, event_id);
+	event = tep_find_event(kshark_ctx->pevent, event_id);
 	pthread_mutex_unlock(&kshark_ctx->input_mutex);
 
 	if (event)
@@ -1236,7 +1236,7 @@ const char *kshark_get_info_easy(struct kshark_entry *entry)
 
 	data = tracecmd_read_at(kshark_ctx->handle, entry->offset, NULL);
 	event_id = tep_data_type(kshark_ctx->pevent, data);
-	event = tep_data_event_from_type(kshark_ctx->pevent, event_id);
+	event = tep_find_event(kshark_ctx->pevent, event_id);
 	if (event)
 		info = kshark_get_info(kshark_ctx->pevent, data, event);
 
@@ -1330,8 +1330,7 @@ char* kshark_dump_entry(const struct kshark_entry *entry)
 		data = tracecmd_read_at(kshark_ctx->handle, entry->offset,
 					NULL);
 
-		event = tep_data_event_from_type(kshark_ctx->pevent,
-						 entry->event_id);
+		event = tep_find_event(kshark_ctx->pevent, entry->event_id);
 
 		event_name = event? event->name : "[UNKNOWN EVENT]";
 		lat = kshark_get_latency(kshark_ctx->pevent, data);
diff --git a/lib/traceevent/event-parse.c b/lib/traceevent/event-parse.c
index 8cdb5a3..ca2989b 100644
--- a/lib/traceevent/event-parse.c
+++ b/lib/traceevent/event-parse.c
@@ -5266,18 +5266,6 @@ int tep_data_type(struct tep_handle *pevent, struct tep_record *rec)
 	return trace_parse_common_type(pevent, rec->data);
 }
 
-/**
- * tep_data_event_from_type - find the event by a given type
- * @pevent: a handle to the pevent
- * @type: the type of the event.
- *
- * This returns the event form a given @type;
- */
-struct tep_event *tep_data_event_from_type(struct tep_handle *pevent, int type)
-{
-	return tep_find_event(pevent, type);
-}
-
 /**
  * tep_data_pid - parse the PID from record
  * @pevent: a handle to the pevent
diff --git a/python/tracecmd.py b/python/tracecmd.py
index 60a0d3e..a6671f6 100644
--- a/python/tracecmd.py
+++ b/python/tracecmd.py
@@ -204,7 +204,7 @@ class Trace(object):
         rec = tracecmd_read_data(self._handle, cpu)
         if rec:
             type = tep_data_type(self._pevent, rec)
-            format = tep_data_event_from_type(self._pevent, type)
+            format = tep_find_event(self._pevent, type)
             # rec ownership goes over to Event instance
             return Event(self._pevent, rec, format)
         return None
@@ -216,7 +216,7 @@ class Trace(object):
             return None
         rec, cpu = res
         type = tep_data_type(self._pevent, rec)
-        format = tep_data_event_from_type(self._pevent, type)
+        format = tep_find_event(self._pevent, type)
         # rec ownership goes over to Event instance
         return Event(self._pevent, rec, format)
 
@@ -226,7 +226,7 @@ class Trace(object):
             return None
         rec, cpu = res
         type = tep_data_type(self._pevent, rec)
-        format = tep_data_event_from_type(self._pevent, type)
+        format = tep_find_event(self._pevent, type)
         return Event(self._pevent, rec, format)
 
     def peek_event(self, cpu):
@@ -234,7 +234,7 @@ class Trace(object):
         if rec is None:
             return None
         type = tep_data_type(self._pevent, rec)
-        format = tep_data_event_from_type(self._pevent, type)
+        format = tep_find_event(self._pevent, type)
         # rec ownership goes over to Event instance
         return Event(self._pevent, rec, format)
 
diff --git a/tracecmd/trace-hist.c b/tracecmd/trace-hist.c
index bd47163..384a7ff 100644
--- a/tracecmd/trace-hist.c
+++ b/tracecmd/trace-hist.c
@@ -541,7 +541,7 @@ process_event(struct tep_handle *pevent, struct tep_record *record, int type)
 		reset_pending_stack();
 	}
 		
-	event = tep_data_event_from_type(pevent, type);
+	event = tep_find_event(pevent, type);
 	event_name = event->name;
 
 	ret = tep_read_number_field(common_pid_field, record->data, &val);
@@ -952,7 +952,7 @@ static void do_trace_hist(struct tracecmd_input *handle)
 		die("No records found in file");
 
 	ret = tep_data_type(pevent, record);
-	event = tep_data_event_from_type(pevent, ret);
+	event = tep_find_event(pevent, ret);
 
 	long_size = tracecmd_long_size(handle);
 
diff --git a/tracecmd/trace-mem.c b/tracecmd/trace-mem.c
index 059bf9a..078a61b 100644
--- a/tracecmd/trace-mem.c
+++ b/tracecmd/trace-mem.c
@@ -488,7 +488,7 @@ static void do_trace_mem(struct tracecmd_input *handle)
 		die("No records found in file");
 
 	ret = tep_data_type(pevent, record);
-	event = tep_data_event_from_type(pevent, ret);
+	event = tep_find_event(pevent, ret);
 
 	common_type_field = tep_find_common_field(event, "common_type");
 	if (!common_type_field)
diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
index 3034a4b..71a407e 100644
--- a/tracecmd/trace-record.c
+++ b/tracecmd/trace-record.c
@@ -3402,7 +3402,7 @@ find_ts_in_page(struct tep_handle *pevent, void *page, int size)
 			break;
 		free_record(last_record);
 		id = tep_data_type(pevent, record);
-		event = tep_data_event_from_type(pevent, id);
+		event = tep_find_event(pevent, id);
 		if (event) {
 			/* Make sure this is our event */
 			field = tep_find_field(event, "buf");
-- 
2.20.1


      parent reply index

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-30 10:44 [PATCH 0/6] Few patches, backported from Arnaldo's kernel repo Tzvetomir Stoyanov
2019-01-30 10:44 ` [PATCH 1/6] trace-cmd: Initialize host_bigendian at tep_handle allocation Tzvetomir Stoyanov
2019-01-30 10:44 ` [PATCH 2/6] trace_cmd: Rename struct cmdline to struct tep_cmdline Tzvetomir Stoyanov
2019-01-30 10:44 ` [PATCH 3/6] trace-cmd: Changed return logic of trace_seq_printf() and trace_seq_vprintf() APIs Tzvetomir Stoyanov
2019-01-30 10:44 ` [PATCH 4/6] trace-cmd: Changed return logic of tep_register_event_handler() API Tzvetomir Stoyanov
2019-01-30 10:44 ` [PATCH 5/6] trace-cmd: Rename tep_is_file_bigendian() to tep_file_bigendian() Tzvetomir Stoyanov
2019-01-30 10:44 ` Tzvetomir Stoyanov [this message]

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190130104425.8813-7-tstoyanov@vmware.com \
    --to=tstoyanov@vmware.com \
    --cc=acme@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=jolsa@redhat.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=namhyung@kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-Trace-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-trace-devel/0 linux-trace-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-trace-devel linux-trace-devel/ https://lore.kernel.org/linux-trace-devel \
		linux-trace-devel@vger.kernel.org linux-trace-devel@archiver.kernel.org
	public-inbox-index linux-trace-devel


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-trace-devel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox