From patchwork Wed Oct 2 11:41:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tzvetomir Stoyanov (VMware)" X-Patchwork-Id: 11170913 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8EB871599 for ; Wed, 2 Oct 2019 11:42:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5B47721A4A for ; Wed, 2 Oct 2019 11:42:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="spnBnjd3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726943AbfJBLmA (ORCPT ); Wed, 2 Oct 2019 07:42:00 -0400 Received: from mail-wr1-f42.google.com ([209.85.221.42]:37719 "EHLO mail-wr1-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726248AbfJBLmA (ORCPT ); Wed, 2 Oct 2019 07:42:00 -0400 Received: by mail-wr1-f42.google.com with SMTP id i1so19285220wro.4 for ; Wed, 02 Oct 2019 04:41:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WRwdxbkoXQv7GO/PrgmAWRrVef7OWn2zVFHo3n/HC5o=; b=spnBnjd3u8ZnXPIHTVxN0mxU7axgpZ+m9s2cGm6LoAK/iKZ1qCYlIYLLyJttzYB+FM i3TCztE5zyq15Vrrw/zfYjj2VbbDdY8a1/B4PU5h1oFjokA4d13sm96nP5YUUMdCv17N 5BYOhFKjsAIdcZtLFM9+aZhMTvMg1xVt0sg/wrcOn8Y7NJam6Mx/csJlvuHFJmGqSwba 5sA7oHpomtuYmnIto0QkLyralvPLAm+4/yrFgaWtPaJcVYbtSD+/wC48rHzDpew2q3Yq LMwt4nwnl7p1a1FgBma4hEC2vvzqZRDId37LWzkhuYzKLU2jlIHbDOD7R/3Dfgdv2PLB geqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WRwdxbkoXQv7GO/PrgmAWRrVef7OWn2zVFHo3n/HC5o=; b=WBAY73RRZI/NYsdH5TxTOtx6krDfFgJikPnlOTo2+lCt0x7FGF9YHicl/BZ1HQXPq5 r94UUeKwxq4hVtL1UTE78GPWHLx2GOdRrnFn8ozfxVKKAcS+W7wWAsIc2pCuxjiB6375 kpGxVr4avZxDr8vQ7OfdTUgbww0JLnpCRfx/Ece+KKFn3XHr6MxOD0RPHOFIR0TdDogF Ndi4bx/y4/Ph6KoT8d7F6q6/ISBFTnWVY2R4WfoXMpKN2v9esqS9z5azmpNIZeoC32F5 Lw/W02JnHL9KruCkMZ/d59JAC1zqIFSdmchxgtYkkp6iKsXZCkYTaFi0KuQGUe67yntr 7ttw== X-Gm-Message-State: APjAAAUSCoFktAuteWNpJYOXonAhZTelUoH4Y9UNtJUIFiKy7Y6NGcdv eyOon81zBofu3tSIM/mtxYqIG5sG X-Google-Smtp-Source: APXvYqxpGOyx7MONVHyeqz0WmXcqo3wGLFEMNdMjupaw5mOZBjoEJmee0H5yzH45ytbfB7ZJegXq4A== X-Received: by 2002:a5d:43c7:: with SMTP id v7mr1430250wrr.135.1570016516036; Wed, 02 Oct 2019 04:41:56 -0700 (PDT) Received: from oberon.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id l4sm3004658wrw.6.2019.10.02.04.41.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2019 04:41:55 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v3 1/5] trace-cmd: Move libtraceevent plugins in its own directory. Date: Wed, 2 Oct 2019 14:41:48 +0300 Message-Id: <20191002114152.30048-2-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191002114152.30048-1-tz.stoyanov@gmail.com> References: <20191002114152.30048-1-tz.stoyanov@gmail.com> MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org All existing plugins are moved from plugins/ to plugins/traceevent/ directory, as all of them (except plugin_python) are designed to be used with the traceevent library. This change paves the way for implementing trace-cmd specific plugins. Signed-off-by: Tzvetomir Stoyanov (VMware) --- .gitignore | 2 +- Makefile | 28 +++++++++---------- lib/trace-cmd/Makefile | 2 -- {plugins => lib/traceevent/plugins}/Makefile | 6 ++-- .../traceevent/plugins}/plugin_blk.c | 0 .../traceevent/plugins}/plugin_cfg80211.c | 0 .../traceevent/plugins}/plugin_function.c | 0 .../traceevent/plugins}/plugin_futex.c | 0 .../traceevent/plugins}/plugin_hrtimer.c | 0 .../traceevent/plugins}/plugin_jbd2.c | 0 .../traceevent/plugins}/plugin_kmem.c | 0 .../traceevent/plugins}/plugin_kvm.c | 0 .../traceevent/plugins}/plugin_mac80211.c | 0 .../traceevent/plugins}/plugin_python.c | 0 .../traceevent/plugins}/plugin_sched_switch.c | 0 .../traceevent/plugins}/plugin_scsi.c | 0 .../traceevent/plugins}/plugin_tlb.c | 0 .../traceevent/plugins}/plugin_xen.c | 0 18 files changed, 18 insertions(+), 20 deletions(-) rename {plugins => lib/traceevent/plugins}/Makefile (93%) rename {plugins => lib/traceevent/plugins}/plugin_blk.c (100%) rename {plugins => lib/traceevent/plugins}/plugin_cfg80211.c (100%) rename {plugins => lib/traceevent/plugins}/plugin_function.c (100%) rename {plugins => lib/traceevent/plugins}/plugin_futex.c (100%) rename {plugins => lib/traceevent/plugins}/plugin_hrtimer.c (100%) rename {plugins => lib/traceevent/plugins}/plugin_jbd2.c (100%) rename {plugins => lib/traceevent/plugins}/plugin_kmem.c (100%) rename {plugins => lib/traceevent/plugins}/plugin_kvm.c (100%) rename {plugins => lib/traceevent/plugins}/plugin_mac80211.c (100%) rename {plugins => lib/traceevent/plugins}/plugin_python.c (100%) rename {plugins => lib/traceevent/plugins}/plugin_sched_switch.c (100%) rename {plugins => lib/traceevent/plugins}/plugin_scsi.c (100%) rename {plugins => lib/traceevent/plugins}/plugin_tlb.c (100%) rename {plugins => lib/traceevent/plugins}/plugin_xen.c (100%) diff --git a/.gitignore b/.gitignore index b7b405f..20bb5a3 100644 --- a/.gitignore +++ b/.gitignore @@ -18,5 +18,5 @@ ctracecmdgui_wrap.c tags TAGS cscope* -trace_plugin_dir +traceevent_plugin_dir trace_python_dir diff --git a/Makefile b/Makefile index dabdf8d..f336f7a 100644 --- a/Makefile +++ b/Makefile @@ -273,16 +273,16 @@ gui: force $(CMD_TARGETS) $(kshark-dir)/build/Makefile trace-cmd: force $(LIBTRACEEVENT_STATIC) $(LIBTRACECMD_STATIC) $(Q)$(MAKE) -C $(src)/tracecmd $(obj)/tracecmd/$@ -$(LIBTRACEEVENT_SHARED): force +$(LIBTRACEEVENT_SHARED): force $(obj)/lib/traceevent/plugins/traceevent_plugin_dir $(Q)$(MAKE) -C $(src)/lib/traceevent $@ -$(LIBTRACEEVENT_STATIC): force +$(LIBTRACEEVENT_STATIC): force $(obj)/lib/traceevent/plugins/traceevent_plugin_dir $(Q)$(MAKE) -C $(src)/lib/traceevent $@ -$(LIBTRACECMD_STATIC): force $(obj)/plugins/trace_plugin_dir +$(LIBTRACECMD_STATIC): force $(Q)$(MAKE) -C $(src)/lib/trace-cmd $@ -$(LIBTRACECMD_SHARED): force $(obj)/plugins/trace_plugin_dir +$(LIBTRACECMD_SHARED): force $(Q)$(MAKE) -C $(src)/lib/trace-cmd $@ libtraceevent.so: $(LIBTRACEEVENT_SHARED) @@ -292,14 +292,14 @@ libtracecmd.so: $(LIBTRACECMD_SHARED) libs: $(LIBTRACECMD_SHARED) $(LIBTRACEEVENT_SHARED) -plugins: force $(obj)/plugins/trace_plugin_dir $(obj)/plugins/trace_python_dir - $(Q)$(MAKE) -C $(src)/plugins +plugins: force $(obj)/lib/traceevent/plugins/traceevent_plugin_dir $(obj)/lib/traceevent/plugins/trace_python_dir + $(Q)$(MAKE) -C $(src)/lib/traceevent/plugins -$(obj)/plugins/trace_plugin_dir: force - $(Q)$(MAKE) -C $(src)/plugins $@ +$(obj)/lib/traceevent/plugins/traceevent_plugin_dir: force + $(Q)$(MAKE) -C $(src)/lib/traceevent/plugins $@ -$(obj)/plugins/trace_python_dir: force - $(Q)$(MAKE) -C $(src)/plugins $@ +$(obj)/lib/traceevent/plugins/trace_python_dir: force + $(Q)$(MAKE) -C $(src)/lib/traceevent/plugins $@ show_gui_make: @echo "Note: to build the gui, type \"make gui\"" @@ -325,7 +325,7 @@ cscope: force $(call find_tag_files) | cscope -b -q install_plugins: force - $(Q)$(MAKE) -C $(src)/plugins $@ + $(Q)$(MAKE) -C $(src)/lib/traceevent/plugins $@ install_python: force $(Q)$(MAKE) -C $(src)/python $@ @@ -372,7 +372,7 @@ clean: $(RM) tags TAGS cscope* $(MAKE) -C $(src)/lib/traceevent clean $(MAKE) -C $(src)/lib/trace-cmd clean - $(MAKE) -C $(src)/plugins clean + $(MAKE) -C $(src)/lib/traceevent/plugins clean $(MAKE) -C $(src)/python clean $(MAKE) -C $(src)/tracecmd clean if [ -f $(kshark-dir)/build/Makefile ]; then $(MAKE) -C $(kshark-dir)/build clean; fi @@ -421,8 +421,8 @@ python-gui: $(PYTHON_GUI) PHONY += python-plugin python-plugin: $(PYTHON_PLUGINS) -plugin_python.so: force $(obj)/plugins/trace_python_dir - $(Q)$(MAKE) -C $(src)/plugins $(obj)/plugins/plugin_python.so +plugin_python.so: force $(obj)/lib/traceevent/plugins/trace_python_dir + $(Q)$(MAKE) -C $(src)/lib/traceevent/plugins $(obj)/lib/traceevent/plugins/plugin_python.so dist: git archive --format=tar --prefix=trace-cmd-$(TRACECMD_VERSION)/ HEAD \ diff --git a/lib/trace-cmd/Makefile b/lib/trace-cmd/Makefile index 78875e4..3b4b5aa 100644 --- a/lib/trace-cmd/Makefile +++ b/lib/trace-cmd/Makefile @@ -40,8 +40,6 @@ $(bdir)/libtracecmd.so: $(OBJS) $(bdir)/%.o: %.c $(Q)$(call do_fpic_compile) -$(bdir)/trace-util.o: $(obj)/plugins/trace_plugin_dir - $(DEPS): $(bdir)/.%.d: %.c $(Q)$(CC) -M $(CPPFLAGS) $(CFLAGS) $< > $@ diff --git a/plugins/Makefile b/lib/traceevent/plugins/Makefile similarity index 93% rename from plugins/Makefile rename to lib/traceevent/plugins/Makefile index 4598e83..e0a7566 100644 --- a/plugins/Makefile +++ b/lib/traceevent/plugins/Makefile @@ -1,6 +1,6 @@ include $(src)/scripts/utils.mk -bdir:=$(obj)/plugins +bdir:=$(obj)/lib/traceevent/plugins PLUGIN_OBJS = PLUGIN_OBJS += plugin_jbd2.o @@ -61,7 +61,7 @@ install_plugins: $(PLUGINS_INSTALL) # and $(PYTHON_DIR) change. Without them, a full clean build would necessary # in order to get the binaries updated. -$(bdir)/trace_plugin_dir: $(bdir) force +$(bdir)/traceevent_plugin_dir: $(bdir) force $(Q)$(N)$(call update_dir, 'PLUGIN_DIR=$(PLUGIN_DIR)') $(bdir)/trace_python_dir: $(bdir) force @@ -75,7 +75,7 @@ ifneq ($(dep_includes),) endif clean: - $(RM) -f $(bdir)/*.a $(bdir)/*.so $(bdir)/*.o $(bdir)/.*.d $(bdir)/trace_plugin_dir $(bdir)/trace_python_dir + $(RM) -f $(bdir)/*.a $(bdir)/*.so $(bdir)/*.o $(bdir)/.*.d $(bdir)/traceevent_plugin_dir $(bdir)/trace_python_dir force: .PHONY: clean force diff --git a/plugins/plugin_blk.c b/lib/traceevent/plugins/plugin_blk.c similarity index 100% rename from plugins/plugin_blk.c rename to lib/traceevent/plugins/plugin_blk.c diff --git a/plugins/plugin_cfg80211.c b/lib/traceevent/plugins/plugin_cfg80211.c similarity index 100% rename from plugins/plugin_cfg80211.c rename to lib/traceevent/plugins/plugin_cfg80211.c diff --git a/plugins/plugin_function.c b/lib/traceevent/plugins/plugin_function.c similarity index 100% rename from plugins/plugin_function.c rename to lib/traceevent/plugins/plugin_function.c diff --git a/plugins/plugin_futex.c b/lib/traceevent/plugins/plugin_futex.c similarity index 100% rename from plugins/plugin_futex.c rename to lib/traceevent/plugins/plugin_futex.c diff --git a/plugins/plugin_hrtimer.c b/lib/traceevent/plugins/plugin_hrtimer.c similarity index 100% rename from plugins/plugin_hrtimer.c rename to lib/traceevent/plugins/plugin_hrtimer.c diff --git a/plugins/plugin_jbd2.c b/lib/traceevent/plugins/plugin_jbd2.c similarity index 100% rename from plugins/plugin_jbd2.c rename to lib/traceevent/plugins/plugin_jbd2.c diff --git a/plugins/plugin_kmem.c b/lib/traceevent/plugins/plugin_kmem.c similarity index 100% rename from plugins/plugin_kmem.c rename to lib/traceevent/plugins/plugin_kmem.c diff --git a/plugins/plugin_kvm.c b/lib/traceevent/plugins/plugin_kvm.c similarity index 100% rename from plugins/plugin_kvm.c rename to lib/traceevent/plugins/plugin_kvm.c diff --git a/plugins/plugin_mac80211.c b/lib/traceevent/plugins/plugin_mac80211.c similarity index 100% rename from plugins/plugin_mac80211.c rename to lib/traceevent/plugins/plugin_mac80211.c diff --git a/plugins/plugin_python.c b/lib/traceevent/plugins/plugin_python.c similarity index 100% rename from plugins/plugin_python.c rename to lib/traceevent/plugins/plugin_python.c diff --git a/plugins/plugin_sched_switch.c b/lib/traceevent/plugins/plugin_sched_switch.c similarity index 100% rename from plugins/plugin_sched_switch.c rename to lib/traceevent/plugins/plugin_sched_switch.c diff --git a/plugins/plugin_scsi.c b/lib/traceevent/plugins/plugin_scsi.c similarity index 100% rename from plugins/plugin_scsi.c rename to lib/traceevent/plugins/plugin_scsi.c diff --git a/plugins/plugin_tlb.c b/lib/traceevent/plugins/plugin_tlb.c similarity index 100% rename from plugins/plugin_tlb.c rename to lib/traceevent/plugins/plugin_tlb.c diff --git a/plugins/plugin_xen.c b/lib/traceevent/plugins/plugin_xen.c similarity index 100% rename from plugins/plugin_xen.c rename to lib/traceevent/plugins/plugin_xen.c From patchwork Wed Oct 2 11:41:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tzvetomir Stoyanov (VMware)" X-Patchwork-Id: 11170917 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6A0911599 for ; Wed, 2 Oct 2019 11:42:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 48E4021929 for ; Wed, 2 Oct 2019 11:42:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rZWOKf0F" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725916AbfJBLmB (ORCPT ); Wed, 2 Oct 2019 07:42:01 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:33215 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726171AbfJBLmA (ORCPT ); Wed, 2 Oct 2019 07:42:00 -0400 Received: by mail-wr1-f68.google.com with SMTP id b9so19287812wrs.0 for ; Wed, 02 Oct 2019 04:41:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7HVPvMkHId7shPJR7QSW7ONG80bylQ1cwLiTUhTiNkw=; b=rZWOKf0FpyEUWs2dwVsl+aN0TYoJTMZc+Ia8qmYi02WZ7BoMC5edFKkm/jwMkzlwaZ fBKqJkm8vapNeZpCE+SKugzvHJoKaxr7KDgxASXQF5WUNNYIZcI1VGsko17yL7H/gWFy oYyCajSCNQYcVER5rBA7UiCJ109PrAXlknMccrcF+pnw81+Pz/INv/0Cdq93mCTgBo3C yVB5MNV26YTS3MBHrAk77uHNAkNu5hmg4AHhE4EN4UK8URSZ9YttmUcycgUgtyUgUiBJ pTeNK4E6a7/a070GJMuV/rGA5GxlOu+wopVeVXr/xGz4GDy6GquzqfwBgaswroP9cZLY EqeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7HVPvMkHId7shPJR7QSW7ONG80bylQ1cwLiTUhTiNkw=; b=Kyxhhr7vUMACdZdTg4orUAjQmiJbNLPZboj1/tkrdKC6h3CIzhpe2J0sArITzoVb0u Pu0VLq6fWSjOZW3sNeN7NucqOgiQQpUpfm0c5V6VAmERj3o46yW5jiBsC3AOc1jAQURw K6DaEtvQoHeHOcLD/cwkjOrx3oJpXijCSIDx97sawU4+ErCMX0u2M9BWDdQeSt8dD0He HUMHsYYJh2mZdYNh1eYid2xU4XXUK0XRn7mWHl4Ia319aM772XrSyNc6Vz2OR9hFs271 UjHt1kWzj5vVrcnSgq2YXcHyI7oIs6MpKKq4x6HJuwWuH9N7rUOr3cqXctkQ2ht+D7Sb JQBg== X-Gm-Message-State: APjAAAX54MDYG5cIl+GtYn+faOxcWyAvV6Id7jOD6v4u8qfmUfGpd7TM AiMsxjIncwR5RHEPyZeDlkIRSAil X-Google-Smtp-Source: APXvYqwLfQMvS6y0wj/gAOLR5kP2Rf3gQAqVtx2FY4msC2kt6870vSG6phlLNSM8bjZ4+bQRl75urg== X-Received: by 2002:a5d:69c7:: with SMTP id s7mr2269996wrw.295.1570016517017; Wed, 02 Oct 2019 04:41:57 -0700 (PDT) Received: from oberon.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id l4sm3004658wrw.6.2019.10.02.04.41.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2019 04:41:56 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v3 2/5] trace-cmd: Rename plugin_python to plugin_python_loader. Date: Wed, 2 Oct 2019 14:41:49 +0300 Message-Id: <20191002114152.30048-3-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191002114152.30048-1-tz.stoyanov@gmail.com> References: <20191002114152.30048-1-tz.stoyanov@gmail.com> MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org The plugin_python is renamed to plugin_python_loader, to make the name more closer to the actual plugin role. Signed-off-by: Tzvetomir Stoyanov (VMware) --- Makefile | 10 +--------- lib/traceevent/plugins/Makefile | 6 +++--- .../{plugin_python.c => plugin_python_loader.c} | 0 3 files changed, 4 insertions(+), 12 deletions(-) rename lib/traceevent/plugins/{plugin_python.c => plugin_python_loader.c} (100%) diff --git a/Makefile b/Makefile index f336f7a..e20eced 100644 --- a/Makefile +++ b/Makefile @@ -116,8 +116,7 @@ PYTHON_PKGCONFIG_VERS ?= $(PYTHON_VERS) # Can build python? ifeq ($(shell sh -c "pkg-config --cflags $(PYTHON_PKGCONFIG_VERS) > /dev/null 2>&1 && echo y"), y) - PYTHON_PLUGINS := plugin_python.so - BUILD_PYTHON := $(PYTHON) $(PYTHON_PLUGINS) + BUILD_PYTHON := $(PYTHON) BUILD_PYTHON_WORKS := 1 else BUILD_PYTHON := report_nopythondev @@ -125,7 +124,6 @@ else endif endif # NO_PYTHON -export PYTHON_PLUGINS export BUILD_PYTHON_WORKS export NO_PYTHON @@ -418,12 +416,6 @@ python: $(PYTHON) PHONY += python-gui python-gui: $(PYTHON_GUI) -PHONY += python-plugin -python-plugin: $(PYTHON_PLUGINS) - -plugin_python.so: force $(obj)/lib/traceevent/plugins/trace_python_dir - $(Q)$(MAKE) -C $(src)/lib/traceevent/plugins $(obj)/lib/traceevent/plugins/plugin_python.so - dist: git archive --format=tar --prefix=trace-cmd-$(TRACECMD_VERSION)/ HEAD \ > ../trace-cmd-$(TRACECMD_VERSION).tar diff --git a/lib/traceevent/plugins/Makefile b/lib/traceevent/plugins/Makefile index e0a7566..061d919 100644 --- a/lib/traceevent/plugins/Makefile +++ b/lib/traceevent/plugins/Makefile @@ -21,7 +21,7 @@ PLUGIN_OBJS := $(PLUGIN_OBJS:%.o=$(bdir)/%.o) PLUGIN_BUILD := $(PLUGIN_OBJS:$(bdir)/%.o=$(bdir)/%.so) PLUGINS := $(PLUGIN_BUILD) ifndef NO_PYTHON -PLUGINS += $(bdir)/plugin_python.so +PLUGINS += $(bdir)/plugin_python_loader.so endif DEPS := $(PLUGIN_OBJS:$(bdir)/%.o=$(bdir)/.%.d) @@ -44,10 +44,10 @@ $(DEPS): $(bdir)/.%.d: %.c $(PLUGIN_OBJS): $(bdir)/%.o : $(bdir)/.%.d -$(bdir)/plugin_python.o: $(bdir)/%.o : %.c $(bdir)/trace_python_dir +$(bdir)/plugin_python_loader.o: $(bdir)/%.o : %.c $(bdir)/trace_python_dir $(Q)$(do_compile_python_plugin_obj) -$(bdir)/plugin_python.so: $(bdir)/%.so: $(bdir)/%.o +$(bdir)/plugin_python_loader.so: $(bdir)/%.so: $(bdir)/%.o $(Q)$(do_python_plugin_build) PLUGINS_INSTALL = $(subst .so,.install,$(PLUGINS)) diff --git a/lib/traceevent/plugins/plugin_python.c b/lib/traceevent/plugins/plugin_python_loader.c similarity index 100% rename from lib/traceevent/plugins/plugin_python.c rename to lib/traceevent/plugins/plugin_python_loader.c From patchwork Wed Oct 2 11:41:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tzvetomir Stoyanov (VMware)" X-Patchwork-Id: 11170915 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2A31013B1 for ; Wed, 2 Oct 2019 11:42:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 08D7621920 for ; Wed, 2 Oct 2019 11:42:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MWjZMahG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726248AbfJBLmA (ORCPT ); Wed, 2 Oct 2019 07:42:00 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:37382 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725916AbfJBLmA (ORCPT ); Wed, 2 Oct 2019 07:42:00 -0400 Received: by mail-wm1-f65.google.com with SMTP id f22so6638325wmc.2 for ; Wed, 02 Oct 2019 04:41:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3h3krUjeDjO3mByQYSfh8zes6w1Xi4ZjEF/nwHcJZ3k=; b=MWjZMahGSZFbz9G48Hi60FkoVQOqvIrm+g6CwzXNK+0CyuFINq0tvn4sFF6StkGcsW LvHC9pgJPvGWdbK8AWYIhQlHAWT9i2gerJOZDuRkNq4VI1Mw9hA8EIvHbAUfxzAG63Xi 7WbkpOpwHbGKYn+XKEeoZBLI1ej7OTN89mOTDvVfbEJfCt9ynco83leclZgA/oCFj6oT 0IPyrAyS4AEIj/AynEuB+N8ln0eC2Vcd/wLdS0LHNwLKBZXF5svR6BQ85XK/NAqkXoQl BYvIHuJdgzGJFIfDuxzYcRZmW6ZAtJDWu4Hy93W+z3IpqyOZ+VBJqdUO/wQ9FrRgogl1 zpPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3h3krUjeDjO3mByQYSfh8zes6w1Xi4ZjEF/nwHcJZ3k=; b=dBAdKrmFI43N2u3L2zrqxD21IeP/bwLSKb+Dlc6NtrJ0mkVqrFTsfGsiU6t85ZPXuy 3vgi7+rMHk/tWYrg26oLxnFmdt5nXVqBOUn0ZRXM7mFPgfp3ImrSUo5JikzvheFWvwLr VwDSb6nWwXLPvkY/WuCEIfiTP3sOBY3m2UYuL+rfkuZu75JRa7S+mstDtkOtHCOuz50U 0ifwth5ngZzIeDr6I9lsvN55ogAkb0vXByG6N9In0EFn9Bd6pbbsytIf6tMpTca4aNAA mzdnjEjUtGt0fGUjaBAGKIcgPDgEoq7cpjwQgxJFzuO4vpb6VPL6XZ75HJ7GxZ/yOQ0a 0I1Q== X-Gm-Message-State: APjAAAW81/m6cFqNSaREwg89/RbYarA4DQDqWf27h2Rm9eO+MjZgcfXU 0Z50nZk6eJ5NNv+LjxKX9d8= X-Google-Smtp-Source: APXvYqwHx+H5B7L2NFeG93HcUgkyP3KtYFmsDWV/AeW2xPGcamF1ISneiRkmd1R4UXo5+t9pvxm9/w== X-Received: by 2002:a1c:b745:: with SMTP id h66mr2437083wmf.70.1570016518124; Wed, 02 Oct 2019 04:41:58 -0700 (PDT) Received: from oberon.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id l4sm3004658wrw.6.2019.10.02.04.41.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2019 04:41:57 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v3 3/5] trace-cmd: Load libtraceevent plugins from build folder, if exists. Date: Wed, 2 Oct 2019 14:41:50 +0300 Message-Id: <20191002114152.30048-4-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191002114152.30048-1-tz.stoyanov@gmail.com> References: <20191002114152.30048-1-tz.stoyanov@gmail.com> MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org When a development version of trace-cmd is built and run on the machine, by default it loads only installed plugins, from system drierctories. Thus, the development plugins will not be loaded. To simplify the development process, a new logic is added: At plugins load time, check the location of trace-cmd application and look for "plugins" directory around it. If found, load plugins from it. Those pluigins will be loaded last, so in case of duplication the "development" plugins win. Signed-off-by: Tzvetomir Stoyanov (VMware) --- lib/traceevent/event-plugin.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/lib/traceevent/event-plugin.c b/lib/traceevent/event-plugin.c index bc10205..4fc4ee3 100644 --- a/lib/traceevent/event-plugin.c +++ b/lib/traceevent/event-plugin.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "event-parse.h" #include "event-parse-local.h" #include "event-utils.h" @@ -538,6 +539,27 @@ load_plugins_dir(struct tep_handle *tep, const char *suffix, closedir(dir); } +static char *get_source_plugins_dir(void) +{ + char *p, path[PATH_MAX+1]; + int ret; + + ret = readlink("/proc/self/exe", path, PATH_MAX); + if (ret > PATH_MAX || ret < 0) + return NULL; + + dirname(path); + p = strrchr(path, '/'); + if (!p) + return NULL; + /* Check if we are in the the source tree */ + if (strcmp(p, "/tracecmd") != 0) + return NULL; + + strcpy(p, "/lib/traceevent/plugins"); + return strdup(path); +} + void tep_load_plugins_hook(struct tep_handle *tep, const char *suffix, void (*load_plugin)(struct tep_handle *tep, const char *path, @@ -588,6 +610,12 @@ void tep_load_plugins_hook(struct tep_handle *tep, const char *suffix, load_plugins_dir(tep, suffix, path, load_plugin, data); free(path); + + path = get_source_plugins_dir(); + if (path) { + load_plugins_dir(tep, suffix, path, load_plugin, data); + free(path); + } } struct tep_plugin_list* From patchwork Wed Oct 2 11:41:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tzvetomir Stoyanov (VMware)" X-Patchwork-Id: 11170919 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9E74513B1 for ; Wed, 2 Oct 2019 11:42:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7C06321929 for ; Wed, 2 Oct 2019 11:42:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Rd20WqDM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727223AbfJBLmC (ORCPT ); Wed, 2 Oct 2019 07:42:02 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:33973 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726721AbfJBLmC (ORCPT ); Wed, 2 Oct 2019 07:42:02 -0400 Received: by mail-wr1-f67.google.com with SMTP id a11so19301223wrx.1 for ; Wed, 02 Oct 2019 04:41:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yjO1GI9WSTyl7GI7EAfh6xqtE/wh9IHfL7MdVWHzIWs=; b=Rd20WqDMTtz1w4UismWXpCQ/BztUgNqY/h4VPHgv9nyidV6vaKH/doRAjcmkLMCBFP PGiqW5vpWeU3pLTTN9upJlxUpinXpNvR9RiI+aN6YLq6dRSi/1gUsIHvt94myotg8E87 Olnl9BGaLRxNxI/n+MBQilQjJbltZJSYYdvQQlm5esBvbZXOgTATG2b4J1EtKaEifwer Fo/WoO8Ck72vyUKuHea1A+u/YipMwWFuxgREmAqduXaMP9WEiXSAV6uX8C/btzOA5Ygw ErUzTgx1m37+sfrrfR/0wIF7HiKbMJmNho04iUUoJWoHNsG4C5C+RyY1a7z9eU4XCmMf POig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yjO1GI9WSTyl7GI7EAfh6xqtE/wh9IHfL7MdVWHzIWs=; b=EdyclNumTUNH26PUL5OYwLyUcSsy54TFq1FCJw+3O5hq1Am2bEFDjWXVJpO26spyKo p64Wx9pX1r9RMLswyn0v+HQY21zyzQOzWnQe1TdRMRwXPzJoXHmK9ColdnimtSIhb58V DGKWQTI+oNQ08DNQy7CkyH+KStAP708vtVx6u+4YT1FJlC5nlkqRYmdyDtkdmNDPr3sT igcFiyck+GNdi0MJWupYhZz+3BHEn4Ao7XhU8FJ3AAt+5s2Jvo8WJa06elRVnp4sFtj7 NMIOmObPUd42KhNjdqa/+U27dLye0QWCETvAxu9FlXOfrG/sipq9zq1N2q739b9csjKx vmlA== X-Gm-Message-State: APjAAAVr1R6kPZSaCMpVZB8MSYFIrHHQnX1rscqHzVD4R2AChOdF9oCM C+Wfj6jyhVmwHTxX62ud53zTR7ss X-Google-Smtp-Source: APXvYqzzJZBUZ7v1LUQa9xoDPfV7lj/BSTIdhGF3LKdjkfavHKcOtLjPYDjVINhJtKaifk5TNn/ChA== X-Received: by 2002:a5d:490f:: with SMTP id x15mr2238706wrq.375.1570016519252; Wed, 02 Oct 2019 04:41:59 -0700 (PDT) Received: from oberon.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id l4sm3004658wrw.6.2019.10.02.04.41.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2019 04:41:58 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v3 4/5] trace-cmd: Change plugin install directories Date: Wed, 2 Oct 2019 14:41:51 +0300 Message-Id: <20191002114152.30048-5-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191002114152.30048-1-tz.stoyanov@gmail.com> References: <20191002114152.30048-1-tz.stoyanov@gmail.com> MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org From: Tzvetomir Stoyanov To be compliant with XDG user directory layout, the user's plugin directory is changed from ~/.traceevent/plugins to ~/.local/lib/traceevent/plugins/ Thanks to Patrick McLean: https://lore.kernel.org/linux-trace-devel/20190313144206.41e75cf8@patrickm/ The system plugin directory is changed from (install_prefix)/lib/trace-cmd/plugins to (install_prefix)/lib/traceevent/plugins This change paves the way for implementing trace-cmd specific plugins. Suggested-by: Patrick McLean Signed-off-by: Tzvetomir Stoyanov (VMware) --- Makefile | 16 ++++++++-------- lib/traceevent/event-plugin.c | 6 +++--- lib/traceevent/plugins/Makefile | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index e20eced..cb5b07b 100644 --- a/Makefile +++ b/Makefile @@ -56,15 +56,15 @@ export img_install img_install_SQ export DESTDIR DESTDIR_SQ ifeq ($(prefix),$(HOME)) -plugin_dir = $(HOME)/.trace-cmd/plugins +plugin_traceevent_dir = $(HOME)/.local/lib/traceevent/plugins python_dir = $(HOME)/.trace-cmd/python var_dir = $(HOME)/.trace-cmd/ else -plugin_dir = $(libdir)/trace-cmd/plugins +plugin_traceevent_dir = $(libdir)/traceevent/plugins python_dir ?= $(libdir)/trace-cmd/python -PLUGIN_DIR = -DPLUGIN_DIR="$(plugin_dir)" +PLUGIN_DIR_TRACEEVENT = -DPLUGIN_TRACEEVENT_DIR="$(plugin_traceevent_dir)" PYTHON_DIR = -DPYTHON_DIR="$(python_dir)" -PLUGIN_DIR_SQ = '$(subst ','\'',$(PLUGIN_DIR))' +PLUGIN_DIR_TRACEEVENT_SQ = '$(subst ','\'',$(PLUGIN_DIR_TRACEEVENT))' PYTHON_DIR_SQ = '$(subst ','\'',$(PYTHON_DIR))' var_dir = /var endif @@ -72,7 +72,7 @@ endif # Shell quotes bindir_SQ = $(subst ','\'',$(bindir)) bindir_relative_SQ = $(subst ','\'',$(bindir_relative)) -plugin_dir_SQ = $(subst ','\'',$(plugin_dir)) +plugin_traceevent_dir_SQ = $(subst ','\'',$(plugin_traceevent_dir)) python_dir_SQ = $(subst ','\'',$(python_dir)) VAR_DIR = -DVAR_DIR="$(var_dir)" @@ -85,10 +85,10 @@ HELP_DIR_SQ = '$(subst ','\'',$(HELP_DIR))' BASH_COMPLETE_DIR ?= /etc/bash_completion.d -export PLUGIN_DIR +export PLUGIN_DIR_TRACEEVENT export PYTHON_DIR export PYTHON_DIR_SQ -export plugin_dir_SQ +export plugin_traceevent_dir_SQ export python_dir_SQ export var_dir @@ -239,7 +239,7 @@ LIBS += -laudit endif # Append required CFLAGS -override CFLAGS += $(INCLUDES) $(PLUGIN_DIR_SQ) $(VAR_DIR) +override CFLAGS += $(INCLUDES) $(PLUGIN_DIR_TRACEEVENT_SQ) $(VAR_DIR) override CFLAGS += $(udis86-flags) $(blk-flags) override LDFLAGS += $(udis86-ldflags) diff --git a/lib/traceevent/event-plugin.c b/lib/traceevent/event-plugin.c index 4fc4ee3..88cd5f0 100644 --- a/lib/traceevent/event-plugin.c +++ b/lib/traceevent/event-plugin.c @@ -20,7 +20,7 @@ #include "event-utils.h" #include "trace-seq.h" -#define LOCAL_PLUGIN_DIR ".traceevent/plugins" +#define LOCAL_PLUGIN_DIR ".local/lib/traceevent/plugins/" static struct registered_plugin_options { struct registered_plugin_options *next; @@ -579,9 +579,9 @@ void tep_load_plugins_hook(struct tep_handle *tep, const char *suffix, * If a system plugin directory was defined, * check that first. */ -#ifdef PLUGIN_DIR +#ifdef PLUGIN_TRACEEVENT_DIR if (!tep || !(tep->flags & TEP_DISABLE_SYS_PLUGINS)) - load_plugins_dir(tep, suffix, PLUGIN_DIR, + load_plugins_dir(tep, suffix, PLUGIN_TRACEEVENT_DIR, load_plugin, data); #endif diff --git a/lib/traceevent/plugins/Makefile b/lib/traceevent/plugins/Makefile index 061d919..4050019 100644 --- a/lib/traceevent/plugins/Makefile +++ b/lib/traceevent/plugins/Makefile @@ -53,11 +53,11 @@ $(bdir)/plugin_python_loader.so: $(bdir)/%.so: $(bdir)/%.o PLUGINS_INSTALL = $(subst .so,.install,$(PLUGINS)) $(PLUGINS_INSTALL): $(bdir)/%.install : $(bdir)/%.so force - $(Q)$(call do_install_data,$<,$(plugin_dir_SQ)) + $(Q)$(call do_install_data,$<,$(plugin_traceevent_dir_SQ)) install_plugins: $(PLUGINS_INSTALL) -# The following targets are necessary to trigger a rebuild when $(PLUGIN_DIR) +# The following targets are necessary to trigger a rebuild when $(PLUGIN_DIR_TRACEEVENT) # and $(PYTHON_DIR) change. Without them, a full clean build would necessary # in order to get the binaries updated. From patchwork Wed Oct 2 11:41:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tzvetomir Stoyanov (VMware)" X-Patchwork-Id: 11170921 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5073A13B1 for ; Wed, 2 Oct 2019 11:42:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 08FB021920 for ; Wed, 2 Oct 2019 11:42:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QLpTM2VS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727235AbfJBLmE (ORCPT ); Wed, 2 Oct 2019 07:42:04 -0400 Received: from mail-wm1-f44.google.com ([209.85.128.44]:38883 "EHLO mail-wm1-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726171AbfJBLmE (ORCPT ); Wed, 2 Oct 2019 07:42:04 -0400 Received: by mail-wm1-f44.google.com with SMTP id 3so6646185wmi.3 for ; Wed, 02 Oct 2019 04:42:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7jC/Qxisg2RgTzjcCIPAkCsLgEiCej9nREkzvpMcHGU=; b=QLpTM2VSKvlcX0EnLRwfZmopULUKoVQLt+Y2yhNSuS4oTw1IcfAAcFt6qOd2jfxeQl Y8t0sr6jSayiZf6Qo4HV2qzMSNtFGdnrKcTBtAoqgjivBHlnL7hOGkqVtpIFZ0QpY+7Y qJwSecokHnVusVCZfBqZh2TfDQL6yptxMMVYavsqbWul9yl5mq6dwlN1aP/CCMhg4/j0 oh5Ahqta1+1Pk+Ck7fmk+VmCcWdLS7JO7rKuf1NK9WemUXhp6SrT5PQtX+gKXx/qoLiO stCOkY2JCuVtMFgofDM0GfsIN1Kw0FmklObDMJMwkAmp0TooVEdgP8VuB0tVHOi3TqdK HCXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7jC/Qxisg2RgTzjcCIPAkCsLgEiCej9nREkzvpMcHGU=; b=pmqsqnpm1r+5YOBDibIp8qeu06xp0OszxYpWlBhjdvm+zvZKtH5DjUFIIwwnZHIMDD hNOkOFmCYr2j5Ug9/3LW5VuqqrpjyMvYIGqGl0hNCJP+jGTrPNx/veqrndjNqLq6WLAa GAslrJP752trBMMkg92EDisIgJESdKEwBH+tXn0QN/mvi1Ods02SCE4CHuQUqwO3Awml mm43g9WNM1ffB7ToCmlsEUxX8RsUDMpcAFRpoQ0pNP0UzERvqBntrMeusz/3ntADcl46 pvMLvWdiElnjrdBUwWm3/KiesHeCl9BSWJghn2W3MIp9doRO47mjrc6v9YZyJCesydTt dsYA== X-Gm-Message-State: APjAAAXrGz5k2Jed349l+c7az8k5DnXkc1DpT7QbU5U0Q2PO+fg8MCCp SdtT59R/Os2naB99IbFFso6UvrSR X-Google-Smtp-Source: APXvYqyS6Yrfe01byQi8cyrGd9frq3mS8c+v8hiUY8kpMBITq/EPHkXDzzrjpkhvlNjqEBh2LcvLkQ== X-Received: by 2002:a1c:7d8e:: with SMTP id y136mr2457993wmc.83.1570016520230; Wed, 02 Oct 2019 04:42:00 -0700 (PDT) Received: from oberon.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id l4sm3004658wrw.6.2019.10.02.04.41.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2019 04:41:59 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v3 5/5] trace-cmd: Add initial infrastructure for trace-cmd specific plugins. Date: Wed, 2 Oct 2019 14:41:52 +0300 Message-Id: <20191002114152.30048-6-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191002114152.30048-1-tz.stoyanov@gmail.com> References: <20191002114152.30048-1-tz.stoyanov@gmail.com> MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org Create a new directory lib/trace-cmd/plugins, where the libtracecmd plugins will be placed. Plugins compilation is integrated in the trace-cmd build process. New plugins are installed in $(HOME)/.local/lib/trace-cmd/plugins or $(libdir)/trace-cmd/plugins directories. Current python_plugin.so is part of libtraceevent plugins, so the python plugins path is changed from $(HOME)/.trace-cmd/python to $(HOME)/.local/lib/traceevent/python and $(libdir)/trace-cmd/python to $(libdir)/traceevent/python Added initial set of APIs for working with trace-cmd plugins Signed-off-by: Tzvetomir Stoyanov (VMware) --- .gitignore | 2 + Makefile | 45 +++-- include/trace-cmd/trace-cmd.h | 44 ++++- lib/trace-cmd/Makefile | 1 + lib/trace-cmd/plugins/Makefile | 58 ++++++ lib/trace-cmd/trace-plugin.c | 313 +++++++++++++++++++++++++++++++++ 6 files changed, 450 insertions(+), 13 deletions(-) create mode 100644 lib/trace-cmd/plugins/Makefile create mode 100644 lib/trace-cmd/trace-plugin.c diff --git a/.gitignore b/.gitignore index 20bb5a3..5a8800a 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,5 @@ TAGS cscope* traceevent_plugin_dir trace_python_dir +tracecmd_plugin_dir +python_dir diff --git a/Makefile b/Makefile index cb5b07b..dd7a84b 100644 --- a/Makefile +++ b/Makefile @@ -57,14 +57,18 @@ export DESTDIR DESTDIR_SQ ifeq ($(prefix),$(HOME)) plugin_traceevent_dir = $(HOME)/.local/lib/traceevent/plugins -python_dir = $(HOME)/.trace-cmd/python +plugin_tracecmd_dir = $(HOME)/.local/lib/trace-cmd/plugins +python_dir = $(HOME)/.local/lib/traceevent/python var_dir = $(HOME)/.trace-cmd/ else plugin_traceevent_dir = $(libdir)/traceevent/plugins -python_dir ?= $(libdir)/trace-cmd/python +plugin_tracecmd_dir = $(libdir)/trace-cmd/plugins +python_dir ?= $(libdir)/traceevent/python PLUGIN_DIR_TRACEEVENT = -DPLUGIN_TRACEEVENT_DIR="$(plugin_traceevent_dir)" +PLUGIN_DIR_TRACECMD = -DPLUGIN_TRACECMD_DIR="$(plugin_tracecmd_dir)" PYTHON_DIR = -DPYTHON_DIR="$(python_dir)" PLUGIN_DIR_TRACEEVENT_SQ = '$(subst ','\'',$(PLUGIN_DIR_TRACEEVENT))' +PLUGIN_DIR_TRACECMD_SQ = '$(subst ','\'',$(PLUGIN_DIR_TRACECMD))' PYTHON_DIR_SQ = '$(subst ','\'',$(PYTHON_DIR))' var_dir = /var endif @@ -73,6 +77,7 @@ endif bindir_SQ = $(subst ','\'',$(bindir)) bindir_relative_SQ = $(subst ','\'',$(bindir_relative)) plugin_traceevent_dir_SQ = $(subst ','\'',$(plugin_traceevent_dir)) +plugin_tracecmd_dir_SQ = $(subst ','\'',$(plugin_tracecmd_dir)) python_dir_SQ = $(subst ','\'',$(python_dir)) VAR_DIR = -DVAR_DIR="$(var_dir)" @@ -86,9 +91,11 @@ HELP_DIR_SQ = '$(subst ','\'',$(HELP_DIR))' BASH_COMPLETE_DIR ?= /etc/bash_completion.d export PLUGIN_DIR_TRACEEVENT +export PLUGIN_DIR_TRACECMD export PYTHON_DIR export PYTHON_DIR_SQ export plugin_traceevent_dir_SQ +export plugin_tracecmd_dir_SQ export python_dir_SQ export var_dir @@ -239,7 +246,8 @@ LIBS += -laudit endif # Append required CFLAGS -override CFLAGS += $(INCLUDES) $(PLUGIN_DIR_TRACEEVENT_SQ) $(VAR_DIR) +override CFLAGS += $(INCLUDES) $(VAR_DIR) +override CFLAGS += $(PLUGIN_DIR_TRACEEVENT_SQ) $(PLUGIN_DIR_TRACECMD_SQ) override CFLAGS += $(udis86-flags) $(blk-flags) override LDFLAGS += $(udis86-ldflags) @@ -268,13 +276,16 @@ gui: force $(CMD_TARGETS) $(kshark-dir)/build/Makefile @echo "gui build complete" @echo " kernelshark located at $(kshark-dir)/bin" -trace-cmd: force $(LIBTRACEEVENT_STATIC) $(LIBTRACECMD_STATIC) +trace-cmd: force $(LIBTRACEEVENT_STATIC) $(LIBTRACECMD_STATIC) \ + force $(obj)/lib/trace-cmd/plugins/tracecmd_plugin_dir $(Q)$(MAKE) -C $(src)/tracecmd $(obj)/tracecmd/$@ -$(LIBTRACEEVENT_SHARED): force $(obj)/lib/traceevent/plugins/traceevent_plugin_dir +$(LIBTRACEEVENT_SHARED): force $(obj)/lib/traceevent/plugins/python_dir \ + $(obj)/lib/traceevent/plugins/traceevent_plugin_dir $(Q)$(MAKE) -C $(src)/lib/traceevent $@ -$(LIBTRACEEVENT_STATIC): force $(obj)/lib/traceevent/plugins/traceevent_plugin_dir +$(LIBTRACEEVENT_STATIC): force $(obj)/lib/traceevent/plugins/python_dir \ + $(obj)/lib/traceevent/plugins/traceevent_plugin_dir $(Q)$(MAKE) -C $(src)/lib/traceevent $@ $(LIBTRACECMD_STATIC): force @@ -290,13 +301,22 @@ libtracecmd.so: $(LIBTRACECMD_SHARED) libs: $(LIBTRACECMD_SHARED) $(LIBTRACEEVENT_SHARED) -plugins: force $(obj)/lib/traceevent/plugins/traceevent_plugin_dir $(obj)/lib/traceevent/plugins/trace_python_dir +plugins_traceevent: force $(obj)/lib/traceevent/plugins/traceevent_plugin_dir \ + $(obj)/lib/traceevent/plugins/python_dir $(Q)$(MAKE) -C $(src)/lib/traceevent/plugins +plugins_tracecmd: force $(obj)/lib/trace-cmd/plugins/tracecmd_plugin_dir + $(Q)$(MAKE) -C $(src)/lib/trace-cmd/plugins + +plugins: plugins_traceevent plugins_tracecmd + $(obj)/lib/traceevent/plugins/traceevent_plugin_dir: force $(Q)$(MAKE) -C $(src)/lib/traceevent/plugins $@ -$(obj)/lib/traceevent/plugins/trace_python_dir: force +$(obj)/lib/trace-cmd/plugins/tracecmd_plugin_dir: force + $(Q)$(MAKE) -C $(src)/lib/trace-cmd/plugins $@ + +$(obj)/lib/traceevent/plugins/python_dir: force $(Q)$(MAKE) -C $(src)/lib/traceevent/plugins $@ show_gui_make: @@ -322,8 +342,12 @@ cscope: force $(RM) cscope* $(call find_tag_files) | cscope -b -q -install_plugins: force - $(Q)$(MAKE) -C $(src)/lib/traceevent/plugins $@ +install_plugins_traceevent: force + $(Q)$(MAKE) -C $(src)/lib/traceevent/plugins install_plugins +install_plugins_tracecmd: force + $(Q)$(MAKE) -C $(src)/lib/trace-cmd/plugins install_plugins + +install_plugins: install_plugins_traceevent install_plugins_tracecmd install_python: force $(Q)$(MAKE) -C $(src)/python $@ @@ -371,6 +395,7 @@ clean: $(MAKE) -C $(src)/lib/traceevent clean $(MAKE) -C $(src)/lib/trace-cmd clean $(MAKE) -C $(src)/lib/traceevent/plugins clean + $(MAKE) -C $(src)/lib/trace-cmd/plugins clean $(MAKE) -C $(src)/python clean $(MAKE) -C $(src)/tracecmd clean if [ -f $(kshark-dir)/build/Makefile ]; then $(MAKE) -C $(kshark-dir)/build clean; fi diff --git a/include/trace-cmd/trace-cmd.h b/include/trace-cmd/trace-cmd.h index 092bd89..6a182af 100644 --- a/include/trace-cmd/trace-cmd.h +++ b/include/trace-cmd/trace-cmd.h @@ -22,9 +22,6 @@ void tracecmd_parse_trace_clock(struct tep_handle *pevent, char *file, int size) void tracecmd_parse_proc_kallsyms(struct tep_handle *pevent, char *file, unsigned int size); void tracecmd_parse_ftrace_printk(struct tep_handle *pevent, char *file, unsigned int size); -extern int tracecmd_disable_sys_plugins; -extern int tracecmd_disable_plugins; - char **tracecmd_event_systems(const char *tracing_dir); char **tracecmd_system_events(const char *tracing_dir, const char *system); struct tep_handle *tracecmd_local_events(const char *tracing_dir); @@ -53,6 +50,47 @@ struct tracecmd_output; struct tracecmd_recorder; struct hook_list; +/* --- tracecmd plugins --- */ + +extern int tracecmd_disable_sys_plugins; +extern int tracecmd_disable_plugins; + +enum tracecmd_context { + TRACECMD_INPUT, + TRACECMD_OUTPUT, +}; + +enum tracecmd_plugin_flag { + TRACECMD_DISABLE_SYS_PLUGINS = 1, + TRACECMD_DISABLE_PLUGINS = 1 << 1, + +}; + +struct trace_plugin_context; + +struct trace_plugin_context * +tracecmd_plugin_context_create(enum tracecmd_context context, void *data); + +void tracecmd_plugin_set_flag(struct trace_plugin_context *context, + enum tracecmd_plugin_flag flag); + +#define TRACECMD_PLUGIN_LOADER tracecmd_plugin_loader +#define TRACECMD_PLUGIN_UNLOADER tracecmd_plugin_unloader +#define TRACECMD_PLUGIN_ALIAS tracecmd_plugin_alias +#define _MAKE_STR(x) #x +#define MAKE_STR(x) _MAKE_STR(x) +#define TRACECMD_PLUGIN_LOADER_NAME MAKE_STR(TRACECMD_PLUGIN_LOADER) +#define TRACECMD_PLUGIN_UNLOADER_NAME MAKE_STR(TRACECMD_PLUGIN_UNLOADER) +#define TRACECMD_PLUGIN_ALIAS_NAME MAKE_STR(TRACECMD_PLUGIN_ALIAS) + +typedef int (*tracecmd_plugin_load_func)(struct trace_plugin_context *trace); +typedef int (*tracecmd_plugin_unload_func)(struct trace_plugin_context *trace); + +struct tracecmd_input * +tracecmd_plugin_context_input(struct trace_plugin_context *trace_context); +struct tracecmd_output * +tracecmd_plugin_context_output(struct trace_plugin_context *trace_context); + static inline int tracecmd_host_bigendian(void) { unsigned char str[] = { 0x1, 0x2, 0x3, 0x4 }; diff --git a/lib/trace-cmd/Makefile b/lib/trace-cmd/Makefile index 3b4b5aa..6f3e6b1 100644 --- a/lib/trace-cmd/Makefile +++ b/lib/trace-cmd/Makefile @@ -15,6 +15,7 @@ OBJS += trace-recorder.o OBJS += trace-util.o OBJS += trace-filter-hash.o OBJS += trace-msg.o +OBJS += trace-plugin.o # Additional util objects OBJS += trace-blk-hack.o diff --git a/lib/trace-cmd/plugins/Makefile b/lib/trace-cmd/plugins/Makefile new file mode 100644 index 0000000..240e6be --- /dev/null +++ b/lib/trace-cmd/plugins/Makefile @@ -0,0 +1,58 @@ +include $(src)/scripts/utils.mk + +bdir:=$(obj)/lib/trace-cmd/plugins + +PLUGIN_OBJS = + +PLUGIN_OBJS := $(PLUGIN_OBJS:%.o=$(bdir)/%.o) +PLUGIN_BUILD := $(PLUGIN_OBJS:$(bdir)/%.o=$(bdir)/%.so) + +PLUGINS := $(PLUGIN_BUILD) + +DEPS := $(PLUGIN_OBJS:$(bdir)/%.o=$(bdir)/.%.d) + +all: $(PLUGINS) + +$(bdir): + @mkdir -p $(bdir) + +$(PLUGIN_OBJS): | $(bdir) +$(DEPS): | $(bdir) + +$(PLUGIN_OBJS): $(bdir)/%.o : %.c + $(Q)$(do_compile_plugin_obj) + +$(PLUGIN_BUILD): $(bdir)/%.so: $(bdir)/%.o + $(Q)$(do_plugin_build) + +$(DEPS): $(bdir)/.%.d: %.c + $(Q)$(CC) -M $(CPPFLAGS) $(CFLAGS) $< > $@ + +$(PLUGIN_OBJS): $(bdir)/%.o : $(bdir)/.%.d + +PLUGINS_INSTALL = $(subst .so,.install,$(PLUGINS)) + +$(PLUGINS_INSTALL): $(bdir)/%.install : $(bdir)/%.so force + $(Q)$(call do_install_data,$<,$(plugin_tracecmd_dir_SQ)) + +install_plugins: $(PLUGINS_INSTALL) + +# The following targets are necessary to trigger a rebuild when +# $(PLUGIN_DIR_TRACECMD) change. Without them, a full clean build would +# necessary in order to get the binaries updated. + +$(bdir)/tracecmd_plugin_dir: $(bdir) force + $(Q)$(N)$(call update_dir, 'PLUGIN_DIR_TRACECMD=$(PLUGIN_DIR_TRACECMD)') + +dep_includes := $(wildcard $(DEPS)) + +ifneq ($(dep_includes),) + include $(dep_includes) +endif + +clean: + $(RM) -f $(bdir)/*.a $(bdir)/*.so $(bdir)/*.o $(bdir)/.*.d\ + $(bdir)/tracecmd_plugin_dir + +force: +.PHONY: clean force diff --git a/lib/trace-cmd/trace-plugin.c b/lib/trace-cmd/trace-plugin.c new file mode 100644 index 0000000..6bec18b --- /dev/null +++ b/lib/trace-cmd/trace-plugin.c @@ -0,0 +1,313 @@ +// SPDX-License-Identifier: LGPL-2.1 +/* + * Copyright (C) 2009, 2010 Red Hat Inc, Steven Rostedt + * + */ +#include +#include +#include +#include +#include +#include "trace-cmd.h" +#include "trace-local.h" + +#define LOCAL_PLUGIN_DIR ".local/lib/trace-cmd/plugins/" + +struct trace_plugin_list { + struct trace_plugin_list *next; + char *name; + void *handle; +}; + +struct trace_plugin_context { + enum tracecmd_context context; + enum tracecmd_plugin_flag flags; + union { + void *data; + struct tracecmd_input *trace_input; + struct tracecmd_output *trace_output; + }; +}; + +/** + * tracecmd_plugin_context_create - Create and initialize tracecmd plugins context. + * @context: Context of the trace-cmd command. + * @data: Pointer to the context specific data, which will be passed to plugins. + * + * Returns a pointer to created tracecmd plugins context, or NULL in case memory + * allocation fails. The returned pointer should be freed by free (). + */ +struct trace_plugin_context * +tracecmd_plugin_context_create(enum tracecmd_context context, void *data) +{ + struct trace_plugin_context *trace; + + trace = calloc(1, sizeof(struct trace_plugin_context)); + if (!trace) + return NULL; + trace->context = context; + trace->data = data; + return trace; +} + +/** + * tracecmd_plugin_set_flag - Set a flag to tracecmd plugins context. + * @context: Context of the trace-cmd command. + * @flag: Flag, whil will be set. + * + */ +void tracecmd_plugin_set_flag(struct trace_plugin_context *context, + enum tracecmd_plugin_flag flag) +{ + if (context) + context->flags |= flag; +} + +/** + * tracecmd_plugin_context_input - Get a tracecmd_input plugin context. + * @context: Context of the trace-cmd command. + * + * Returns pointer to tracecmd_input, if such context is available or + * NULL otherwise. + */ +struct tracecmd_input * +tracecmd_plugin_context_input(struct trace_plugin_context *context) +{ + if (!context || context->context != TRACECMD_INPUT) + return NULL; + return context->trace_input; +} + +/** + * tracecmd_plugin_context_output - Get a tracecmd_output plugin context + * @context: Context of the trace-cmd command. + * + * Returns pointer to tracecmd_output, if such context is available or + * NULL otherwise. + */ +struct tracecmd_output * +tracecmd_plugin_context_output(struct trace_plugin_context *context) +{ + if (!context || context->context != TRACECMD_OUTPUT) + return NULL; + return context->trace_output; +} + +static void +load_plugin(struct trace_plugin_context *trace, const char *path, + const char *file, void *data) +{ + struct trace_plugin_list **plugin_list = data; + tracecmd_plugin_load_func func; + struct trace_plugin_list *list; + const char *alias; + char *plugin; + void *handle; + int ret; + + ret = asprintf(&plugin, "%s/%s", path, file); + if (ret < 0) { + warning("could not allocate plugin memory\n"); + return; + } + + handle = dlopen(plugin, RTLD_NOW | RTLD_GLOBAL); + if (!handle) { + warning("could not load plugin '%s'\n%s\n", + plugin, dlerror()); + goto out_free; + } + + alias = dlsym(handle, TRACECMD_PLUGIN_ALIAS_NAME); + if (!alias) + alias = file; + + func = dlsym(handle, TRACECMD_PLUGIN_LOADER_NAME); + if (!func) { + warning("could not find func '%s' in plugin '%s'\n%s\n", + TRACECMD_PLUGIN_LOADER_NAME, plugin, dlerror()); + goto out_free; + } + + list = malloc(sizeof(*list)); + if (!list) { + warning("could not allocate plugin memory\n"); + goto out_free; + } + + list->next = *plugin_list; + list->handle = handle; + list->name = plugin; + *plugin_list = list; + + pr_stat("registering plugin: %s", plugin); + func(trace); + return; + + out_free: + free(plugin); +} + +static void +load_plugins_dir(struct trace_plugin_context *trace, const char *suffix, + const char *path, + void (*load_plugin)(struct trace_plugin_context *trace, + const char *path, + const char *name, + void *data), + void *data) +{ + struct dirent *dent; + struct stat st; + DIR *dir; + int ret; + + ret = stat(path, &st); + if (ret < 0) + return; + + if (!S_ISDIR(st.st_mode)) + return; + + dir = opendir(path); + if (!dir) + return; + + while ((dent = readdir(dir))) { + const char *name = dent->d_name; + + if (strcmp(name, ".") == 0 || + strcmp(name, "..") == 0) + continue; + + /* Only load plugins that end in suffix */ + if (strcmp(name + (strlen(name) - strlen(suffix)), suffix) != 0) + continue; + + load_plugin(trace, path, name, data); + } + + closedir(dir); +} + +static char *get_source_plugins_dir(void) +{ + char *p, path[PATH_MAX+1]; + int ret; + + ret = readlink("/proc/self/exe", path, PATH_MAX); + if (ret > PATH_MAX || ret < 0) + return NULL; + + dirname(path); + p = strrchr(path, '/'); + if (!p) + return NULL; + /* Check if we are in the the source tree */ + if (strcmp(p, "/tracecmd") != 0) + return NULL; + + strcpy(p, "/lib/trace-cmd/plugins"); + return strdup(path); +} + +static void +load_plugins_hook(struct trace_plugin_context *trace, const char *suffix, + void (*load_plugin)(struct trace_plugin_context *trace, + const char *path, + const char *name, + void *data), + void *data) +{ + char *home; + char *path; + char *envdir; + int ret; + + if (trace && trace->flags & TRACECMD_DISABLE_PLUGINS) + return; + + /* + * If a system plugin directory was defined, + * check that first. + */ +#ifdef PLUGIN_TRACECMD_DIR + if (!trace || !(trace->flags & TRACECMD_DISABLE_SYS_PLUGINS)) + load_plugins_dir(trace, suffix, PLUGIN_TRACECMD_DIR, + load_plugin, data); +#endif + + /* + * Next let the environment-set plugin directory + * override the system defaults. + */ + envdir = getenv("TRACECMD_PLUGIN_DIR"); + if (envdir) + load_plugins_dir(trace, suffix, envdir, load_plugin, data); + + /* + * Now let the home directory override the environment + * or system defaults. + */ + home = getenv("HOME"); + if (!home) + return; + + ret = asprintf(&path, "%s/%s", home, LOCAL_PLUGIN_DIR); + if (ret < 0) { + warning("could not allocate plugin memory\n"); + return; + } + + load_plugins_dir(trace, suffix, path, load_plugin, data); + + free(path); + + path = get_source_plugins_dir(); + if (path) { + load_plugins_dir(trace, suffix, path, load_plugin, data); + free(path); + } +} + +/** + * tracecmd_load_plugins - Load trace-cmd specific plugins. + * @context: Context of the trace-cmd command, will be passed to the plugins + * at load time. + * + * Returns a list of loaded plugins + */ +struct trace_plugin_list* +tracecmd_load_plugins(struct trace_plugin_context *trace) +{ + struct trace_plugin_list *list = NULL; + + load_plugins_hook(trace, ".so", load_plugin, &list); + return list; +} + +/** + * tracecmd_unload_plugins - Unload trace-cmd specific plugins. + * @plugin_list - List of plugins, previously loaded with tracecmd_load_plugins. + * @context: Context of the trace-cmd command, will be passed to the plugins + * at unload time. + * + */ +void +tracecmd_unload_plugins(struct trace_plugin_list *plugin_list, + struct trace_plugin_context *trace) +{ + tracecmd_plugin_unload_func func; + struct trace_plugin_list *list; + + while (plugin_list) { + list = plugin_list; + plugin_list = list->next; + func = dlsym(list->handle, TRACECMD_PLUGIN_UNLOADER_NAME); + if (func) + func(trace); + dlclose(list->handle); + free(list->name); + free(list); + } +}