From patchwork Wed Jun 12 18:19:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 10990621 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 972C914E5 for ; Wed, 12 Jun 2019 18:20:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A86F26E7B for ; Wed, 12 Jun 2019 18:20:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7F429288C3; Wed, 12 Jun 2019 18:20:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 171E0288C6 for ; Wed, 12 Jun 2019 18:20:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726774AbfFLSUU (ORCPT ); Wed, 12 Jun 2019 14:20:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:46874 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726735AbfFLSUU (ORCPT ); Wed, 12 Jun 2019 14:20:20 -0400 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C007E20B7C; Wed, 12 Jun 2019 18:20:19 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.92) (envelope-from ) id 1hb7r8-00057b-VB; Wed, 12 Jun 2019 14:20:18 -0400 Message-Id: <20190612182018.861661984@goodmis.org> User-Agent: quilt/0.65 Date: Wed, 12 Jun 2019 14:19:28 -0400 From: Steven Rostedt To: linux-trace-devel@vger.kernel.org Subject: [PATCH 1/3] trace-cmd: Fix typo in Makefile bidr to bdir References: <20190612181927.608151291@goodmis.org> 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 X-Virus-Scanned: ClamAV using ClamSMTP From: "Steven Rostedt (VMware)" The order-only prerequisit to $(bdir)/include has a typo of "$(bidr)" instead of being "$(bdir)" Signed-off-by: Steven Rostedt (VMware) Reviewed-by: Tzvetomir Stoyanov --- tracecmd/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tracecmd/Makefile b/tracecmd/Makefile index 93b373d58155..bcd437a26b98 100644 --- a/tracecmd/Makefile +++ b/tracecmd/Makefile @@ -47,7 +47,7 @@ all: $(TARGETS) $(bdir): @mkdir -p $(bdir) -$(bdir)/include: | $(bidr) +$(bdir)/include: | $(bdir) @mkdir -p $(bdir)/include $(TC_VERSION): force | $(bdir)/include From patchwork Wed Jun 12 18:19:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 10990619 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 770471708 for ; Wed, 12 Jun 2019 18:20:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 675CC28821 for ; Wed, 12 Jun 2019 18:20:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B4112899C; Wed, 12 Jun 2019 18:20:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EBC36288C3 for ; Wed, 12 Jun 2019 18:20:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726724AbfFLSUU (ORCPT ); Wed, 12 Jun 2019 14:20:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:46888 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726774AbfFLSUU (ORCPT ); Wed, 12 Jun 2019 14:20:20 -0400 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F1010215EA; Wed, 12 Jun 2019 18:20:19 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.92) (envelope-from ) id 1hb7r9-000587-46; Wed, 12 Jun 2019 14:20:19 -0400 Message-Id: <20190612182019.007518394@goodmis.org> User-Agent: quilt/0.65 Date: Wed, 12 Jun 2019 14:19:29 -0400 From: Steven Rostedt To: linux-trace-devel@vger.kernel.org Subject: [PATCH 2/3] trace-cmd: Have --max-graph-depth only be part of instance References: <20190612181927.608151291@goodmis.org> 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 X-Virus-Scanned: ClamAV using ClamSMTP From: "Steven Rostedt (VMware)" New kernels will allow function graph tracer to be used in an instance, which means that the max_graph_depth file will be per instance and not just the top level file. Make the max_graph_depth associated to the instance and not part of the trace record context. Signed-off-by: Steven Rostedt (VMware) Reviewed-by: Tzvetomir Stoyanov --- tracecmd/include/trace-local.h | 2 ++ tracecmd/trace-record.c | 27 +++++++++++++++------------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/tracecmd/include/trace-local.h b/tracecmd/include/trace-local.h index a1a06e9196b4..1cad3ccc4de7 100644 --- a/tracecmd/include/trace-local.h +++ b/tracecmd/include/trace-local.h @@ -183,6 +183,8 @@ struct buffer_instance { struct tracecmd_msg_handle *msg_handle; struct tracecmd_output *network_handle; + char *max_graph_depth; + int flags; int tracing_on_init_val; int tracing_on_fd; diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c index ee35ada10d6e..2d716a81acbf 100644 --- a/tracecmd/trace-record.c +++ b/tracecmd/trace-record.c @@ -207,7 +207,6 @@ struct common_record_context { struct buffer_instance *instance; const char *output; char *date2ts; - char *max_graph_depth; int data_flags; int record_all; @@ -4892,9 +4891,9 @@ static void parse_record_options(int argc, ctx->data_flags |= DATA_FL_OFFSET; break; case OPT_max_graph_depth: - free(ctx->max_graph_depth); - ctx->max_graph_depth = strdup(optarg); - if (!ctx->max_graph_depth) + free(ctx->instance->max_graph_depth); + ctx->instance->max_graph_depth = strdup(optarg); + if (!ctx->instance->max_graph_depth) die("Could not allocate option"); break; case OPT_no_filter: @@ -5056,10 +5055,12 @@ static void record_trace(int argc, char **argv, update_plugins(type); set_options(); - if (ctx->max_graph_depth) { - for_all_instances(instance) - set_max_graph_depth(instance, ctx->max_graph_depth); - free(ctx->max_graph_depth); + for_all_instances(instance) { + if (instance->max_graph_depth) { + set_max_graph_depth(instance, instance->max_graph_depth); + free(instance->max_graph_depth); + instance->max_graph_depth = NULL; + } } allocate_seq(); @@ -5155,10 +5156,12 @@ void trace_extract(int argc, char **argv) update_plugins(type); set_options(); - if (ctx.max_graph_depth) { - for_all_instances(instance) - set_max_graph_depth(instance, ctx.max_graph_depth); - free(ctx.max_graph_depth); + for_all_instances(instance) { + if (instance->max_graph_depth) { + set_max_graph_depth(instance, instance->max_graph_depth); + free(instance->max_graph_depth); + instance->max_graph_depth = NULL; + } } allocate_seq(); From patchwork Wed Jun 12 18:19:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 10990623 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A2B2518E8 for ; Wed, 12 Jun 2019 18:20:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 95CB728821 for ; Wed, 12 Jun 2019 18:20:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8A3922885F; Wed, 12 Jun 2019 18:20:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3647226E7B for ; Wed, 12 Jun 2019 18:20:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726735AbfFLSUU (ORCPT ); Wed, 12 Jun 2019 14:20:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:46892 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726808AbfFLSUU (ORCPT ); Wed, 12 Jun 2019 14:20:20 -0400 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2109921721; Wed, 12 Jun 2019 18:20:20 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.92) (envelope-from ) id 1hb7r9-00058c-9O; Wed, 12 Jun 2019 14:20:19 -0400 Message-Id: <20190612182019.169932649@goodmis.org> User-Agent: quilt/0.65 Date: Wed, 12 Jun 2019 14:19:30 -0400 From: Steven Rostedt To: linux-trace-devel@vger.kernel.org Subject: [PATCH 3/3] trace-cmd: Check the return of get_file_content() before calling add_reset_file() References: <20190612181927.608151291@goodmis.org> 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 X-Virus-Scanned: ClamAV using ClamSMTP From: "Steven Rostedt (VMware)" If get_file_content() returns NULL, because the file does not exist or for any other reason, it will cause add_reset_file() to trigger a SEGSEGV due to using a NULL pointer. Only call add_reset_file() if get_file_content() actually returns something. Signed-off-by: Steven Rostedt (VMware) Reviewed-by: Tzvetomir Stoyanov --- tracecmd/trace-record.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c index 2d716a81acbf..5dc6f17aa743 100644 --- a/tracecmd/trace-record.c +++ b/tracecmd/trace-record.c @@ -270,8 +270,10 @@ static void reset_save_file(const char *file, int prio) char *content; content = get_file_content(file); - add_reset_file(file, content, prio); - free(content); + if (content) { + add_reset_file(file, content, prio); + free(content); + } } /*