Skip to contentSkip to conversation

tracecmd library API cleanup

PATCH New Tzvetomir Stoyanov (VMware) 1 participant 3 messages Nov 12, 2020 Kbuild

lore
Share & tools
lore
#0 lore raw

cover tracecmd library API cleanup

Remove (temporary) all libtracecmd APIs, except those used by KernelShark.

Tzvetomir Stoyanov (VMware) (2):
libtraceevent: Remove plugins dependencies of libtracecmd
trace-cmd: libtracecmd API cleanup

 Makefile                                      |   2 +-
 include/trace-cmd/trace-cmd.h                 | 488 +-----------------
 .../include/private/trace-cmd-private.h       | 480 +++++++++++++++++
 .../include/private}/trace-filter-hash.h      |   0
 .../trace-cmd/include/private}/trace-hash.h   |   0
 .../trace-cmd/include/private}/trace-msg.h    |   0
 lib/trace-cmd/include/trace-cmd-local.h       |   2 +
 lib/trace-cmd/trace-ftrace.c                  |   2 +-
 lib/trace-cmd/trace-hooks.c                   |   2 +-
 lib/trace-cmd/trace-recorder.c                |   2 +-
 lib/trace-cmd/trace-timesync.c                |   2 +-
 lib/trace-cmd/trace-util.c                    |   2 +-
 lib/traceevent/plugins/plugin_blk.c           |  10 +-
 lib/traceevent/plugins/plugin_function.c      |   2 +-
 lib/traceevent/plugins/plugin_futex.c         |   6 +-
 lib/traceevent/plugins/plugin_kmem.c          |   2 +-
 lib/traceevent/plugins/plugin_python_loader.c |   3 +-
 lib/traceevent/plugins/plugin_sched_switch.c  |   2 +-
 python/ctracecmd.i                            |   1 +
 tracecmd/include/trace-local.h                |   2 +-
 20 files changed, 518 insertions(+), 492 deletions(-)
 create mode 100644 lib/trace-cmd/include/private/trace-cmd-private.h
 rename {include/trace-cmd => lib/trace-cmd/include/private}/trace-filter-hash.h (100%)
 rename {include/trace-cmd => lib/trace-cmd/include/private}/trace-hash.h (100%)
 rename {include/trace-cmd => lib/trace-cmd/include/private}/trace-msg.h (100%)
Signature · 1 line
2.28.0
#1 lore raw

PATCH 1/2 libtraceevent: Remove plugins dependencies of libtracecmd

None of the libtraceevent plugins should depend on libtracecmd, they should depend only on the traceevent library.

---
 lib/traceevent/plugins/plugin_blk.c          | 10 +++++++---
 lib/traceevent/plugins/plugin_function.c     |  2 +-
 lib/traceevent/plugins/plugin_futex.c        |  6 +++++-
 lib/traceevent/plugins/plugin_kmem.c         |  2 +-
 lib/traceevent/plugins/plugin_sched_switch.c |  2 +-
 5 files changed, 15 insertions(+), 7 deletions(-)
lib/traceevent/plugins/plugin_blk.c +7 -3
index ea3a9cf6..04d99a21 100644
@@ -8,13 +8,17 @@
 
 #include <linux/blktrace_api.h>
 
