Skip to contentSkip to conversation

perf trace: Use consistent print_opts formatting in trace__fprintf_callchain()

PATCH In review Ahmed Atef El-Emary 2 participants 2 messages Aug 26, 2025 – Sep 13, 2025 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf trace: Use consistent print_opts formatting in trace__fprintf_callchain()

trace__fprintf_callchain() previously omitted IP and symoffset from its print_opts, unlike other callchain printers in perf. This resulted in less detailed and inconsistent callchain output.

Add EVSEL__PRINT_IP and EVSEL__PRINT_SYMOFFSET to make the output more consistent and informative. The callchain output now includes IP, symbol offset, DSO, and falls back to the raw address when no symbol is found, matching the detail level of other perf callchain outputs.

---
 tools/perf/builtin-trace.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
tools/perf/builtin-trace.c +4 -2
index fe737b3ac6e6..20f3488d4a21 100644
@@ -2892,8 +2892,10 @@ static int trace__fprintf_callchain(struct trace *trace, struct perf_sample *sam
 {
 	/* TODO: user-configurable print_opts */
 	const unsigned int print_opts = EVSEL__PRINT_SYM |
-				        EVSEL__PRINT_DSO |
-				        EVSEL__PRINT_UNKNOWN_AS_ADDR;
+				EVSEL__PRINT_DSO |
+				EVSEL__PRINT_UNKNOWN_AS_ADDR |
+				EVSEL__PRINT_IP |
+				EVSEL__PRINT_SYMOFFSET;
 
 	return sample__fprintf_callchain(sample, 38, print_opts, get_tls_callchain_cursor(), symbol_conf.bt_stop_list, trace->output);
 }
Signature · 1 line
2.43.0
#1 lore raw
Quoted 8 lines · Ahmed Atef El-Emary

trace__fprintf_callchain() previously omitted IP and symoffset from its print_opts, unlike other callchain printers in perf. This resulted in less detailed and inconsistent callchain output.

Add EVSEL__PRINT_IP and EVSEL__PRINT_SYMOFFSET to make the output more consistent and informative. The callchain output now includes IP, symbol offset, DSO, and falls back to the raw address when no symbol is found, matching the detail level of other perf callchain outputs.

Can you please exemplify before and after output in addition of just describing the changes?

- Arnaldo

Quoted 24 lines
---
 tools/perf/builtin-trace.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
tools/perf/builtin-trace.c +4 -2
index fe737b3ac6e6..20f3488d4a21 100644
@@ -2892,8 +2892,10 @@ static int trace__fprintf_callchain(struct trace *trace, struct perf_sample *sam
 {
 	/* TODO: user-configurable print_opts */
 	const unsigned int print_opts = EVSEL__PRINT_SYM |
-				        EVSEL__PRINT_DSO |
-				        EVSEL__PRINT_UNKNOWN_AS_ADDR;
+				EVSEL__PRINT_DSO |
+				EVSEL__PRINT_UNKNOWN_AS_ADDR |
+				EVSEL__PRINT_IP |
+				EVSEL__PRINT_SYMOFFSET;
 
 	return sample__fprintf_callchain(sample, 38, print_opts, get_tls_callchain_cursor(), symbol_conf.bt_stop_list, trace->output);
 }
Signature · 1 line
2.43.0