From patchwork Wed Jul 17 08:53:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 11047477 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 D0AF16C5 for ; Wed, 17 Jul 2019 08:53:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFB03286AC for ; Wed, 17 Jul 2019 08:53:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B40B028716; Wed, 17 Jul 2019 08:53:42 +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 3FD47286AC for ; Wed, 17 Jul 2019 08:53:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726851AbfGQIxl (ORCPT ); Wed, 17 Jul 2019 04:53:41 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:55424 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725890AbfGQIxl (ORCPT ); Wed, 17 Jul 2019 04:53:41 -0400 Received: by mail-wm1-f67.google.com with SMTP id a15so21271462wmj.5 for ; Wed, 17 Jul 2019 01:53:40 -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=hZsbXSzkaL5uC/+rz+3t2VLv0xFcqNvTyg6Ul4E7X/U=; b=I7O5vrYfnkB5rH8/DwtWi1x+dEj05AhmHU3jZskzZFHYI7LAZXpivXtbegQIU6WW3r mw4QlfQlhUKMYA+GzQOdQaIRWd1eIRTtyu/UNGNV/Nixo1k1l6f/hnUu3PdJP6zHuukn Ys918kY/olpDWwXq8VvAC00AJt3M0R0KEcwWh1bF5tUpXOukhq+VOyiEGHRrh+aYcQae wxuqRESyY2T9hlwMSz13SDLdiEad1cBXASQMQCtyod+UCOYR7HhVAk4hZfi4A7XzQ+31 gOes4dcrh0Furq2acTtNiTArpIy1BGQ4l9mX4KIRrz/4TrgLaHT6aopV6M6TRahUY8TG 9e2Q== 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=hZsbXSzkaL5uC/+rz+3t2VLv0xFcqNvTyg6Ul4E7X/U=; b=awgXF3WCr7MljcSCps1ZYihVGa4Um5KC2UwAIu0kunHFefU3hP+nPQTYwPaKUkHxTY kov6QFRDS0etEJTnYWdYQAeE2tYNgkoMMno9R01iXpEP7b+f5PYaImT7mn67a1XgJrp9 7fuB5dBoXlWQ4QJKAY1psJ/tHrGKn/lxQby7iQq94Wewm4r7DoYKj3P8d4+Nz3l+o96e /f8bAiSQcYerxwEinNyAMm8oaRw1UxA+EPqwufiDFQqwPVSf6lPSTaZjhg0LDbDswiUE Gi26GyDPcSBGK6xqlPxGCauKK9nh0+JTU6dbNae2WvLlQmP9cs2ZOAGUVw46y8Sxs2Yi Ps+w== X-Gm-Message-State: APjAAAXqXTJf37N/Z3OIsJMd9vHEs/bC87jsZBU/BZOrfcQDBIceRhJg SDtpreopL3hvS2olUjWcXIc= X-Google-Smtp-Source: APXvYqwOfVJm+bAF+TZOXKeO/mz9lLbc4rVm9W6CCkJmKBMlQURnswAA/yVEYsK6FuM5c1xzlbgKtg== X-Received: by 2002:a1c:343:: with SMTP id 64mr30565890wmd.116.1563353620060; Wed, 17 Jul 2019 01:53:40 -0700 (PDT) Received: from mamba.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id w23sm24102127wmi.45.2019.07.17.01.53.39 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 17 Jul 2019 01:53:39 -0700 (PDT) From: "Yordan Karadzhov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, "Yordan Karadzhov (VMware)" Subject: [PATCH 1/2] kernel-shark: Initialize the data-related fields of the model Date: Wed, 17 Jul 2019 11:53:05 +0300 Message-Id: <20190717085306.12393-2-y.karadz@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190717085306.12393-1-y.karadz@gmail.com> References: <20190717085306.12393-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 It is particularly important to initialize to zero the "data_size" field because its value is used when doing operations like scroll or zoom to check if data has been loaded or not. Not having "data_size" set to zero can cause segfault (as reported by Steven). Reported-By: Steven Rostedt (VMware) Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=204195 Signed-off-by: Yordan Karadzhov (VMware) Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Steven Rostedt (VMware) Reviewed-by: Yordan Karadzhov (VMware) --- kernel-shark/src/libkshark-model.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel-shark/src/libkshark-model.c b/kernel-shark/src/libkshark-model.c index 18f9c69..fd4d876 100644 --- a/kernel-shark/src/libkshark-model.c +++ b/kernel-shark/src/libkshark-model.c @@ -36,6 +36,9 @@ void ksmodel_init(struct kshark_trace_histo *histo) * Initialize an empty histo. The histo will have no bins and will * contain no data. */ + histo->data_size = 0; + histo->data = NULL; + histo->bin_size = 0; histo->min = 0; histo->max = 0; From patchwork Wed Jul 17 08:53:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 11047479 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 5E83E6C5 for ; Wed, 17 Jul 2019 08:53:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D67E286AC for ; Wed, 17 Jul 2019 08:53:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4209028716; Wed, 17 Jul 2019 08:53:44 +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 CC647286AC for ; Wed, 17 Jul 2019 08:53:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727099AbfGQIxn (ORCPT ); Wed, 17 Jul 2019 04:53:43 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:44606 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725890AbfGQIxn (ORCPT ); Wed, 17 Jul 2019 04:53:43 -0400 Received: by mail-wr1-f68.google.com with SMTP id p17so23832707wrf.11 for ; Wed, 17 Jul 2019 01:53:41 -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=YZfgbfjlvqspg+SIs4amFjMMq3Ztoyr0Cba62FvzcMM=; b=SI66BH9d2FmIi+TK0zAwTX8kbJl5MnoMxBLP+Uu2+h1izrhmMQPt8RrRl9ctCkHfIY NUrlVl1lWUJ/h0YnVuuELCfuiyikkwnLKSOXFiFc9O5M6VjlyOTeBwzf9AQE6dUF1300 2bgaoGcHQTB/LznGABDWazgL1HqkSUOl0paXCEBeg3Xbnunh8Nav/NjodTcZg+iVcrMq /cEtM2hp70Apc+ee2jv1PVFZp0xzcWtNx+6YgguilKDxPmk+U8WiHylDu3Y3Kn4Juytu 4NOoXVNJ06Xj3zdc3879Jj9GjJz1GbQbpQ93Q+OJkiJ/kYnpFldFivV0yPIWIBt26iQ4 GZ1A== 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=YZfgbfjlvqspg+SIs4amFjMMq3Ztoyr0Cba62FvzcMM=; b=UDJEOy0ypLZ5fVBo23du27e6M0cLNwg0XuDQFBrZe1GgZYtezCBsJjea+OXTz1CAbP Yx0bHYkSc7eGUJpLcVKw32lF71Y8Mo2MjDC75h2T/5UFQedaza71UuoV5N9Gb25rkZ2G bdzeZRX7fgHdlM8Q09mkredUuyqANlI+uB7QgwaDrElv2JTgZ6stPJhAzUxfN7BoxoLx CblXre9CaP7BLDoU7ZbrX6Hbgd5guXnZiJH6rP3OQQuvi3f44VLRTeUBNyOTIq6zQXV7 +OhTUUWh9iDGeKm6vro58APzUuVIF583BU3yO7zMIl4z7rmgk2risFjF5GyiYgzN9ri9 U7Ig== X-Gm-Message-State: APjAAAU4b6nMM4yF2Vwo6n5eFkAOfYDToO87ZuoWYQpHkkE8nqNpZJZC 06iR9Muc77w9bT6G+27fo4k= X-Google-Smtp-Source: APXvYqxg0rpTCVg4jBKasFWtUnZQcE57L+GeWF1WZIuu1WNEdCnbtKNFJ6DkIc/IB7gA/l8v6hMWeQ== X-Received: by 2002:a5d:4108:: with SMTP id l8mr40858539wrp.113.1563353621310; Wed, 17 Jul 2019 01:53:41 -0700 (PDT) Received: from mamba.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id w23sm24102127wmi.45.2019.07.17.01.53.40 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 17 Jul 2019 01:53:41 -0700 (PDT) From: "Yordan Karadzhov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, "Yordan Karadzhov (VMware)" Subject: [PATCH 2/2] kernel-shark: Always check if data is loaded before changing the graphs Date: Wed, 17 Jul 2019 11:53:06 +0300 Message-Id: <20190717085306.12393-3-y.karadz@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190717085306.12393-1-y.karadz@gmail.com> References: <20190717085306.12393-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 We want all operations over the graphs (like Zoom or Scroll) to be protected for the case when no data is loaded or no graphs are plotted. Signed-off-by: Yordan Karadzhov (VMware) --- kernel-shark/src/KsGLWidget.cpp | 22 ++++++++++++++++++++-- kernel-shark/src/KsGLWidget.hpp | 2 ++ kernel-shark/src/KsTraceGraph.cpp | 9 +++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/kernel-shark/src/KsGLWidget.cpp b/kernel-shark/src/KsGLWidget.cpp index ce68052..e930006 100644 --- a/kernel-shark/src/KsGLWidget.cpp +++ b/kernel-shark/src/KsGLWidget.cpp @@ -88,9 +88,11 @@ void KsGLWidget::paintGL() glClear(GL_COLOR_BUFFER_BIT); + if (isEmpty()) + return; + /* Draw the time axis. */ - if(_data) - _drawAxisX(size); + _drawAxisX(size); /* Process and draw all graphs by using the built-in logic. */ _makeGraphs(_cpuList, _taskList); @@ -127,6 +129,13 @@ void KsGLWidget::reset() _model.reset(); } +/** Check if the widget is empty (not showing anything). */ +bool KsGLWidget::isEmpty() const { + return !_data || + !_data->size() || + (!_cpuList.size() && !_taskList.size()); +} + /** Reimplemented event handler used to receive mouse press events. */ void KsGLWidget::mousePressEvent(QMouseEvent *event) { @@ -198,6 +207,9 @@ void KsGLWidget::mouseMoveEvent(QMouseEvent *event) size_t row; bool ret; + if (isEmpty()) + return; + if (_rubberBand.isVisible()) _rangeBoundStretched(_posInRange(event->pos().x())); @@ -224,6 +236,9 @@ void KsGLWidget::mouseMoveEvent(QMouseEvent *event) /** Reimplemented event handler used to receive mouse release events. */ void KsGLWidget::mouseReleaseEvent(QMouseEvent *event) { + if (isEmpty()) + return; + if (event->button() == Qt::LeftButton) { size_t posMouseRel = _posInRange(event->pos().x()); int min, max; @@ -251,6 +266,9 @@ void KsGLWidget::wheelEvent(QWheelEvent * event) { int zoomFocus; + if (isEmpty()) + return; + if (_mState->activeMarker()._isSet && _mState->activeMarker().isVisible()) { /* diff --git a/kernel-shark/src/KsGLWidget.hpp b/kernel-shark/src/KsGLWidget.hpp index e141b0a..3d428b1 100644 --- a/kernel-shark/src/KsGLWidget.hpp +++ b/kernel-shark/src/KsGLWidget.hpp @@ -41,6 +41,8 @@ public: void reset(); + bool isEmpty() const; + /** Reprocess all graphs. */ void update() {resizeGL(width(), height());} diff --git a/kernel-shark/src/KsTraceGraph.cpp b/kernel-shark/src/KsTraceGraph.cpp index 324f36e..2e48372 100644 --- a/kernel-shark/src/KsTraceGraph.cpp +++ b/kernel-shark/src/KsTraceGraph.cpp @@ -234,6 +234,9 @@ void KsTraceGraph::_zoomOut() void KsTraceGraph::_quickZoomIn() { + if (_glWindow.isEmpty()) + return; + /* Bin size will be 100 ns. */ _glWindow.model()->quickZoomIn(100); if (_mState->activeMarker()._isSet && @@ -249,6 +252,9 @@ void KsTraceGraph::_quickZoomIn() void KsTraceGraph::_quickZoomOut() { + if (_glWindow.isEmpty()) + return; + _glWindow.model()->quickZoomOut(); } @@ -646,6 +652,9 @@ void KsTraceGraph::_updateGraphs(GraphActions action) double k; int bin; + if (_glWindow.isEmpty()) + return; + /* * Set the "Key Pressed" flag. The flag will stay set as long as the user * keeps the corresponding action button pressed.