From patchwork Wed Jul 24 15:40:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 11057103 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 B1E40112C for ; Wed, 24 Jul 2019 15:41:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A30EC286C1 for ; Wed, 24 Jul 2019 15:41:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 97B7628875; Wed, 24 Jul 2019 15:41:00 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 24418286C1 for ; Wed, 24 Jul 2019 15:41:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387637AbfGXPlA (ORCPT ); Wed, 24 Jul 2019 11:41:00 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:35215 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387394AbfGXPk7 (ORCPT ); Wed, 24 Jul 2019 11:40:59 -0400 Received: by mail-wr1-f67.google.com with SMTP id y4so47525185wrm.2 for ; Wed, 24 Jul 2019 08:40: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=2FKD0UEiJP4GyqOPIYG1PA0KGvvAv4TgsN6F0517/kg=; b=s5PKAIt5PhacPKalKNx8FfghqU3gWoBFMGE/jMHZVylxa73hYnZ9dwf0uWzSdnwt80 iHvYmFoY5DH3JJTrlXwWU/h4ltNL3M53XXG8knS5SMrn0BKmnHCra75hGlWp5lrLaEpc CSQjdJKEVtmok1se1oSLKl7k7vgaMvATquXC/PsetSYAKtHoW4bQq2v7gW+bZhsu0Jbg YVVtn6ddQ+mY1GqsCGVjIGX+QhfxwzC9N36q89dq8wcUzcgItalaMPiKk136oaIBlfUU TqV0Q/ZhFDP62MgBM2kvnFx8hjE0yqx+K1fNRrgPlNLH2e8ruNGyMRAz3w11D03kSbXK xMeA== 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=2FKD0UEiJP4GyqOPIYG1PA0KGvvAv4TgsN6F0517/kg=; b=oKs54GKwWjibEcUa6kfBRUYZLiX6MR8/7IEM+RNoOjvitl5xhiaZOJKvnnBrS5gr11 KwIAusieQ9AZ7e5A/rkOJFQD8szks7LC1Aeg+nX7CTfZj4ETg8jLvHTx7aX5r2yAePl8 cBNk2/9xdemE7yGPMwEfNvh0TQAr5ZaK4H0g4I+N+H9Cb/JEi+Gahu+sqCn7NDuDWQrJ De06cTkIkoQSZl2P6n4PRSEkRd/xpX2jexFTvHibT+ag2HXKUSKKvbTWgZlMBvKFm4aA pHL/OTHLLbtKVHoepBAnbrqGe5VHf3eyfPIKLgAd8zj1qui7meHeqgbz4MnCu8BdaBb3 KZ5w== X-Gm-Message-State: APjAAAWtj3jEBKC3UhklXfKSIDsfvCJqxA92+SQ2yZcdsEd13rE1fMjw pkeAB1u02gZi9mTAoGhOe+Q= X-Google-Smtp-Source: APXvYqxGj/nlHaMBH+bjqDXGmxTh+GFLDLqpqgpXPBegjRACItGDOVYHQ9UUDRlvyr6lyOe2elmeTQ== X-Received: by 2002:adf:e2c1:: with SMTP id d1mr92911330wrj.283.1563982856918; Wed, 24 Jul 2019 08:40:56 -0700 (PDT) Received: from localhost.localdomain ([95.87.223.238]) by smtp.gmail.com with ESMTPSA id a64sm45510570wmf.1.2019.07.24.08.40.56 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 24 Jul 2019 08:40:56 -0700 (PDT) From: "Yordan Karadzhov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, "Yordan Karadzhov (VMware)" Subject: [PATCH 1/4] kernel-shark: kshark_import_event_filter() tolerates non-existing events Date: Wed, 24 Jul 2019 18:40:36 +0300 Message-Id: <20190724154039.23705-2-y.karadz@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190724154039.23705-1-y.karadz@gmail.com> References: <20190724154039.23705-1-y.karadz@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 X-Virus-Scanned: ClamAV using ClamSMTP Instead of aborting, the function will ignore (skip) the non-existing event and will continue loading the other events in the configuration file. The return type is changed to int in order to provide information about the number of events successfully added to the filter. Signed-off-by: Yordan Karadzhov (VMware) --- kernel-shark/src/libkshark-configio.c | 33 +++++++++++++++------------ kernel-shark/src/libkshark.h | 8 +++---- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/kernel-shark/src/libkshark-configio.c b/kernel-shark/src/libkshark-configio.c index cac27a7..5d7323f 100644 --- a/kernel-shark/src/libkshark-configio.c +++ b/kernel-shark/src/libkshark-configio.c @@ -793,7 +793,7 @@ bool kshark_export_event_filter(struct tep_handle *pevent, } } -static bool kshark_event_filter_from_json(struct tep_handle *pevent, +static int kshark_event_filter_from_json(struct tep_handle *pevent, struct tracecmd_filter_id *filter, const char *filter_name, struct json_object *jobj) @@ -801,7 +801,7 @@ static bool kshark_event_filter_from_json(struct tep_handle *pevent, json_object *jfilter, *jevent, *jsystem, *jname; const char *system_str, *name_str; struct tep_event *event; - int i, length; + int i, length, count = 0; /* * Use the name of the filter to find the array of events associated @@ -809,7 +809,7 @@ static bool kshark_event_filter_from_json(struct tep_handle *pevent, * contain no data for this particular filter. */ if (!json_object_object_get_ex(jobj, filter_name, &jfilter)) - return false; + return 0; if (!kshark_json_type_check(jobj, "kshark.config.filter") || json_object_get_type(jfilter) != json_type_array) @@ -829,16 +829,21 @@ static bool kshark_event_filter_from_json(struct tep_handle *pevent, event = tep_find_event_by_name(pevent, system_str, name_str); if (!event) - goto fail; + continue; tracecmd_filter_id_add(filter, event->id); + ++count; } - return true; + if (count != length) + count = -count; + + return count; fail: fprintf(stderr, "Failed to load event filter from json_object.\n"); - return false; + tracecmd_filter_id_clear(filter); + return 0; } /** @@ -851,14 +856,14 @@ static bool kshark_event_filter_from_json(struct tep_handle *pevent, * @param conf: Input location for the kshark_config_doc instance. Currently * only Json format is supported. * - * @returns True, if a filter has been loaded. If the filter configuration - * document contains no data for this particular filter or in a case - * of an error, the function returns False. + * @returns The total number of events added to the filter. If not all events + * listed in the input configuration have been added successfully, + * the returned number is negative. */ -bool kshark_import_event_filter(struct tep_handle *pevent, - struct tracecmd_filter_id *filter, - const char *filter_name, - struct kshark_config_doc *conf) +int kshark_import_event_filter(struct tep_handle *pevent, + struct tracecmd_filter_id *filter, + const char *filter_name, + struct kshark_config_doc *conf) { switch (conf->format) { case KS_CONFIG_JSON: @@ -869,7 +874,7 @@ bool kshark_import_event_filter(struct tep_handle *pevent, default: fprintf(stderr, "Document format %d not supported\n", conf->format); - return false; + return 0; } } diff --git a/kernel-shark/src/libkshark.h b/kernel-shark/src/libkshark.h index fe35333..04e9cbf 100644 --- a/kernel-shark/src/libkshark.h +++ b/kernel-shark/src/libkshark.h @@ -587,10 +587,10 @@ bool kshark_export_event_filter(struct tep_handle *pevent, const char *filter_name, struct kshark_config_doc *conf); -bool kshark_import_event_filter(struct tep_handle *pevent, - struct tracecmd_filter_id *filter, - const char *filter_name, - struct kshark_config_doc *conf); +int kshark_import_event_filter(struct tep_handle *pevent, + struct tracecmd_filter_id *filter, + const char *filter_name, + struct kshark_config_doc *conf); bool kshark_export_user_mask(struct kshark_context *kshark_ctx, struct kshark_config_doc **conf); From patchwork Wed Jul 24 15:40:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 11057105 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 5D8D513A4 for ; Wed, 24 Jul 2019 15:41:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4EF96286C1 for ; Wed, 24 Jul 2019 15:41:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 439CC28876; Wed, 24 Jul 2019 15:41:01 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 E1D10286C1 for ; Wed, 24 Jul 2019 15:41:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387394AbfGXPlA (ORCPT ); Wed, 24 Jul 2019 11:41:00 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:35219 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387404AbfGXPlA (ORCPT ); Wed, 24 Jul 2019 11:41:00 -0400 Received: by mail-wr1-f67.google.com with SMTP id y4so47525279wrm.2 for ; Wed, 24 Jul 2019 08:40: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=LCuB/9KaAkuuXZUrB8z4Rd/JrV0a/sptwy60/02rzEY=; b=NfIAwUH9lzpKLhvg0hE2xZ8deNQanDEcyOm4HhH80faTz+oQ/F1R6tXAs20cZjwWrU twExgS8w9dfKNnb6tvat92eedl3qcYk2moEMFCObSp+4WAu6wmRE3rU/ka8QfAgDQOmc JWqsrqlKpAsPOatLN+3U6dazGulZJFUM+1IBQ0+zJjHRlFepRmIT2/KQFQ3Fmzs+od7d FTEBI7kkkfRyObBTLcPiGGaEGFsCOQye4CmZaLsXdlOx0QxiEYi8R3ir/NbbLItB8j+I Fhnu2VgrkYZCBPH8VHA0xaM/nMRdKGBO/E52ywNeZTVaI2UNKzaTDPbzLChmlwRo7XE0 lBig== 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=LCuB/9KaAkuuXZUrB8z4Rd/JrV0a/sptwy60/02rzEY=; b=pVds5LnKQBo/ZVrt1BEqNX8fr/O20UKBlkn6o+Wd/0dlJ0DxZ1Qip9BLY+o1PsbP8E 9M4mPAOA/sVNmuPw5T79CoOtgcMJQRBe+QN1v3HVYlK+i1vr9l7WtyCPU2W4kiF9mu0n d9dT8s5TNEVVQm8alPWpOX9eSVY7mfrQuvKU5jaHiDr/PYb8IZHzmtrxZ7awTfEmnUx7 GkJJAzW1k4VTQGe+4srjwTmJPV60YG9oZ6mCXY1DRhbN/g3H77IAy9rLjGz+jMBC3wJf wFhLgeBBAs2MRbp6jeO4jsQtuRsnzLC7p3h/LkwZ3CJcrrqHEvdQJtmuf2ZEWiLFidxE 823g== X-Gm-Message-State: APjAAAWcMAfIdpYXvcUf9/sHORnPtOsXx7vTEEbV+2ofJ2GctSEr+sTA GRZDRhcwo0Xow3BrD5gB5S6VV322 X-Google-Smtp-Source: APXvYqzuSXmWB2bWt1YUNiM5MvePFwaYfhYOGvycJ3Fofg9mML+YVL8C26W7iDxGjHqYqQErU3nkgw== X-Received: by 2002:adf:f286:: with SMTP id k6mr13211596wro.320.1563982858462; Wed, 24 Jul 2019 08:40:58 -0700 (PDT) Received: from localhost.localdomain ([95.87.223.238]) by smtp.gmail.com with ESMTPSA id a64sm45510570wmf.1.2019.07.24.08.40.57 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 24 Jul 2019 08:40:58 -0700 (PDT) From: "Yordan Karadzhov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, "Yordan Karadzhov (VMware)" Subject: [PATCH 2/4] kernel-shark: Allow KsCaptureControl widget to print text to the console Date: Wed, 24 Jul 2019 18:40:37 +0300 Message-Id: <20190724154039.23705-3-y.karadz@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190724154039.23705-1-y.karadz@gmail.com> References: <20190724154039.23705-1-y.karadz@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 X-Virus-Scanned: ClamAV using ClamSMTP This will be used to show Warning messages. Signed-off-by: Yordan Karadzhov (VMware) --- kernel-shark/src/KsCaptureDialog.cpp | 3 +++ kernel-shark/src/KsCaptureDialog.hpp | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/kernel-shark/src/KsCaptureDialog.cpp b/kernel-shark/src/KsCaptureDialog.cpp index 888ffea..6e526ff 100644 --- a/kernel-shark/src/KsCaptureDialog.cpp +++ b/kernel-shark/src/KsCaptureDialog.cpp @@ -437,6 +437,9 @@ void KsCaptureMonitor::connectMe(QProcess *proc, KsCaptureControl *ctrl) connect(ctrl, &KsCaptureControl::argsReady, this, &KsCaptureMonitor::_argsReady); + + connect(ctrl, &KsCaptureControl::print, + this, &KsCaptureMonitor::print); } void KsCaptureMonitor::_captureStarted() diff --git a/kernel-shark/src/KsCaptureDialog.hpp b/kernel-shark/src/KsCaptureDialog.hpp index b168a2b..f8ddf4a 100644 --- a/kernel-shark/src/KsCaptureDialog.hpp +++ b/kernel-shark/src/KsCaptureDialog.hpp @@ -40,6 +40,12 @@ signals: /** This signal is emitted when the "Apply" button is pressed. */ void argsReady(const QString &args); + /** + * This signal is emitted when text has to be printed on the + * KsCaptureMonitor widget. + */ + void print(const QString &message); + private: tep_handle *_localTEP; From patchwork Wed Jul 24 15:40:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 11057107 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 257E6112C for ; Wed, 24 Jul 2019 15:41:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 16EC528897 for ; Wed, 24 Jul 2019 15:41:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0BD6828875; Wed, 24 Jul 2019 15:41:03 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 A136F2887A for ; Wed, 24 Jul 2019 15:41:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727699AbfGXPlC (ORCPT ); Wed, 24 Jul 2019 11:41:02 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:35013 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726031AbfGXPlC (ORCPT ); Wed, 24 Jul 2019 11:41:02 -0400 Received: by mail-wm1-f68.google.com with SMTP id l2so42042732wmg.0 for ; Wed, 24 Jul 2019 08:41: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=QAyL3MWEZNKJtev3DFSSTOy/cq19gunvIHzpfuWlMyY=; b=pR8vFzbwzcnGxkEHu//Uw4xL8pkrrjxZqQpbdI2g7qolA9yhuMx9s53g4Ag4uzof9q 7OTHn0EmektghMv8RTVTGL31ikj5BeDpDfKm5sj3g6egJeJ71ju/M9GGKUDYQ38+HOpM ovuYKZ84+F7rHa7giW66aROPHVMzN81ysdOvtdvTgWIo602jZ6JNYaaOCGyQIKam2+eF SSfwNvzvqNcF7bGgfR+s1lgOzpZdTi7F468Nsh/ndXVPbj/YaUQ3I675I03uNTt68E+C 3UMxJKV2/fMCMDrJzVlAmTN25uXq36kArk3RUrLddrLu/WfdGlOkA9oRxUgnGiZKCan7 /4Ig== 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=QAyL3MWEZNKJtev3DFSSTOy/cq19gunvIHzpfuWlMyY=; b=VMUKTW7uvtclK2pWqXVj1ualYtm0o/0ZQ1w57aAe5U0q2Pes43bj9exUL+sB7YRRxd jf24ueIerC0EAIPWU8U/DB8qIBd219tMU6cFzp0+hsX9Kno+ZbpV1Fv0wXmkBzbmQder Sjq/gh7QEQuluhYxav+8Nd/3+VFjT811AXJAEZUWGwV+Q9li0CUcLK/jOkDDDycVADxm hl+GroalFwNRrydCoEv1BevVQoTJMWoAqFGWQI6xt53me3FBm7Yo34VTHEJHnnV14TFu xq7Y7AEpNkXtm6nX4kTHPRYa94Bxrf16g0he1cOAiHxpZrlN2ElZY+TcegZudBHtKFY9 k+Tw== X-Gm-Message-State: APjAAAUfHB9SIUia9hrL8YNplou4CzwkRx9bq+mK+9jEPng6U8P6wwGw wCOC7cEXisaNeeaJr4I0uqVxSNxb X-Google-Smtp-Source: APXvYqyOXm80uIrxYf9RB6q6NieDfKWon6yqoU8bWxmIF1V1UUD4TMgK2OMRtDkoSzRv0VwmphoYhQ== X-Received: by 2002:a1c:3587:: with SMTP id c129mr77503124wma.90.1563982860466; Wed, 24 Jul 2019 08:41:00 -0700 (PDT) Received: from localhost.localdomain ([95.87.223.238]) by smtp.gmail.com with ESMTPSA id a64sm45510570wmf.1.2019.07.24.08.40.59 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 24 Jul 2019 08:41:00 -0700 (PDT) From: "Yordan Karadzhov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, "Yordan Karadzhov (VMware)" Subject: [PATCH 3/4] kernel-shark: Handle errors when loading Capture configurations Date: Wed, 24 Jul 2019 18:40:38 +0300 Message-Id: <20190724154039.23705-4-y.karadz@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190724154039.23705-1-y.karadz@gmail.com> References: <20190724154039.23705-1-y.karadz@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 X-Virus-Scanned: ClamAV using ClamSMTP A configuration file (Json) for the Capture dialog can contain non-existing tracer plugin or events. This can happen if the configuration was exported on one machine and then imported on another. In such a case the non-existing plugin/events will be ignored and a warning message will be printed to the console-like widget. Signed-off-by: Yordan Karadzhov (VMware) --- kernel-shark/src/KsCaptureDialog.cpp | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/kernel-shark/src/KsCaptureDialog.cpp b/kernel-shark/src/KsCaptureDialog.cpp index 6e526ff..02bbbbc 100644 --- a/kernel-shark/src/KsCaptureDialog.cpp +++ b/kernel-shark/src/KsCaptureDialog.cpp @@ -194,7 +194,7 @@ QStringList KsCaptureControl::_getPlugins() void KsCaptureControl::_importSettings() { - int nEvts = tep_get_events_count(_localTEP); + int nEvts = tep_get_events_count(_localTEP), nIds; kshark_config_doc *conf, *jevents, *temp; QVector v(nEvts, false); tracecmd_filter_id *eventHash; @@ -227,7 +227,14 @@ void KsCaptureControl::_importSettings() return; eventHash = tracecmd_filter_id_hash_alloc(); - kshark_import_event_filter(_localTEP, eventHash, "Events", jevents); + nIds = kshark_import_event_filter(_localTEP, eventHash, "Events", jevents); + if (nIds < 0) { + QString err("WARNING: "); + err += "Some of the imported events are not available on this system.\n"; + err += "All missing events are ignored.\n"; + emit print(err); + } + for (int i = 0; i < nEvts; ++i) { if (tracecmd_filter_id_find(eventHash, events[i]->id)) v[i] = true; @@ -239,8 +246,19 @@ void KsCaptureControl::_importSettings() /** Get all available plugins. */ temp = kshark_string_config_alloc(); - if (kshark_config_doc_get(conf, "Plugin", temp)) - _pluginsComboBox.setCurrentText(KS_C_STR_CAST(temp->conf_doc)); + if (kshark_config_doc_get(conf, "Plugin", temp)) { + const char *plugin = KS_C_STR_CAST(temp->conf_doc); + int pluginIndex = _pluginsComboBox.findText(plugin); + + if (pluginIndex >= 0) { + _pluginsComboBox.setCurrentText(KS_C_STR_CAST(temp->conf_doc)); + } else { + QString err("WARNING: The traceer plugin \""); + err += plugin; + err += "\" is not available on this machine\n"; + emit print(err); + } + } if (kshark_config_doc_get(conf, "Output", temp)) _outputLineEdit.setText(KS_C_STR_CAST(temp->conf_doc)); From patchwork Wed Jul 24 15:40:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 11057109 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 3AA6F112C for ; Wed, 24 Jul 2019 15:41:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C5782871C for ; Wed, 24 Jul 2019 15:41:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 214D128875; Wed, 24 Jul 2019 15:41:04 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 C071A288BA for ; Wed, 24 Jul 2019 15:41:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726031AbfGXPlD (ORCPT ); Wed, 24 Jul 2019 11:41:03 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:41168 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727035AbfGXPlD (ORCPT ); Wed, 24 Jul 2019 11:41:03 -0400 Received: by mail-wr1-f67.google.com with SMTP id c2so44293992wrm.8 for ; Wed, 24 Jul 2019 08:41:02 -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=3/2koJsAEbjHIuBnamymnthhFIJO79KbyPc3HmVywUc=; b=EgjqJISsJt7qGgBefLI6r2OpFTNIq+1I5w8cspIabIDP8DJVJcXslL7ptUiTSLlEsh NIxCi9kn4KV58yXgjQXXd7G2F8oigG/lsemJTTeNxIOaTrYj9x8Xkdj3Wzj6LLdpKFrs rVNBCgj9D7f9CNiEQK7jH1nSv+AMdIh+XkxNI5WB+QRbNH05cNZp5TMhKYz+MdAHBB66 kRinDS055ZDccDkixNtTtDASPya4MKa6863naHOrEHnFftftr8HZqCaH2ADGRtpZqgR4 ul8GvTlyVstTwk/J4lkd0yYphgRkC2KpNm/aatno2b2domV6TcY4IcVAfdbOsYXKK+va FOeQ== 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=3/2koJsAEbjHIuBnamymnthhFIJO79KbyPc3HmVywUc=; b=nr/vr+w0J4jFcOAVOVXMVcrqZoudG0HFW06rR2vqrJ3W7/330ZQrpmQmQES9tW/EG3 wvqcIoxNfUTMzmLeen41XbxZLW1+FXQk41DFpVPg84qwYCTEgGMQlR/9wHWnqQmoG+G0 V+3ZIXd+CT7QEOJNgmIlbX5eMNIfZMRhe1qkSJgfp+g+dWrWQ97Q33S9mbP1qJAtISDC CiMD5zHro3N2zUwWykq19jnUGU6nZI1IlEqWlzRIyFfI1eDAZzKiC7Obufk66sZZoO0x aAcK45yEPjoMDxSHqco+gX0kHazHR1SCD85bUej65M7vj3X8RSc8dSlklpL1Zmi0mMYC TN7A== X-Gm-Message-State: APjAAAXid+lqRFpFcBd4Azq/6b6CrYSUOBmYhtgsTjdXwbVDP1aiACSi reCERFfHrdKWXs+k+f+AsXg= X-Google-Smtp-Source: APXvYqwd/YYbJ7xcFuBYIwDClWz0b1PQ3RzxXX81JbsHWK1wlxLeeK8P8LqIqMYfriTYh7N5Y1WKlw== X-Received: by 2002:adf:f046:: with SMTP id t6mr3188786wro.307.1563982861826; Wed, 24 Jul 2019 08:41:01 -0700 (PDT) Received: from localhost.localdomain ([95.87.223.238]) by smtp.gmail.com with ESMTPSA id a64sm45510570wmf.1.2019.07.24.08.41.01 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 24 Jul 2019 08:41:01 -0700 (PDT) From: "Yordan Karadzhov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, "Yordan Karadzhov (VMware)" Subject: [PATCH 4/4] kernel-shark: Handle corrupted configuration file for the Capture dialog Date: Wed, 24 Jul 2019 18:40:39 +0300 Message-Id: <20190724154039.23705-5-y.karadz@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190724154039.23705-1-y.karadz@gmail.com> References: <20190724154039.23705-1-y.karadz@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 X-Virus-Scanned: ClamAV using ClamSMTP Error message will be printed to the console-like widget. Signed-off-by: Yordan Karadzhov (VMware) --- kernel-shark/src/KsCaptureDialog.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/kernel-shark/src/KsCaptureDialog.cpp b/kernel-shark/src/KsCaptureDialog.cpp index 02bbbbc..addd41d 100644 --- a/kernel-shark/src/KsCaptureDialog.cpp +++ b/kernel-shark/src/KsCaptureDialog.cpp @@ -201,6 +201,9 @@ void KsCaptureControl::_importSettings() tep_event **events; QString fileName; + auto lamImportError = [this] () { + emit print("ERROR: Unable to load the configuration file.\n"); + }; /** Get all available events. */ events = tep_list_events(_localTEP, TEP_EVENT_SORT_SYSTEM); @@ -210,21 +213,27 @@ void KsCaptureControl::_importSettings() "Kernel Shark Config files (*.json);;", _lastFilePath); - if (fileName.isEmpty()) + if (fileName.isEmpty()) { + lamImportError(); return; + } conf = kshark_open_config_file(fileName.toStdString().c_str(), "kshark.config.record"); - if (!conf) + if (!conf) { + lamImportError(); return; + } /* * Load the hash table of selected events from the configuration * document. */ jevents = kshark_config_alloc(KS_CONFIG_JSON); - if (!kshark_config_doc_get(conf, "Events", jevents)) + if (!kshark_config_doc_get(conf, "Events", jevents)) { + lamImportError(); return; + } eventHash = tracecmd_filter_id_hash_alloc(); nIds = kshark_import_event_filter(_localTEP, eventHash, "Events", jevents);