Arnaldo Carvalho de Melo and Namhyung Kim
19a9ed115f
perf tools: Replace basename() calls with perf_basename()
...
As noticed in a sashiko review for a patch adding a missing libgen.h
in a file using basename():
https://sashiko.dev/#/patchset/20260402001740.2220481-1-acme%40kernel.org
So avoid these subtleties and instead reuse the gnu_basename() function
we had in srcline.c, renaming it to perf_basename() and replace
basename() calls with it, simplifying several cases by removing now
needless strdups.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
Signed-off-by: Namhyung Kim <namhyung@kernel.org >
2026-04-08 19:21:05 -07:00
Chen Ni and Arnaldo Carvalho de Melo
bf29cb3641
perf annotate: Fix hashmap__new() error checking
...
The hashmap__new() function never returns NULL, it returns error
pointers. Fix the error checking to match.
Additionally, set src->samples to NULL to prevent any later code from
accidentally using the error pointer.
Fixes: d3e7cad6f3 ("perf annotate: Add a hashmap for symbol histogram")
Reviewed-by: Ian Rogers <irogers@google.com >
Signed-off-by: Chen Ni <nichen@iscas.ac.cn >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: James Clark <james.clark@linaro.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Tianyou Li <tianyou.li@intel.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2026-03-10 10:19:44 -03:00
Namhyung Kim and Arnaldo Carvalho de Melo
64ea7a4620
perf annotate: Fix register usage in data type profiling
...
On data type profiling, it tried to match register name with a partial
string. For example, it allowed to match with "%rbp)" or "%rdi,8)".
But with recent change in the area, it doesn't match anymore and break
the data type profiling.
Let's pass the correct register name by removing the unwanted part.
Add arch__dwarf_regnum() to handle it in a single place.
Closes: 7d3n23li6drroxrdlpxn7ixehdeszkjdftah3zyngjl2qs22ef@yelcjv53v42o
Reported-by: Dmitry Dolgov <9erthalion6@gmail.com >
Reviewed-by: Ian Rogers <irogers@google.com >
Signed-off-by: Namhyung Kim <namhyung@kernel.org >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Ingo Molnar <mingo@kernel.org >
Cc: James Clark <james.clark@linaro.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Zecheng Li <zli94@ncsu.edu >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2026-02-06 18:18:52 -03:00
Ian Rogers and Arnaldo Carvalho de Melo
4e66527f88
perf thread: Add optional e_flags output argument to thread__e_machine
...
The e_flags are needed to accurately compute complete perf register
information for CSKY.
Add the ability to read and have this value associated with a thread.
This change doesn't wire up the use of the e_flags except in disasm
where use already exists but just wasn't set up yet.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Aditya Bodkhe <aditya.b1@linux.ibm.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.ibm.com >
Cc: Chun-Tse Shao <ctshao@google.com >
Cc: Guo Ren <guoren@kernel.org >
Cc: Howard Chu <howardchu95@gmail.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: James Clark <james.clark@linaro.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Sergei Trofimovich <slyich@gmail.com >
Cc: Shimin Guo <shimin.guo@skydio.com >
Cc: Stephen Brennan <stephen.s.brennan@oracle.com >
Cc: Swapnil Sapkal <swapnil.sapkal@amd.com >
Cc: Tianyou Li <tianyou.li@intel.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2026-01-26 18:21:20 -03:00
Ian Rogers and Arnaldo Carvalho de Melo
0e26ba5a87
perf disasm: Refactor arch__find and initialization of arch structs
...
Switch arch__find to using an ELF machine number rather than a
string.
Rather than an array of fixed size arch structs turn the init functions
into new functions indexed by the ELF machine they correspond to.
This allows data to be stored with a struct arch with the container_of
trick, so the priv variable can be removed.
Switch to using the thread to find the arch rather than the evsel as the
evsel only has limited notions of the running thread upon which
disassembly is performed.
Factor out the e_machine and e_flags into their own struct to make them
easier to pass around.
Reviewed-by: James Clark <james.clark@linaro.org >
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Aditya Bodkhe <aditya.b1@linux.ibm.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Albert Ou <aou@eecs.berkeley.edu >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Alexandre Ghiti <alex@ghiti.fr >
Cc: Athira Rajeev <atrajeev@linux.ibm.com >
Cc: Bill Wendling <morbo@google.com >
Cc: Dr. David Alan Gilbert <linux@treblig.org >
Cc: Guo Ren <guoren@kernel.org >
Cc: Howard Chu <howardchu95@gmail.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: Julia Lawall <Julia.Lawall@inria.fr >
Cc: Justin Stitt <justinstitt@google.com >
Cc: Krzysztof Łopatowski <krzysztof.m.lopatowski@gmail.com >
Cc: Leo Yan <leo.yan@linux.dev >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Nathan Chancellor <nathan@kernel.org >
Cc: Nick Desaulniers <nick.desaulniers+lkml@gmail.com >
Cc: Palmer Dabbelt <palmer@dabbelt.com >
Cc: Paul Walmsley <pjw@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Sergei Trofimovich <slyich@gmail.com >
Cc: Shimin Guo <shimin.guo@skydio.com >
Cc: Suchit Karunakaran <suchitkarunakaran@gmail.com >
Cc: Thomas Falcon <thomas.falcon@intel.com >
Cc: Tianyou Li <tianyou.li@intel.com >
Cc: Will Deacon <will@kernel.org >
Cc: Zecheng Li <zecheng@google.com >
[ Include elf.h for EM_CSKY and friends and also conditionally define EM_CSKY_ABIMASK for old distros ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2026-01-23 16:58:39 -03:00
Ian Rogers and Arnaldo Carvalho de Melo
9273085273
perf disasm: Rework the string arch__is to use the ELF machine
...
Add new arch__is_x86 and arch__is_powerpc functions that avoid string
comparisons and use the ELF machine.
Remove arch__is() that is no longer used.
Reviewed-by: James Clark <james.clark@linaro.org >
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Aditya Bodkhe <aditya.b1@linux.ibm.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Albert Ou <aou@eecs.berkeley.edu >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Alexandre Ghiti <alex@ghiti.fr >
Cc: Athira Rajeev <atrajeev@linux.ibm.com >
Cc: Bill Wendling <morbo@google.com >
Cc: Dr. David Alan Gilbert <linux@treblig.org >
Cc: Guo Ren <guoren@kernel.org >
Cc: Howard Chu <howardchu95@gmail.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: Julia Lawall <Julia.Lawall@inria.fr >
Cc: Justin Stitt <justinstitt@google.com >
Cc: Krzysztof Łopatowski <krzysztof.m.lopatowski@gmail.com >
Cc: Leo Yan <leo.yan@linux.dev >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Nathan Chancellor <nathan@kernel.org >
Cc: Nick Desaulniers <nick.desaulniers+lkml@gmail.com >
Cc: Palmer Dabbelt <palmer@dabbelt.com >
Cc: Paul Walmsley <pjw@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Sergei Trofimovich <slyich@gmail.com >
Cc: Shimin Guo <shimin.guo@skydio.com >
Cc: Suchit Karunakaran <suchitkarunakaran@gmail.com >
Cc: Thomas Falcon <thomas.falcon@intel.com >
Cc: Tianyou Li <tianyou.li@intel.com >
Cc: Will Deacon <will@kernel.org >
Cc: Zecheng Li <zecheng@google.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2026-01-23 16:58:38 -03:00
Ian Rogers and Arnaldo Carvalho de Melo
57d26593a9
perf disasm: Constify use of 'struct arch'
...
The 'struct arch' holds variables that are read but not written, except
during some initialization.
Change most uses to be for a "const struct arch *" version to capture
this immutability.
Reviewed-by: James Clark <james.clark@linaro.org >
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Aditya Bodkhe <aditya.b1@linux.ibm.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Albert Ou <aou@eecs.berkeley.edu >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Alexandre Ghiti <alex@ghiti.fr >
Cc: Athira Rajeev <atrajeev@linux.ibm.com >
Cc: Bill Wendling <morbo@google.com >
Cc: Dr. David Alan Gilbert <linux@treblig.org >
Cc: Guo Ren <guoren@kernel.org >
Cc: Howard Chu <howardchu95@gmail.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: Julia Lawall <Julia.Lawall@inria.fr >
Cc: Justin Stitt <justinstitt@google.com >
Cc: Krzysztof Łopatowski <krzysztof.m.lopatowski@gmail.com >
Cc: Leo Yan <leo.yan@linux.dev >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Nathan Chancellor <nathan@kernel.org >
Cc: Nick Desaulniers <nick.desaulniers+lkml@gmail.com >
Cc: Palmer Dabbelt <palmer@dabbelt.com >
Cc: Paul Walmsley <pjw@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Sergei Trofimovich <slyich@gmail.com >
Cc: Shimin Guo <shimin.guo@skydio.com >
Cc: Suchit Karunakaran <suchitkarunakaran@gmail.com >
Cc: Thomas Falcon <thomas.falcon@intel.com >
Cc: Tianyou Li <tianyou.li@intel.com >
Cc: Will Deacon <will@kernel.org >
Cc: Zecheng Li <zecheng@google.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2026-01-23 16:58:38 -03:00
Ian Rogers and Arnaldo Carvalho de Melo
00419892ba
perf annotate: Fix args leak of map_symbol
...
map_symbol__exit() needs calling on an annotate_args.ms, however, rather
than introduce proper reference count handling to symbol__annotate()
just switch to passing the map_symbol pointer parameter around, making
the puts the caller's responsibility.
Fix a number of cases to ensure the map in a map_symbol has a
reference count increment and add the then necessary map_symbol_exits.
Fixes: 56e144fe98 ("perf mem_info: Add and use map_symbol__exit and addr_map_symbol__exit")
Reviewed-by: James Clark <james.clark@linaro.org >
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Aditya Bodkhe <aditya.b1@linux.ibm.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Albert Ou <aou@eecs.berkeley.edu >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Alexandre Ghiti <alex@ghiti.fr >
Cc: Athira Rajeev <atrajeev@linux.ibm.com >
Cc: Bill Wendling <morbo@google.com >
Cc: Dr. David Alan Gilbert <linux@treblig.org >
Cc: Guo Ren <guoren@kernel.org >
Cc: Howard Chu <howardchu95@gmail.com >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: Julia Lawall <Julia.Lawall@inria.fr >
Cc: Justin Stitt <justinstitt@google.com >
Cc: Krzysztof Łopatowski <krzysztof.m.lopatowski@gmail.com >
Cc: Leo Yan <leo.yan@linux.dev >
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-csky@vger.kernel.org
Cc: linux-riscv@lists.infradead.org
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Nathan Chancellor <nathan@kernel.org >
Cc: Nick Desaulniers <nick.desaulniers+lkml@gmail.com >
Cc: Palmer Dabbelt <palmer@dabbelt.com >
Cc: Paul Walmsley <pjw@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Sergei Trofimovich <slyich@gmail.com >
Cc: Shimin Guo <shimin.guo@skydio.com >
Cc: Suchit Karunakaran <suchitkarunakaran@gmail.com >
Cc: Thomas Falcon <thomas.falcon@intel.com >
Cc: Tianyou Li <tianyou.li@intel.com >
Cc: Will Deacon <will@kernel.org >
Cc: Zecheng Li <zecheng@google.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2026-01-23 16:58:38 -03:00
Zecheng Li and Namhyung Kim
068b6a4524
perf annotate: Skip annotating data types to lea instructions
...
Introduce a helper function is_address_gen_insn() to check
arch-dependent address generation instructions like lea in x86. Remove
type annotation on these instructions since they are not accessing
memory. It should be counted as `no_mem_ops`.
Signed-off-by: Zecheng Li <zecheng@google.com >
Signed-off-by: Namhyung Kim <namhyung@kernel.org >
2025-10-21 06:02:49 -07:00
Tianyou Li and Namhyung Kim
f1204e5846
perf annotate: Check return value of evsel__get_arch() properly
...
Check the error code of evsel__get_arch() in the symbol__annotate().
Previously it checked non-zero value but after the refactoring it does
only for negative values.
Fixes: 0669729eb0 ("perf annotate: Factor out evsel__get_arch()")
Suggested-by: James Clark <james.clark@linaro.org >
Acked-by: Namhyung Kim <namhyung@kernel.org >
Signed-off-by: Tianyou Li <tianyou.li@intel.com >
Signed-off-by: Namhyung Kim <namhyung@kernel.org >
2025-10-21 05:42:34 -07:00
Tianyou Li and Namhyung Kim
262c61435c
perf annotate: fix a crash when annotate the same symbol with 's' and 'T'
...
When perf report with annotation for a symbol, press 's' and 'T', then exit
the annotate browser. Once annotate the same symbol, the annotate browser
will crash.
The browser.arch was required to be correctly updated when data type
feature was enabled by 'T'. Usually it was initialized by symbol__annotate2
function. If a symbol has already been correctly annotated at the first
time, it should not call the symbol__annotate2 function again, thus the
browser.arch will not get initialized. Then at the second time to show the
annotate browser, the data type needs to be displayed but the browser.arch
is empty.
Stack trace as below:
Perf: Segmentation fault
-------- backtrace --------
#0 0x55d365 in ui__signal_backtrace setup.c:0
#1 0x7f5ff1a3e930 in __restore_rt libc.so.6[3e930]
#2 0x570f08 in arch__is perf[570f08]
#3 0x562186 in annotate_get_insn_location perf[562186]
#4 0x562626 in __hist_entry__get_data_type annotate.c:0
#5 0x56476d in annotation_line__write perf[56476d]
#6 0x54e2db in annotate_browser__write annotate.c:0
#7 0x54d061 in ui_browser__list_head_refresh perf[54d061]
#8 0x54dc9e in annotate_browser__refresh annotate.c:0
#9 0x54c03d in __ui_browser__refresh browser.c:0
#10 0x54ccf8 in ui_browser__run perf[54ccf8]
#11 0x54eb92 in __hist_entry__tui_annotate perf[54eb92]
#12 0x552293 in do_annotate hists.c:0
#13 0x55941c in evsel__hists_browse hists.c:0
#14 0x55b00f in evlist__tui_browse_hists perf[55b00f]
#15 0x42ff02 in cmd_report perf[42ff02]
#16 0x494008 in run_builtin perf.c:0
#17 0x494305 in handle_internal_command perf.c:0
#18 0x410547 in main perf[410547]
#19 0x7f5ff1a295d0 in __libc_start_call_main libc.so.6[295d0]
#20 0x7f5ff1a29680 in __libc_start_main@@GLIBC_2.34 libc.so.6[29680]
#21 0x410b75 in _start perf[410b75]
Fixes: 1d4374afd0 ("perf annotate: Add 'T' hot key to toggle data type display")
Reviewed-by: James Clark <james.clark@linaro.org >
Tested-by: Namhyung Kim <namhyung@kernel.org >
Signed-off-by: Tianyou Li <tianyou.li@intel.com >
Signed-off-by: Namhyung Kim <namhyung@kernel.org >
2025-10-21 05:42:01 -07:00
Ian Rogers and Arnaldo Carvalho de Melo
e3b08a0664
perf disasm: Remove unused evsel from 'struct annotate_args'
...
Set in symbol__annotate() but never used.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Alexandre Ghiti <alexghiti@rivosinc.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.ibm.com >
Cc: Bill Wendling <morbo@google.com >
Cc: Charlie Jenkins <charlie@rivosinc.com >
Cc: Collin Funk <collin.funk1@gmail.com >
Cc: Dmitriy Vyukov <dvyukov@google.com >
Cc: Dr. David Alan Gilbert <linux@treblig.org >
Cc: Eric Biggers <ebiggers@kernel.org >
Cc: Haibo Xu <haibo1.xu@intel.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: James Clark <james.clark@linaro.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Justin Stitt <justinstitt@google.com >
Cc: Li Huafei <lihuafei1@huawei.com >
Cc: Masami Hiramatsu <mhiramat@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Nathan Chancellor <nathan@kernel.org >
Cc: Nick Desaulniers <nick.desaulniers+lkml@gmail.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Song Liu <song@kernel.org >
Cc: Stephen Brennan <stephen.s.brennan@oracle.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-10-06 16:47:51 -03:00
Namhyung Kim and Arnaldo Carvalho de Melo
1086237f0a
perf annotate: Use a hashmap to save type data
...
It can slowdown annotation browser if objdump is processing large DWARF
data. Let's add a hashmap to save the data type info for each line.
Note that this is needed for TUI only because stdio only processes each
line once. TUI will display the same line whenever it refreshes the
screen.
Signed-off-by: Namhyung Kim <namhyung@kernel.org >
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@kernel.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Link: https://lore.kernel.org/r/20250816031635.25318-13-namhyung@kernel.org
[ Add lines around an if block and use zfree() in one case, acked by Namhyung ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-09-02 17:14:00 -03:00
Namhyung Kim and Arnaldo Carvalho de Melo
53a61a6ca2
perf annotate: Add dso__debuginfo() helper
...
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 <irogers@google.com >
Signed-off-by: Namhyung Kim <namhyung@kernel.org >
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Ingo Molnar <mingo@kernel.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Link: https://lore.kernel.org/r/20250816031635.25318-12-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-08-28 12:35:42 -03:00
Namhyung Kim and Arnaldo Carvalho de Melo
d69f56545e
perf annotate: Hide data-type for stack operation and canary
...
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 operation)
0.00 : 5: movq %rsp, %rbp
0.00 : 8: pushq %r15 # data-type: (stack operation)
0.00 : a: pushq %r14 # data-type: (stack operation)
0.00 : c: pushq %r13 # data-type: (stack operation)
0.00 : e: pushq %r12 # data-type: (stack operation)
0.00 : 10: pushq %rbx # data-type: (stack operation)
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
...
Reviewed-by: Ian Rogers <irogers@google.com >
Signed-off-by: Namhyung Kim <namhyung@kernel.org >
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Ingo Molnar <mingo@kernel.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Link: https://lore.kernel.org/r/20250816031635.25318-11-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-08-28 12:35:30 -03:00
Namhyung Kim and Arnaldo Carvalho de Melo
7dbe89ca3d
perf annotate: Add --code-with-type support for TUI
...
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
and remove the limitation and update the man page.
Signed-off-by: Namhyung Kim <namhyung@kernel.org >
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@kernel.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Link: https://lore.kernel.org/r/20250816031635.25318-8-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-08-28 12:33:08 -03:00
Namhyung Kim and Arnaldo Carvalho de Melo
e38ea8c41e
perf annotate: Return printed number from disasm_line__write()
...
Like other print functions, make disasm_line__write() return the number
of printed characters. It'll be used to skip unnecessary operations
when the screen is full.
Signed-off-by: Namhyung Kim <namhyung@kernel.org >
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@kernel.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Link: https://lore.kernel.org/r/20250816031635.25318-7-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-08-28 12:32:58 -03:00
Namhyung Kim and Arnaldo Carvalho de Melo
7736a6fba0
perf annotate: Simplify width calculation in annotation_line__write()
...
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 <namhyung@kernel.org >
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@kernel.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Link: https://lore.kernel.org/r/20250816031635.25318-6-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-08-28 12:32:47 -03:00
Namhyung Kim and Arnaldo Carvalho de Melo
d94d5eb54f
perf annotate: Pass annotation_print_data to annotation_line__write()
...
It will be used for data type display later.
Reviewed-by: Ian Rogers <irogers@google.com >
Signed-off-by: Namhyung Kim <namhyung@kernel.org >
Link: https://lore.kernel.org/r/20250816031635.25318-5-namhyung@kernel.org
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Arnaldo Carvalho de Melo <acme@kernel.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Ingo Molnar <mingo@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: LKML <linux-kernel@vger.kernel.org >
Cc: linux-perf-users@vger.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-08-28 12:32:32 -03:00
Namhyung Kim and Arnaldo Carvalho de Melo
05a706b157
perf annotate: Remove __annotation_line__write()
...
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 <namhyung@kernel.org >
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@kernel.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Link: https://lore.kernel.org/r/20250816031635.25318-4-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-08-28 12:32:19 -03:00
Namhyung Kim and Arnaldo Carvalho de Melo
4e3c9dc8b8
perf annotate: Remove annotation_print_data.start
...
The start field is to control whether the output shows full address or
offset from the function start. But actually it can be changed
dynamically in annotation__toggle_full_addr(). The informaiton should
be available through struct annotation. Let's use it directly.
Signed-off-by: Namhyung Kim <namhyung@kernel.org >
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@kernel.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Link: https://lore.kernel.org/r/20250816031635.25318-3-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-08-28 12:32:08 -03:00
Namhyung Kim
e201757f7a
perf annotate: Fix source code annotate with objdump
...
Recently it uses llvm and capstone to speed up annotation or disassembly
of instructions. But they don't support source code view yet. Until it
fixed, we can force to use objdump for source code annotation.
To prevent performance loss, it's disabled by default and turned it on
when user requests it in TUI by pressing 's' key.
Acked-by: Ian Rogers <irogers@google.com >
Link: https://lore.kernel.org/r/20250625230339.702610-1-namhyung@kernel.org
Reported-by: Ingo Molnar <mingo@kernel.org >
Signed-off-by: Namhyung Kim <namhyung@kernel.org >
2025-06-26 15:15:48 -07:00
Arnaldo Carvalho de Melo
bf5ea13bae
perf ui browser annotate: Don't show the source code view status initially
...
To avoid initial clutter, and not to change the view users that are not
interested in toggling the source code view, just show it when the user
does the first toggle keypress (pressing 's').
I know that there are users that really disable the source code view by
using:
# perf config annotate.hide_src_code=yes
Tested-by: Ingo Molnar <mingo@kernel.org >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@kernel.org >
Cc: James Clark <james.clark@linaro.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Link: https://lore.kernel.org/r/Z_TYux5fUg2pW-pF@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-04-10 10:46:32 -03:00
Namhyung Kim
30c5a3941d
perf annotate: Implement code + data type annotation
...
Sometimes it's useful to see both instructions and their data type
together. Let's extend the annotate code to use data type profiling
functions.
To make it easy to pass more argument, introduce a struct to carry
necessary information together. Also add a new annotation_option called
'code_with_type' to control the behavior. This is not enabled yet but
it'll be set later from the command line.
For simplicity, this is implemented for --stdio only.
Reviewed-by: Ian Rogers <irogers@google.com >
Link: https://lore.kernel.org/r/20250310224925.799005-7-namhyung@kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org >
2025-03-13 00:19:51 -07:00
Namhyung Kim
236ee2569a
perf annotate: Factor out __hist_entry__get_data_type()
...
So that it can only handle a single disasm_linme and hopefully make the
code simpler. This is also a preparation to be called from different
places later.
The NO_TYPE macro was added to distinguish when it failed or needs retry.
Reviewed-by: Ian Rogers <irogers@google.com >
Link: https://lore.kernel.org/r/20250310224925.799005-6-namhyung@kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org >
2025-03-13 00:19:51 -07:00