From nobody Sun Feb 8 13:09:09 2026 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 444AD189905; Sun, 1 Jun 2025 06:53: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=1748760784; cv=none; b=eKvw1jSAGgplM/Mja0uF8CxEmok6mmNdHaiNaLEAPUIRqdifEmKnFf8gNr29qPCZ78g8PGCl3dS2CQ7EZHurQbg6ycbFG1oaZhs98q0BTOhdQ85yAqdVm2pU4v+4X/ZhrUyWBpB6ziLkk/IJW5WRlg3DGzpk6RnXnbWrkiY3/Tk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748760784; c=relaxed/simple; bh=liYp8n1KXK/hxafeALqTC/1jlvCB11uSi6ZO28RNPFE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cTjhU8BEGENIy88xYXFH3Zi0u4js5l9mhk0hSKCLr3u/rY4C+6See6zCzBpelSJfSGo/mTLmR/g4G7rJuA3GfvJp83W+Fi6ExUm3vhSBEUOde9uIz52QW2Z8dscXggE6QvklMWffIc9zWfhW+f6s2d74CWWzXkFtlZuDCc1cMIs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rpha6xRO; 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="rpha6xRO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B222C4CEF4; Sun, 1 Jun 2025 06:53:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1748760783; bh=liYp8n1KXK/hxafeALqTC/1jlvCB11uSi6ZO28RNPFE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rpha6xROGPrtzTzTXg+LVX1CpdWdZZi8yt/uXF+TI0lqGXdrFUvp+T/G5wfWFTwzh XldNhxiGJJsCLMsnEsloL8Rbd8Hc6Umln5qvFjZs1Curyb90MbOquv/g/GA2PXMiWI rpkac9pbp+tiJa3+BYgXlHH0MKo5LSxSG672OXAsCuLaPYnh1f7o3G61CctGDAHj1Q DuA1PGPud/w4YDSOK9/A8yQl2DDvDl2FUTMtThpDnedMzyNt9uyYy5dnJKHXPb+rAT poV2pb02h2lsq+rn43bglSAvJapmuxStBPd/j0CggagtfkztXdIOUjjXZWNtWxBVQZ jPaKL7et8UY4A== 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, Athira Rajeev Subject: [PATCH 1/6] perf annotate: Rename to __hist_entry__tui_annotate() Date: Sat, 31 May 2025 23:52:57 -0700 Message-ID: <20250601065302.12531-2-namhyung@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250601065302.12531-1-namhyung@kernel.org> References: <20250601065302.12531-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 --- 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 ab776b1ed2d5b4ba..af3e52ce4da62eb9 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]; }; @@ -483,7 +484,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; @@ -958,12 +959,6 @@ static int annotate_browser__run(struct annotate_brows= er *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) { @@ -972,11 +967,12 @@ int hist_entry__tui_annotate(struct hist_entry *he, s= truct 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); @@ -990,6 +986,7 @@ int symbol__tui_annotate(struct map_symbol *ms, struct = 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 d26b925e3d7f46af..55455c49faf01891 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 bbb89b32f398b3c9..9cd723b8b987db1a 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -470,18 +470,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 c64254088fc77246..11ae738772ca4f61 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h @@ -712,8 +712,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); @@ -741,9 +742,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.49.0 From nobody Sun Feb 8 13:09:09 2026 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 B4830198A1A; Sun, 1 Jun 2025 06:53: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=1748760784; cv=none; b=FfT8I/0EsohUXYpjSwuZvqys2Ta+uAy7WNkCi6wFRTjyMdclNW74U8NTgluaOAeURbo8vkvPVVClRydob7oF5Tzh4vbp3lB6M77hG+GbKpTIdNSH6s/Uh5dUa13Hpwh/9O46jpXojpEDntS4/rsSGO8nYO0xWkc5HUmbjA8b52s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748760784; c=relaxed/simple; bh=3mjIs8R0jw2Lh21XJ+qjluJ9Sq4LcsMQd8WZ6SX5HRw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Wc3SLFSngYJf2ejUvW0zFfFHq6E2DoLsffzmSd9SGwq7CTQfPyK/YOexudv9HvfouhAqAOidQ9ybm4DDfn0M7MjggjhKBMfD/dG+PIAf7/2VGEmzP+HRm8eKWUtz3xi+nmb8vOF/XTTSBvMC43YmXnGbozh07nnvwGH1Lg76os0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JAsdsMDP; 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="JAsdsMDP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4EE3C4CEF5; Sun, 1 Jun 2025 06:53:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1748760784; bh=3mjIs8R0jw2Lh21XJ+qjluJ9Sq4LcsMQd8WZ6SX5HRw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JAsdsMDPB/KPr/zCjoIaZGE9/7nSR0Ic817sjYVXz0kOWLD8HLqH+o/uNxEqgznlj KFndYzVwYRF85nuhBHbXJ0C/jBP+oG0UIYynq6ZNRMJ+vv/unERfOXJGpbb1M2jtHZ joaKs0uIrZnEA1fKbNDkczOd4WKtLMlgyzEpsDB4uJy59Xj3K4m2Yf2sZYw2J0VNVc MbCPuNjfu7qmH/O/qq9Aq2pIGvafsJnvdde4KzZIyr6Uhf1GbTsoWxQrOhKn96z8Q+ FVtFDrxMdfGFOavHgP+itEf7FY+FOTdNCXHxFhyjnL5Gut/8H3brQLSRIqMCfTnY7F uwWgP51aFZAbA== 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, Athira Rajeev Subject: [PATCH 2/6] perf annotate: Remove __annotation_line__write() Date: Sat, 31 May 2025 23:52:58 -0700 Message-ID: <20250601065302.12531-3-namhyung@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250601065302.12531-1-namhyung@kernel.org> References: <20250601065302.12531-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 then twice. Signed-off-by: Namhyung Kim --- tools/perf/util/annotate.c | 49 ++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 264a212b47df850c..48fac08c4c9502b1 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -1934,24 +1934,25 @@ 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; + 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; @@ -1965,7 +1966,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) { @@ -2101,10 +2103,10 @@ static void __annotation_line__write(struct annotat= ion_line *al, struct annotati } } =20 - if (change_color) + if (wops->change_color) color =3D obj__set_color(obj, HE_COLORSET_ADDR); obj__printf(obj, bf); - if (change_color) + if (wops->change_color) obj__set_color(obj, color); =20 disasm_line__write(disasm_line(al), notes, obj, bf, sizeof(bf), obj__pri= ntf, obj__write_graph); @@ -2114,17 +2116,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.49.0 From nobody Sun Feb 8 13:09:09 2026 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 646EE19CC22; Sun, 1 Jun 2025 06:53: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=1748760785; cv=none; b=RXgKij8FF4Nyi1r0S3RtKFiUIubGITL8NeGucn5SLYE/UO3yCxN8cu3TuEhDAxJ8mazilQziYsS15MLGmmGFdNMrZ/HqxpWEwbeYV55igKtuM5/EziwzS7R0h8ReTJ3NLAEMEAzzqaXPfbb5/Ot5i39VXu84/d0bNIXmUuiZmdQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748760785; c=relaxed/simple; bh=8KadBIksUF4b4enxCoHxuGdc8PDW7zeH359dBd0XnEw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bCplT9x36C8IS9nU1K1XdR/JLMQjDx4gbdpxW49e/yKl2uMOuVmNcBTefX6TWoqP3f7ShP2IuPPtpsdw0KYoqV9fcatR/zvS/x08UabUgvyop0AD1IlQBpWMATSKHqL5zFTb4pUgJM8id+kX3LLyQVq179DpQIle5WwZi60MkZ0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HnCGWPLs; 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="HnCGWPLs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6CB57C4CEF4; Sun, 1 Jun 2025 06:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1748760784; bh=8KadBIksUF4b4enxCoHxuGdc8PDW7zeH359dBd0XnEw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HnCGWPLs9x/CmzpHzgjt980br9jC6mXA1MlbWBVLKlyTKXRD4+GC76Ol6XH0v4rWa mvgK6o/1QPobKWNewvCzE6oi3aWo3gQ2i31MTRI6OiTtYNfKnmsn0a7U1B5LW+OMCq mxT9X8Xf34na5REEBtvwz/rQyZxHFdtshBbnpfCtC534T3KZHeufBFXnoSzRXRqraq b/G0siGc/BDEDgt3lzz2t9O+E65eMwZE+0DGGnv1fUl9WqUs9B9WPISQMmMo5+sXBN non1IsRwPupDvjhvMRt97Uqjo0AGqa1Xp6Rw/jwwb1diPZTBa4w9UGaCMTlPMedwqI aqDMGzfhhOWdA== 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, Athira Rajeev Subject: [PATCH 3/6] perf annotate: Pass annotation_print_data to annotaiton_line__write() Date: Sat, 31 May 2025 23:52:59 -0700 Message-ID: <20250601065302.12531-4-namhyung@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250601065302.12531-1-namhyung@kernel.org> References: <20250601065302.12531-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" Signed-off-by: Namhyung Kim --- 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 af3e52ce4da62eb9..0057fb485e85aaaf 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; @@ -902,7 +910,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) { @@ -987,6 +995,7 @@ int __hist_entry__tui_annotate(struct hist_entry *he, s= truct 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 48fac08c4c9502b1..7df726b99541a571 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; @@ -1655,6 +1651,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 @@ -1677,7 +1677,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 @@ -1935,7 +1935,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; double percent_max =3D annotation_line__max_percent(al, annotate_opts.per= cent_type); @@ -2112,6 +2113,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 9cd723b8b987db1a..bc195bd0429e039d 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, @@ -462,7 +472,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.49.0 From nobody Sun Feb 8 13:09:09 2026 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 CA0BF19E98B; Sun, 1 Jun 2025 06:53: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=1748760785; cv=none; b=cGjvcuS3qtp7TiHGWLYUT0YxeEqJGY6lsvAQrMW1arwGCSysW3d9q2KcHLl5D7vrygsb9dFC2u6yl98hrfvf1c/thrxqcRl6C4BfDOwLliq6Svg4EUSsH/TXIKSoq5mD11s4V2SDyOgXh5F0fSlttngo5yOvUeB1BvcyjI7pMVI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748760785; c=relaxed/simple; bh=HkrML6il0hnxClDP7JZCCS/zpvPHPDWqmrLKm9GftDM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FmM7soK33oOTE7KEFaXOAYCi5K8vLGnogzKRV7dRy8bpXPmcCfG1nT1pEc+86Pq8H40NeYgLsPLuh3hL2MzkLwJUkCAzQ/EpsoZDfX6NGZeqwYwjU+W3mqX+DS6vvSsjNcRmm7bNx9V19HpbTsQ9EkEMyLW7jH08CVtRbI8ufTA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=s4tyEcVA; 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="s4tyEcVA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA4A7C4CEFE; Sun, 1 Jun 2025 06:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1748760785; bh=HkrML6il0hnxClDP7JZCCS/zpvPHPDWqmrLKm9GftDM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s4tyEcVAhcMmHuOsU8A7b+6dwSEEjvhcnDUD3DhfrBigvrYSVxsZjHZ8Aqyn7UVFN GJriLaxAwraND468br0b5qBz4I2VRb1VDFqAKBwnJqEi6zfbw9/KJEorKyo30LVL67 8NnzH1d6awHF3iJrhJ+SuyFynv8uTTwXdPMPgsPD6DxY3CrZDyJkk4kuJ3OqHjajgy l8HO6ekNfs9+6a7DJWcv82HTzrdF/iCpbdw19+xy+1mzO8K3df92zDTeBCAk95Ani1 o51aoCCim7lrdZ+kE8KO0T0IQQqzRPyyHHW32C2+r/T7t6KuXoDpdg6g80J62nQrP3 v7fA26/YbVKPg== 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, Athira Rajeev Subject: [PATCH 4/6] perf annotate: Simplify width calculation in annotation_line__write() Date: Sat, 31 May 2025 23:53:00 -0700 Message-ID: <20250601065302.12531-5-namhyung@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250601065302.12531-1-namhyung@kernel.org> References: <20250601065302.12531-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 7df726b99541a571..94f73c8944cde519 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -1991,6 +1991,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) @@ -2054,11 +2055,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 ", @@ -2067,7 +2069,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; @@ -2110,9 +2112,11 @@ void annotation_line__write(struct annotation_line *= al, struct annotation *notes if (wops->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.49.0 From nobody Sun Feb 8 13:09:09 2026 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 E42B519F40B; Sun, 1 Jun 2025 06:53: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=1748760786; cv=none; b=PT7EsvieW3zs1zVrkphsRemHauiM8YcAvF+7QrXYyLbCml0a9QXJ46raDvD70TrEGww2kbs+jBCfnbeGXezgPfO8JXNAc0V+uPuxrZ09sGrOWF1G9gcGp0wkhbxlNAP28xPGXxLVaCia8bQx4EILDnbpuu/awXk8ayIT+Mv4528= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748760786; c=relaxed/simple; bh=+cfucBX5cy1DW4FpLSQqN4Bp+xknd+/eBxoN/P9e848=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fvB1I5OEsuTd1N7VZab6goTPgWXMq31BtR/hMWmH0QiCR6xEtWMcqa3w6BR5k+7lgK4LGvWqQ3H6su2l7AQKKlAZRjVAmSgj3IWs7iO2o956/L5EIaamqdVhY+uTHc5j6/JSRG59QDtmoklk/j754jl/Uu2uKZPf9OqO1owINQo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EMGydDoh; 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="EMGydDoh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 711CFC4CEE7; Sun, 1 Jun 2025 06:53:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1748760785; bh=+cfucBX5cy1DW4FpLSQqN4Bp+xknd+/eBxoN/P9e848=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EMGydDohWxSpv7s1Asy4FPasgWad8N63Liap9Vr0PwzoqftasFVhuvpSyhD2z0jDa bT5D6jEzO2RiY0DKdE8sS2kTYqwn6b+JP6vmhx5mkY7tdYm7dn3xn1NP6X/nrJM0pz Tuu099sHyXrgPYRB62H5AwBWy9gJ6il9AFMb9JAauemw5FBdYF5b2BBDAE2xApk6HK eXED5aktYN6/PDPMThBVoGSLGVdhPeYKB4Q+1xzi/b7N3urW2oPWOYKNgs9jaY2e6E BxeriQvESDs3bCukR8LZjUIvUvUpENpLqFbtnCwMwe/O4vWX9KJcz86b4I+rYUcZYC i7b3urd8/F+Ig== 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, Athira Rajeev Subject: [PATCH 5/6] perf annotate: Add --code-with-type support for TUI Date: Sat, 31 May 2025 23:53:01 -0700 Message-ID: <20250601065302.12531-6-namhyung@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250601065302.12531-1-namhyung@kernel.org> References: <20250601065302.12531-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 9833c2c82a2fee46..6debd725392db4a4 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 0057fb485e85aaaf..686fa54e545e275c 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" @@ -1021,6 +1022,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; @@ -1031,6 +1035,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) annotated_source__purge(notes->src); =20 diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 94f73c8944cde519..bf480f5b87eedd50 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 @@ -1742,7 +1750,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)) @@ -1770,8 +1778,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) @@ -2114,11 +2122,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.49.0 From nobody Sun Feb 8 13:09:09 2026 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 D0B261A9B39; Sun, 1 Jun 2025 06:53:06 +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=1748760786; cv=none; b=MhegZqd83Waz5euuhVx02ft3sOFTY+eVV1aghQQoquiJe+zbvDlrBlnKlIH+2ObBD3xKyHWw04a0N7DyOo/m3x+j0v8cXXUGHNtvfzSvTcG/DpAhjDkgPR/NwWm7+KkWfxVGmdQGKy4/JmOBnd7L67cGsQjFhLlnYOjvZfPKg5E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748760786; c=relaxed/simple; bh=w8+QfNx+uCIISmTP+rtDGxlrj31TjIv8kOjYOA/n79A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hQp0LRq4b4IJXVfVf0d47Uv9HVZZgRXWRQ7fXl6Qt5xaI98A1Mrz+MR9ccRVsuPJHXvEm/hpjqlI/ndIuZ9p5tRAEcksBZ/Y4OYbZbij0tVPQj3gJm6+5d33YJWcUIkfQXIvpzmn01UA+XiZbsHTSbTHWGL6iw2qgvPNeXOOeoI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mmE4GxBC; 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="mmE4GxBC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EDA35C4CEFA; Sun, 1 Jun 2025 06:53:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1748760786; bh=w8+QfNx+uCIISmTP+rtDGxlrj31TjIv8kOjYOA/n79A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mmE4GxBCIffR64tod0PgumkxK1z3gc+5FWXaPhpx5lDBPh8y6ovzltIhz+0LB3bkz tVn4A/P6uO2Y6fH04Lm+K+MgjK9B82rZshP6NKbZpsr0WqEy3HS2DDnZFZwAk7T3ib 5xSXPLAl90XpVpeQ81GhLm39cz3f50yg58rlQDTrJxYbu7ecK7c0y6lakCKA7CLw0A lnBY+Qxxw+h3u9p7NiJyQ4pVoueZm67rrdlf/QJwU0GuC9b3yU0nhXhKhqdfYM89Xz zE54Vgsh+sd88HnszXVWOMZl5HFBR5O7R+5+ouSZVxNUOYcQqBX61hOTJSUfwYiBra 0nZqqCBJBoLgg== 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, Athira Rajeev Subject: [PATCH 6/6] perf annotate: Add 'y' hot key to toggle data type display Date: Sat, 31 May 2025 23:53:02 -0700 Message-ID: <20250601065302.12531-7-namhyung@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250601065302.12531-1-namhyung@kernel.org> References: <20250601065302.12531-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. Signed-off-by: Namhyung Kim Tested-by: Arnaldo Carvalho de Melo --- tools/perf/ui/browsers/annotate.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/ann= otate.c index 686fa54e545e275c..cd1d452035a265d3 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -827,7 +827,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" + "y Toggle data type display\n"); continue; case 'r': script_browse(NULL, NULL); @@ -947,6 +948,11 @@ static int annotate_browser__run(struct annotate_brows= er *browser, case 'f': annotation__toggle_full_addr(notes, ms); continue; + case 'y': + 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))); + continue; case K_LEFT: case '<': case '>': @@ -1035,8 +1041,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) annotated_source__purge(notes->src); =20 --=20 2.49.0