Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4190582pxj; Mon, 21 Jun 2021 16:03:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8hu55TH4lYc0gNgin4oDNg/RHcNsEQsOifvuSc5ELg60E9YIV3D4ARYRgYB10qid5fREA X-Received: by 2002:a92:dac3:: with SMTP id o3mr437840ilq.290.1624316620690; Mon, 21 Jun 2021 16:03:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624316620; cv=none; d=google.com; s=arc-20160816; b=mf62jlJ38kivB4Z5lUGqmu1pY85RjxWtfizqPatOXG1xa5tAjDYEJicP8EIz8OiSGS vNzUSu3CL5+2sYoJ3uNCnndTZ+FjCnw6utBMSxJ/kv4g7dz6KE4fCftOCV1Wsbwj0Vo6 cEfQIyHcZv1Z2dvYXsSNN2+KJLU2s2IX223iuSNeiooLnSxHhoS6kMNHQn4/iG0xWZ3B ug+yV6tmYFk2BneT0v9i03zIw96s/g5pbdhqDDBBITFNEDveV7tTH+33B1TBv6qMvtAy VKpINq4qwFg1A3SrhHUfnCzvEjUxk9AHZiaG13KasGi85cu5JDozlw3XXI+n2LmxemQ1 isbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=gCG6H7GuL0YCs68rOtAhGiPNk+jNUbnfrlm8YFS4cH0=; b=06kb/sp+bIfSsaqUR3cbcrFLy79TMgVegjHNWs3Kh+sbZLlx27FAQLfwm15G3wutNX NnQdfTy3oCbEBhbaBV8d22gPpPS9i0s+Kbugae4brkQ5KciEYhZWHpSXFm4thssQjO9g /tbgdMp+f9MCt0Eem3lo65ec/xhXg6HCEn9+xVB827GmymgSoV6znTiTuHjbs4wDtrG+ pZaNXU/irmcmnTV5DFPHHnSuY91DA5g6XKuCEH2aCLFiZuZwkQm3wDBjq9ggXqyo6pXo 0PS588Iw6o8qMZfmmmM1ZSAufaBZ39ouG15a/eRRBEKgX/5SQKg0rqAAMNhUBvHYp6m+ Z8QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=B2895Ujx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x19si20845632jat.6.2021.06.21.16.03.28; Mon, 21 Jun 2021 16:03:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=B2895Ujx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230222AbhFUXFO (ORCPT + 99 others); Mon, 21 Jun 2021 19:05:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229940AbhFUXFN (ORCPT ); Mon, 21 Jun 2021 19:05:13 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDFFBC061574; Mon, 21 Jun 2021 16:02:57 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id d11so19035632wrm.0; Mon, 21 Jun 2021 16:02: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:mime-version :content-transfer-encoding; bh=gCG6H7GuL0YCs68rOtAhGiPNk+jNUbnfrlm8YFS4cH0=; b=B2895UjxZZOVMW3o6YZas7ftFhr5xzWNp34dcyqq3kFi6XVfz61XS/hs2m45T1Nnos NlCAqZfyn5u0ARpo7iVa6O6JsdkI1ZFDqsvNITqT+z9G8cBq8OTCfI5mi1wXMIM+hU/u H4UMNzUJv12ZUKw/b4b1XXEQHaI2zUDt4cxwub/oNts22FEbAH/XxwniwMmZAg0nl13v VVScN17r5Axdl8w8afP0DV6bG0URQlUOQMtScN4E61aAkhfPWuQoHZ4IrFYGCzhmf1+s ZaR9UWBH5tsr7To85gJMzno3CZiR6sNf/78DgKSg5vzYHdbQns8mDXyJyMZvu4sCtWfR IDcg== 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:mime-version :content-transfer-encoding; bh=gCG6H7GuL0YCs68rOtAhGiPNk+jNUbnfrlm8YFS4cH0=; b=NMzpSV5S4DqKbOy6JRsoGrnjEZRdK9qKEwaB2UAPdIorfZrpdnHGGx/H039cJcBnbw BGWfuN4lIhglHtusf/8OMGpMy4IYqclS5ghcX68YoqIMhl64CHBZOx73r0dAmB8u8nBl lX5Swk/vI+YApiGOqWT+b1Z4IAOvXHlm5xREIdEjatbk/HrJpDznsWej6vPsRI0ItZP3 iBoCEBzd+dzNcT1LXjvW7MwzyXzfRqCHIJWZ1DZEJ6ljEsUu2xI2L+Kh74n0TJc0azAI grlt4c6mLysFE5KOgdQh2UIaTFMT/FXdrjiuxwzwtnWxmjkHsbnL12uI+cKObq/aUeAd Xl8Q== X-Gm-Message-State: AOAM532V8V7C9AER4cwEPCQsa+2+RUfUMEu3H8PGieaI6mERReoootM6 7uljA/siPDiFYP6ZM9ug6VM= X-Received: by 2002:a5d:5987:: with SMTP id n7mr903268wri.293.1624316576571; Mon, 21 Jun 2021 16:02:56 -0700 (PDT) Received: from honeypot.. ([151.29.45.200]) by smtp.googlemail.com with ESMTPSA id r4sm20179517wre.84.2021.06.21.16.02.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 16:02:56 -0700 (PDT) From: Riccardo Mancini To: Arnaldo Carvalho de Melo Cc: Namhyung Kim , Ian Rogers , Riccardo Mancini , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Martin Liska , Jason Yan , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] perf annotate: allow 's' on source code lines Date: Tue, 22 Jun 2021 01:00:47 +0200 Message-Id: <20210621230047.211430-1-rickyman7@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In perf annotate, when 's' is pressed on a line containing source code, it shows the message "Only available for assembly lines". This patch gets rid of the error, moving the cursr to the next available asm line (or the closest previous one if no asm line is found moving forwards), before hiding source code lines. Signed-off-by: Riccardo Mancini --- tools/perf/ui/browsers/annotate.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index ad0a70f0edaf..eb94d20d0d13 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -343,6 +343,29 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser, browser->curr_hot = rb_last(&browser->entries); } +static struct annotation_line *annotate_browser__find_next_asm_line( + struct annotate_browser *browser, + struct annotation_line *al) +{ + struct annotation_line *it = al; + + /* find next asm line */ + list_for_each_entry_continue(it, browser->b.top, node) { + if (it->idx_asm >= 0) + return it; + } + + /* no asm line found forwards, try backwards */ + it = al; + list_for_each_entry_continue_reverse(it, browser->b.top, node) { + if (it->idx_asm >= 0) + return it; + } + + /* There are no asm lines */ + return al; +} + static bool annotate_browser__toggle_source(struct annotate_browser *browser) { struct annotation *notes = browser__annotation(&browser->b); @@ -363,9 +386,8 @@ static bool annotate_browser__toggle_source(struct annotate_browser *browser) browser->b.index = al->idx; } else { if (al->idx_asm < 0) { - ui_helpline__puts("Only available for assembly lines."); - browser->b.seek(&browser->b, -offset, SEEK_CUR); - return false; + /* move cursor to next asm line */ + al = annotate_browser__find_next_asm_line(browser, al); } if (al->idx_asm < offset) -- 2.31.1