From patchwork Mon Nov 22 23:49:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 12633141 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 077DCC433EF for ; Mon, 22 Nov 2021 23:50:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231974AbhKVXxM (ORCPT ); Mon, 22 Nov 2021 18:53:12 -0500 Received: from ex13-edg-ou-002.vmware.com ([208.91.0.190]:7560 "EHLO EX13-EDG-OU-002.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231956AbhKVXxL (ORCPT ); Mon, 22 Nov 2021 18:53:11 -0500 Received: from sc9-mailhost1.vmware.com (10.113.161.71) by EX13-EDG-OU-002.vmware.com (10.113.208.156) with Microsoft SMTP Server id 15.0.1156.6; Mon, 22 Nov 2021 15:50:02 -0800 Received: from vypre.local.home (unknown [10.21.245.36]) by sc9-mailhost1.vmware.com (Postfix) with ESMTP id 0C3902037D; Mon, 22 Nov 2021 15:50:03 -0800 (PST) From: Steven Rostedt To: CC: "Steven Rostedt (VMware)" Subject: [PATCH 01/11] libtracefs: Move creation of sqlhist into new samples directory Date: Mon, 22 Nov 2021 18:49:46 -0500 Message-ID: <20211122234956.788401-2-rostedt@goodmis.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211122234956.788401-1-rostedt@goodmis.org> References: <20211122234956.788401-1-rostedt@goodmis.org> MIME-Version: 1.0 Received-SPF: None (EX13-EDG-OU-002.vmware.com: rostedt@goodmis.org does not designate permitted sender hosts) Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org From: "Steven Rostedt (VMware)" Move the creation of the sqlhist utility into the samples directory. This will be where other examples in the man pages will be extracted to create the samples. The executables will be added to a new bin/ directory as well as the intermediate files used to create the binaries. Signed-off-by: Steven Rostedt (VMware) --- Makefile | 13 +++++-------- samples/Makefile | 27 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 samples/Makefile diff --git a/Makefile b/Makefile index 7f382c3..7c96674 100644 --- a/Makefile +++ b/Makefile @@ -142,6 +142,7 @@ LIBS = $(LIBTRACEEVENT_LIBS) -lpthread export LIBS export LIBTRACEFS_STATIC LIBTRACEFS_SHARED +export LIBTRACEEVENT_LIBS LIBTRACEEVENT_INCLUDES export Q SILENT VERBOSE EXT @@ -364,21 +365,17 @@ $(bdir)/libtracefs.so.$(TRACEFS_VERSION): force $(Q)mkdir -p $(bdir) $(Q)$(MAKE) -C $(src)/src libtracefs.so -$(bdir)/sqlhist.c: Documentation/libtracefs-sql.txt - cat $< | sed -ne '/^EXAMPLE/,/FILES/ { /EXAMPLE/,+2d ; /^FILES/d ; /^--/d ; p}' > $@ +samples/sqlhist: $(LIBTRACEFS_STATIC) + $(Q)$(MAKE) -C $(src)/samples sqlhist -$(bdir)/sqlhist.o: $(bdir)/sqlhist.c - $(CC) -g -Wall -c -o $@ $^ -Iinclude/ $(LIBTRACEEVENT_INCLUDES) - -sqlhist: $(bdir)/sqlhist.o $(LIBTRACEFS_STATIC) - $(CC) -o $@ $^ $(LIBTRACEEVENT_LIBS) +sqlhist: samples/sqlhist clean: $(MAKE) -C $(src)/utest clean $(MAKE) -C $(src)/src clean + $(MAKE) -C $(src)/samples clean $(RM) $(TARGETS) $(bdir)/*.a $(bdir)/*.so $(bdir)/*.so.* $(bdir)/*.o $(bdir)/.*.d $(RM) $(PKG_CONFIG_FILE) $(RM) $(VERSION_FILE) - $(RM) $(bdir)/sqlhist.o $(bdir)/sqlhist.c sqlhist .PHONY: clean diff --git a/samples/Makefile b/samples/Makefile new file mode 100644 index 0000000..aae3e27 --- /dev/null +++ b/samples/Makefile @@ -0,0 +1,27 @@ +# SPDX-License-Identifier: LGPL-2.1 + +# +# The samples are pulled out of the examples used in the man pages +# that are located in the Documentation directory. +# + +include $(src)/scripts/utils.mk + +bdir := $(obj)/bin + +$(bdir): + @mkdir -p $(bdir) + +sqlhist: $(bdir) $(bdir) $(bdir)/sqlhist + +$(bdir)/sqlhist: $(bdir)/sqlhist.o $(LIBTRACEFS_STATIC) + $(CC) -o $@ $^ $(LIBTRACEEVENT_LIBS) + +$(bdir)/sqlhist.c: ../Documentation/libtracefs-sql.txt + cat $< | sed -ne '/^EXAMPLE/,/FILES/ { /EXAMPLE/,+2d ; /^FILES/d ; /^--/d ; p}' > $@ + +$(bdir)/sqlhist.o: $(bdir)/sqlhist.c + $(CC) -g -Wall -c -o $@ $^ -I../include/ $(LIBTRACEEVENT_INCLUDES) + +clean: + $(RM) $(bdir)/* From patchwork Mon Nov 22 23:49:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 12633147 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9ACF1C433FE for ; Mon, 22 Nov 2021 23:50:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231940AbhKVXxM (ORCPT ); Mon, 22 Nov 2021 18:53:12 -0500 Received: from ex13-edg-ou-002.vmware.com ([208.91.0.190]:7562 "EHLO EX13-EDG-OU-002.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231970AbhKVXxM (ORCPT ); Mon, 22 Nov 2021 18:53:12 -0500 Received: from sc9-mailhost1.vmware.com (10.113.161.71) by EX13-EDG-OU-002.vmware.com (10.113.208.156) with Microsoft SMTP Server id 15.0.1156.6; Mon, 22 Nov 2021 15:50:02 -0800 Received: from vypre.local.home (unknown [10.21.245.36]) by sc9-mailhost1.vmware.com (Postfix) with ESMTP id B7C8720374; Mon, 22 Nov 2021 15:50:04 -0800 (PST) From: Steven Rostedt To: CC: "Steven Rostedt (VMware)" Subject: [PATCH 02/11] libtracefs: Fix example in the dynamic events man page to compile Date: Mon, 22 Nov 2021 18:49:47 -0500 Message-ID: <20211122234956.788401-3-rostedt@goodmis.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211122234956.788401-1-rostedt@goodmis.org> References: <20211122234956.788401-1-rostedt@goodmis.org> MIME-Version: 1.0 Received-SPF: None (EX13-EDG-OU-002.vmware.com: rostedt@goodmis.org does not designate permitted sender hosts) Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org From: "Steven Rostedt (VMware)" The example in the dynamic events man page fails to compile because it references an "err" variable without declaring it. Declare it so that the example will compile. Signed-off-by: Steven Rostedt (VMware) --- Documentation/libtracefs-dynevents.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/libtracefs-dynevents.txt b/Documentation/libtracefs-dynevents.txt index 25172c3..503bd7e 100644 --- a/Documentation/libtracefs-dynevents.txt +++ b/Documentation/libtracefs-dynevents.txt @@ -182,7 +182,7 @@ int main (int argc, char **argv, char **env) } if (tracefs_dynevent_create(kprobe) || tracefs_dynevent_create(kretprobe)){ - err = tracefs_error_last(NULL); + char *err = tracefs_error_last(NULL); perror("Failed to create kprobes:"); if (err && strlen(err)) fprintf(stderr, "%s\n", err); From patchwork Mon Nov 22 23:49:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 12633149 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A9EEC4332F for ; Mon, 22 Nov 2021 23:50:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231917AbhKVXxN (ORCPT ); Mon, 22 Nov 2021 18:53:13 -0500 Received: from ex13-edg-ou-001.vmware.com ([208.91.0.189]:32620 "EHLO EX13-EDG-OU-001.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231938AbhKVXxN (ORCPT ); Mon, 22 Nov 2021 18:53:13 -0500 Received: from sc9-mailhost1.vmware.com (10.113.161.71) by EX13-EDG-OU-001.vmware.com (10.113.208.155) with Microsoft SMTP Server id 15.0.1156.6; Mon, 22 Nov 2021 15:50:03 -0800 Received: from vypre.local.home (unknown [10.21.245.36]) by sc9-mailhost1.vmware.com (Postfix) with ESMTP id 7670320349; Mon, 22 Nov 2021 15:50:05 -0800 (PST) From: Steven Rostedt To: CC: "Steven Rostedt (VMware)" Subject: [PATCH 03/11] libtracefs/Documentation: Fix man page examples to include the proper header Date: Mon, 22 Nov 2021 18:49:48 -0500 Message-ID: <20211122234956.788401-4-rostedt@goodmis.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211122234956.788401-1-rostedt@goodmis.org> References: <20211122234956.788401-1-rostedt@goodmis.org> MIME-Version: 1.0 Received-SPF: None (EX13-EDG-OU-001.vmware.com: rostedt@goodmis.org does not designate permitted sender hosts) Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org From: "Steven Rostedt (VMware)" It's #include not #include as the pkg-config will give the full path to the include headers. Anything else will not build properly. Signed-off-by: Steven Rostedt (VMware) --- Documentation/libtracefs-dynevents.txt | 2 +- Documentation/libtracefs-eprobes.txt | 2 +- Documentation/libtracefs-error.txt | 2 +- Documentation/libtracefs-hist-cont.txt | 2 +- Documentation/libtracefs-hist.txt | 2 +- Documentation/libtracefs-kprobes.txt | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Documentation/libtracefs-dynevents.txt b/Documentation/libtracefs-dynevents.txt index 503bd7e..89b2e92 100644 --- a/Documentation/libtracefs-dynevents.txt +++ b/Documentation/libtracefs-dynevents.txt @@ -101,7 +101,7 @@ EXAMPLE #include #include -#include +#include static struct tep_event *open_event; static struct tep_format_field *file_field; diff --git a/Documentation/libtracefs-eprobes.txt b/Documentation/libtracefs-eprobes.txt index 3baaea3..65e5b13 100644 --- a/Documentation/libtracefs-eprobes.txt +++ b/Documentation/libtracefs-eprobes.txt @@ -41,7 +41,7 @@ EXAMPLE #include #include -#include +#include static struct tep_event *open_event; static struct tep_format_field *file_field; diff --git a/Documentation/libtracefs-error.txt b/Documentation/libtracefs-error.txt index 3f6a154..33af074 100644 --- a/Documentation/libtracefs-error.txt +++ b/Documentation/libtracefs-error.txt @@ -48,7 +48,7 @@ EXAMPLE #include #include -#include +#include int main (int argc, char **argv, char **env) { diff --git a/Documentation/libtracefs-hist-cont.txt b/Documentation/libtracefs-hist-cont.txt index 2ee830d..778b8ee 100644 --- a/Documentation/libtracefs-hist-cont.txt +++ b/Documentation/libtracefs-hist-cont.txt @@ -51,7 +51,7 @@ EXAMPLE [source,c] -- #include -#include +#include enum commands { START, diff --git a/Documentation/libtracefs-hist.txt b/Documentation/libtracefs-hist.txt index cc6b859..c07fe6f 100644 --- a/Documentation/libtracefs-hist.txt +++ b/Documentation/libtracefs-hist.txt @@ -222,7 +222,7 @@ EXAMPLE [source,c] -- #include -#include +#include enum commands { START, diff --git a/Documentation/libtracefs-kprobes.txt b/Documentation/libtracefs-kprobes.txt index 4a4bf01..e488f9a 100644 --- a/Documentation/libtracefs-kprobes.txt +++ b/Documentation/libtracefs-kprobes.txt @@ -89,7 +89,7 @@ EXAMPLE #include #include -#include +#include static struct tep_event *open_event; static struct tep_format_field *file_field; From patchwork Mon Nov 22 23:49:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 12633145 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD413C43217 for ; Mon, 22 Nov 2021 23:50:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231937AbhKVXxO (ORCPT ); Mon, 22 Nov 2021 18:53:14 -0500 Received: from ex13-edg-ou-001.vmware.com ([208.91.0.189]:32625 "EHLO EX13-EDG-OU-001.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231894AbhKVXxN (ORCPT ); Mon, 22 Nov 2021 18:53:13 -0500 Received: from sc9-mailhost1.vmware.com (10.113.161.71) by EX13-EDG-OU-001.vmware.com (10.113.208.155) with Microsoft SMTP Server id 15.0.1156.6; Mon, 22 Nov 2021 15:50:04 -0800 Received: from vypre.local.home (unknown [10.21.245.36]) by sc9-mailhost1.vmware.com (Postfix) with ESMTP id 2B72420348; Mon, 22 Nov 2021 15:50:06 -0800 (PST) From: Steven Rostedt To: CC: "Steven Rostedt (VMware)" Subject: [PATCH 04/11] tracefs/Documentation: Fix example in libtracefs-eprobes.txt to compile Date: Mon, 22 Nov 2021 18:49:49 -0500 Message-ID: <20211122234956.788401-5-rostedt@goodmis.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211122234956.788401-1-rostedt@goodmis.org> References: <20211122234956.788401-1-rostedt@goodmis.org> MIME-Version: 1.0 Received-SPF: None (EX13-EDG-OU-001.vmware.com: rostedt@goodmis.org does not designate permitted sender hosts) Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org From: "Steven Rostedt (VMware)" The example program in libtracefs-eprobes.txt man page did not compile, and had a warning. Fix the mykprobe string, and remove the unused label. Signed-off-by: Steven Rostedt (VMware) --- Documentation/libtracefs-eprobes.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Documentation/libtracefs-eprobes.txt b/Documentation/libtracefs-eprobes.txt index 65e5b13..4155544 100644 --- a/Documentation/libtracefs-eprobes.txt +++ b/Documentation/libtracefs-eprobes.txt @@ -62,8 +62,6 @@ static int callback(struct tep_event *event, struct tep_record *record, trace_seq_terminate(&seq); trace_seq_do_printf(&seq); - -out: trace_seq_destroy(&seq); return 0; @@ -89,7 +87,7 @@ int main (int argc, char **argv, char **env) struct tracefs_dynevent *eprobe; struct tracefs_instance *instance; struct tep_handle *tep; - const char *sysnames[] = { mykprobe, NULL }; + const char *sysnames[] = { myprobe, NULL }; pid_t pid; if (argc < 2) { From patchwork Mon Nov 22 23:49:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 12633151 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4CE5EC43219 for ; Mon, 22 Nov 2021 23:50:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231938AbhKVXxO (ORCPT ); Mon, 22 Nov 2021 18:53:14 -0500 Received: from ex13-edg-ou-001.vmware.com ([208.91.0.189]:32627 "EHLO EX13-EDG-OU-001.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231894AbhKVXxO (ORCPT ); Mon, 22 Nov 2021 18:53:14 -0500 Received: from sc9-mailhost1.vmware.com (10.113.161.71) by EX13-EDG-OU-001.vmware.com (10.113.208.155) with Microsoft SMTP Server id 15.0.1156.6; Mon, 22 Nov 2021 15:50:05 -0800 Received: from vypre.local.home (unknown [10.21.245.36]) by sc9-mailhost1.vmware.com (Postfix) with ESMTP id E078E20355; Mon, 22 Nov 2021 15:50:06 -0800 (PST) From: Steven Rostedt To: CC: "Steven Rostedt (VMware)" Subject: [PATCH 05/11] libtracefs: Make samples easily extract man page example programs Date: Mon, 22 Nov 2021 18:49:50 -0500 Message-ID: <20211122234956.788401-6-rostedt@goodmis.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211122234956.788401-1-rostedt@goodmis.org> References: <20211122234956.788401-1-rostedt@goodmis.org> MIME-Version: 1.0 Received-SPF: None (EX13-EDG-OU-001.vmware.com: rostedt@goodmis.org does not designate permitted sender hosts) Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org From: "Steven Rostedt (VMware)" Have the Makefile in the samples directory extract examples out of the man pages and create them as executables in the bin directory. This adds the infrastructure to do so, and includes the dynevent example. Signed-off-by: Steven Rostedt (VMware) --- Makefile | 3 +++ samples/Makefile | 26 +++++++++++++++++++++----- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 7c96674..85b3c39 100644 --- a/Makefile +++ b/Makefile @@ -370,6 +370,9 @@ samples/sqlhist: $(LIBTRACEFS_STATIC) sqlhist: samples/sqlhist +samples: $(LIBTRACEFS_STATIC) force + $(Q)$(MAKE) -C $(src)/samples all + clean: $(MAKE) -C $(src)/utest clean $(MAKE) -C $(src)/src clean diff --git a/samples/Makefile b/samples/Makefile index aae3e27..53b6630 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -7,20 +7,36 @@ include $(src)/scripts/utils.mk +TARGETS := +TARGETS += sqlhist +TARGETS += dynevent + bdir := $(obj)/bin +all: $(TARGETS) + +extract_example = \ + cat $1 | sed -ne '/^EXAMPLE/,/FILES/ { /EXAMPLE/,+2d ; /^FILES/d ; /^--/d ; p}' > $2 + +$(bdir)/sqlhist.c: ../Documentation/libtracefs-sql.txt + $(call extract_example,$<,$@) + +$(bdir)/dynevent.c: ../Documentation/libtracefs-dynevents.txt + $(call extract_example,$<,$@) + $(bdir): @mkdir -p $(bdir) sqlhist: $(bdir) $(bdir) $(bdir)/sqlhist -$(bdir)/sqlhist: $(bdir)/sqlhist.o $(LIBTRACEFS_STATIC) - $(CC) -o $@ $^ $(LIBTRACEEVENT_LIBS) +$(TARGETS): $(bdir) -$(bdir)/sqlhist.c: ../Documentation/libtracefs-sql.txt - cat $< | sed -ne '/^EXAMPLE/,/FILES/ { /EXAMPLE/,+2d ; /^FILES/d ; /^--/d ; p}' > $@ +$(bdir)/%: $(bdir)/%.o + $(CC) -o $@ $^ $(LIBTRACEFS_STATIC) $(LIBTRACEEVENT_LIBS) + +$(TARGETS): $(patsubst %,$(bdir)/%,$(TARGETS)) -$(bdir)/sqlhist.o: $(bdir)/sqlhist.c +$(bdir)/%.o: %.c $(CC) -g -Wall -c -o $@ $^ -I../include/ $(LIBTRACEEVENT_INCLUDES) clean: From patchwork Mon Nov 22 23:49:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 12633153 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24234C433F5 for ; Mon, 22 Nov 2021 23:50:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231952AbhKVXxP (ORCPT ); Mon, 22 Nov 2021 18:53:15 -0500 Received: from ex13-edg-ou-001.vmware.com ([208.91.0.189]:32629 "EHLO EX13-EDG-OU-001.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231950AbhKVXxP (ORCPT ); Mon, 22 Nov 2021 18:53:15 -0500 Received: from sc9-mailhost1.vmware.com (10.113.161.71) by EX13-EDG-OU-001.vmware.com (10.113.208.155) with Microsoft SMTP Server id 15.0.1156.6; Mon, 22 Nov 2021 15:50:05 -0800 Received: from vypre.local.home (unknown [10.21.245.36]) by sc9-mailhost1.vmware.com (Postfix) with ESMTP id 9357020348; Mon, 22 Nov 2021 15:50:07 -0800 (PST) From: Steven Rostedt To: CC: "Steven Rostedt (VMware)" Subject: [PATCH 06/11] libtracefs: Add new API tracefs_dynevent_get() Date: Mon, 22 Nov 2021 18:49:51 -0500 Message-ID: <20211122234956.788401-7-rostedt@goodmis.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211122234956.788401-1-rostedt@goodmis.org> References: <20211122234956.788401-1-rostedt@goodmis.org> MIME-Version: 1.0 Received-SPF: None (EX13-EDG-OU-001.vmware.com: rostedt@goodmis.org does not designate permitted sender hosts) Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org From: "Steven Rostedt (VMware)" Add tracefs_dynevent_get() that allows the user to look for a single event, and not have to get all events in the system. Signed-off-by: Steven Rostedt (VMware) --- Documentation/libtracefs-dynevents.txt | 10 ++++++ include/tracefs.h | 2 ++ src/tracefs-dynevents.c | 45 ++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) diff --git a/Documentation/libtracefs-dynevents.txt b/Documentation/libtracefs-dynevents.txt index 89b2e92..a374651 100644 --- a/Documentation/libtracefs-dynevents.txt +++ b/Documentation/libtracefs-dynevents.txt @@ -20,6 +20,7 @@ int *tracefs_dynevent_destroy*(struct tracefs_dynevent pass:[*]_devent_, bool _f int *tracefs_dynevent_destroy_all*(unsigned int _types_, bool _force_); void *tracefs_dynevent_free*(struct tracefs_dynevent pass:[*]_devent_); void *tracefs_dynevent_list_free*(struct tracefs_dynevent pass:[*]pass:[*]_events_); +struct tracefs_dynevent pass:[*]*tracefs_dynevent_get*(enum tracefs_dynevent_type _type_, const char pass:[*]_system_, const char pass:[*]_event_); struct tracefs_dynevent pass:[*]pass:[*]*tracefs_dynevent_get_all*(unsigned int _types_, const char pass:[*]_system_); enum tracefs_dynevent_type *tracefs_dynevent_info*(struct tracefs_dynevent pass:[*]_dynevent_, char pass:[*]pass:[*]_system_, char pass:[*]pass:[*]_event_, char pass:[*]pass:[*]_prefix_, char pass:[*]pass:[*]_addr_, char pass:[*]pass:[*]_format_); -- @@ -39,6 +40,12 @@ types *tracefs_dynevent_type*, that will be removed. If _types_ is 0, dynamic ev will be removed. If _force_ is true, the function will attempt to disable all events in all trace instances, before removing the dynamic events. +The *tracefs_dynevent_get*() function allocates and returns a single instance of a dynamic +event that matches the given *type*, *system* and *event* that is passed to it. NULL is returned +if there is no match. The returned event is what is found in the system, and must be freed +with *tracefs_dynevent_free*(). If *system* is NULL, then the first *event* of any system +of the given type that has the name of *event* will be returned. + The *tracefs_dynevent_get_all*() function allocates and returns an array of pointers to dynamic events of given types that exist in the system. The last element of the array is a NULL pointer. The array must be freed with *tracefs_dynevent_list_free*(). If there are no events a NULL pointer is @@ -70,6 +77,9 @@ RETURN VALUE *tracefs_dynevent_destroy*() and *tracefs_dynevent_destroy_all*() return 0 on success, or -1 on error. If _force_ is enabled, the functions may fail on disabling the events. +*tracefs_dynevent_get*() function returns an allocated dynamic event from the system that matches +the type, system and event given. + *tracefs_dynevent_get_all*() function returns allocated array of pointers to dynamic events, or NULL in case of an error or in case there are no events in the system. That array must be freed by *tracefs_dynevent_list_free*(). diff --git a/include/tracefs.h b/include/tracefs.h index 81efe87..2ced45c 100644 --- a/include/tracefs.h +++ b/include/tracefs.h @@ -257,6 +257,8 @@ void tracefs_dynevent_free(struct tracefs_dynevent *devent); void tracefs_dynevent_list_free(struct tracefs_dynevent **events); struct tracefs_dynevent ** tracefs_dynevent_get_all(unsigned int types, const char *system); +struct tracefs_dynevent * +tracefs_dynevent_get(enum tracefs_dynevent_type type, const char *system, const char *event); enum tracefs_dynevent_type tracefs_dynevent_info(struct tracefs_dynevent *dynevent, char **system, char **event, char **prefix, char **addr, char **format); diff --git a/src/tracefs-dynevents.c b/src/tracefs-dynevents.c index 0f7cccd..ea07d13 100644 --- a/src/tracefs-dynevents.c +++ b/src/tracefs-dynevents.c @@ -596,6 +596,51 @@ error: return NULL; } +/** + * tracefs_dynevent_get - return a single dynamic event if it exists + * @type; Dynamic event type + * @system: Get events from that system only. May be NULL. + * @event: Get event of the system type (may not be NULL) + * + * Returns the dynamic event of the given @type and @system for with the @event + * name. If @system is NULL, it will return the first dynamic event that it finds + * that matches the @event name. + * + * The returned event must be freed with tracefs_dynevent_free(). + * NULL is returned if no event match is found, or other error. + */ +struct tracefs_dynevent * +tracefs_dynevent_get(enum tracefs_dynevent_type type, const char *system, + const char *event) +{ + struct tracefs_dynevent **events; + struct tracefs_dynevent *devent = NULL; + int count; + int i; + + if (!event) { + errno = -EINVAL; + return NULL; + } + + count = get_all_dynevents(type, system, &events); + if (count <= 0) + return NULL; + + for (i = 0; i < count; i++) { + if (strcmp(events[i]->event, event) == 0) + break; + } + if (i < count) { + devent = events[i]; + events[i] = NULL; + } + + tracefs_dynevent_list_free(events); + + return devent; +} + /** * tracefs_dynevent_destroy_all - removes all dynamic events of given types from the system * @types: Dynamic event type, or bitmask of dynamic event types. If 0 is passed, all types From patchwork Mon Nov 22 23:49:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 12633155 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 120D4C43217 for ; Mon, 22 Nov 2021 23:50:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231956AbhKVXxQ (ORCPT ); Mon, 22 Nov 2021 18:53:16 -0500 Received: from ex13-edg-ou-001.vmware.com ([208.91.0.189]:32630 "EHLO EX13-EDG-OU-001.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231953AbhKVXxP (ORCPT ); Mon, 22 Nov 2021 18:53:15 -0500 Received: from sc9-mailhost1.vmware.com (10.113.161.71) by EX13-EDG-OU-001.vmware.com (10.113.208.155) with Microsoft SMTP Server id 15.0.1156.6; Mon, 22 Nov 2021 15:50:06 -0800 Received: from vypre.local.home (unknown [10.21.245.36]) by sc9-mailhost1.vmware.com (Postfix) with ESMTP id 4B37B20364; Mon, 22 Nov 2021 15:50:08 -0800 (PST) From: Steven Rostedt To: CC: "Steven Rostedt (VMware)" Subject: [PATCH 07/11] libtracefs/Documentation: Fix example in libtracefs-error.txt Date: Mon, 22 Nov 2021 18:49:52 -0500 Message-ID: <20211122234956.788401-8-rostedt@goodmis.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211122234956.788401-1-rostedt@goodmis.org> References: <20211122234956.788401-1-rostedt@goodmis.org> MIME-Version: 1.0 Received-SPF: None (EX13-EDG-OU-001.vmware.com: rostedt@goodmis.org does not designate permitted sender hosts) Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org From: "Steven Rostedt (VMware)" The example code in libtracefs-error.txt man page referenced the old tracefs_kprobe_clear_probe() API that no longer exists. Update it to use the new tracefs_dynevent_get() and the tracefs_dynevent_destroy() API to do the same thing. Signed-off-by: Steven Rostedt (VMware) --- Documentation/libtracefs-error.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Documentation/libtracefs-error.txt b/Documentation/libtracefs-error.txt index 33af074..8dd5b42 100644 --- a/Documentation/libtracefs-error.txt +++ b/Documentation/libtracefs-error.txt @@ -52,6 +52,7 @@ EXAMPLE int main (int argc, char **argv, char **env) { + struct tracefs_dynevent *kevent; char *system = NULL; char *kprobe; char *format; @@ -72,7 +73,11 @@ int main (int argc, char **argv, char **env) format = argv[arg++]; tracefs_error_clear(NULL); - tracefs_kprobe_clear_probe(system, kprobe, true); + kevent = tracefs_dynevent_get(TRACEFS_DYNEVENT_KPROBE, system, kprobe); + if (kevent) { + tracefs_dynevent_destroy(kevent, true); + tracefs_dynevent_free(kevent); + } ret = tracefs_kprobe_raw(system, kprobe, addr, format); if (ret < 0) { From patchwork Mon Nov 22 23:49:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 12633157 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91515C433F5 for ; Mon, 22 Nov 2021 23:50:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231976AbhKVXxR (ORCPT ); Mon, 22 Nov 2021 18:53:17 -0500 Received: from ex13-edg-ou-001.vmware.com ([208.91.0.189]:32631 "EHLO EX13-EDG-OU-001.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231950AbhKVXxQ (ORCPT ); Mon, 22 Nov 2021 18:53:16 -0500 Received: from sc9-mailhost1.vmware.com (10.113.161.71) by EX13-EDG-OU-001.vmware.com (10.113.208.155) with Microsoft SMTP Server id 15.0.1156.6; Mon, 22 Nov 2021 15:50:07 -0800 Received: from vypre.local.home (unknown [10.21.245.36]) by sc9-mailhost1.vmware.com (Postfix) with ESMTP id F1A3E20349; Mon, 22 Nov 2021 15:50:08 -0800 (PST) From: Steven Rostedt To: CC: "Steven Rostedt (VMware)" Subject: [PATCH 08/11] libtracefs/Documentation: Fix function-filter call to tracefs_list_free() Date: Mon, 22 Nov 2021 18:49:53 -0500 Message-ID: <20211122234956.788401-9-rostedt@goodmis.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211122234956.788401-1-rostedt@goodmis.org> References: <20211122234956.788401-1-rostedt@goodmis.org> MIME-Version: 1.0 Received-SPF: None (EX13-EDG-OU-001.vmware.com: rostedt@goodmis.org does not designate permitted sender hosts) Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org From: "Steven Rostedt (VMware)" The function-filter man page example used tracefs_free_list() instead of tracefs_list_free() Signed-off-by: Steven Rostedt (VMware) --- Documentation/libtracefs-function-filter.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/libtracefs-function-filter.txt b/Documentation/libtracefs-function-filter.txt index ac43d9b..23ba2b8 100644 --- a/Documentation/libtracefs-function-filter.txt +++ b/Documentation/libtracefs-function-filter.txt @@ -152,7 +152,7 @@ int main(int argc, char *argv[]) printf("Ignoring the following functions:\n"); for (i = 0; func_list[i]; i++) printf(" %s\n", func_list[i]); - tracefs_free_list(func_list); + tracefs_list_free(func_list); /* Do not trace any function with the word "lock" in it */ ret = tracefs_function_notrace(inst, "*lock*", NULL, TRACEFS_FL_RESET); From patchwork Mon Nov 22 23:49:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 12633159 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 752BFC433FE for ; Mon, 22 Nov 2021 23:50:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232010AbhKVXxT (ORCPT ); Mon, 22 Nov 2021 18:53:19 -0500 Received: from ex13-edg-ou-002.vmware.com ([208.91.0.190]:7565 "EHLO EX13-EDG-OU-002.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231970AbhKVXxR (ORCPT ); Mon, 22 Nov 2021 18:53:17 -0500 Received: from sc9-mailhost1.vmware.com (10.113.161.71) by EX13-EDG-OU-002.vmware.com (10.113.208.156) with Microsoft SMTP Server id 15.0.1156.6; Mon, 22 Nov 2021 15:50:07 -0800 Received: from vypre.local.home (unknown [10.21.245.36]) by sc9-mailhost1.vmware.com (Postfix) with ESMTP id B28DB20250; Mon, 22 Nov 2021 15:50:09 -0800 (PST) From: Steven Rostedt To: CC: "Steven Rostedt (VMware)" Subject: [PATCH 09/11] libtracefs/Documentation: Update libtracefs-hist-cont.txt to new API Date: Mon, 22 Nov 2021 18:49:54 -0500 Message-ID: <20211122234956.788401-10-rostedt@goodmis.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211122234956.788401-1-rostedt@goodmis.org> References: <20211122234956.788401-1-rostedt@goodmis.org> MIME-Version: 1.0 Received-SPF: None (EX13-EDG-OU-002.vmware.com: rostedt@goodmis.org does not designate permitted sender hosts) Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org From: "Steven Rostedt (VMware)" The histogram API has changed. Update the man page example to reflect that. Signed-off-by: Steven Rostedt (VMware) --- Documentation/libtracefs-hist-cont.txt | 27 +++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/Documentation/libtracefs-hist-cont.txt b/Documentation/libtracefs-hist-cont.txt index 778b8ee..5cdcc0a 100644 --- a/Documentation/libtracefs-hist-cont.txt +++ b/Documentation/libtracefs-hist-cont.txt @@ -66,6 +66,7 @@ int main (int argc, char **argv, char **env) { struct tracefs_instance *instance; struct tracefs_hist *hist; + struct tep_handle *tep; enum commands cmd; char *cmd_str; int ret; @@ -94,22 +95,29 @@ int main (int argc, char **argv, char **env) exit(-1); } + tep = tracefs_local_events(NULL); + if (!tep) { + perror("Reading tracefs"); + exit(-1); + } + instance = tracefs_instance_create("hist_test"); if (!instance) { fprintf(stderr, "Failed instance create\n"); exit(-1); } - hist = tracefs_hist_alloc(instance, "kmem", "kmalloc", - "call_site", TRACEFS_HIST_KEY_SYM, - "bytes_req", 0); + hist = tracefs_hist2d_alloc(tep, "kmem", "kmalloc", + "call_site",TRACEFS_HIST_KEY_SYM, + "bytes_req", 0); if (!hist) { fprintf(stderr, "Failed hist create\n"); exit(-1); } ret = tracefs_hist_add_value(hist, "bytes_alloc"); - ret |= tracefs_hist_add_sort_key(hist, "bytes_req", "bytes_alloc", NULL); + ret |= tracefs_hist_add_sort_key(hist, "bytes_req"); + ret |= tracefs_hist_add_sort_key(hist, "bytes_alloc"); ret |= tracefs_hist_sort_key_direction(hist, "bytes_alloc", TRACEFS_HIST_SORT_DESCENDING); @@ -122,7 +130,7 @@ int main (int argc, char **argv, char **env) switch (cmd) { case START: - ret = tracefs_hist_start(hist); + ret = tracefs_hist_start(instance, hist); if (ret) { char *err = tracefs_error_last(instance); if (err) @@ -130,16 +138,16 @@ int main (int argc, char **argv, char **env) } break; case PAUSE: - ret = tracefs_hist_pause(hist); + ret = tracefs_hist_pause(instance, hist); break; case CONT: - ret = tracefs_hist_continue(hist); + ret = tracefs_hist_continue(instance, hist); break; case RESET: - ret = tracefs_hist_reset(hist); + ret = tracefs_hist_reset(instance, hist); break; case DELETE: - ret = tracefs_hist_destroy(hist); + ret = tracefs_hist_destroy(instance, hist); break; case SHOW: { char *content; @@ -157,6 +165,7 @@ int main (int argc, char **argv, char **env) fprintf(stderr, "Failed: command\n"); exit(ret); } + -- FILES From patchwork Mon Nov 22 23:49:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 12633161 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 349D9C4332F for ; Mon, 22 Nov 2021 23:50:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231894AbhKVXxV (ORCPT ); Mon, 22 Nov 2021 18:53:21 -0500 Received: from ex13-edg-ou-002.vmware.com ([208.91.0.190]:7566 "EHLO EX13-EDG-OU-002.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232002AbhKVXxS (ORCPT ); Mon, 22 Nov 2021 18:53:18 -0500 Received: from sc9-mailhost1.vmware.com (10.113.161.71) by EX13-EDG-OU-002.vmware.com (10.113.208.156) with Microsoft SMTP Server id 15.0.1156.6; Mon, 22 Nov 2021 15:50:08 -0800 Received: from vypre.local.home (unknown [10.21.245.36]) by sc9-mailhost1.vmware.com (Postfix) with ESMTP id 674C120250; Mon, 22 Nov 2021 15:50:10 -0800 (PST) From: Steven Rostedt To: CC: "Steven Rostedt (VMware)" Subject: [PATCH 10/11] libtracefs: Add all working man page examples to samples Date: Mon, 22 Nov 2021 18:49:55 -0500 Message-ID: <20211122234956.788401-11-rostedt@goodmis.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211122234956.788401-1-rostedt@goodmis.org> References: <20211122234956.788401-1-rostedt@goodmis.org> MIME-Version: 1.0 Received-SPF: None (EX13-EDG-OU-002.vmware.com: rostedt@goodmis.org does not designate permitted sender hosts) Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org From: "Steven Rostedt (VMware)" Parse out all the working examples in the man pages, and have make samples build them. Signed-off-by: Steven Rostedt (VMware) --- samples/Makefile | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/samples/Makefile b/samples/Makefile index 53b6630..6ee57fe 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -7,9 +7,22 @@ include $(src)/scripts/utils.mk +EXAMPLES := +EXAMPLES += dynevents +EXAMPLES += kprobes +EXAMPLES += eprobes +EXAMPLES += synth +EXAMPLES += error +EXAMPLES += filter +EXAMPLES += function-filter +EXAMPLES += hist +EXAMPLES += hist-cont +EXAMPLES += tracer +EXAMPLES += stream + TARGETS := TARGETS += sqlhist -TARGETS += dynevent +TARGETS += $(EXAMPLES) bdir := $(obj)/bin @@ -21,7 +34,9 @@ extract_example = \ $(bdir)/sqlhist.c: ../Documentation/libtracefs-sql.txt $(call extract_example,$<,$@) -$(bdir)/dynevent.c: ../Documentation/libtracefs-dynevents.txt +EXAMPLE_C_CODE := $(patsubst %,$(bdir)/%.c,$(EXAMPLES)) + +$(bdir)/%.c: ../Documentation/libtracefs-%.txt $(call extract_example,$<,$@) $(bdir): @@ -31,10 +46,21 @@ sqlhist: $(bdir) $(bdir) $(bdir)/sqlhist $(TARGETS): $(bdir) +# sqlhist is unique and stands on its own +sqlhist: $(bdir)/sqlhist + $(bdir)/%: $(bdir)/%.o $(CC) -o $@ $^ $(LIBTRACEFS_STATIC) $(LIBTRACEEVENT_LIBS) -$(TARGETS): $(patsubst %,$(bdir)/%,$(TARGETS)) +$(EXAMPLES): $(patsubst %,$(bdir)/%,$(TARGETS)) + +## The intermediate files get removed by Make. +## To examine the .c files created by one of the man pages, +## uncomment the below, and replace the XX with the exec example +## name, and the file will not be discarded by make. +# +# $(bdir)/XX.o: $(bdir)/XX.c +# $(CC) -g -Wall -c -o $@ $^ -I../include/ $(LIBTRACEEVENT_INCLUDES) $(bdir)/%.o: %.c $(CC) -g -Wall -c -o $@ $^ -I../include/ $(LIBTRACEEVENT_INCLUDES) From patchwork Mon Nov 22 23:49:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 12633163 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0650FC433EF for ; Mon, 22 Nov 2021 23:50:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231970AbhKVXxV (ORCPT ); Mon, 22 Nov 2021 18:53:21 -0500 Received: from ex13-edg-ou-001.vmware.com ([208.91.0.189]:32632 "EHLO EX13-EDG-OU-001.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232007AbhKVXxS (ORCPT ); Mon, 22 Nov 2021 18:53:18 -0500 Received: from sc9-mailhost1.vmware.com (10.113.161.71) by EX13-EDG-OU-001.vmware.com (10.113.208.155) with Microsoft SMTP Server id 15.0.1156.6; Mon, 22 Nov 2021 15:50:09 -0800 Received: from vypre.local.home (unknown [10.21.245.36]) by sc9-mailhost1.vmware.com (Postfix) with ESMTP id 1CF4220348; Mon, 22 Nov 2021 15:50:11 -0800 (PST) From: Steven Rostedt To: CC: "Steven Rostedt (VMware)" Subject: [PATCH 11/11] libtracefs/Documentation: Update stream example to have a parameter Date: Mon, 22 Nov 2021 18:49:56 -0500 Message-ID: <20211122234956.788401-12-rostedt@goodmis.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211122234956.788401-1-rostedt@goodmis.org> References: <20211122234956.788401-1-rostedt@goodmis.org> MIME-Version: 1.0 Received-SPF: None (EX13-EDG-OU-001.vmware.com: rostedt@goodmis.org does not designate permitted sender hosts) Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org From: "Steven Rostedt (VMware)" Instead of writing the output of the tracing data to trace.txt, have the example require a file name. As it is now compiled out, it should not create some random file that the user will not expect. Signed-off-by: Steven Rostedt (VMware) --- Documentation/libtracefs-stream.txt | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Documentation/libtracefs-stream.txt b/Documentation/libtracefs-stream.txt index 48fc8fa..7d723c5 100644 --- a/Documentation/libtracefs-stream.txt +++ b/Documentation/libtracefs-stream.txt @@ -47,6 +47,8 @@ EXAMPLE ------- [source,c] -- +#include +#include #include #include @@ -57,13 +59,23 @@ void stop(int sig) tracefs_trace_pipe_stop(NULL); } -int main() +int main(int argc, char **argv) { mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; - const char *filename = "trace.txt"; - int fd = creat(filename, mode); + const char *filename; + int fd; int ret; + if (argc < 2) { + fprintf(stderr, "usage: %s output_file\n", argv[0]); + exit(-1); + } + filename = argv[1]; + fd = creat(filename, mode); + if (fd < 0) { + perror(filename); + exit(-1); + } signal(SIGINT, stop); ret = tracefs_trace_pipe_stream(fd, NULL, SPLICE_F_NONBLOCK); close(fd);