-#include "trace-cmd.h"
+#include "event-parse.h"
 
 #define MINORBITS	20
 #define MINORMASK	((1U << MINORBITS) - 1)
 #define MAJOR(dev)	((unsigned int) ((dev) >> MINORBITS))
 #define MINOR(dev)	((unsigned int) ((dev) & MINORMASK))
 
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(_a) (sizeof(_a) / sizeof((_a)[0]))
+#endif
+
 struct blk_data {
 	unsigned long long	sector;
 	struct tep_event	*event;
@@ -129,7 +133,7 @@ static unsigned int be32_to_cpu(unsigned int val)
 {
 	unsigned int swap;
 
-	if (tracecmd_host_bigendian())
+	if (tep_is_bigendian())
 		return val;
 
 	swap = ((val & 0xffULL) << 24) |
@@ -144,7 +148,7 @@ static unsigned long long be64_to_cpu(unsigned long long val)
 {
 	unsigned long long swap;
 
-	if (tracecmd_host_bigendian())
+	if (tep_is_bigendian())
 		return val;
 
 	swap = ((val & 0xffULL) << 56) |
lib/traceevent/plugins/plugin_function.c +1 -1
index 938b7410..807b16e1 100644
@@ -6,7 +6,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "trace-cmd.h"
+#include "event-parse.h"
 #include "event-utils.h"
 #include "trace-seq.h"
 
lib/traceevent/plugins/plugin_futex.c +5 -1
index 1e235c2a..b8eb8a5f 100644
@@ -10,7 +10,11 @@
 #include <string.h>
 #include <linux/futex.h>
 
-#include "trace-cmd.h"
+#include "event-parse.h"
+
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(_a) (sizeof(_a) / sizeof((_a)[0]))
+#endif
 
 struct futex_args {
 	unsigned long long	uaddr;
lib/traceevent/plugins/plugin_kmem.c +1 -1
index 1117bdd2..45696f12 100644
@@ -6,7 +6,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "trace-cmd.h"
+#include "event-parse.h"
 #include "trace-seq.h"
 
 static int call_site_handler(struct trace_seq *s, struct tep_record *record,
lib/traceevent/plugins/plugin_sched_switch.c +1 -1
index 566f1661..8c90677c 100644
@@ -6,7 +6,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "trace-cmd.h"
+#include "event-parse.h"
 #include "trace-seq.h"
 
 static void write_state(struct trace_seq *s, int val)
Signature · 1 line
2.28.0
#2 lore raw

PATCH 2/2 trace-cmd: libtracecmd API cleanup

In reply to Tzvetomir Stoyanov (VMware)

The tracecmd library is used by trace-cmd and KernelShark applications. All APIs, that are not used by KernelShark arf removed from trace-cmd.h. This is the first step to cleanup the library APIs and dependencies.

---
 Makefile                                      |   2 +-
 include/trace-cmd/trace-cmd.h                 | 488 +-----------------
 .../include/private/trace-cmd-private.h       | 480 +++++++++++++++++
 .../include/private}/trace-filter-hash.h      |   0
 .../trace-cmd/include/private}/trace-hash.h   |   0
 .../trace-cmd/include/private}/trace-msg.h    |   0
 lib/trace-cmd/include/trace-cmd-local.h       |   2 +
 lib/trace-cmd/trace-ftrace.c                  |   2 +-
 lib/trace-cmd/trace-hooks.c                   |   2 +-
 lib/trace-cmd/trace-recorder.c                |   2 +-
 lib/trace-cmd/trace-timesync.c                |   2 +-
 lib/trace-cmd/trace-util.c                    |   2 +-
 lib/traceevent/plugins/plugin_python_loader.c |   3 +-
 python/ctracecmd.i                            |   1 +
 tracecmd/include/trace-local.h                |   2 +-
 15 files changed, 503 insertions(+), 485 deletions(-)
 create mode 100644 lib/trace-cmd/include/private/trace-cmd-private.h
 rename {include/trace-cmd => lib/trace-cmd/include/private}/trace-filter-hash.h (100%)
 rename {include/trace-cmd => lib/trace-cmd/include/private}/trace-hash.h (100%)
 rename {include/trace-cmd => lib/trace-cmd/include/private}/trace-msg.h (100%)
Makefile +1 -1
index b0340427..6ef69367 100644
@@ -224,6 +224,7 @@ INCLUDES += -I$(src)/include/trace-cmd
 INCLUDES += -I$(src)/include/tracefs
 INCLUDES += -I$(src)/lib/traceevent/include
 INCLUDES += -I$(src)/lib/trace-cmd/include
+INCLUDES += -I$(src)/lib/trace-cmd/include/private
 INCLUDES += -I$(src)/lib/tracefs/include
 INCLUDES += -I$(src)/tracecmd/include
 INCLUDES += -I$(obj)/tracecmd/include
@@ -417,7 +418,6 @@ install_libs: libs
 	$(Q)$(call do_install,$(src)/include/traceevent/event-parse.h,$(includedir_SQ)/traceevent)
 	$(Q)$(call do_install,$(src)/include/traceevent/trace-seq.h,$(includedir_SQ)/traceevent)
 	$(Q)$(call do_install,$(src)/include/trace-cmd/trace-cmd.h,$(includedir_SQ)/trace-cmd)
-	$(Q)$(call do_install,$(src)/include/trace-cmd/trace-filter-hash.h,$(includedir_SQ)/trace-cmd)
 	$(Q)$(call do_install,$(src)/include/tracefs/tracefs.h,$(includedir_SQ)/tracefs)
 	$(Q)$(call do_install_ld,$(TRACE_LD_FILE),$(LD_SO_CONF_DIR),$(libdir_SQ)/trace-cmd)
 	$(Q)$(call do_install_ld,$(TRACE_LD_FILE),$(LD_SO_CONF_DIR),$(libdir_SQ)/traceevent)
include/trace-cmd/trace-cmd.h +11 -477

508 lines not on this page · raw message

lib/trace-cmd/include/private/trace-cmd-private.h new file +480 -0

480 lines not on this page · raw message

lib/trace-cmd/include/private/trace-filter-hash.h renamed from include/trace-cmd/trace-filter-hash.h +0 -0
similarity index 100%
rename from include/trace-cmd/trace-filter-hash.h
rename to lib/trace-cmd/include/private/trace-filter-hash.h
lib/trace-cmd/include/private/trace-hash.h renamed from include/trace-cmd/trace-hash.h +0 -0
similarity index 100%
rename from include/trace-cmd/trace-hash.h
rename to lib/trace-cmd/include/private/trace-hash.h
lib/trace-cmd/include/private/trace-msg.h renamed from include/trace-cmd/trace-msg.h +0 -0
similarity index 100%
rename from include/trace-cmd/trace-msg.h
rename to lib/trace-cmd/include/private/trace-msg.h
lib/trace-cmd/include/trace-cmd-local.h +2 -0
index 95dce66c..d0a7365a 100644
@@ -6,6 +6,8 @@
 #ifndef _TRACE_CMD_LOCAL_H
 #define _TRACE_CMD_LOCAL_H
 
+#include "trace-cmd-private.h"
+
 /* Can be overridden */
 void warning(const char *fmt, ...);
 
lib/trace-cmd/trace-ftrace.c +1 -1
index 20bf71f4..df7335f0 100644
@@ -8,7 +8,7 @@
 #include <string.h>
 #include <sys/param.h>
 
-#include "trace-cmd.h"
+#include "trace-cmd-private.h"
 
 struct tep_plugin_option trace_ftrace_options[] = {
 	{
lib/trace-cmd/trace-hooks.c +1 -1
index 8c969a63..2dadf616 100644
@@ -8,7 +8,7 @@
 #include <stdlib.h>
 #include <ctype.h>
 
-#include "trace-cmd.h"
+#include "trace-cmd-private.h"
 #include "event-utils.h"
 
 struct hook_list *tracecmd_create_event_hook(const char *arg)
lib/trace-cmd/trace-recorder.c +1 -1
index 2a6e2b67..6b647d6c 100644
@@ -13,7 +13,7 @@
 #include <errno.h>
 
 #include "tracefs.h"
-#include "trace-cmd.h"
+#include "trace-cmd-private.h"
 #include "event-utils.h"
 
 /* F_GETPIPE_SZ was introduced in 2.6.35, older systems don't have it */
lib/trace-cmd/trace-timesync.c +1 -1
index 35a41394..5758a337 100644
@@ -17,7 +17,7 @@
 #include <errno.h>
 #include <pthread.h>
 
-#include "trace-cmd.h"
+#include "trace-cmd-private.h"
 #include "tracefs.h"
 #include "event-utils.h"
 #include "trace-tsync-local.h"
lib/trace-cmd/trace-util.c +1 -1
index 0ead96ea..6b5d8729 100644
@@ -21,7 +21,7 @@
 #include <sys/sysinfo.h>
 #include <time.h>
 
-#include "trace-cmd.h"
+#include "trace-cmd-private.h"
 #include "event-utils.h"
 
 #define LOCAL_PLUGIN_DIR ".trace-cmd/plugins"
lib/traceevent/plugins/plugin_python_loader.c +2 -1
index 776bf127..01bdfad3 100644
@@ -1,6 +1,7 @@
 #include <Python.h>
 #include <stdio.h>
-#include "trace-cmd.h"
+#include "event-parse.h"
+#include "trace-cmd-private.h"
 
 #ifndef PYTHON_DIR
 #define PYTHON_DIR "."
python/ctracecmd.i +1 -0
index 01cd0d55..5f7181c7 100644
@@ -15,6 +15,7 @@
 
 %{
 #include "trace-cmd.h"
+#include "event-parse.h"
 #include "event-utils.h"
 #include <Python.h>
 %}
tracecmd/include/trace-local.h +1 -1
index d148aa16..796b0f0d 100644
@@ -9,7 +9,7 @@
 #include <sys/types.h>
 #include <dirent.h>	/* for DIR */
 
-#include "trace-cmd.h"
+#include "trace-cmd-private.h"
 #include "event-utils.h"
 
 #define TRACE_AGENT_DEFAULT_PORT	823
Signature · 1 line
2.28.0