Skip to content

Commit 3add2d3

Browse files
committed
tracing: Have syscall trace events show "0x" for values greater than 10
Currently the syscall trace events show each value as hexadecimal, but without adding "0x" it can be confusing: sys_write(fd: 4, buf: 0x55c4a1fa9270, count: 44) Looks like the above write wrote 44 bytes, when in reality it wrote 68 bytes. Add a "0x" for all values greater or equal to 10 to remove the ambiguity. For values less than 10, leave off the "0x" as that just adds noise to the output. Also change the iterator to check if "i" is nonzero and print the ", " delimiter at the start, then adding the logic to the trace_seq_printf() at the end. Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Takaya Saeki <takayas@google.com> Cc: Tom Zanussi <zanussi@kernel.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ian Rogers <irogers@google.com> Cc: Douglas Raillard <douglas.raillard@arm.com> Link: https://lore.kernel.org/20250923130713.764558957@kernel.org Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent 17a1a10 commit 3add2d3

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

kernel/trace/trace_syscalls.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,20 @@ print_syscall_enter(struct trace_iterator *iter, int flags,
153153
if (trace_seq_has_overflowed(s))
154154
goto end;
155155

156+
if (i)
157+
trace_seq_puts(s, ", ");
158+
156159
/* parameter types */
157160
if (tr && tr->trace_flags & TRACE_ITER_VERBOSE)
158161
trace_seq_printf(s, "%s ", entry->types[i]);
159162

160163
/* parameter values */
161-
trace_seq_printf(s, "%s: %lx%s", entry->args[i],
162-
trace->args[i],
163-
i == entry->nb_args - 1 ? "" : ", ");
164+
if (trace->args[i] < 10)
165+
trace_seq_printf(s, "%s: %lu", entry->args[i],
166+
trace->args[i]);
167+
else
168+
trace_seq_printf(s, "%s: 0x%lx", entry->args[i],
169+
trace->args[i]);
164170
}
165171

166172
trace_seq_putc(s, ')');

0 commit comments

Comments
 (0)