From nobody Mon Oct 6 01:29:05 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9AC62248F74; Fri, 25 Jul 2025 19:38:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753472282; cv=none; b=Qng3DiiUUcW9azUoiQxOQ0FqG9QyHpO81ernGJVLpLNUh6GkFJo+7SOpLMsW1P+dnDpKyUsQ1n0ROBgQDefU7B70H04YNvrdoKXg3/D0ntZPJGrn5PdMA5D7Eg/siZqLKx8UpYatfJwUWq9vKQkV5un4Ws1YOXO/WnCAKPNVVl8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753472282; c=relaxed/simple; bh=1oEn/noJpop/kPy31O4iVBmwGzWGx3I0ATp1Neb7mZU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TxTJ2N/GPM8bHptw8x13Vq8gvSSLkThI03rh0/STKjqTyPhKOvIJX2tuuVf406WFvx1PjojupJlCydAoI4i9+g7ZXWphWaDBKpKaYSSCvJUXpSTcZ0eyD7T51uF9cUBAt9nFKkk/gEXSW/P7gZeozs8ohgSaGTeXIlYeb6dvbMo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Opj1V112; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Opj1V112" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B19BFC4CEF4; Fri, 25 Jul 2025 19:38:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753472282; bh=1oEn/noJpop/kPy31O4iVBmwGzWGx3I0ATp1Neb7mZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Opj1V1128nLYLEi95UyBThmmO7ziS3crsacmIwJbNjj1+O7p8RBBhTbq4hZ8f/q+l Joy15bqitC7Ag3r/IRzPxUJZ2K5bME9Y0W4Fy07kvmP72xPDH+s+LucKYKxJYRylxm QmWVB87755UPOdZ/tG8oafE6UIq6SybXfxe9otyXh/Gh75kNFyerCmrKhur0yI2EZN eaKScNcpbaxiz1U2iQg4ucGrb9zjCWxxXykWwQYyFw+APeoCK++zEYnxtqfQA4rEYU Ga2s5+VKF1kmhlBM6nydtClkrFM7e5Lr7tVYJ1njbqcg9dFKa7LVbKdvwx5d5YzcnV m3OYZBEaG3itA== From: Namhyung Kim To: Arnaldo Carvalho de Melo , Ian Rogers , Kan Liang Cc: Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org Subject: [PATCH v4 1/9] perf annotate: Rename to __hist_entry__tui_annotate() Date: Fri, 25 Jul 2025 12:37:47 -0700 Message-ID: <20250725193755.12276-2-namhyung@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250725193755.12276-1-namhyung@kernel.org> References: <20250725193755.12276-1-namhyung@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There are three different but similar functions for annotation on TUI. Rename it to __hist_entry__tui_annotate() and make sure it passes 'he'. It's not used for now but it'll be needed for later use. Also remove map_symbol__tui_annotate() which was a simple wrapper. Signed-off-by: Namhyung Kim Reviewed-by: Ian Rogers --- tools/perf/ui/browsers/annotate.c | 17 +++++++---------- tools/perf/ui/browsers/hists.c | 2 +- tools/perf/util/annotate.h | 12 ------------ tools/perf/util/hist.h | 12 +++++++----- 4 files changed, 15 insertions(+), 28 deletions(-) diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/ann= otate.c index 183902dac042ecb0..28ef146f29e8e742 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -27,6 +27,7 @@ struct annotate_browser { struct rb_node *curr_hot; struct annotation_line *selection; struct arch *arch; + struct hist_entry *he; bool searching_backwards; char search_bf[128]; }; @@ -557,7 +558,7 @@ static bool annotate_browser__callq(struct annotate_bro= wser *browser, target_ms.map =3D ms->map; target_ms.sym =3D dl->ops.target.sym; annotation__unlock(notes); - symbol__tui_annotate(&target_ms, evsel, hbt); + __hist_entry__tui_annotate(browser->he, &target_ms, evsel, hbt); sym_title(ms->sym, ms->map, title, sizeof(title), annotate_opts.percent_t= ype); ui_browser__show_title(&browser->b, title); return true; @@ -1032,12 +1033,6 @@ static int annotate_browser__run(struct annotate_bro= wser *browser, return key; } =20 -int map_symbol__tui_annotate(struct map_symbol *ms, struct evsel *evsel, - struct hist_browser_timer *hbt) -{ - return symbol__tui_annotate(ms, evsel, hbt); -} - int hist_entry__tui_annotate(struct hist_entry *he, struct evsel *evsel, struct hist_browser_timer *hbt) { @@ -1046,11 +1041,12 @@ int hist_entry__tui_annotate(struct hist_entry *he,= struct evsel *evsel, SLang_init_tty(0, 0, 0); SLtty_set_suspend_state(true); =20 - return map_symbol__tui_annotate(&he->ms, evsel, hbt); + return __hist_entry__tui_annotate(he, &he->ms, evsel, hbt); } =20 -int symbol__tui_annotate(struct map_symbol *ms, struct evsel *evsel, - struct hist_browser_timer *hbt) +int __hist_entry__tui_annotate(struct hist_entry *he, struct map_symbol *m= s, + struct evsel *evsel, + struct hist_browser_timer *hbt) { struct symbol *sym =3D ms->sym; struct annotation *notes =3D symbol__annotation(sym); @@ -1064,6 +1060,7 @@ int symbol__tui_annotate(struct map_symbol *ms, struc= t evsel *evsel, .priv =3D ms, .use_navkeypressed =3D true, }, + .he =3D he, }; struct dso *dso; int ret =3D -1, err; diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index d9d3fb44477ac6d5..487c0b08c0038710 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c @@ -2484,8 +2484,8 @@ do_annotate(struct hist_browser *browser, struct popu= p_action *act) else evsel =3D hists_to_evsel(browser->hists); =20 - err =3D map_symbol__tui_annotate(&act->ms, evsel, browser->hbt); he =3D hist_browser__selected_entry(browser); + err =3D __hist_entry__tui_annotate(he, &act->ms, evsel, browser->hbt); /* * offer option to annotate the other branch source or target * (if they exists) when returning from annotate diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index 8b5131d257b01e3e..0f640e4871744262 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -471,18 +471,6 @@ int hist_entry__annotate_printf(struct hist_entry *he,= struct evsel *evsel); int hist_entry__tty_annotate(struct hist_entry *he, struct evsel *evsel); int hist_entry__tty_annotate2(struct hist_entry *he, struct evsel *evsel); =20 -#ifdef HAVE_SLANG_SUPPORT -int symbol__tui_annotate(struct map_symbol *ms, struct evsel *evsel, - struct hist_browser_timer *hbt); -#else -static inline int symbol__tui_annotate(struct map_symbol *ms __maybe_unuse= d, - struct evsel *evsel __maybe_unused, - struct hist_browser_timer *hbt __maybe_unused) -{ - return 0; -} -#endif - void annotation_options__init(void); void annotation_options__exit(void); =20 diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index 70438d03ca9c33b1..c64005278687cb02 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h @@ -713,8 +713,9 @@ struct block_hist { #include "../ui/keysyms.h" void attr_to_script(char *buf, struct perf_event_attr *attr); =20 -int map_symbol__tui_annotate(struct map_symbol *ms, struct evsel *evsel, - struct hist_browser_timer *hbt); +int __hist_entry__tui_annotate(struct hist_entry *he, struct map_symbol *m= s, + struct evsel *evsel, + struct hist_browser_timer *hbt); =20 int hist_entry__tui_annotate(struct hist_entry *he, struct evsel *evsel, struct hist_browser_timer *hbt); @@ -742,9 +743,10 @@ int evlist__tui_browse_hists(struct evlist *evlist __m= aybe_unused, { return 0; } -static inline int map_symbol__tui_annotate(struct map_symbol *ms __maybe_u= nused, - struct evsel *evsel __maybe_unused, - struct hist_browser_timer *hbt __maybe_unused) +static inline int __hist_entry__tui_annotate(struct hist_entry *he __maybe= _unused, + struct map_symbol *ms __maybe_unused, + struct evsel *evsel __maybe_unused, + struct hist_browser_timer *hbt __maybe_unused) { return 0; } --=20 2.50.1 From nobody Mon Oct 6 01:29:05 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3D5524CEE8; Fri, 25 Jul 2025 19:38:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753472283; cv=none; b=JI7mdLjjJJH+4UofKzt1t7JLK4HdZkiBtTUvl2fa77sxjHYwzkAeVaE8dAhPpON/hsiQZicFuCPDfmC6d1thtb5/5RHUT4/QUxzurOjLQYtBG6fR3we4p6xw/J4is+fofDiOGsc1EyFj2tFDsI05f171UyYuXFEZqS3/Ay8C8Q8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753472283; c=relaxed/simple; bh=+xRfxl6reT2O47Gb7JM+Ilv6ijsGqAACPOiQ1gg1OQE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LK5yv55VGGGDqvgfwkQeup495XS4lH8Jl2WY9DZQ+b8cwIXTC5fU/dpcbsm4DVoYSiLWb1BI8DzNltVzDV27zr0Rj5ogOyC8q06G91+L85+LxmMAPXrIOaUX1Z5KG3CigLGq11Lwfe0EpktqdLhQChRQB+kNyb2AgTnNdwXnHQI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NjPaKvLq; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NjPaKvLq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3788AC4CEE7; Fri, 25 Jul 2025 19:38:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753472282; bh=+xRfxl6reT2O47Gb7JM+Ilv6ijsGqAACPOiQ1gg1OQE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NjPaKvLqTGop/ine+UqvJrSNOP71Em4gGu1oEJ6Uqdk/XETkYG/4ZhjtwsDcP9tPt cwA2Vr7Q65q5k5ipwur6vTwLktJVRX945P9OYz95rItrGlE1WMZtXt1PwJ9/RmGir+ aiUE3tKYZyfVYkl1F3uzqEqGUrvsYiu//1HN7zjzhhbm90rSAo9o/drt9quEYDceEw ZY7ZrC4YL2MJaOJCIYykJc77n87RyCKL98H7n87+oMNKgi7L3stDFyScmarkGAC2sF 6xREb/V8FTT7AHLokRPmk8fHpOPP8jRwpvDpPFrLLXtOzteljZqTyr3eVzfnUQ419S Vpj+8aH+bTyrw== From: Namhyung Kim To: Arnaldo Carvalho de Melo , Ian Rogers , Kan Liang Cc: Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org Subject: [PATCH v4 2/9] perf annotate: Remove __annotation_line__write() Date: Fri, 25 Jul 2025 12:37:48 -0700 Message-ID: <20250725193755.12276-3-namhyung@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250725193755.12276-1-namhyung@kernel.org> References: <20250725193755.12276-1-namhyung@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Get rid of the internal function and convert function arguments into local variables if they are used more than once. Signed-off-by: Namhyung Kim --- tools/perf/util/annotate.c | 46 ++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 0dd475a744b6dfac..69ee83052396b15e 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -1935,24 +1935,26 @@ int annotation_br_cntr_entry(char **str, int br_cnt= r_nr, return -ENOMEM; } =20 -static void __annotation_line__write(struct annotation_line *al, struct an= notation *notes, - bool first_line, bool current_entry, bool change_color, int width, - void *obj, unsigned int percent_type, - int (*obj__set_color)(void *obj, int color), - void (*obj__set_percent_color)(void *obj, double percent, bool cu= rrent), - int (*obj__set_jumps_percent_color)(void *obj, int nr, bool curr= ent), - void (*obj__printf)(void *obj, const char *fmt, ...), - void (*obj__write_graph)(void *obj, int graph)) - -{ - double percent_max =3D annotation_line__max_percent(al, percent_type); - int pcnt_width =3D annotation__pcnt_width(notes), - cycles_width =3D annotation__cycles_width(notes); +void annotation_line__write(struct annotation_line *al, struct annotation = *notes, + struct annotation_write_ops *wops) +{ + bool current_entry =3D wops->current_entry; + bool change_color =3D wops->change_color; + double percent_max =3D annotation_line__max_percent(al, annotate_opts.per= cent_type); + int width =3D wops->width; + int pcnt_width =3D annotation__pcnt_width(notes); + int cycles_width =3D annotation__cycles_width(notes); bool show_title =3D false; char bf[256]; int printed; - - if (first_line && (al->offset =3D=3D -1 || percent_max =3D=3D 0.0)) { + void *obj =3D wops->obj; + int (*obj__set_color)(void *obj, int color) =3D wops->set_color; + void (*obj__set_percent_color)(void *obj, double percent, bool current) = =3D wops->set_percent_color; + int (*obj__set_jumps_percent_color)(void *obj, int nr, bool current) =3D= wops->set_jumps_percent_color; + void (*obj__printf)(void *obj, const char *fmt, ...) =3D wops->printf; + void (*obj__write_graph)(void *obj, int graph) =3D wops->write_graph; + + if (wops->first_line && (al->offset =3D=3D -1 || percent_max =3D=3D 0.0))= { if (notes->branch && al->cycles) { if (al->cycles->ipc =3D=3D 0.0 && al->cycles->avg =3D=3D 0) show_title =3D true; @@ -1966,7 +1968,8 @@ static void __annotation_line__write(struct annotatio= n_line *al, struct annotati for (i =3D 0; i < al->data_nr; i++) { double percent; =20 - percent =3D annotation_data__percent(&al->data[i], percent_type); + percent =3D annotation_data__percent(&al->data[i], + annotate_opts.percent_type); =20 obj__set_percent_color(obj, percent, current_entry); if (symbol_conf.show_total_period) { @@ -2115,17 +2118,6 @@ static void __annotation_line__write(struct annotati= on_line *al, struct annotati =20 } =20 -void annotation_line__write(struct annotation_line *al, struct annotation = *notes, - struct annotation_write_ops *wops) -{ - __annotation_line__write(al, notes, wops->first_line, wops->current_entry, - wops->change_color, wops->width, wops->obj, - annotate_opts.percent_type, - wops->set_color, wops->set_percent_color, - wops->set_jumps_percent_color, wops->printf, - wops->write_graph); -} - int symbol__annotate2(struct map_symbol *ms, struct evsel *evsel, struct arch **parch) { --=20 2.50.1 From nobody Mon Oct 6 01:29:05 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D2FC24E00F; Fri, 25 Jul 2025 19:38:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753472283; cv=none; b=oLa5jk0HIFUfWNHxMDHCiJaIsN6SiQ5xgAfdW/blDoOmm1Fn8E3lIagW+OjP0qfLebYZllt6l97X4i00FqtS73cnNt4D6rY5u6aVBc3JbqTV12Xw0FWS9z6WHXja7OVyuM0B179VLFgsfVP7dhJUiBOvCay+pA4KCRJ4EwITBQU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753472283; c=relaxed/simple; bh=uHRYfLUvDeNj8maTn+EBLwWa+MfSuuZKS4voL4S27/I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Cejv1keK/xQkN0qVzF2j/vKpggGFRfLfYDmwZtq9mUDYzNuC3xHAj5H/nic0mI7bIcMgcFpnZDlZR96uktjx09zkqttvw7wGCPZzsrs31bjZfJnmOCPM9fF+vv293tc9vxXxTBRoHIQ9E//DDFyJZcHeAA7+bPhpQhoITrOfd4U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=csK6fo/Z; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="csK6fo/Z" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA565C4CEEF; Fri, 25 Jul 2025 19:38:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753472283; bh=uHRYfLUvDeNj8maTn+EBLwWa+MfSuuZKS4voL4S27/I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=csK6fo/ZKvA+xTlIDMknR1+f+MjB3k60JJgoxV2ImKSr7n8Ae7wtOvCe0PeCHueS/ UmOvm/Mos+yXuRsap0wVxg0gVyvXVexeuFL+ajf09FLhKw+xs52gW/cuFF3M15hrUG ygkQsIEfHR/LA990sRLrdpcJaGZy9rTFJlGQW9o6ToudeLXwEHeE00YYtCby3rAQMV qpE/RO906A1HVxyl1ItlJH0E+lH2T+r3GzRfeWBQlb667RExvXaEchaj7rrqp7e1Jv stkkb4w7bFgh8zTqCt72wOxsRhGC6REMlPkIzRkdZH8PM5hAHUbwazJ8H+U+vGyHUY ZbonKvUFjcIeQ== From: Namhyung Kim To: Arnaldo Carvalho de Melo , Ian Rogers , Kan Liang Cc: Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org Subject: [PATCH v4 3/9] perf annotate: Pass annotation_print_data to annotation_line__write() Date: Fri, 25 Jul 2025 12:37:49 -0700 Message-ID: <20250725193755.12276-4-namhyung@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250725193755.12276-1-namhyung@kernel.org> References: <20250725193755.12276-1-namhyung@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" It will be used for data type display later. Signed-off-by: Namhyung Kim Reviewed-by: Ian Rogers --- tools/perf/ui/browsers/annotate.c | 13 ++++++++++-- tools/perf/util/annotate.c | 35 +++++++++++++++++-------------- tools/perf/util/annotate.h | 15 +++++++++++-- 3 files changed, 43 insertions(+), 20 deletions(-) diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/ann= otate.c index 28ef146f29e8e742..23bea5b165774ae7 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -28,6 +28,8 @@ struct annotate_browser { struct annotation_line *selection; struct arch *arch; struct hist_entry *he; + struct debuginfo *dbg; + struct evsel *evsel; bool searching_backwards; char search_bf[128]; }; @@ -108,12 +110,18 @@ static void annotate_browser__write(struct ui_browser= *browser, void *entry, int .printf =3D annotate_browser__printf, .write_graph =3D annotate_browser__write_graph, }; + struct annotation_print_data apd =3D { + .he =3D ab->he, + .arch =3D ab->arch, + .evsel =3D ab->evsel, + .dbg =3D ab->dbg, + }; =20 /* The scroll bar isn't being used */ if (!browser->navkeypressed) ops.width +=3D 1; =20 - annotation_line__write(al, notes, &ops); + annotation_line__write(al, notes, &ops, &apd); =20 if (ops.current_entry) ab->selection =3D al; @@ -976,7 +984,7 @@ static int annotate_browser__run(struct annotate_browse= r *browser, continue; } case 'P': - map_symbol__annotation_dump(ms, evsel); + map_symbol__annotation_dump(ms, evsel, browser->he); continue; case 't': if (symbol_conf.show_total_period) { @@ -1061,6 +1069,7 @@ int __hist_entry__tui_annotate(struct hist_entry *he,= struct map_symbol *ms, .use_navkeypressed =3D true, }, .he =3D he, + .evsel =3D evsel, }; struct dso *dso; int ret =3D -1, err; diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 69ee83052396b15e..c21152710148b68c 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -765,15 +765,6 @@ __hist_entry__get_data_type(struct hist_entry *he, str= uct arch *arch, struct debuginfo *dbg, struct disasm_line *dl, int *type_offset); =20 -struct annotation_print_data { - struct hist_entry *he; - struct evsel *evsel; - struct arch *arch; - struct debuginfo *dbg; - u64 start; - int addr_fmt_width; -}; - static int annotation_line__print(struct annotation_line *al, struct annotation_print= _data *apd, struct annotation_options *opts, int printed, @@ -1230,7 +1221,6 @@ int hist_entry__annotate_printf(struct hist_entry *he= , struct evsel *evsel) struct annotation_print_data apd =3D { .he =3D he, .evsel =3D evsel, - .start =3D map__rip_2objdump(map, sym->start), }; int printed =3D 2, queue_len =3D 0; int more =3D 0; @@ -1357,7 +1347,8 @@ static void FILE__write_graph(void *fp, int graph) fputs(s, fp); } =20 -static int symbol__annotate_fprintf2(struct symbol *sym, FILE *fp) +static int symbol__annotate_fprintf2(struct symbol *sym, FILE *fp, + struct annotation_print_data *apd) { struct annotation *notes =3D symbol__annotation(sym); struct annotation_write_ops wops =3D { @@ -1374,7 +1365,7 @@ static int symbol__annotate_fprintf2(struct symbol *s= ym, FILE *fp) list_for_each_entry(al, ¬es->src->source, node) { if (annotation_line__filter(al)) continue; - annotation_line__write(al, notes, &wops); + annotation_line__write(al, notes, &wops, apd); fputc('\n', fp); wops.first_line =3D false; } @@ -1382,13 +1373,18 @@ static int symbol__annotate_fprintf2(struct symbol = *sym, FILE *fp) return 0; } =20 -int map_symbol__annotation_dump(struct map_symbol *ms, struct evsel *evsel) +int map_symbol__annotation_dump(struct map_symbol *ms, struct evsel *evsel, + struct hist_entry *he) { const char *ev_name =3D evsel__name(evsel); char buf[1024]; char *filename; int err =3D -1; FILE *fp; + struct annotation_print_data apd =3D { + .he =3D he, + .evsel =3D evsel, + }; =20 if (asprintf(&filename, "%s.annotation", ms->sym->name) < 0) return -1; @@ -1404,7 +1400,7 @@ int map_symbol__annotation_dump(struct map_symbol *ms= , struct evsel *evsel) =20 fprintf(fp, "%s() %s\nEvent: %s\n\n", ms->sym->name, dso__long_name(map__dso(ms->map)), ev_name); - symbol__annotate_fprintf2(ms->sym, fp); + symbol__annotate_fprintf2(ms->sym, fp, &apd); =20 fclose(fp); err =3D 0; @@ -1656,6 +1652,10 @@ int hist_entry__tty_annotate2(struct hist_entry *he,= struct evsel *evsel) struct symbol *sym =3D ms->sym; struct rb_root source_line =3D RB_ROOT; struct hists *hists =3D evsel__hists(evsel); + struct annotation_print_data apd =3D { + .he =3D he, + .evsel =3D evsel, + }; char buf[1024]; int err; =20 @@ -1678,7 +1678,7 @@ int hist_entry__tty_annotate2(struct hist_entry *he, = struct evsel *evsel) hists__scnprintf_title(hists, buf, sizeof(buf)); fprintf(stdout, "%s, [percent: %s]\n%s() %s\n", buf, percent_type_str(annotate_opts.percent_type), sym->name, dso__long_= name(dso)); - symbol__annotate_fprintf2(sym, stdout); + symbol__annotate_fprintf2(sym, stdout, &apd); =20 annotated_source__purge(symbol__annotation(sym)->src); =20 @@ -1936,7 +1936,8 @@ int annotation_br_cntr_entry(char **str, int br_cntr_= nr, } =20 void annotation_line__write(struct annotation_line *al, struct annotation = *notes, - struct annotation_write_ops *wops) + struct annotation_write_ops *wops, + struct annotation_print_data *apd) { bool current_entry =3D wops->current_entry; bool change_color =3D wops->change_color; @@ -2114,6 +2115,8 @@ void annotation_line__write(struct annotation_line *a= l, struct annotation *notes disasm_line__write(disasm_line(al), notes, obj, bf, sizeof(bf), obj__pri= ntf, obj__write_graph); =20 obj__printf(obj, "%-*s", width - pcnt_width - cycles_width - 3 - printed= , bf); + + (void)apd; } =20 } diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index 0f640e4871744262..8fad464a870a2b8e 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -199,8 +199,18 @@ struct annotation_write_ops { void (*write_graph)(void *obj, int graph); }; =20 +struct annotation_print_data { + struct hist_entry *he; + struct evsel *evsel; + struct arch *arch; + struct debuginfo *dbg; + u64 start; + int addr_fmt_width; +}; + void annotation_line__write(struct annotation_line *al, struct annotation = *notes, - struct annotation_write_ops *ops); + struct annotation_write_ops *ops, + struct annotation_print_data *apd); =20 int __annotation__scnprintf_samples_period(struct annotation *notes, char *bf, size_t size, @@ -463,7 +473,8 @@ void symbol__annotate_zero_histogram(struct symbol *sym= , struct evsel *evsel); void symbol__annotate_decay_histogram(struct symbol *sym, struct evsel *ev= sel); void annotated_source__purge(struct annotated_source *as); =20 -int map_symbol__annotation_dump(struct map_symbol *ms, struct evsel *evsel= ); +int map_symbol__annotation_dump(struct map_symbol *ms, struct evsel *evsel, + struct hist_entry *he); =20 bool ui__has_annotation(void); =20 --=20 2.50.1 From nobody Mon Oct 6 01:29:05 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 17E22253F00; Fri, 25 Jul 2025 19:38:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753472284; cv=none; b=GSz7NO/k3LqSB59cH9a2Do/NkB78cuveV+HsaeXJCFYpcf65NMx149fXOjdJvmNGtWXQxIQD9a6gLyrEm09U6O6p1LX1U5HE99aaHbl222lcxUUX+io3BM2nFjdMrfhcZkpAcG0Sxp3HRaucxz22a6Kz/+kTwRFWjm4IikqfrhY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753472284; c=relaxed/simple; bh=wQ9L7f8hO9TQ6BvEZdDgbDLshKYzraqvQQQMdZzUV/g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FuWsR1k8ZXzS6QO9Rql3H8+FO+Vd25aXpUpLE+MvrEKeNov8YMksG2+mOjcazMXi55ZjOJR5PatsYZkCz4Bjtz0GOpp+DA53fuMXrfcpJFiMH86QkY/u1g2Wk8QzaJ2c3tTMGqZMb2JLSU4retyG6Ss6GRIrURUWLpKJ+qKHXcI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=p2WIh1/+; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="p2WIh1/+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43F98C4CEF8; Fri, 25 Jul 2025 19:38:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753472283; bh=wQ9L7f8hO9TQ6BvEZdDgbDLshKYzraqvQQQMdZzUV/g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p2WIh1/+nxQMD4lbCK+Dy6pSEcbo+HQGR9I6k+gzPBTCh9+pSSRcGzKkwogRgrdMo vQ/Sr1zXNRUzm0CafR//XUrH+vSEwiLFDiIBeZYuFqmcdZdh8SwFLql6mXsFISxHhF o9xIGkiXwL2mPwR/N38R4A5mCDsQRWjkLQXFCQG/SzuMc5vGMvQYV+NDNGqpWUdD9g r4do+Hf6ze9DKTtOGbrPWjyT1Z5m+iP/Dzlf2FEaqjZ/CNgeVF8UMe3Pn7QtR5PMBJ D94hvIQy/kNfJMHFqbuxQt7GXBLbWZsbXlTDDZgMPuoFfGw8oa8F1htX4QkkE90Z2g jbIgy8hjEL6fQ== From: Namhyung Kim To: Arnaldo Carvalho de Melo , Ian Rogers , Kan Liang Cc: Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org Subject: [PATCH v4 4/9] perf annotate: Simplify width calculation in annotation_line__write() Date: Fri, 25 Jul 2025 12:37:50 -0700 Message-ID: <20250725193755.12276-5-namhyung@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250725193755.12276-1-namhyung@kernel.org> References: <20250725193755.12276-1-namhyung@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The width is updated after each part is printed. It can skip the output processing if the total printed size is bigger than the width. No function changes intended. Signed-off-by: Namhyung Kim --- tools/perf/util/annotate.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index c21152710148b68c..d69e406c1bc289cd 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -1993,6 +1993,7 @@ void annotation_line__write(struct annotation_line *a= l, struct annotation *notes symbol_conf.show_nr_samples ? "Samples" : "Percent"); } } + width -=3D pcnt_width; =20 if (notes->branch) { if (al->cycles && al->cycles->ipc) @@ -2056,11 +2057,12 @@ void annotation_line__write(struct annotation_line = *al, struct annotation *notes obj__printf(obj, "%*s", ANNOTATION__AVG_IPC_WIDTH, bf); } } + width -=3D cycles_width; =20 obj__printf(obj, " "); =20 if (!*al->line) - obj__printf(obj, "%-*s", width - pcnt_width - cycles_width, " "); + obj__printf(obj, "%-*s", width, " "); else if (al->offset =3D=3D -1) { if (al->line_nr && annotate_opts.show_linenr) printed =3D scnprintf(bf, sizeof(bf), "%-*d ", @@ -2069,7 +2071,7 @@ void annotation_line__write(struct annotation_line *a= l, struct annotation *notes printed =3D scnprintf(bf, sizeof(bf), "%-*s ", notes->src->widths.addr, " "); obj__printf(obj, bf); - obj__printf(obj, "%-*s", width - printed - pcnt_width - cycles_width + 1= , al->line); + obj__printf(obj, "%-*s", width - printed + 1, al->line); } else { u64 addr =3D al->offset; int color =3D -1; @@ -2112,9 +2114,11 @@ void annotation_line__write(struct annotation_line *= al, struct annotation *notes if (change_color) obj__set_color(obj, color); =20 + width -=3D printed + 3; + disasm_line__write(disasm_line(al), notes, obj, bf, sizeof(bf), obj__pri= ntf, obj__write_graph); =20 - obj__printf(obj, "%-*s", width - pcnt_width - cycles_width - 3 - printed= , bf); + obj__printf(obj, "%-*s", width, bf); =20 (void)apd; } --=20 2.50.1 From nobody Mon Oct 6 01:29:05 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4378A254876; Fri, 25 Jul 2025 19:38:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753472284; cv=none; b=o/0gqfor5mdTiwDhRMuCoZdEn+asMrr7mkU6nHVwPoi9ihSvR30twtfX8C5beQxqfV9bu4Bw1yTT6u36kDG9uwpbhp45ykwaYELFwG7HV3B8DH3H0VUoDZfTdKO8Zs1mMx7rDg+p9/Yp21+wtvpxtYgw96558P7xKdTsemL1FdI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753472284; c=relaxed/simple; bh=EKg15sMXsH25mK5b/RDI8GRaMQ9l1ESv3pCQz+tdD2k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LYGak0mNy/8TT9zG28zL2+YVUcO5gNgJwu8enmRphh/F2k97VFNwAin8oCT8zni+7ybrrb3hPL9s8sw79Hi/VspGWURSO86b0vkB0vwcXgNpMu1RmhGnvpfQX/RbNp0tp2XKWzOwpNufiG0KRPh6LdPy7ReDIXXGXptyf+ZpCMA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RBEQ+OJ1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RBEQ+OJ1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3627C4CEF6; Fri, 25 Jul 2025 19:38:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753472284; bh=EKg15sMXsH25mK5b/RDI8GRaMQ9l1ESv3pCQz+tdD2k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RBEQ+OJ1B5ga+a0qWu4muyZpEguKMiMh+6TLZVncAL8G6FVGqHnnyxSMoCqo6dgGm eJ7nEyCk+6FfPhvpz8rjAFKKI9Ka3jB7spzx/qvQIs0jzyfoqR+hEPHem3a7KxNpdI l0207gR9JWiPcT3Mhg0r4xmx7sjW1wwWlgXv4HfLDa1uYpFIIrZyjRY+AH2Z0PDVOS 6QG4cBMkVrxbsQITIqgJq9z/zJJEuNR+Zg42TNYr7LdfzJt2l9ImHLtCgnxSRoVLA6 3ou+oR93DjOrvuunsMFGKnyn2jqL79HdAg4f/6gjRUy7Kbk1kTypE6UFxCluDCmEjP K4j8ytxNU5fNw== From: Namhyung Kim To: Arnaldo Carvalho de Melo , Ian Rogers , Kan Liang Cc: Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org Subject: [PATCH v4 5/9] perf annotate: Add --code-with-type support for TUI Date: Fri, 25 Jul 2025 12:37:51 -0700 Message-ID: <20250725193755.12276-6-namhyung@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250725193755.12276-1-namhyung@kernel.org> References: <20250725193755.12276-1-namhyung@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Until now, the --code-with-type option is available only on stdio. But it was an artifical limitation because of an implemention issue. Implement the same logic in annotation_line__write() for stdio2/TUI. Make disasm_line__write() return the number of printed characters so that it can skip unnecessary operations when the screen is full. Remove the limitation and update the man page. Signed-off-by: Namhyung Kim --- tools/perf/Documentation/perf-annotate.txt | 1 - tools/perf/builtin-annotate.c | 5 -- tools/perf/ui/browsers/annotate.c | 6 +++ tools/perf/util/annotate.c | 61 +++++++++++++++++++--- 4 files changed, 61 insertions(+), 12 deletions(-) diff --git a/tools/perf/Documentation/perf-annotate.txt b/tools/perf/Docume= ntation/perf-annotate.txt index 46090c5b42b4762f..547f1a2680185e3c 100644 --- a/tools/perf/Documentation/perf-annotate.txt +++ b/tools/perf/Documentation/perf-annotate.txt @@ -170,7 +170,6 @@ include::itrace.txt[] =20 --code-with-type:: Show data type info in code annotation (for memory instructions only). - Currently it only works with --stdio option. =20 =20 SEE ALSO diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 5d57d2913f3d9a33..646f43b0f7c4c9b0 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -917,11 +917,6 @@ int cmd_annotate(int argc, const char **argv) symbol_conf.annotate_data_sample =3D true; } else if (annotate_opts.code_with_type) { symbol_conf.annotate_data_member =3D true; - - if (!annotate.use_stdio) { - pr_err("--code-with-type only works with --stdio.\n"); - goto out_delete; - } } =20 setup_browser(true); diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/ann= otate.c index 23bea5b165774ae7..cdee1969f3131a7c 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -4,6 +4,7 @@ #include "../ui.h" #include "../../util/annotate.h" #include "../../util/debug.h" +#include "../../util/debuginfo.h" #include "../../util/dso.h" #include "../../util/hist.h" #include "../../util/sort.h" @@ -1101,6 +1102,9 @@ int __hist_entry__tui_annotate(struct hist_entry *he,= struct map_symbol *ms, =20 ui_helpline__push("Press ESC to exit"); =20 + if (annotate_opts.code_with_type) + browser.dbg =3D debuginfo__new(dso__long_name(dso)); + browser.b.width =3D notes->src->widths.max_line_len; browser.b.nr_entries =3D notes->src->nr_entries; browser.b.entries =3D ¬es->src->source; @@ -1111,6 +1115,8 @@ int __hist_entry__tui_annotate(struct hist_entry *he,= struct map_symbol *ms, =20 ret =3D annotate_browser__run(&browser, evsel, hbt); =20 + if (annotate_opts.code_with_type) + debuginfo__delete(browser.dbg); if (not_annotated && !notes->src->tried_source) annotated_source__purge(notes->src); =20 diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index d69e406c1bc289cd..06ddc7a9f58722a4 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -1362,6 +1362,11 @@ static int symbol__annotate_fprintf2(struct symbol *= sym, FILE *fp, }; struct annotation_line *al; =20 + if (annotate_opts.code_with_type) { + evsel__get_arch(apd->evsel, &apd->arch); + apd->dbg =3D debuginfo__new(dso__long_name(map__dso(apd->he->ms.map))); + } + list_for_each_entry(al, ¬es->src->source, node) { if (annotation_line__filter(al)) continue; @@ -1370,6 +1375,9 @@ static int symbol__annotate_fprintf2(struct symbol *s= ym, FILE *fp, wops.first_line =3D false; } =20 + if (annotate_opts.code_with_type) + debuginfo__delete(apd->dbg); + return 0; } =20 @@ -1743,7 +1751,7 @@ static double annotation_line__max_percent(struct ann= otation_line *al, return percent_max; } =20 -static void disasm_line__write(struct disasm_line *dl, struct annotation *= notes, +static int disasm_line__write(struct disasm_line *dl, struct annotation *n= otes, void *obj, char *bf, size_t size, void (*obj__printf)(void *obj, const char *fmt, ...), void (*obj__write_graph)(void *obj, int graph)) @@ -1771,8 +1779,8 @@ static void disasm_line__write(struct disasm_line *dl= , struct annotation *notes, obj__printf(obj, " "); } =20 - disasm_line__scnprintf(dl, bf, size, !annotate_opts.use_offset, - notes->src->widths.max_ins_name); + return disasm_line__scnprintf(dl, bf, size, !annotate_opts.use_offset, + notes->src->widths.max_ins_name); } =20 static void ipc_coverage_string(char *bf, int size, struct annotation *not= es) @@ -2116,11 +2124,52 @@ void annotation_line__write(struct annotation_line = *al, struct annotation *notes =20 width -=3D printed + 3; =20 - disasm_line__write(disasm_line(al), notes, obj, bf, sizeof(bf), obj__pri= ntf, obj__write_graph); + printed =3D disasm_line__write(disasm_line(al), notes, obj, bf, sizeof(b= f), + obj__printf, obj__write_graph); + + obj__printf(obj, "%s", bf); + width -=3D printed; + + if (annotate_opts.code_with_type && apd->dbg) { + struct annotated_data_type *data_type; + int offset =3D 0; + + data_type =3D __hist_entry__get_data_type(apd->he, apd->arch, + apd->dbg, + disasm_line(al), + &offset); + if (data_type && data_type !=3D NO_TYPE) { + char member[256]; + + printed =3D scnprintf(bf, sizeof(bf), + "\t\t# data-type: %s", + data_type->self.type_name); =20 - obj__printf(obj, "%-*s", width, bf); + if (data_type !=3D &stackop_type && + data_type !=3D &canary_type && + sizeof(bf) > (size_t)printed) { + printed +=3D scnprintf(bf + printed, + sizeof(bf) - printed, + " +%#x", offset); + } + + if (annotated_data_type__get_member_name(data_type, + member, + sizeof(member), + offset) && + sizeof(bf) > (size_t)printed) { + printed +=3D scnprintf(bf + printed, + sizeof(bf) - printed, + " (%s)", member); + } =20 - (void)apd; + obj__printf(obj, "%-*s", width, bf); + } else { + obj__printf(obj, "%-*s", width, " "); + } + } else { + obj__printf(obj, "%-*s", width, " "); + } } =20 } --=20 2.50.1 From nobody Mon Oct 6 01:29:05 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C773D257AF0; Fri, 25 Jul 2025 19:38:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753472284; cv=none; b=A9j6LuRILj7l6nRqAmgON3Xpiy5j7Vq3ru4KG3CdIIT0PbViwNLQUcjIogOSULIdUEhbcX/41QgLSVtwztcKCiyZ3V8pAk8O55LSME60W5sPuoO/4eztiG3Hml8xH/UvJA0Y1q3+QCu/JvY2VEIm8n9Czp64qmdHa9SxuDDHcP0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753472284; c=relaxed/simple; bh=RZwoNefxnoF2jKQS/nrvWEJRyA20FSBuyZwRH1BtM18=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=s9TpTK9qi032xevWWsrlwaLerGsm8QnXPq/BlFbyykZdo2+UXXEP6H7cmCiS05eiCpBb9UCLOo7b5JgvA/XzE/+0bXd/zMVrM8IgoiHVil2x9U6C0x7uVB68pOc/dfgwOyiOiVTHxx2rNdqMNi+dOB/rayUIc52aBwNq5jcX2ww= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pnGFBffG; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pnGFBffG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A699C4CEF7; Fri, 25 Jul 2025 19:38:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753472284; bh=RZwoNefxnoF2jKQS/nrvWEJRyA20FSBuyZwRH1BtM18=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pnGFBffGD7znfhMFp1VvnEi6OIWmwxvcjvq9DwIjAyxnRomYcbwroX33vmPMz1Vk4 krpkn6dOwoVG5TILlbo86fwxIZQiGEMYTUpaI1QmozEoxb4k6gvIGD+UdOZz8eRIQP hYiJsqxa8USY3UwXi2JScnJQgbtIdw5gnmencj/Ase6cWAsVAJsMVLRGebAWOk9g70 dbVMXeBmOowCBi8/mqErriUBDodR5y6oPofxAtAZI7beEH1+6tS+nTsQD16p2jxw8X b+d/jQ+oNQPHag0xQ9vc15iZ07TSdlQfdi2QLXUyRScnpTXjL5ynfwAEcR/BapUw+/ cvNwXalVxHd1g== From: Namhyung Kim To: Arnaldo Carvalho de Melo , Ian Rogers , Kan Liang Cc: Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org Subject: [PATCH v4 6/9] perf annotate: Add 'T' hot key to toggle data type display Date: Fri, 25 Jul 2025 12:37:52 -0700 Message-ID: <20250725193755.12276-7-namhyung@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250725193755.12276-1-namhyung@kernel.org> References: <20250725193755.12276-1-namhyung@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Support data type display with a key press so that users can toggle the output dynamically on TUI. Also display "[Type]" in the title line if it's enabled. Signed-off-by: Namhyung Kim --- tools/perf/ui/browsers/annotate.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/ann= otate.c index cdee1969f3131a7c..4b059e0bafd33fcf 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -525,9 +525,10 @@ static void ui_browser__init_asm_mode(struct ui_browse= r *browser) static int sym_title(struct symbol *sym, struct map *map, char *title, size_t sz, int percent_type) { - return snprintf(title, sz, "%s %s [Percent: %s]", sym->name, + return snprintf(title, sz, "%s %s [Percent: %s] %s", sym->name, dso__long_name(map__dso(map)), - percent_type_str(percent_type)); + percent_type_str(percent_type), + annotate_opts.code_with_type ? "[Type]" : ""); } =20 /* @@ -901,7 +902,8 @@ static int annotate_browser__run(struct annotate_browse= r *browser, "b Toggle percent base [period/hits]\n" "B Branch counter abbr list (Optional)\n" "? Search string backwards\n" - "f Toggle showing offsets to full address\n"); + "f Toggle showing offsets to full address\n" + "T Toggle data type display\n"); continue; case 'r': script_browse(NULL, NULL); @@ -1021,6 +1023,12 @@ static int annotate_browser__run(struct annotate_bro= wser *browser, case 'f': annotation__toggle_full_addr(notes, ms); continue; + case 'T': + annotate_opts.code_with_type ^=3D 1; + if (browser->dbg =3D=3D NULL) + browser->dbg =3D debuginfo__new(dso__long_name(map__dso(ms->map))); + annotate_browser__show(&browser->b, title, help); + continue; case K_LEFT: case '<': case '>': @@ -1115,8 +1123,7 @@ int __hist_entry__tui_annotate(struct hist_entry *he,= struct map_symbol *ms, =20 ret =3D annotate_browser__run(&browser, evsel, hbt); =20 - if (annotate_opts.code_with_type) - debuginfo__delete(browser.dbg); + debuginfo__delete(browser.dbg); if (not_annotated && !notes->src->tried_source) annotated_source__purge(notes->src); =20 --=20 2.50.1 From nobody Mon Oct 6 01:29:05 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AEBD125A352; Fri, 25 Jul 2025 19:38:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753472285; cv=none; b=LznUPSocr/aiuR9DzGrEhnJtNJKa2YjtmBhX86lNjq7aD9j1WvRYTCPwdaEQ18bpqaTMnQEcZeCICi8yXWVVzYoXQBS2lj8HISTYuklim1B7OD+nC8mJdE7Jet1XydYlgUPynwtmmHHauRPNZTjP7MqfdpIVrxcNfbwxU/9asYs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753472285; c=relaxed/simple; bh=rMP4NwEbgs09Yo6duPN7LsyJrXjr4LcRueUhN1EP6L0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XkqoAeItPuv4/ax3WD/uYqvuFFB3AbHR5sp3wASOLLm7nKSUucpXUS/Mjwql0wZag18Q1OEY5lULlszFdIIetDHgBUzG25k1KI+qMf5SUPNUhC8o23XlqGRlaJ8riEhR7EVxxa/wShiXh3C7yQBrHa3Kq125jIpj8d7O47wFR6Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QsvrNXeH; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QsvrNXeH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C67A3C4CEF8; Fri, 25 Jul 2025 19:38:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753472285; bh=rMP4NwEbgs09Yo6duPN7LsyJrXjr4LcRueUhN1EP6L0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QsvrNXeHY26NDoQp4A8mJfP6ig1bOkYAim2QVT1IgQFGTSyVLAriZOB+pciHdsJQ9 O5KQTIUyQBqUdIAs2++p2tTD4Pc9wOpkOt4jceJEaE7sWwgzSh3s7+UkVMw/Y2ec3y aRSRynFmRF+msMUGb+nhad7o2qe7p8oonR9nPunL2CWim9TvPsGZBHJSp4fIf3vpoD TjZI9lwCTegEwlWnJk0v+5fjpi1LcGqGOwi8X5KgQp66f7ZwkFP6HtcMVks1D9P2d6 BPMi60mJHyM5uAIGPVheowQGjLHGl9ITaGExAD1Vy/azcg/pxAAUQfJsGry4EBiRfp U4ZyrbxJsaQqg== From: Namhyung Kim To: Arnaldo Carvalho de Melo , Ian Rogers , Kan Liang Cc: Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org Subject: [PATCH v4 7/9] perf annotate: Show warning when debuginfo is not available Date: Fri, 25 Jul 2025 12:37:53 -0700 Message-ID: <20250725193755.12276-8-namhyung@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250725193755.12276-1-namhyung@kernel.org> References: <20250725193755.12276-1-namhyung@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When user requests data-type annotation but no DWARF info is available, show a warning message about it. Warning: DWARF debuginfo not found. Data-type in this DSO will not be displayed. Please make sure to have debug information. Press any key... Signed-off-by: Namhyung Kim --- tools/perf/ui/browsers/annotate.c | 17 +++++++++++++++++ tools/perf/util/dso.h | 11 +++++++++++ 2 files changed, 28 insertions(+) diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/ann= otate.c index 4b059e0bafd33fcf..2a4db5bdcdb7e9d8 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -804,6 +804,20 @@ static int annotate__scnprintf_title(struct hists *his= ts, char *bf, size_t size) return printed; } =20 +static void annotate_browser__debuginfo_warning(struct annotate_browser *b= rowser) +{ + struct map_symbol *ms =3D browser->b.priv; + struct dso *dso =3D map__dso(ms->map); + + if (browser->dbg =3D=3D NULL && annotate_opts.code_with_type && + !dso__debuginfo_warned(dso)) { + ui__warning("DWARF debuginfo not found.\n\n" + "Data-type in this DSO will not be displayed.\n" + "Please make sure to have debug information."); + dso__set_debuginfo_warned(dso); + } +} + static int annotate_browser__run(struct annotate_browser *browser, struct evsel *evsel, struct hist_browser_timer *hbt) @@ -834,6 +848,8 @@ static int annotate_browser__run(struct annotate_browse= r *browser, =20 annotation_br_cntr_abbr_list(&br_cntr_text, evsel, false); =20 + annotate_browser__debuginfo_warning(browser); + while (1) { key =3D ui_browser__run(&browser->b, delay_secs); =20 @@ -1028,6 +1044,7 @@ static int annotate_browser__run(struct annotate_brow= ser *browser, if (browser->dbg =3D=3D NULL) browser->dbg =3D debuginfo__new(dso__long_name(map__dso(ms->map))); annotate_browser__show(&browser->b, title, help); + annotate_browser__debuginfo_warning(browser); continue; case K_LEFT: case '<': diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h index 3457d713d3c56df6..7df1673f08d3ddb4 100644 --- a/tools/perf/util/dso.h +++ b/tools/perf/util/dso.h @@ -299,6 +299,7 @@ DECLARE_RC_STRUCT(dso) { u8 hit:1; u8 annotate_warned:1; u8 auxtrace_warned:1; + u8 debuginfo_warned:1; u8 short_name_allocated:1; u8 long_name_allocated:1; u8 is_64_bit:1; @@ -362,6 +363,16 @@ static inline void dso__set_annotate_warned(struct dso= *dso) RC_CHK_ACCESS(dso)->annotate_warned =3D 1; } =20 +static inline bool dso__debuginfo_warned(const struct dso *dso) +{ + return RC_CHK_ACCESS(dso)->debuginfo_warned; +} + +static inline void dso__set_debuginfo_warned(struct dso *dso) +{ + RC_CHK_ACCESS(dso)->debuginfo_warned =3D 1; +} + static inline bool dso__auxtrace_warned(const struct dso *dso) { return RC_CHK_ACCESS(dso)->auxtrace_warned; --=20 2.50.1 From nobody Mon Oct 6 01:29:05 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 18F6025B2F4; Fri, 25 Jul 2025 19:38:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753472286; cv=none; b=AZDl6DKoCOguEp+h1edySY3126etjwGiAppo9qfvwax77v8F38fgxqY9IJgGwssWYPeDSFxtPMPOGSmNexAUbDOercQQ+WUn3BQX6C6L9rip9nbCPEVQ9LiWt7Xp22pvuap/2e4jKcnXdRA36PWsacJ/pwcasd87ndBkBz1R/Xw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753472286; c=relaxed/simple; bh=sV+jtxkR0MKnjqlOdl3FeDkrZ+55eI0w/gMHwiB93nk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F2DHfI3sPMF1Ija7oc/59+XkboAoh1E63Lmk27+iDBMGdO7U89MVuujus7OBrTPoAv6OsdxJgW7CDFUUecCut35DO6dWBbwZoKVXjvnQlimDjttCA44qpplKlq43RKQDLRx8v7KyjAZhEXLnv9ch/yHsCzAvgHE/hE1k8uhjD2c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=K1SlLC9j; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="K1SlLC9j" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50DEBC4CEEF; Fri, 25 Jul 2025 19:38:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753472285; bh=sV+jtxkR0MKnjqlOdl3FeDkrZ+55eI0w/gMHwiB93nk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K1SlLC9jj/UI/axYvABCWKItSIiMjyJEmzXv7yx9Qz4k8GrfozvIB+pMfW6wy3eCD TtBCdRlwR6PbueVIye1DhUU/IRxFT6Mtvkn/4uIN92ZE1Svm/sO6hFw4XGiDf2QXxF FOt5F/WPSZjYuRYuiEUhvVyfGHSRDoJR/Cf1WPzBc65ecXcup3C7wwAAKX9avOqyUG e9ZK4qWLPmMhjsK7Y7Zsq/8MELaxsoWUIZaqTCPJ1ewyIcOFxAHw0vx0GBsTiTHPZ3 nRBcQSmdCn5SgewNusqEIBLR+g6fB5YP9xEn1QPrjOYp17Efv/w1m4kSM9ptMZEWl+ NoZ2RZL1e+CGg== From: Namhyung Kim To: Arnaldo Carvalho de Melo , Ian Rogers , Kan Liang Cc: Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org Subject: [PATCH v4 8/9] perf annotate: Hide data-type for stack operation and canary Date: Fri, 25 Jul 2025 12:37:54 -0700 Message-ID: <20250725193755.12276-9-namhyung@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250725193755.12276-1-namhyung@kernel.org> References: <20250725193755.12276-1-namhyung@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" It's mostly unnecessary to print when it has no actual type information like in the stack operations and canary. Let's have them if -v option is given. Before: $ perf annotate --code-with-type ... : 0 0xd640 <_dl_relocate_object>: 0.00 : 0: endbr64 0.00 : 4: pushq %rbp # data-type: (stack operati= on) 0.00 : 5: movq %rsp, %rbp 0.00 : 8: pushq %r15 # data-type: (stack operati= on) 0.00 : a: pushq %r14 # data-type: (stack operati= on) 0.00 : c: pushq %r13 # data-type: (stack operati= on) 0.00 : e: pushq %r12 # data-type: (stack operati= on) 0.00 : 10: pushq %rbx # data-type: (stack operati= on) 0.00 : 11: subq $0xf8, %rsp ... 0.00 : d4: testl %eax, %eax 0.00 : d6: jne 0xf424 0.00 : dc: movq 0xf0(%r14), %rbx # data-type= : struct link_map +0xf0 0.00 : e3: testq %rbx, %rbx 0.00 : e6: jne 0xf2dd 0.00 : ec: cmpq $0, 0xf8(%r14) # data-type: struct= link_map +0xf8 ... After: : 0 0xd640 <_dl_relocate_object>: 0.00 : 0: endbr64 0.00 : 4: pushq %rbp 0.00 : 5: movq %rsp, %rbp 0.00 : 8: pushq %r15 0.00 : a: pushq %r14 0.00 : c: pushq %r13 0.00 : e: pushq %r12 0.00 : 10: pushq %rbx 0.00 : 11: subq $0xf8, %rsp ... 0.00 : d4: testl %eax, %eax 0.00 : d6: jne 0xf424 0.00 : dc: movq 0xf0(%r14), %rbx # data-type= : struct link_map +0xf0 0.00 : e3: testq %rbx, %rbx 0.00 : e6: jne 0xf2dd 0.00 : ec: cmpq $0, 0xf8(%r14) # data-type: struct= link_map +0xf8 ... Signed-off-by: Namhyung Kim Reviewed-by: Ian Rogers --- tools/perf/util/annotate.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 06ddc7a9f58722a4..6fc07971631ac8a3 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -765,6 +765,17 @@ __hist_entry__get_data_type(struct hist_entry *he, str= uct arch *arch, struct debuginfo *dbg, struct disasm_line *dl, int *type_offset); =20 +static bool needs_type_info(struct annotated_data_type *data_type) +{ + if (data_type =3D=3D NULL || data_type =3D=3D NO_TYPE) + return false; + + if (verbose) + return true; + + return (data_type !=3D &stackop_type) && (data_type !=3D &canary_type); +} + static int annotation_line__print(struct annotation_line *al, struct annotation_print= _data *apd, struct annotation_options *opts, int printed, @@ -844,7 +855,7 @@ annotation_line__print(struct annotation_line *al, stru= ct annotation_print_data =20 data_type =3D __hist_entry__get_data_type(apd->he, apd->arch, apd->dbg, dl, &offset); - if (data_type && data_type !=3D NO_TYPE) { + if (needs_type_info(data_type)) { char buf[4096]; =20 printf("\t\t# data-type: %s", @@ -2138,7 +2149,7 @@ void annotation_line__write(struct annotation_line *a= l, struct annotation *notes apd->dbg, disasm_line(al), &offset); - if (data_type && data_type !=3D NO_TYPE) { + if (needs_type_info(data_type)) { char member[256]; =20 printed =3D scnprintf(bf, sizeof(bf), --=20 2.50.1 From nobody Mon Oct 6 01:29:05 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DEF1B24A051; Fri, 25 Jul 2025 19:38:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753472293; cv=none; b=OyH6gWAGA+5MHhGnihXmhHfLLsR6hjuRCanipHPcwvlba1qh5sy1yCw5XOUIgO8uBgNGdL41Ic3iNQLxMOQZUyXkx3Q7OfVjJ/8cwxFKlQOvwhZ3ya8w+SZSroq66fv+7V/Y2qdUTkPT4OwlwQPrxj2dPrno+itrWfKP9LSsTWA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753472293; c=relaxed/simple; bh=FBzJE/zcrbCRDFg7+nPtUWKHLbZcikfu52tPxC8ov4c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZVX/ZIFNer3Bc5xPlZKkn072bgQEgA5U/U14II3jwuJyQj+aNM82qBy8tWravUtjdEDCIZvXtJCY5PKW1Wap/fDClFajQY+R9QgDXskytos7YtXS9H7ZzjfTQq01Ei0bL+g/hctTxpkK5RnmdyafmSeEbmdQnbZpawgl1j+fXIE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nQ5CNljF; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nQ5CNljF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2169BC4CEE7; Fri, 25 Jul 2025 19:38:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753472292; bh=FBzJE/zcrbCRDFg7+nPtUWKHLbZcikfu52tPxC8ov4c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nQ5CNljFVqeNeUQ2UO8EiMp5lF4p119riNz/3EoIT8jc4Sti5K9Ny+kPjdzMCCZkb HD9TialCLBbSwjupC12Yc0WYNXVH9ERBee28/gvhHG7DLs+BOMIMpxnv/HjqoHIc2q vQ8FPValqp8g6Z86LXJeHAK5D/Q1oCVHfbZqw+dXhaLtkku+ENRCGeg9s8/WoLgbKe HtpJIq3VKVkxOi/D0gCbRV8aKVvdBDqUBSUqgTUemLdJQAjK811Qp5R3kAULmaRinx DLdrax19nZQlnMtUQeAC5idHZbL5TsWUz8yKiEGx2fVV8BgvVDjPNy69YibX7ktuly 1gVN/pG0ezbcw== From: Namhyung Kim To: Arnaldo Carvalho de Melo , Ian Rogers , Kan Liang Cc: Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org Subject: [PATCH v4 9/9] perf annotate: Add dso__debuginfo() helper Date: Fri, 25 Jul 2025 12:37:55 -0700 Message-ID: <20250725193755.12276-10-namhyung@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250725193755.12276-1-namhyung@kernel.org> References: <20250725193755.12276-1-namhyung@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" It'd be great if it can get the correct debug information using DSO build-Id not just the path name. Instead of adding new callsites of debuginfo__new(), let's add dso__debuginfo() which can hide the access using the pathname and help the future conversion. Suggested-by: Ian Rogers Signed-off-by: Namhyung Kim --- tools/perf/ui/browsers/annotate.c | 4 ++-- tools/perf/util/annotate.c | 6 +++--- tools/perf/util/dso.h | 10 ++++++++++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/ann= otate.c index 2a4db5bdcdb7e9d8..54610621c5f910fe 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -1042,7 +1042,7 @@ static int annotate_browser__run(struct annotate_brow= ser *browser, case 'T': annotate_opts.code_with_type ^=3D 1; if (browser->dbg =3D=3D NULL) - browser->dbg =3D debuginfo__new(dso__long_name(map__dso(ms->map))); + browser->dbg =3D dso__debuginfo(map__dso(ms->map)); annotate_browser__show(&browser->b, title, help); annotate_browser__debuginfo_warning(browser); continue; @@ -1128,7 +1128,7 @@ int __hist_entry__tui_annotate(struct hist_entry *he,= struct map_symbol *ms, ui_helpline__push("Press ESC to exit"); =20 if (annotate_opts.code_with_type) - browser.dbg =3D debuginfo__new(dso__long_name(dso)); + browser.dbg =3D dso__debuginfo(dso); =20 browser.b.width =3D notes->src->widths.max_line_len; browser.b.nr_entries =3D notes->src->nr_entries; diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 6fc07971631ac8a3..05eb19b110ab7dcf 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -1270,7 +1270,7 @@ int hist_entry__annotate_printf(struct hist_entry *he= , struct evsel *evsel) apd.addr_fmt_width =3D annotated_source__addr_fmt_width(¬es->src->sour= ce, apd.start); evsel__get_arch(evsel, &apd.arch); - apd.dbg =3D debuginfo__new(filename); + apd.dbg =3D dso__debuginfo(dso); =20 list_for_each_entry(pos, ¬es->src->source, node) { int err; @@ -1375,7 +1375,7 @@ static int symbol__annotate_fprintf2(struct symbol *s= ym, FILE *fp, =20 if (annotate_opts.code_with_type) { evsel__get_arch(apd->evsel, &apd->arch); - apd->dbg =3D debuginfo__new(dso__long_name(map__dso(apd->he->ms.map))); + apd->dbg =3D dso__debuginfo(map__dso(apd->he->ms.map)); } =20 list_for_each_entry(al, ¬es->src->source, node) { @@ -2888,7 +2888,7 @@ struct annotated_data_type *hist_entry__get_data_type= (struct hist_entry *he) di_cache.dso =3D dso__get(map__dso(ms->map)); =20 debuginfo__delete(di_cache.dbg); - di_cache.dbg =3D debuginfo__new(dso__long_name(di_cache.dso)); + di_cache.dbg =3D dso__debuginfo(di_cache.dso); } =20 if (di_cache.dbg =3D=3D NULL) { diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h index 7df1673f08d3ddb4..fd8e95de77f78dfc 100644 --- a/tools/perf/util/dso.h +++ b/tools/perf/util/dso.h @@ -10,6 +10,7 @@ #include #include #include "build-id.h" +#include "debuginfo.h" #include "mutex.h" #include =20 @@ -914,4 +915,13 @@ u64 dso__findnew_global_type(struct dso *dso, u64 addr= , u64 offset); bool perf_pid_map_tid(const char *dso_name, int *tid); bool is_perf_pid_map_name(const char *dso_name); =20 +/* + * In the future, we may get debuginfo using build-ID (w/o path). + * Add this helper is for the smooth conversion. + */ +static inline struct debuginfo *dso__debuginfo(struct dso *dso) +{ + return debuginfo__new(dso__long_name(dso)); +} + #endif /* __PERF_DSO */ --=20 2.50.1